effect 4.0.0-beta.85 → 4.0.0-beta.86
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/ChannelSchema.d.ts +8 -8
- package/dist/ChannelSchema.d.ts.map +1 -1
- package/dist/Config.d.ts +2 -2
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +10 -3
- package/dist/Config.js.map +1 -1
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +4 -0
- package/dist/Cron.js.map +1 -1
- package/dist/Schema.d.ts +745 -393
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +90 -64
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +20 -29
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaParser.d.ts +24 -24
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +43 -39
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +300 -300
- package/dist/internal/effect.js +6 -7
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/matcher.js +0 -2
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/schema/representation.js +1 -5
- package/dist/internal/schema/representation.js.map +1 -1
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +9 -9
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +3 -2
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +2 -2
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +1 -1
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +4 -4
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +13 -6
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +4 -4
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +2 -2
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Response.d.ts +2 -2
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +26 -26
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/cli/Argument.d.ts +8 -7
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/Flag.d.ts +8 -7
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/Param.d.ts +1806 -168
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +0 -70
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +3 -4
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/internal/ansi.d.ts.map +1 -1
- package/dist/unstable/cli/internal/ansi.js +0 -22
- package/dist/unstable/cli/internal/ansi.js.map +1 -1
- package/dist/unstable/cli/internal/config.d.ts +48 -0
- package/dist/unstable/cli/internal/config.d.ts.map +1 -1
- package/dist/unstable/cli/internal/config.js +0 -6
- package/dist/unstable/cli/internal/config.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -3
- package/dist/unstable/cluster/Reply.d.ts +2 -2
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/encoding/Msgpack.d.ts +6 -6
- package/dist/unstable/encoding/Msgpack.d.ts.map +1 -1
- package/dist/unstable/encoding/Msgpack.js.map +1 -1
- package/dist/unstable/encoding/Ndjson.d.ts +8 -8
- package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.d.ts +1 -1
- package/dist/unstable/encoding/Sse.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts +22 -22
- package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +15 -15
- package/dist/unstable/http/HttpBody.d.ts +1 -1
- package/dist/unstable/http/HttpBody.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +12 -3
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApi.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +2 -2
- 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 +32 -32
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +13 -6
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.js +0 -13
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/observability/internal/otlpProtobuf.js +0 -68
- package/dist/unstable/observability/internal/otlpProtobuf.js.map +1 -1
- package/dist/unstable/observability/internal/protobuf.js +0 -28
- package/dist/unstable/observability/internal/protobuf.js.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.d.ts +2 -2
- package/dist/unstable/persistence/KeyValueStore.d.ts.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
- package/dist/unstable/persistence/Persistable.d.ts +6 -6
- package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +3 -3
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts +5 -5
- package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.d.ts +2 -2
- package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +1 -1
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +3 -4
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +1 -1
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +25 -4
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcMessage.d.ts +7 -0
- package/dist/unstable/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMessage.js +20 -0
- package/dist/unstable/rpc/RpcMessage.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +2 -2
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +10 -3
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcWorker.d.ts +3 -3
- package/dist/unstable/rpc/RpcWorker.d.ts.map +1 -1
- package/dist/unstable/schema/Model.d.ts +2 -2
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +16 -2
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/sql/SqlConnection.d.ts +1 -0
- package/dist/unstable/sql/SqlConnection.d.ts.map +1 -1
- package/dist/unstable/sql/SqlConnection.js.map +1 -1
- package/dist/unstable/sql/SqlModel.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.d.ts +4 -4
- package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/sql/SqlSchema.d.ts +5 -5
- package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.d.ts +1 -0
- package/dist/unstable/sql/Statement.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.js +3 -0
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +2 -2
- package/dist/unstable/workflow/Activity.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.d.ts +18 -18
- package/dist/unstable/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +3 -3
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +3 -3
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ChannelSchema.ts +9 -9
- package/src/Config.ts +12 -5
- package/src/Cron.ts +4 -0
- package/src/Schema.ts +963 -688
- package/src/SchemaAST.ts +25 -35
- package/src/SchemaParser.ts +85 -77
- package/src/internal/effect.ts +6 -22
- package/src/internal/matcher.ts +0 -5
- package/src/internal/schema/arbitrary.ts +1 -1
- package/src/internal/schema/representation.ts +1 -5
- package/src/internal/schema/schema.ts +1 -1
- package/src/testing/TestSchema.ts +14 -13
- package/src/unstable/ai/AnthropicStructuredOutput.ts +2 -2
- package/src/unstable/ai/Chat.ts +1 -1
- package/src/unstable/ai/LanguageModel.ts +7 -7
- package/src/unstable/ai/McpSchema.ts +16 -14
- package/src/unstable/ai/McpServer.ts +7 -7
- package/src/unstable/ai/OpenAiStructuredOutput.ts +2 -2
- package/src/unstable/ai/Response.ts +9 -5
- package/src/unstable/ai/Tool.ts +49 -47
- package/src/unstable/cli/Argument.ts +9 -8
- package/src/unstable/cli/Flag.ts +9 -8
- package/src/unstable/cli/Param.ts +6 -146
- package/src/unstable/cli/Primitive.ts +5 -6
- package/src/unstable/cli/internal/ansi.ts +0 -33
- package/src/unstable/cli/internal/config.ts +0 -8
- package/src/unstable/cli/internal/parser.ts +2 -2
- package/src/unstable/cluster/MessageStorage.ts +1 -1
- package/src/unstable/cluster/Reply.ts +6 -2
- package/src/unstable/devtools/DevToolsSchema.ts +1 -1
- package/src/unstable/encoding/Msgpack.ts +9 -7
- package/src/unstable/encoding/Ndjson.ts +10 -10
- package/src/unstable/encoding/Sse.ts +1 -1
- package/src/unstable/eventlog/Event.ts +3 -3
- package/src/unstable/http/HttpBody.ts +1 -1
- package/src/unstable/http/HttpClientRequest.ts +1 -1
- package/src/unstable/http/HttpIncomingMessage.ts +1 -1
- package/src/unstable/http/HttpMiddleware.ts +12 -3
- package/src/unstable/httpapi/HttpApi.ts +1 -1
- package/src/unstable/httpapi/HttpApiBuilder.ts +9 -5
- package/src/unstable/httpapi/HttpApiClient.ts +10 -10
- package/src/unstable/httpapi/HttpApiEndpoint.ts +45 -33
- package/src/unstable/httpapi/HttpApiMiddleware.ts +2 -2
- package/src/unstable/httpapi/HttpApiSchema.ts +16 -43
- package/src/unstable/httpapi/OpenApi.ts +5 -5
- package/src/unstable/observability/internal/otlpProtobuf.ts +0 -75
- package/src/unstable/observability/internal/protobuf.ts +0 -42
- package/src/unstable/persistence/KeyValueStore.ts +2 -2
- package/src/unstable/persistence/Persistable.ts +7 -7
- package/src/unstable/persistence/PersistedQueue.ts +3 -3
- package/src/unstable/persistence/Persistence.ts +5 -5
- package/src/unstable/reactivity/AsyncResult.ts +4 -4
- package/src/unstable/reactivity/Atom.ts +1 -1
- package/src/unstable/reactivity/AtomHttpApi.ts +1 -1
- package/src/unstable/rpc/Rpc.ts +7 -8
- package/src/unstable/rpc/RpcClient.ts +26 -4
- package/src/unstable/rpc/RpcMessage.ts +19 -0
- package/src/unstable/rpc/RpcMiddleware.ts +2 -2
- package/src/unstable/rpc/RpcSchema.ts +12 -9
- package/src/unstable/rpc/RpcWorker.ts +3 -3
- package/src/unstable/schema/Model.ts +2 -2
- package/src/unstable/schema/VariantSchema.ts +19 -17
- package/src/unstable/sql/SqlConnection.ts +5 -0
- package/src/unstable/sql/SqlModel.ts +2 -2
- package/src/unstable/sql/SqlResolver.ts +6 -6
- package/src/unstable/sql/SqlSchema.ts +5 -5
- package/src/unstable/sql/Statement.ts +11 -0
- package/src/unstable/workflow/Activity.ts +6 -6
- package/src/unstable/workflow/DurableDeferred.ts +33 -33
- package/src/unstable/workflow/Workflow.ts +5 -5
- package/src/unstable/workflow/WorkflowEngine.ts +10 -10
- package/dist/internal/concurrency.d.ts +0 -2
- package/dist/internal/concurrency.d.ts.map +0 -1
- package/dist/internal/concurrency.js +0 -29
- package/dist/internal/concurrency.js.map +0 -1
- package/src/internal/concurrency.ts +0 -52
package/src/Schema.ts
CHANGED
|
@@ -126,19 +126,13 @@ export interface MakeOptions {
|
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
128
|
* The fully-parameterized base interface for all schemas. Exposes all 14 type
|
|
129
|
-
* parameters controlling type inference, mutability, optionality, services,
|
|
130
|
-
*
|
|
129
|
+
* parameters controlling type inference, mutability, optionality, services, and
|
|
130
|
+
* transformation behavior.
|
|
131
131
|
*
|
|
132
132
|
* **When to use**
|
|
133
133
|
*
|
|
134
|
-
* Use when you are writing advanced generic schema utilities or performing
|
|
135
|
-
* introspection.
|
|
136
|
-
* - In user code, prefer {@link Schema}, {@link Codec}, {@link Decoder}, or
|
|
137
|
-
* {@link Encoder} instead.
|
|
138
|
-
*
|
|
139
|
-
* @see {@link Top} — the existential "any schema" type (erased type params)
|
|
140
|
-
* @see {@link Schema} — tracks only the decoded Type
|
|
141
|
-
* @see {@link Codec} — tracks Type + Encoded
|
|
134
|
+
* Use when you are writing advanced generic schema utilities or performing
|
|
135
|
+
* schema introspection.
|
|
142
136
|
*
|
|
143
137
|
* @category models
|
|
144
138
|
* @since 4.0.0
|
|
@@ -152,7 +146,7 @@ export interface Bottom<
|
|
|
152
146
|
out Rebuild extends Top,
|
|
153
147
|
out TypeMakeIn = T,
|
|
154
148
|
out Iso = T,
|
|
155
|
-
in out TypeParameters extends ReadonlyArray<
|
|
149
|
+
in out TypeParameters extends ReadonlyArray<Constraint> = readonly [],
|
|
156
150
|
out TypeMake = TypeMakeIn,
|
|
157
151
|
out TypeMutability extends Mutability = "readonly",
|
|
158
152
|
out TypeOptionality extends Optionality = "required",
|
|
@@ -248,13 +242,67 @@ export interface Bottom<
|
|
|
248
242
|
makeEffect(input: this["~type.make.in"], options?: MakeOptions): Effect.Effect<this["Type"], SchemaError>
|
|
249
243
|
}
|
|
250
244
|
|
|
245
|
+
/**
|
|
246
|
+
* Lazy `Bottom` variant for schema implementations that compute their public
|
|
247
|
+
* views on demand.
|
|
248
|
+
*
|
|
249
|
+
* **When to use**
|
|
250
|
+
*
|
|
251
|
+
* Use as an implementation base for schema interfaces that must expose
|
|
252
|
+
* `Bottom` behavior without forcing TypeScript to eagerly evaluate expensive
|
|
253
|
+
* `Type`, `Encoded`, or service views.
|
|
254
|
+
*
|
|
255
|
+
* **Details**
|
|
256
|
+
*
|
|
257
|
+
* The laziness is purely type-level; runtime behavior is unchanged.
|
|
258
|
+
* `BottomLazy` keeps the structural operations inherited from `Bottom`, but
|
|
259
|
+
* erases the expensive schema views to `unknown`. Concrete schema interfaces can
|
|
260
|
+
* then redeclare the precise views they expose. This keeps wide schemas such as
|
|
261
|
+
* `Struct` and `Union` cheaper when generic code reads a single view, while
|
|
262
|
+
* preserving their exact public types.
|
|
263
|
+
*
|
|
264
|
+
* @see {@link Bottom} for the fully parameterized schema interface when every
|
|
265
|
+
* view must be supplied directly.
|
|
266
|
+
*
|
|
267
|
+
* @category utility types
|
|
268
|
+
* @since 4.0.0
|
|
269
|
+
*/
|
|
270
|
+
export interface BottomLazy<
|
|
271
|
+
out Ast extends SchemaAST.AST,
|
|
272
|
+
out Rebuild extends Top,
|
|
273
|
+
in out TypeParameters extends ReadonlyArray<Constraint> = readonly [],
|
|
274
|
+
out TypeMutability extends Mutability = "readonly",
|
|
275
|
+
out TypeOptionality extends Optionality = "required",
|
|
276
|
+
out TypeConstructorDefault extends ConstructorDefault = "no-default",
|
|
277
|
+
out EncodedMutability extends Mutability = "readonly",
|
|
278
|
+
out EncodedOptionality extends Optionality = "required"
|
|
279
|
+
> extends
|
|
280
|
+
Bottom<
|
|
281
|
+
unknown,
|
|
282
|
+
unknown,
|
|
283
|
+
unknown,
|
|
284
|
+
unknown,
|
|
285
|
+
Ast,
|
|
286
|
+
Rebuild,
|
|
287
|
+
unknown,
|
|
288
|
+
unknown,
|
|
289
|
+
TypeParameters,
|
|
290
|
+
unknown,
|
|
291
|
+
TypeMutability,
|
|
292
|
+
TypeOptionality,
|
|
293
|
+
TypeConstructorDefault,
|
|
294
|
+
EncodedMutability,
|
|
295
|
+
EncodedOptionality
|
|
296
|
+
>
|
|
297
|
+
{}
|
|
298
|
+
|
|
251
299
|
/**
|
|
252
300
|
* Type-level representation returned by {@link declareConstructor}.
|
|
253
301
|
*
|
|
254
302
|
* @category constructors
|
|
255
303
|
* @since 4.0.0
|
|
256
304
|
*/
|
|
257
|
-
export interface declareConstructor<T, E, TypeParameters extends ReadonlyArray<
|
|
305
|
+
export interface declareConstructor<T, E, TypeParameters extends ReadonlyArray<Constraint>, Iso = T> extends
|
|
258
306
|
Bottom<
|
|
259
307
|
T,
|
|
260
308
|
E,
|
|
@@ -301,7 +349,7 @@ export interface declareConstructor<T, E, TypeParameters extends ReadonlyArray<T
|
|
|
301
349
|
* const isBox = (u: unknown): u is Box<unknown> =>
|
|
302
350
|
* typeof u === "object" && u !== null && "value" in u
|
|
303
351
|
*
|
|
304
|
-
* const Box = <A extends Schema.
|
|
352
|
+
* const Box = <A extends Schema.Constraint>(item: A) =>
|
|
305
353
|
* Schema.declareConstructor<Box<A["Type"]>, Box<A["Encoded"]>>()(
|
|
306
354
|
* [item],
|
|
307
355
|
* ([itemCodec]) =>
|
|
@@ -323,7 +371,7 @@ export interface declareConstructor<T, E, TypeParameters extends ReadonlyArray<T
|
|
|
323
371
|
* @since 4.0.0
|
|
324
372
|
*/
|
|
325
373
|
export function declareConstructor<T, E = T, Iso = T>() {
|
|
326
|
-
return <const TypeParameters extends ReadonlyArray<
|
|
374
|
+
return <const TypeParameters extends ReadonlyArray<Constraint>>(
|
|
327
375
|
typeParameters: TypeParameters,
|
|
328
376
|
run: (
|
|
329
377
|
typeParameters: {
|
|
@@ -566,8 +614,8 @@ export function annotateKey<S extends Top>(annotations: Annotations.Key<S["Type"
|
|
|
566
614
|
* In user code prefer the narrower interfaces:
|
|
567
615
|
* - {@link Schema}`<T>` — when you only care about the decoded type
|
|
568
616
|
* - {@link Codec}`<T, E, RD, RE>` — when you need the encoded type and service requirements
|
|
569
|
-
* - {@link
|
|
570
|
-
* - {@link
|
|
617
|
+
* - {@link ConstraintDecoder}`<T, RD>` — for decode-only APIs
|
|
618
|
+
* - {@link ConstraintEncoder}`<E, RE>` — for encode-only APIs
|
|
571
619
|
*
|
|
572
620
|
* @category models
|
|
573
621
|
* @since 4.0.0
|
|
@@ -592,6 +640,127 @@ export interface Top extends
|
|
|
592
640
|
>
|
|
593
641
|
{}
|
|
594
642
|
|
|
643
|
+
/**
|
|
644
|
+
* Lightweight structural constraint for APIs that accept schema values but only
|
|
645
|
+
* read their data and type-level views.
|
|
646
|
+
*
|
|
647
|
+
* **When to use**
|
|
648
|
+
*
|
|
649
|
+
* Use when you need to constrain a generic value to be a schema, but the API
|
|
650
|
+
* only reads properties such as `ast`, `Type`, `Encoded`, service
|
|
651
|
+
* requirements, constructor input views, or modifier flags.
|
|
652
|
+
*
|
|
653
|
+
* **Details**
|
|
654
|
+
*
|
|
655
|
+
* `Constraint` keeps the schema type identifier and the property surface needed
|
|
656
|
+
* by schema constructors, while avoiding the full `Bottom` protocol. Use
|
|
657
|
+
* {@link Top} when an API calls schema methods such as `annotate`, `check`,
|
|
658
|
+
* `rebuild`, `make`, or `makeEffect`.
|
|
659
|
+
*
|
|
660
|
+
* @see {@link Top} for the complete schema protocol.
|
|
661
|
+
*
|
|
662
|
+
* @category models
|
|
663
|
+
* @since 4.0.0
|
|
664
|
+
*/
|
|
665
|
+
export interface Constraint {
|
|
666
|
+
readonly [TypeId]: typeof TypeId
|
|
667
|
+
readonly "ast": SchemaAST.AST
|
|
668
|
+
|
|
669
|
+
readonly "Type": unknown
|
|
670
|
+
readonly "Encoded": unknown
|
|
671
|
+
readonly "DecodingServices": unknown
|
|
672
|
+
readonly "EncodingServices": unknown
|
|
673
|
+
|
|
674
|
+
readonly "~type.parameters": any
|
|
675
|
+
readonly "~type.make.in": unknown
|
|
676
|
+
readonly "~type.make": unknown
|
|
677
|
+
readonly "Iso": unknown
|
|
678
|
+
|
|
679
|
+
readonly "~type.optionality": Optionality
|
|
680
|
+
readonly "~type.mutability": Mutability
|
|
681
|
+
readonly "~type.constructor.default": ConstructorDefault
|
|
682
|
+
readonly "~encoded.optionality": Optionality
|
|
683
|
+
readonly "~encoded.mutability": Mutability
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* Lightweight structural constraint for APIs that need codec type views but do
|
|
688
|
+
* not need the full schema protocol.
|
|
689
|
+
*
|
|
690
|
+
* **When to use**
|
|
691
|
+
*
|
|
692
|
+
* Use when you need to preserve decoded type, encoded type, and service
|
|
693
|
+
* requirements for a schema value, but the API does not call schema methods
|
|
694
|
+
* such as `annotate`, `check`, `rebuild`, `make`, or `makeEffect`.
|
|
695
|
+
*
|
|
696
|
+
* @see {@link Constraint} for the generic lightweight schema constraint.
|
|
697
|
+
* @see {@link Codec} for the full schema protocol with codec type views.
|
|
698
|
+
*
|
|
699
|
+
* @category models
|
|
700
|
+
* @since 4.0.0
|
|
701
|
+
*/
|
|
702
|
+
export interface ConstraintCodec<out T, out E = T, out RD = never, out RE = never> extends Constraint {
|
|
703
|
+
readonly "Type": T
|
|
704
|
+
readonly "Encoded": E
|
|
705
|
+
readonly "DecodingServices": RD
|
|
706
|
+
readonly "EncodingServices": RE
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Lightweight structural constraint for APIs that need decoder type views but
|
|
711
|
+
* do not need the full schema protocol.
|
|
712
|
+
*
|
|
713
|
+
* **When to use**
|
|
714
|
+
*
|
|
715
|
+
* Use when you need to preserve a schema's decoded type and decoding services,
|
|
716
|
+
* but the API does not constrain the encoded type, encoding services, or call
|
|
717
|
+
* schema methods such as `annotate`, `check`, `rebuild`, `make`, or
|
|
718
|
+
* `makeEffect`.
|
|
719
|
+
*
|
|
720
|
+
* @see {@link ConstraintCodec} for APIs that need both decoded and encoded codec views.
|
|
721
|
+
* @see {@link Codec} for the full schema protocol with codec type views.
|
|
722
|
+
*
|
|
723
|
+
* @category models
|
|
724
|
+
* @since 4.0.0
|
|
725
|
+
*/
|
|
726
|
+
export interface ConstraintDecoder<out T, out RD = never> extends ConstraintCodec<T, unknown, RD, unknown> {}
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* Lightweight structural constraint for APIs that need encoder type views but
|
|
730
|
+
* do not need the full schema protocol.
|
|
731
|
+
*
|
|
732
|
+
* **When to use**
|
|
733
|
+
*
|
|
734
|
+
* Use when you need to preserve a schema's encoded type and encoding services,
|
|
735
|
+
* but the API does not constrain the decoded type, decoding services, or call
|
|
736
|
+
* schema methods such as `annotate`, `check`, `rebuild`, `make`, or
|
|
737
|
+
* `makeEffect`.
|
|
738
|
+
*
|
|
739
|
+
* @see {@link ConstraintCodec} for APIs that need both decoded and encoded codec views.
|
|
740
|
+
* @see {@link Codec} for the full schema protocol with codec type views.
|
|
741
|
+
*
|
|
742
|
+
* @category models
|
|
743
|
+
* @since 4.0.0
|
|
744
|
+
*/
|
|
745
|
+
export interface ConstraintEncoder<out E, out RE = never> extends ConstraintCodec<unknown, E, unknown, RE> {}
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* Lightweight structural constraint for APIs that need schema views and the
|
|
749
|
+
* rebuilt schema type, but do not call the full schema protocol.
|
|
750
|
+
*
|
|
751
|
+
* **When to use**
|
|
752
|
+
*
|
|
753
|
+
* Use when an API needs to read `Rebuild` in addition to the schema views
|
|
754
|
+
* exposed by {@link Constraint}, but does not call methods such as `annotate`,
|
|
755
|
+
* `check`, `rebuild`, `make`, or `makeEffect`.
|
|
756
|
+
*
|
|
757
|
+
* @category models
|
|
758
|
+
* @since 4.0.0
|
|
759
|
+
*/
|
|
760
|
+
export interface ConstraintRebuildable extends Constraint {
|
|
761
|
+
readonly "Rebuild": Constraint
|
|
762
|
+
}
|
|
763
|
+
|
|
595
764
|
/**
|
|
596
765
|
* Namespace of type-level helpers for {@link Schema}.
|
|
597
766
|
*
|
|
@@ -614,7 +783,7 @@ export declare namespace Schema {
|
|
|
614
783
|
* @category utility types
|
|
615
784
|
* @since 3.10.0
|
|
616
785
|
*/
|
|
617
|
-
export type Type<S> = S extends
|
|
786
|
+
export type Type<S> = S extends { readonly "Type": infer T } ? T : never
|
|
618
787
|
}
|
|
619
788
|
|
|
620
789
|
/**
|
|
@@ -674,7 +843,8 @@ export declare namespace Codec {
|
|
|
674
843
|
* @category utility types
|
|
675
844
|
* @since 3.10.0
|
|
676
845
|
*/
|
|
677
|
-
export type Encoded<S> = S extends
|
|
846
|
+
export type Encoded<S> = S extends { readonly "Encoded": infer E } ? E : never
|
|
847
|
+
|
|
678
848
|
/**
|
|
679
849
|
* Extracts the Effect services required during *decoding* from a schema.
|
|
680
850
|
*
|
|
@@ -691,7 +861,8 @@ export declare namespace Codec {
|
|
|
691
861
|
* @category utility types
|
|
692
862
|
* @since 4.0.0
|
|
693
863
|
*/
|
|
694
|
-
export type DecodingServices<S> = S extends
|
|
864
|
+
export type DecodingServices<S> = S extends { readonly "DecodingServices": infer R } ? R : never
|
|
865
|
+
|
|
695
866
|
/**
|
|
696
867
|
* Extracts the Effect services required during *encoding* from a schema.
|
|
697
868
|
*
|
|
@@ -708,7 +879,7 @@ export declare namespace Codec {
|
|
|
708
879
|
* @category utility types
|
|
709
880
|
* @since 4.0.0
|
|
710
881
|
*/
|
|
711
|
-
export type EncodingServices<S> = S extends
|
|
882
|
+
export type EncodingServices<S> = S extends { readonly "EncodingServices": infer R } ? R : never
|
|
712
883
|
}
|
|
713
884
|
|
|
714
885
|
/**
|
|
@@ -747,8 +918,8 @@ export interface Optic<out T, out Iso> extends Schema<T> {
|
|
|
747
918
|
* Most concrete schemas produced by this module implement `Codec`.
|
|
748
919
|
*
|
|
749
920
|
* For APIs that only need one direction, prefer the narrower views:
|
|
750
|
-
* - {@link
|
|
751
|
-
* - {@link
|
|
921
|
+
* - {@link ConstraintDecoder}`<T, RD>` — decode-only
|
|
922
|
+
* - {@link ConstraintEncoder}`<E, RE>` — encode-only
|
|
752
923
|
* - {@link Schema}`<T>` — type-only (no encoded representation)
|
|
753
924
|
*
|
|
754
925
|
* **Example** (Accepting a codec that decodes to `number` from `string`)
|
|
@@ -776,60 +947,6 @@ export interface Codec<out T, out E = T, out RD = never, out RE = never> extends
|
|
|
776
947
|
readonly "Rebuild": Codec<T, E, RD, RE>
|
|
777
948
|
}
|
|
778
949
|
|
|
779
|
-
/**
|
|
780
|
-
* A {@link Codec} view for APIs that only *decode* (parse/validate) values.
|
|
781
|
-
*
|
|
782
|
-
* **Details**
|
|
783
|
-
*
|
|
784
|
-
* Use `Decoder<T, RD>` to accept "any schema that can decode to `T`" without
|
|
785
|
-
* constraining or depending on the encoded representation (`Encoded` is
|
|
786
|
-
* `unknown`) or encoding services.
|
|
787
|
-
*
|
|
788
|
-
* **Example** (Accepting schemas that only need to decode)
|
|
789
|
-
*
|
|
790
|
-
* ```ts
|
|
791
|
-
* import { Schema } from "effect"
|
|
792
|
-
*
|
|
793
|
-
* declare function validate<T>(decoder: Schema.Decoder<T>): (input: unknown) => T
|
|
794
|
-
*
|
|
795
|
-
* validate(Schema.String) // ok
|
|
796
|
-
* validate(Schema.NumberFromString) // ok
|
|
797
|
-
* ```
|
|
798
|
-
*
|
|
799
|
-
* @category models
|
|
800
|
-
* @since 4.0.0
|
|
801
|
-
*/
|
|
802
|
-
export interface Decoder<out T, out RD = never> extends Codec<T, unknown, RD, unknown> {
|
|
803
|
-
readonly "Rebuild": Decoder<T, RD>
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
/**
|
|
807
|
-
* A {@link Codec} view for APIs that only *encode* values.
|
|
808
|
-
*
|
|
809
|
-
* **Details**
|
|
810
|
-
*
|
|
811
|
-
* Use `Encoder<E, RE>` to accept "any schema that can encode to `E`" without
|
|
812
|
-
* constraining or depending on the decoded `Type` (`Type` is `unknown`) or
|
|
813
|
-
* decoding services.
|
|
814
|
-
*
|
|
815
|
-
* **Example** (Accepting schemas that only need to encode)
|
|
816
|
-
*
|
|
817
|
-
* ```ts
|
|
818
|
-
* import { Schema } from "effect"
|
|
819
|
-
*
|
|
820
|
-
* declare function serialize<E>(encoder: Schema.Encoder<E>): (value: unknown) => E
|
|
821
|
-
*
|
|
822
|
-
* serialize(Schema.String) // ok — encodes to string
|
|
823
|
-
* serialize(Schema.NumberFromString) // ok — encodes number to string
|
|
824
|
-
* ```
|
|
825
|
-
*
|
|
826
|
-
* @category models
|
|
827
|
-
* @since 4.0.0
|
|
828
|
-
*/
|
|
829
|
-
export interface Encoder<out E, out RE = never> extends Codec<unknown, E, unknown, RE> {
|
|
830
|
-
readonly "Rebuild": Encoder<E, RE>
|
|
831
|
-
}
|
|
832
|
-
|
|
833
950
|
/**
|
|
834
951
|
* Returns a codec widened to the full {@link Codec} interface, prompting
|
|
835
952
|
* TypeScript to infer all four type parameters (`T`, `E`, `RD`, `RE`).
|
|
@@ -987,7 +1104,7 @@ function makeStandardResult<A>(exit: Exit_.Exit<StandardSchemaV1.Result<A>>): St
|
|
|
987
1104
|
* @category Standard Schema
|
|
988
1105
|
* @since 4.0.0
|
|
989
1106
|
*/
|
|
990
|
-
export function toStandardSchemaV1<S extends
|
|
1107
|
+
export function toStandardSchemaV1<S extends ConstraintDecoder<unknown>>(
|
|
991
1108
|
self: S,
|
|
992
1109
|
options?: {
|
|
993
1110
|
readonly leafHook?: SchemaIssue.LeafHook | undefined
|
|
@@ -1037,7 +1154,7 @@ export function toStandardSchemaV1<S extends Decoder<unknown>>(
|
|
|
1037
1154
|
}
|
|
1038
1155
|
}
|
|
1039
1156
|
|
|
1040
|
-
function toBaseStandardJSONSchemaV1(self:
|
|
1157
|
+
function toBaseStandardJSONSchemaV1(self: Constraint, target: StandardJSONSchemaV1.Target): JsonSchema.JsonSchema {
|
|
1041
1158
|
const doc2020_12 = toJsonSchemaDocument(self)
|
|
1042
1159
|
if (target === "draft-2020-12") {
|
|
1043
1160
|
const schema = doc2020_12.schema
|
|
@@ -1066,7 +1183,9 @@ function toBaseStandardJSONSchemaV1(self: Top, target: StandardJSONSchemaV1.Targ
|
|
|
1066
1183
|
* @category Standard Schema
|
|
1067
1184
|
* @since 4.0.0
|
|
1068
1185
|
*/
|
|
1069
|
-
export function toStandardJSONSchemaV1<S extends
|
|
1186
|
+
export function toStandardJSONSchemaV1<S extends Constraint>(
|
|
1187
|
+
self: S
|
|
1188
|
+
): StandardJSONSchemaV1<S["Encoded"], S["Type"]> & S {
|
|
1070
1189
|
const jsonSchema: StandardJSONSchemaV1.Props<S["Encoded"], S["Type"]>["jsonSchema"] = {
|
|
1071
1190
|
input(options) {
|
|
1072
1191
|
return toBaseStandardJSONSchemaV1(self, options.target)
|
|
@@ -1173,7 +1292,8 @@ export const is = SchemaParser.is
|
|
|
1173
1292
|
* @category guards
|
|
1174
1293
|
* @since 4.0.0
|
|
1175
1294
|
*/
|
|
1176
|
-
export const asserts: <S extends
|
|
1295
|
+
export const asserts: <S extends Constraint, I>(schema: S, input: I) => asserts input is I & S["Type"] =
|
|
1296
|
+
SchemaParser.asserts
|
|
1177
1297
|
|
|
1178
1298
|
/**
|
|
1179
1299
|
* Decodes an `unknown` input against a schema, returning an `Effect` that
|
|
@@ -1196,7 +1316,7 @@ export const asserts: <S extends Top, I>(schema: S, input: I) => asserts input i
|
|
|
1196
1316
|
* @category decoding
|
|
1197
1317
|
* @since 4.0.0
|
|
1198
1318
|
*/
|
|
1199
|
-
export function decodeUnknownEffect<S extends
|
|
1319
|
+
export function decodeUnknownEffect<S extends Constraint>(schema: S, options?: SchemaAST.ParseOptions) {
|
|
1200
1320
|
const parser = SchemaParser.decodeUnknownEffect(schema, options)
|
|
1201
1321
|
return (
|
|
1202
1322
|
input: unknown,
|
|
@@ -1227,7 +1347,7 @@ export function decodeUnknownEffect<S extends Top>(schema: S, options?: SchemaAS
|
|
|
1227
1347
|
* @category decoding
|
|
1228
1348
|
* @since 4.0.0
|
|
1229
1349
|
*/
|
|
1230
|
-
export const decodeEffect: <S extends
|
|
1350
|
+
export const decodeEffect: <S extends Constraint>(
|
|
1231
1351
|
schema: S,
|
|
1232
1352
|
options?: SchemaAST.ParseOptions
|
|
1233
1353
|
) => (
|
|
@@ -1303,7 +1423,7 @@ function runSchemaErrorSync<A>(
|
|
|
1303
1423
|
* @category decoding
|
|
1304
1424
|
* @since 4.0.0
|
|
1305
1425
|
*/
|
|
1306
|
-
export function decodeUnknownExit<S extends
|
|
1426
|
+
export function decodeUnknownExit<S extends ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
|
|
1307
1427
|
const parser = SchemaParser.decodeUnknownExit(schema, options)
|
|
1308
1428
|
return (input: unknown, options?: SchemaAST.ParseOptions): Exit_.Exit<S["Type"], SchemaError> => {
|
|
1309
1429
|
return InternalSchema.mapSchemaIssueExit(parser(input, options))
|
|
@@ -1340,7 +1460,7 @@ export function decodeUnknownExit<S extends Decoder<unknown>>(schema: S, options
|
|
|
1340
1460
|
* @category decoding
|
|
1341
1461
|
* @since 4.0.0
|
|
1342
1462
|
*/
|
|
1343
|
-
export const decodeExit: <S extends
|
|
1463
|
+
export const decodeExit: <S extends ConstraintDecoder<unknown>>(
|
|
1344
1464
|
schema: S,
|
|
1345
1465
|
options?: SchemaAST.ParseOptions
|
|
1346
1466
|
) => (input: S["Encoded"], options?: SchemaAST.ParseOptions) => Exit_.Exit<S["Type"], SchemaError> = decodeUnknownExit
|
|
@@ -1371,7 +1491,7 @@ export const decodeExit: <S extends Decoder<unknown>>(
|
|
|
1371
1491
|
* @category decoding
|
|
1372
1492
|
* @since 3.10.0
|
|
1373
1493
|
*/
|
|
1374
|
-
export const decodeUnknownOption: <S extends
|
|
1494
|
+
export const decodeUnknownOption: <S extends ConstraintDecoder<unknown>>(
|
|
1375
1495
|
schema: S,
|
|
1376
1496
|
options?: SchemaAST.ParseOptions
|
|
1377
1497
|
) => (input: unknown, options?: SchemaAST.ParseOptions) => Option_.Option<S["Type"]> = SchemaParser.decodeUnknownOption
|
|
@@ -1401,10 +1521,10 @@ export const decodeUnknownOption: <S extends Decoder<unknown>>(
|
|
|
1401
1521
|
* @category decoding
|
|
1402
1522
|
* @since 3.10.0
|
|
1403
1523
|
*/
|
|
1404
|
-
export const decodeOption: <S extends
|
|
1524
|
+
export const decodeOption: <S extends ConstraintDecoder<unknown>>(
|
|
1405
1525
|
schema: S,
|
|
1406
1526
|
options?: SchemaAST.ParseOptions
|
|
1407
|
-
) => (input: S["Encoded"], options?: SchemaAST.ParseOptions) => Option_.Option<S["Type"]> =
|
|
1527
|
+
) => (input: S["Encoded"], options?: SchemaAST.ParseOptions) => Option_.Option<S["Type"]> = SchemaParser.decodeOption
|
|
1408
1528
|
|
|
1409
1529
|
/**
|
|
1410
1530
|
* Decodes an `unknown` input against a schema, returning a `Result` that
|
|
@@ -1435,7 +1555,7 @@ export const decodeOption: <S extends Decoder<unknown>>(
|
|
|
1435
1555
|
* @category decoding
|
|
1436
1556
|
* @since 4.0.0
|
|
1437
1557
|
*/
|
|
1438
|
-
export function decodeUnknownResult<S extends
|
|
1558
|
+
export function decodeUnknownResult<S extends ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
|
|
1439
1559
|
const parser = SchemaParser.decodeUnknownResult(schema, options)
|
|
1440
1560
|
return (input: unknown, options?: SchemaAST.ParseOptions): Result_.Result<S["Type"], SchemaError> => {
|
|
1441
1561
|
return Result_.mapError(parser(input, options), (issue) => new SchemaError(issue))
|
|
@@ -1470,7 +1590,7 @@ export function decodeUnknownResult<S extends Decoder<unknown>>(schema: S, optio
|
|
|
1470
1590
|
* @category decoding
|
|
1471
1591
|
* @since 4.0.0
|
|
1472
1592
|
*/
|
|
1473
|
-
export const decodeResult: <S extends
|
|
1593
|
+
export const decodeResult: <S extends ConstraintDecoder<unknown>>(
|
|
1474
1594
|
schema: S,
|
|
1475
1595
|
options?: SchemaAST.ParseOptions
|
|
1476
1596
|
) => (input: S["Encoded"], options?: SchemaAST.ParseOptions) => Result_.Result<S["Type"], SchemaError> =
|
|
@@ -1503,7 +1623,10 @@ export const decodeResult: <S extends Decoder<unknown>>(
|
|
|
1503
1623
|
* @category decoding
|
|
1504
1624
|
* @since 3.10.0
|
|
1505
1625
|
*/
|
|
1506
|
-
export function decodeUnknownPromise<S extends
|
|
1626
|
+
export function decodeUnknownPromise<S extends ConstraintDecoder<unknown>>(
|
|
1627
|
+
schema: S,
|
|
1628
|
+
options?: SchemaAST.ParseOptions
|
|
1629
|
+
) {
|
|
1507
1630
|
const parser = decodeUnknownEffect(schema, options)
|
|
1508
1631
|
return (input: unknown, options?: SchemaAST.ParseOptions): Promise<S["Type"]> => {
|
|
1509
1632
|
return runSchemaErrorPromise(parser(input, options))
|
|
@@ -1537,7 +1660,7 @@ export function decodeUnknownPromise<S extends Decoder<unknown>>(schema: S, opti
|
|
|
1537
1660
|
* @category decoding
|
|
1538
1661
|
* @since 3.10.0
|
|
1539
1662
|
*/
|
|
1540
|
-
export const decodePromise: <S extends
|
|
1663
|
+
export const decodePromise: <S extends ConstraintDecoder<unknown>>(
|
|
1541
1664
|
schema: S,
|
|
1542
1665
|
options?: SchemaAST.ParseOptions
|
|
1543
1666
|
) => (input: S["Encoded"], options?: SchemaAST.ParseOptions) => Promise<S["Type"]> = decodeUnknownPromise
|
|
@@ -1586,7 +1709,7 @@ export const decodePromise: <S extends Decoder<unknown>>(
|
|
|
1586
1709
|
* @category decoding
|
|
1587
1710
|
* @since 4.0.0
|
|
1588
1711
|
*/
|
|
1589
|
-
export function decodeUnknownSync<S extends
|
|
1712
|
+
export function decodeUnknownSync<S extends ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
|
|
1590
1713
|
const parser = decodeUnknownEffect(schema, options)
|
|
1591
1714
|
return (input: unknown, options?: SchemaAST.ParseOptions): S["Type"] => {
|
|
1592
1715
|
return runSchemaErrorSync(parser(input, options))
|
|
@@ -1619,7 +1742,7 @@ export function decodeUnknownSync<S extends Decoder<unknown>>(schema: S, options
|
|
|
1619
1742
|
* @category decoding
|
|
1620
1743
|
* @since 4.0.0
|
|
1621
1744
|
*/
|
|
1622
|
-
export const decodeSync: <S extends
|
|
1745
|
+
export const decodeSync: <S extends ConstraintDecoder<unknown>>(
|
|
1623
1746
|
schema: S,
|
|
1624
1747
|
options?: SchemaAST.ParseOptions
|
|
1625
1748
|
) => (input: S["Encoded"], options?: SchemaAST.ParseOptions) => S["Type"] = decodeUnknownSync
|
|
@@ -1656,7 +1779,7 @@ export const decodeSync: <S extends Decoder<unknown>>(
|
|
|
1656
1779
|
* @category encoding
|
|
1657
1780
|
* @since 4.0.0
|
|
1658
1781
|
*/
|
|
1659
|
-
export function encodeUnknownEffect<S extends
|
|
1782
|
+
export function encodeUnknownEffect<S extends Constraint>(schema: S, options?: SchemaAST.ParseOptions) {
|
|
1660
1783
|
const parser = SchemaParser.encodeUnknownEffect(schema, options)
|
|
1661
1784
|
return (
|
|
1662
1785
|
input: unknown,
|
|
@@ -1687,7 +1810,7 @@ export function encodeUnknownEffect<S extends Top>(schema: S, options?: SchemaAS
|
|
|
1687
1810
|
* @category encoding
|
|
1688
1811
|
* @since 4.0.0
|
|
1689
1812
|
*/
|
|
1690
|
-
export const encodeEffect: <S extends
|
|
1813
|
+
export const encodeEffect: <S extends Constraint>(
|
|
1691
1814
|
schema: S,
|
|
1692
1815
|
options?: SchemaAST.ParseOptions
|
|
1693
1816
|
) => (
|
|
@@ -1724,7 +1847,7 @@ export const encodeEffect: <S extends Top>(
|
|
|
1724
1847
|
* @category encoding
|
|
1725
1848
|
* @since 4.0.0
|
|
1726
1849
|
*/
|
|
1727
|
-
export function encodeUnknownExit<S extends
|
|
1850
|
+
export function encodeUnknownExit<S extends ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
|
|
1728
1851
|
const parser = SchemaParser.encodeUnknownExit(schema, options)
|
|
1729
1852
|
return (input: unknown, options?: SchemaAST.ParseOptions): Exit_.Exit<S["Encoded"], SchemaError> => {
|
|
1730
1853
|
return InternalSchema.mapSchemaIssueExit(parser(input, options))
|
|
@@ -1761,7 +1884,7 @@ export function encodeUnknownExit<S extends Encoder<unknown>>(schema: S, options
|
|
|
1761
1884
|
* @category encoding
|
|
1762
1885
|
* @since 4.0.0
|
|
1763
1886
|
*/
|
|
1764
|
-
export const encodeExit: <S extends
|
|
1887
|
+
export const encodeExit: <S extends ConstraintEncoder<unknown>>(
|
|
1765
1888
|
schema: S,
|
|
1766
1889
|
options?: SchemaAST.ParseOptions
|
|
1767
1890
|
) => (input: S["Type"], options?: SchemaAST.ParseOptions) => Exit_.Exit<S["Encoded"], SchemaError> = encodeUnknownExit
|
|
@@ -1792,7 +1915,7 @@ export const encodeExit: <S extends Encoder<unknown>>(
|
|
|
1792
1915
|
* @category encoding
|
|
1793
1916
|
* @since 3.10.0
|
|
1794
1917
|
*/
|
|
1795
|
-
export const encodeUnknownOption: <S extends
|
|
1918
|
+
export const encodeUnknownOption: <S extends ConstraintEncoder<unknown>>(
|
|
1796
1919
|
schema: S,
|
|
1797
1920
|
options?: SchemaAST.ParseOptions
|
|
1798
1921
|
) => (input: unknown, options?: SchemaAST.ParseOptions) => Option_.Option<S["Encoded"]> =
|
|
@@ -1823,10 +1946,10 @@ export const encodeUnknownOption: <S extends Encoder<unknown>>(
|
|
|
1823
1946
|
* @category encoding
|
|
1824
1947
|
* @since 3.10.0
|
|
1825
1948
|
*/
|
|
1826
|
-
export const encodeOption: <S extends
|
|
1949
|
+
export const encodeOption: <S extends ConstraintEncoder<unknown>>(
|
|
1827
1950
|
schema: S,
|
|
1828
1951
|
options?: SchemaAST.ParseOptions
|
|
1829
|
-
) => (input: S["Type"], options?: SchemaAST.ParseOptions) => Option_.Option<S["Encoded"]> =
|
|
1952
|
+
) => (input: S["Type"], options?: SchemaAST.ParseOptions) => Option_.Option<S["Encoded"]> = SchemaParser.encodeOption
|
|
1830
1953
|
|
|
1831
1954
|
/**
|
|
1832
1955
|
* Encodes an `unknown` input against a schema, returning a `Result` that
|
|
@@ -1856,7 +1979,7 @@ export const encodeOption: <S extends Encoder<unknown>>(
|
|
|
1856
1979
|
* @category encoding
|
|
1857
1980
|
* @since 4.0.0
|
|
1858
1981
|
*/
|
|
1859
|
-
export function encodeUnknownResult<S extends
|
|
1982
|
+
export function encodeUnknownResult<S extends ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
|
|
1860
1983
|
const parser = SchemaParser.encodeUnknownResult(schema, options)
|
|
1861
1984
|
return (input: unknown, options?: SchemaAST.ParseOptions): Result_.Result<S["Encoded"], SchemaError> => {
|
|
1862
1985
|
return Result_.mapError(parser(input, options), (issue) => new SchemaError(issue))
|
|
@@ -1891,7 +2014,7 @@ export function encodeUnknownResult<S extends Encoder<unknown>>(schema: S, optio
|
|
|
1891
2014
|
* @category encoding
|
|
1892
2015
|
* @since 4.0.0
|
|
1893
2016
|
*/
|
|
1894
|
-
export const encodeResult: <S extends
|
|
2017
|
+
export const encodeResult: <S extends ConstraintEncoder<unknown>>(
|
|
1895
2018
|
schema: S,
|
|
1896
2019
|
options?: SchemaAST.ParseOptions
|
|
1897
2020
|
) => (input: S["Type"], options?: SchemaAST.ParseOptions) => Result_.Result<S["Encoded"], SchemaError> =
|
|
@@ -1923,7 +2046,10 @@ export const encodeResult: <S extends Encoder<unknown>>(
|
|
|
1923
2046
|
* @category encoding
|
|
1924
2047
|
* @since 3.10.0
|
|
1925
2048
|
*/
|
|
1926
|
-
export function encodeUnknownPromise<S extends
|
|
2049
|
+
export function encodeUnknownPromise<S extends ConstraintEncoder<unknown>>(
|
|
2050
|
+
schema: S,
|
|
2051
|
+
options?: SchemaAST.ParseOptions
|
|
2052
|
+
) {
|
|
1927
2053
|
const parser = encodeUnknownEffect(schema, options)
|
|
1928
2054
|
return (input: unknown, options?: SchemaAST.ParseOptions): Promise<S["Encoded"]> => {
|
|
1929
2055
|
return runSchemaErrorPromise(parser(input, options))
|
|
@@ -1957,7 +2083,7 @@ export function encodeUnknownPromise<S extends Encoder<unknown>>(schema: S, opti
|
|
|
1957
2083
|
* @category encoding
|
|
1958
2084
|
* @since 3.10.0
|
|
1959
2085
|
*/
|
|
1960
|
-
export const encodePromise: <S extends
|
|
2086
|
+
export const encodePromise: <S extends ConstraintEncoder<unknown>>(
|
|
1961
2087
|
schema: S,
|
|
1962
2088
|
options?: SchemaAST.ParseOptions
|
|
1963
2089
|
) => (input: S["Type"], options?: SchemaAST.ParseOptions) => Promise<S["Encoded"]> = encodeUnknownPromise
|
|
@@ -1988,7 +2114,7 @@ export const encodePromise: <S extends Encoder<unknown>>(
|
|
|
1988
2114
|
* @category encoding
|
|
1989
2115
|
* @since 4.0.0
|
|
1990
2116
|
*/
|
|
1991
|
-
export function encodeUnknownSync<S extends
|
|
2117
|
+
export function encodeUnknownSync<S extends ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
|
|
1992
2118
|
const parser = encodeUnknownEffect(schema, options)
|
|
1993
2119
|
return (input: unknown, options?: SchemaAST.ParseOptions): S["Encoded"] => {
|
|
1994
2120
|
return runSchemaErrorSync(parser(input, options) as Effect.Effect<S["Encoded"], SchemaError>)
|
|
@@ -2019,7 +2145,7 @@ export function encodeUnknownSync<S extends Encoder<unknown>>(schema: S, options
|
|
|
2019
2145
|
* @category encoding
|
|
2020
2146
|
* @since 4.0.0
|
|
2021
2147
|
*/
|
|
2022
|
-
export const encodeSync: <S extends
|
|
2148
|
+
export const encodeSync: <S extends ConstraintEncoder<unknown>>(
|
|
2023
2149
|
schema: S,
|
|
2024
2150
|
options?: SchemaAST.ParseOptions
|
|
2025
2151
|
) => (input: S["Type"], options?: SchemaAST.ParseOptions) => S["Encoded"] = encodeUnknownSync
|
|
@@ -2041,7 +2167,7 @@ export const encodeSync: <S extends Encoder<unknown>>(
|
|
|
2041
2167
|
* @category constructors
|
|
2042
2168
|
* @since 3.10.0
|
|
2043
2169
|
*/
|
|
2044
|
-
export const make: <S extends
|
|
2170
|
+
export const make: <S extends Constraint>(ast: S["ast"], options?: object) => S = InternalSchema.make
|
|
2045
2171
|
|
|
2046
2172
|
/**
|
|
2047
2173
|
* Transforms a schema into a class that can be extended with `extends`. The
|
|
@@ -2086,18 +2212,11 @@ export function isSchema(u: unknown): u is Top {
|
|
|
2086
2212
|
* @category models
|
|
2087
2213
|
* @since 4.0.0
|
|
2088
2214
|
*/
|
|
2089
|
-
export interface optionalKey<S extends
|
|
2090
|
-
|
|
2091
|
-
S["Type"],
|
|
2092
|
-
S["Encoded"],
|
|
2093
|
-
S["DecodingServices"],
|
|
2094
|
-
S["EncodingServices"],
|
|
2215
|
+
export interface optionalKey<S extends Constraint> extends
|
|
2216
|
+
BottomLazy<
|
|
2095
2217
|
S["ast"],
|
|
2096
2218
|
optionalKey<S>,
|
|
2097
|
-
S["~type.make.in"],
|
|
2098
|
-
S["Iso"],
|
|
2099
2219
|
S["~type.parameters"],
|
|
2100
|
-
S["~type.make"],
|
|
2101
2220
|
S["~type.mutability"],
|
|
2102
2221
|
"optional",
|
|
2103
2222
|
S["~type.constructor.default"],
|
|
@@ -2105,12 +2224,19 @@ export interface optionalKey<S extends Top> extends
|
|
|
2105
2224
|
"optional"
|
|
2106
2225
|
>
|
|
2107
2226
|
{
|
|
2227
|
+
readonly "Type": S["Type"]
|
|
2228
|
+
readonly "Encoded": S["Encoded"]
|
|
2229
|
+
readonly "DecodingServices": S["DecodingServices"]
|
|
2230
|
+
readonly "EncodingServices": S["EncodingServices"]
|
|
2231
|
+
readonly "~type.make.in": S["~type.make.in"]
|
|
2232
|
+
readonly "~type.make": S["~type.make"]
|
|
2233
|
+
readonly "Iso": S["Iso"]
|
|
2108
2234
|
readonly schema: S
|
|
2109
2235
|
}
|
|
2110
2236
|
|
|
2111
2237
|
interface optionalKeyLambda extends Lambda {
|
|
2112
|
-
<S extends
|
|
2113
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
2238
|
+
<S extends Constraint>(self: S): optionalKey<S>
|
|
2239
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint ? optionalKey<this["~lambda.in"]> : never
|
|
2114
2240
|
}
|
|
2115
2241
|
|
|
2116
2242
|
/**
|
|
@@ -2140,8 +2266,8 @@ export const optionalKey = Struct_.lambda<optionalKeyLambda>((schema) =>
|
|
|
2140
2266
|
)
|
|
2141
2267
|
|
|
2142
2268
|
interface requiredKeyLambda extends Lambda {
|
|
2143
|
-
<S extends
|
|
2144
|
-
readonly "~lambda.out": this["~lambda.in"] extends optionalKey<
|
|
2269
|
+
<S extends Constraint>(self: optionalKey<S>): S
|
|
2270
|
+
readonly "~lambda.out": this["~lambda.in"] extends optionalKey<Constraint> ? this["~lambda.in"]["schema"]
|
|
2145
2271
|
: "Error: schema not eligible for requiredKey"
|
|
2146
2272
|
}
|
|
2147
2273
|
|
|
@@ -2164,13 +2290,13 @@ export const requiredKey = Struct_.lambda<requiredKeyLambda>((self) => self.sche
|
|
|
2164
2290
|
* @category models
|
|
2165
2291
|
* @since 3.10.0
|
|
2166
2292
|
*/
|
|
2167
|
-
export interface optional<S extends
|
|
2293
|
+
export interface optional<S extends Constraint> extends optionalKey<UndefinedOr<S>> {
|
|
2168
2294
|
readonly "Rebuild": optional<S>
|
|
2169
2295
|
}
|
|
2170
2296
|
|
|
2171
2297
|
interface optionalLambda extends Lambda {
|
|
2172
|
-
<S extends
|
|
2173
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
2298
|
+
<S extends Constraint>(self: S): optional<S>
|
|
2299
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint ? optional<this["~lambda.in"]> : never
|
|
2174
2300
|
}
|
|
2175
2301
|
|
|
2176
2302
|
/**
|
|
@@ -2205,8 +2331,8 @@ interface optionalLambda extends Lambda {
|
|
|
2205
2331
|
export const optional = Struct_.lambda<optionalLambda>((self) => optionalKey(UndefinedOr(self)))
|
|
2206
2332
|
|
|
2207
2333
|
interface requiredLambda extends Lambda {
|
|
2208
|
-
<S extends
|
|
2209
|
-
readonly "~lambda.out": this["~lambda.in"] extends optional<
|
|
2334
|
+
<S extends Constraint>(self: optional<S>): S
|
|
2335
|
+
readonly "~lambda.out": this["~lambda.in"] extends optional<Constraint> ? this["~lambda.in"]["schema"]["members"][0]
|
|
2210
2336
|
: "Error: schema not eligible for required"
|
|
2211
2337
|
}
|
|
2212
2338
|
|
|
@@ -2233,18 +2359,11 @@ export const required = Struct_.lambda<requiredLambda>((self) => self.schema.mem
|
|
|
2233
2359
|
* @category models
|
|
2234
2360
|
* @since 4.0.0
|
|
2235
2361
|
*/
|
|
2236
|
-
export interface mutableKey<S extends
|
|
2237
|
-
|
|
2238
|
-
S["Type"],
|
|
2239
|
-
S["Encoded"],
|
|
2240
|
-
S["DecodingServices"],
|
|
2241
|
-
S["EncodingServices"],
|
|
2362
|
+
export interface mutableKey<S extends Constraint> extends
|
|
2363
|
+
BottomLazy<
|
|
2242
2364
|
S["ast"],
|
|
2243
2365
|
mutableKey<S>,
|
|
2244
|
-
S["~type.make.in"],
|
|
2245
|
-
S["Iso"],
|
|
2246
2366
|
S["~type.parameters"],
|
|
2247
|
-
S["~type.make"],
|
|
2248
2367
|
"mutable",
|
|
2249
2368
|
S["~type.optionality"],
|
|
2250
2369
|
S["~type.constructor.default"],
|
|
@@ -2252,12 +2371,19 @@ export interface mutableKey<S extends Top> extends
|
|
|
2252
2371
|
S["~encoded.optionality"]
|
|
2253
2372
|
>
|
|
2254
2373
|
{
|
|
2374
|
+
readonly "Type": S["Type"]
|
|
2375
|
+
readonly "Encoded": S["Encoded"]
|
|
2376
|
+
readonly "DecodingServices": S["DecodingServices"]
|
|
2377
|
+
readonly "EncodingServices": S["EncodingServices"]
|
|
2378
|
+
readonly "~type.make.in": S["~type.make.in"]
|
|
2379
|
+
readonly "~type.make": S["~type.make"]
|
|
2380
|
+
readonly "Iso": S["Iso"]
|
|
2255
2381
|
readonly schema: S
|
|
2256
2382
|
}
|
|
2257
2383
|
|
|
2258
2384
|
interface mutableKeyLambda extends Lambda {
|
|
2259
|
-
<S extends
|
|
2260
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
2385
|
+
<S extends Constraint>(self: S): mutableKey<S>
|
|
2386
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint ? mutableKey<this["~lambda.in"]> : never
|
|
2261
2387
|
}
|
|
2262
2388
|
|
|
2263
2389
|
/**
|
|
@@ -2272,8 +2398,8 @@ export const mutableKey = Struct_.lambda<mutableKeyLambda>((schema) =>
|
|
|
2272
2398
|
)
|
|
2273
2399
|
|
|
2274
2400
|
interface readonlyKeyLambda extends Lambda {
|
|
2275
|
-
<S extends
|
|
2276
|
-
readonly "~lambda.out": this["~lambda.in"] extends mutableKey<
|
|
2401
|
+
<S extends Constraint>(self: mutableKey<S>): S
|
|
2402
|
+
readonly "~lambda.out": this["~lambda.in"] extends mutableKey<Constraint> ? this["~lambda.in"]["schema"]
|
|
2277
2403
|
: "Error: schema not eligible for readonlyKey"
|
|
2278
2404
|
}
|
|
2279
2405
|
|
|
@@ -2296,29 +2422,30 @@ export const readonlyKey = Struct_.lambda<readonlyKeyLambda>((self) => self.sche
|
|
|
2296
2422
|
* @category transforming
|
|
2297
2423
|
* @since 4.0.0
|
|
2298
2424
|
*/
|
|
2299
|
-
export interface toType<S extends
|
|
2300
|
-
|
|
2301
|
-
S["Type"],
|
|
2302
|
-
S["Type"],
|
|
2303
|
-
never,
|
|
2304
|
-
never,
|
|
2425
|
+
export interface toType<S extends Constraint> extends
|
|
2426
|
+
BottomLazy<
|
|
2305
2427
|
S["ast"],
|
|
2306
2428
|
toType<S>,
|
|
2307
|
-
S["~type.make.in"],
|
|
2308
|
-
S["Iso"],
|
|
2309
2429
|
S["~type.parameters"],
|
|
2310
|
-
S["~type.make"],
|
|
2311
2430
|
S["~type.mutability"],
|
|
2312
2431
|
S["~type.optionality"],
|
|
2313
2432
|
S["~type.constructor.default"],
|
|
2314
2433
|
S["~encoded.mutability"],
|
|
2315
2434
|
S["~encoded.optionality"]
|
|
2316
2435
|
>
|
|
2317
|
-
{
|
|
2436
|
+
{
|
|
2437
|
+
readonly "Type": S["Type"]
|
|
2438
|
+
readonly "Encoded": S["Type"]
|
|
2439
|
+
readonly "DecodingServices": never
|
|
2440
|
+
readonly "EncodingServices": never
|
|
2441
|
+
readonly "~type.make.in": S["~type.make.in"]
|
|
2442
|
+
readonly "~type.make": S["~type.make"]
|
|
2443
|
+
readonly "Iso": S["Iso"]
|
|
2444
|
+
}
|
|
2318
2445
|
|
|
2319
2446
|
interface toTypeLambda extends Lambda {
|
|
2320
|
-
<S extends
|
|
2321
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
2447
|
+
<S extends Constraint>(self: S): toType<S>
|
|
2448
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint ? toType<this["~lambda.in"]> : never
|
|
2322
2449
|
}
|
|
2323
2450
|
|
|
2324
2451
|
/**
|
|
@@ -2336,29 +2463,30 @@ export const toType = Struct_.lambda<toTypeLambda>((schema) => make(SchemaAST.to
|
|
|
2336
2463
|
* @category transforming
|
|
2337
2464
|
* @since 4.0.0
|
|
2338
2465
|
*/
|
|
2339
|
-
export interface toEncoded<S extends
|
|
2340
|
-
|
|
2341
|
-
S["Encoded"],
|
|
2342
|
-
S["Encoded"],
|
|
2343
|
-
never,
|
|
2344
|
-
never,
|
|
2466
|
+
export interface toEncoded<S extends Constraint> extends
|
|
2467
|
+
BottomLazy<
|
|
2345
2468
|
SchemaAST.AST,
|
|
2346
2469
|
toEncoded<S>,
|
|
2347
|
-
|
|
2348
|
-
S["Encoded"],
|
|
2349
|
-
ReadonlyArray<Top>,
|
|
2350
|
-
S["Encoded"],
|
|
2470
|
+
ReadonlyArray<Constraint>,
|
|
2351
2471
|
S["~type.mutability"],
|
|
2352
2472
|
S["~type.optionality"],
|
|
2353
2473
|
S["~type.constructor.default"],
|
|
2354
2474
|
S["~encoded.mutability"],
|
|
2355
2475
|
S["~encoded.optionality"]
|
|
2356
2476
|
>
|
|
2357
|
-
{
|
|
2477
|
+
{
|
|
2478
|
+
readonly "Type": S["Encoded"]
|
|
2479
|
+
readonly "Encoded": S["Encoded"]
|
|
2480
|
+
readonly "DecodingServices": never
|
|
2481
|
+
readonly "EncodingServices": never
|
|
2482
|
+
readonly "~type.make.in": S["Encoded"]
|
|
2483
|
+
readonly "~type.make": S["Encoded"]
|
|
2484
|
+
readonly "Iso": S["Encoded"]
|
|
2485
|
+
}
|
|
2358
2486
|
|
|
2359
2487
|
interface toEncodedLambda extends Lambda {
|
|
2360
|
-
<S extends
|
|
2361
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
2488
|
+
<S extends Constraint>(self: S): toEncoded<S>
|
|
2489
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint ? toEncoded<this["~lambda.in"]> : never
|
|
2362
2490
|
}
|
|
2363
2491
|
|
|
2364
2492
|
/**
|
|
@@ -2379,17 +2507,10 @@ const FlipTypeId = "~effect/Schema/flip"
|
|
|
2379
2507
|
* @since 4.0.0
|
|
2380
2508
|
*/
|
|
2381
2509
|
export interface flip<S extends Top> extends
|
|
2382
|
-
|
|
2383
|
-
S["Encoded"],
|
|
2384
|
-
S["Type"],
|
|
2385
|
-
S["EncodingServices"],
|
|
2386
|
-
S["DecodingServices"],
|
|
2510
|
+
BottomLazy<
|
|
2387
2511
|
SchemaAST.AST,
|
|
2388
2512
|
flip<S>,
|
|
2389
|
-
|
|
2390
|
-
S["Encoded"],
|
|
2391
|
-
ReadonlyArray<Top>,
|
|
2392
|
-
S["Encoded"],
|
|
2513
|
+
ReadonlyArray<Constraint>,
|
|
2393
2514
|
S["~encoded.mutability"],
|
|
2394
2515
|
S["~encoded.optionality"],
|
|
2395
2516
|
ConstructorDefault,
|
|
@@ -2397,6 +2518,13 @@ export interface flip<S extends Top> extends
|
|
|
2397
2518
|
S["~type.optionality"]
|
|
2398
2519
|
>
|
|
2399
2520
|
{
|
|
2521
|
+
readonly "Type": S["Encoded"]
|
|
2522
|
+
readonly "Encoded": S["Type"]
|
|
2523
|
+
readonly "DecodingServices": S["EncodingServices"]
|
|
2524
|
+
readonly "EncodingServices": S["DecodingServices"]
|
|
2525
|
+
readonly "~type.make.in": S["Encoded"]
|
|
2526
|
+
readonly "~type.make": S["Encoded"]
|
|
2527
|
+
readonly "Iso": S["Encoded"]
|
|
2400
2528
|
readonly [FlipTypeId]: typeof FlipTypeId
|
|
2401
2529
|
readonly schema: S
|
|
2402
2530
|
}
|
|
@@ -2498,7 +2626,7 @@ export declare namespace TemplateLiteral {
|
|
|
2498
2626
|
* @category utility types
|
|
2499
2627
|
* @since 4.0.0
|
|
2500
2628
|
*/
|
|
2501
|
-
export interface SchemaPart extends
|
|
2629
|
+
export interface SchemaPart extends Constraint {
|
|
2502
2630
|
readonly Encoded: string | number | bigint
|
|
2503
2631
|
}
|
|
2504
2632
|
|
|
@@ -2531,7 +2659,7 @@ export declare namespace TemplateLiteral {
|
|
|
2531
2659
|
Template extends string,
|
|
2532
2660
|
Next
|
|
2533
2661
|
> = Next extends LiteralPart ? `${Template}${Next}`
|
|
2534
|
-
: Next extends
|
|
2662
|
+
: Next extends { readonly Encoded: infer E extends LiteralPart } ? `${Template}${E}`
|
|
2535
2663
|
: never
|
|
2536
2664
|
|
|
2537
2665
|
/**
|
|
@@ -2565,7 +2693,9 @@ export interface TemplateLiteral<Parts extends TemplateLiteral.Parts> extends
|
|
|
2565
2693
|
}
|
|
2566
2694
|
|
|
2567
2695
|
function templateLiteralFromParts<Parts extends TemplateLiteral.Parts>(parts: Parts) {
|
|
2568
|
-
return new SchemaAST.TemplateLiteral(
|
|
2696
|
+
return new SchemaAST.TemplateLiteral(
|
|
2697
|
+
parts.map((part) => isSchema(part) ? part.ast : new SchemaAST.Literal(part as TemplateLiteral.LiteralPart))
|
|
2698
|
+
)
|
|
2569
2699
|
}
|
|
2570
2700
|
|
|
2571
2701
|
/**
|
|
@@ -2633,15 +2763,18 @@ export declare namespace TemplateLiteralParser {
|
|
|
2633
2763
|
* @since 3.10.0
|
|
2634
2764
|
*/
|
|
2635
2765
|
export interface TemplateLiteralParser<Parts extends TemplateLiteral.Parts> extends
|
|
2636
|
-
|
|
2637
|
-
TemplateLiteralParser.Type<Parts>,
|
|
2638
|
-
TemplateLiteral.Encoded<Parts>,
|
|
2639
|
-
never,
|
|
2640
|
-
never,
|
|
2766
|
+
BottomLazy<
|
|
2641
2767
|
SchemaAST.Arrays,
|
|
2642
2768
|
TemplateLiteralParser<Parts>
|
|
2643
2769
|
>
|
|
2644
2770
|
{
|
|
2771
|
+
readonly "Type": TemplateLiteralParser.Type<Parts>
|
|
2772
|
+
readonly "Encoded": TemplateLiteral.Encoded<Parts>
|
|
2773
|
+
readonly "DecodingServices": never
|
|
2774
|
+
readonly "EncodingServices": never
|
|
2775
|
+
readonly "~type.make.in": TemplateLiteralParser.Type<Parts>
|
|
2776
|
+
readonly "~type.make": TemplateLiteralParser.Type<Parts>
|
|
2777
|
+
readonly "Iso": TemplateLiteralParser.Type<Parts>
|
|
2645
2778
|
readonly parts: Parts
|
|
2646
2779
|
}
|
|
2647
2780
|
|
|
@@ -2999,7 +3132,7 @@ export declare namespace Struct {
|
|
|
2999
3132
|
* @category utility types
|
|
3000
3133
|
* @since 3.10.0
|
|
3001
3134
|
*/
|
|
3002
|
-
export type Fields = { readonly [x: PropertyKey]:
|
|
3135
|
+
export type Fields = { readonly [x: PropertyKey]: Constraint }
|
|
3003
3136
|
|
|
3004
3137
|
type TypeOptionalKeys<Fields extends Struct.Fields> = {
|
|
3005
3138
|
[K in keyof Fields]: Fields[K] extends { readonly "~type.optionality": "optional" } ? K
|
|
@@ -3011,15 +3144,46 @@ export declare namespace Struct {
|
|
|
3011
3144
|
: never
|
|
3012
3145
|
}[keyof Fields]
|
|
3013
3146
|
|
|
3014
|
-
type
|
|
3147
|
+
type SetOptional<A, K extends keyof A> = Omit<A, K> & Partial<Pick<A, K>>
|
|
3148
|
+
|
|
3149
|
+
type Mutable<A> = { -readonly [K in keyof A]: A[K] }
|
|
3150
|
+
|
|
3151
|
+
type SetMutable<A, K extends keyof A> = Omit<A, K> & Mutable<Pick<A, K>>
|
|
3152
|
+
|
|
3153
|
+
type Side = "Type" | "Iso" | "Encoded"
|
|
3154
|
+
|
|
3155
|
+
type EncodedOptionalKeys<Fields extends Struct.Fields> = {
|
|
3156
|
+
[K in keyof Fields]: Fields[K] extends { readonly "~encoded.optionality": "optional" } ? K
|
|
3157
|
+
: never
|
|
3158
|
+
}[keyof Fields]
|
|
3159
|
+
|
|
3160
|
+
type EncodedMutableKeys<Fields extends Struct.Fields> = {
|
|
3161
|
+
[K in keyof Fields]: Fields[K] extends { readonly "~encoded.mutability": "mutable" } ? K
|
|
3162
|
+
: never
|
|
3163
|
+
}[keyof Fields]
|
|
3164
|
+
|
|
3165
|
+
type SideOptionalKeys<F extends Fields, S extends Side> = S extends "Encoded" ? EncodedOptionalKeys<F>
|
|
3166
|
+
: TypeOptionalKeys<F>
|
|
3167
|
+
|
|
3168
|
+
type SideMutableKeys<F extends Fields, S extends Side> = S extends "Encoded" ? EncodedMutableKeys<F>
|
|
3169
|
+
: TypeMutableKeys<F>
|
|
3170
|
+
|
|
3171
|
+
type ReadonlySide<F extends Fields, S extends Side> = { readonly [K in keyof F]: F[K][S] }
|
|
3172
|
+
|
|
3173
|
+
type View<
|
|
3015
3174
|
F extends Fields,
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3175
|
+
S extends Side,
|
|
3176
|
+
O extends keyof F = SideOptionalKeys<F, S>,
|
|
3177
|
+
M extends keyof F = SideMutableKeys<F, S>
|
|
3178
|
+
> = [O | M] extends [never] ? ReadonlySide<F, S>
|
|
3179
|
+
: [M] extends [never] ? Simplify<SetOptional<ReadonlySide<F, S>, O>>
|
|
3180
|
+
: [O] extends [never] ? Simplify<SetMutable<ReadonlySide<F, S>, M>>
|
|
3181
|
+
: Simplify<
|
|
3182
|
+
SetMutable<
|
|
3183
|
+
SetOptional<ReadonlySide<F, S>, O>,
|
|
3184
|
+
Extract<keyof SetOptional<ReadonlySide<F, S>, O>, M>
|
|
3185
|
+
>
|
|
3186
|
+
>
|
|
3023
3187
|
|
|
3024
3188
|
/**
|
|
3025
3189
|
* Computes the decoded object type for a struct field map.
|
|
@@ -3032,17 +3196,7 @@ export declare namespace Struct {
|
|
|
3032
3196
|
* @category utility types
|
|
3033
3197
|
* @since 3.10.0
|
|
3034
3198
|
*/
|
|
3035
|
-
export type Type<F extends Fields> =
|
|
3036
|
-
|
|
3037
|
-
type Iso_<
|
|
3038
|
-
F extends Fields,
|
|
3039
|
-
O extends keyof F = TypeOptionalKeys<F>,
|
|
3040
|
-
M extends keyof F = TypeMutableKeys<F>
|
|
3041
|
-
> =
|
|
3042
|
-
& { readonly [K in keyof F as K extends M | O ? never : K]: F[K]["Iso"] }
|
|
3043
|
-
& { readonly [K in keyof F as K extends O ? K extends M ? never : K : never]?: F[K]["Iso"] }
|
|
3044
|
-
& { -readonly [K in keyof F as K extends M ? K extends O ? never : K : never]: F[K]["Iso"] }
|
|
3045
|
-
& { -readonly [K in keyof F as K extends M & O ? K : never]?: F[K]["Iso"] }
|
|
3199
|
+
export type Type<F extends Fields> = View<F, "Type">
|
|
3046
3200
|
|
|
3047
3201
|
/**
|
|
3048
3202
|
* Computes the iso object type for a struct field map from each field schema's
|
|
@@ -3056,27 +3210,7 @@ export declare namespace Struct {
|
|
|
3056
3210
|
* @category utility types
|
|
3057
3211
|
* @since 4.0.0
|
|
3058
3212
|
*/
|
|
3059
|
-
export type Iso<F extends Fields> =
|
|
3060
|
-
|
|
3061
|
-
type EncodedOptionalKeys<Fields extends Struct.Fields> = {
|
|
3062
|
-
[K in keyof Fields]: Fields[K] extends { readonly "~encoded.optionality": "optional" } ? K
|
|
3063
|
-
: never
|
|
3064
|
-
}[keyof Fields]
|
|
3065
|
-
|
|
3066
|
-
type EncodedMutableKeys<Fields extends Struct.Fields> = {
|
|
3067
|
-
[K in keyof Fields]: Fields[K] extends { readonly "~encoded.mutability": "mutable" } ? K
|
|
3068
|
-
: never
|
|
3069
|
-
}[keyof Fields]
|
|
3070
|
-
|
|
3071
|
-
type Encoded_<
|
|
3072
|
-
F extends Fields,
|
|
3073
|
-
O extends keyof F = EncodedOptionalKeys<F>,
|
|
3074
|
-
M extends keyof F = EncodedMutableKeys<F>
|
|
3075
|
-
> =
|
|
3076
|
-
& { readonly [K in keyof F as K extends M | O ? never : K]: F[K]["Encoded"] }
|
|
3077
|
-
& { readonly [K in keyof F as K extends O ? K extends M ? never : K : never]?: F[K]["Encoded"] }
|
|
3078
|
-
& { -readonly [K in keyof F as K extends M ? K extends O ? never : K : never]: F[K]["Encoded"] }
|
|
3079
|
-
& { -readonly [K in keyof F as K extends M & O ? K : never]?: F[K]["Encoded"] }
|
|
3213
|
+
export type Iso<F extends Fields> = View<F, "Iso">
|
|
3080
3214
|
|
|
3081
3215
|
/**
|
|
3082
3216
|
* Computes the encoded object type for a struct field map.
|
|
@@ -3090,7 +3224,7 @@ export declare namespace Struct {
|
|
|
3090
3224
|
* @category utility types
|
|
3091
3225
|
* @since 3.10.0
|
|
3092
3226
|
*/
|
|
3093
|
-
export type Encoded<F extends Fields> =
|
|
3227
|
+
export type Encoded<F extends Fields> = View<F, "Encoded">
|
|
3094
3228
|
|
|
3095
3229
|
/**
|
|
3096
3230
|
* Union of all decoding service requirements needed by the schemas in a struct
|
|
@@ -3115,12 +3249,12 @@ export declare namespace Struct {
|
|
|
3115
3249
|
: never
|
|
3116
3250
|
}[keyof Fields]
|
|
3117
3251
|
|
|
3118
|
-
type
|
|
3252
|
+
type ReadonlyMakeIn<F extends Fields> = { readonly [K in keyof F]: F[K]["~type.make"] }
|
|
3253
|
+
|
|
3254
|
+
type MakeInView<
|
|
3119
3255
|
F extends Fields,
|
|
3120
|
-
O = TypeOptionalKeys<F> | TypeConstructorDefaultedKeys<F>
|
|
3121
|
-
> =
|
|
3122
|
-
& { readonly [K in keyof F as K extends O ? never : K]: F[K]["~type.make"] }
|
|
3123
|
-
& { readonly [K in keyof F as K extends O ? K : never]?: F[K]["~type.make"] }
|
|
3256
|
+
O extends keyof F = TypeOptionalKeys<F> | TypeConstructorDefaultedKeys<F>
|
|
3257
|
+
> = [O] extends [never] ? ReadonlyMakeIn<F> : Simplify<SetOptional<ReadonlyMakeIn<F>, O>>
|
|
3124
3258
|
|
|
3125
3259
|
/**
|
|
3126
3260
|
* Computes the input object type accepted when constructing a struct value.
|
|
@@ -3133,7 +3267,7 @@ export declare namespace Struct {
|
|
|
3133
3267
|
* @category utility types
|
|
3134
3268
|
* @since 4.0.0
|
|
3135
3269
|
*/
|
|
3136
|
-
export type MakeIn<F extends Fields> =
|
|
3270
|
+
export type MakeIn<F extends Fields> = MakeInView<F>
|
|
3137
3271
|
}
|
|
3138
3272
|
|
|
3139
3273
|
/**
|
|
@@ -3142,18 +3276,14 @@ export declare namespace Struct {
|
|
|
3142
3276
|
* @category models
|
|
3143
3277
|
* @since 3.10.0
|
|
3144
3278
|
*/
|
|
3145
|
-
export interface Struct<Fields extends Struct.Fields> extends
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
Struct.MakeIn<Fields>,
|
|
3154
|
-
Struct.Iso<Fields>
|
|
3155
|
-
>
|
|
3156
|
-
{
|
|
3279
|
+
export interface Struct<Fields extends Struct.Fields> extends BottomLazy<SchemaAST.Objects, Struct<Fields>> {
|
|
3280
|
+
readonly "Type": Struct.Type<Fields>
|
|
3281
|
+
readonly "Encoded": Struct.Encoded<Fields>
|
|
3282
|
+
readonly "DecodingServices": Struct.DecodingServices<Fields>
|
|
3283
|
+
readonly "EncodingServices": Struct.EncodingServices<Fields>
|
|
3284
|
+
readonly "~type.make.in": Struct.MakeIn<Fields>
|
|
3285
|
+
readonly "~type.make": Struct.MakeIn<Fields>
|
|
3286
|
+
readonly "Iso": Struct.Iso<Fields>
|
|
3157
3287
|
/**
|
|
3158
3288
|
* The field definitions of this struct. Spread them into a new struct to
|
|
3159
3289
|
* reuse fields across schemas.
|
|
@@ -3300,7 +3430,7 @@ export function fieldsAssign<const NewFields extends Struct.Fields>(fields: NewF
|
|
|
3300
3430
|
* @since 4.0.0
|
|
3301
3431
|
*/
|
|
3302
3432
|
export interface encodeKeys<
|
|
3303
|
-
S extends
|
|
3433
|
+
S extends Constraint & { readonly fields: Struct.Fields },
|
|
3304
3434
|
M extends { readonly [K in keyof S["fields"]]?: PropertyKey }
|
|
3305
3435
|
> extends
|
|
3306
3436
|
decodeTo<
|
|
@@ -3347,7 +3477,7 @@ const canonicalPropertyKey = (key: PropertyKey): string | symbol =>
|
|
|
3347
3477
|
* @since 4.0.0
|
|
3348
3478
|
*/
|
|
3349
3479
|
export function encodeKeys<
|
|
3350
|
-
S extends
|
|
3480
|
+
S extends Constraint & { readonly fields: Struct.Fields },
|
|
3351
3481
|
const M extends { readonly [K in keyof S["fields"]]?: PropertyKey }
|
|
3352
3482
|
>(mapping: M) {
|
|
3353
3483
|
return function(self: S): encodeKeys<S, M> {
|
|
@@ -3489,7 +3619,7 @@ export declare namespace Record {
|
|
|
3489
3619
|
* @category utility types
|
|
3490
3620
|
* @since 3.10.0
|
|
3491
3621
|
*/
|
|
3492
|
-
export type Type<Key extends Record.Key, Value extends
|
|
3622
|
+
export type Type<Key extends Record.Key, Value extends Constraint> = Value extends
|
|
3493
3623
|
{ readonly "~type.optionality": "optional" } ?
|
|
3494
3624
|
Value extends { readonly "~type.mutability": "mutable" } ? { [P in Key["Type"]]?: Value["Type"] }
|
|
3495
3625
|
: { readonly [P in Key["Type"]]?: Value["Type"] }
|
|
@@ -3503,7 +3633,7 @@ export declare namespace Record {
|
|
|
3503
3633
|
* @category utility types
|
|
3504
3634
|
* @since 4.0.0
|
|
3505
3635
|
*/
|
|
3506
|
-
export type Iso<Key extends Record.Key, Value extends
|
|
3636
|
+
export type Iso<Key extends Record.Key, Value extends Constraint> = Value extends
|
|
3507
3637
|
{ readonly "~type.optionality": "optional" } ?
|
|
3508
3638
|
Value extends { readonly "~type.mutability": "mutable" } ? { [P in Key["Iso"]]?: Value["Iso"] }
|
|
3509
3639
|
: { readonly [P in Key["Iso"]]?: Value["Iso"] }
|
|
@@ -3522,7 +3652,7 @@ export declare namespace Record {
|
|
|
3522
3652
|
* @category utility types
|
|
3523
3653
|
* @since 3.10.0
|
|
3524
3654
|
*/
|
|
3525
|
-
export type Encoded<Key extends Record.Key, Value extends
|
|
3655
|
+
export type Encoded<Key extends Record.Key, Value extends Constraint> = Value extends
|
|
3526
3656
|
{ readonly "~encoded.optionality": "optional" } ?
|
|
3527
3657
|
Value extends { readonly "~encoded.mutability": "mutable" } ? { [P in Key["Encoded"]]?: Value["Encoded"] }
|
|
3528
3658
|
: { readonly [P in Key["Encoded"]]?: Value["Encoded"] }
|
|
@@ -3536,7 +3666,7 @@ export declare namespace Record {
|
|
|
3536
3666
|
* @category utility types
|
|
3537
3667
|
* @since 4.0.0
|
|
3538
3668
|
*/
|
|
3539
|
-
export type DecodingServices<Key extends Record.Key, Value extends
|
|
3669
|
+
export type DecodingServices<Key extends Record.Key, Value extends Constraint> =
|
|
3540
3670
|
| Key["DecodingServices"]
|
|
3541
3671
|
| Value["DecodingServices"]
|
|
3542
3672
|
|
|
@@ -3547,7 +3677,7 @@ export declare namespace Record {
|
|
|
3547
3677
|
* @category utility types
|
|
3548
3678
|
* @since 4.0.0
|
|
3549
3679
|
*/
|
|
3550
|
-
export type EncodingServices<Key extends Record.Key, Value extends
|
|
3680
|
+
export type EncodingServices<Key extends Record.Key, Value extends Constraint> =
|
|
3551
3681
|
| Key["EncodingServices"]
|
|
3552
3682
|
| Value["EncodingServices"]
|
|
3553
3683
|
|
|
@@ -3563,7 +3693,7 @@ export declare namespace Record {
|
|
|
3563
3693
|
* @category utility types
|
|
3564
3694
|
* @since 4.0.0
|
|
3565
3695
|
*/
|
|
3566
|
-
export type MakeIn<Key extends Record.Key, Value extends
|
|
3696
|
+
export type MakeIn<Key extends Record.Key, Value extends Constraint> = Value extends
|
|
3567
3697
|
{ readonly "~encoded.optionality": "optional" } ?
|
|
3568
3698
|
Value extends { readonly "~encoded.mutability": "mutable" } ? { [P in Key["~type.make"]]?: Value["~type.make"] }
|
|
3569
3699
|
: { readonly [P in Key["~type.make"]]?: Value["~type.make"] }
|
|
@@ -3577,18 +3707,19 @@ export declare namespace Record {
|
|
|
3577
3707
|
* @category models
|
|
3578
3708
|
* @since 4.0.0
|
|
3579
3709
|
*/
|
|
3580
|
-
export interface $Record<Key extends Record.Key, Value extends
|
|
3581
|
-
|
|
3582
|
-
Record.Type<Key, Value>,
|
|
3583
|
-
Record.Encoded<Key, Value>,
|
|
3584
|
-
Record.DecodingServices<Key, Value>,
|
|
3585
|
-
Record.EncodingServices<Key, Value>,
|
|
3710
|
+
export interface $Record<Key extends Record.Key, Value extends Constraint> extends
|
|
3711
|
+
BottomLazy<
|
|
3586
3712
|
SchemaAST.Objects,
|
|
3587
|
-
$Record<Key, Value
|
|
3588
|
-
Simplify<Record.MakeIn<Key, Value>>,
|
|
3589
|
-
Record.Iso<Key, Value>
|
|
3713
|
+
$Record<Key, Value>
|
|
3590
3714
|
>
|
|
3591
3715
|
{
|
|
3716
|
+
readonly "Type": Record.Type<Key, Value>
|
|
3717
|
+
readonly "Encoded": Record.Encoded<Key, Value>
|
|
3718
|
+
readonly "DecodingServices": Record.DecodingServices<Key, Value>
|
|
3719
|
+
readonly "EncodingServices": Record.EncodingServices<Key, Value>
|
|
3720
|
+
readonly "~type.make.in": Simplify<Record.MakeIn<Key, Value>>
|
|
3721
|
+
readonly "~type.make": Simplify<Record.MakeIn<Key, Value>>
|
|
3722
|
+
readonly "Iso": Record.Iso<Key, Value>
|
|
3592
3723
|
readonly key: Key
|
|
3593
3724
|
readonly value: Value
|
|
3594
3725
|
}
|
|
@@ -3625,7 +3756,7 @@ export interface $Record<Key extends Record.Key, Value extends Top> extends
|
|
|
3625
3756
|
* @category constructors
|
|
3626
3757
|
* @since 3.10.0
|
|
3627
3758
|
*/
|
|
3628
|
-
export function Record<Key extends Record.Key, Value extends
|
|
3759
|
+
export function Record<Key extends Record.Key, Value extends Constraint>(
|
|
3629
3760
|
key: Key,
|
|
3630
3761
|
value: Value,
|
|
3631
3762
|
options?: {
|
|
@@ -3659,7 +3790,7 @@ export declare namespace StructWithRest {
|
|
|
3659
3790
|
* @category utility types
|
|
3660
3791
|
* @since 4.0.0
|
|
3661
3792
|
*/
|
|
3662
|
-
export type Objects =
|
|
3793
|
+
export type Objects = Constraint & { readonly ast: SchemaAST.Objects }
|
|
3663
3794
|
|
|
3664
3795
|
/**
|
|
3665
3796
|
* Readonly list of record schemas that provide the additional index signatures
|
|
@@ -3668,7 +3799,7 @@ export declare namespace StructWithRest {
|
|
|
3668
3799
|
* @category utility types
|
|
3669
3800
|
* @since 3.10.0
|
|
3670
3801
|
*/
|
|
3671
|
-
export type Records = ReadonlyArray<$Record<Record.Key,
|
|
3802
|
+
export type Records = ReadonlyArray<$Record<Record.Key, Constraint>>
|
|
3672
3803
|
|
|
3673
3804
|
type MergeTuple<T extends ReadonlyArray<unknown>> = T extends readonly [infer Head, ...infer Tail] ?
|
|
3674
3805
|
Head & MergeTuple<Tail>
|
|
@@ -3765,24 +3896,52 @@ export declare namespace StructWithRest {
|
|
|
3765
3896
|
[I in keyof Records]: Records[I][Side] extends object ? IncompatibleKeys<S[Side], Records[I][Side]> : never
|
|
3766
3897
|
}[number]
|
|
3767
3898
|
|
|
3899
|
+
type IncompatibleRecords<S extends Objects, Records extends StructWithRest.Records> =
|
|
3900
|
+
| IncompatibleSideKeys<S, Records, "Type">
|
|
3901
|
+
| IncompatibleSideKeys<S, Records, "Encoded">
|
|
3902
|
+
| IncompatibleSideKeys<S, Records, "Iso">
|
|
3903
|
+
| IncompatibleSideKeys<S, Records, "~type.make">
|
|
3904
|
+
|
|
3768
3905
|
/**
|
|
3769
|
-
*
|
|
3906
|
+
* Checks whether fixed fields are compatible with the rest record schemas.
|
|
3907
|
+
*
|
|
3908
|
+
* **Details**
|
|
3909
|
+
*
|
|
3910
|
+
* Returns `true` when all fixed fields can also satisfy the matching rest
|
|
3911
|
+
* index signatures. Returns a diagnostic object when TypeScript would make
|
|
3912
|
+
* the resulting intersection too narrow for one or more fixed keys.
|
|
3913
|
+
*
|
|
3914
|
+
* **Example** (Checking record compatibility)
|
|
3915
|
+
*
|
|
3916
|
+
* ```ts
|
|
3917
|
+
* import { Schema } from "effect"
|
|
3918
|
+
*
|
|
3919
|
+
* const user = Schema.Struct({ id: Schema.String })
|
|
3920
|
+
* const stringExtras = [Schema.Record(Schema.String, Schema.String)] as const
|
|
3921
|
+
*
|
|
3922
|
+
* type UserCheck = Schema.StructWithRest.ValidateRecords<typeof user, typeof stringExtras>
|
|
3923
|
+
*
|
|
3924
|
+
* const userCheck: UserCheck = true
|
|
3925
|
+
* void userCheck
|
|
3926
|
+
*
|
|
3927
|
+
* const counter = Schema.Struct({ count: Schema.NumberFromString })
|
|
3928
|
+
*
|
|
3929
|
+
* type CounterCheck = Schema.StructWithRest.ValidateRecords<typeof counter, typeof stringExtras>
|
|
3930
|
+
* // ^? { "incompatible index signatures": "count" }
|
|
3931
|
+
*
|
|
3932
|
+
* const counterCheck = null as unknown as CounterCheck
|
|
3933
|
+
* void counterCheck
|
|
3934
|
+
* ```
|
|
3770
3935
|
*
|
|
3771
3936
|
* @category utility types
|
|
3772
3937
|
* @since 4.0.0
|
|
3773
3938
|
*/
|
|
3774
|
-
export type ValidateRecords<
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
| IncompatibleSideKeys<S, Records, "~type.make">
|
|
3779
|
-
] extends [never] ? unknown
|
|
3939
|
+
export type ValidateRecords<
|
|
3940
|
+
S extends Objects,
|
|
3941
|
+
Records extends StructWithRest.Records
|
|
3942
|
+
> = [IncompatibleRecords<S, Records>] extends [never] ? true
|
|
3780
3943
|
: {
|
|
3781
|
-
"incompatible index signatures":
|
|
3782
|
-
| IncompatibleSideKeys<S, Records, "Type">
|
|
3783
|
-
| IncompatibleSideKeys<S, Records, "Encoded">
|
|
3784
|
-
| IncompatibleSideKeys<S, Records, "Iso">
|
|
3785
|
-
| IncompatibleSideKeys<S, Records, "~type.make">
|
|
3944
|
+
"incompatible index signatures": IncompatibleRecords<S, Records>
|
|
3786
3945
|
}
|
|
3787
3946
|
}
|
|
3788
3947
|
|
|
@@ -3796,17 +3955,18 @@ export interface StructWithRest<
|
|
|
3796
3955
|
S extends StructWithRest.Objects,
|
|
3797
3956
|
Records extends StructWithRest.Records
|
|
3798
3957
|
> extends
|
|
3799
|
-
|
|
3800
|
-
Simplify<StructWithRest.Type<S, Records>>,
|
|
3801
|
-
Simplify<StructWithRest.Encoded<S, Records>>,
|
|
3802
|
-
StructWithRest.DecodingServices<S, Records>,
|
|
3803
|
-
StructWithRest.EncodingServices<S, Records>,
|
|
3958
|
+
BottomLazy<
|
|
3804
3959
|
SchemaAST.Objects,
|
|
3805
|
-
StructWithRest<S, Records
|
|
3806
|
-
Simplify<StructWithRest.MakeIn<S, Records>>,
|
|
3807
|
-
Simplify<StructWithRest.Iso<S, Records>>
|
|
3960
|
+
StructWithRest<S, Records>
|
|
3808
3961
|
>
|
|
3809
3962
|
{
|
|
3963
|
+
readonly "Type": Simplify<StructWithRest.Type<S, Records>>
|
|
3964
|
+
readonly "Encoded": Simplify<StructWithRest.Encoded<S, Records>>
|
|
3965
|
+
readonly "DecodingServices": StructWithRest.DecodingServices<S, Records>
|
|
3966
|
+
readonly "EncodingServices": StructWithRest.EncodingServices<S, Records>
|
|
3967
|
+
readonly "~type.make.in": Simplify<StructWithRest.MakeIn<S, Records>>
|
|
3968
|
+
readonly "~type.make": Simplify<StructWithRest.MakeIn<S, Records>>
|
|
3969
|
+
readonly "Iso": Simplify<StructWithRest.Iso<S, Records>>
|
|
3810
3970
|
readonly schema: S
|
|
3811
3971
|
readonly records: Records
|
|
3812
3972
|
}
|
|
@@ -3815,6 +3975,13 @@ export interface StructWithRest<
|
|
|
3815
3975
|
* Extends a struct schema with one or more record (index-signature) schemas,
|
|
3816
3976
|
* producing a schema whose decoded type intersects the struct and all records.
|
|
3817
3977
|
*
|
|
3978
|
+
* **Gotchas**
|
|
3979
|
+
*
|
|
3980
|
+
* TypeScript index signatures also apply to fixed keys. `StructWithRest` does
|
|
3981
|
+
* not reject incompatible fixed fields at the call site; use
|
|
3982
|
+
* `StructWithRest.ValidateRecords` when you want an explicit type-level
|
|
3983
|
+
* compatibility check.
|
|
3984
|
+
*
|
|
3818
3985
|
* **Example** (Defining structs with string-indexed extra keys)
|
|
3819
3986
|
*
|
|
3820
3987
|
* ```ts
|
|
@@ -3837,7 +4004,7 @@ export function StructWithRest<
|
|
|
3837
4004
|
const Records extends StructWithRest.Records
|
|
3838
4005
|
>(
|
|
3839
4006
|
schema: S,
|
|
3840
|
-
records: Records
|
|
4007
|
+
records: Records
|
|
3841
4008
|
): StructWithRest<S, Records> {
|
|
3842
4009
|
return make(SchemaAST.structWithRest(schema.ast, records.map(SchemaAST.getAST)), { schema, records })
|
|
3843
4010
|
}
|
|
@@ -3862,7 +4029,7 @@ export declare namespace Tuple {
|
|
|
3862
4029
|
* @category utility types
|
|
3863
4030
|
* @since 3.10.0
|
|
3864
4031
|
*/
|
|
3865
|
-
export type Elements = ReadonlyArray<
|
|
4032
|
+
export type Elements = ReadonlyArray<Constraint>
|
|
3866
4033
|
|
|
3867
4034
|
type Type_<
|
|
3868
4035
|
Elements,
|
|
@@ -3980,17 +4147,18 @@ export declare namespace Tuple {
|
|
|
3980
4147
|
* @since 3.10.0
|
|
3981
4148
|
*/
|
|
3982
4149
|
export interface Tuple<Elements extends Tuple.Elements> extends
|
|
3983
|
-
|
|
3984
|
-
Tuple.Type<Elements>,
|
|
3985
|
-
Tuple.Encoded<Elements>,
|
|
3986
|
-
Tuple.DecodingServices<Elements>,
|
|
3987
|
-
Tuple.EncodingServices<Elements>,
|
|
4150
|
+
BottomLazy<
|
|
3988
4151
|
SchemaAST.Arrays,
|
|
3989
|
-
Tuple<Elements
|
|
3990
|
-
Tuple.MakeIn<Elements>,
|
|
3991
|
-
Tuple.Iso<Elements>
|
|
4152
|
+
Tuple<Elements>
|
|
3992
4153
|
>
|
|
3993
4154
|
{
|
|
4155
|
+
readonly "Type": Tuple.Type<Elements>
|
|
4156
|
+
readonly "Encoded": Tuple.Encoded<Elements>
|
|
4157
|
+
readonly "DecodingServices": Tuple.DecodingServices<Elements>
|
|
4158
|
+
readonly "EncodingServices": Tuple.EncodingServices<Elements>
|
|
4159
|
+
readonly "~type.make.in": Tuple.MakeIn<Elements>
|
|
4160
|
+
readonly "~type.make": Tuple.MakeIn<Elements>
|
|
4161
|
+
readonly "Iso": Tuple.Iso<Elements>
|
|
3994
4162
|
readonly elements: Elements
|
|
3995
4163
|
/**
|
|
3996
4164
|
* Returns a new tuple with the elements modified by the provided function.
|
|
@@ -4050,7 +4218,7 @@ function makeTuple<Elements extends Tuple.Elements>(ast: SchemaAST.Arrays, eleme
|
|
|
4050
4218
|
* @category constructors
|
|
4051
4219
|
* @since 3.10.0
|
|
4052
4220
|
*/
|
|
4053
|
-
export function Tuple<const Elements extends ReadonlyArray<
|
|
4221
|
+
export function Tuple<const Elements extends ReadonlyArray<Constraint>>(elements: Elements): Tuple<Elements> {
|
|
4054
4222
|
return makeTuple(SchemaAST.tuple(elements), elements)
|
|
4055
4223
|
}
|
|
4056
4224
|
|
|
@@ -4074,7 +4242,7 @@ export declare namespace TupleWithRest {
|
|
|
4074
4242
|
* @category utility types
|
|
4075
4243
|
* @since 3.10.0
|
|
4076
4244
|
*/
|
|
4077
|
-
export type TupleType =
|
|
4245
|
+
export type TupleType = Constraint & {
|
|
4078
4246
|
readonly Type: ReadonlyArray<unknown>
|
|
4079
4247
|
readonly Encoded: ReadonlyArray<unknown>
|
|
4080
4248
|
readonly ast: SchemaAST.Arrays
|
|
@@ -4093,7 +4261,7 @@ export declare namespace TupleWithRest {
|
|
|
4093
4261
|
* @category utility types
|
|
4094
4262
|
* @since 3.10.0
|
|
4095
4263
|
*/
|
|
4096
|
-
export type Rest = readonly [
|
|
4264
|
+
export type Rest = readonly [Constraint, ...Array<Constraint>]
|
|
4097
4265
|
|
|
4098
4266
|
/**
|
|
4099
4267
|
* Computes the decoded tuple type for a `TupleWithRest`.
|
|
@@ -4108,7 +4276,7 @@ export declare namespace TupleWithRest {
|
|
|
4108
4276
|
* @since 3.10.0
|
|
4109
4277
|
*/
|
|
4110
4278
|
export type Type<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends
|
|
4111
|
-
readonly [infer Head extends
|
|
4279
|
+
readonly [infer Head extends Constraint, ...infer Tail extends ReadonlyArray<Constraint>] ? Readonly<[
|
|
4112
4280
|
...T,
|
|
4113
4281
|
...Array<Head["Type"]>,
|
|
4114
4282
|
...{ readonly [K in keyof Tail]: Tail[K]["Type"] }
|
|
@@ -4128,7 +4296,7 @@ export declare namespace TupleWithRest {
|
|
|
4128
4296
|
* @since 4.0.0
|
|
4129
4297
|
*/
|
|
4130
4298
|
export type Iso<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends
|
|
4131
|
-
readonly [infer Head extends
|
|
4299
|
+
readonly [infer Head extends Constraint, ...infer Tail extends ReadonlyArray<Constraint>] ? Readonly<[
|
|
4132
4300
|
...T,
|
|
4133
4301
|
...Array<Head["Iso"]>,
|
|
4134
4302
|
...{ readonly [K in keyof Tail]: Tail[K]["Iso"] }
|
|
@@ -4148,7 +4316,7 @@ export declare namespace TupleWithRest {
|
|
|
4148
4316
|
* @since 3.10.0
|
|
4149
4317
|
*/
|
|
4150
4318
|
export type Encoded<E extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends
|
|
4151
|
-
readonly [infer Head extends
|
|
4319
|
+
readonly [infer Head extends Constraint, ...infer Tail extends ReadonlyArray<Constraint>] ? readonly [
|
|
4152
4320
|
...E,
|
|
4153
4321
|
...Array<Head["Encoded"]>,
|
|
4154
4322
|
...{ readonly [K in keyof Tail]: Tail[K]["Encoded"] }
|
|
@@ -4168,7 +4336,7 @@ export declare namespace TupleWithRest {
|
|
|
4168
4336
|
* @since 4.0.0
|
|
4169
4337
|
*/
|
|
4170
4338
|
export type MakeIn<M extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends
|
|
4171
|
-
readonly [infer Head extends
|
|
4339
|
+
readonly [infer Head extends Constraint, ...infer Tail extends ReadonlyArray<Constraint>] ? readonly [
|
|
4172
4340
|
...M,
|
|
4173
4341
|
...Array<Head["~type.make"]>,
|
|
4174
4342
|
...{ readonly [K in keyof Tail]: Tail[K]["~type.make"] }
|
|
@@ -4186,17 +4354,18 @@ export interface TupleWithRest<
|
|
|
4186
4354
|
S extends TupleWithRest.TupleType,
|
|
4187
4355
|
Rest extends TupleWithRest.Rest
|
|
4188
4356
|
> extends
|
|
4189
|
-
|
|
4190
|
-
TupleWithRest.Type<S["Type"], Rest>,
|
|
4191
|
-
TupleWithRest.Encoded<S["Encoded"], Rest>,
|
|
4192
|
-
S["DecodingServices"] | Rest[number]["DecodingServices"],
|
|
4193
|
-
S["EncodingServices"] | Rest[number]["EncodingServices"],
|
|
4357
|
+
BottomLazy<
|
|
4194
4358
|
SchemaAST.Arrays,
|
|
4195
|
-
TupleWithRest<S, Rest
|
|
4196
|
-
TupleWithRest.MakeIn<S["~type.make"], Rest>,
|
|
4197
|
-
TupleWithRest.Iso<S["Iso"], Rest>
|
|
4359
|
+
TupleWithRest<S, Rest>
|
|
4198
4360
|
>
|
|
4199
4361
|
{
|
|
4362
|
+
readonly "Type": TupleWithRest.Type<S["Type"], Rest>
|
|
4363
|
+
readonly "Encoded": TupleWithRest.Encoded<S["Encoded"], Rest>
|
|
4364
|
+
readonly "DecodingServices": S["DecodingServices"] | Rest[number]["DecodingServices"]
|
|
4365
|
+
readonly "EncodingServices": S["EncodingServices"] | Rest[number]["EncodingServices"]
|
|
4366
|
+
readonly "~type.make.in": TupleWithRest.MakeIn<S["~type.make"], Rest>
|
|
4367
|
+
readonly "~type.make": TupleWithRest.MakeIn<S["~type.make"], Rest>
|
|
4368
|
+
readonly "Iso": TupleWithRest.Iso<S["Iso"], Rest>
|
|
4200
4369
|
readonly schema: S
|
|
4201
4370
|
readonly rest: Rest
|
|
4202
4371
|
}
|
|
@@ -4244,24 +4413,25 @@ export function TupleWithRest<S extends Tuple<Tuple.Elements>, const Rest extend
|
|
|
4244
4413
|
* @category models
|
|
4245
4414
|
* @since 4.0.0
|
|
4246
4415
|
*/
|
|
4247
|
-
export interface $Array<S extends
|
|
4248
|
-
|
|
4249
|
-
ReadonlyArray<S["Type"]>,
|
|
4250
|
-
ReadonlyArray<S["Encoded"]>,
|
|
4251
|
-
S["DecodingServices"],
|
|
4252
|
-
S["EncodingServices"],
|
|
4416
|
+
export interface $Array<S extends Constraint> extends
|
|
4417
|
+
BottomLazy<
|
|
4253
4418
|
SchemaAST.Arrays,
|
|
4254
|
-
$Array<S
|
|
4255
|
-
ReadonlyArray<S["~type.make"]>,
|
|
4256
|
-
ReadonlyArray<S["Iso"]>
|
|
4419
|
+
$Array<S>
|
|
4257
4420
|
>
|
|
4258
4421
|
{
|
|
4422
|
+
readonly "Type": ReadonlyArray<S["Type"]>
|
|
4423
|
+
readonly "Encoded": ReadonlyArray<S["Encoded"]>
|
|
4424
|
+
readonly "DecodingServices": S["DecodingServices"]
|
|
4425
|
+
readonly "EncodingServices": S["EncodingServices"]
|
|
4426
|
+
readonly "~type.make.in": ReadonlyArray<S["~type.make"]>
|
|
4427
|
+
readonly "~type.make": ReadonlyArray<S["~type.make"]>
|
|
4428
|
+
readonly "Iso": ReadonlyArray<S["Iso"]>
|
|
4259
4429
|
readonly value: S
|
|
4260
4430
|
}
|
|
4261
4431
|
|
|
4262
4432
|
interface ArrayLambda extends Lambda {
|
|
4263
|
-
<S extends
|
|
4264
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
4433
|
+
<S extends Constraint>(self: S): $Array<S>
|
|
4434
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint ? $Array<this["~lambda.in"]> : never
|
|
4265
4435
|
}
|
|
4266
4436
|
|
|
4267
4437
|
/**
|
|
@@ -4300,24 +4470,25 @@ export {
|
|
|
4300
4470
|
* @category models
|
|
4301
4471
|
* @since 3.10.0
|
|
4302
4472
|
*/
|
|
4303
|
-
export interface NonEmptyArray<S extends
|
|
4304
|
-
|
|
4305
|
-
readonly [S["Type"], ...Array<S["Type"]>],
|
|
4306
|
-
readonly [S["Encoded"], ...Array<S["Encoded"]>],
|
|
4307
|
-
S["DecodingServices"],
|
|
4308
|
-
S["EncodingServices"],
|
|
4473
|
+
export interface NonEmptyArray<S extends Constraint> extends
|
|
4474
|
+
BottomLazy<
|
|
4309
4475
|
SchemaAST.Arrays,
|
|
4310
|
-
NonEmptyArray<S
|
|
4311
|
-
readonly [S["~type.make"], ...Array<S["~type.make"]>],
|
|
4312
|
-
readonly [S["Iso"], ...Array<S["Iso"]>]
|
|
4476
|
+
NonEmptyArray<S>
|
|
4313
4477
|
>
|
|
4314
4478
|
{
|
|
4479
|
+
readonly "Type": readonly [S["Type"], ...Array<S["Type"]>]
|
|
4480
|
+
readonly "Encoded": readonly [S["Encoded"], ...Array<S["Encoded"]>]
|
|
4481
|
+
readonly "DecodingServices": S["DecodingServices"]
|
|
4482
|
+
readonly "EncodingServices": S["EncodingServices"]
|
|
4483
|
+
readonly "~type.make.in": readonly [S["~type.make"], ...Array<S["~type.make"]>]
|
|
4484
|
+
readonly "~type.make": readonly [S["~type.make"], ...Array<S["~type.make"]>]
|
|
4485
|
+
readonly "Iso": readonly [S["Iso"], ...Array<S["Iso"]>]
|
|
4315
4486
|
readonly value: S
|
|
4316
4487
|
}
|
|
4317
4488
|
|
|
4318
4489
|
interface NonEmptyArrayLambda extends Lambda {
|
|
4319
|
-
<S extends
|
|
4320
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
4490
|
+
<S extends Constraint>(self: S): NonEmptyArray<S>
|
|
4491
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint ? NonEmptyArray<this["~lambda.in"]> : never
|
|
4321
4492
|
}
|
|
4322
4493
|
|
|
4323
4494
|
/**
|
|
@@ -4348,7 +4519,7 @@ export const NonEmptyArray = Struct_.lambda<NonEmptyArrayLambda>((schema) =>
|
|
|
4348
4519
|
* @category constructors
|
|
4349
4520
|
* @since 3.10.0
|
|
4350
4521
|
*/
|
|
4351
|
-
export interface ArrayEnsure<S extends
|
|
4522
|
+
export interface ArrayEnsure<S extends Constraint> extends decodeTo<$Array<toType<S>>, Union<readonly [S, $Array<S>]>> {
|
|
4352
4523
|
readonly "Rebuild": ArrayEnsure<S>
|
|
4353
4524
|
}
|
|
4354
4525
|
|
|
@@ -4378,7 +4549,7 @@ export interface ArrayEnsure<S extends Top> extends decodeTo<$Array<toType<S>>,
|
|
|
4378
4549
|
* @category constructors
|
|
4379
4550
|
* @since 3.10.0
|
|
4380
4551
|
*/
|
|
4381
|
-
export function ArrayEnsure<S extends
|
|
4552
|
+
export function ArrayEnsure<S extends Constraint>(schema: S): ArrayEnsure<S> {
|
|
4382
4553
|
return Union([schema, ArraySchema(schema)]).pipe(decodeTo(
|
|
4383
4554
|
ArraySchema(toType(schema)),
|
|
4384
4555
|
SchemaTransformation.transform({
|
|
@@ -4394,7 +4565,7 @@ export function ArrayEnsure<S extends Top>(schema: S): ArrayEnsure<S> {
|
|
|
4394
4565
|
* @category models
|
|
4395
4566
|
* @since 4.0.0
|
|
4396
4567
|
*/
|
|
4397
|
-
export interface UniqueArray<S extends
|
|
4568
|
+
export interface UniqueArray<S extends Constraint> extends $Array<S> {
|
|
4398
4569
|
readonly "Rebuild": UniqueArray<S>
|
|
4399
4570
|
}
|
|
4400
4571
|
|
|
@@ -4409,7 +4580,7 @@ export interface UniqueArray<S extends Top> extends $Array<S> {
|
|
|
4409
4580
|
* @category constructors
|
|
4410
4581
|
* @since 4.0.0
|
|
4411
4582
|
*/
|
|
4412
|
-
export function UniqueArray<S extends
|
|
4583
|
+
export function UniqueArray<S extends Constraint>(item: S): UniqueArray<S> {
|
|
4413
4584
|
return ArraySchema(item).check(isUnique())
|
|
4414
4585
|
}
|
|
4415
4586
|
|
|
@@ -4419,19 +4590,11 @@ export function UniqueArray<S extends Top>(item: S): UniqueArray<S> {
|
|
|
4419
4590
|
* @category transforming
|
|
4420
4591
|
* @since 3.10.0
|
|
4421
4592
|
*/
|
|
4422
|
-
export interface mutable<S extends
|
|
4423
|
-
|
|
4424
|
-
Mutable<S["Type"]>,
|
|
4425
|
-
Mutable<S["Encoded"]>,
|
|
4426
|
-
S["DecodingServices"],
|
|
4427
|
-
S["EncodingServices"],
|
|
4593
|
+
export interface mutable<S extends Constraint & { readonly "ast": SchemaAST.Arrays }> extends
|
|
4594
|
+
BottomLazy<
|
|
4428
4595
|
S["ast"],
|
|
4429
4596
|
mutable<S>,
|
|
4430
|
-
// "~type.make" and "~type.make.in" as they are because they are contravariant
|
|
4431
|
-
S["~type.make.in"],
|
|
4432
|
-
S["Iso"],
|
|
4433
4597
|
S["~type.parameters"],
|
|
4434
|
-
S["~type.make"],
|
|
4435
4598
|
S["~type.mutability"],
|
|
4436
4599
|
S["~type.optionality"],
|
|
4437
4600
|
S["~type.constructor.default"],
|
|
@@ -4439,12 +4602,20 @@ export interface mutable<S extends Top & { readonly "ast": SchemaAST.Arrays }> e
|
|
|
4439
4602
|
S["~encoded.optionality"]
|
|
4440
4603
|
>
|
|
4441
4604
|
{
|
|
4605
|
+
readonly "Type": Mutable<S["Type"]>
|
|
4606
|
+
readonly "Encoded": Mutable<S["Encoded"]>
|
|
4607
|
+
readonly "DecodingServices": S["DecodingServices"]
|
|
4608
|
+
readonly "EncodingServices": S["EncodingServices"]
|
|
4609
|
+
// "~type.make" and "~type.make.in" as they are because they are contravariant
|
|
4610
|
+
readonly "~type.make.in": S["~type.make.in"]
|
|
4611
|
+
readonly "~type.make": S["~type.make"]
|
|
4612
|
+
readonly "Iso": S["Iso"]
|
|
4442
4613
|
readonly schema: S
|
|
4443
4614
|
}
|
|
4444
4615
|
|
|
4445
4616
|
interface mutableLambda extends Lambda {
|
|
4446
|
-
<S extends
|
|
4447
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
4617
|
+
<S extends Constraint & { readonly "ast": SchemaAST.Arrays }>(self: S): mutable<S>
|
|
4618
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint & { readonly "ast": SchemaAST.Arrays } ?
|
|
4448
4619
|
mutable<this["~lambda.in"]>
|
|
4449
4620
|
: "Error: schema not eligible for mutable"
|
|
4450
4621
|
}
|
|
@@ -4476,18 +4647,19 @@ export const mutable = Struct_.lambda<mutableLambda>((schema) => {
|
|
|
4476
4647
|
* @category models
|
|
4477
4648
|
* @since 3.10.0
|
|
4478
4649
|
*/
|
|
4479
|
-
export interface Union<Members extends ReadonlyArray<
|
|
4480
|
-
|
|
4481
|
-
{ [K in keyof Members]: Members[K]["Type"] }[number],
|
|
4482
|
-
{ [K in keyof Members]: Members[K]["Encoded"] }[number],
|
|
4483
|
-
{ [K in keyof Members]: Members[K]["DecodingServices"] }[number],
|
|
4484
|
-
{ [K in keyof Members]: Members[K]["EncodingServices"] }[number],
|
|
4650
|
+
export interface Union<Members extends ReadonlyArray<Constraint>> extends
|
|
4651
|
+
BottomLazy<
|
|
4485
4652
|
SchemaAST.Union<{ [K in keyof Members]: Members[K]["ast"] }[number]>,
|
|
4486
|
-
Union<Members
|
|
4487
|
-
{ [K in keyof Members]: Members[K]["~type.make"] }[number],
|
|
4488
|
-
{ [K in keyof Members]: Members[K]["Iso"] }[number]
|
|
4653
|
+
Union<Members>
|
|
4489
4654
|
>
|
|
4490
4655
|
{
|
|
4656
|
+
readonly "Type": { [K in keyof Members]: Members[K]["Type"] }[number]
|
|
4657
|
+
readonly "Encoded": { [K in keyof Members]: Members[K]["Encoded"] }[number]
|
|
4658
|
+
readonly "DecodingServices": { [K in keyof Members]: Members[K]["DecodingServices"] }[number]
|
|
4659
|
+
readonly "EncodingServices": { [K in keyof Members]: Members[K]["EncodingServices"] }[number]
|
|
4660
|
+
readonly "~type.make.in": { [K in keyof Members]: Members[K]["~type.make"] }[number]
|
|
4661
|
+
readonly "~type.make": { [K in keyof Members]: Members[K]["~type.make"] }[number]
|
|
4662
|
+
readonly "Iso": { [K in keyof Members]: Members[K]["Iso"] }[number]
|
|
4491
4663
|
readonly members: Members
|
|
4492
4664
|
/**
|
|
4493
4665
|
* Returns a new union with the members modified by the provided function.
|
|
@@ -4505,7 +4677,7 @@ export interface Union<Members extends ReadonlyArray<Top>> extends
|
|
|
4505
4677
|
* use this option if you have verified that your refinements remain correct
|
|
4506
4678
|
* after the transformation.
|
|
4507
4679
|
*/
|
|
4508
|
-
mapMembers<To extends ReadonlyArray<
|
|
4680
|
+
mapMembers<To extends ReadonlyArray<Constraint>>(
|
|
4509
4681
|
f: (members: Members) => To,
|
|
4510
4682
|
options?: {
|
|
4511
4683
|
readonly unsafePreserveChecks?: boolean | undefined
|
|
@@ -4513,13 +4685,13 @@ export interface Union<Members extends ReadonlyArray<Top>> extends
|
|
|
4513
4685
|
): Union<Simplify<Readonly<To>>>
|
|
4514
4686
|
}
|
|
4515
4687
|
|
|
4516
|
-
function makeUnion<Members extends ReadonlyArray<
|
|
4688
|
+
function makeUnion<Members extends ReadonlyArray<Constraint>>(
|
|
4517
4689
|
ast: SchemaAST.Union<Members[number]["ast"]>,
|
|
4518
4690
|
members: Members
|
|
4519
4691
|
): Union<Members> {
|
|
4520
4692
|
return make(ast, {
|
|
4521
4693
|
members,
|
|
4522
|
-
mapMembers<To extends ReadonlyArray<
|
|
4694
|
+
mapMembers<To extends ReadonlyArray<Constraint>>(
|
|
4523
4695
|
this: Union<Members>,
|
|
4524
4696
|
f: (members: Members) => To,
|
|
4525
4697
|
options?: {
|
|
@@ -4559,7 +4731,7 @@ function makeUnion<Members extends ReadonlyArray<Top>>(
|
|
|
4559
4731
|
* @category constructors
|
|
4560
4732
|
* @since 3.10.0
|
|
4561
4733
|
*/
|
|
4562
|
-
export function Union<const Members extends ReadonlyArray<
|
|
4734
|
+
export function Union<const Members extends ReadonlyArray<Constraint>>(
|
|
4563
4735
|
members: Members,
|
|
4564
4736
|
options?: { mode?: "anyOf" | "oneOf" }
|
|
4565
4737
|
): Union<Members> {
|
|
@@ -4580,7 +4752,7 @@ export interface Literals<L extends ReadonlyArray<SchemaAST.LiteralValue>>
|
|
|
4580
4752
|
/**
|
|
4581
4753
|
* Map over the members of the union.
|
|
4582
4754
|
*/
|
|
4583
|
-
mapMembers<To extends ReadonlyArray<
|
|
4755
|
+
mapMembers<To extends ReadonlyArray<Constraint>>(f: (members: this["members"]) => To): Union<Simplify<Readonly<To>>>
|
|
4584
4756
|
|
|
4585
4757
|
pick<const L2 extends ReadonlyArray<L[number]>>(literals: L2): Literals<L2>
|
|
4586
4758
|
|
|
@@ -4610,7 +4782,7 @@ export function Literals<const L extends ReadonlyArray<SchemaAST.LiteralValue>>(
|
|
|
4610
4782
|
return make(SchemaAST.union(members, "anyOf", undefined), {
|
|
4611
4783
|
literals,
|
|
4612
4784
|
members,
|
|
4613
|
-
mapMembers<To extends ReadonlyArray<
|
|
4785
|
+
mapMembers<To extends ReadonlyArray<Constraint>>(
|
|
4614
4786
|
this: Literals<L>,
|
|
4615
4787
|
f: (members: Literals<L>["members"]) => To
|
|
4616
4788
|
): Union<Simplify<Readonly<To>>> {
|
|
@@ -4633,13 +4805,13 @@ export function Literals<const L extends ReadonlyArray<SchemaAST.LiteralValue>>(
|
|
|
4633
4805
|
* @category models
|
|
4634
4806
|
* @since 3.10.0
|
|
4635
4807
|
*/
|
|
4636
|
-
export interface NullOr<S extends
|
|
4808
|
+
export interface NullOr<S extends Constraint> extends Union<readonly [S, Null]> {
|
|
4637
4809
|
readonly "Rebuild": NullOr<S>
|
|
4638
4810
|
}
|
|
4639
4811
|
|
|
4640
4812
|
interface NullOrLambda extends Lambda {
|
|
4641
|
-
<S extends
|
|
4642
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
4813
|
+
<S extends Constraint>(self: S): NullOr<S>
|
|
4814
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint ? NullOr<this["~lambda.in"]> : never
|
|
4643
4815
|
}
|
|
4644
4816
|
|
|
4645
4817
|
/**
|
|
@@ -4656,13 +4828,13 @@ export const NullOr = Struct_.lambda<NullOrLambda>((self) => Union([self, Null])
|
|
|
4656
4828
|
* @category models
|
|
4657
4829
|
* @since 3.10.0
|
|
4658
4830
|
*/
|
|
4659
|
-
export interface UndefinedOr<S extends
|
|
4831
|
+
export interface UndefinedOr<S extends Constraint> extends Union<readonly [S, Undefined]> {
|
|
4660
4832
|
readonly "Rebuild": UndefinedOr<S>
|
|
4661
4833
|
}
|
|
4662
4834
|
|
|
4663
4835
|
interface UndefinedOrLambda extends Lambda {
|
|
4664
|
-
<S extends
|
|
4665
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
4836
|
+
<S extends Constraint>(self: S): UndefinedOr<S>
|
|
4837
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint ? UndefinedOr<this["~lambda.in"]> : never
|
|
4666
4838
|
}
|
|
4667
4839
|
|
|
4668
4840
|
/**
|
|
@@ -4679,13 +4851,13 @@ export const UndefinedOr = Struct_.lambda<UndefinedOrLambda>((self) => Union([se
|
|
|
4679
4851
|
* @category models
|
|
4680
4852
|
* @since 3.10.0
|
|
4681
4853
|
*/
|
|
4682
|
-
export interface NullishOr<S extends
|
|
4854
|
+
export interface NullishOr<S extends Constraint> extends Union<readonly [S, Null, Undefined]> {
|
|
4683
4855
|
readonly "Rebuild": NullishOr<S>
|
|
4684
4856
|
}
|
|
4685
4857
|
|
|
4686
4858
|
interface NullishOrLambda extends Lambda {
|
|
4687
|
-
<S extends
|
|
4688
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
4859
|
+
<S extends Constraint>(self: S): NullishOr<S>
|
|
4860
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint ? NullishOr<this["~lambda.in"]> : never
|
|
4689
4861
|
}
|
|
4690
4862
|
|
|
4691
4863
|
/**
|
|
@@ -4702,25 +4874,26 @@ export const NullishOr = Struct_.lambda<NullishOrLambda>((self) => Union([self,
|
|
|
4702
4874
|
* @category models
|
|
4703
4875
|
* @since 3.10.0
|
|
4704
4876
|
*/
|
|
4705
|
-
export interface suspend<S extends
|
|
4706
|
-
|
|
4707
|
-
S["Type"],
|
|
4708
|
-
S["Encoded"],
|
|
4709
|
-
S["DecodingServices"],
|
|
4710
|
-
S["EncodingServices"],
|
|
4877
|
+
export interface suspend<S extends Constraint> extends
|
|
4878
|
+
BottomLazy<
|
|
4711
4879
|
SchemaAST.Suspend,
|
|
4712
4880
|
suspend<S>,
|
|
4713
|
-
S["~type.make.in"],
|
|
4714
|
-
S["Iso"],
|
|
4715
4881
|
S["~type.parameters"],
|
|
4716
|
-
S["~type.make"],
|
|
4717
4882
|
S["~type.mutability"],
|
|
4718
4883
|
S["~type.optionality"],
|
|
4719
4884
|
S["~type.constructor.default"],
|
|
4720
4885
|
S["~encoded.mutability"],
|
|
4721
4886
|
S["~encoded.optionality"]
|
|
4722
4887
|
>
|
|
4723
|
-
{
|
|
4888
|
+
{
|
|
4889
|
+
readonly "Type": S["Type"]
|
|
4890
|
+
readonly "Encoded": S["Encoded"]
|
|
4891
|
+
readonly "DecodingServices": S["DecodingServices"]
|
|
4892
|
+
readonly "EncodingServices": S["EncodingServices"]
|
|
4893
|
+
readonly "~type.make.in": S["~type.make.in"]
|
|
4894
|
+
readonly "~type.make": S["~type.make"]
|
|
4895
|
+
readonly "Iso": S["Iso"]
|
|
4896
|
+
}
|
|
4724
4897
|
|
|
4725
4898
|
/**
|
|
4726
4899
|
* Creates a suspended schema that defers evaluation until needed. This is
|
|
@@ -4746,7 +4919,7 @@ export interface suspend<S extends Top> extends
|
|
|
4746
4919
|
* @category constructors
|
|
4747
4920
|
* @since 3.10.0
|
|
4748
4921
|
*/
|
|
4749
|
-
export function suspend<S extends
|
|
4922
|
+
export function suspend<S extends Constraint>(f: () => S): suspend<S> {
|
|
4750
4923
|
return make(new SchemaAST.Suspend(() => f().ast))
|
|
4751
4924
|
}
|
|
4752
4925
|
|
|
@@ -4779,18 +4952,11 @@ export function check<S extends Top>(
|
|
|
4779
4952
|
* @category filtering
|
|
4780
4953
|
* @since 3.10.0
|
|
4781
4954
|
*/
|
|
4782
|
-
export interface refine<T extends S["Type"], S extends
|
|
4783
|
-
|
|
4784
|
-
T,
|
|
4785
|
-
S["Encoded"],
|
|
4786
|
-
S["DecodingServices"],
|
|
4787
|
-
S["EncodingServices"],
|
|
4955
|
+
export interface refine<T extends S["Type"], S extends Constraint> extends
|
|
4956
|
+
BottomLazy<
|
|
4788
4957
|
S["ast"],
|
|
4789
4958
|
refine<T, S>,
|
|
4790
|
-
S["~type.make.in"],
|
|
4791
|
-
T,
|
|
4792
4959
|
S["~type.parameters"],
|
|
4793
|
-
T,
|
|
4794
4960
|
S["~type.mutability"],
|
|
4795
4961
|
S["~type.optionality"],
|
|
4796
4962
|
S["~type.constructor.default"],
|
|
@@ -4798,6 +4964,13 @@ export interface refine<T extends S["Type"], S extends Top> extends
|
|
|
4798
4964
|
S["~encoded.optionality"]
|
|
4799
4965
|
>
|
|
4800
4966
|
{
|
|
4967
|
+
readonly "Type": T
|
|
4968
|
+
readonly "Encoded": S["Encoded"]
|
|
4969
|
+
readonly "DecodingServices": S["DecodingServices"]
|
|
4970
|
+
readonly "EncodingServices": S["EncodingServices"]
|
|
4971
|
+
readonly "~type.make.in": S["~type.make.in"]
|
|
4972
|
+
readonly "~type.make": T
|
|
4973
|
+
readonly "Iso": T
|
|
4801
4974
|
readonly schema: S
|
|
4802
4975
|
}
|
|
4803
4976
|
|
|
@@ -4816,7 +4989,7 @@ export interface refine<T extends S["Type"], S extends Top> extends
|
|
|
4816
4989
|
* @category filtering
|
|
4817
4990
|
* @since 3.10.0
|
|
4818
4991
|
*/
|
|
4819
|
-
export function refine<S extends
|
|
4992
|
+
export function refine<S extends Constraint, T extends S["Type"]>(
|
|
4820
4993
|
refinement: (value: S["Type"]) => value is T,
|
|
4821
4994
|
annotations?: Annotations.Filter
|
|
4822
4995
|
) {
|
|
@@ -4832,18 +5005,11 @@ type DistributeBrands<B> = UnionToIntersection<B extends infer U extends string
|
|
|
4832
5005
|
* @category branding
|
|
4833
5006
|
* @since 3.10.0
|
|
4834
5007
|
*/
|
|
4835
|
-
export interface brand<S extends
|
|
4836
|
-
|
|
4837
|
-
S["Type"] & DistributeBrands<B>,
|
|
4838
|
-
S["Encoded"],
|
|
4839
|
-
S["DecodingServices"],
|
|
4840
|
-
S["EncodingServices"],
|
|
5008
|
+
export interface brand<S extends Constraint, B> extends
|
|
5009
|
+
BottomLazy<
|
|
4841
5010
|
S["ast"],
|
|
4842
5011
|
brand<S, B>,
|
|
4843
|
-
S["~type.make.in"],
|
|
4844
|
-
S["Type"] & DistributeBrands<B>,
|
|
4845
5012
|
S["~type.parameters"],
|
|
4846
|
-
S["Type"] & DistributeBrands<B>,
|
|
4847
5013
|
S["~type.mutability"],
|
|
4848
5014
|
S["~type.optionality"],
|
|
4849
5015
|
S["~type.constructor.default"],
|
|
@@ -4851,6 +5017,13 @@ export interface brand<S extends Top, B> extends
|
|
|
4851
5017
|
S["~encoded.optionality"]
|
|
4852
5018
|
>
|
|
4853
5019
|
{
|
|
5020
|
+
readonly "Type": S["Type"] & DistributeBrands<B>
|
|
5021
|
+
readonly "Encoded": S["Encoded"]
|
|
5022
|
+
readonly "DecodingServices": S["DecodingServices"]
|
|
5023
|
+
readonly "EncodingServices": S["EncodingServices"]
|
|
5024
|
+
readonly "~type.make.in": S["~type.make.in"]
|
|
5025
|
+
readonly "~type.make": S["Type"] & DistributeBrands<B>
|
|
5026
|
+
readonly "Iso": S["Type"] & DistributeBrands<B>
|
|
4854
5027
|
readonly schema: S
|
|
4855
5028
|
readonly identifier: string
|
|
4856
5029
|
}
|
|
@@ -4875,7 +5048,7 @@ export interface brand<S extends Top, B> extends
|
|
|
4875
5048
|
* @since 3.10.0
|
|
4876
5049
|
*/
|
|
4877
5050
|
export function brand<B extends string>(identifier: B) {
|
|
4878
|
-
return <S extends
|
|
5051
|
+
return <S extends ConstraintRebuildable>(schema: S): brand<S["Rebuild"], B> =>
|
|
4879
5052
|
make(SchemaAST.brand(schema.ast, identifier), { schema, identifier })
|
|
4880
5053
|
}
|
|
4881
5054
|
|
|
@@ -4900,18 +5073,11 @@ export function fromBrand<A extends Brand.Brand<any>>(identifier: string, ctor:
|
|
|
4900
5073
|
* @category decoding
|
|
4901
5074
|
* @since 4.0.0
|
|
4902
5075
|
*/
|
|
4903
|
-
export interface middlewareDecoding<S extends
|
|
4904
|
-
|
|
4905
|
-
S["Type"],
|
|
4906
|
-
S["Encoded"],
|
|
4907
|
-
RD,
|
|
4908
|
-
S["EncodingServices"],
|
|
5076
|
+
export interface middlewareDecoding<S extends Constraint, RD> extends
|
|
5077
|
+
BottomLazy<
|
|
4909
5078
|
S["ast"],
|
|
4910
5079
|
middlewareDecoding<S, RD>,
|
|
4911
|
-
S["~type.make.in"],
|
|
4912
|
-
S["Iso"],
|
|
4913
5080
|
S["~type.parameters"],
|
|
4914
|
-
S["~type.make"],
|
|
4915
5081
|
S["~type.mutability"],
|
|
4916
5082
|
S["~type.optionality"],
|
|
4917
5083
|
S["~type.constructor.default"],
|
|
@@ -4919,6 +5085,13 @@ export interface middlewareDecoding<S extends Top, RD> extends
|
|
|
4919
5085
|
S["~encoded.optionality"]
|
|
4920
5086
|
>
|
|
4921
5087
|
{
|
|
5088
|
+
readonly "Type": S["Type"]
|
|
5089
|
+
readonly "Encoded": S["Encoded"]
|
|
5090
|
+
readonly "DecodingServices": RD
|
|
5091
|
+
readonly "EncodingServices": S["EncodingServices"]
|
|
5092
|
+
readonly "~type.make.in": S["~type.make.in"]
|
|
5093
|
+
readonly "~type.make": S["~type.make"]
|
|
5094
|
+
readonly "Iso": S["Iso"]
|
|
4922
5095
|
readonly schema: S
|
|
4923
5096
|
}
|
|
4924
5097
|
|
|
@@ -4947,7 +5120,7 @@ export interface middlewareDecoding<S extends Top, RD> extends
|
|
|
4947
5120
|
* @category decoding
|
|
4948
5121
|
* @since 4.0.0
|
|
4949
5122
|
*/
|
|
4950
|
-
export function middlewareDecoding<S extends
|
|
5123
|
+
export function middlewareDecoding<S extends Constraint, RD>(
|
|
4951
5124
|
decode: (
|
|
4952
5125
|
effect: Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, S["DecodingServices"]>,
|
|
4953
5126
|
options: SchemaAST.ParseOptions
|
|
@@ -4966,18 +5139,11 @@ export function middlewareDecoding<S extends Top, RD>(
|
|
|
4966
5139
|
* @category encoding
|
|
4967
5140
|
* @since 4.0.0
|
|
4968
5141
|
*/
|
|
4969
|
-
export interface middlewareEncoding<S extends
|
|
4970
|
-
|
|
4971
|
-
S["Type"],
|
|
4972
|
-
S["Encoded"],
|
|
4973
|
-
S["DecodingServices"],
|
|
4974
|
-
RE,
|
|
5142
|
+
export interface middlewareEncoding<S extends Constraint, RE> extends
|
|
5143
|
+
BottomLazy<
|
|
4975
5144
|
S["ast"],
|
|
4976
5145
|
middlewareEncoding<S, RE>,
|
|
4977
|
-
S["~type.make.in"],
|
|
4978
|
-
S["Iso"],
|
|
4979
5146
|
S["~type.parameters"],
|
|
4980
|
-
S["~type.make"],
|
|
4981
5147
|
S["~type.mutability"],
|
|
4982
5148
|
S["~type.optionality"],
|
|
4983
5149
|
S["~type.constructor.default"],
|
|
@@ -4985,6 +5151,13 @@ export interface middlewareEncoding<S extends Top, RE> extends
|
|
|
4985
5151
|
S["~encoded.optionality"]
|
|
4986
5152
|
>
|
|
4987
5153
|
{
|
|
5154
|
+
readonly "Type": S["Type"]
|
|
5155
|
+
readonly "Encoded": S["Encoded"]
|
|
5156
|
+
readonly "DecodingServices": S["DecodingServices"]
|
|
5157
|
+
readonly "EncodingServices": RE
|
|
5158
|
+
readonly "~type.make.in": S["~type.make.in"]
|
|
5159
|
+
readonly "~type.make": S["~type.make"]
|
|
5160
|
+
readonly "Iso": S["Iso"]
|
|
4988
5161
|
readonly schema: S
|
|
4989
5162
|
}
|
|
4990
5163
|
|
|
@@ -5013,7 +5186,7 @@ export interface middlewareEncoding<S extends Top, RE> extends
|
|
|
5013
5186
|
* @category encoding
|
|
5014
5187
|
* @since 4.0.0
|
|
5015
5188
|
*/
|
|
5016
|
-
export function middlewareEncoding<S extends
|
|
5189
|
+
export function middlewareEncoding<S extends Constraint, RE>(
|
|
5017
5190
|
encode: (
|
|
5018
5191
|
effect: Effect.Effect<Option_.Option<S["Encoded"]>, SchemaIssue.Issue, S["EncodingServices"]>,
|
|
5019
5192
|
options: SchemaAST.ParseOptions
|
|
@@ -5048,9 +5221,9 @@ export function middlewareEncoding<S extends Top, RE>(
|
|
|
5048
5221
|
* @category error handling
|
|
5049
5222
|
* @since 4.0.0
|
|
5050
5223
|
*/
|
|
5051
|
-
export function catchDecoding<S extends
|
|
5224
|
+
export function catchDecoding<S extends Constraint>(
|
|
5052
5225
|
f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue>
|
|
5053
|
-
): (self: S) => S["
|
|
5226
|
+
): (self: S) => middlewareDecoding<S, S["DecodingServices"]> {
|
|
5054
5227
|
return catchDecodingWithContext(f)
|
|
5055
5228
|
}
|
|
5056
5229
|
|
|
@@ -5074,11 +5247,11 @@ export function catchDecoding<S extends Top>(
|
|
|
5074
5247
|
* @category error handling
|
|
5075
5248
|
* @since 4.0.0
|
|
5076
5249
|
*/
|
|
5077
|
-
export function catchDecodingWithContext<S extends
|
|
5250
|
+
export function catchDecodingWithContext<S extends Constraint, R = never>(
|
|
5078
5251
|
f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, R>
|
|
5079
5252
|
) {
|
|
5080
5253
|
return (self: S): middlewareDecoding<S, S["DecodingServices"] | R> =>
|
|
5081
|
-
|
|
5254
|
+
middlewareDecoding<S, S["DecodingServices"] | R>(Effect.catchEager(f))(self)
|
|
5082
5255
|
}
|
|
5083
5256
|
|
|
5084
5257
|
/**
|
|
@@ -5093,9 +5266,9 @@ export function catchDecodingWithContext<S extends Top, R = never>(
|
|
|
5093
5266
|
* @category error handling
|
|
5094
5267
|
* @since 4.0.0
|
|
5095
5268
|
*/
|
|
5096
|
-
export function catchEncoding<S extends
|
|
5269
|
+
export function catchEncoding<S extends Constraint>(
|
|
5097
5270
|
f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Encoded"]>, SchemaIssue.Issue>
|
|
5098
|
-
): (self: S) => S["
|
|
5271
|
+
): (self: S) => middlewareEncoding<S, S["EncodingServices"]> {
|
|
5099
5272
|
return catchEncodingWithContext(f)
|
|
5100
5273
|
}
|
|
5101
5274
|
|
|
@@ -5119,11 +5292,11 @@ export function catchEncoding<S extends Top>(
|
|
|
5119
5292
|
* @category error handling
|
|
5120
5293
|
* @since 4.0.0
|
|
5121
5294
|
*/
|
|
5122
|
-
export function catchEncodingWithContext<S extends
|
|
5295
|
+
export function catchEncodingWithContext<S extends Constraint, R = never>(
|
|
5123
5296
|
f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Encoded"]>, SchemaIssue.Issue, R>
|
|
5124
5297
|
) {
|
|
5125
5298
|
return (self: S): middlewareEncoding<S, S["EncodingServices"] | R> =>
|
|
5126
|
-
|
|
5299
|
+
middlewareEncoding<S, S["EncodingServices"] | R>(Effect.catchEager(f))(self)
|
|
5127
5300
|
}
|
|
5128
5301
|
|
|
5129
5302
|
/**
|
|
@@ -5132,18 +5305,11 @@ export function catchEncodingWithContext<S extends Top, R = never>(
|
|
|
5132
5305
|
* @category transforming
|
|
5133
5306
|
* @since 4.0.0
|
|
5134
5307
|
*/
|
|
5135
|
-
export interface decodeTo<To extends
|
|
5136
|
-
|
|
5137
|
-
To["Type"],
|
|
5138
|
-
From["Encoded"],
|
|
5139
|
-
To["DecodingServices"] | From["DecodingServices"] | RD,
|
|
5140
|
-
To["EncodingServices"] | From["EncodingServices"] | RE,
|
|
5308
|
+
export interface decodeTo<To extends Constraint, From extends Constraint, RD = never, RE = never> extends
|
|
5309
|
+
BottomLazy<
|
|
5141
5310
|
To["ast"],
|
|
5142
5311
|
decodeTo<To, From, RD, RE>,
|
|
5143
|
-
To["~type.make.in"],
|
|
5144
|
-
To["Iso"],
|
|
5145
5312
|
To["~type.parameters"],
|
|
5146
|
-
To["~type.make"],
|
|
5147
5313
|
To["~type.mutability"],
|
|
5148
5314
|
To["~type.optionality"],
|
|
5149
5315
|
To["~type.constructor.default"],
|
|
@@ -5151,6 +5317,13 @@ export interface decodeTo<To extends Top, From extends Top, RD = never, RE = nev
|
|
|
5151
5317
|
From["~encoded.optionality"]
|
|
5152
5318
|
>
|
|
5153
5319
|
{
|
|
5320
|
+
readonly "Type": To["Type"]
|
|
5321
|
+
readonly "Encoded": From["Encoded"]
|
|
5322
|
+
readonly "DecodingServices": To["DecodingServices"] | From["DecodingServices"] | RD
|
|
5323
|
+
readonly "EncodingServices": To["EncodingServices"] | From["EncodingServices"] | RE
|
|
5324
|
+
readonly "~type.make.in": To["~type.make.in"]
|
|
5325
|
+
readonly "~type.make": To["~type.make"]
|
|
5326
|
+
readonly "Iso": To["Iso"]
|
|
5154
5327
|
readonly from: From
|
|
5155
5328
|
readonly to: To
|
|
5156
5329
|
}
|
|
@@ -5161,7 +5334,7 @@ export interface decodeTo<To extends Top, From extends Top, RD = never, RE = nev
|
|
|
5161
5334
|
* @category transforming
|
|
5162
5335
|
* @since 3.10.0
|
|
5163
5336
|
*/
|
|
5164
|
-
export interface compose<To extends
|
|
5337
|
+
export interface compose<To extends Constraint, From extends Constraint> extends decodeTo<To, From> {}
|
|
5165
5338
|
|
|
5166
5339
|
/**
|
|
5167
5340
|
* Creates a schema that transforms from a source schema to a target schema.
|
|
@@ -5211,15 +5384,15 @@ export interface compose<To extends Top, From extends Top> extends decodeTo<To,
|
|
|
5211
5384
|
* @category transforming
|
|
5212
5385
|
* @since 4.0.0
|
|
5213
5386
|
*/
|
|
5214
|
-
export function decodeTo<To extends
|
|
5215
|
-
export function decodeTo<To extends
|
|
5387
|
+
export function decodeTo<To extends Constraint>(to: To): <From extends Constraint>(from: From) => compose<To, From>
|
|
5388
|
+
export function decodeTo<To extends Constraint, From extends Constraint, RD = never, RE = never>(
|
|
5216
5389
|
to: To,
|
|
5217
5390
|
transformation: {
|
|
5218
5391
|
readonly decode: SchemaGetter.Getter<NoInfer<To["Encoded"]>, NoInfer<From["Type"]>, RD>
|
|
5219
5392
|
readonly encode: SchemaGetter.Getter<NoInfer<From["Type"]>, NoInfer<To["Encoded"]>, RE>
|
|
5220
5393
|
}
|
|
5221
5394
|
): (from: From) => decodeTo<To, From, RD, RE>
|
|
5222
|
-
export function decodeTo<To extends
|
|
5395
|
+
export function decodeTo<To extends Constraint, From extends Constraint, RD = never, RE = never>(
|
|
5223
5396
|
to: To,
|
|
5224
5397
|
transformation?: {
|
|
5225
5398
|
readonly decode: SchemaGetter.Getter<To["Encoded"], From["Type"], RD>
|
|
@@ -5284,12 +5457,12 @@ export function decodeTo<To extends Top, From extends Top, RD = never, RE = neve
|
|
|
5284
5457
|
* @category transforming
|
|
5285
5458
|
* @since 3.10.0
|
|
5286
5459
|
*/
|
|
5287
|
-
export function decode<S extends
|
|
5460
|
+
export function decode<S extends Constraint, RD = never, RE = never>(transformation: {
|
|
5288
5461
|
readonly decode: SchemaGetter.Getter<S["Type"], S["Type"], RD>
|
|
5289
5462
|
readonly encode: SchemaGetter.Getter<S["Type"], S["Type"], RE>
|
|
5290
5463
|
}) {
|
|
5291
5464
|
return (self: S): decodeTo<toType<S>, S, RD, RE> => {
|
|
5292
|
-
return
|
|
5465
|
+
return decodeTo<toType<S>, S, RD, RE>(toType(self), transformation)(self)
|
|
5293
5466
|
}
|
|
5294
5467
|
}
|
|
5295
5468
|
|
|
@@ -5322,17 +5495,17 @@ export function decode<S extends Top, RD = never, RE = never>(transformation: {
|
|
|
5322
5495
|
* @category transforming
|
|
5323
5496
|
* @since 4.0.0
|
|
5324
5497
|
*/
|
|
5325
|
-
export function encodeTo<To extends
|
|
5498
|
+
export function encodeTo<To extends Constraint>(
|
|
5326
5499
|
to: To
|
|
5327
|
-
): <From extends
|
|
5328
|
-
export function encodeTo<To extends
|
|
5500
|
+
): <From extends Constraint>(from: From) => decodeTo<From, To>
|
|
5501
|
+
export function encodeTo<To extends Constraint, From extends Constraint, RD = never, RE = never>(
|
|
5329
5502
|
to: To,
|
|
5330
5503
|
transformation: {
|
|
5331
5504
|
readonly decode: SchemaGetter.Getter<NoInfer<From["Encoded"]>, NoInfer<To["Type"]>, RD>
|
|
5332
5505
|
readonly encode: SchemaGetter.Getter<NoInfer<To["Type"]>, NoInfer<From["Encoded"]>, RE>
|
|
5333
5506
|
}
|
|
5334
5507
|
): (from: From) => decodeTo<From, To, RD, RE>
|
|
5335
|
-
export function encodeTo<To extends
|
|
5508
|
+
export function encodeTo<To extends Constraint, From extends Constraint, RD = never, RE = never>(
|
|
5336
5509
|
to: To,
|
|
5337
5510
|
transformation?: {
|
|
5338
5511
|
readonly decode: SchemaGetter.Getter<From["Encoded"], To["Type"], RD>
|
|
@@ -5341,8 +5514,8 @@ export function encodeTo<To extends Top, From extends Top, RD = never, RE = neve
|
|
|
5341
5514
|
) {
|
|
5342
5515
|
return (from: From): decodeTo<From, To, RD, RE> => {
|
|
5343
5516
|
return transformation ?
|
|
5344
|
-
|
|
5345
|
-
|
|
5517
|
+
decodeTo<From, To, RD, RE>(from, transformation)(to) :
|
|
5518
|
+
decodeTo<From>(from)(to)
|
|
5346
5519
|
}
|
|
5347
5520
|
}
|
|
5348
5521
|
|
|
@@ -5371,12 +5544,12 @@ export function encodeTo<To extends Top, From extends Top, RD = never, RE = neve
|
|
|
5371
5544
|
* @category transforming
|
|
5372
5545
|
* @since 3.10.0
|
|
5373
5546
|
*/
|
|
5374
|
-
export function encode<S extends
|
|
5547
|
+
export function encode<S extends Constraint, RD = never, RE = never>(transformation: {
|
|
5375
5548
|
readonly decode: SchemaGetter.Getter<S["Encoded"], S["Encoded"], RD>
|
|
5376
5549
|
readonly encode: SchemaGetter.Getter<S["Encoded"], S["Encoded"], RE>
|
|
5377
5550
|
}) {
|
|
5378
5551
|
return (self: S): decodeTo<S, toEncoded<S>, RD, RE> => {
|
|
5379
|
-
return toEncoded(self)
|
|
5552
|
+
return decodeTo<S, toEncoded<S>, RD, RE>(self, transformation)(toEncoded(self))
|
|
5380
5553
|
}
|
|
5381
5554
|
}
|
|
5382
5555
|
|
|
@@ -5400,18 +5573,11 @@ export interface WithoutConstructorDefault {
|
|
|
5400
5573
|
* @category constructors
|
|
5401
5574
|
* @since 3.10.0
|
|
5402
5575
|
*/
|
|
5403
|
-
export interface withConstructorDefault<S extends
|
|
5404
|
-
|
|
5405
|
-
S["Type"],
|
|
5406
|
-
S["Encoded"],
|
|
5407
|
-
S["DecodingServices"],
|
|
5408
|
-
S["EncodingServices"],
|
|
5576
|
+
export interface withConstructorDefault<S extends Constraint & WithoutConstructorDefault> extends
|
|
5577
|
+
BottomLazy<
|
|
5409
5578
|
S["ast"],
|
|
5410
5579
|
withConstructorDefault<S>,
|
|
5411
|
-
S["~type.make.in"],
|
|
5412
|
-
S["Iso"],
|
|
5413
5580
|
S["~type.parameters"],
|
|
5414
|
-
S["~type.make"],
|
|
5415
5581
|
S["~type.mutability"],
|
|
5416
5582
|
S["~type.optionality"],
|
|
5417
5583
|
"with-default",
|
|
@@ -5419,6 +5585,13 @@ export interface withConstructorDefault<S extends Top & WithoutConstructorDefaul
|
|
|
5419
5585
|
S["~encoded.optionality"]
|
|
5420
5586
|
>
|
|
5421
5587
|
{
|
|
5588
|
+
readonly "Type": S["Type"]
|
|
5589
|
+
readonly "Encoded": S["Encoded"]
|
|
5590
|
+
readonly "DecodingServices": S["DecodingServices"]
|
|
5591
|
+
readonly "EncodingServices": S["EncodingServices"]
|
|
5592
|
+
readonly "~type.make.in": S["~type.make.in"]
|
|
5593
|
+
readonly "~type.make": S["~type.make"]
|
|
5594
|
+
readonly "Iso": S["Iso"]
|
|
5422
5595
|
readonly schema: S
|
|
5423
5596
|
}
|
|
5424
5597
|
|
|
@@ -5449,7 +5622,7 @@ export interface withConstructorDefault<S extends Top & WithoutConstructorDefaul
|
|
|
5449
5622
|
* @category constructors
|
|
5450
5623
|
* @since 3.10.0
|
|
5451
5624
|
*/
|
|
5452
|
-
export function withConstructorDefault<S extends
|
|
5625
|
+
export function withConstructorDefault<S extends Constraint & WithoutConstructorDefault>(
|
|
5453
5626
|
// `S["~type.make.in"]` instead of `S["Type"]` is intentional here because
|
|
5454
5627
|
// it makes easier to define the default value if there are nested defaults
|
|
5455
5628
|
defaultValue: Effect.Effect<S["~type.make.in"], SchemaError>
|
|
@@ -5464,7 +5637,9 @@ export function withConstructorDefault<S extends Top & WithoutConstructorDefault
|
|
|
5464
5637
|
* @category decoding
|
|
5465
5638
|
* @since 4.0.0
|
|
5466
5639
|
*/
|
|
5467
|
-
export interface withDecodingDefaultKey<S extends
|
|
5640
|
+
export interface withDecodingDefaultKey<S extends Constraint, R = never>
|
|
5641
|
+
extends decodeTo<S, optionalKey<toEncoded<S>>, R>
|
|
5642
|
+
{
|
|
5468
5643
|
readonly "Rebuild": withDecodingDefaultKey<S, R>
|
|
5469
5644
|
}
|
|
5470
5645
|
|
|
@@ -5518,7 +5693,7 @@ export type DecodingDefaultOptions = {
|
|
|
5518
5693
|
* @category decoding
|
|
5519
5694
|
* @since 4.0.0
|
|
5520
5695
|
*/
|
|
5521
|
-
export function withDecodingDefaultKey<S extends
|
|
5696
|
+
export function withDecodingDefaultKey<S extends Constraint, R = never>(
|
|
5522
5697
|
defaultValue: Effect.Effect<S["Encoded"], SchemaError, R>,
|
|
5523
5698
|
options?: DecodingDefaultOptions
|
|
5524
5699
|
) {
|
|
@@ -5537,7 +5712,7 @@ export function withDecodingDefaultKey<S extends Top, R = never>(
|
|
|
5537
5712
|
* @category decoding
|
|
5538
5713
|
* @since 4.0.0
|
|
5539
5714
|
*/
|
|
5540
|
-
export interface withDecodingDefaultTypeKey<S extends
|
|
5715
|
+
export interface withDecodingDefaultTypeKey<S extends Constraint, R = never>
|
|
5541
5716
|
extends decodeTo<withDecodingDefaultKey<toType<S>, R>, optionalKey<S>>
|
|
5542
5717
|
{
|
|
5543
5718
|
readonly "Rebuild": withDecodingDefaultTypeKey<S, R>
|
|
@@ -5565,7 +5740,7 @@ export interface withDecodingDefaultTypeKey<S extends Top, R = never>
|
|
|
5565
5740
|
* @category decoding
|
|
5566
5741
|
* @since 4.0.0
|
|
5567
5742
|
*/
|
|
5568
|
-
export function withDecodingDefaultTypeKey<S extends
|
|
5743
|
+
export function withDecodingDefaultTypeKey<S extends Constraint, R = never>(
|
|
5569
5744
|
defaultValue: Effect.Effect<S["Type"], SchemaError, R>,
|
|
5570
5745
|
options?: DecodingDefaultOptions
|
|
5571
5746
|
) {
|
|
@@ -5583,7 +5758,7 @@ export function withDecodingDefaultTypeKey<S extends Top, R = never>(
|
|
|
5583
5758
|
* @category decoding
|
|
5584
5759
|
* @since 3.10.0
|
|
5585
5760
|
*/
|
|
5586
|
-
export interface withDecodingDefault<S extends
|
|
5761
|
+
export interface withDecodingDefault<S extends Constraint, R = never> extends decodeTo<S, optional<toEncoded<S>>, R> {
|
|
5587
5762
|
readonly "Rebuild": withDecodingDefault<S, R>
|
|
5588
5763
|
}
|
|
5589
5764
|
|
|
@@ -5626,7 +5801,7 @@ export interface withDecodingDefault<S extends Top, R = never> extends decodeTo<
|
|
|
5626
5801
|
* @category decoding
|
|
5627
5802
|
* @since 3.10.0
|
|
5628
5803
|
*/
|
|
5629
|
-
export function withDecodingDefault<S extends
|
|
5804
|
+
export function withDecodingDefault<S extends Constraint, R = never>(
|
|
5630
5805
|
defaultValue: Effect.Effect<S["Encoded"], SchemaError, R>,
|
|
5631
5806
|
options?: DecodingDefaultOptions
|
|
5632
5807
|
) {
|
|
@@ -5645,7 +5820,7 @@ export function withDecodingDefault<S extends Top, R = never>(
|
|
|
5645
5820
|
* @category decoding
|
|
5646
5821
|
* @since 4.0.0
|
|
5647
5822
|
*/
|
|
5648
|
-
export interface withDecodingDefaultType<S extends
|
|
5823
|
+
export interface withDecodingDefaultType<S extends Constraint, R = never>
|
|
5649
5824
|
extends decodeTo<withDecodingDefault<toType<S>, R>, optional<S>>
|
|
5650
5825
|
{
|
|
5651
5826
|
readonly "Rebuild": withDecodingDefaultType<S, R>
|
|
@@ -5678,7 +5853,7 @@ export interface withDecodingDefaultType<S extends Top, R = never>
|
|
|
5678
5853
|
* @category decoding
|
|
5679
5854
|
* @since 4.0.0
|
|
5680
5855
|
*/
|
|
5681
|
-
export function withDecodingDefaultType<S extends
|
|
5856
|
+
export function withDecodingDefaultType<S extends Constraint, R = never>(
|
|
5682
5857
|
defaultValue: Effect.Effect<S["Type"], SchemaError, R>,
|
|
5683
5858
|
options?: DecodingDefaultOptions
|
|
5684
5859
|
) {
|
|
@@ -5833,8 +6008,8 @@ type Flatten<Schemas> = Schemas extends readonly [infer Head, ...infer Tail]
|
|
|
5833
6008
|
|
|
5834
6009
|
type TaggedUnionUtils<
|
|
5835
6010
|
Tag extends PropertyKey,
|
|
5836
|
-
Members extends ReadonlyArray<
|
|
5837
|
-
Flattened extends ReadonlyArray<
|
|
6011
|
+
Members extends ReadonlyArray<Constraint & { readonly Type: { readonly [K in Tag]: PropertyKey } }>,
|
|
6012
|
+
Flattened extends ReadonlyArray<Constraint & { readonly Type: { readonly [K in Tag]: PropertyKey } }> = Flatten<
|
|
5838
6013
|
Members
|
|
5839
6014
|
>
|
|
5840
6015
|
> = {
|
|
@@ -5868,7 +6043,7 @@ type TaggedUnionUtils<
|
|
|
5868
6043
|
*/
|
|
5869
6044
|
export type toTaggedUnion<
|
|
5870
6045
|
Tag extends PropertyKey,
|
|
5871
|
-
Members extends ReadonlyArray<
|
|
6046
|
+
Members extends ReadonlyArray<Constraint & { readonly Type: { readonly [K in Tag]: PropertyKey } }>
|
|
5872
6047
|
> = Union<Members> & TaggedUnionUtils<Tag, Members>
|
|
5873
6048
|
|
|
5874
6049
|
/**
|
|
@@ -5896,7 +6071,7 @@ export type toTaggedUnion<
|
|
|
5896
6071
|
* @since 4.0.0
|
|
5897
6072
|
*/
|
|
5898
6073
|
export function toTaggedUnion<const Tag extends PropertyKey>(tag: Tag) {
|
|
5899
|
-
return <const Members extends ReadonlyArray<
|
|
6074
|
+
return <const Members extends ReadonlyArray<Constraint & { readonly Type: { readonly [K in Tag]: PropertyKey } }>>(
|
|
5900
6075
|
self: Union<Members>
|
|
5901
6076
|
): toTaggedUnion<Tag, Members> => {
|
|
5902
6077
|
const cases: Record<PropertyKey, unknown> = {}
|
|
@@ -5907,7 +6082,7 @@ export function toTaggedUnion<const Tag extends PropertyKey>(tag: Tag) {
|
|
|
5907
6082
|
|
|
5908
6083
|
return Object.assign(self, { cases, isAnyOf, guards, match }) as any
|
|
5909
6084
|
|
|
5910
|
-
function walk(schema:
|
|
6085
|
+
function walk(schema: Constraint) {
|
|
5911
6086
|
const ast = schema.ast
|
|
5912
6087
|
|
|
5913
6088
|
if (
|
|
@@ -5950,17 +6125,19 @@ export function toTaggedUnion<const Tag extends PropertyKey>(tag: Tag) {
|
|
|
5950
6125
|
* @category models
|
|
5951
6126
|
* @since 4.0.0
|
|
5952
6127
|
*/
|
|
5953
|
-
export interface TaggedUnion<Cases extends Record<string,
|
|
5954
|
-
|
|
5955
|
-
{ [K in keyof Cases]: Cases[K]["Type"] }[keyof Cases],
|
|
5956
|
-
{ [K in keyof Cases]: Cases[K]["Encoded"] }[keyof Cases],
|
|
5957
|
-
{ [K in keyof Cases]: Cases[K]["DecodingServices"] }[keyof Cases],
|
|
5958
|
-
{ [K in keyof Cases]: Cases[K]["EncodingServices"] }[keyof Cases],
|
|
6128
|
+
export interface TaggedUnion<Cases extends Record<string, Constraint>> extends
|
|
6129
|
+
BottomLazy<
|
|
5959
6130
|
SchemaAST.Union<SchemaAST.Objects>,
|
|
5960
|
-
TaggedUnion<Cases
|
|
5961
|
-
{ [K in keyof Cases]: Cases[K]["~type.make"] }[keyof Cases]
|
|
6131
|
+
TaggedUnion<Cases>
|
|
5962
6132
|
>
|
|
5963
6133
|
{
|
|
6134
|
+
readonly "Type": { [K in keyof Cases]: Cases[K]["Type"] }[keyof Cases]
|
|
6135
|
+
readonly "Encoded": { [K in keyof Cases]: Cases[K]["Encoded"] }[keyof Cases]
|
|
6136
|
+
readonly "DecodingServices": { [K in keyof Cases]: Cases[K]["DecodingServices"] }[keyof Cases]
|
|
6137
|
+
readonly "EncodingServices": { [K in keyof Cases]: Cases[K]["EncodingServices"] }[keyof Cases]
|
|
6138
|
+
readonly "~type.make.in": { [K in keyof Cases]: Cases[K]["~type.make"] }[keyof Cases]
|
|
6139
|
+
readonly "~type.make": { [K in keyof Cases]: Cases[K]["~type.make"] }[keyof Cases]
|
|
6140
|
+
readonly "Iso": { [K in keyof Cases]: Cases[K]["Type"] }[keyof Cases]
|
|
5964
6141
|
readonly cases: Cases
|
|
5965
6142
|
readonly isAnyOf: <const Keys>(
|
|
5966
6143
|
keys: ReadonlyArray<Keys>
|
|
@@ -6023,17 +6200,10 @@ export function TaggedUnion<const CasesByTag extends Record<string, Struct.Field
|
|
|
6023
6200
|
* @since 4.0.0
|
|
6024
6201
|
*/
|
|
6025
6202
|
export interface Opaque<Self, S extends Top, Brand> extends
|
|
6026
|
-
|
|
6027
|
-
Self,
|
|
6028
|
-
S["Encoded"],
|
|
6029
|
-
S["DecodingServices"],
|
|
6030
|
-
S["EncodingServices"],
|
|
6203
|
+
BottomLazy<
|
|
6031
6204
|
S["ast"],
|
|
6032
6205
|
S["Rebuild"],
|
|
6033
|
-
S["~type.make.in"],
|
|
6034
|
-
S["Iso"],
|
|
6035
6206
|
S["~type.parameters"],
|
|
6036
|
-
S["~type.make"],
|
|
6037
6207
|
S["~type.mutability"],
|
|
6038
6208
|
S["~type.optionality"],
|
|
6039
6209
|
S["~type.constructor.default"],
|
|
@@ -6041,6 +6211,13 @@ export interface Opaque<Self, S extends Top, Brand> extends
|
|
|
6041
6211
|
S["~encoded.optionality"]
|
|
6042
6212
|
>
|
|
6043
6213
|
{
|
|
6214
|
+
readonly "Type": Self
|
|
6215
|
+
readonly "Encoded": S["Encoded"]
|
|
6216
|
+
readonly "DecodingServices": S["DecodingServices"]
|
|
6217
|
+
readonly "EncodingServices": S["EncodingServices"]
|
|
6218
|
+
readonly "~type.make.in": S["~type.make.in"]
|
|
6219
|
+
readonly "~type.make": S["~type.make"]
|
|
6220
|
+
readonly "Iso": S["Iso"]
|
|
6044
6221
|
new(_: never): S["Type"] & Brand
|
|
6045
6222
|
}
|
|
6046
6223
|
|
|
@@ -6119,7 +6296,7 @@ export function instanceOf<C extends abstract new(...args: any) => any, Iso = In
|
|
|
6119
6296
|
* @since 4.0.0
|
|
6120
6297
|
*/
|
|
6121
6298
|
export function link<T>() {
|
|
6122
|
-
return <To extends
|
|
6299
|
+
return <To extends Constraint>(
|
|
6123
6300
|
encodeTo: To,
|
|
6124
6301
|
transformation: {
|
|
6125
6302
|
readonly decode: SchemaGetter.Getter<T, NoInfer<To["Type"]>>
|
|
@@ -8132,7 +8309,7 @@ export function isPropertiesLengthBetween(minimum: number, maximum: number, anno
|
|
|
8132
8309
|
* @category Object checks
|
|
8133
8310
|
* @since 4.0.0
|
|
8134
8311
|
*/
|
|
8135
|
-
export function isPropertyNames(keySchema:
|
|
8312
|
+
export function isPropertyNames(keySchema: Constraint, annotations?: Annotations.Filter) {
|
|
8136
8313
|
const propertyNames = toEncoded(keySchema)
|
|
8137
8314
|
const parser = SchemaParser._issue(propertyNames.ast)
|
|
8138
8315
|
return makeFilter<object>(
|
|
@@ -8258,7 +8435,7 @@ export const Char: Char = String.check(isLengthBetween(1, 1))
|
|
|
8258
8435
|
* @category Option
|
|
8259
8436
|
* @since 3.10.0
|
|
8260
8437
|
*/
|
|
8261
|
-
export interface Option<A extends
|
|
8438
|
+
export interface Option<A extends Constraint> extends
|
|
8262
8439
|
declareConstructor<
|
|
8263
8440
|
Option_.Option<A["Type"]>,
|
|
8264
8441
|
Option_.Option<A["Encoded"]>,
|
|
@@ -8281,7 +8458,7 @@ export interface Option<A extends Top> extends
|
|
|
8281
8458
|
* @category Option
|
|
8282
8459
|
* @since 4.0.0
|
|
8283
8460
|
*/
|
|
8284
|
-
export type OptionIso<A extends
|
|
8461
|
+
export type OptionIso<A extends Constraint> =
|
|
8285
8462
|
| { readonly _tag: "None" }
|
|
8286
8463
|
| { readonly _tag: "Some"; readonly value: A["Iso"] }
|
|
8287
8464
|
|
|
@@ -8291,7 +8468,7 @@ export type OptionIso<A extends Top> =
|
|
|
8291
8468
|
* @category Option
|
|
8292
8469
|
* @since 3.10.0
|
|
8293
8470
|
*/
|
|
8294
|
-
export function Option<A extends
|
|
8471
|
+
export function Option<A extends Constraint>(value: A): Option<A> {
|
|
8295
8472
|
const schema = declareConstructor<
|
|
8296
8473
|
Option_.Option<A["Type"]>,
|
|
8297
8474
|
Option_.Option<A["Encoded"]>,
|
|
@@ -8360,7 +8537,7 @@ export function Option<A extends Top>(value: A): Option<A> {
|
|
|
8360
8537
|
* @category Option
|
|
8361
8538
|
* @since 3.10.0
|
|
8362
8539
|
*/
|
|
8363
|
-
export interface OptionFromNullOr<S extends
|
|
8540
|
+
export interface OptionFromNullOr<S extends Constraint> extends decodeTo<Option<toType<S>>, NullOr<S>> {
|
|
8364
8541
|
readonly "Rebuild": OptionFromNullOr<S>
|
|
8365
8542
|
}
|
|
8366
8543
|
|
|
@@ -8375,7 +8552,7 @@ export interface OptionFromNullOr<S extends Top> extends decodeTo<Option<toType<
|
|
|
8375
8552
|
* @category Option
|
|
8376
8553
|
* @since 3.10.0
|
|
8377
8554
|
*/
|
|
8378
|
-
export function OptionFromNullOr<S extends
|
|
8555
|
+
export function OptionFromNullOr<S extends Constraint>(schema: S): OptionFromNullOr<S> {
|
|
8379
8556
|
return NullOr(schema).pipe(decodeTo(
|
|
8380
8557
|
Option(toType(schema)),
|
|
8381
8558
|
SchemaTransformation.optionFromNullOr()
|
|
@@ -8388,7 +8565,7 @@ export function OptionFromNullOr<S extends Top>(schema: S): OptionFromNullOr<S>
|
|
|
8388
8565
|
* @category Option
|
|
8389
8566
|
* @since 3.10.0
|
|
8390
8567
|
*/
|
|
8391
|
-
export interface OptionFromUndefinedOr<S extends
|
|
8568
|
+
export interface OptionFromUndefinedOr<S extends Constraint> extends decodeTo<Option<toType<S>>, UndefinedOr<S>> {
|
|
8392
8569
|
readonly "Rebuild": OptionFromUndefinedOr<S>
|
|
8393
8570
|
}
|
|
8394
8571
|
|
|
@@ -8404,7 +8581,7 @@ export interface OptionFromUndefinedOr<S extends Top> extends decodeTo<Option<to
|
|
|
8404
8581
|
* @category Option
|
|
8405
8582
|
* @since 3.10.0
|
|
8406
8583
|
*/
|
|
8407
|
-
export function OptionFromUndefinedOr<S extends
|
|
8584
|
+
export function OptionFromUndefinedOr<S extends Constraint>(schema: S): OptionFromUndefinedOr<S> {
|
|
8408
8585
|
return UndefinedOr(schema).pipe(decodeTo(
|
|
8409
8586
|
Option(toType(schema)),
|
|
8410
8587
|
SchemaTransformation.optionFromUndefinedOr()
|
|
@@ -8417,7 +8594,7 @@ export function OptionFromUndefinedOr<S extends Top>(schema: S): OptionFromUndef
|
|
|
8417
8594
|
* @category Option
|
|
8418
8595
|
* @since 3.10.0
|
|
8419
8596
|
*/
|
|
8420
|
-
export interface OptionFromNullishOr<S extends
|
|
8597
|
+
export interface OptionFromNullishOr<S extends Constraint> extends decodeTo<Option<toType<S>>, NullishOr<S>> {
|
|
8421
8598
|
readonly "Rebuild": OptionFromNullishOr<S>
|
|
8422
8599
|
}
|
|
8423
8600
|
|
|
@@ -8434,7 +8611,7 @@ export interface OptionFromNullishOr<S extends Top> extends decodeTo<Option<toTy
|
|
|
8434
8611
|
* @category Option
|
|
8435
8612
|
* @since 3.10.0
|
|
8436
8613
|
*/
|
|
8437
|
-
export function OptionFromNullishOr<S extends
|
|
8614
|
+
export function OptionFromNullishOr<S extends Constraint>(
|
|
8438
8615
|
schema: S,
|
|
8439
8616
|
options?: {
|
|
8440
8617
|
onNoneEncoding: null | undefined
|
|
@@ -8452,7 +8629,7 @@ export function OptionFromNullishOr<S extends Top>(
|
|
|
8452
8629
|
* @category Option
|
|
8453
8630
|
* @since 4.0.0
|
|
8454
8631
|
*/
|
|
8455
|
-
export interface OptionFromOptionalKey<S extends
|
|
8632
|
+
export interface OptionFromOptionalKey<S extends Constraint> extends decodeTo<Option<toType<S>>, optionalKey<S>> {
|
|
8456
8633
|
readonly "Rebuild": OptionFromOptionalKey<S>
|
|
8457
8634
|
}
|
|
8458
8635
|
|
|
@@ -8467,7 +8644,7 @@ export interface OptionFromOptionalKey<S extends Top> extends decodeTo<Option<to
|
|
|
8467
8644
|
* @category Option
|
|
8468
8645
|
* @since 4.0.0
|
|
8469
8646
|
*/
|
|
8470
|
-
export function OptionFromOptionalKey<S extends
|
|
8647
|
+
export function OptionFromOptionalKey<S extends Constraint>(schema: S): OptionFromOptionalKey<S> {
|
|
8471
8648
|
return optionalKey(schema).pipe(decodeTo(
|
|
8472
8649
|
Option(toType(schema)),
|
|
8473
8650
|
SchemaTransformation.optionFromOptionalKey()
|
|
@@ -8480,7 +8657,7 @@ export function OptionFromOptionalKey<S extends Top>(schema: S): OptionFromOptio
|
|
|
8480
8657
|
* @category Option
|
|
8481
8658
|
* @since 4.0.0
|
|
8482
8659
|
*/
|
|
8483
|
-
export interface OptionFromOptional<S extends
|
|
8660
|
+
export interface OptionFromOptional<S extends Constraint> extends decodeTo<Option<toType<S>>, optional<S>> {
|
|
8484
8661
|
readonly "Rebuild": OptionFromOptional<S>
|
|
8485
8662
|
}
|
|
8486
8663
|
|
|
@@ -8497,7 +8674,7 @@ export interface OptionFromOptional<S extends Top> extends decodeTo<Option<toTyp
|
|
|
8497
8674
|
* @category Option
|
|
8498
8675
|
* @since 4.0.0
|
|
8499
8676
|
*/
|
|
8500
|
-
export function OptionFromOptional<S extends
|
|
8677
|
+
export function OptionFromOptional<S extends Constraint>(schema: S): OptionFromOptional<S> {
|
|
8501
8678
|
return optional(schema).pipe(decodeTo(
|
|
8502
8679
|
Option(toType(schema)),
|
|
8503
8680
|
SchemaTransformation.optionFromOptional<any>()
|
|
@@ -8510,7 +8687,9 @@ export function OptionFromOptional<S extends Top>(schema: S): OptionFromOptional
|
|
|
8510
8687
|
* @category Option
|
|
8511
8688
|
* @since 4.0.0
|
|
8512
8689
|
*/
|
|
8513
|
-
export interface OptionFromOptionalNullOr<S extends
|
|
8690
|
+
export interface OptionFromOptionalNullOr<S extends Constraint>
|
|
8691
|
+
extends decodeTo<Option<toType<S>>, optional<NullOr<S>>>
|
|
8692
|
+
{
|
|
8514
8693
|
readonly "Rebuild": OptionFromOptionalNullOr<S>
|
|
8515
8694
|
}
|
|
8516
8695
|
|
|
@@ -8528,7 +8707,7 @@ export interface OptionFromOptionalNullOr<S extends Top> extends decodeTo<Option
|
|
|
8528
8707
|
* @category Option
|
|
8529
8708
|
* @since 4.0.0
|
|
8530
8709
|
*/
|
|
8531
|
-
export function OptionFromOptionalNullOr<S extends
|
|
8710
|
+
export function OptionFromOptionalNullOr<S extends Constraint>(
|
|
8532
8711
|
schema: S,
|
|
8533
8712
|
options?: {
|
|
8534
8713
|
readonly onNoneEncoding: "omit" | null | undefined
|
|
@@ -8555,7 +8734,7 @@ export function OptionFromOptionalNullOr<S extends Top>(
|
|
|
8555
8734
|
* @category schemas
|
|
8556
8735
|
* @since 4.0.0
|
|
8557
8736
|
*/
|
|
8558
|
-
export interface Result<A extends
|
|
8737
|
+
export interface Result<A extends Constraint, E extends Constraint> extends
|
|
8559
8738
|
declareConstructor<
|
|
8560
8739
|
Result_.Result<A["Type"], E["Type"]>,
|
|
8561
8740
|
Result_.Result<A["Encoded"], E["Encoded"]>,
|
|
@@ -8579,7 +8758,7 @@ export interface Result<A extends Top, E extends Top> extends
|
|
|
8579
8758
|
* @category schemas
|
|
8580
8759
|
* @since 4.0.0
|
|
8581
8760
|
*/
|
|
8582
|
-
export type ResultIso<A extends
|
|
8761
|
+
export type ResultIso<A extends Constraint, E extends Constraint> =
|
|
8583
8762
|
| { readonly _tag: "Success"; readonly success: A["Iso"] }
|
|
8584
8763
|
| { readonly _tag: "Failure"; readonly failure: E["Iso"] }
|
|
8585
8764
|
|
|
@@ -8589,7 +8768,7 @@ export type ResultIso<A extends Top, E extends Top> =
|
|
|
8589
8768
|
* @category schemas
|
|
8590
8769
|
* @since 4.0.0
|
|
8591
8770
|
*/
|
|
8592
|
-
export function Result<A extends
|
|
8771
|
+
export function Result<A extends Constraint, E extends Constraint>(
|
|
8593
8772
|
success: A,
|
|
8594
8773
|
failure: E
|
|
8595
8774
|
): Result<A, E> {
|
|
@@ -8672,7 +8851,7 @@ export function Result<A extends Top, E extends Top>(
|
|
|
8672
8851
|
* @category Redacted
|
|
8673
8852
|
* @since 3.10.0
|
|
8674
8853
|
*/
|
|
8675
|
-
export interface Redacted<S extends
|
|
8854
|
+
export interface Redacted<S extends Constraint> extends
|
|
8676
8855
|
declareConstructor<
|
|
8677
8856
|
Redacted_.Redacted<S["Type"]>,
|
|
8678
8857
|
Redacted_.Redacted<S["Encoded"]>,
|
|
@@ -8703,10 +8882,11 @@ export interface Redacted<S extends Top> extends
|
|
|
8703
8882
|
* into JSON, it will fail with an error. This is useful when the wrapped schema is
|
|
8704
8883
|
* sensitive and should not be exposed in JSON.
|
|
8705
8884
|
*
|
|
8885
|
+
* @see {@link RedactedFromValue} for decoding raw values and wrapping them in `Redacted`.
|
|
8706
8886
|
* @category Redacted
|
|
8707
8887
|
* @since 3.10.0
|
|
8708
8888
|
*/
|
|
8709
|
-
export function Redacted<S extends
|
|
8889
|
+
export function Redacted<S extends Constraint>(value: S, options?: {
|
|
8710
8890
|
readonly label?: string | undefined
|
|
8711
8891
|
readonly disallowJsonEncode?: boolean | undefined
|
|
8712
8892
|
}): Redacted<S> {
|
|
@@ -8783,7 +8963,7 @@ export function Redacted<S extends Top>(value: S, options?: {
|
|
|
8783
8963
|
* @category Redacted
|
|
8784
8964
|
* @since 4.0.0
|
|
8785
8965
|
*/
|
|
8786
|
-
export interface RedactedFromValue<S extends
|
|
8966
|
+
export interface RedactedFromValue<S extends Constraint>
|
|
8787
8967
|
extends decodeTo<Redacted<toType<S>>, middlewareDecoding<S, S["DecodingServices"]>>
|
|
8788
8968
|
{
|
|
8789
8969
|
readonly "Rebuild": RedactedFromValue<S>
|
|
@@ -8796,8 +8976,8 @@ export interface RedactedFromValue<S extends Top>
|
|
|
8796
8976
|
* @category Redacted
|
|
8797
8977
|
* @since 4.0.0
|
|
8798
8978
|
*/
|
|
8799
|
-
export function redact<S extends
|
|
8800
|
-
return
|
|
8979
|
+
export function redact<S extends Constraint>(schema: S): middlewareDecoding<S, S["DecodingServices"]> {
|
|
8980
|
+
return middlewareDecoding<S, S["DecodingServices"]>(Effect.mapErrorEager(SchemaIssue.redact))(schema)
|
|
8801
8981
|
}
|
|
8802
8982
|
|
|
8803
8983
|
/**
|
|
@@ -8805,10 +8985,11 @@ export function redact<S extends Top>(schema: S): middlewareDecoding<S, S["Decod
|
|
|
8805
8985
|
* expects the input to already be a `Redacted` instance, this schema decodes
|
|
8806
8986
|
* the raw value and wraps it.
|
|
8807
8987
|
*
|
|
8988
|
+
* @see {@link Redacted} for schemas whose input is already a `Redacted` value.
|
|
8808
8989
|
* @category Redacted
|
|
8809
8990
|
* @since 4.0.0
|
|
8810
8991
|
*/
|
|
8811
|
-
export function RedactedFromValue<S extends
|
|
8992
|
+
export function RedactedFromValue<S extends Constraint>(value: S, options?: {
|
|
8812
8993
|
readonly label?: string | undefined
|
|
8813
8994
|
readonly disallowEncode?: boolean | undefined
|
|
8814
8995
|
}): RedactedFromValue<S> {
|
|
@@ -8837,7 +9018,7 @@ export function RedactedFromValue<S extends Top>(value: S, options?: {
|
|
|
8837
9018
|
* @category CauseReason
|
|
8838
9019
|
* @since 4.0.0
|
|
8839
9020
|
*/
|
|
8840
|
-
export interface CauseReason<E extends
|
|
9021
|
+
export interface CauseReason<E extends Constraint, D extends Constraint> extends
|
|
8841
9022
|
declareConstructor<
|
|
8842
9023
|
Cause_.Reason<E["Type"]>,
|
|
8843
9024
|
Cause_.Reason<E["Encoded"]>,
|
|
@@ -8861,7 +9042,7 @@ export interface CauseReason<E extends Top, D extends Top> extends
|
|
|
8861
9042
|
* @category CauseReason
|
|
8862
9043
|
* @since 4.0.0
|
|
8863
9044
|
*/
|
|
8864
|
-
export type CauseReasonIso<E extends
|
|
9045
|
+
export type CauseReasonIso<E extends Constraint, D extends Constraint> = {
|
|
8865
9046
|
readonly _tag: "Fail"
|
|
8866
9047
|
readonly error: E["Iso"]
|
|
8867
9048
|
} | {
|
|
@@ -8892,7 +9073,7 @@ export type CauseReasonIso<E extends Top, D extends Top> = {
|
|
|
8892
9073
|
* @category CauseReason
|
|
8893
9074
|
* @since 4.0.0
|
|
8894
9075
|
*/
|
|
8895
|
-
export function CauseReason<E extends
|
|
9076
|
+
export function CauseReason<E extends Constraint, D extends Constraint>(error: E, defect: D): CauseReason<E, D> {
|
|
8896
9077
|
const schema = declareConstructor<Cause_.Reason<E["Type"]>, Cause_.Reason<E["Encoded"]>, CauseReasonIso<E, D>>()(
|
|
8897
9078
|
[error, defect],
|
|
8898
9079
|
([error, defect]) => (input, ast, options) => {
|
|
@@ -9010,7 +9191,7 @@ function causeReasonToFormatter<E>(error: Formatter<E>, defect: Formatter<unknow
|
|
|
9010
9191
|
* @category Cause
|
|
9011
9192
|
* @since 3.10.0
|
|
9012
9193
|
*/
|
|
9013
|
-
export interface Cause<E extends
|
|
9194
|
+
export interface Cause<E extends Constraint, D extends Constraint> extends
|
|
9014
9195
|
declareConstructor<
|
|
9015
9196
|
Cause_.Cause<E["Type"]>,
|
|
9016
9197
|
Cause_.Cause<E["Encoded"]>,
|
|
@@ -9038,7 +9219,7 @@ export interface Cause<E extends Top, D extends Top> extends
|
|
|
9038
9219
|
* @category Cause
|
|
9039
9220
|
* @since 4.0.0
|
|
9040
9221
|
*/
|
|
9041
|
-
export type CauseIso<E extends
|
|
9222
|
+
export type CauseIso<E extends Constraint, D extends Constraint> = ReadonlyArray<CauseReasonIso<E, D>>
|
|
9042
9223
|
|
|
9043
9224
|
/**
|
|
9044
9225
|
* Creates a schema for `Cause` values using separate schemas for typed failures
|
|
@@ -9061,7 +9242,7 @@ export type CauseIso<E extends Top, D extends Top> = ReadonlyArray<CauseReasonIs
|
|
|
9061
9242
|
* @category Cause
|
|
9062
9243
|
* @since 3.10.0
|
|
9063
9244
|
*/
|
|
9064
|
-
export function Cause<E extends
|
|
9245
|
+
export function Cause<E extends Constraint, D extends Constraint>(error: E, defect: D): Cause<E, D> {
|
|
9065
9246
|
const schema = declareConstructor<Cause_.Cause<E["Type"]>, Cause_.Cause<E["Encoded"]>, CauseIso<E, D>>()(
|
|
9066
9247
|
[error, defect],
|
|
9067
9248
|
([error, defect]) => {
|
|
@@ -9287,7 +9468,7 @@ export function Defect(options?: ErrorOptions): Defect {
|
|
|
9287
9468
|
* @category Exit
|
|
9288
9469
|
* @since 3.10.0
|
|
9289
9470
|
*/
|
|
9290
|
-
export interface Exit<A extends
|
|
9471
|
+
export interface Exit<A extends Constraint, E extends Constraint, D extends Constraint> extends
|
|
9291
9472
|
declareConstructor<
|
|
9292
9473
|
Exit_.Exit<A["Type"], E["Type"]>,
|
|
9293
9474
|
Exit_.Exit<A["Encoded"], E["Encoded"]>,
|
|
@@ -9312,7 +9493,7 @@ export interface Exit<A extends Top, E extends Top, D extends Top> extends
|
|
|
9312
9493
|
* @category Exit
|
|
9313
9494
|
* @since 4.0.0
|
|
9314
9495
|
*/
|
|
9315
|
-
export type ExitIso<A extends
|
|
9496
|
+
export type ExitIso<A extends Constraint, E extends Constraint, D extends Constraint> = {
|
|
9316
9497
|
readonly _tag: "Success"
|
|
9317
9498
|
readonly value: A["Iso"]
|
|
9318
9499
|
} | {
|
|
@@ -9332,7 +9513,11 @@ export type ExitIso<A extends Top, E extends Top, D extends Top> = {
|
|
|
9332
9513
|
* @category Exit
|
|
9333
9514
|
* @since 3.10.0
|
|
9334
9515
|
*/
|
|
9335
|
-
export function Exit<A extends
|
|
9516
|
+
export function Exit<A extends Constraint, E extends Constraint, D extends Constraint>(
|
|
9517
|
+
value: A,
|
|
9518
|
+
error: E,
|
|
9519
|
+
defect: D
|
|
9520
|
+
): Exit<A, E, D> {
|
|
9336
9521
|
const schema = declareConstructor<
|
|
9337
9522
|
Exit_.Exit<A["Type"], E["Type"]>,
|
|
9338
9523
|
Exit_.Exit<A["Encoded"], E["Encoded"]>,
|
|
@@ -9439,7 +9624,7 @@ export function Exit<A extends Top, E extends Top, D extends Top>(value: A, erro
|
|
|
9439
9624
|
* @category ReadonlyMap
|
|
9440
9625
|
* @since 4.0.0
|
|
9441
9626
|
*/
|
|
9442
|
-
export interface $ReadonlyMap<Key extends
|
|
9627
|
+
export interface $ReadonlyMap<Key extends Constraint, Value extends Constraint> extends
|
|
9443
9628
|
declareConstructor<
|
|
9444
9629
|
globalThis.ReadonlyMap<Key["Type"], Value["Type"]>,
|
|
9445
9630
|
globalThis.ReadonlyMap<Key["Encoded"], Value["Encoded"]>,
|
|
@@ -9459,7 +9644,9 @@ export interface $ReadonlyMap<Key extends Top, Value extends Top> extends
|
|
|
9459
9644
|
* @category ReadonlyMap
|
|
9460
9645
|
* @since 4.0.0
|
|
9461
9646
|
*/
|
|
9462
|
-
export type ReadonlyMapIso<Key extends
|
|
9647
|
+
export type ReadonlyMapIso<Key extends Constraint, Value extends Constraint> = ReadonlyArray<
|
|
9648
|
+
readonly [Key["Iso"], Value["Iso"]]
|
|
9649
|
+
>
|
|
9463
9650
|
|
|
9464
9651
|
function oneOfArbitraries<T>(
|
|
9465
9652
|
fc: typeof FastCheck,
|
|
@@ -9558,7 +9745,10 @@ function entriesArbitrary<K, V, Out>(
|
|
|
9558
9745
|
* @category ReadonlyMap
|
|
9559
9746
|
* @since 3.10.0
|
|
9560
9747
|
*/
|
|
9561
|
-
export function ReadonlyMap<Key extends
|
|
9748
|
+
export function ReadonlyMap<Key extends Constraint, Value extends Constraint>(
|
|
9749
|
+
key: Key,
|
|
9750
|
+
value: Value
|
|
9751
|
+
): $ReadonlyMap<Key, Value> {
|
|
9562
9752
|
const schema = declareConstructor<
|
|
9563
9753
|
globalThis.ReadonlyMap<Key["Type"], Value["Type"]>,
|
|
9564
9754
|
globalThis.ReadonlyMap<Key["Encoded"], Value["Encoded"]>,
|
|
@@ -9619,7 +9809,7 @@ export function ReadonlyMap<Key extends Top, Value extends Top>(key: Key, value:
|
|
|
9619
9809
|
* @category HashMap
|
|
9620
9810
|
* @since 3.10.0
|
|
9621
9811
|
*/
|
|
9622
|
-
export interface HashMap<Key extends
|
|
9812
|
+
export interface HashMap<Key extends Constraint, Value extends Constraint> extends
|
|
9623
9813
|
declareConstructor<
|
|
9624
9814
|
HashMap_.HashMap<Key["Type"], Value["Type"]>,
|
|
9625
9815
|
HashMap_.HashMap<Key["Encoded"], Value["Encoded"]>,
|
|
@@ -9639,7 +9829,9 @@ export interface HashMap<Key extends Top, Value extends Top> extends
|
|
|
9639
9829
|
* @category HashMap
|
|
9640
9830
|
* @since 4.0.0
|
|
9641
9831
|
*/
|
|
9642
|
-
export type HashMapIso<Key extends
|
|
9832
|
+
export type HashMapIso<Key extends Constraint, Value extends Constraint> = ReadonlyArray<
|
|
9833
|
+
readonly [Key["Iso"], Value["Iso"]]
|
|
9834
|
+
>
|
|
9643
9835
|
|
|
9644
9836
|
/**
|
|
9645
9837
|
* Schema for hash maps whose keys and values conform to the provided schemas.
|
|
@@ -9647,7 +9839,7 @@ export type HashMapIso<Key extends Top, Value extends Top> = ReadonlyArray<reado
|
|
|
9647
9839
|
* @category HashMap
|
|
9648
9840
|
* @since 3.10.0
|
|
9649
9841
|
*/
|
|
9650
|
-
export function HashMap<Key extends
|
|
9842
|
+
export function HashMap<Key extends Constraint, Value extends Constraint>(key: Key, value: Value): HashMap<Key, Value> {
|
|
9651
9843
|
const schema = declareConstructor<
|
|
9652
9844
|
HashMap_.HashMap<Key["Type"], Value["Type"]>,
|
|
9653
9845
|
HashMap_.HashMap<Key["Encoded"], Value["Encoded"]>,
|
|
@@ -9709,7 +9901,7 @@ export function HashMap<Key extends Top, Value extends Top>(key: Key, value: Val
|
|
|
9709
9901
|
* @category ReadonlySet
|
|
9710
9902
|
* @since 4.0.0
|
|
9711
9903
|
*/
|
|
9712
|
-
export interface $ReadonlySet<Value extends
|
|
9904
|
+
export interface $ReadonlySet<Value extends Constraint> extends
|
|
9713
9905
|
declareConstructor<
|
|
9714
9906
|
globalThis.ReadonlySet<Value["Type"]>,
|
|
9715
9907
|
globalThis.ReadonlySet<Value["Encoded"]>,
|
|
@@ -9728,7 +9920,7 @@ export interface $ReadonlySet<Value extends Top> extends
|
|
|
9728
9920
|
* @category ReadonlySet
|
|
9729
9921
|
* @since 4.0.0
|
|
9730
9922
|
*/
|
|
9731
|
-
export type ReadonlySetIso<Value extends
|
|
9923
|
+
export type ReadonlySetIso<Value extends Constraint> = ReadonlyArray<Value["Iso"]>
|
|
9732
9924
|
|
|
9733
9925
|
/**
|
|
9734
9926
|
* Schema for readonly sets whose values conform to the provided element schema.
|
|
@@ -9736,7 +9928,7 @@ export type ReadonlySetIso<Value extends Top> = ReadonlyArray<Value["Iso"]>
|
|
|
9736
9928
|
* @category ReadonlySet
|
|
9737
9929
|
* @since 3.10.0
|
|
9738
9930
|
*/
|
|
9739
|
-
export function ReadonlySet<Value extends
|
|
9931
|
+
export function ReadonlySet<Value extends Constraint>(value: Value): $ReadonlySet<Value> {
|
|
9740
9932
|
const schema = declareConstructor<
|
|
9741
9933
|
globalThis.ReadonlySet<Value["Type"]>,
|
|
9742
9934
|
globalThis.ReadonlySet<Value["Encoded"]>,
|
|
@@ -9798,7 +9990,7 @@ export function ReadonlySet<Value extends Top>(value: Value): $ReadonlySet<Value
|
|
|
9798
9990
|
* @category HashSet
|
|
9799
9991
|
* @since 3.10.0
|
|
9800
9992
|
*/
|
|
9801
|
-
export interface HashSet<Value extends
|
|
9993
|
+
export interface HashSet<Value extends Constraint> extends
|
|
9802
9994
|
declareConstructor<
|
|
9803
9995
|
HashSet_.HashSet<Value["Type"]>,
|
|
9804
9996
|
HashSet_.HashSet<Value["Encoded"]>,
|
|
@@ -9817,7 +10009,7 @@ export interface HashSet<Value extends Top> extends
|
|
|
9817
10009
|
* @category HashSet
|
|
9818
10010
|
* @since 4.0.0
|
|
9819
10011
|
*/
|
|
9820
|
-
export type HashSetIso<Value extends
|
|
10012
|
+
export type HashSetIso<Value extends Constraint> = ReadonlyArray<Value["Iso"]>
|
|
9821
10013
|
|
|
9822
10014
|
/**
|
|
9823
10015
|
* Schema for hash sets whose values conform to the provided element schema.
|
|
@@ -9825,7 +10017,7 @@ export type HashSetIso<Value extends Top> = ReadonlyArray<Value["Iso"]>
|
|
|
9825
10017
|
* @category HashSet
|
|
9826
10018
|
* @since 3.10.0
|
|
9827
10019
|
*/
|
|
9828
|
-
export function HashSet<Value extends
|
|
10020
|
+
export function HashSet<Value extends Constraint>(value: Value): HashSet<Value> {
|
|
9829
10021
|
const schema = declareConstructor<
|
|
9830
10022
|
HashSet_.HashSet<Value["Type"]>,
|
|
9831
10023
|
HashSet_.HashSet<Value["Encoded"]>,
|
|
@@ -9887,7 +10079,7 @@ export function HashSet<Value extends Top>(value: Value): HashSet<Value> {
|
|
|
9887
10079
|
* @category Chunk
|
|
9888
10080
|
* @since 3.10.0
|
|
9889
10081
|
*/
|
|
9890
|
-
export interface Chunk<Value extends
|
|
10082
|
+
export interface Chunk<Value extends Constraint> extends
|
|
9891
10083
|
declareConstructor<
|
|
9892
10084
|
Chunk_.Chunk<Value["Type"]>,
|
|
9893
10085
|
Chunk_.Chunk<Value["Encoded"]>,
|
|
@@ -9913,7 +10105,7 @@ export interface Chunk<Value extends Top> extends
|
|
|
9913
10105
|
* @category Chunk
|
|
9914
10106
|
* @since 4.0.0
|
|
9915
10107
|
*/
|
|
9916
|
-
export type ChunkIso<Value extends
|
|
10108
|
+
export type ChunkIso<Value extends Constraint> = ReadonlyArray<Value["Iso"]>
|
|
9917
10109
|
|
|
9918
10110
|
/**
|
|
9919
10111
|
* Schema for chunks whose values conform to the provided element schema.
|
|
@@ -9921,7 +10113,7 @@ export type ChunkIso<Value extends Top> = ReadonlyArray<Value["Iso"]>
|
|
|
9921
10113
|
* @category Chunk
|
|
9922
10114
|
* @since 3.10.0
|
|
9923
10115
|
*/
|
|
9924
|
-
export function Chunk<Value extends
|
|
10116
|
+
export function Chunk<Value extends Constraint>(value: Value): Chunk<Value> {
|
|
9925
10117
|
const schema = declareConstructor<
|
|
9926
10118
|
Chunk_.Chunk<Value["Type"]>,
|
|
9927
10119
|
Chunk_.Chunk<Value["Encoded"]>,
|
|
@@ -10139,7 +10331,7 @@ type DateArbitraryConstraints = FastCheck.DateConstraints & {
|
|
|
10139
10331
|
}
|
|
10140
10332
|
|
|
10141
10333
|
function dateArbitraryConstraints<T = globalThis.Date>(
|
|
10142
|
-
constraint: Annotations.ToArbitrary.
|
|
10334
|
+
constraint: Annotations.ToArbitrary.GenerationConstraint | undefined,
|
|
10143
10335
|
ordered: Annotations.ToArbitrary.OrderedConstraint<T> | undefined,
|
|
10144
10336
|
base?: DateArbitraryConstraints | undefined,
|
|
10145
10337
|
toDate?: (value: T) => globalThis.Date
|
|
@@ -10697,7 +10889,7 @@ export const UnknownFromJsonString: UnknownFromJsonString = fromJsonString(Unkno
|
|
|
10697
10889
|
* @category models
|
|
10698
10890
|
* @since 4.0.0
|
|
10699
10891
|
*/
|
|
10700
|
-
export interface fromJsonString<S extends
|
|
10892
|
+
export interface fromJsonString<S extends Constraint> extends decodeTo<S, String> {
|
|
10701
10893
|
readonly "Rebuild": fromJsonString<S>
|
|
10702
10894
|
}
|
|
10703
10895
|
|
|
@@ -10767,7 +10959,7 @@ export interface fromJsonString<S extends Top> extends decodeTo<S, String> {
|
|
|
10767
10959
|
* @category constructors
|
|
10768
10960
|
* @since 4.0.0
|
|
10769
10961
|
*/
|
|
10770
|
-
export function fromJsonString<S extends
|
|
10962
|
+
export function fromJsonString<S extends Constraint>(schema: S): fromJsonString<S> {
|
|
10771
10963
|
return String.annotate({
|
|
10772
10964
|
expected: "a string that will be decoded as JSON",
|
|
10773
10965
|
contentMediaType: "application/json",
|
|
@@ -10919,7 +11111,7 @@ export const FormData: FormData = instanceOf(globalThis.FormData, {
|
|
|
10919
11111
|
* @category FormData
|
|
10920
11112
|
* @since 4.0.0
|
|
10921
11113
|
*/
|
|
10922
|
-
export interface fromFormData<S extends
|
|
11114
|
+
export interface fromFormData<S extends Constraint> extends decodeTo<S, FormData> {
|
|
10923
11115
|
readonly "Rebuild": fromFormData<S>
|
|
10924
11116
|
}
|
|
10925
11117
|
|
|
@@ -10939,10 +11131,8 @@ export interface fromFormData<S extends Top> extends decodeTo<S, FormData> {
|
|
|
10939
11131
|
*
|
|
10940
11132
|
* You can express nested values using bracket notation.
|
|
10941
11133
|
*
|
|
10942
|
-
* If you want to decode
|
|
10943
|
-
* `Schema.toCodecStringTree
|
|
10944
|
-
* This serializer preserves values such as numbers and `Blob` objects when
|
|
10945
|
-
* compatible with the schema.
|
|
11134
|
+
* If you want to decode string fields into non-string primitive values, use
|
|
11135
|
+
* `Schema.toCodecStringTree`.
|
|
10946
11136
|
*
|
|
10947
11137
|
* **Example** (Decoding a flat structure)
|
|
10948
11138
|
*
|
|
@@ -10996,8 +11186,7 @@ export interface fromFormData<S extends Top> extends decodeTo<S, FormData> {
|
|
|
10996
11186
|
* Schema.toCodecStringTree(
|
|
10997
11187
|
* Schema.Struct({
|
|
10998
11188
|
* a: Schema.Int
|
|
10999
|
-
* })
|
|
11000
|
-
* { keepDeclarations: true }
|
|
11189
|
+
* })
|
|
11001
11190
|
* )
|
|
11002
11191
|
* )
|
|
11003
11192
|
*
|
|
@@ -11011,7 +11200,7 @@ export interface fromFormData<S extends Top> extends decodeTo<S, FormData> {
|
|
|
11011
11200
|
* @category decoding
|
|
11012
11201
|
* @since 4.0.0
|
|
11013
11202
|
*/
|
|
11014
|
-
export function fromFormData<S extends
|
|
11203
|
+
export function fromFormData<S extends Constraint>(schema: S): fromFormData<S> {
|
|
11015
11204
|
return FormData.pipe(decodeTo(schema, SchemaTransformation.fromFormData))
|
|
11016
11205
|
}
|
|
11017
11206
|
|
|
@@ -11060,7 +11249,7 @@ export const URLSearchParams: URLSearchParams = instanceOf(globalThis.URLSearchP
|
|
|
11060
11249
|
* @category search params
|
|
11061
11250
|
* @since 4.0.0
|
|
11062
11251
|
*/
|
|
11063
|
-
export interface fromURLSearchParams<S extends
|
|
11252
|
+
export interface fromURLSearchParams<S extends Constraint> extends decodeTo<S, URLSearchParams> {
|
|
11064
11253
|
readonly "Rebuild": fromURLSearchParams<S>
|
|
11065
11254
|
}
|
|
11066
11255
|
|
|
@@ -11144,7 +11333,7 @@ export interface fromURLSearchParams<S extends Top> extends decodeTo<S, URLSearc
|
|
|
11144
11333
|
* @category decoding
|
|
11145
11334
|
* @since 4.0.0
|
|
11146
11335
|
*/
|
|
11147
|
-
export function fromURLSearchParams<S extends
|
|
11336
|
+
export function fromURLSearchParams<S extends Constraint>(schema: S): fromURLSearchParams<S> {
|
|
11148
11337
|
return URLSearchParams.pipe(decodeTo(schema, SchemaTransformation.fromURLSearchParams))
|
|
11149
11338
|
}
|
|
11150
11339
|
|
|
@@ -12163,18 +12352,11 @@ export const DateTimeZonedFromString: DateTimeZonedFromString = DateTimeZonedStr
|
|
|
12163
12352
|
* @category models
|
|
12164
12353
|
* @since 3.10.0
|
|
12165
12354
|
*/
|
|
12166
|
-
export interface Class<Self, S extends
|
|
12167
|
-
|
|
12168
|
-
Self,
|
|
12169
|
-
S["Encoded"],
|
|
12170
|
-
S["DecodingServices"],
|
|
12171
|
-
S["EncodingServices"],
|
|
12355
|
+
export interface Class<Self, S extends Constraint & { readonly fields: Struct.Fields }, Inherited> extends
|
|
12356
|
+
BottomLazy<
|
|
12172
12357
|
SchemaAST.Declaration,
|
|
12173
12358
|
decodeTo<declareConstructor<Self, S["Encoded"], readonly [S], S["Iso"]>, S>,
|
|
12174
|
-
RequiredKeys<S["~type.make.in"]> extends never ? void | S["~type.make.in"] : S["~type.make.in"],
|
|
12175
|
-
S["Iso"],
|
|
12176
12359
|
readonly [S],
|
|
12177
|
-
Self,
|
|
12178
12360
|
S["~type.mutability"],
|
|
12179
12361
|
S["~type.optionality"],
|
|
12180
12362
|
S["~type.constructor.default"],
|
|
@@ -12182,6 +12364,14 @@ export interface Class<Self, S extends Top & { readonly fields: Struct.Fields },
|
|
|
12182
12364
|
S["~encoded.optionality"]
|
|
12183
12365
|
>
|
|
12184
12366
|
{
|
|
12367
|
+
readonly "Type": Self
|
|
12368
|
+
readonly "Encoded": S["Encoded"]
|
|
12369
|
+
readonly "DecodingServices": S["DecodingServices"]
|
|
12370
|
+
readonly "EncodingServices": S["EncodingServices"]
|
|
12371
|
+
readonly "~type.make.in": RequiredKeys<S["~type.make.in"]> extends never ? void | S["~type.make.in"]
|
|
12372
|
+
: S["~type.make.in"]
|
|
12373
|
+
readonly "~type.make": Self
|
|
12374
|
+
readonly "Iso": S["Iso"]
|
|
12185
12375
|
new(
|
|
12186
12376
|
...args: {} extends S["~type.make.in"] ? [props?: S["~type.make.in"], options?: MakeOptions]
|
|
12187
12377
|
: [props: S["~type.make.in"], options?: MakeOptions]
|
|
@@ -12368,7 +12558,7 @@ function getClassTypeId(identifier: string) {
|
|
|
12368
12558
|
return `~effect/Schema/Class/${identifier}`
|
|
12369
12559
|
}
|
|
12370
12560
|
|
|
12371
|
-
function getClassSchemaFactory<S extends
|
|
12561
|
+
function getClassSchemaFactory<S extends Constraint>(
|
|
12372
12562
|
from: S,
|
|
12373
12563
|
identifier: string,
|
|
12374
12564
|
annotations: Annotations.Declaration<any, readonly [S]> | undefined
|
|
@@ -12377,34 +12567,34 @@ function getClassSchemaFactory<S extends Top>(
|
|
|
12377
12567
|
return <Self extends (new(...args: ReadonlyArray<any>) => any) & { readonly identifier: string }>(
|
|
12378
12568
|
self: Self
|
|
12379
12569
|
): decodeTo<declareConstructor<Self, S["Encoded"], readonly [S]>, S> => {
|
|
12380
|
-
if (memo
|
|
12381
|
-
|
|
12382
|
-
const to = make<declareConstructor<Self, S["Encoded"], readonly [S]>>(
|
|
12383
|
-
new SchemaAST.Declaration(
|
|
12384
|
-
[from.ast],
|
|
12385
|
-
() => (input, ast) => {
|
|
12386
|
-
return input instanceof self ||
|
|
12387
|
-
Predicate.hasProperty(input, getClassTypeId(identifier)) ?
|
|
12388
|
-
Effect.succeed(input) :
|
|
12389
|
-
Effect.fail(new SchemaIssue.InvalidType(ast, Option_.some(input)))
|
|
12390
|
-
},
|
|
12391
|
-
{
|
|
12392
|
-
identifier,
|
|
12393
|
-
[SchemaAST.ClassTypeId]: ([from]: readonly [SchemaAST.AST]) => new SchemaAST.Link(from, transformation),
|
|
12394
|
-
toCodec: ([from]: readonly [Codec<S["Encoded"]>]) => new SchemaAST.Link(from.ast, transformation),
|
|
12395
|
-
toArbitrary: ([from]: readonly [Annotations.ToArbitrary.TypeParameter<S["Type"]>]) => () => ({
|
|
12396
|
-
arbitrary: from.arbitrary.map((args: S["Type"]) => new self(args)),
|
|
12397
|
-
terminal: from.terminal?.map((args: S["Type"]) => new self(args))
|
|
12398
|
-
}),
|
|
12399
|
-
toFormatter: ([from]: readonly [Formatter<S["Type"]>]) => (t: Self) => `${self.identifier}(${from(t)})`,
|
|
12400
|
-
"~sentinels": SchemaAST.collectSentinels(from.ast),
|
|
12401
|
-
...annotations
|
|
12402
|
-
}
|
|
12403
|
-
)
|
|
12404
|
-
)
|
|
12405
|
-
memo = from.pipe(decodeTo(to, transformation))
|
|
12570
|
+
if (memo !== undefined) {
|
|
12571
|
+
return memo
|
|
12406
12572
|
}
|
|
12407
|
-
|
|
12573
|
+
const transformation = getClassTransformation(self)
|
|
12574
|
+
const to = make<declareConstructor<Self, S["Encoded"], readonly [S]>>(
|
|
12575
|
+
new SchemaAST.Declaration(
|
|
12576
|
+
[from.ast],
|
|
12577
|
+
() => (input, ast) => {
|
|
12578
|
+
return input instanceof self ||
|
|
12579
|
+
Predicate.hasProperty(input, getClassTypeId(identifier)) ?
|
|
12580
|
+
Effect.succeed(input) :
|
|
12581
|
+
Effect.fail(new SchemaIssue.InvalidType(ast, Option_.some(input)))
|
|
12582
|
+
},
|
|
12583
|
+
{
|
|
12584
|
+
identifier,
|
|
12585
|
+
[SchemaAST.ClassTypeId]: ([from]: readonly [SchemaAST.AST]) => new SchemaAST.Link(from, transformation),
|
|
12586
|
+
toCodec: ([from]: readonly [Codec<S["Encoded"]>]) => new SchemaAST.Link(from.ast, transformation),
|
|
12587
|
+
toArbitrary: ([from]: readonly [Annotations.ToArbitrary.TypeParameter<S["Type"]>]) => () => ({
|
|
12588
|
+
arbitrary: from.arbitrary.map((args: S["Type"]) => new self(args)),
|
|
12589
|
+
terminal: from.terminal?.map((args: S["Type"]) => new self(args))
|
|
12590
|
+
}),
|
|
12591
|
+
toFormatter: ([from]: readonly [Formatter<S["Type"]>]) => (t: Self) => `${self.identifier}(${from(t)})`,
|
|
12592
|
+
"~sentinels": SchemaAST.collectSentinels(from.ast),
|
|
12593
|
+
...annotations
|
|
12594
|
+
}
|
|
12595
|
+
)
|
|
12596
|
+
)
|
|
12597
|
+
return memo = decodeTo<declareConstructor<Self, S["Encoded"], readonly [S]>, S>(to, transformation)(from)
|
|
12408
12598
|
}
|
|
12409
12599
|
}
|
|
12410
12600
|
|
|
@@ -13122,7 +13312,7 @@ export type LazyArbitrary<T> = (fc: typeof FastCheck) => FastCheck.Arbitrary<T>
|
|
|
13122
13312
|
* @category Arbitrary
|
|
13123
13313
|
* @since 4.0.0
|
|
13124
13314
|
*/
|
|
13125
|
-
export function toArbitraryLazy<S extends
|
|
13315
|
+
export function toArbitraryLazy<S extends Constraint>(schema: S): LazyArbitrary<S["Type"]> {
|
|
13126
13316
|
const lawc = InternalArbitrary.memoized(schema.ast)
|
|
13127
13317
|
return (fc) => lawc(fc, {})
|
|
13128
13318
|
}
|
|
@@ -13156,12 +13346,12 @@ export function toArbitraryLazy<S extends Top>(schema: S): LazyArbitrary<S["Type
|
|
|
13156
13346
|
* @category Arbitrary
|
|
13157
13347
|
* @since 4.0.0
|
|
13158
13348
|
*/
|
|
13159
|
-
export function toArbitrary<S extends
|
|
13160
|
-
export function toArbitrary<S extends
|
|
13349
|
+
export function toArbitrary<S extends Constraint>(schema: S): FastCheck.Arbitrary<S["Type"]>
|
|
13350
|
+
export function toArbitrary<S extends Constraint>(
|
|
13161
13351
|
schema: S,
|
|
13162
13352
|
options: { readonly report: true }
|
|
13163
13353
|
): Annotations.ToArbitrary.WithReport<FastCheck.Arbitrary<S["Type"]>>
|
|
13164
|
-
export function toArbitrary<S extends
|
|
13354
|
+
export function toArbitrary<S extends Constraint>(
|
|
13165
13355
|
schema: S,
|
|
13166
13356
|
options?: { readonly report?: boolean }
|
|
13167
13357
|
): FastCheck.Arbitrary<S["Type"]> | Annotations.ToArbitrary.WithReport<FastCheck.Arbitrary<S["Type"]>> {
|
|
@@ -13212,14 +13402,14 @@ export function overrideToFormatter<S extends Top>(toFormatter: () => Formatter<
|
|
|
13212
13402
|
* @category Formatter
|
|
13213
13403
|
* @since 4.0.0
|
|
13214
13404
|
*/
|
|
13215
|
-
export function toFormatter<
|
|
13405
|
+
export function toFormatter<S extends Constraint>(schema: S, options?: {
|
|
13216
13406
|
readonly onBefore?:
|
|
13217
13407
|
| ((ast: SchemaAST.AST, recur: (ast: SchemaAST.AST) => Formatter<any>) => Formatter<any> | undefined)
|
|
13218
13408
|
| undefined
|
|
13219
|
-
}): Formatter<
|
|
13409
|
+
}): Formatter<S["Type"]> {
|
|
13220
13410
|
return recur(schema.ast)
|
|
13221
13411
|
|
|
13222
|
-
function recur(ast: SchemaAST.AST): Formatter<
|
|
13412
|
+
function recur(ast: SchemaAST.AST): Formatter<S["Type"]> {
|
|
13223
13413
|
// ---------------------------------------------
|
|
13224
13414
|
// handle annotation
|
|
13225
13415
|
// ---------------------------------------------
|
|
@@ -13403,7 +13593,7 @@ export function toEquivalence<T>(schema: Schema<T>): Equivalence.Equivalence<T>
|
|
|
13403
13593
|
* @category Representation
|
|
13404
13594
|
* @since 4.0.0
|
|
13405
13595
|
*/
|
|
13406
|
-
export function toRepresentation(schema:
|
|
13596
|
+
export function toRepresentation(schema: Constraint): SchemaRepresentation.Document {
|
|
13407
13597
|
return InternalStandard.fromAST(schema.ast)
|
|
13408
13598
|
}
|
|
13409
13599
|
|
|
@@ -13504,7 +13694,10 @@ export interface ToJsonSchemaOptions {
|
|
|
13504
13694
|
* @category converting
|
|
13505
13695
|
* @since 4.0.0
|
|
13506
13696
|
*/
|
|
13507
|
-
export function toJsonSchemaDocument(
|
|
13697
|
+
export function toJsonSchemaDocument(
|
|
13698
|
+
schema: Constraint,
|
|
13699
|
+
options?: ToJsonSchemaOptions
|
|
13700
|
+
): JsonSchema.Document<"draft-2020-12"> {
|
|
13508
13701
|
const sd = toRepresentation(schema)
|
|
13509
13702
|
const jd = InternalStandard.toJsonSchemaDocument(sd, options)
|
|
13510
13703
|
return {
|
|
@@ -13518,6 +13711,33 @@ export function toJsonSchemaDocument(schema: Top, options?: ToJsonSchemaOptions)
|
|
|
13518
13711
|
// Canonical Codecs
|
|
13519
13712
|
// -----------------------------------------------------------------------------
|
|
13520
13713
|
|
|
13714
|
+
/**
|
|
13715
|
+
* Type-level representation returned by {@link toCodecJson}.
|
|
13716
|
+
*
|
|
13717
|
+
* @category Canonical Codecs
|
|
13718
|
+
* @since 4.0.0
|
|
13719
|
+
*/
|
|
13720
|
+
export interface toCodecJson<S extends Constraint> extends
|
|
13721
|
+
BottomLazy<
|
|
13722
|
+
S["ast"],
|
|
13723
|
+
toCodecJson<S>,
|
|
13724
|
+
S["~type.parameters"],
|
|
13725
|
+
S["~type.mutability"],
|
|
13726
|
+
S["~type.optionality"],
|
|
13727
|
+
S["~type.constructor.default"],
|
|
13728
|
+
S["~encoded.mutability"],
|
|
13729
|
+
S["~encoded.optionality"]
|
|
13730
|
+
>
|
|
13731
|
+
{
|
|
13732
|
+
readonly "Type": S["Type"]
|
|
13733
|
+
readonly "Encoded": Json
|
|
13734
|
+
readonly "DecodingServices": S["DecodingServices"]
|
|
13735
|
+
readonly "EncodingServices": S["EncodingServices"]
|
|
13736
|
+
readonly "~type.make.in": S["~type.make.in"]
|
|
13737
|
+
readonly "~type.make": S["~type.make"]
|
|
13738
|
+
readonly "Iso": S["Iso"]
|
|
13739
|
+
}
|
|
13740
|
+
|
|
13521
13741
|
/**
|
|
13522
13742
|
* Derives a canonical JSON codec from a schema. The encoded form is `Json`, and
|
|
13523
13743
|
* decoding produces the schema's `Type`.
|
|
@@ -13525,11 +13745,11 @@ export function toJsonSchemaDocument(schema: Top, options?: ToJsonSchemaOptions)
|
|
|
13525
13745
|
* @category Canonical Codecs
|
|
13526
13746
|
* @since 4.0.0
|
|
13527
13747
|
*/
|
|
13528
|
-
export function toCodecJson<
|
|
13748
|
+
export function toCodecJson<S extends Constraint>(schema: S): toCodecJson<S> {
|
|
13529
13749
|
return make(toCodecJsonTop(schema.ast))
|
|
13530
13750
|
}
|
|
13531
13751
|
|
|
13532
|
-
const toCodecJsonTop = SchemaAST.
|
|
13752
|
+
const toCodecJsonTop = SchemaAST.applyToSelfOrLastLinkEncoding((ast) => {
|
|
13533
13753
|
const out = toCodecJsonBase(ast, toCodecJsonTop)
|
|
13534
13754
|
return out !== ast && SchemaAST.isOptional(ast) ? SchemaAST.optionalKeyLastLink(out) : out
|
|
13535
13755
|
})
|
|
@@ -13596,7 +13816,7 @@ function toCodecJsonBase(ast: SchemaAST.AST, recur: (ast: SchemaAST.AST) => Sche
|
|
|
13596
13816
|
* @category Canonical Codecs
|
|
13597
13817
|
* @since 4.0.0
|
|
13598
13818
|
*/
|
|
13599
|
-
export function toCodecIso<S extends
|
|
13819
|
+
export function toCodecIso<S extends Constraint>(schema: S): Codec<S["Type"], S["Iso"]> {
|
|
13600
13820
|
return make(toCodecIsoTop(SchemaAST.toType(schema.ast)))
|
|
13601
13821
|
}
|
|
13602
13822
|
|
|
@@ -13634,6 +13854,33 @@ function toCodecIsoBase(ast: SchemaAST.AST, recur: (ast: SchemaAST.AST) => Schem
|
|
|
13634
13854
|
*/
|
|
13635
13855
|
export type StringTree = Tree<string | undefined>
|
|
13636
13856
|
|
|
13857
|
+
/**
|
|
13858
|
+
* Type-level representation returned by {@link toCodecStringTree}.
|
|
13859
|
+
*
|
|
13860
|
+
* @category Canonical Codecs
|
|
13861
|
+
* @since 4.0.0
|
|
13862
|
+
*/
|
|
13863
|
+
export interface toCodecStringTree<S extends Constraint> extends
|
|
13864
|
+
BottomLazy<
|
|
13865
|
+
S["ast"],
|
|
13866
|
+
toCodecStringTree<S>,
|
|
13867
|
+
ReadonlyArray<Constraint>,
|
|
13868
|
+
S["~type.mutability"],
|
|
13869
|
+
S["~type.optionality"],
|
|
13870
|
+
S["~type.constructor.default"],
|
|
13871
|
+
S["~encoded.mutability"],
|
|
13872
|
+
S["~encoded.optionality"]
|
|
13873
|
+
>
|
|
13874
|
+
{
|
|
13875
|
+
readonly "Type": S["Type"]
|
|
13876
|
+
readonly "Encoded": StringTree
|
|
13877
|
+
readonly "DecodingServices": S["DecodingServices"]
|
|
13878
|
+
readonly "EncodingServices": S["EncodingServices"]
|
|
13879
|
+
readonly "~type.make.in": S["~type.make.in"]
|
|
13880
|
+
readonly "~type.make": S["~type.make"]
|
|
13881
|
+
readonly "Iso": S["Iso"]
|
|
13882
|
+
}
|
|
13883
|
+
|
|
13637
13884
|
/**
|
|
13638
13885
|
* Converts a schema to the StringTree canonical codec, where every leaf value
|
|
13639
13886
|
* becomes a string while preserving the original structure.
|
|
@@ -13643,33 +13890,60 @@ export type StringTree = Tree<string | undefined>
|
|
|
13643
13890
|
* Declarations are converted to `undefined` (unless they have a
|
|
13644
13891
|
* `toCodecJson` or `toCodec` annotation).
|
|
13645
13892
|
*
|
|
13646
|
-
*
|
|
13893
|
+
* @category Canonical Codecs
|
|
13894
|
+
* @since 4.0.0
|
|
13895
|
+
*/
|
|
13896
|
+
export function toCodecStringTree<S extends Constraint>(schema: S): toCodecStringTree<S> {
|
|
13897
|
+
return make(serializerStringTree(schema.ast))
|
|
13898
|
+
}
|
|
13899
|
+
|
|
13900
|
+
/**
|
|
13901
|
+
* Type-level representation returned by {@link toCodecArrayFromSingle}.
|
|
13902
|
+
*
|
|
13903
|
+
* @category Canonical Codecs
|
|
13904
|
+
* @since 4.0.0
|
|
13905
|
+
*/
|
|
13906
|
+
export interface toCodecArrayFromSingle<S extends Constraint> extends
|
|
13907
|
+
BottomLazy<
|
|
13908
|
+
S["ast"],
|
|
13909
|
+
toCodecArrayFromSingle<S>,
|
|
13910
|
+
S["~type.parameters"],
|
|
13911
|
+
S["~type.mutability"],
|
|
13912
|
+
S["~type.optionality"],
|
|
13913
|
+
S["~type.constructor.default"],
|
|
13914
|
+
S["~encoded.mutability"],
|
|
13915
|
+
S["~encoded.optionality"]
|
|
13916
|
+
>
|
|
13917
|
+
{
|
|
13918
|
+
readonly "Type": S["Type"]
|
|
13919
|
+
readonly "Encoded": S["Encoded"]
|
|
13920
|
+
readonly "DecodingServices": S["DecodingServices"]
|
|
13921
|
+
readonly "EncodingServices": S["EncodingServices"]
|
|
13922
|
+
readonly "~type.make.in": S["~type.make.in"]
|
|
13923
|
+
readonly "~type.make": S["~type.make"]
|
|
13924
|
+
readonly "Iso": S["Iso"]
|
|
13925
|
+
}
|
|
13926
|
+
|
|
13927
|
+
/**
|
|
13928
|
+
* Allows array schemas to decode from either an array input or a single value
|
|
13929
|
+
* input.
|
|
13647
13930
|
*
|
|
13648
|
-
*
|
|
13649
|
-
*
|
|
13650
|
-
*
|
|
13931
|
+
* **When to use**
|
|
13932
|
+
*
|
|
13933
|
+
* Use when you need to accept transport formats that may represent a
|
|
13934
|
+
* single-item array as a bare value, such as query-string or form-data adapters.
|
|
13935
|
+
*
|
|
13936
|
+
* **Gotchas**
|
|
13651
13937
|
*
|
|
13652
|
-
*
|
|
13938
|
+
* This combinator is intentionally not part of `toCodecStringTree`; it adds a
|
|
13939
|
+
* decoding convenience rather than a canonical StringTree representation. It
|
|
13940
|
+
* does not parse comma-separated strings.
|
|
13653
13941
|
*
|
|
13654
13942
|
* @category Canonical Codecs
|
|
13655
13943
|
* @since 4.0.0
|
|
13656
13944
|
*/
|
|
13657
|
-
export function
|
|
13658
|
-
|
|
13659
|
-
schema: Codec<T, E, RD, RE>,
|
|
13660
|
-
options: { readonly keepDeclarations: true } // Used in FormData
|
|
13661
|
-
): Codec<T, unknown, RD, RE>
|
|
13662
|
-
export function toCodecStringTree<T, E, RD, RE>(
|
|
13663
|
-
schema: Codec<T, E, RD, RE>,
|
|
13664
|
-
options?: { readonly keepDeclarations?: boolean | undefined }
|
|
13665
|
-
): Codec<T, unknown, RD, RE> {
|
|
13666
|
-
return make(
|
|
13667
|
-
toCodecEnsureArray(
|
|
13668
|
-
options?.keepDeclarations === true
|
|
13669
|
-
? serializerStringTreeKeepDeclarations(schema.ast)
|
|
13670
|
-
: serializerStringTree(schema.ast)
|
|
13671
|
-
)
|
|
13672
|
-
)
|
|
13945
|
+
export function toCodecArrayFromSingle<S extends Constraint>(schema: S): toCodecArrayFromSingle<S> {
|
|
13946
|
+
return make(toCodecArrayFromSingleTop(schema.ast))
|
|
13673
13947
|
}
|
|
13674
13948
|
|
|
13675
13949
|
type XmlEncoderOptions = {
|
|
@@ -13885,7 +14159,15 @@ const booleanToString = new SchemaAST.Link(
|
|
|
13885
14159
|
)
|
|
13886
14160
|
)
|
|
13887
14161
|
|
|
13888
|
-
const
|
|
14162
|
+
const SERIALIZER_ENSURE_ARRAY = "~effect/Schema/SERIALIZER_ENSURE_ARRAY"
|
|
14163
|
+
|
|
14164
|
+
const isSerializerArrayFromSingle = (ast: SchemaAST.AST): boolean =>
|
|
14165
|
+
SchemaAST.isUnion(ast) && ast.annotations?.[SERIALIZER_ENSURE_ARRAY] === true
|
|
14166
|
+
|
|
14167
|
+
const serializerStringTree = SchemaAST.applyToSelfOrLastLinkEncoding((ast) => {
|
|
14168
|
+
if (isSerializerArrayFromSingle(ast)) {
|
|
14169
|
+
return ast
|
|
14170
|
+
}
|
|
13889
14171
|
const out = serializerTree(ast, serializerStringTree, (ast) => SchemaAST.replaceEncoding(ast, [unknownToUndefined]))
|
|
13890
14172
|
if (out !== ast && SchemaAST.isOptional(ast)) {
|
|
13891
14173
|
return SchemaAST.optionalKeyLastLink(out)
|
|
@@ -13901,53 +14183,46 @@ const unknownToUndefined = new SchemaAST.Link(
|
|
|
13901
14183
|
)
|
|
13902
14184
|
)
|
|
13903
14185
|
|
|
13904
|
-
const
|
|
13905
|
-
|
|
13906
|
-
if (out !== ast && SchemaAST.isOptional(ast)) {
|
|
13907
|
-
return SchemaAST.optionalKeyLastLink(out)
|
|
13908
|
-
}
|
|
13909
|
-
return out
|
|
13910
|
-
})
|
|
14186
|
+
const toArrayFromSingleInputElement = (ast: SchemaAST.AST): SchemaAST.AST =>
|
|
14187
|
+
SchemaAST.isOptional(ast) ? SchemaAST.optionalKey(SchemaAST.unknown) : SchemaAST.unknown
|
|
13911
14188
|
|
|
13912
|
-
const
|
|
14189
|
+
const arrayFromSingleTransformation = new SchemaTransformation.Transformation(
|
|
14190
|
+
SchemaGetter.transform((input: ReadonlyArray<unknown> | string) => typeof input === "string" ? [input] : input),
|
|
14191
|
+
SchemaGetter.passthrough()
|
|
14192
|
+
)
|
|
13913
14193
|
|
|
13914
|
-
const
|
|
13915
|
-
if (
|
|
14194
|
+
const toCodecArrayFromSingleTop = SchemaAST.applyToSelfOrLastLinkEncoding((ast) => {
|
|
14195
|
+
if (isSerializerArrayFromSingle(ast)) {
|
|
13916
14196
|
return ast
|
|
13917
14197
|
}
|
|
13918
|
-
const out =
|
|
14198
|
+
const out = onSerializerArrayFromSingle(ast)
|
|
13919
14199
|
if (SchemaAST.isArrays(out)) {
|
|
13920
|
-
const ensure =
|
|
13921
|
-
|
|
13922
|
-
|
|
13923
|
-
|
|
13924
|
-
|
|
13925
|
-
|
|
13926
|
-
|
|
13927
|
-
|
|
13928
|
-
|
|
13929
|
-
|
|
13930
|
-
|
|
13931
|
-
|
|
13932
|
-
|
|
13933
|
-
|
|
14200
|
+
const ensure = SchemaAST.decodeTo(
|
|
14201
|
+
new SchemaAST.Union(
|
|
14202
|
+
[
|
|
14203
|
+
new SchemaAST.Arrays(
|
|
14204
|
+
out.isMutable,
|
|
14205
|
+
out.elements.map(toArrayFromSingleInputElement),
|
|
14206
|
+
out.rest.map(toArrayFromSingleInputElement)
|
|
14207
|
+
),
|
|
14208
|
+
SchemaAST.string
|
|
14209
|
+
],
|
|
14210
|
+
"anyOf",
|
|
14211
|
+
{ [SERIALIZER_ENSURE_ARRAY]: true }
|
|
14212
|
+
),
|
|
14213
|
+
out,
|
|
14214
|
+
arrayFromSingleTransformation
|
|
13934
14215
|
)
|
|
13935
14216
|
return SchemaAST.isOptional(ast) ? SchemaAST.optionalKey(ensure) : ensure
|
|
13936
14217
|
}
|
|
13937
14218
|
return out
|
|
13938
14219
|
})
|
|
13939
14220
|
|
|
13940
|
-
function
|
|
13941
|
-
|
|
13942
|
-
|
|
13943
|
-
|
|
13944
|
-
|
|
13945
|
-
case "Arrays":
|
|
13946
|
-
case "Objects":
|
|
13947
|
-
case "Union":
|
|
13948
|
-
case "Suspend":
|
|
13949
|
-
return ast.recur(toCodecEnsureArray)
|
|
13950
|
-
}
|
|
14221
|
+
function onSerializerArrayFromSingle(ast: SchemaAST.AST): SchemaAST.AST {
|
|
14222
|
+
return ast._tag === "Declaration" || ast._tag === "Arrays" || ast._tag === "Objects" || ast._tag === "Union" ||
|
|
14223
|
+
ast._tag === "Suspend"
|
|
14224
|
+
? ast.recur(toCodecArrayFromSingleTop)
|
|
14225
|
+
: ast
|
|
13951
14226
|
}
|
|
13952
14227
|
|
|
13953
14228
|
// -----------------------------------------------------------------------------
|
|
@@ -13961,7 +14236,7 @@ function onSerializerEnsureArray(ast: SchemaAST.AST): SchemaAST.AST {
|
|
|
13961
14236
|
* @category Optic
|
|
13962
14237
|
* @since 4.0.0
|
|
13963
14238
|
*/
|
|
13964
|
-
export function toIso<S extends
|
|
14239
|
+
export function toIso<S extends Constraint>(schema: S): Optic_.Iso<S["Type"], S["Iso"]> {
|
|
13965
14240
|
const serializer = toCodecIso(schema)
|
|
13966
14241
|
return Optic_.makeIso(SchemaParser.encodeSync(serializer), SchemaParser.decodeSync(serializer))
|
|
13967
14242
|
}
|
|
@@ -13972,7 +14247,7 @@ export function toIso<S extends Top>(schema: S): Optic_.Iso<S["Type"], S["Iso"]>
|
|
|
13972
14247
|
* @category Optic
|
|
13973
14248
|
* @since 4.0.0
|
|
13974
14249
|
*/
|
|
13975
|
-
export function toIsoSource<S extends
|
|
14250
|
+
export function toIsoSource<S extends Constraint>(_: S): Optic_.Iso<S["Type"], S["Type"]> {
|
|
13976
14251
|
return Optic_.id()
|
|
13977
14252
|
}
|
|
13978
14253
|
|
|
@@ -13982,7 +14257,7 @@ export function toIsoSource<S extends Top>(_: S): Optic_.Iso<S["Type"], S["Type"
|
|
|
13982
14257
|
* @category Optic
|
|
13983
14258
|
* @since 4.0.0
|
|
13984
14259
|
*/
|
|
13985
|
-
export function toIsoFocus<S extends
|
|
14260
|
+
export function toIsoFocus<S extends Constraint>(_: S): Optic_.Iso<S["Iso"], S["Iso"]> {
|
|
13986
14261
|
return Optic_.id()
|
|
13987
14262
|
}
|
|
13988
14263
|
|
|
@@ -13992,18 +14267,11 @@ export function toIsoFocus<S extends Top>(_: S): Optic_.Iso<S["Iso"], S["Iso"]>
|
|
|
13992
14267
|
* @category Optic
|
|
13993
14268
|
* @since 4.0.0
|
|
13994
14269
|
*/
|
|
13995
|
-
export interface overrideToCodecIso<S extends
|
|
13996
|
-
|
|
13997
|
-
S["Type"],
|
|
13998
|
-
S["Encoded"],
|
|
13999
|
-
S["DecodingServices"],
|
|
14000
|
-
S["EncodingServices"],
|
|
14270
|
+
export interface overrideToCodecIso<S extends Constraint, Iso> extends
|
|
14271
|
+
BottomLazy<
|
|
14001
14272
|
S["ast"],
|
|
14002
14273
|
overrideToCodecIso<S, Iso>,
|
|
14003
|
-
S["~type.make.in"],
|
|
14004
|
-
Iso,
|
|
14005
14274
|
S["~type.parameters"],
|
|
14006
|
-
S["~type.make"],
|
|
14007
14275
|
S["~type.mutability"],
|
|
14008
14276
|
S["~type.optionality"],
|
|
14009
14277
|
S["~type.constructor.default"],
|
|
@@ -14011,6 +14279,13 @@ export interface overrideToCodecIso<S extends Top, Iso> extends
|
|
|
14011
14279
|
S["~encoded.optionality"]
|
|
14012
14280
|
>
|
|
14013
14281
|
{
|
|
14282
|
+
readonly "Type": S["Type"]
|
|
14283
|
+
readonly "Encoded": S["Encoded"]
|
|
14284
|
+
readonly "DecodingServices": S["DecodingServices"]
|
|
14285
|
+
readonly "EncodingServices": S["EncodingServices"]
|
|
14286
|
+
readonly "~type.make.in": S["~type.make.in"]
|
|
14287
|
+
readonly "~type.make": S["~type.make"]
|
|
14288
|
+
readonly "Iso": Iso
|
|
14014
14289
|
readonly schema: S
|
|
14015
14290
|
}
|
|
14016
14291
|
|
|
@@ -14031,7 +14306,7 @@ export interface overrideToCodecIso<S extends Top, Iso> extends
|
|
|
14031
14306
|
* @category Optic
|
|
14032
14307
|
* @since 4.0.0
|
|
14033
14308
|
*/
|
|
14034
|
-
export function overrideToCodecIso<S extends
|
|
14309
|
+
export function overrideToCodecIso<S extends Constraint, Iso>(
|
|
14035
14310
|
to: Codec<Iso>,
|
|
14036
14311
|
transformation: {
|
|
14037
14312
|
readonly decode: SchemaGetter.Getter<S["Type"], Iso>
|
|
@@ -14104,7 +14379,7 @@ export interface TreeRecord<A> {
|
|
|
14104
14379
|
* @category Tree
|
|
14105
14380
|
* @since 4.0.0
|
|
14106
14381
|
*/
|
|
14107
|
-
export function Tree<S extends
|
|
14382
|
+
export function Tree<S extends Constraint>(node: S) {
|
|
14108
14383
|
const Tree$ref = suspend((): Codec<
|
|
14109
14384
|
Tree<S["Type"]>,
|
|
14110
14385
|
Tree<S["Encoded"]>,
|
|
@@ -14221,7 +14496,7 @@ export const MutableJson: Codec<MutableJson> = make(SchemaAST.MutableJson)
|
|
|
14221
14496
|
* @category Schema Resolvers
|
|
14222
14497
|
* @since 4.0.0
|
|
14223
14498
|
*/
|
|
14224
|
-
export function resolveAnnotations<S extends
|
|
14499
|
+
export function resolveAnnotations<S extends Constraint>(
|
|
14225
14500
|
schema: S
|
|
14226
14501
|
): Annotations.Bottom<S["Type"], S["~type.parameters"]> | undefined {
|
|
14227
14502
|
return InternalAnnotations.resolve(schema.ast)
|
|
@@ -14235,7 +14510,7 @@ export function resolveAnnotations<S extends Top>(
|
|
|
14235
14510
|
* @category Schema Resolvers
|
|
14236
14511
|
* @since 4.0.0
|
|
14237
14512
|
*/
|
|
14238
|
-
export function resolveAnnotationsKey<S extends
|
|
14513
|
+
export function resolveAnnotationsKey<S extends Constraint>(schema: S): Annotations.Key<S["Type"]> | undefined {
|
|
14239
14514
|
return schema.ast.context?.annotations
|
|
14240
14515
|
}
|
|
14241
14516
|
|
|
@@ -14364,7 +14639,7 @@ export declare namespace Annotations {
|
|
|
14364
14639
|
* @category models
|
|
14365
14640
|
* @since 4.0.0
|
|
14366
14641
|
*/
|
|
14367
|
-
export interface Bottom<T, TypeParameters extends ReadonlyArray<
|
|
14642
|
+
export interface Bottom<T, TypeParameters extends ReadonlyArray<Constraint>> extends Documentation<T> {
|
|
14368
14643
|
/**
|
|
14369
14644
|
* Complete message to use when this schema node reports an issue.
|
|
14370
14645
|
*
|
|
@@ -14424,7 +14699,7 @@ export declare namespace Annotations {
|
|
|
14424
14699
|
* @category utility types
|
|
14425
14700
|
* @since 4.0.0
|
|
14426
14701
|
*/
|
|
14427
|
-
export type Type<TypeParameters extends ReadonlyArray<
|
|
14702
|
+
export type Type<TypeParameters extends ReadonlyArray<Constraint>> = {
|
|
14428
14703
|
readonly [K in keyof TypeParameters]: Codec<TypeParameters[K]["Type"]>
|
|
14429
14704
|
}
|
|
14430
14705
|
/**
|
|
@@ -14433,7 +14708,7 @@ export declare namespace Annotations {
|
|
|
14433
14708
|
* @category utility types
|
|
14434
14709
|
* @since 4.0.0
|
|
14435
14710
|
*/
|
|
14436
|
-
export type Encoded<TypeParameters extends ReadonlyArray<
|
|
14711
|
+
export type Encoded<TypeParameters extends ReadonlyArray<Constraint>> = {
|
|
14437
14712
|
readonly [K in keyof TypeParameters]: Codec<TypeParameters[K]["Encoded"]>
|
|
14438
14713
|
}
|
|
14439
14714
|
}
|
|
@@ -14448,7 +14723,7 @@ export declare namespace Annotations {
|
|
|
14448
14723
|
* @category models
|
|
14449
14724
|
* @since 4.0.0
|
|
14450
14725
|
*/
|
|
14451
|
-
export interface Declaration<T, TypeParameters extends ReadonlyArray<
|
|
14726
|
+
export interface Declaration<T, TypeParameters extends ReadonlyArray<Constraint> = readonly []>
|
|
14452
14727
|
extends Bottom<T, TypeParameters>
|
|
14453
14728
|
{
|
|
14454
14729
|
readonly toCodec?:
|
|
@@ -14561,7 +14836,7 @@ export declare namespace Annotations {
|
|
|
14561
14836
|
* @since 4.0.0
|
|
14562
14837
|
*/
|
|
14563
14838
|
export interface Filter {
|
|
14564
|
-
readonly constraint?:
|
|
14839
|
+
readonly constraint?: GenerationConstraint | undefined
|
|
14565
14840
|
readonly candidate?: Candidate | undefined
|
|
14566
14841
|
}
|
|
14567
14842
|
|
|
@@ -14613,10 +14888,10 @@ export declare namespace Annotations {
|
|
|
14613
14888
|
*
|
|
14614
14889
|
* **Details**
|
|
14615
14890
|
*
|
|
14616
|
-
* `
|
|
14617
|
-
* self-describing validation contract. Each generator consumes
|
|
14618
|
-
* understands for the current node and ignores the rest;
|
|
14619
|
-
* filters still validate every generated value.
|
|
14891
|
+
* `GenerationConstraint` is a generation hint for the current schema AST
|
|
14892
|
+
* node, not a self-describing validation contract. Each generator consumes
|
|
14893
|
+
* the fields it understands for the current node and ignores the rest;
|
|
14894
|
+
* final schema filters still validate every generated value.
|
|
14620
14895
|
*
|
|
14621
14896
|
* `minLength` and `maxLength` represent node-local cardinality: string
|
|
14622
14897
|
* length for strings, array length for arrays, final own-property count for
|
|
@@ -14629,7 +14904,7 @@ export declare namespace Annotations {
|
|
|
14629
14904
|
* @category models
|
|
14630
14905
|
* @since 4.0.0
|
|
14631
14906
|
*/
|
|
14632
|
-
export interface
|
|
14907
|
+
export interface GenerationConstraint {
|
|
14633
14908
|
readonly minLength?: number | undefined
|
|
14634
14909
|
readonly maxLength?: number | undefined
|
|
14635
14910
|
readonly patterns?: readonly [string, ...Array<string>]
|
|
@@ -14672,7 +14947,7 @@ export declare namespace Annotations {
|
|
|
14672
14947
|
* @since 4.0.0
|
|
14673
14948
|
*/
|
|
14674
14949
|
export interface Context {
|
|
14675
|
-
readonly constraint?: ToArbitrary.
|
|
14950
|
+
readonly constraint?: ToArbitrary.GenerationConstraint | undefined
|
|
14676
14951
|
readonly recursion?: ToArbitrary.Recursion | undefined
|
|
14677
14952
|
}
|
|
14678
14953
|
|
|
@@ -14738,7 +15013,7 @@ export declare namespace Annotations {
|
|
|
14738
15013
|
* @category models
|
|
14739
15014
|
* @since 4.0.0
|
|
14740
15015
|
*/
|
|
14741
|
-
export interface Declaration<T, TypeParameters extends ReadonlyArray<
|
|
15016
|
+
export interface Declaration<T, TypeParameters extends ReadonlyArray<Constraint>> {
|
|
14742
15017
|
(
|
|
14743
15018
|
/* Arbitrary derivations for any type parameters of the schema (if present) */
|
|
14744
15019
|
typeParameters: { readonly [K in keyof TypeParameters]: TypeParameter<TypeParameters[K]["Type"]> }
|
|
@@ -14815,7 +15090,7 @@ export declare namespace Annotations {
|
|
|
14815
15090
|
* @category models
|
|
14816
15091
|
* @since 4.0.0
|
|
14817
15092
|
*/
|
|
14818
|
-
export interface Declaration<T, TypeParameters extends ReadonlyArray<
|
|
15093
|
+
export interface Declaration<T, TypeParameters extends ReadonlyArray<Constraint>> {
|
|
14819
15094
|
(
|
|
14820
15095
|
/* Formatters for any type parameters of the schema (if present) */
|
|
14821
15096
|
typeParameters: { readonly [K in keyof TypeParameters]: Formatter<TypeParameters[K]["Type"]> }
|
|
@@ -14840,7 +15115,7 @@ export declare namespace Annotations {
|
|
|
14840
15115
|
* @category models
|
|
14841
15116
|
* @since 4.0.0
|
|
14842
15117
|
*/
|
|
14843
|
-
export interface Declaration<T, TypeParameters extends ReadonlyArray<
|
|
15118
|
+
export interface Declaration<T, TypeParameters extends ReadonlyArray<Constraint>> {
|
|
14844
15119
|
(
|
|
14845
15120
|
/* Equivalences for any type parameters of the schema (if present) */
|
|
14846
15121
|
typeParameters: { readonly [K in keyof TypeParameters]: Equivalence.Equivalence<TypeParameters[K]["Type"]> }
|