effect 4.0.0-beta.75 → 4.0.0-beta.76

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 (95) hide show
  1. package/dist/Schema.d.ts +102 -40
  2. package/dist/Schema.d.ts.map +1 -1
  3. package/dist/Schema.js +149 -78
  4. package/dist/Schema.js.map +1 -1
  5. package/dist/SchemaAST.d.ts.map +1 -1
  6. package/dist/SchemaAST.js +2 -1
  7. package/dist/SchemaAST.js.map +1 -1
  8. package/dist/SchemaRepresentation.d.ts +10 -1
  9. package/dist/SchemaRepresentation.d.ts.map +1 -1
  10. package/dist/SchemaRepresentation.js +12 -5
  11. package/dist/SchemaRepresentation.js.map +1 -1
  12. package/dist/SchemaTransformation.d.ts.map +1 -1
  13. package/dist/SchemaTransformation.js +57 -18
  14. package/dist/SchemaTransformation.js.map +1 -1
  15. package/dist/internal/schema/representation.js +1 -0
  16. package/dist/internal/schema/representation.js.map +1 -1
  17. package/dist/unstable/ai/McpSchema.js +1 -1
  18. package/dist/unstable/ai/McpSchema.js.map +1 -1
  19. package/dist/unstable/cli/CliError.js +1 -1
  20. package/dist/unstable/cli/CliError.js.map +1 -1
  21. package/dist/unstable/cluster/ClusterError.js +2 -2
  22. package/dist/unstable/cluster/ClusterError.js.map +1 -1
  23. package/dist/unstable/cluster/Reply.js +1 -1
  24. package/dist/unstable/cluster/Reply.js.map +1 -1
  25. package/dist/unstable/devtools/DevToolsSchema.js +5 -1
  26. package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
  27. package/dist/unstable/http/HttpClientError.js +1 -1
  28. package/dist/unstable/http/HttpClientError.js.map +1 -1
  29. package/dist/unstable/httpapi/HttpApiScalar.d.ts +2 -0
  30. package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
  31. package/dist/unstable/httpapi/HttpApiScalar.js +12 -6
  32. package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
  33. package/dist/unstable/persistence/Persistable.js +1 -1
  34. package/dist/unstable/persistence/Persistable.js.map +1 -1
  35. package/dist/unstable/persistence/PersistedQueue.js +1 -1
  36. package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
  37. package/dist/unstable/persistence/Persistence.js +1 -1
  38. package/dist/unstable/persistence/Persistence.js.map +1 -1
  39. package/dist/unstable/persistence/RateLimiter.js +1 -1
  40. package/dist/unstable/persistence/RateLimiter.js.map +1 -1
  41. package/dist/unstable/persistence/Redis.js +1 -1
  42. package/dist/unstable/persistence/Redis.js.map +1 -1
  43. package/dist/unstable/reactivity/AsyncResult.js +1 -1
  44. package/dist/unstable/reactivity/AsyncResult.js.map +1 -1
  45. package/dist/unstable/rpc/Rpc.d.ts +1 -1
  46. package/dist/unstable/rpc/Rpc.js +2 -2
  47. package/dist/unstable/rpc/Rpc.js.map +1 -1
  48. package/dist/unstable/rpc/RpcClient.js +1 -1
  49. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  50. package/dist/unstable/rpc/RpcClientError.js +1 -1
  51. package/dist/unstable/rpc/RpcClientError.js.map +1 -1
  52. package/dist/unstable/rpc/RpcMessage.d.ts +2 -2
  53. package/dist/unstable/rpc/RpcMessage.js +3 -3
  54. package/dist/unstable/rpc/RpcMessage.js.map +1 -1
  55. package/dist/unstable/socket/Socket.js +3 -3
  56. package/dist/unstable/socket/Socket.js.map +1 -1
  57. package/dist/unstable/sql/SqlError.js +1 -1
  58. package/dist/unstable/sql/SqlError.js.map +1 -1
  59. package/dist/unstable/workers/WorkerError.js +4 -4
  60. package/dist/unstable/workers/WorkerError.js.map +1 -1
  61. package/dist/unstable/workflow/Activity.js +1 -1
  62. package/dist/unstable/workflow/Activity.js.map +1 -1
  63. package/dist/unstable/workflow/DurableDeferred.js +1 -1
  64. package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
  65. package/dist/unstable/workflow/Workflow.js +2 -2
  66. package/dist/unstable/workflow/Workflow.js.map +1 -1
  67. package/package.json +1 -1
  68. package/src/Schema.ts +179 -117
  69. package/src/SchemaAST.ts +3 -1
  70. package/src/SchemaRepresentation.ts +12 -4
  71. package/src/SchemaTransformation.ts +75 -25
  72. package/src/internal/schema/representation.ts +1 -0
  73. package/src/unstable/ai/McpSchema.ts +1 -1
  74. package/src/unstable/cli/CliError.ts +1 -1
  75. package/src/unstable/cluster/ClusterError.ts +2 -2
  76. package/src/unstable/cluster/Reply.ts +1 -1
  77. package/src/unstable/devtools/DevToolsSchema.ts +1 -1
  78. package/src/unstable/http/HttpClientError.ts +1 -1
  79. package/src/unstable/httpapi/HttpApiScalar.ts +14 -7
  80. package/src/unstable/persistence/Persistable.ts +1 -1
  81. package/src/unstable/persistence/PersistedQueue.ts +1 -1
  82. package/src/unstable/persistence/Persistence.ts +1 -1
  83. package/src/unstable/persistence/RateLimiter.ts +1 -1
  84. package/src/unstable/persistence/Redis.ts +1 -1
  85. package/src/unstable/reactivity/AsyncResult.ts +1 -1
  86. package/src/unstable/rpc/Rpc.ts +3 -3
  87. package/src/unstable/rpc/RpcClient.ts +1 -1
  88. package/src/unstable/rpc/RpcClientError.ts +1 -1
  89. package/src/unstable/rpc/RpcMessage.ts +3 -3
  90. package/src/unstable/socket/Socket.ts +3 -3
  91. package/src/unstable/sql/SqlError.ts +1 -1
  92. package/src/unstable/workers/WorkerError.ts +4 -4
  93. package/src/unstable/workflow/Activity.ts +1 -1
  94. package/src/unstable/workflow/DurableDeferred.ts +1 -1
  95. package/src/unstable/workflow/Workflow.ts +2 -2
package/dist/Schema.d.ts CHANGED
@@ -31,7 +31,7 @@
31
31
  * - Type guard: {@link is}
32
32
  * - Assertion: {@link asserts}
33
33
  * - Add constraints: `.check(...)` with filters like {@link isMinLength},
34
- * {@link isGreaterThan}, {@link isPattern}, {@link isUUID}
34
+ * {@link isGreaterThan}, {@link isPattern}, {@link isUUID}, {@link isGUID}
35
35
  * - Transform between schemas: {@link decodeTo}, {@link encodeTo}
36
36
  * - Add a default for missing keys: {@link withDecodingDefault}, {@link withDecodingDefaultKey}
37
37
  * - Create branded types: {@link brand}
@@ -4757,12 +4757,21 @@ export declare const isStringBigInt: (annotations?: Annotations.Filter) => Schem
4757
4757
  */
4758
4758
  export declare const isStringSymbol: (annotations?: Annotations.Filter) => SchemaAST.Filter<string>;
4759
4759
  /**
4760
- * Validates that a string is a valid Universally Unique Identifier (UUID).
4761
- * Optionally specify a version (1-8) to validate against a specific UUID version.
4762
- * If no version is specified (`undefined`), all versions are supported.
4760
+ * Validates that a string is a strict Universally Unique Identifier (UUID).
4761
+ *
4762
+ * **When to use**
4763
+ *
4764
+ * Use when you need UUID semantics, including version and RFC variant bits,
4765
+ * rather than only the dashed hexadecimal shape.
4763
4766
  *
4764
4767
  * **Details**
4765
4768
  *
4769
+ * Without a version argument, this accepts UUID versions 1 through 8, the nil
4770
+ * UUID (`00000000-0000-0000-0000-000000000000`), and the max UUID
4771
+ * (`ffffffff-ffff-ffff-ffff-ffffffffffff`). With a version argument, this
4772
+ * accepts only UUIDs with that version and RFC variant bits; nil and max UUIDs
4773
+ * are not versioned UUIDs and do not match version-specific checks.
4774
+ *
4766
4775
  * JSON Schema:
4767
4776
  *
4768
4777
  * This check corresponds to a `pattern` constraint in JSON Schema that matches
@@ -4773,10 +4782,36 @@ export declare const isStringSymbol: (annotations?: Annotations.Filter) => Schem
4773
4782
  * When generating test data with fast-check, this applies a `patterns`
4774
4783
  * constraint to ensure generated strings match the UUID pattern.
4775
4784
  *
4785
+ * @see {@link isGUID} for shape-only GUID validation.
4776
4786
  * @category String checks
4777
4787
  * @since 4.0.0
4778
4788
  */
4779
4789
  export declare function isUUID(version?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8, annotations?: Annotations.Filter): SchemaAST.Filter<string>;
4790
+ /**
4791
+ * Validates that a string has the GUID / UUID textual shape.
4792
+ *
4793
+ * **When to use**
4794
+ *
4795
+ * Use when you need to accept dashed hexadecimal identifiers without enforcing
4796
+ * UUID version or variant bits.
4797
+ *
4798
+ * **Details**
4799
+ *
4800
+ * This check accepts strings in the `8-4-4-4-12` hexadecimal form. JSON Schema
4801
+ * output includes the corresponding `pattern` constraint and intentionally does
4802
+ * not include `format: "uuid"` because GUID validation is looser than UUID
4803
+ * validation.
4804
+ *
4805
+ * Arbitrary:
4806
+ *
4807
+ * When generating test data with fast-check, this applies a `patterns`
4808
+ * constraint to ensure generated strings match the GUID pattern.
4809
+ *
4810
+ * @see {@link isUUID} for strict UUID validation.
4811
+ * @category String checks
4812
+ * @since 4.0.0
4813
+ */
4814
+ export declare function isGUID(annotations?: Annotations.Filter): SchemaAST.Filter<string>;
4780
4815
  /**
4781
4816
  * Validates that a string is a valid ULID (Universally Unique Lexicographically
4782
4817
  * Sortable Identifier).
@@ -6157,70 +6192,93 @@ export interface Error extends instanceOf<globalThis.Error> {
6157
6192
  readonly "Rebuild": Error;
6158
6193
  }
6159
6194
  /**
6160
- * Schema for JavaScript `Error` objects.
6161
- *
6162
- * **Details**
6163
- *
6164
- * Default JSON serializer:
6165
- * Encodes an `Error` as an object with `message` and optional `name` properties,
6166
- * and decodes that object back into an `Error`. The stack trace is omitted from
6167
- * the encoded form for security.
6195
+ * Options for {@link Error} and {@link Defect}.
6168
6196
  *
6169
- * @category schemas
6197
+ * @category options
6170
6198
  * @since 4.0.0
6171
6199
  */
6172
- export declare const Error: Error;
6200
+ export interface ErrorOptions {
6201
+ /**
6202
+ * Includes string stack traces in encoded `Error` values when set to `true`.
6203
+ *
6204
+ * @default false
6205
+ */
6206
+ readonly includeStack?: boolean | undefined;
6207
+ /**
6208
+ * Excludes `Error.cause` values from encoded `Error` values when set to
6209
+ * `true`.
6210
+ *
6211
+ * @default false
6212
+ */
6213
+ readonly excludeCause?: boolean | undefined;
6214
+ }
6173
6215
  /**
6174
- * Schema for JavaScript `Error` objects that preserves stack traces in the JSON
6175
- * encoded form.
6216
+ * Schema for JavaScript `Error` objects.
6176
6217
  *
6177
6218
  * **Details**
6178
6219
  *
6179
6220
  * Default JSON serializer:
6221
+ *
6180
6222
  * Encodes an `Error` as an object with `message`, optional `name`, and optional
6181
- * `stack` properties, and decodes that object back into an `Error`.
6223
+ * `cause` properties, and decodes that object back into an `Error`. Stack
6224
+ * traces are omitted by default for security. Pass `{ includeStack: true }` to
6225
+ * include stack traces, or `{ excludeCause: true }` to omit causes.
6182
6226
  *
6183
- * @category schemas
6227
+ * @category constructors
6184
6228
  * @since 4.0.0
6185
6229
  */
6186
- export declare const ErrorWithStack: Error;
6230
+ export declare function Error(options?: ErrorOptions): Error;
6187
6231
  /**
6188
6232
  * Type-level representation of {@link Defect}.
6189
6233
  *
6190
6234
  * @category Defect
6191
6235
  * @since 3.10.0
6192
6236
  */
6193
- export interface Defect extends Union<readonly [
6194
- decodeTo<Error, Struct<{
6195
- readonly message: String;
6196
- readonly name: optionalKey<String>;
6197
- readonly stack: optionalKey<String>;
6198
- }>>,
6199
- decodeTo<Unknown, Any>
6200
- ]> {
6237
+ export interface Defect extends decodeTo<Unknown, typeof Json> {
6201
6238
  readonly "Rebuild": Defect;
6202
6239
  }
6203
6240
  /**
6204
- * Schema for defect values, accepting either JavaScript `Error` values encoded
6205
- * with `message` and optional `name`, or arbitrary unknown defect values.
6241
+ * Schema for unexpected defect values represented as `unknown` with a JSON
6242
+ * encoded form.
6243
+ *
6244
+ * **When to use**
6245
+ *
6246
+ * Use when you need a schema for `Cause` defects or other unexpected failures
6247
+ * whose runtime value may be any value.
6206
6248
  *
6207
6249
  * **Details**
6208
6250
  *
6209
- * Default JSON serializer:
6210
- * Unknown defects are serialized with `JSON.stringify` when possible and fall
6211
- * back to Effect's formatted representation when JSON serialization fails.
6251
+ * The encoded side is {@link Json}. During decoding, JSON objects with a string
6252
+ * `message` property are decoded into JavaScript `Error` values, preserving a
6253
+ * non-default `name` and any string `stack`. Other JSON values decode
6254
+ * unchanged.
6212
6255
  *
6213
- * @category constructors
6214
- * @since 3.10.0
6215
- */
6216
- export declare const Defect: Defect;
6217
- /**
6218
- * Schema for defects that also includes stack traces in the encoded form.
6256
+ * During encoding, JavaScript `Error` values encode to JSON objects with
6257
+ * `name`, `message`, and optional `cause` properties. Pass
6258
+ * `{ includeStack: true }` to include string stack traces in encoded `Error`
6259
+ * defects, or `{ excludeCause: true }` to omit causes. Other values are
6260
+ * serialized through Effect's JSON formatter and then parsed back into JSON
6261
+ * when possible.
6219
6262
  *
6220
- * @category Defect
6263
+ * **Gotchas**
6264
+ *
6265
+ * This schema is for carrying defects across JSON boundaries, not for
6266
+ * preserving every JavaScript value exactly. Some values cannot round-trip
6267
+ * unchanged:
6268
+ *
6269
+ * - A non-`Error` object such as `{ message: "boom" }` encodes as an
6270
+ * error-shaped JSON object and decodes back as an `Error`.
6271
+ * - JSON serialization normalizes unsupported values. For example,
6272
+ * `undefined` array elements encode as `null`, unsupported object properties
6273
+ * are omitted, and circular references are dropped.
6274
+ * - Values that cannot be represented as JSON fall back to Effect's formatted
6275
+ * string representation.
6276
+ *
6277
+ * @see {@link Error} for a schema that only accepts JavaScript `Error` values.
6278
+ * @category constructors
6221
6279
  * @since 4.0.0
6222
6280
  */
6223
- export declare const DefectWithStack: Defect;
6281
+ export declare function Defect(options?: ErrorOptions): Defect;
6224
6282
  /**
6225
6283
  * Type-level representation returned by {@link Exit}.
6226
6284
  *
@@ -9361,6 +9419,10 @@ export declare namespace Annotations {
9361
9419
  readonly regExp: globalThis.RegExp;
9362
9420
  readonly version: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | undefined;
9363
9421
  };
9422
+ readonly isGUID: {
9423
+ readonly _tag: "isGUID";
9424
+ readonly regExp: globalThis.RegExp;
9425
+ };
9364
9426
  readonly isULID: {
9365
9427
  readonly _tag: "isULID";
9366
9428
  readonly regExp: globalThis.RegExp;