-
-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce
Redacted<T>
module (#2856)
Co-authored-by: maksim.khramtsov <maksim.khramtsov@btsdigital.kz> Co-authored-by: Tim <hello@timsmart.co>
- Loading branch information
Showing
32 changed files
with
640 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@effect/cli": patch | ||
--- | ||
|
||
add .redacted apis to /cli package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"effect": minor | ||
--- | ||
|
||
Introduced `Redacted<out T = string>` module - `Secret` generalization | ||
`Secret extends Redacted` | ||
The use of the `Redacted` has been replaced by the use of the `Redacted` in packages with version `0.*.*` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@effect/schema": patch | ||
--- | ||
|
||
Added two related schemas `Redacted` and `RedactedFromSelf` | ||
`Secret` and `SecretFromSelf` marked as deprecated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* @since 3.3.0 | ||
*/ | ||
import type * as Equal from "./Equal.js" | ||
import * as Equivalence from "./Equivalence.js" | ||
import * as redacted_ from "./internal/redacted.js" | ||
import type { Pipeable } from "./Pipeable.js" | ||
import type { Covariant } from "./Types.js" | ||
|
||
/** | ||
* @since 3.3.0 | ||
* @category symbols | ||
*/ | ||
export const RedactedTypeId: unique symbol = redacted_.RedactedTypeId | ||
|
||
/** | ||
* @since 3.3.0 | ||
* @category symbols | ||
*/ | ||
export type RedactedTypeId = typeof RedactedTypeId | ||
|
||
/** | ||
* @since 3.3.0 | ||
* @category models | ||
*/ | ||
export interface Redacted<out A = string> extends Redacted.Variance<A>, Equal.Equal, Pipeable { | ||
} | ||
|
||
/** | ||
* @since 3.3.0 | ||
*/ | ||
export declare namespace Redacted { | ||
/** | ||
* @since 3.3.0 | ||
* @category models | ||
*/ | ||
export interface Variance<out A> { | ||
readonly [RedactedTypeId]: { | ||
readonly _A: Covariant<A> | ||
} | ||
} | ||
|
||
/** | ||
* @since 3.3.0 | ||
* @category type-level | ||
*/ | ||
export type Value<T extends Redacted<any>> = [T] extends [Redacted<infer _A>] ? _A : never | ||
} | ||
|
||
/** | ||
* @since 3.3.0 | ||
* @category refinements | ||
*/ | ||
export const isRedacted: (u: unknown) => u is Redacted<unknown> = redacted_.isRedacted | ||
|
||
/** | ||
* @since 3.3.0 | ||
* @category constructors | ||
*/ | ||
export const make: <A>(value: A) => Redacted<A> = redacted_.make | ||
|
||
/** | ||
* @since 3.3.0 | ||
* @category getters | ||
*/ | ||
export const value: <A>(self: Redacted<A>) => A = redacted_.value | ||
|
||
/** | ||
* @since 3.3.0 | ||
* @category unsafe | ||
*/ | ||
export const unsafeWipe: <A>(self: Redacted<A>) => boolean = redacted_.unsafeWipe | ||
|
||
/** | ||
* @category equivalence | ||
* @since 3.3.0 | ||
*/ | ||
export const getEquivalence = <A>(isEquivalent: Equivalence.Equivalence<A>): Equivalence.Equivalence<Redacted<A>> => | ||
Equivalence.make((x, y) => x === y || (isEquivalent(value(x), value(y)))) |
Oops, something went wrong.