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.
Files changed (81) hide show
  1. package/dist/BigDecimal.d.ts.map +1 -1
  2. package/dist/BigDecimal.js +18 -14
  3. package/dist/BigDecimal.js.map +1 -1
  4. package/dist/BigInt.d.ts.map +1 -1
  5. package/dist/BigInt.js +4 -4
  6. package/dist/BigInt.js.map +1 -1
  7. package/dist/Brand.d.ts +2 -4
  8. package/dist/Brand.d.ts.map +1 -1
  9. package/dist/Brand.js.map +1 -1
  10. package/dist/Duration.js +1 -1
  11. package/dist/Duration.js.map +1 -1
  12. package/dist/Schema.d.ts +77 -9
  13. package/dist/Schema.d.ts.map +1 -1
  14. package/dist/Schema.js +37 -7
  15. package/dist/Schema.js.map +1 -1
  16. package/dist/SchemaAST.d.ts +6 -0
  17. package/dist/SchemaAST.d.ts.map +1 -1
  18. package/dist/SchemaAST.js +216 -229
  19. package/dist/SchemaAST.js.map +1 -1
  20. package/dist/SchemaGetter.d.ts +3 -5
  21. package/dist/SchemaGetter.d.ts.map +1 -1
  22. package/dist/SchemaGetter.js +3 -2
  23. package/dist/SchemaGetter.js.map +1 -1
  24. package/dist/SchemaIssue.d.ts.map +1 -1
  25. package/dist/SchemaIssue.js +29 -11
  26. package/dist/SchemaIssue.js.map +1 -1
  27. package/dist/SchemaParser.js +14 -2
  28. package/dist/SchemaParser.js.map +1 -1
  29. package/dist/internal/effect.js +142 -65
  30. package/dist/internal/effect.js.map +1 -1
  31. package/dist/unstable/cluster/Runners.d.ts.map +1 -1
  32. package/dist/unstable/cluster/Runners.js +3 -2
  33. package/dist/unstable/cluster/Runners.js.map +1 -1
  34. package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
  35. package/dist/unstable/cluster/SqlMessageStorage.js +1 -0
  36. package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
  37. package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
  38. package/dist/unstable/cluster/SqlRunnerStorage.js +6 -6
  39. package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
  40. package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -1
  41. package/dist/unstable/eventlog/SqlEventJournal.js +9 -8
  42. package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
  43. package/dist/unstable/eventlog/SqlEventLogServerEncrypted.d.ts.map +1 -1
  44. package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js +6 -5
  45. package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
  46. package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.d.ts.map +1 -1
  47. package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +6 -5
  48. package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
  49. package/dist/unstable/httpapi/OpenApi.d.ts +1 -10
  50. package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
  51. package/dist/unstable/httpapi/OpenApi.js +2 -11
  52. package/dist/unstable/httpapi/OpenApi.js.map +1 -1
  53. package/dist/unstable/observability/OtlpMetrics.js +1 -1
  54. package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
  55. package/dist/unstable/observability/internal/protobuf.js +4 -4
  56. package/dist/unstable/observability/internal/protobuf.js.map +1 -1
  57. package/dist/unstable/rpc/RpcSerialization.d.ts +11 -0
  58. package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
  59. package/dist/unstable/rpc/RpcSerialization.js +14 -9
  60. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  61. package/package.json +1 -1
  62. package/src/BigDecimal.ts +20 -16
  63. package/src/BigInt.ts +4 -4
  64. package/src/Brand.ts +2 -4
  65. package/src/Duration.ts +1 -1
  66. package/src/Schema.ts +87 -11
  67. package/src/SchemaAST.ts +315 -267
  68. package/src/SchemaGetter.ts +4 -6
  69. package/src/SchemaIssue.ts +28 -15
  70. package/src/SchemaParser.ts +8 -2
  71. package/src/internal/effect.ts +196 -69
  72. package/src/unstable/cluster/Runners.ts +8 -5
  73. package/src/unstable/cluster/SqlMessageStorage.ts +1 -0
  74. package/src/unstable/cluster/SqlRunnerStorage.ts +12 -6
  75. package/src/unstable/eventlog/SqlEventJournal.ts +10 -2
  76. package/src/unstable/eventlog/SqlEventLogServerEncrypted.ts +8 -3
  77. package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +9 -3
  78. package/src/unstable/httpapi/OpenApi.ts +2 -14
  79. package/src/unstable/observability/OtlpMetrics.ts +1 -1
  80. package/src/unstable/observability/internal/protobuf.ts +4 -4
  81. 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
- * `true`/`undefined` on success or a failure description on error.
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
- * // Check that a number is even
2464
- * const isEven = Schema.makeFilter(
2465
- * (n: number) => n % 2 === 0 || "expected an even number"
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
- * const EvenNumber = Schema.Number.check(isEven)
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(0n)).pipe(/*#__PURE__*/decodeTo(Duration, Transformation.durationFromNanos));
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