effect 4.0.0-beta.50 → 4.0.0-beta.51
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/Duration.js +1 -1
- package/dist/Duration.js.map +1 -1
- package/dist/Schema.d.ts +77 -9
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +37 -7
- 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/internal/effect.js +142 -65
- package/dist/internal/effect.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/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/Duration.ts +1 -1
- package/src/Schema.ts +87 -11
- 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/internal/effect.ts +196 -69
- 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/OpenApi.ts +2 -14
- 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/Schema.js
CHANGED
|
@@ -2454,18 +2454,47 @@ export function link() {
|
|
|
2454
2454
|
/**
|
|
2455
2455
|
* Creates a custom filter check from a predicate function. The predicate
|
|
2456
2456
|
* receives the input value, the schema's AST, and parse options, and returns
|
|
2457
|
-
*
|
|
2457
|
+
* a value of type {@link FilterOutput}.
|
|
2458
|
+
*
|
|
2459
|
+
* **Example** (Failure at a nested path)
|
|
2458
2460
|
*
|
|
2459
|
-
* **Example** (Custom filter check)
|
|
2460
2461
|
* ```ts
|
|
2461
2462
|
* import { Schema } from "effect"
|
|
2462
2463
|
*
|
|
2463
|
-
*
|
|
2464
|
-
*
|
|
2465
|
-
*
|
|
2464
|
+
* const schema = Schema.Struct({ password: Schema.String, confirmPassword: Schema.String }).check(
|
|
2465
|
+
* Schema.makeFilter((o) =>
|
|
2466
|
+
* o.password === o.confirmPassword
|
|
2467
|
+
* ? undefined
|
|
2468
|
+
* : { path: ["password"], issue: "password and confirmPassword must match" }
|
|
2469
|
+
* )
|
|
2470
|
+
* )
|
|
2471
|
+
*
|
|
2472
|
+
* console.log(String(Schema.decodeUnknownExit(schema)({ password: "123456", confirmPassword: "1234567" })))
|
|
2473
|
+
* // Failure(Cause([Fail(SchemaError: password and confirmPassword must match
|
|
2474
|
+
* // at ["password"])]))
|
|
2475
|
+
* ```
|
|
2476
|
+
*
|
|
2477
|
+
* **Example** (Reporting multiple failures at once)
|
|
2478
|
+
*
|
|
2479
|
+
* ```ts
|
|
2480
|
+
* import { Schema } from "effect"
|
|
2481
|
+
*
|
|
2482
|
+
* const schema = Schema.Struct({ a: Schema.Finite, b: Schema.Finite, c: Schema.Finite }).check(
|
|
2483
|
+
* Schema.makeFilter((o) => {
|
|
2484
|
+
* const issues: Array<Schema.FilterIssue> = []
|
|
2485
|
+
* if (o.a > 0) {
|
|
2486
|
+
* if (o.b <= 0) issues.push({ path: ["b"], issue: "b must be greater than 0" })
|
|
2487
|
+
* if (o.c <= 0) issues.push({ path: ["c"], issue: "c must be greater than 0" })
|
|
2488
|
+
* }
|
|
2489
|
+
* return issues
|
|
2490
|
+
* })
|
|
2466
2491
|
* )
|
|
2467
2492
|
*
|
|
2468
|
-
*
|
|
2493
|
+
* console.log(String(Schema.decodeUnknownExit(schema)({ a: 1, b: 0, c: 0 })))
|
|
2494
|
+
* // Failure(Cause([Fail(SchemaError: b must be greater than 0
|
|
2495
|
+
* // at ["b"]
|
|
2496
|
+
* // c must be greater than 0
|
|
2497
|
+
* // at ["c"])]))
|
|
2469
2498
|
* ```
|
|
2470
2499
|
*
|
|
2471
2500
|
* @category Checks Constructors
|
|
@@ -5287,6 +5316,7 @@ export const Duration = /*#__PURE__*/declare(Duration_.isDuration, {
|
|
|
5287
5316
|
toFormatter: () => globalThis.String,
|
|
5288
5317
|
toEquivalence: () => Duration_.Equivalence
|
|
5289
5318
|
});
|
|
5319
|
+
const bigint0 = /*#__PURE__*/globalThis.BigInt(0);
|
|
5290
5320
|
/**
|
|
5291
5321
|
* A transformation schema that decodes a non-negative `bigint` into a
|
|
5292
5322
|
* `Duration`, treating the `bigint` value as the duration in nanoseconds.
|
|
@@ -5300,7 +5330,7 @@ export const Duration = /*#__PURE__*/declare(Duration_.isDuration, {
|
|
|
5300
5330
|
* @category Duration
|
|
5301
5331
|
* @since 4.0.0
|
|
5302
5332
|
*/
|
|
5303
|
-
export const DurationFromNanos = /*#__PURE__*/BigInt.check(isGreaterThanOrEqualToBigInt(
|
|
5333
|
+
export const DurationFromNanos = /*#__PURE__*/BigInt.check(isGreaterThanOrEqualToBigInt(bigint0)).pipe(/*#__PURE__*/decodeTo(Duration, Transformation.durationFromNanos));
|
|
5304
5334
|
/**
|
|
5305
5335
|
* A transformation schema that decodes a non-negative (possibly infinite)
|
|
5306
5336
|
* integer into a `Duration`, treating the integer value as the duration in
|