effect 4.0.0-beta.50 → 4.0.0-beta.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +18 -14
- package/dist/BigDecimal.js.map +1 -1
- package/dist/BigInt.d.ts.map +1 -1
- package/dist/BigInt.js +4 -4
- package/dist/BigInt.js.map +1 -1
- package/dist/Brand.d.ts +2 -4
- package/dist/Brand.d.ts.map +1 -1
- package/dist/Brand.js.map +1 -1
- package/dist/Data.js +2 -2
- package/dist/Data.js.map +1 -1
- package/dist/Duration.js +1 -1
- package/dist/Duration.js.map +1 -1
- package/dist/Schema.d.ts +77 -10
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +119 -18
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +6 -0
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +216 -229
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +3 -5
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +3 -2
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.d.ts.map +1 -1
- package/dist/SchemaIssue.js +29 -11
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.js +14 -2
- package/dist/SchemaParser.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/effect.js +142 -65
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/schema/representation.js +1 -2
- package/dist/internal/schema/representation.js.map +1 -1
- package/dist/internal/schema/schema.d.ts.map +1 -1
- package/dist/internal/schema/schema.js +37 -0
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +7 -0
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/cli/index.d.ts +2 -0
- package/dist/unstable/cli/index.d.ts.map +1 -1
- package/dist/unstable/cli/index.js +2 -0
- package/dist/unstable/cli/index.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +3 -2
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +1 -0
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +6 -6
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.js +9 -8
- package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.d.ts.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js +6 -5
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.d.ts.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +6 -5
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +11 -6
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +5 -6
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +17 -18
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js +1 -2
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +28 -8
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +28 -15
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +4 -3
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +2 -2
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts +1 -10
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +2 -11
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.js +1 -1
- package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
- package/dist/unstable/observability/internal/protobuf.js +4 -4
- package/dist/unstable/observability/internal/protobuf.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts +11 -0
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +14 -9
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/package.json +1 -1
- package/src/BigDecimal.ts +20 -16
- package/src/BigInt.ts +4 -4
- package/src/Brand.ts +2 -4
- package/src/Data.ts +1 -1
- package/src/Duration.ts +1 -1
- package/src/Schema.ts +183 -23
- package/src/SchemaAST.ts +315 -267
- package/src/SchemaGetter.ts +4 -6
- package/src/SchemaIssue.ts +28 -15
- package/src/SchemaParser.ts +8 -2
- package/src/index.ts +3 -0
- package/src/internal/effect.ts +196 -69
- package/src/internal/schema/representation.ts +1 -2
- package/src/internal/schema/schema.ts +43 -0
- package/src/unstable/ai/McpServer.ts +8 -0
- package/src/unstable/cli/index.ts +2 -0
- package/src/unstable/cluster/Runners.ts +8 -5
- package/src/unstable/cluster/SqlMessageStorage.ts +1 -0
- package/src/unstable/cluster/SqlRunnerStorage.ts +12 -6
- package/src/unstable/eventlog/SqlEventJournal.ts +10 -2
- package/src/unstable/eventlog/SqlEventLogServerEncrypted.ts +8 -3
- package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +9 -3
- package/src/unstable/httpapi/HttpApi.ts +1 -1
- package/src/unstable/httpapi/HttpApiBuilder.ts +13 -6
- package/src/unstable/httpapi/HttpApiClient.ts +5 -6
- package/src/unstable/httpapi/HttpApiEndpoint.ts +6 -7
- package/src/unstable/httpapi/HttpApiError.ts +43 -22
- package/src/unstable/httpapi/HttpApiMiddleware.ts +6 -5
- package/src/unstable/httpapi/OpenApi.ts +3 -15
- package/src/unstable/observability/OtlpMetrics.ts +1 -1
- package/src/unstable/observability/internal/protobuf.ts +4 -4
- package/src/unstable/rpc/RpcSerialization.ts +41 -36
- package/dist/internal/schema/to-codec.d.ts +0 -2
- package/dist/internal/schema/to-codec.d.ts.map +0 -1
- package/dist/internal/schema/to-codec.js +0 -126
- package/dist/internal/schema/to-codec.js.map +0 -1
- package/src/internal/schema/to-codec.ts +0 -138
package/dist/Schema.d.ts
CHANGED
|
@@ -3629,7 +3629,6 @@ export declare function instanceOf<C extends abstract new (...args: any) => any,
|
|
|
3629
3629
|
* Used when building low-level AST transformations that bridge two schema types.
|
|
3630
3630
|
*
|
|
3631
3631
|
* @since 4.0.0
|
|
3632
|
-
* @experimental
|
|
3633
3632
|
*/
|
|
3634
3633
|
export declare function link<T>(): <To extends Top>(encodeTo: To, transformation: {
|
|
3635
3634
|
readonly decode: Getter.Getter<T, NoInfer<To["Type"]>>;
|
|
@@ -3638,27 +3637,95 @@ export declare function link<T>(): <To extends Top>(encodeTo: To, transformation
|
|
|
3638
3637
|
/**
|
|
3639
3638
|
* Creates a custom filter check from a predicate function. The predicate
|
|
3640
3639
|
* receives the input value, the schema's AST, and parse options, and returns
|
|
3641
|
-
*
|
|
3640
|
+
* a value of type {@link FilterOutput}.
|
|
3641
|
+
*
|
|
3642
|
+
* **Example** (Failure at a nested path)
|
|
3642
3643
|
*
|
|
3643
|
-
* **Example** (Custom filter check)
|
|
3644
3644
|
* ```ts
|
|
3645
3645
|
* import { Schema } from "effect"
|
|
3646
3646
|
*
|
|
3647
|
-
*
|
|
3648
|
-
*
|
|
3649
|
-
*
|
|
3647
|
+
* const schema = Schema.Struct({ password: Schema.String, confirmPassword: Schema.String }).check(
|
|
3648
|
+
* Schema.makeFilter((o) =>
|
|
3649
|
+
* o.password === o.confirmPassword
|
|
3650
|
+
* ? undefined
|
|
3651
|
+
* : { path: ["password"], issue: "password and confirmPassword must match" }
|
|
3652
|
+
* )
|
|
3653
|
+
* )
|
|
3654
|
+
*
|
|
3655
|
+
* console.log(String(Schema.decodeUnknownExit(schema)({ password: "123456", confirmPassword: "1234567" })))
|
|
3656
|
+
* // Failure(Cause([Fail(SchemaError: password and confirmPassword must match
|
|
3657
|
+
* // at ["password"])]))
|
|
3658
|
+
* ```
|
|
3659
|
+
*
|
|
3660
|
+
* **Example** (Reporting multiple failures at once)
|
|
3661
|
+
*
|
|
3662
|
+
* ```ts
|
|
3663
|
+
* import { Schema } from "effect"
|
|
3664
|
+
*
|
|
3665
|
+
* const schema = Schema.Struct({ a: Schema.Finite, b: Schema.Finite, c: Schema.Finite }).check(
|
|
3666
|
+
* Schema.makeFilter((o) => {
|
|
3667
|
+
* const issues: Array<Schema.FilterIssue> = []
|
|
3668
|
+
* if (o.a > 0) {
|
|
3669
|
+
* if (o.b <= 0) issues.push({ path: ["b"], issue: "b must be greater than 0" })
|
|
3670
|
+
* if (o.c <= 0) issues.push({ path: ["c"], issue: "c must be greater than 0" })
|
|
3671
|
+
* }
|
|
3672
|
+
* return issues
|
|
3673
|
+
* })
|
|
3650
3674
|
* )
|
|
3651
3675
|
*
|
|
3652
|
-
*
|
|
3676
|
+
* console.log(String(Schema.decodeUnknownExit(schema)({ a: 1, b: 0, c: 0 })))
|
|
3677
|
+
* // Failure(Cause([Fail(SchemaError: b must be greater than 0
|
|
3678
|
+
* // at ["b"]
|
|
3679
|
+
* // c must be greater than 0
|
|
3680
|
+
* // at ["c"])]))
|
|
3653
3681
|
* ```
|
|
3654
3682
|
*
|
|
3655
3683
|
* @category Checks Constructors
|
|
3656
3684
|
* @since 4.0.0
|
|
3657
3685
|
*/
|
|
3658
|
-
export declare const makeFilter: <T>(filter: (input: T, ast: AST.AST, options: AST.ParseOptions) =>
|
|
3686
|
+
export declare const makeFilter: <T>(filter: (input: T, ast: AST.AST, options: AST.ParseOptions) => FilterOutput, annotations?: Annotations.Filter | undefined, abort?: boolean) => AST.Filter<T>;
|
|
3687
|
+
/**
|
|
3688
|
+
* A single failure reported by a filter predicate. Used as the element type
|
|
3689
|
+
* of the array arm of {@link FilterOutput}, and also accepted on its own.
|
|
3690
|
+
*
|
|
3691
|
+
* - `string`: failure with that string as the message. Produces an
|
|
3692
|
+
* {@link Issue.InvalidValue} wrapping the input, with the string used as
|
|
3693
|
+
* the issue's `message` annotation.
|
|
3694
|
+
* - {@link Issue.Issue}: a fully-formed issue, returned as-is.
|
|
3695
|
+
* - `{ path, issue }`: failure attached to a nested path. `issue` is either
|
|
3696
|
+
* a `string` (wrapped in an {@link Issue.InvalidValue}) or a full
|
|
3697
|
+
* {@link Issue.Issue}; the result is wrapped in an {@link Issue.Pointer}
|
|
3698
|
+
* at the given `path`.
|
|
3699
|
+
*
|
|
3700
|
+
* @category model
|
|
3701
|
+
* @since 4.0.0
|
|
3702
|
+
*/
|
|
3703
|
+
export type FilterIssue = string | Issue.Issue | {
|
|
3659
3704
|
readonly path: ReadonlyArray<PropertyKey>;
|
|
3660
|
-
readonly
|
|
3661
|
-
}
|
|
3705
|
+
readonly issue: string | Issue.Issue;
|
|
3706
|
+
};
|
|
3707
|
+
/**
|
|
3708
|
+
* The value a filter predicate (see {@link makeFilter}) may return.
|
|
3709
|
+
*
|
|
3710
|
+
* Each shape is normalized into an {@link Issue.Issue} (or `undefined` for
|
|
3711
|
+
* success) before being attached to the parse result:
|
|
3712
|
+
*
|
|
3713
|
+
* - `undefined`: success. The input satisfies the filter.
|
|
3714
|
+
* - `true`: success. Equivalent to `undefined`, useful when the predicate is
|
|
3715
|
+
* a plain boolean expression.
|
|
3716
|
+
* - `false`: generic failure. Produces an {@link Issue.InvalidValue} wrapping
|
|
3717
|
+
* the input, with no custom message.
|
|
3718
|
+
* - {@link FilterIssue}: a single failure. See {@link FilterIssue} for the
|
|
3719
|
+
* shapes (`string`, {@link Issue.Issue}, or `{ path, issue }`).
|
|
3720
|
+
* - `ReadonlyArray<FilterIssue>`: several failures reported together. An
|
|
3721
|
+
* empty array is treated as success; a single-element array is equivalent
|
|
3722
|
+
* to returning that element directly; otherwise the entries are grouped
|
|
3723
|
+
* into an {@link Issue.Composite}.
|
|
3724
|
+
*
|
|
3725
|
+
* @category model
|
|
3726
|
+
* @since 4.0.0
|
|
3727
|
+
*/
|
|
3728
|
+
export type FilterOutput = undefined | boolean | FilterIssue | ReadonlyArray<FilterIssue>;
|
|
3662
3729
|
/**
|
|
3663
3730
|
* Groups multiple checks into a single {@link AST.FilterGroup}, applying
|
|
3664
3731
|
* optional shared annotations to the group as a whole.
|