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/dist/Schema.d.ts
CHANGED
|
@@ -102,24 +102,18 @@ export interface MakeOptions {
|
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* The fully-parameterized base interface for all schemas. Exposes all 14 type
|
|
105
|
-
* parameters controlling type inference, mutability, optionality, services,
|
|
106
|
-
*
|
|
105
|
+
* parameters controlling type inference, mutability, optionality, services, and
|
|
106
|
+
* transformation behavior.
|
|
107
107
|
*
|
|
108
108
|
* **When to use**
|
|
109
109
|
*
|
|
110
|
-
* Use when you are writing advanced generic schema utilities or performing
|
|
111
|
-
* introspection.
|
|
112
|
-
* - In user code, prefer {@link Schema}, {@link Codec}, {@link Decoder}, or
|
|
113
|
-
* {@link Encoder} instead.
|
|
114
|
-
*
|
|
115
|
-
* @see {@link Top} — the existential "any schema" type (erased type params)
|
|
116
|
-
* @see {@link Schema} — tracks only the decoded Type
|
|
117
|
-
* @see {@link Codec} — tracks Type + Encoded
|
|
110
|
+
* Use when you are writing advanced generic schema utilities or performing
|
|
111
|
+
* schema introspection.
|
|
118
112
|
*
|
|
119
113
|
* @category models
|
|
120
114
|
* @since 4.0.0
|
|
121
115
|
*/
|
|
122
|
-
export interface Bottom<out T, out E, out RD, out RE, out Ast extends SchemaAST.AST, out Rebuild extends Top, out TypeMakeIn = T, out Iso = T, in out TypeParameters extends ReadonlyArray<
|
|
116
|
+
export interface Bottom<out T, out E, out RD, out RE, out Ast extends SchemaAST.AST, out Rebuild extends Top, out TypeMakeIn = T, out Iso = T, in out TypeParameters extends ReadonlyArray<Constraint> = readonly [], out TypeMake = TypeMakeIn, out TypeMutability extends Mutability = "readonly", out TypeOptionality extends Optionality = "required", out TypeConstructorDefault extends ConstructorDefault = "no-default", out EncodedMutability extends Mutability = "readonly", out EncodedOptionality extends Optionality = "required"> extends Pipeable.Pipeable {
|
|
123
117
|
readonly [TypeId]: typeof TypeId;
|
|
124
118
|
readonly "ast": Ast;
|
|
125
119
|
readonly "Rebuild": Rebuild;
|
|
@@ -202,13 +196,40 @@ export interface Bottom<out T, out E, out RD, out RE, out Ast extends SchemaAST.
|
|
|
202
196
|
*/
|
|
203
197
|
makeEffect(input: this["~type.make.in"], options?: MakeOptions): Effect.Effect<this["Type"], SchemaError>;
|
|
204
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Lazy `Bottom` variant for schema implementations that compute their public
|
|
201
|
+
* views on demand.
|
|
202
|
+
*
|
|
203
|
+
* **When to use**
|
|
204
|
+
*
|
|
205
|
+
* Use as an implementation base for schema interfaces that must expose
|
|
206
|
+
* `Bottom` behavior without forcing TypeScript to eagerly evaluate expensive
|
|
207
|
+
* `Type`, `Encoded`, or service views.
|
|
208
|
+
*
|
|
209
|
+
* **Details**
|
|
210
|
+
*
|
|
211
|
+
* The laziness is purely type-level; runtime behavior is unchanged.
|
|
212
|
+
* `BottomLazy` keeps the structural operations inherited from `Bottom`, but
|
|
213
|
+
* erases the expensive schema views to `unknown`. Concrete schema interfaces can
|
|
214
|
+
* then redeclare the precise views they expose. This keeps wide schemas such as
|
|
215
|
+
* `Struct` and `Union` cheaper when generic code reads a single view, while
|
|
216
|
+
* preserving their exact public types.
|
|
217
|
+
*
|
|
218
|
+
* @see {@link Bottom} for the fully parameterized schema interface when every
|
|
219
|
+
* view must be supplied directly.
|
|
220
|
+
*
|
|
221
|
+
* @category utility types
|
|
222
|
+
* @since 4.0.0
|
|
223
|
+
*/
|
|
224
|
+
export interface BottomLazy<out Ast extends SchemaAST.AST, out Rebuild extends Top, in out TypeParameters extends ReadonlyArray<Constraint> = readonly [], out TypeMutability extends Mutability = "readonly", out TypeOptionality extends Optionality = "required", out TypeConstructorDefault extends ConstructorDefault = "no-default", out EncodedMutability extends Mutability = "readonly", out EncodedOptionality extends Optionality = "required"> extends Bottom<unknown, unknown, unknown, unknown, Ast, Rebuild, unknown, unknown, TypeParameters, unknown, TypeMutability, TypeOptionality, TypeConstructorDefault, EncodedMutability, EncodedOptionality> {
|
|
225
|
+
}
|
|
205
226
|
/**
|
|
206
227
|
* Type-level representation returned by {@link declareConstructor}.
|
|
207
228
|
*
|
|
208
229
|
* @category constructors
|
|
209
230
|
* @since 4.0.0
|
|
210
231
|
*/
|
|
211
|
-
export interface declareConstructor<T, E, TypeParameters extends ReadonlyArray<
|
|
232
|
+
export interface declareConstructor<T, E, TypeParameters extends ReadonlyArray<Constraint>, Iso = T> extends Bottom<T, E, TypeParameters[number]["DecodingServices"], TypeParameters[number]["EncodingServices"], SchemaAST.Declaration, declareConstructor<T, E, TypeParameters, Iso>, T, Iso, TypeParameters> {
|
|
212
233
|
}
|
|
213
234
|
/**
|
|
214
235
|
* Creates a schema for a **parametric** type (a generic container such as
|
|
@@ -243,7 +264,7 @@ export interface declareConstructor<T, E, TypeParameters extends ReadonlyArray<T
|
|
|
243
264
|
* const isBox = (u: unknown): u is Box<unknown> =>
|
|
244
265
|
* typeof u === "object" && u !== null && "value" in u
|
|
245
266
|
*
|
|
246
|
-
* const Box = <A extends Schema.
|
|
267
|
+
* const Box = <A extends Schema.Constraint>(item: A) =>
|
|
247
268
|
* Schema.declareConstructor<Box<A["Type"]>, Box<A["Encoded"]>>()(
|
|
248
269
|
* [item],
|
|
249
270
|
* ([itemCodec]) =>
|
|
@@ -264,7 +285,7 @@ export interface declareConstructor<T, E, TypeParameters extends ReadonlyArray<T
|
|
|
264
285
|
* @category constructors
|
|
265
286
|
* @since 4.0.0
|
|
266
287
|
*/
|
|
267
|
-
export declare function declareConstructor<T, E = T, Iso = T>(): <const TypeParameters extends ReadonlyArray<
|
|
288
|
+
export declare function declareConstructor<T, E = T, Iso = T>(): <const TypeParameters extends ReadonlyArray<Constraint>>(typeParameters: TypeParameters, run: (typeParameters: { readonly [K in keyof TypeParameters]: Codec<TypeParameters[K]["Type"], TypeParameters[K]["Encoded"]>; }) => (u: unknown, self: SchemaAST.Declaration, options: SchemaAST.ParseOptions) => Effect.Effect<T, SchemaIssue.Issue>, annotations?: Annotations.Declaration<T, TypeParameters>) => declareConstructor<T, E, TypeParameters, Iso>;
|
|
268
289
|
/**
|
|
269
290
|
* Type-level representation returned by {@link declare}.
|
|
270
291
|
*
|
|
@@ -439,8 +460,8 @@ export declare function annotateKey<S extends Top>(annotations: Annotations.Key<
|
|
|
439
460
|
* In user code prefer the narrower interfaces:
|
|
440
461
|
* - {@link Schema}`<T>` — when you only care about the decoded type
|
|
441
462
|
* - {@link Codec}`<T, E, RD, RE>` — when you need the encoded type and service requirements
|
|
442
|
-
* - {@link
|
|
443
|
-
* - {@link
|
|
463
|
+
* - {@link ConstraintDecoder}`<T, RD>` — for decode-only APIs
|
|
464
|
+
* - {@link ConstraintEncoder}`<E, RE>` — for encode-only APIs
|
|
444
465
|
*
|
|
445
466
|
* @category models
|
|
446
467
|
* @since 4.0.0
|
|
@@ -448,6 +469,121 @@ export declare function annotateKey<S extends Top>(annotations: Annotations.Key<
|
|
|
448
469
|
export interface Top extends Bottom<unknown, unknown, unknown, unknown, SchemaAST.AST, Top, unknown, unknown, any, // this is because TypeParameters is invariant
|
|
449
470
|
unknown, Mutability, Optionality, ConstructorDefault, Mutability, Optionality> {
|
|
450
471
|
}
|
|
472
|
+
/**
|
|
473
|
+
* Lightweight structural constraint for APIs that accept schema values but only
|
|
474
|
+
* read their data and type-level views.
|
|
475
|
+
*
|
|
476
|
+
* **When to use**
|
|
477
|
+
*
|
|
478
|
+
* Use when you need to constrain a generic value to be a schema, but the API
|
|
479
|
+
* only reads properties such as `ast`, `Type`, `Encoded`, service
|
|
480
|
+
* requirements, constructor input views, or modifier flags.
|
|
481
|
+
*
|
|
482
|
+
* **Details**
|
|
483
|
+
*
|
|
484
|
+
* `Constraint` keeps the schema type identifier and the property surface needed
|
|
485
|
+
* by schema constructors, while avoiding the full `Bottom` protocol. Use
|
|
486
|
+
* {@link Top} when an API calls schema methods such as `annotate`, `check`,
|
|
487
|
+
* `rebuild`, `make`, or `makeEffect`.
|
|
488
|
+
*
|
|
489
|
+
* @see {@link Top} for the complete schema protocol.
|
|
490
|
+
*
|
|
491
|
+
* @category models
|
|
492
|
+
* @since 4.0.0
|
|
493
|
+
*/
|
|
494
|
+
export interface Constraint {
|
|
495
|
+
readonly [TypeId]: typeof TypeId;
|
|
496
|
+
readonly "ast": SchemaAST.AST;
|
|
497
|
+
readonly "Type": unknown;
|
|
498
|
+
readonly "Encoded": unknown;
|
|
499
|
+
readonly "DecodingServices": unknown;
|
|
500
|
+
readonly "EncodingServices": unknown;
|
|
501
|
+
readonly "~type.parameters": any;
|
|
502
|
+
readonly "~type.make.in": unknown;
|
|
503
|
+
readonly "~type.make": unknown;
|
|
504
|
+
readonly "Iso": unknown;
|
|
505
|
+
readonly "~type.optionality": Optionality;
|
|
506
|
+
readonly "~type.mutability": Mutability;
|
|
507
|
+
readonly "~type.constructor.default": ConstructorDefault;
|
|
508
|
+
readonly "~encoded.optionality": Optionality;
|
|
509
|
+
readonly "~encoded.mutability": Mutability;
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Lightweight structural constraint for APIs that need codec type views but do
|
|
513
|
+
* not need the full schema protocol.
|
|
514
|
+
*
|
|
515
|
+
* **When to use**
|
|
516
|
+
*
|
|
517
|
+
* Use when you need to preserve decoded type, encoded type, and service
|
|
518
|
+
* requirements for a schema value, but the API does not call schema methods
|
|
519
|
+
* such as `annotate`, `check`, `rebuild`, `make`, or `makeEffect`.
|
|
520
|
+
*
|
|
521
|
+
* @see {@link Constraint} for the generic lightweight schema constraint.
|
|
522
|
+
* @see {@link Codec} for the full schema protocol with codec type views.
|
|
523
|
+
*
|
|
524
|
+
* @category models
|
|
525
|
+
* @since 4.0.0
|
|
526
|
+
*/
|
|
527
|
+
export interface ConstraintCodec<out T, out E = T, out RD = never, out RE = never> extends Constraint {
|
|
528
|
+
readonly "Type": T;
|
|
529
|
+
readonly "Encoded": E;
|
|
530
|
+
readonly "DecodingServices": RD;
|
|
531
|
+
readonly "EncodingServices": RE;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Lightweight structural constraint for APIs that need decoder type views but
|
|
535
|
+
* do not need the full schema protocol.
|
|
536
|
+
*
|
|
537
|
+
* **When to use**
|
|
538
|
+
*
|
|
539
|
+
* Use when you need to preserve a schema's decoded type and decoding services,
|
|
540
|
+
* but the API does not constrain the encoded type, encoding services, or call
|
|
541
|
+
* schema methods such as `annotate`, `check`, `rebuild`, `make`, or
|
|
542
|
+
* `makeEffect`.
|
|
543
|
+
*
|
|
544
|
+
* @see {@link ConstraintCodec} for APIs that need both decoded and encoded codec views.
|
|
545
|
+
* @see {@link Codec} for the full schema protocol with codec type views.
|
|
546
|
+
*
|
|
547
|
+
* @category models
|
|
548
|
+
* @since 4.0.0
|
|
549
|
+
*/
|
|
550
|
+
export interface ConstraintDecoder<out T, out RD = never> extends ConstraintCodec<T, unknown, RD, unknown> {
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Lightweight structural constraint for APIs that need encoder type views but
|
|
554
|
+
* do not need the full schema protocol.
|
|
555
|
+
*
|
|
556
|
+
* **When to use**
|
|
557
|
+
*
|
|
558
|
+
* Use when you need to preserve a schema's encoded type and encoding services,
|
|
559
|
+
* but the API does not constrain the decoded type, decoding services, or call
|
|
560
|
+
* schema methods such as `annotate`, `check`, `rebuild`, `make`, or
|
|
561
|
+
* `makeEffect`.
|
|
562
|
+
*
|
|
563
|
+
* @see {@link ConstraintCodec} for APIs that need both decoded and encoded codec views.
|
|
564
|
+
* @see {@link Codec} for the full schema protocol with codec type views.
|
|
565
|
+
*
|
|
566
|
+
* @category models
|
|
567
|
+
* @since 4.0.0
|
|
568
|
+
*/
|
|
569
|
+
export interface ConstraintEncoder<out E, out RE = never> extends ConstraintCodec<unknown, E, unknown, RE> {
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Lightweight structural constraint for APIs that need schema views and the
|
|
573
|
+
* rebuilt schema type, but do not call the full schema protocol.
|
|
574
|
+
*
|
|
575
|
+
* **When to use**
|
|
576
|
+
*
|
|
577
|
+
* Use when an API needs to read `Rebuild` in addition to the schema views
|
|
578
|
+
* exposed by {@link Constraint}, but does not call methods such as `annotate`,
|
|
579
|
+
* `check`, `rebuild`, `make`, or `makeEffect`.
|
|
580
|
+
*
|
|
581
|
+
* @category models
|
|
582
|
+
* @since 4.0.0
|
|
583
|
+
*/
|
|
584
|
+
export interface ConstraintRebuildable extends Constraint {
|
|
585
|
+
readonly "Rebuild": Constraint;
|
|
586
|
+
}
|
|
451
587
|
/**
|
|
452
588
|
* Namespace of type-level helpers for {@link Schema}.
|
|
453
589
|
*
|
|
@@ -470,7 +606,9 @@ export declare namespace Schema {
|
|
|
470
606
|
* @category utility types
|
|
471
607
|
* @since 3.10.0
|
|
472
608
|
*/
|
|
473
|
-
type Type<S> = S extends
|
|
609
|
+
type Type<S> = S extends {
|
|
610
|
+
readonly "Type": infer T;
|
|
611
|
+
} ? T : never;
|
|
474
612
|
}
|
|
475
613
|
/**
|
|
476
614
|
* A typed view of a schema that tracks only the decoded (output) type `T`.
|
|
@@ -528,7 +666,9 @@ export declare namespace Codec {
|
|
|
528
666
|
* @category utility types
|
|
529
667
|
* @since 3.10.0
|
|
530
668
|
*/
|
|
531
|
-
type Encoded<S> = S extends
|
|
669
|
+
type Encoded<S> = S extends {
|
|
670
|
+
readonly "Encoded": infer E;
|
|
671
|
+
} ? E : never;
|
|
532
672
|
/**
|
|
533
673
|
* Extracts the Effect services required during *decoding* from a schema.
|
|
534
674
|
*
|
|
@@ -545,7 +685,9 @@ export declare namespace Codec {
|
|
|
545
685
|
* @category utility types
|
|
546
686
|
* @since 4.0.0
|
|
547
687
|
*/
|
|
548
|
-
type DecodingServices<S> = S extends
|
|
688
|
+
type DecodingServices<S> = S extends {
|
|
689
|
+
readonly "DecodingServices": infer R;
|
|
690
|
+
} ? R : never;
|
|
549
691
|
/**
|
|
550
692
|
* Extracts the Effect services required during *encoding* from a schema.
|
|
551
693
|
*
|
|
@@ -562,7 +704,9 @@ export declare namespace Codec {
|
|
|
562
704
|
* @category utility types
|
|
563
705
|
* @since 4.0.0
|
|
564
706
|
*/
|
|
565
|
-
type EncodingServices<S> = S extends
|
|
707
|
+
type EncodingServices<S> = S extends {
|
|
708
|
+
readonly "EncodingServices": infer R;
|
|
709
|
+
} ? R : never;
|
|
566
710
|
}
|
|
567
711
|
/**
|
|
568
712
|
* A schema that additionally supports optic (lens/prism) operations.
|
|
@@ -599,8 +743,8 @@ export interface Optic<out T, out Iso> extends Schema<T> {
|
|
|
599
743
|
* Most concrete schemas produced by this module implement `Codec`.
|
|
600
744
|
*
|
|
601
745
|
* For APIs that only need one direction, prefer the narrower views:
|
|
602
|
-
* - {@link
|
|
603
|
-
* - {@link
|
|
746
|
+
* - {@link ConstraintDecoder}`<T, RD>` — decode-only
|
|
747
|
+
* - {@link ConstraintEncoder}`<E, RE>` — encode-only
|
|
604
748
|
* - {@link Schema}`<T>` — type-only (no encoded representation)
|
|
605
749
|
*
|
|
606
750
|
* **Example** (Accepting a codec that decodes to `number` from `string`)
|
|
@@ -627,58 +771,6 @@ export interface Codec<out T, out E = T, out RD = never, out RE = never> extends
|
|
|
627
771
|
readonly "EncodingServices": RE;
|
|
628
772
|
readonly "Rebuild": Codec<T, E, RD, RE>;
|
|
629
773
|
}
|
|
630
|
-
/**
|
|
631
|
-
* A {@link Codec} view for APIs that only *decode* (parse/validate) values.
|
|
632
|
-
*
|
|
633
|
-
* **Details**
|
|
634
|
-
*
|
|
635
|
-
* Use `Decoder<T, RD>` to accept "any schema that can decode to `T`" without
|
|
636
|
-
* constraining or depending on the encoded representation (`Encoded` is
|
|
637
|
-
* `unknown`) or encoding services.
|
|
638
|
-
*
|
|
639
|
-
* **Example** (Accepting schemas that only need to decode)
|
|
640
|
-
*
|
|
641
|
-
* ```ts
|
|
642
|
-
* import { Schema } from "effect"
|
|
643
|
-
*
|
|
644
|
-
* declare function validate<T>(decoder: Schema.Decoder<T>): (input: unknown) => T
|
|
645
|
-
*
|
|
646
|
-
* validate(Schema.String) // ok
|
|
647
|
-
* validate(Schema.NumberFromString) // ok
|
|
648
|
-
* ```
|
|
649
|
-
*
|
|
650
|
-
* @category models
|
|
651
|
-
* @since 4.0.0
|
|
652
|
-
*/
|
|
653
|
-
export interface Decoder<out T, out RD = never> extends Codec<T, unknown, RD, unknown> {
|
|
654
|
-
readonly "Rebuild": Decoder<T, RD>;
|
|
655
|
-
}
|
|
656
|
-
/**
|
|
657
|
-
* A {@link Codec} view for APIs that only *encode* values.
|
|
658
|
-
*
|
|
659
|
-
* **Details**
|
|
660
|
-
*
|
|
661
|
-
* Use `Encoder<E, RE>` to accept "any schema that can encode to `E`" without
|
|
662
|
-
* constraining or depending on the decoded `Type` (`Type` is `unknown`) or
|
|
663
|
-
* decoding services.
|
|
664
|
-
*
|
|
665
|
-
* **Example** (Accepting schemas that only need to encode)
|
|
666
|
-
*
|
|
667
|
-
* ```ts
|
|
668
|
-
* import { Schema } from "effect"
|
|
669
|
-
*
|
|
670
|
-
* declare function serialize<E>(encoder: Schema.Encoder<E>): (value: unknown) => E
|
|
671
|
-
*
|
|
672
|
-
* serialize(Schema.String) // ok — encodes to string
|
|
673
|
-
* serialize(Schema.NumberFromString) // ok — encodes number to string
|
|
674
|
-
* ```
|
|
675
|
-
*
|
|
676
|
-
* @category models
|
|
677
|
-
* @since 4.0.0
|
|
678
|
-
*/
|
|
679
|
-
export interface Encoder<out E, out RE = never> extends Codec<unknown, E, unknown, RE> {
|
|
680
|
-
readonly "Rebuild": Encoder<E, RE>;
|
|
681
|
-
}
|
|
682
774
|
/**
|
|
683
775
|
* Returns a codec widened to the full {@link Codec} interface, prompting
|
|
684
776
|
* TypeScript to infer all four type parameters (`T`, `E`, `RD`, `RE`).
|
|
@@ -822,7 +914,7 @@ export declare function isSchemaError(u: unknown): u is SchemaError;
|
|
|
822
914
|
* @category Standard Schema
|
|
823
915
|
* @since 4.0.0
|
|
824
916
|
*/
|
|
825
|
-
export declare function toStandardSchemaV1<S extends
|
|
917
|
+
export declare function toStandardSchemaV1<S extends ConstraintDecoder<unknown>>(self: S, options?: {
|
|
826
918
|
readonly leafHook?: SchemaIssue.LeafHook | undefined;
|
|
827
919
|
readonly checkHook?: SchemaIssue.CheckHook | undefined;
|
|
828
920
|
readonly parseOptions?: SchemaAST.ParseOptions | undefined;
|
|
@@ -837,7 +929,7 @@ export declare function toStandardSchemaV1<S extends Decoder<unknown>>(self: S,
|
|
|
837
929
|
* @category Standard Schema
|
|
838
930
|
* @since 4.0.0
|
|
839
931
|
*/
|
|
840
|
-
export declare function toStandardJSONSchemaV1<S extends
|
|
932
|
+
export declare function toStandardJSONSchemaV1<S extends Constraint>(self: S): StandardJSONSchemaV1<S["Encoded"], S["Type"]> & S;
|
|
841
933
|
/**
|
|
842
934
|
* Creates a type guard function that checks if a value conforms to a given
|
|
843
935
|
* schema.
|
|
@@ -919,7 +1011,7 @@ export declare const is: typeof SchemaParser.is;
|
|
|
919
1011
|
* @category guards
|
|
920
1012
|
* @since 4.0.0
|
|
921
1013
|
*/
|
|
922
|
-
export declare const asserts: <S extends
|
|
1014
|
+
export declare const asserts: <S extends Constraint, I>(schema: S, input: I) => asserts input is I & S["Type"];
|
|
923
1015
|
/**
|
|
924
1016
|
* Decodes an `unknown` input against a schema, returning an `Effect` that
|
|
925
1017
|
* succeeds with the decoded value or fails with a {@link SchemaError}.
|
|
@@ -941,7 +1033,7 @@ export declare const asserts: <S extends Top, I>(schema: S, input: I) => asserts
|
|
|
941
1033
|
* @category decoding
|
|
942
1034
|
* @since 4.0.0
|
|
943
1035
|
*/
|
|
944
|
-
export declare function decodeUnknownEffect<S extends
|
|
1036
|
+
export declare function decodeUnknownEffect<S extends Constraint>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, options?: SchemaAST.ParseOptions) => Effect.Effect<S["Type"], SchemaError, S["DecodingServices"]>;
|
|
945
1037
|
/**
|
|
946
1038
|
* Decodes a typed input (the schema's `Encoded` type) against a schema,
|
|
947
1039
|
* returning an `Effect` that succeeds with the decoded value or fails with a
|
|
@@ -963,7 +1055,7 @@ export declare function decodeUnknownEffect<S extends Top>(schema: S, options?:
|
|
|
963
1055
|
* @category decoding
|
|
964
1056
|
* @since 4.0.0
|
|
965
1057
|
*/
|
|
966
|
-
export declare const decodeEffect: <S extends
|
|
1058
|
+
export declare const decodeEffect: <S extends Constraint>(schema: S, options?: SchemaAST.ParseOptions) => (input: S["Encoded"], options?: SchemaAST.ParseOptions) => Effect.Effect<S["Type"], SchemaError, S["DecodingServices"]>;
|
|
967
1059
|
/**
|
|
968
1060
|
* Decodes an `unknown` input against a schema synchronously, returning an
|
|
969
1061
|
* `Exit` that is either a `Success` with the decoded value or a `Failure`.
|
|
@@ -994,7 +1086,7 @@ export declare const decodeEffect: <S extends Top>(schema: S, options?: SchemaAS
|
|
|
994
1086
|
* @category decoding
|
|
995
1087
|
* @since 4.0.0
|
|
996
1088
|
*/
|
|
997
|
-
export declare function decodeUnknownExit<S extends
|
|
1089
|
+
export declare function decodeUnknownExit<S extends ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, options?: SchemaAST.ParseOptions) => Exit_.Exit<S["Type"], SchemaError>;
|
|
998
1090
|
/**
|
|
999
1091
|
* Decodes a typed input (the schema's `Encoded` type) against a schema
|
|
1000
1092
|
* synchronously, returning an `Exit` that is either a `Success` with the decoded
|
|
@@ -1025,7 +1117,7 @@ export declare function decodeUnknownExit<S extends Decoder<unknown>>(schema: S,
|
|
|
1025
1117
|
* @category decoding
|
|
1026
1118
|
* @since 4.0.0
|
|
1027
1119
|
*/
|
|
1028
|
-
export declare const decodeExit: <S extends
|
|
1120
|
+
export declare const decodeExit: <S extends ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) => (input: S["Encoded"], options?: SchemaAST.ParseOptions) => Exit_.Exit<S["Type"], SchemaError>;
|
|
1029
1121
|
/**
|
|
1030
1122
|
* Decodes an `unknown` input against a schema, returning an `Option` that is
|
|
1031
1123
|
* `Some` with the decoded value on success or `None` for schema mismatches.
|
|
@@ -1052,7 +1144,7 @@ export declare const decodeExit: <S extends Decoder<unknown>>(schema: S, options
|
|
|
1052
1144
|
* @category decoding
|
|
1053
1145
|
* @since 3.10.0
|
|
1054
1146
|
*/
|
|
1055
|
-
export declare const decodeUnknownOption: <S extends
|
|
1147
|
+
export declare const decodeUnknownOption: <S extends ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) => (input: unknown, options?: SchemaAST.ParseOptions) => Option_.Option<S["Type"]>;
|
|
1056
1148
|
/**
|
|
1057
1149
|
* Decodes a typed input (the schema's `Encoded` type) against a schema,
|
|
1058
1150
|
* returning an `Option` that is `Some` with the decoded value on success or
|
|
@@ -1078,7 +1170,7 @@ export declare const decodeUnknownOption: <S extends Decoder<unknown>>(schema: S
|
|
|
1078
1170
|
* @category decoding
|
|
1079
1171
|
* @since 3.10.0
|
|
1080
1172
|
*/
|
|
1081
|
-
export declare const decodeOption: <S extends
|
|
1173
|
+
export declare const decodeOption: <S extends ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) => (input: S["Encoded"], options?: SchemaAST.ParseOptions) => Option_.Option<S["Type"]>;
|
|
1082
1174
|
/**
|
|
1083
1175
|
* Decodes an `unknown` input against a schema, returning a `Result` that
|
|
1084
1176
|
* succeeds with the decoded value or fails with a {@link SchemaError} for schema
|
|
@@ -1108,7 +1200,7 @@ export declare const decodeOption: <S extends Decoder<unknown>>(schema: S, optio
|
|
|
1108
1200
|
* @category decoding
|
|
1109
1201
|
* @since 4.0.0
|
|
1110
1202
|
*/
|
|
1111
|
-
export declare function decodeUnknownResult<S extends
|
|
1203
|
+
export declare function decodeUnknownResult<S extends ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, options?: SchemaAST.ParseOptions) => Result_.Result<S["Type"], SchemaError>;
|
|
1112
1204
|
/**
|
|
1113
1205
|
* Decodes a typed input (the schema's `Encoded` type) against a schema,
|
|
1114
1206
|
* returning a `Result` that succeeds with the decoded value or fails with a
|
|
@@ -1137,7 +1229,7 @@ export declare function decodeUnknownResult<S extends Decoder<unknown>>(schema:
|
|
|
1137
1229
|
* @category decoding
|
|
1138
1230
|
* @since 4.0.0
|
|
1139
1231
|
*/
|
|
1140
|
-
export declare const decodeResult: <S extends
|
|
1232
|
+
export declare const decodeResult: <S extends ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) => (input: S["Encoded"], options?: SchemaAST.ParseOptions) => Result_.Result<S["Type"], SchemaError>;
|
|
1141
1233
|
/**
|
|
1142
1234
|
* Decodes an `unknown` input against a schema, returning a `Promise` that
|
|
1143
1235
|
* resolves with the decoded value or rejects with a {@link SchemaError} for
|
|
@@ -1165,7 +1257,7 @@ export declare const decodeResult: <S extends Decoder<unknown>>(schema: S, optio
|
|
|
1165
1257
|
* @category decoding
|
|
1166
1258
|
* @since 3.10.0
|
|
1167
1259
|
*/
|
|
1168
|
-
export declare function decodeUnknownPromise<S extends
|
|
1260
|
+
export declare function decodeUnknownPromise<S extends ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, options?: SchemaAST.ParseOptions) => Promise<S["Type"]>;
|
|
1169
1261
|
/**
|
|
1170
1262
|
* Decodes a typed input (the schema's `Encoded` type) against a schema,
|
|
1171
1263
|
* returning a `Promise` that resolves with the decoded value or rejects with a
|
|
@@ -1193,7 +1285,7 @@ export declare function decodeUnknownPromise<S extends Decoder<unknown>>(schema:
|
|
|
1193
1285
|
* @category decoding
|
|
1194
1286
|
* @since 3.10.0
|
|
1195
1287
|
*/
|
|
1196
|
-
export declare const decodePromise: <S extends
|
|
1288
|
+
export declare const decodePromise: <S extends ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) => (input: S["Encoded"], options?: SchemaAST.ParseOptions) => Promise<S["Type"]>;
|
|
1197
1289
|
/**
|
|
1198
1290
|
* Decodes an `unknown` input against a schema synchronously, returning the
|
|
1199
1291
|
* decoded value or throwing a {@link SchemaError} for schema mismatches.
|
|
@@ -1238,7 +1330,7 @@ export declare const decodePromise: <S extends Decoder<unknown>>(schema: S, opti
|
|
|
1238
1330
|
* @category decoding
|
|
1239
1331
|
* @since 4.0.0
|
|
1240
1332
|
*/
|
|
1241
|
-
export declare function decodeUnknownSync<S extends
|
|
1333
|
+
export declare function decodeUnknownSync<S extends ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, options?: SchemaAST.ParseOptions) => S["Type"];
|
|
1242
1334
|
/**
|
|
1243
1335
|
* Decodes a typed input (the schema's `Encoded` type) against a schema
|
|
1244
1336
|
* synchronously, returning the decoded value or throwing a {@link SchemaError}
|
|
@@ -1265,7 +1357,7 @@ export declare function decodeUnknownSync<S extends Decoder<unknown>>(schema: S,
|
|
|
1265
1357
|
* @category decoding
|
|
1266
1358
|
* @since 4.0.0
|
|
1267
1359
|
*/
|
|
1268
|
-
export declare const decodeSync: <S extends
|
|
1360
|
+
export declare const decodeSync: <S extends ConstraintDecoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) => (input: S["Encoded"], options?: SchemaAST.ParseOptions) => S["Type"];
|
|
1269
1361
|
/**
|
|
1270
1362
|
* Encodes an `unknown` input against a schema, returning an `Effect` that
|
|
1271
1363
|
* succeeds with the encoded value or fails with a {@link SchemaError}.
|
|
@@ -1298,7 +1390,7 @@ export declare const decodeSync: <S extends Decoder<unknown>>(schema: S, options
|
|
|
1298
1390
|
* @category encoding
|
|
1299
1391
|
* @since 4.0.0
|
|
1300
1392
|
*/
|
|
1301
|
-
export declare function encodeUnknownEffect<S extends
|
|
1393
|
+
export declare function encodeUnknownEffect<S extends Constraint>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, options?: SchemaAST.ParseOptions) => Effect.Effect<S["Encoded"], SchemaError, S["EncodingServices"]>;
|
|
1302
1394
|
/**
|
|
1303
1395
|
* Encodes a typed input (the schema's `Type`) against a schema, returning an
|
|
1304
1396
|
* `Effect` that succeeds with the encoded value or fails with a
|
|
@@ -1320,7 +1412,7 @@ export declare function encodeUnknownEffect<S extends Top>(schema: S, options?:
|
|
|
1320
1412
|
* @category encoding
|
|
1321
1413
|
* @since 4.0.0
|
|
1322
1414
|
*/
|
|
1323
|
-
export declare const encodeEffect: <S extends
|
|
1415
|
+
export declare const encodeEffect: <S extends Constraint>(schema: S, options?: SchemaAST.ParseOptions) => (input: S["Type"], options?: SchemaAST.ParseOptions) => Effect.Effect<S["Encoded"], SchemaError, S["EncodingServices"]>;
|
|
1324
1416
|
/**
|
|
1325
1417
|
* Encodes an `unknown` input against a schema synchronously, returning an
|
|
1326
1418
|
* `Exit` that is either a `Success` with the encoded value or a `Failure`.
|
|
@@ -1350,7 +1442,7 @@ export declare const encodeEffect: <S extends Top>(schema: S, options?: SchemaAS
|
|
|
1350
1442
|
* @category encoding
|
|
1351
1443
|
* @since 4.0.0
|
|
1352
1444
|
*/
|
|
1353
|
-
export declare function encodeUnknownExit<S extends
|
|
1445
|
+
export declare function encodeUnknownExit<S extends ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, options?: SchemaAST.ParseOptions) => Exit_.Exit<S["Encoded"], SchemaError>;
|
|
1354
1446
|
/**
|
|
1355
1447
|
* Encodes a typed input (the schema's `Type`) against a schema synchronously,
|
|
1356
1448
|
* returning an `Exit` that is either a `Success` with the encoded value or a
|
|
@@ -1381,7 +1473,7 @@ export declare function encodeUnknownExit<S extends Encoder<unknown>>(schema: S,
|
|
|
1381
1473
|
* @category encoding
|
|
1382
1474
|
* @since 4.0.0
|
|
1383
1475
|
*/
|
|
1384
|
-
export declare const encodeExit: <S extends
|
|
1476
|
+
export declare const encodeExit: <S extends ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) => (input: S["Type"], options?: SchemaAST.ParseOptions) => Exit_.Exit<S["Encoded"], SchemaError>;
|
|
1385
1477
|
/**
|
|
1386
1478
|
* Encodes an `unknown` input against a schema, returning an `Option` that is
|
|
1387
1479
|
* `Some` with the encoded value on success or `None` for schema mismatches.
|
|
@@ -1408,7 +1500,7 @@ export declare const encodeExit: <S extends Encoder<unknown>>(schema: S, options
|
|
|
1408
1500
|
* @category encoding
|
|
1409
1501
|
* @since 3.10.0
|
|
1410
1502
|
*/
|
|
1411
|
-
export declare const encodeUnknownOption: <S extends
|
|
1503
|
+
export declare const encodeUnknownOption: <S extends ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) => (input: unknown, options?: SchemaAST.ParseOptions) => Option_.Option<S["Encoded"]>;
|
|
1412
1504
|
/**
|
|
1413
1505
|
* Encodes a typed input (the schema's `Type`) against a schema, returning an
|
|
1414
1506
|
* `Option` that is `Some` with the encoded value on success or `None` for schema
|
|
@@ -1434,7 +1526,7 @@ export declare const encodeUnknownOption: <S extends Encoder<unknown>>(schema: S
|
|
|
1434
1526
|
* @category encoding
|
|
1435
1527
|
* @since 3.10.0
|
|
1436
1528
|
*/
|
|
1437
|
-
export declare const encodeOption: <S extends
|
|
1529
|
+
export declare const encodeOption: <S extends ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) => (input: S["Type"], options?: SchemaAST.ParseOptions) => Option_.Option<S["Encoded"]>;
|
|
1438
1530
|
/**
|
|
1439
1531
|
* Encodes an `unknown` input against a schema, returning a `Result` that
|
|
1440
1532
|
* succeeds with the encoded value or fails with a {@link SchemaError} for schema
|
|
@@ -1463,7 +1555,7 @@ export declare const encodeOption: <S extends Encoder<unknown>>(schema: S, optio
|
|
|
1463
1555
|
* @category encoding
|
|
1464
1556
|
* @since 4.0.0
|
|
1465
1557
|
*/
|
|
1466
|
-
export declare function encodeUnknownResult<S extends
|
|
1558
|
+
export declare function encodeUnknownResult<S extends ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, options?: SchemaAST.ParseOptions) => Result_.Result<S["Encoded"], SchemaError>;
|
|
1467
1559
|
/**
|
|
1468
1560
|
* Encodes a typed input (the schema's `Type`) against a schema, returning a
|
|
1469
1561
|
* `Result` that succeeds with the encoded value or fails with a
|
|
@@ -1492,7 +1584,7 @@ export declare function encodeUnknownResult<S extends Encoder<unknown>>(schema:
|
|
|
1492
1584
|
* @category encoding
|
|
1493
1585
|
* @since 4.0.0
|
|
1494
1586
|
*/
|
|
1495
|
-
export declare const encodeResult: <S extends
|
|
1587
|
+
export declare const encodeResult: <S extends ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) => (input: S["Type"], options?: SchemaAST.ParseOptions) => Result_.Result<S["Encoded"], SchemaError>;
|
|
1496
1588
|
/**
|
|
1497
1589
|
* Encodes an `unknown` input against a schema, returning a `Promise` that
|
|
1498
1590
|
* resolves with the encoded value or rejects with a {@link SchemaError} for
|
|
@@ -1519,7 +1611,7 @@ export declare const encodeResult: <S extends Encoder<unknown>>(schema: S, optio
|
|
|
1519
1611
|
* @category encoding
|
|
1520
1612
|
* @since 3.10.0
|
|
1521
1613
|
*/
|
|
1522
|
-
export declare function encodeUnknownPromise<S extends
|
|
1614
|
+
export declare function encodeUnknownPromise<S extends ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, options?: SchemaAST.ParseOptions) => Promise<S["Encoded"]>;
|
|
1523
1615
|
/**
|
|
1524
1616
|
* Encodes a typed input (the schema's `Type`) against a schema, returning a
|
|
1525
1617
|
* `Promise` that resolves with the encoded value or rejects with a
|
|
@@ -1547,7 +1639,7 @@ export declare function encodeUnknownPromise<S extends Encoder<unknown>>(schema:
|
|
|
1547
1639
|
* @category encoding
|
|
1548
1640
|
* @since 3.10.0
|
|
1549
1641
|
*/
|
|
1550
|
-
export declare const encodePromise: <S extends
|
|
1642
|
+
export declare const encodePromise: <S extends ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) => (input: S["Type"], options?: SchemaAST.ParseOptions) => Promise<S["Encoded"]>;
|
|
1551
1643
|
/**
|
|
1552
1644
|
* Encodes an `unknown` input against a schema synchronously, throwing a
|
|
1553
1645
|
* {@link SchemaError} for schema mismatches.
|
|
@@ -1574,7 +1666,7 @@ export declare const encodePromise: <S extends Encoder<unknown>>(schema: S, opti
|
|
|
1574
1666
|
* @category encoding
|
|
1575
1667
|
* @since 4.0.0
|
|
1576
1668
|
*/
|
|
1577
|
-
export declare function encodeUnknownSync<S extends
|
|
1669
|
+
export declare function encodeUnknownSync<S extends ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: unknown, options?: SchemaAST.ParseOptions) => S["Encoded"];
|
|
1578
1670
|
/**
|
|
1579
1671
|
* Encodes a typed input (the schema's `Type`) against a schema synchronously,
|
|
1580
1672
|
* throwing a {@link SchemaError} for schema mismatches.
|
|
@@ -1599,7 +1691,7 @@ export declare function encodeUnknownSync<S extends Encoder<unknown>>(schema: S,
|
|
|
1599
1691
|
* @category encoding
|
|
1600
1692
|
* @since 4.0.0
|
|
1601
1693
|
*/
|
|
1602
|
-
export declare const encodeSync: <S extends
|
|
1694
|
+
export declare const encodeSync: <S extends ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) => (input: S["Type"], options?: SchemaAST.ParseOptions) => S["Encoded"];
|
|
1603
1695
|
/**
|
|
1604
1696
|
* Creates a schema from an AST (Abstract Syntax Tree) node.
|
|
1605
1697
|
*
|
|
@@ -1617,7 +1709,7 @@ export declare const encodeSync: <S extends Encoder<unknown>>(schema: S, options
|
|
|
1617
1709
|
* @category constructors
|
|
1618
1710
|
* @since 3.10.0
|
|
1619
1711
|
*/
|
|
1620
|
-
export declare const make: <S extends
|
|
1712
|
+
export declare const make: <S extends Constraint>(ast: S["ast"], options?: object) => S;
|
|
1621
1713
|
/**
|
|
1622
1714
|
* Transforms a schema into a class that can be extended with `extends`. The
|
|
1623
1715
|
* resulting class inherits the full schema API (e.g. `annotate`) and can define
|
|
@@ -1655,12 +1747,19 @@ export declare function isSchema(u: unknown): u is Top;
|
|
|
1655
1747
|
* @category models
|
|
1656
1748
|
* @since 4.0.0
|
|
1657
1749
|
*/
|
|
1658
|
-
export interface optionalKey<S extends
|
|
1750
|
+
export interface optionalKey<S extends Constraint> extends BottomLazy<S["ast"], optionalKey<S>, S["~type.parameters"], S["~type.mutability"], "optional", S["~type.constructor.default"], S["~encoded.mutability"], "optional"> {
|
|
1751
|
+
readonly "Type": S["Type"];
|
|
1752
|
+
readonly "Encoded": S["Encoded"];
|
|
1753
|
+
readonly "DecodingServices": S["DecodingServices"];
|
|
1754
|
+
readonly "EncodingServices": S["EncodingServices"];
|
|
1755
|
+
readonly "~type.make.in": S["~type.make.in"];
|
|
1756
|
+
readonly "~type.make": S["~type.make"];
|
|
1757
|
+
readonly "Iso": S["Iso"];
|
|
1659
1758
|
readonly schema: S;
|
|
1660
1759
|
}
|
|
1661
1760
|
interface optionalKeyLambda extends Lambda {
|
|
1662
|
-
<S extends
|
|
1663
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
1761
|
+
<S extends Constraint>(self: S): optionalKey<S>;
|
|
1762
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint ? optionalKey<this["~lambda.in"]> : never;
|
|
1664
1763
|
}
|
|
1665
1764
|
/**
|
|
1666
1765
|
* Creates an exact optional key schema for struct fields. Unlike `optional`,
|
|
@@ -1686,8 +1785,8 @@ interface optionalKeyLambda extends Lambda {
|
|
|
1686
1785
|
*/
|
|
1687
1786
|
export declare const optionalKey: optionalKeyLambda;
|
|
1688
1787
|
interface requiredKeyLambda extends Lambda {
|
|
1689
|
-
<S extends
|
|
1690
|
-
readonly "~lambda.out": this["~lambda.in"] extends optionalKey<
|
|
1788
|
+
<S extends Constraint>(self: optionalKey<S>): S;
|
|
1789
|
+
readonly "~lambda.out": this["~lambda.in"] extends optionalKey<Constraint> ? this["~lambda.in"]["schema"] : "Error: schema not eligible for requiredKey";
|
|
1691
1790
|
}
|
|
1692
1791
|
/**
|
|
1693
1792
|
* Reverses `optionalKey` and returns the inner required schema.
|
|
@@ -1707,12 +1806,12 @@ export declare const requiredKey: requiredKeyLambda;
|
|
|
1707
1806
|
* @category models
|
|
1708
1807
|
* @since 3.10.0
|
|
1709
1808
|
*/
|
|
1710
|
-
export interface optional<S extends
|
|
1809
|
+
export interface optional<S extends Constraint> extends optionalKey<UndefinedOr<S>> {
|
|
1711
1810
|
readonly "Rebuild": optional<S>;
|
|
1712
1811
|
}
|
|
1713
1812
|
interface optionalLambda extends Lambda {
|
|
1714
|
-
<S extends
|
|
1715
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
1813
|
+
<S extends Constraint>(self: S): optional<S>;
|
|
1814
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint ? optional<this["~lambda.in"]> : never;
|
|
1716
1815
|
}
|
|
1717
1816
|
/**
|
|
1718
1817
|
* Marks a struct field as optional, allowing the key to be absent or
|
|
@@ -1745,8 +1844,8 @@ interface optionalLambda extends Lambda {
|
|
|
1745
1844
|
*/
|
|
1746
1845
|
export declare const optional: optionalLambda;
|
|
1747
1846
|
interface requiredLambda extends Lambda {
|
|
1748
|
-
<S extends
|
|
1749
|
-
readonly "~lambda.out": this["~lambda.in"] extends optional<
|
|
1847
|
+
<S extends Constraint>(self: optional<S>): S;
|
|
1848
|
+
readonly "~lambda.out": this["~lambda.in"] extends optional<Constraint> ? this["~lambda.in"]["schema"]["members"][0] : "Error: schema not eligible for required";
|
|
1750
1849
|
}
|
|
1751
1850
|
/**
|
|
1752
1851
|
* Reverses `optional` and returns the inner schema.
|
|
@@ -1770,12 +1869,19 @@ export declare const required: requiredLambda;
|
|
|
1770
1869
|
* @category models
|
|
1771
1870
|
* @since 4.0.0
|
|
1772
1871
|
*/
|
|
1773
|
-
export interface mutableKey<S extends
|
|
1872
|
+
export interface mutableKey<S extends Constraint> extends BottomLazy<S["ast"], mutableKey<S>, S["~type.parameters"], "mutable", S["~type.optionality"], S["~type.constructor.default"], "mutable", S["~encoded.optionality"]> {
|
|
1873
|
+
readonly "Type": S["Type"];
|
|
1874
|
+
readonly "Encoded": S["Encoded"];
|
|
1875
|
+
readonly "DecodingServices": S["DecodingServices"];
|
|
1876
|
+
readonly "EncodingServices": S["EncodingServices"];
|
|
1877
|
+
readonly "~type.make.in": S["~type.make.in"];
|
|
1878
|
+
readonly "~type.make": S["~type.make"];
|
|
1879
|
+
readonly "Iso": S["Iso"];
|
|
1774
1880
|
readonly schema: S;
|
|
1775
1881
|
}
|
|
1776
1882
|
interface mutableKeyLambda extends Lambda {
|
|
1777
|
-
<S extends
|
|
1778
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
1883
|
+
<S extends Constraint>(self: S): mutableKey<S>;
|
|
1884
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint ? mutableKey<this["~lambda.in"]> : never;
|
|
1779
1885
|
}
|
|
1780
1886
|
/**
|
|
1781
1887
|
* Makes a struct field mutable (removes the `readonly` modifier on the property).
|
|
@@ -1786,8 +1892,8 @@ interface mutableKeyLambda extends Lambda {
|
|
|
1786
1892
|
*/
|
|
1787
1893
|
export declare const mutableKey: mutableKeyLambda;
|
|
1788
1894
|
interface readonlyKeyLambda extends Lambda {
|
|
1789
|
-
<S extends
|
|
1790
|
-
readonly "~lambda.out": this["~lambda.in"] extends mutableKey<
|
|
1895
|
+
<S extends Constraint>(self: mutableKey<S>): S;
|
|
1896
|
+
readonly "~lambda.out": this["~lambda.in"] extends mutableKey<Constraint> ? this["~lambda.in"]["schema"] : "Error: schema not eligible for readonlyKey";
|
|
1791
1897
|
}
|
|
1792
1898
|
/**
|
|
1793
1899
|
* Reverses `mutableKey` and returns the inner readonly schema.
|
|
@@ -1807,11 +1913,18 @@ export declare const readonlyKey: readonlyKeyLambda;
|
|
|
1807
1913
|
* @category transforming
|
|
1808
1914
|
* @since 4.0.0
|
|
1809
1915
|
*/
|
|
1810
|
-
export interface toType<S extends
|
|
1916
|
+
export interface toType<S extends Constraint> extends BottomLazy<S["ast"], toType<S>, S["~type.parameters"], S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
1917
|
+
readonly "Type": S["Type"];
|
|
1918
|
+
readonly "Encoded": S["Type"];
|
|
1919
|
+
readonly "DecodingServices": never;
|
|
1920
|
+
readonly "EncodingServices": never;
|
|
1921
|
+
readonly "~type.make.in": S["~type.make.in"];
|
|
1922
|
+
readonly "~type.make": S["~type.make"];
|
|
1923
|
+
readonly "Iso": S["Iso"];
|
|
1811
1924
|
}
|
|
1812
1925
|
interface toTypeLambda extends Lambda {
|
|
1813
|
-
<S extends
|
|
1814
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
1926
|
+
<S extends Constraint>(self: S): toType<S>;
|
|
1927
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint ? toType<this["~lambda.in"]> : never;
|
|
1815
1928
|
}
|
|
1816
1929
|
/**
|
|
1817
1930
|
* Extracts the type-side schema: sets `Encoded` to equal the decoded `Type`,
|
|
@@ -1827,11 +1940,18 @@ export declare const toType: toTypeLambda;
|
|
|
1827
1940
|
* @category transforming
|
|
1828
1941
|
* @since 4.0.0
|
|
1829
1942
|
*/
|
|
1830
|
-
export interface toEncoded<S extends
|
|
1943
|
+
export interface toEncoded<S extends Constraint> extends BottomLazy<SchemaAST.AST, toEncoded<S>, ReadonlyArray<Constraint>, S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
1944
|
+
readonly "Type": S["Encoded"];
|
|
1945
|
+
readonly "Encoded": S["Encoded"];
|
|
1946
|
+
readonly "DecodingServices": never;
|
|
1947
|
+
readonly "EncodingServices": never;
|
|
1948
|
+
readonly "~type.make.in": S["Encoded"];
|
|
1949
|
+
readonly "~type.make": S["Encoded"];
|
|
1950
|
+
readonly "Iso": S["Encoded"];
|
|
1831
1951
|
}
|
|
1832
1952
|
interface toEncodedLambda extends Lambda {
|
|
1833
|
-
<S extends
|
|
1834
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
1953
|
+
<S extends Constraint>(self: S): toEncoded<S>;
|
|
1954
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint ? toEncoded<this["~lambda.in"]> : never;
|
|
1835
1955
|
}
|
|
1836
1956
|
/**
|
|
1837
1957
|
* Extracts the encoded-side schema: sets `Type` to equal the `Encoded`,
|
|
@@ -1848,7 +1968,14 @@ declare const FlipTypeId = "~effect/Schema/flip";
|
|
|
1848
1968
|
* @category transforming
|
|
1849
1969
|
* @since 4.0.0
|
|
1850
1970
|
*/
|
|
1851
|
-
export interface flip<S extends Top> extends
|
|
1971
|
+
export interface flip<S extends Top> extends BottomLazy<SchemaAST.AST, flip<S>, ReadonlyArray<Constraint>, S["~encoded.mutability"], S["~encoded.optionality"], ConstructorDefault, S["~type.mutability"], S["~type.optionality"]> {
|
|
1972
|
+
readonly "Type": S["Encoded"];
|
|
1973
|
+
readonly "Encoded": S["Type"];
|
|
1974
|
+
readonly "DecodingServices": S["EncodingServices"];
|
|
1975
|
+
readonly "EncodingServices": S["DecodingServices"];
|
|
1976
|
+
readonly "~type.make.in": S["Encoded"];
|
|
1977
|
+
readonly "~type.make": S["Encoded"];
|
|
1978
|
+
readonly "Iso": S["Encoded"];
|
|
1852
1979
|
readonly [FlipTypeId]: typeof FlipTypeId;
|
|
1853
1980
|
readonly schema: S;
|
|
1854
1981
|
}
|
|
@@ -1923,7 +2050,7 @@ export declare namespace TemplateLiteral {
|
|
|
1923
2050
|
* @category utility types
|
|
1924
2051
|
* @since 4.0.0
|
|
1925
2052
|
*/
|
|
1926
|
-
interface SchemaPart extends
|
|
2053
|
+
interface SchemaPart extends Constraint {
|
|
1927
2054
|
readonly Encoded: string | number | bigint;
|
|
1928
2055
|
}
|
|
1929
2056
|
/**
|
|
@@ -1948,7 +2075,9 @@ export declare namespace TemplateLiteral {
|
|
|
1948
2075
|
* @since 4.0.0
|
|
1949
2076
|
*/
|
|
1950
2077
|
type Parts = ReadonlyArray<Part>;
|
|
1951
|
-
type AppendType<Template extends string, Next> = Next extends LiteralPart ? `${Template}${Next}` : Next extends
|
|
2078
|
+
type AppendType<Template extends string, Next> = Next extends LiteralPart ? `${Template}${Next}` : Next extends {
|
|
2079
|
+
readonly Encoded: infer E extends LiteralPart;
|
|
2080
|
+
} ? `${Template}${E}` : never;
|
|
1952
2081
|
/**
|
|
1953
2082
|
* Computes the encoded string literal type produced by concatenating the encoded
|
|
1954
2083
|
* forms of all template literal parts.
|
|
@@ -2024,7 +2153,14 @@ export declare namespace TemplateLiteralParser {
|
|
|
2024
2153
|
* @category models
|
|
2025
2154
|
* @since 3.10.0
|
|
2026
2155
|
*/
|
|
2027
|
-
export interface TemplateLiteralParser<Parts extends TemplateLiteral.Parts> extends
|
|
2156
|
+
export interface TemplateLiteralParser<Parts extends TemplateLiteral.Parts> extends BottomLazy<SchemaAST.Arrays, TemplateLiteralParser<Parts>> {
|
|
2157
|
+
readonly "Type": TemplateLiteralParser.Type<Parts>;
|
|
2158
|
+
readonly "Encoded": TemplateLiteral.Encoded<Parts>;
|
|
2159
|
+
readonly "DecodingServices": never;
|
|
2160
|
+
readonly "EncodingServices": never;
|
|
2161
|
+
readonly "~type.make.in": TemplateLiteralParser.Type<Parts>;
|
|
2162
|
+
readonly "~type.make": TemplateLiteralParser.Type<Parts>;
|
|
2163
|
+
readonly "Iso": TemplateLiteralParser.Type<Parts>;
|
|
2028
2164
|
readonly parts: Parts;
|
|
2029
2165
|
}
|
|
2030
2166
|
/**
|
|
@@ -2351,7 +2487,7 @@ export declare namespace Struct {
|
|
|
2351
2487
|
* @since 3.10.0
|
|
2352
2488
|
*/
|
|
2353
2489
|
type Fields = {
|
|
2354
|
-
readonly [x: PropertyKey]:
|
|
2490
|
+
readonly [x: PropertyKey]: Constraint;
|
|
2355
2491
|
};
|
|
2356
2492
|
type TypeOptionalKeys<Fields extends Struct.Fields> = {
|
|
2357
2493
|
[K in keyof Fields]: Fields[K] extends {
|
|
@@ -2363,15 +2499,28 @@ export declare namespace Struct {
|
|
|
2363
2499
|
readonly "~type.mutability": "mutable";
|
|
2364
2500
|
} ? K : never;
|
|
2365
2501
|
}[keyof Fields];
|
|
2366
|
-
type
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2502
|
+
type SetOptional<A, K extends keyof A> = Omit<A, K> & Partial<Pick<A, K>>;
|
|
2503
|
+
type Mutable<A> = {
|
|
2504
|
+
-readonly [K in keyof A]: A[K];
|
|
2505
|
+
};
|
|
2506
|
+
type SetMutable<A, K extends keyof A> = Omit<A, K> & Mutable<Pick<A, K>>;
|
|
2507
|
+
type Side = "Type" | "Iso" | "Encoded";
|
|
2508
|
+
type EncodedOptionalKeys<Fields extends Struct.Fields> = {
|
|
2509
|
+
[K in keyof Fields]: Fields[K] extends {
|
|
2510
|
+
readonly "~encoded.optionality": "optional";
|
|
2511
|
+
} ? K : never;
|
|
2512
|
+
}[keyof Fields];
|
|
2513
|
+
type EncodedMutableKeys<Fields extends Struct.Fields> = {
|
|
2514
|
+
[K in keyof Fields]: Fields[K] extends {
|
|
2515
|
+
readonly "~encoded.mutability": "mutable";
|
|
2516
|
+
} ? K : never;
|
|
2517
|
+
}[keyof Fields];
|
|
2518
|
+
type SideOptionalKeys<F extends Fields, S extends Side> = S extends "Encoded" ? EncodedOptionalKeys<F> : TypeOptionalKeys<F>;
|
|
2519
|
+
type SideMutableKeys<F extends Fields, S extends Side> = S extends "Encoded" ? EncodedMutableKeys<F> : TypeMutableKeys<F>;
|
|
2520
|
+
type ReadonlySide<F extends Fields, S extends Side> = {
|
|
2521
|
+
readonly [K in keyof F]: F[K][S];
|
|
2374
2522
|
};
|
|
2523
|
+
type View<F extends Fields, S extends Side, O extends keyof F = SideOptionalKeys<F, S>, M extends keyof F = SideMutableKeys<F, S>> = [O | M] extends [never] ? ReadonlySide<F, S> : [M] extends [never] ? Simplify<SetOptional<ReadonlySide<F, S>, O>> : [O] extends [never] ? Simplify<SetMutable<ReadonlySide<F, S>, M>> : Simplify<SetMutable<SetOptional<ReadonlySide<F, S>, O>, Extract<keyof SetOptional<ReadonlySide<F, S>, O>, M>>>;
|
|
2375
2524
|
/**
|
|
2376
2525
|
* Computes the decoded object type for a struct field map.
|
|
2377
2526
|
*
|
|
@@ -2383,16 +2532,7 @@ export declare namespace Struct {
|
|
|
2383
2532
|
* @category utility types
|
|
2384
2533
|
* @since 3.10.0
|
|
2385
2534
|
*/
|
|
2386
|
-
type Type<F extends Fields> =
|
|
2387
|
-
type Iso_<F extends Fields, O extends keyof F = TypeOptionalKeys<F>, M extends keyof F = TypeMutableKeys<F>> = {
|
|
2388
|
-
readonly [K in keyof F as K extends M | O ? never : K]: F[K]["Iso"];
|
|
2389
|
-
} & {
|
|
2390
|
-
readonly [K in keyof F as K extends O ? K extends M ? never : K : never]?: F[K]["Iso"];
|
|
2391
|
-
} & {
|
|
2392
|
-
-readonly [K in keyof F as K extends M ? K extends O ? never : K : never]: F[K]["Iso"];
|
|
2393
|
-
} & {
|
|
2394
|
-
-readonly [K in keyof F as K extends M & O ? K : never]?: F[K]["Iso"];
|
|
2395
|
-
};
|
|
2535
|
+
type Type<F extends Fields> = View<F, "Type">;
|
|
2396
2536
|
/**
|
|
2397
2537
|
* Computes the iso object type for a struct field map from each field schema's
|
|
2398
2538
|
* `Iso` type.
|
|
@@ -2405,26 +2545,7 @@ export declare namespace Struct {
|
|
|
2405
2545
|
* @category utility types
|
|
2406
2546
|
* @since 4.0.0
|
|
2407
2547
|
*/
|
|
2408
|
-
type Iso<F extends Fields> =
|
|
2409
|
-
type EncodedOptionalKeys<Fields extends Struct.Fields> = {
|
|
2410
|
-
[K in keyof Fields]: Fields[K] extends {
|
|
2411
|
-
readonly "~encoded.optionality": "optional";
|
|
2412
|
-
} ? K : never;
|
|
2413
|
-
}[keyof Fields];
|
|
2414
|
-
type EncodedMutableKeys<Fields extends Struct.Fields> = {
|
|
2415
|
-
[K in keyof Fields]: Fields[K] extends {
|
|
2416
|
-
readonly "~encoded.mutability": "mutable";
|
|
2417
|
-
} ? K : never;
|
|
2418
|
-
}[keyof Fields];
|
|
2419
|
-
type Encoded_<F extends Fields, O extends keyof F = EncodedOptionalKeys<F>, M extends keyof F = EncodedMutableKeys<F>> = {
|
|
2420
|
-
readonly [K in keyof F as K extends M | O ? never : K]: F[K]["Encoded"];
|
|
2421
|
-
} & {
|
|
2422
|
-
readonly [K in keyof F as K extends O ? K extends M ? never : K : never]?: F[K]["Encoded"];
|
|
2423
|
-
} & {
|
|
2424
|
-
-readonly [K in keyof F as K extends M ? K extends O ? never : K : never]: F[K]["Encoded"];
|
|
2425
|
-
} & {
|
|
2426
|
-
-readonly [K in keyof F as K extends M & O ? K : never]?: F[K]["Encoded"];
|
|
2427
|
-
};
|
|
2548
|
+
type Iso<F extends Fields> = View<F, "Iso">;
|
|
2428
2549
|
/**
|
|
2429
2550
|
* Computes the encoded object type for a struct field map.
|
|
2430
2551
|
*
|
|
@@ -2437,7 +2558,7 @@ export declare namespace Struct {
|
|
|
2437
2558
|
* @category utility types
|
|
2438
2559
|
* @since 3.10.0
|
|
2439
2560
|
*/
|
|
2440
|
-
type Encoded<F extends Fields> =
|
|
2561
|
+
type Encoded<F extends Fields> = View<F, "Encoded">;
|
|
2441
2562
|
/**
|
|
2442
2563
|
* Union of all decoding service requirements needed by the schemas in a struct
|
|
2443
2564
|
* field map.
|
|
@@ -2463,11 +2584,10 @@ export declare namespace Struct {
|
|
|
2463
2584
|
readonly "~type.constructor.default": "with-default";
|
|
2464
2585
|
} ? K : never;
|
|
2465
2586
|
}[keyof Fields];
|
|
2466
|
-
type
|
|
2467
|
-
readonly [K in keyof F
|
|
2468
|
-
} & {
|
|
2469
|
-
readonly [K in keyof F as K extends O ? K : never]?: F[K]["~type.make"];
|
|
2587
|
+
type ReadonlyMakeIn<F extends Fields> = {
|
|
2588
|
+
readonly [K in keyof F]: F[K]["~type.make"];
|
|
2470
2589
|
};
|
|
2590
|
+
type MakeInView<F extends Fields, O extends keyof F = TypeOptionalKeys<F> | TypeConstructorDefaultedKeys<F>> = [O] extends [never] ? ReadonlyMakeIn<F> : Simplify<SetOptional<ReadonlyMakeIn<F>, O>>;
|
|
2471
2591
|
/**
|
|
2472
2592
|
* Computes the input object type accepted when constructing a struct value.
|
|
2473
2593
|
*
|
|
@@ -2479,7 +2599,7 @@ export declare namespace Struct {
|
|
|
2479
2599
|
* @category utility types
|
|
2480
2600
|
* @since 4.0.0
|
|
2481
2601
|
*/
|
|
2482
|
-
type MakeIn<F extends Fields> =
|
|
2602
|
+
type MakeIn<F extends Fields> = MakeInView<F>;
|
|
2483
2603
|
}
|
|
2484
2604
|
/**
|
|
2485
2605
|
* Type-level representation returned by {@link Struct}.
|
|
@@ -2487,7 +2607,14 @@ export declare namespace Struct {
|
|
|
2487
2607
|
* @category models
|
|
2488
2608
|
* @since 3.10.0
|
|
2489
2609
|
*/
|
|
2490
|
-
export interface Struct<Fields extends Struct.Fields> extends
|
|
2610
|
+
export interface Struct<Fields extends Struct.Fields> extends BottomLazy<SchemaAST.Objects, Struct<Fields>> {
|
|
2611
|
+
readonly "Type": Struct.Type<Fields>;
|
|
2612
|
+
readonly "Encoded": Struct.Encoded<Fields>;
|
|
2613
|
+
readonly "DecodingServices": Struct.DecodingServices<Fields>;
|
|
2614
|
+
readonly "EncodingServices": Struct.EncodingServices<Fields>;
|
|
2615
|
+
readonly "~type.make.in": Struct.MakeIn<Fields>;
|
|
2616
|
+
readonly "~type.make": Struct.MakeIn<Fields>;
|
|
2617
|
+
readonly "Iso": Struct.Iso<Fields>;
|
|
2491
2618
|
/**
|
|
2492
2619
|
* The field definitions of this struct. Spread them into a new struct to
|
|
2493
2620
|
* reuse fields across schemas.
|
|
@@ -2602,7 +2729,7 @@ export declare function fieldsAssign<const NewFields extends Struct.Fields>(fiel
|
|
|
2602
2729
|
* @category transforming
|
|
2603
2730
|
* @since 4.0.0
|
|
2604
2731
|
*/
|
|
2605
|
-
export interface encodeKeys<S extends
|
|
2732
|
+
export interface encodeKeys<S extends Constraint & {
|
|
2606
2733
|
readonly fields: Struct.Fields;
|
|
2607
2734
|
}, M extends {
|
|
2608
2735
|
readonly [K in keyof S["fields"]]?: PropertyKey;
|
|
@@ -2638,7 +2765,7 @@ export interface encodeKeys<S extends Top & {
|
|
|
2638
2765
|
* @category transforming
|
|
2639
2766
|
* @since 4.0.0
|
|
2640
2767
|
*/
|
|
2641
|
-
export declare function encodeKeys<S extends
|
|
2768
|
+
export declare function encodeKeys<S extends Constraint & {
|
|
2642
2769
|
readonly fields: Struct.Fields;
|
|
2643
2770
|
}, const M extends {
|
|
2644
2771
|
readonly [K in keyof S["fields"]]?: PropertyKey;
|
|
@@ -2721,7 +2848,7 @@ export declare namespace Record {
|
|
|
2721
2848
|
* @category utility types
|
|
2722
2849
|
* @since 3.10.0
|
|
2723
2850
|
*/
|
|
2724
|
-
type Type<Key extends Record.Key, Value extends
|
|
2851
|
+
type Type<Key extends Record.Key, Value extends Constraint> = Value extends {
|
|
2725
2852
|
readonly "~type.optionality": "optional";
|
|
2726
2853
|
} ? Value extends {
|
|
2727
2854
|
readonly "~type.mutability": "mutable";
|
|
@@ -2743,7 +2870,7 @@ export declare namespace Record {
|
|
|
2743
2870
|
* @category utility types
|
|
2744
2871
|
* @since 4.0.0
|
|
2745
2872
|
*/
|
|
2746
|
-
type Iso<Key extends Record.Key, Value extends
|
|
2873
|
+
type Iso<Key extends Record.Key, Value extends Constraint> = Value extends {
|
|
2747
2874
|
readonly "~type.optionality": "optional";
|
|
2748
2875
|
} ? Value extends {
|
|
2749
2876
|
readonly "~type.mutability": "mutable";
|
|
@@ -2770,7 +2897,7 @@ export declare namespace Record {
|
|
|
2770
2897
|
* @category utility types
|
|
2771
2898
|
* @since 3.10.0
|
|
2772
2899
|
*/
|
|
2773
|
-
type Encoded<Key extends Record.Key, Value extends
|
|
2900
|
+
type Encoded<Key extends Record.Key, Value extends Constraint> = Value extends {
|
|
2774
2901
|
readonly "~encoded.optionality": "optional";
|
|
2775
2902
|
} ? Value extends {
|
|
2776
2903
|
readonly "~encoded.mutability": "mutable";
|
|
@@ -2792,7 +2919,7 @@ export declare namespace Record {
|
|
|
2792
2919
|
* @category utility types
|
|
2793
2920
|
* @since 4.0.0
|
|
2794
2921
|
*/
|
|
2795
|
-
type DecodingServices<Key extends Record.Key, Value extends
|
|
2922
|
+
type DecodingServices<Key extends Record.Key, Value extends Constraint> = Key["DecodingServices"] | Value["DecodingServices"];
|
|
2796
2923
|
/**
|
|
2797
2924
|
* Union of the encoding service requirements of a record's key schema and value
|
|
2798
2925
|
* schema.
|
|
@@ -2800,7 +2927,7 @@ export declare namespace Record {
|
|
|
2800
2927
|
* @category utility types
|
|
2801
2928
|
* @since 4.0.0
|
|
2802
2929
|
*/
|
|
2803
|
-
type EncodingServices<Key extends Record.Key, Value extends
|
|
2930
|
+
type EncodingServices<Key extends Record.Key, Value extends Constraint> = Key["EncodingServices"] | Value["EncodingServices"];
|
|
2804
2931
|
/**
|
|
2805
2932
|
* Computes the input object type accepted when constructing a record value.
|
|
2806
2933
|
*
|
|
@@ -2813,7 +2940,7 @@ export declare namespace Record {
|
|
|
2813
2940
|
* @category utility types
|
|
2814
2941
|
* @since 4.0.0
|
|
2815
2942
|
*/
|
|
2816
|
-
type MakeIn<Key extends Record.Key, Value extends
|
|
2943
|
+
type MakeIn<Key extends Record.Key, Value extends Constraint> = Value extends {
|
|
2817
2944
|
readonly "~encoded.optionality": "optional";
|
|
2818
2945
|
} ? Value extends {
|
|
2819
2946
|
readonly "~encoded.mutability": "mutable";
|
|
@@ -2835,7 +2962,14 @@ export declare namespace Record {
|
|
|
2835
2962
|
* @category models
|
|
2836
2963
|
* @since 4.0.0
|
|
2837
2964
|
*/
|
|
2838
|
-
export interface $Record<Key extends Record.Key, Value extends
|
|
2965
|
+
export interface $Record<Key extends Record.Key, Value extends Constraint> extends BottomLazy<SchemaAST.Objects, $Record<Key, Value>> {
|
|
2966
|
+
readonly "Type": Record.Type<Key, Value>;
|
|
2967
|
+
readonly "Encoded": Record.Encoded<Key, Value>;
|
|
2968
|
+
readonly "DecodingServices": Record.DecodingServices<Key, Value>;
|
|
2969
|
+
readonly "EncodingServices": Record.EncodingServices<Key, Value>;
|
|
2970
|
+
readonly "~type.make.in": Simplify<Record.MakeIn<Key, Value>>;
|
|
2971
|
+
readonly "~type.make": Simplify<Record.MakeIn<Key, Value>>;
|
|
2972
|
+
readonly "Iso": Record.Iso<Key, Value>;
|
|
2839
2973
|
readonly key: Key;
|
|
2840
2974
|
readonly value: Value;
|
|
2841
2975
|
}
|
|
@@ -2871,7 +3005,7 @@ export interface $Record<Key extends Record.Key, Value extends Top> extends Bott
|
|
|
2871
3005
|
* @category constructors
|
|
2872
3006
|
* @since 3.10.0
|
|
2873
3007
|
*/
|
|
2874
|
-
export declare function Record<Key extends Record.Key, Value extends
|
|
3008
|
+
export declare function Record<Key extends Record.Key, Value extends Constraint>(key: Key, value: Value, options?: {
|
|
2875
3009
|
readonly keyValueCombiner: {
|
|
2876
3010
|
readonly decode?: Combiner.Combiner<readonly [Key["Type"], Value["Type"]]> | undefined;
|
|
2877
3011
|
readonly encode?: Combiner.Combiner<readonly [Key["Encoded"], Value["Encoded"]]> | undefined;
|
|
@@ -2895,7 +3029,7 @@ export declare namespace StructWithRest {
|
|
|
2895
3029
|
* @category utility types
|
|
2896
3030
|
* @since 4.0.0
|
|
2897
3031
|
*/
|
|
2898
|
-
type Objects =
|
|
3032
|
+
type Objects = Constraint & {
|
|
2899
3033
|
readonly ast: SchemaAST.Objects;
|
|
2900
3034
|
};
|
|
2901
3035
|
/**
|
|
@@ -2905,7 +3039,7 @@ export declare namespace StructWithRest {
|
|
|
2905
3039
|
* @category utility types
|
|
2906
3040
|
* @since 3.10.0
|
|
2907
3041
|
*/
|
|
2908
|
-
type Records = ReadonlyArray<$Record<Record.Key,
|
|
3042
|
+
type Records = ReadonlyArray<$Record<Record.Key, Constraint>>;
|
|
2909
3043
|
type MergeTuple<T extends ReadonlyArray<unknown>> = T extends readonly [infer Head, ...infer Tail] ? Head & MergeTuple<Tail> : {};
|
|
2910
3044
|
type Intersect<S extends Objects, Records extends StructWithRest.Records, Side extends "Type" | "Iso" | "Encoded" | "~type.make"> = S[Side] & MergeTuple<{
|
|
2911
3045
|
readonly [K in keyof Records]: Records[K][Side];
|
|
@@ -2968,16 +3102,43 @@ export declare namespace StructWithRest {
|
|
|
2968
3102
|
type IncompatibleSideKeys<S extends Objects, Records extends StructWithRest.Records, Side extends "Type" | "Encoded" | "Iso" | "~type.make"> = {
|
|
2969
3103
|
[I in keyof Records]: Records[I][Side] extends object ? IncompatibleKeys<S[Side], Records[I][Side]> : never;
|
|
2970
3104
|
}[number];
|
|
3105
|
+
type IncompatibleRecords<S extends Objects, Records extends StructWithRest.Records> = IncompatibleSideKeys<S, Records, "Type"> | IncompatibleSideKeys<S, Records, "Encoded"> | IncompatibleSideKeys<S, Records, "Iso"> | IncompatibleSideKeys<S, Records, "~type.make">;
|
|
2971
3106
|
/**
|
|
2972
|
-
*
|
|
3107
|
+
* Checks whether fixed fields are compatible with the rest record schemas.
|
|
3108
|
+
*
|
|
3109
|
+
* **Details**
|
|
3110
|
+
*
|
|
3111
|
+
* Returns `true` when all fixed fields can also satisfy the matching rest
|
|
3112
|
+
* index signatures. Returns a diagnostic object when TypeScript would make
|
|
3113
|
+
* the resulting intersection too narrow for one or more fixed keys.
|
|
3114
|
+
*
|
|
3115
|
+
* **Example** (Checking record compatibility)
|
|
3116
|
+
*
|
|
3117
|
+
* ```ts
|
|
3118
|
+
* import { Schema } from "effect"
|
|
3119
|
+
*
|
|
3120
|
+
* const user = Schema.Struct({ id: Schema.String })
|
|
3121
|
+
* const stringExtras = [Schema.Record(Schema.String, Schema.String)] as const
|
|
3122
|
+
*
|
|
3123
|
+
* type UserCheck = Schema.StructWithRest.ValidateRecords<typeof user, typeof stringExtras>
|
|
3124
|
+
*
|
|
3125
|
+
* const userCheck: UserCheck = true
|
|
3126
|
+
* void userCheck
|
|
3127
|
+
*
|
|
3128
|
+
* const counter = Schema.Struct({ count: Schema.NumberFromString })
|
|
3129
|
+
*
|
|
3130
|
+
* type CounterCheck = Schema.StructWithRest.ValidateRecords<typeof counter, typeof stringExtras>
|
|
3131
|
+
* // ^? { "incompatible index signatures": "count" }
|
|
3132
|
+
*
|
|
3133
|
+
* const counterCheck = null as unknown as CounterCheck
|
|
3134
|
+
* void counterCheck
|
|
3135
|
+
* ```
|
|
2973
3136
|
*
|
|
2974
3137
|
* @category utility types
|
|
2975
3138
|
* @since 4.0.0
|
|
2976
3139
|
*/
|
|
2977
|
-
type ValidateRecords<S extends Objects, Records extends StructWithRest.Records> = [
|
|
2978
|
-
|
|
2979
|
-
] extends [never] ? unknown : {
|
|
2980
|
-
"incompatible index signatures": IncompatibleSideKeys<S, Records, "Type"> | IncompatibleSideKeys<S, Records, "Encoded"> | IncompatibleSideKeys<S, Records, "Iso"> | IncompatibleSideKeys<S, Records, "~type.make">;
|
|
3140
|
+
type ValidateRecords<S extends Objects, Records extends StructWithRest.Records> = [IncompatibleRecords<S, Records>] extends [never] ? true : {
|
|
3141
|
+
"incompatible index signatures": IncompatibleRecords<S, Records>;
|
|
2981
3142
|
};
|
|
2982
3143
|
}
|
|
2983
3144
|
/**
|
|
@@ -2986,7 +3147,14 @@ export declare namespace StructWithRest {
|
|
|
2986
3147
|
* @category models
|
|
2987
3148
|
* @since 4.0.0
|
|
2988
3149
|
*/
|
|
2989
|
-
export interface StructWithRest<S extends StructWithRest.Objects, Records extends StructWithRest.Records> extends
|
|
3150
|
+
export interface StructWithRest<S extends StructWithRest.Objects, Records extends StructWithRest.Records> extends BottomLazy<SchemaAST.Objects, StructWithRest<S, Records>> {
|
|
3151
|
+
readonly "Type": Simplify<StructWithRest.Type<S, Records>>;
|
|
3152
|
+
readonly "Encoded": Simplify<StructWithRest.Encoded<S, Records>>;
|
|
3153
|
+
readonly "DecodingServices": StructWithRest.DecodingServices<S, Records>;
|
|
3154
|
+
readonly "EncodingServices": StructWithRest.EncodingServices<S, Records>;
|
|
3155
|
+
readonly "~type.make.in": Simplify<StructWithRest.MakeIn<S, Records>>;
|
|
3156
|
+
readonly "~type.make": Simplify<StructWithRest.MakeIn<S, Records>>;
|
|
3157
|
+
readonly "Iso": Simplify<StructWithRest.Iso<S, Records>>;
|
|
2990
3158
|
readonly schema: S;
|
|
2991
3159
|
readonly records: Records;
|
|
2992
3160
|
}
|
|
@@ -2994,6 +3162,13 @@ export interface StructWithRest<S extends StructWithRest.Objects, Records extend
|
|
|
2994
3162
|
* Extends a struct schema with one or more record (index-signature) schemas,
|
|
2995
3163
|
* producing a schema whose decoded type intersects the struct and all records.
|
|
2996
3164
|
*
|
|
3165
|
+
* **Gotchas**
|
|
3166
|
+
*
|
|
3167
|
+
* TypeScript index signatures also apply to fixed keys. `StructWithRest` does
|
|
3168
|
+
* not reject incompatible fixed fields at the call site; use
|
|
3169
|
+
* `StructWithRest.ValidateRecords` when you want an explicit type-level
|
|
3170
|
+
* compatibility check.
|
|
3171
|
+
*
|
|
2997
3172
|
* **Example** (Defining structs with string-indexed extra keys)
|
|
2998
3173
|
*
|
|
2999
3174
|
* ```ts
|
|
@@ -3011,7 +3186,7 @@ export interface StructWithRest<S extends StructWithRest.Objects, Records extend
|
|
|
3011
3186
|
* @category constructors
|
|
3012
3187
|
* @since 4.0.0
|
|
3013
3188
|
*/
|
|
3014
|
-
export declare function StructWithRest<const S extends StructWithRest.Objects, const Records extends StructWithRest.Records>(schema: S, records: Records
|
|
3189
|
+
export declare function StructWithRest<const S extends StructWithRest.Objects, const Records extends StructWithRest.Records>(schema: S, records: Records): StructWithRest<S, Records>;
|
|
3015
3190
|
/**
|
|
3016
3191
|
* Namespace for `Tuple` type utilities.
|
|
3017
3192
|
*
|
|
@@ -3032,7 +3207,7 @@ export declare namespace Tuple {
|
|
|
3032
3207
|
* @category utility types
|
|
3033
3208
|
* @since 3.10.0
|
|
3034
3209
|
*/
|
|
3035
|
-
type Elements = ReadonlyArray<
|
|
3210
|
+
type Elements = ReadonlyArray<Constraint>;
|
|
3036
3211
|
type Type_<Elements, Out extends ReadonlyArray<any> = readonly []> = Elements extends readonly [infer Head, ...infer Tail] ? Head extends {
|
|
3037
3212
|
readonly "Type": infer T;
|
|
3038
3213
|
} ? Head extends {
|
|
@@ -3122,7 +3297,14 @@ export declare namespace Tuple {
|
|
|
3122
3297
|
* @category models
|
|
3123
3298
|
* @since 3.10.0
|
|
3124
3299
|
*/
|
|
3125
|
-
export interface Tuple<Elements extends Tuple.Elements> extends
|
|
3300
|
+
export interface Tuple<Elements extends Tuple.Elements> extends BottomLazy<SchemaAST.Arrays, Tuple<Elements>> {
|
|
3301
|
+
readonly "Type": Tuple.Type<Elements>;
|
|
3302
|
+
readonly "Encoded": Tuple.Encoded<Elements>;
|
|
3303
|
+
readonly "DecodingServices": Tuple.DecodingServices<Elements>;
|
|
3304
|
+
readonly "EncodingServices": Tuple.EncodingServices<Elements>;
|
|
3305
|
+
readonly "~type.make.in": Tuple.MakeIn<Elements>;
|
|
3306
|
+
readonly "~type.make": Tuple.MakeIn<Elements>;
|
|
3307
|
+
readonly "Iso": Tuple.Iso<Elements>;
|
|
3126
3308
|
readonly elements: Elements;
|
|
3127
3309
|
/**
|
|
3128
3310
|
* Returns a new tuple with the elements modified by the provided function.
|
|
@@ -3162,7 +3344,7 @@ export interface Tuple<Elements extends Tuple.Elements> extends Bottom<Tuple.Typ
|
|
|
3162
3344
|
* @category constructors
|
|
3163
3345
|
* @since 3.10.0
|
|
3164
3346
|
*/
|
|
3165
|
-
export declare function Tuple<const Elements extends ReadonlyArray<
|
|
3347
|
+
export declare function Tuple<const Elements extends ReadonlyArray<Constraint>>(elements: Elements): Tuple<Elements>;
|
|
3166
3348
|
/**
|
|
3167
3349
|
* Namespace for `TupleWithRest` type utilities.
|
|
3168
3350
|
*
|
|
@@ -3183,7 +3365,7 @@ export declare namespace TupleWithRest {
|
|
|
3183
3365
|
* @category utility types
|
|
3184
3366
|
* @since 3.10.0
|
|
3185
3367
|
*/
|
|
3186
|
-
type TupleType =
|
|
3368
|
+
type TupleType = Constraint & {
|
|
3187
3369
|
readonly Type: ReadonlyArray<unknown>;
|
|
3188
3370
|
readonly Encoded: ReadonlyArray<unknown>;
|
|
3189
3371
|
readonly ast: SchemaAST.Arrays;
|
|
@@ -3201,7 +3383,7 @@ export declare namespace TupleWithRest {
|
|
|
3201
3383
|
* @category utility types
|
|
3202
3384
|
* @since 3.10.0
|
|
3203
3385
|
*/
|
|
3204
|
-
type Rest = readonly [
|
|
3386
|
+
type Rest = readonly [Constraint, ...Array<Constraint>];
|
|
3205
3387
|
/**
|
|
3206
3388
|
* Computes the decoded tuple type for a `TupleWithRest`.
|
|
3207
3389
|
*
|
|
@@ -3214,7 +3396,7 @@ export declare namespace TupleWithRest {
|
|
|
3214
3396
|
* @category utility types
|
|
3215
3397
|
* @since 3.10.0
|
|
3216
3398
|
*/
|
|
3217
|
-
type Type<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends readonly [infer Head extends
|
|
3399
|
+
type Type<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends readonly [infer Head extends Constraint, ...infer Tail extends ReadonlyArray<Constraint>] ? Readonly<[
|
|
3218
3400
|
...T,
|
|
3219
3401
|
...Array<Head["Type"]>,
|
|
3220
3402
|
...{
|
|
@@ -3233,7 +3415,7 @@ export declare namespace TupleWithRest {
|
|
|
3233
3415
|
* @category utility types
|
|
3234
3416
|
* @since 4.0.0
|
|
3235
3417
|
*/
|
|
3236
|
-
type Iso<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends readonly [infer Head extends
|
|
3418
|
+
type Iso<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends readonly [infer Head extends Constraint, ...infer Tail extends ReadonlyArray<Constraint>] ? Readonly<[
|
|
3237
3419
|
...T,
|
|
3238
3420
|
...Array<Head["Iso"]>,
|
|
3239
3421
|
...{
|
|
@@ -3252,7 +3434,7 @@ export declare namespace TupleWithRest {
|
|
|
3252
3434
|
* @category utility types
|
|
3253
3435
|
* @since 3.10.0
|
|
3254
3436
|
*/
|
|
3255
|
-
type Encoded<E extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends readonly [infer Head extends
|
|
3437
|
+
type Encoded<E extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends readonly [infer Head extends Constraint, ...infer Tail extends ReadonlyArray<Constraint>] ? readonly [
|
|
3256
3438
|
...E,
|
|
3257
3439
|
...Array<Head["Encoded"]>,
|
|
3258
3440
|
...{
|
|
@@ -3271,7 +3453,7 @@ export declare namespace TupleWithRest {
|
|
|
3271
3453
|
* @category utility types
|
|
3272
3454
|
* @since 4.0.0
|
|
3273
3455
|
*/
|
|
3274
|
-
type MakeIn<M extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends readonly [infer Head extends
|
|
3456
|
+
type MakeIn<M extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends readonly [infer Head extends Constraint, ...infer Tail extends ReadonlyArray<Constraint>] ? readonly [
|
|
3275
3457
|
...M,
|
|
3276
3458
|
...Array<Head["~type.make"]>,
|
|
3277
3459
|
...{
|
|
@@ -3285,7 +3467,14 @@ export declare namespace TupleWithRest {
|
|
|
3285
3467
|
* @category models
|
|
3286
3468
|
* @since 4.0.0
|
|
3287
3469
|
*/
|
|
3288
|
-
export interface TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest> extends
|
|
3470
|
+
export interface TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest> extends BottomLazy<SchemaAST.Arrays, TupleWithRest<S, Rest>> {
|
|
3471
|
+
readonly "Type": TupleWithRest.Type<S["Type"], Rest>;
|
|
3472
|
+
readonly "Encoded": TupleWithRest.Encoded<S["Encoded"], Rest>;
|
|
3473
|
+
readonly "DecodingServices": S["DecodingServices"] | Rest[number]["DecodingServices"];
|
|
3474
|
+
readonly "EncodingServices": S["EncodingServices"] | Rest[number]["EncodingServices"];
|
|
3475
|
+
readonly "~type.make.in": TupleWithRest.MakeIn<S["~type.make"], Rest>;
|
|
3476
|
+
readonly "~type.make": TupleWithRest.MakeIn<S["~type.make"], Rest>;
|
|
3477
|
+
readonly "Iso": TupleWithRest.Iso<S["Iso"], Rest>;
|
|
3289
3478
|
readonly schema: S;
|
|
3290
3479
|
readonly rest: Rest;
|
|
3291
3480
|
}
|
|
@@ -3326,12 +3515,19 @@ export declare function TupleWithRest<S extends Tuple<Tuple.Elements>, const Res
|
|
|
3326
3515
|
* @category models
|
|
3327
3516
|
* @since 4.0.0
|
|
3328
3517
|
*/
|
|
3329
|
-
export interface $Array<S extends
|
|
3518
|
+
export interface $Array<S extends Constraint> extends BottomLazy<SchemaAST.Arrays, $Array<S>> {
|
|
3519
|
+
readonly "Type": ReadonlyArray<S["Type"]>;
|
|
3520
|
+
readonly "Encoded": ReadonlyArray<S["Encoded"]>;
|
|
3521
|
+
readonly "DecodingServices": S["DecodingServices"];
|
|
3522
|
+
readonly "EncodingServices": S["EncodingServices"];
|
|
3523
|
+
readonly "~type.make.in": ReadonlyArray<S["~type.make"]>;
|
|
3524
|
+
readonly "~type.make": ReadonlyArray<S["~type.make"]>;
|
|
3525
|
+
readonly "Iso": ReadonlyArray<S["Iso"]>;
|
|
3330
3526
|
readonly value: S;
|
|
3331
3527
|
}
|
|
3332
3528
|
interface ArrayLambda extends Lambda {
|
|
3333
|
-
<S extends
|
|
3334
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
3529
|
+
<S extends Constraint>(self: S): $Array<S>;
|
|
3530
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint ? $Array<this["~lambda.in"]> : never;
|
|
3335
3531
|
}
|
|
3336
3532
|
/**
|
|
3337
3533
|
* @category constructors
|
|
@@ -3364,12 +3560,19 @@ ArraySchema as Array };
|
|
|
3364
3560
|
* @category models
|
|
3365
3561
|
* @since 3.10.0
|
|
3366
3562
|
*/
|
|
3367
|
-
export interface NonEmptyArray<S extends
|
|
3563
|
+
export interface NonEmptyArray<S extends Constraint> extends BottomLazy<SchemaAST.Arrays, NonEmptyArray<S>> {
|
|
3564
|
+
readonly "Type": readonly [S["Type"], ...Array<S["Type"]>];
|
|
3565
|
+
readonly "Encoded": readonly [S["Encoded"], ...Array<S["Encoded"]>];
|
|
3566
|
+
readonly "DecodingServices": S["DecodingServices"];
|
|
3567
|
+
readonly "EncodingServices": S["EncodingServices"];
|
|
3568
|
+
readonly "~type.make.in": readonly [S["~type.make"], ...Array<S["~type.make"]>];
|
|
3569
|
+
readonly "~type.make": readonly [S["~type.make"], ...Array<S["~type.make"]>];
|
|
3570
|
+
readonly "Iso": readonly [S["Iso"], ...Array<S["Iso"]>];
|
|
3368
3571
|
readonly value: S;
|
|
3369
3572
|
}
|
|
3370
3573
|
interface NonEmptyArrayLambda extends Lambda {
|
|
3371
|
-
<S extends
|
|
3372
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
3574
|
+
<S extends Constraint>(self: S): NonEmptyArray<S>;
|
|
3575
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint ? NonEmptyArray<this["~lambda.in"]> : never;
|
|
3373
3576
|
}
|
|
3374
3577
|
/**
|
|
3375
3578
|
* Defines a non-empty `ReadonlyArray` schema — at least one element required.
|
|
@@ -3396,7 +3599,7 @@ export declare const NonEmptyArray: NonEmptyArrayLambda;
|
|
|
3396
3599
|
* @category constructors
|
|
3397
3600
|
* @since 3.10.0
|
|
3398
3601
|
*/
|
|
3399
|
-
export interface ArrayEnsure<S extends
|
|
3602
|
+
export interface ArrayEnsure<S extends Constraint> extends decodeTo<$Array<toType<S>>, Union<readonly [S, $Array<S>]>> {
|
|
3400
3603
|
readonly "Rebuild": ArrayEnsure<S>;
|
|
3401
3604
|
}
|
|
3402
3605
|
/**
|
|
@@ -3425,14 +3628,14 @@ export interface ArrayEnsure<S extends Top> extends decodeTo<$Array<toType<S>>,
|
|
|
3425
3628
|
* @category constructors
|
|
3426
3629
|
* @since 3.10.0
|
|
3427
3630
|
*/
|
|
3428
|
-
export declare function ArrayEnsure<S extends
|
|
3631
|
+
export declare function ArrayEnsure<S extends Constraint>(schema: S): ArrayEnsure<S>;
|
|
3429
3632
|
/**
|
|
3430
3633
|
* Type-level representation returned by {@link UniqueArray}.
|
|
3431
3634
|
*
|
|
3432
3635
|
* @category models
|
|
3433
3636
|
* @since 4.0.0
|
|
3434
3637
|
*/
|
|
3435
|
-
export interface UniqueArray<S extends
|
|
3638
|
+
export interface UniqueArray<S extends Constraint> extends $Array<S> {
|
|
3436
3639
|
readonly "Rebuild": UniqueArray<S>;
|
|
3437
3640
|
}
|
|
3438
3641
|
/**
|
|
@@ -3446,23 +3649,30 @@ export interface UniqueArray<S extends Top> extends $Array<S> {
|
|
|
3446
3649
|
* @category constructors
|
|
3447
3650
|
* @since 4.0.0
|
|
3448
3651
|
*/
|
|
3449
|
-
export declare function UniqueArray<S extends
|
|
3652
|
+
export declare function UniqueArray<S extends Constraint>(item: S): UniqueArray<S>;
|
|
3450
3653
|
/**
|
|
3451
3654
|
* Type-level representation returned by {@link mutable}.
|
|
3452
3655
|
*
|
|
3453
3656
|
* @category transforming
|
|
3454
3657
|
* @since 3.10.0
|
|
3455
3658
|
*/
|
|
3456
|
-
export interface mutable<S extends
|
|
3659
|
+
export interface mutable<S extends Constraint & {
|
|
3457
3660
|
readonly "ast": SchemaAST.Arrays;
|
|
3458
|
-
}> extends
|
|
3661
|
+
}> extends BottomLazy<S["ast"], mutable<S>, S["~type.parameters"], S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
3662
|
+
readonly "Type": Mutable<S["Type"]>;
|
|
3663
|
+
readonly "Encoded": Mutable<S["Encoded"]>;
|
|
3664
|
+
readonly "DecodingServices": S["DecodingServices"];
|
|
3665
|
+
readonly "EncodingServices": S["EncodingServices"];
|
|
3666
|
+
readonly "~type.make.in": S["~type.make.in"];
|
|
3667
|
+
readonly "~type.make": S["~type.make"];
|
|
3668
|
+
readonly "Iso": S["Iso"];
|
|
3459
3669
|
readonly schema: S;
|
|
3460
3670
|
}
|
|
3461
3671
|
interface mutableLambda extends Lambda {
|
|
3462
|
-
<S extends
|
|
3672
|
+
<S extends Constraint & {
|
|
3463
3673
|
readonly "ast": SchemaAST.Arrays;
|
|
3464
3674
|
}>(self: S): mutable<S>;
|
|
3465
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
3675
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint & {
|
|
3466
3676
|
readonly "ast": SchemaAST.Arrays;
|
|
3467
3677
|
} ? mutable<this["~lambda.in"]> : "Error: schema not eligible for mutable";
|
|
3468
3678
|
}
|
|
@@ -3490,21 +3700,30 @@ export declare const mutable: mutableLambda;
|
|
|
3490
3700
|
* @category models
|
|
3491
3701
|
* @since 3.10.0
|
|
3492
3702
|
*/
|
|
3493
|
-
export interface Union<Members extends ReadonlyArray<
|
|
3494
|
-
[K in keyof Members]: Members[K]["Type"];
|
|
3495
|
-
}[number], {
|
|
3496
|
-
[K in keyof Members]: Members[K]["Encoded"];
|
|
3497
|
-
}[number], {
|
|
3498
|
-
[K in keyof Members]: Members[K]["DecodingServices"];
|
|
3499
|
-
}[number], {
|
|
3500
|
-
[K in keyof Members]: Members[K]["EncodingServices"];
|
|
3501
|
-
}[number], SchemaAST.Union<{
|
|
3703
|
+
export interface Union<Members extends ReadonlyArray<Constraint>> extends BottomLazy<SchemaAST.Union<{
|
|
3502
3704
|
[K in keyof Members]: Members[K]["ast"];
|
|
3503
|
-
}[number]>, Union<Members
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
[
|
|
3507
|
-
|
|
3705
|
+
}[number]>, Union<Members>> {
|
|
3706
|
+
readonly "Type": {
|
|
3707
|
+
[K in keyof Members]: Members[K]["Type"];
|
|
3708
|
+
}[number];
|
|
3709
|
+
readonly "Encoded": {
|
|
3710
|
+
[K in keyof Members]: Members[K]["Encoded"];
|
|
3711
|
+
}[number];
|
|
3712
|
+
readonly "DecodingServices": {
|
|
3713
|
+
[K in keyof Members]: Members[K]["DecodingServices"];
|
|
3714
|
+
}[number];
|
|
3715
|
+
readonly "EncodingServices": {
|
|
3716
|
+
[K in keyof Members]: Members[K]["EncodingServices"];
|
|
3717
|
+
}[number];
|
|
3718
|
+
readonly "~type.make.in": {
|
|
3719
|
+
[K in keyof Members]: Members[K]["~type.make"];
|
|
3720
|
+
}[number];
|
|
3721
|
+
readonly "~type.make": {
|
|
3722
|
+
[K in keyof Members]: Members[K]["~type.make"];
|
|
3723
|
+
}[number];
|
|
3724
|
+
readonly "Iso": {
|
|
3725
|
+
[K in keyof Members]: Members[K]["Iso"];
|
|
3726
|
+
}[number];
|
|
3508
3727
|
readonly members: Members;
|
|
3509
3728
|
/**
|
|
3510
3729
|
* Returns a new union with the members modified by the provided function.
|
|
@@ -3522,7 +3741,7 @@ export interface Union<Members extends ReadonlyArray<Top>> extends Bottom<{
|
|
|
3522
3741
|
* use this option if you have verified that your refinements remain correct
|
|
3523
3742
|
* after the transformation.
|
|
3524
3743
|
*/
|
|
3525
|
-
mapMembers<To extends ReadonlyArray<
|
|
3744
|
+
mapMembers<To extends ReadonlyArray<Constraint>>(f: (members: Members) => To, options?: {
|
|
3526
3745
|
readonly unsafePreserveChecks?: boolean | undefined;
|
|
3527
3746
|
} | undefined): Union<Simplify<Readonly<To>>>;
|
|
3528
3747
|
}
|
|
@@ -3550,7 +3769,7 @@ export interface Union<Members extends ReadonlyArray<Top>> extends Bottom<{
|
|
|
3550
3769
|
* @category constructors
|
|
3551
3770
|
* @since 3.10.0
|
|
3552
3771
|
*/
|
|
3553
|
-
export declare function Union<const Members extends ReadonlyArray<
|
|
3772
|
+
export declare function Union<const Members extends ReadonlyArray<Constraint>>(members: Members, options?: {
|
|
3554
3773
|
mode?: "anyOf" | "oneOf";
|
|
3555
3774
|
}): Union<Members>;
|
|
3556
3775
|
/**
|
|
@@ -3567,7 +3786,7 @@ export interface Literals<L extends ReadonlyArray<SchemaAST.LiteralValue>> exten
|
|
|
3567
3786
|
/**
|
|
3568
3787
|
* Map over the members of the union.
|
|
3569
3788
|
*/
|
|
3570
|
-
mapMembers<To extends ReadonlyArray<
|
|
3789
|
+
mapMembers<To extends ReadonlyArray<Constraint>>(f: (members: this["members"]) => To): Union<Simplify<Readonly<To>>>;
|
|
3571
3790
|
pick<const L2 extends ReadonlyArray<L[number]>>(literals: L2): Literals<L2>;
|
|
3572
3791
|
transform<const L2 extends {
|
|
3573
3792
|
readonly [I in keyof L]: SchemaAST.LiteralValue;
|
|
@@ -3598,12 +3817,12 @@ export declare function Literals<const L extends ReadonlyArray<SchemaAST.Literal
|
|
|
3598
3817
|
* @category models
|
|
3599
3818
|
* @since 3.10.0
|
|
3600
3819
|
*/
|
|
3601
|
-
export interface NullOr<S extends
|
|
3820
|
+
export interface NullOr<S extends Constraint> extends Union<readonly [S, Null]> {
|
|
3602
3821
|
readonly "Rebuild": NullOr<S>;
|
|
3603
3822
|
}
|
|
3604
3823
|
interface NullOrLambda extends Lambda {
|
|
3605
|
-
<S extends
|
|
3606
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
3824
|
+
<S extends Constraint>(self: S): NullOr<S>;
|
|
3825
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint ? NullOr<this["~lambda.in"]> : never;
|
|
3607
3826
|
}
|
|
3608
3827
|
/**
|
|
3609
3828
|
* Creates a union schema of `S | null`.
|
|
@@ -3618,12 +3837,12 @@ export declare const NullOr: NullOrLambda;
|
|
|
3618
3837
|
* @category models
|
|
3619
3838
|
* @since 3.10.0
|
|
3620
3839
|
*/
|
|
3621
|
-
export interface UndefinedOr<S extends
|
|
3840
|
+
export interface UndefinedOr<S extends Constraint> extends Union<readonly [S, Undefined]> {
|
|
3622
3841
|
readonly "Rebuild": UndefinedOr<S>;
|
|
3623
3842
|
}
|
|
3624
3843
|
interface UndefinedOrLambda extends Lambda {
|
|
3625
|
-
<S extends
|
|
3626
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
3844
|
+
<S extends Constraint>(self: S): UndefinedOr<S>;
|
|
3845
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint ? UndefinedOr<this["~lambda.in"]> : never;
|
|
3627
3846
|
}
|
|
3628
3847
|
/**
|
|
3629
3848
|
* Creates a union schema of `S | undefined`.
|
|
@@ -3638,12 +3857,12 @@ export declare const UndefinedOr: UndefinedOrLambda;
|
|
|
3638
3857
|
* @category models
|
|
3639
3858
|
* @since 3.10.0
|
|
3640
3859
|
*/
|
|
3641
|
-
export interface NullishOr<S extends
|
|
3860
|
+
export interface NullishOr<S extends Constraint> extends Union<readonly [S, Null, Undefined]> {
|
|
3642
3861
|
readonly "Rebuild": NullishOr<S>;
|
|
3643
3862
|
}
|
|
3644
3863
|
interface NullishOrLambda extends Lambda {
|
|
3645
|
-
<S extends
|
|
3646
|
-
readonly "~lambda.out": this["~lambda.in"] extends
|
|
3864
|
+
<S extends Constraint>(self: S): NullishOr<S>;
|
|
3865
|
+
readonly "~lambda.out": this["~lambda.in"] extends Constraint ? NullishOr<this["~lambda.in"]> : never;
|
|
3647
3866
|
}
|
|
3648
3867
|
/**
|
|
3649
3868
|
* Creates a union schema of `S | null | undefined`.
|
|
@@ -3658,7 +3877,14 @@ export declare const NullishOr: NullishOrLambda;
|
|
|
3658
3877
|
* @category models
|
|
3659
3878
|
* @since 3.10.0
|
|
3660
3879
|
*/
|
|
3661
|
-
export interface suspend<S extends
|
|
3880
|
+
export interface suspend<S extends Constraint> extends BottomLazy<SchemaAST.Suspend, suspend<S>, S["~type.parameters"], S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
3881
|
+
readonly "Type": S["Type"];
|
|
3882
|
+
readonly "Encoded": S["Encoded"];
|
|
3883
|
+
readonly "DecodingServices": S["DecodingServices"];
|
|
3884
|
+
readonly "EncodingServices": S["EncodingServices"];
|
|
3885
|
+
readonly "~type.make.in": S["~type.make.in"];
|
|
3886
|
+
readonly "~type.make": S["~type.make"];
|
|
3887
|
+
readonly "Iso": S["Iso"];
|
|
3662
3888
|
}
|
|
3663
3889
|
/**
|
|
3664
3890
|
* Creates a suspended schema that defers evaluation until needed. This is
|
|
@@ -3684,7 +3910,7 @@ export interface suspend<S extends Top> extends Bottom<S["Type"], S["Encoded"],
|
|
|
3684
3910
|
* @category constructors
|
|
3685
3911
|
* @since 3.10.0
|
|
3686
3912
|
*/
|
|
3687
|
-
export declare function suspend<S extends
|
|
3913
|
+
export declare function suspend<S extends Constraint>(f: () => S): suspend<S>;
|
|
3688
3914
|
/**
|
|
3689
3915
|
* Attaches one or more filter checks to a schema without changing the
|
|
3690
3916
|
* TypeScript type.
|
|
@@ -3709,7 +3935,14 @@ export declare function check<S extends Top>(...checks: readonly [SchemaAST.Chec
|
|
|
3709
3935
|
* @category filtering
|
|
3710
3936
|
* @since 3.10.0
|
|
3711
3937
|
*/
|
|
3712
|
-
export interface refine<T extends S["Type"], S extends
|
|
3938
|
+
export interface refine<T extends S["Type"], S extends Constraint> extends BottomLazy<S["ast"], refine<T, S>, S["~type.parameters"], S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
3939
|
+
readonly "Type": T;
|
|
3940
|
+
readonly "Encoded": S["Encoded"];
|
|
3941
|
+
readonly "DecodingServices": S["DecodingServices"];
|
|
3942
|
+
readonly "EncodingServices": S["EncodingServices"];
|
|
3943
|
+
readonly "~type.make.in": S["~type.make.in"];
|
|
3944
|
+
readonly "~type.make": T;
|
|
3945
|
+
readonly "Iso": T;
|
|
3713
3946
|
readonly schema: S;
|
|
3714
3947
|
}
|
|
3715
3948
|
/**
|
|
@@ -3727,7 +3960,7 @@ export interface refine<T extends S["Type"], S extends Top> extends Bottom<T, S[
|
|
|
3727
3960
|
* @category filtering
|
|
3728
3961
|
* @since 3.10.0
|
|
3729
3962
|
*/
|
|
3730
|
-
export declare function refine<S extends
|
|
3963
|
+
export declare function refine<S extends Constraint, T extends S["Type"]>(refinement: (value: S["Type"]) => value is T, annotations?: Annotations.Filter): (schema: S) => refine<T, S>;
|
|
3731
3964
|
type DistributeBrands<B> = UnionToIntersection<B extends infer U extends string ? Brand.Brand<U> : never>;
|
|
3732
3965
|
/**
|
|
3733
3966
|
* Type-level representation returned by {@link brand}.
|
|
@@ -3735,7 +3968,14 @@ type DistributeBrands<B> = UnionToIntersection<B extends infer U extends string
|
|
|
3735
3968
|
* @category branding
|
|
3736
3969
|
* @since 3.10.0
|
|
3737
3970
|
*/
|
|
3738
|
-
export interface brand<S extends
|
|
3971
|
+
export interface brand<S extends Constraint, B> extends BottomLazy<S["ast"], brand<S, B>, S["~type.parameters"], S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
3972
|
+
readonly "Type": S["Type"] & DistributeBrands<B>;
|
|
3973
|
+
readonly "Encoded": S["Encoded"];
|
|
3974
|
+
readonly "DecodingServices": S["DecodingServices"];
|
|
3975
|
+
readonly "EncodingServices": S["EncodingServices"];
|
|
3976
|
+
readonly "~type.make.in": S["~type.make.in"];
|
|
3977
|
+
readonly "~type.make": S["Type"] & DistributeBrands<B>;
|
|
3978
|
+
readonly "Iso": S["Type"] & DistributeBrands<B>;
|
|
3739
3979
|
readonly schema: S;
|
|
3740
3980
|
readonly identifier: string;
|
|
3741
3981
|
}
|
|
@@ -3758,7 +3998,7 @@ export interface brand<S extends Top, B> extends Bottom<S["Type"] & DistributeBr
|
|
|
3758
3998
|
* @category branding
|
|
3759
3999
|
* @since 3.10.0
|
|
3760
4000
|
*/
|
|
3761
|
-
export declare function brand<B extends string>(identifier: B): <S extends
|
|
4001
|
+
export declare function brand<B extends string>(identifier: B): <S extends ConstraintRebuildable>(schema: S) => brand<S["Rebuild"], B>;
|
|
3762
4002
|
/**
|
|
3763
4003
|
* Creates a branded schema from a {@link Brand.Constructor}, applying the
|
|
3764
4004
|
* constructor's checks and brand tag to the underlying schema.
|
|
@@ -3775,7 +4015,14 @@ export declare function fromBrand<A extends Brand.Brand<any>>(identifier: string
|
|
|
3775
4015
|
* @category decoding
|
|
3776
4016
|
* @since 4.0.0
|
|
3777
4017
|
*/
|
|
3778
|
-
export interface middlewareDecoding<S extends
|
|
4018
|
+
export interface middlewareDecoding<S extends Constraint, RD> extends BottomLazy<S["ast"], middlewareDecoding<S, RD>, S["~type.parameters"], S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
4019
|
+
readonly "Type": S["Type"];
|
|
4020
|
+
readonly "Encoded": S["Encoded"];
|
|
4021
|
+
readonly "DecodingServices": RD;
|
|
4022
|
+
readonly "EncodingServices": S["EncodingServices"];
|
|
4023
|
+
readonly "~type.make.in": S["~type.make.in"];
|
|
4024
|
+
readonly "~type.make": S["~type.make"];
|
|
4025
|
+
readonly "Iso": S["Iso"];
|
|
3779
4026
|
readonly schema: S;
|
|
3780
4027
|
}
|
|
3781
4028
|
/**
|
|
@@ -3803,14 +4050,21 @@ export interface middlewareDecoding<S extends Top, RD> extends Bottom<S["Type"],
|
|
|
3803
4050
|
* @category decoding
|
|
3804
4051
|
* @since 4.0.0
|
|
3805
4052
|
*/
|
|
3806
|
-
export declare function middlewareDecoding<S extends
|
|
4053
|
+
export declare function middlewareDecoding<S extends Constraint, RD>(decode: (effect: Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, S["DecodingServices"]>, options: SchemaAST.ParseOptions) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, RD>): (schema: S) => middlewareDecoding<S, RD>;
|
|
3807
4054
|
/**
|
|
3808
4055
|
* Type-level representation returned by {@link middlewareEncoding}.
|
|
3809
4056
|
*
|
|
3810
4057
|
* @category encoding
|
|
3811
4058
|
* @since 4.0.0
|
|
3812
4059
|
*/
|
|
3813
|
-
export interface middlewareEncoding<S extends
|
|
4060
|
+
export interface middlewareEncoding<S extends Constraint, RE> extends BottomLazy<S["ast"], middlewareEncoding<S, RE>, S["~type.parameters"], S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
4061
|
+
readonly "Type": S["Type"];
|
|
4062
|
+
readonly "Encoded": S["Encoded"];
|
|
4063
|
+
readonly "DecodingServices": S["DecodingServices"];
|
|
4064
|
+
readonly "EncodingServices": RE;
|
|
4065
|
+
readonly "~type.make.in": S["~type.make.in"];
|
|
4066
|
+
readonly "~type.make": S["~type.make"];
|
|
4067
|
+
readonly "Iso": S["Iso"];
|
|
3814
4068
|
readonly schema: S;
|
|
3815
4069
|
}
|
|
3816
4070
|
/**
|
|
@@ -3838,7 +4092,7 @@ export interface middlewareEncoding<S extends Top, RE> extends Bottom<S["Type"],
|
|
|
3838
4092
|
* @category encoding
|
|
3839
4093
|
* @since 4.0.0
|
|
3840
4094
|
*/
|
|
3841
|
-
export declare function middlewareEncoding<S extends
|
|
4095
|
+
export declare function middlewareEncoding<S extends Constraint, RE>(encode: (effect: Effect.Effect<Option_.Option<S["Encoded"]>, SchemaIssue.Issue, S["EncodingServices"]>, options: SchemaAST.ParseOptions) => Effect.Effect<Option_.Option<S["Encoded"]>, SchemaIssue.Issue, RE>): (schema: S) => middlewareEncoding<S, RE>;
|
|
3842
4096
|
/**
|
|
3843
4097
|
* Recovers from a decoding error by providing a fallback value.
|
|
3844
4098
|
*
|
|
@@ -3861,7 +4115,7 @@ export declare function middlewareEncoding<S extends Top, RE>(encode: (effect: E
|
|
|
3861
4115
|
* @category error handling
|
|
3862
4116
|
* @since 4.0.0
|
|
3863
4117
|
*/
|
|
3864
|
-
export declare function catchDecoding<S extends
|
|
4118
|
+
export declare function catchDecoding<S extends Constraint>(f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue>): (self: S) => middlewareDecoding<S, S["DecodingServices"]>;
|
|
3865
4119
|
/**
|
|
3866
4120
|
* Recovers from a decoding error with a handler that may require Effect services.
|
|
3867
4121
|
*
|
|
@@ -3882,7 +4136,7 @@ export declare function catchDecoding<S extends Top>(f: (issue: SchemaIssue.Issu
|
|
|
3882
4136
|
* @category error handling
|
|
3883
4137
|
* @since 4.0.0
|
|
3884
4138
|
*/
|
|
3885
|
-
export declare function catchDecodingWithContext<S extends
|
|
4139
|
+
export declare function catchDecodingWithContext<S extends Constraint, R = never>(f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, R>): (self: S) => middlewareDecoding<S, S["DecodingServices"] | R>;
|
|
3886
4140
|
/**
|
|
3887
4141
|
* Recovers from an encoding error by providing a fallback value.
|
|
3888
4142
|
*
|
|
@@ -3895,7 +4149,7 @@ export declare function catchDecodingWithContext<S extends Top, R = never>(f: (i
|
|
|
3895
4149
|
* @category error handling
|
|
3896
4150
|
* @since 4.0.0
|
|
3897
4151
|
*/
|
|
3898
|
-
export declare function catchEncoding<S extends
|
|
4152
|
+
export declare function catchEncoding<S extends Constraint>(f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Encoded"]>, SchemaIssue.Issue>): (self: S) => middlewareEncoding<S, S["EncodingServices"]>;
|
|
3899
4153
|
/**
|
|
3900
4154
|
* Recovers from an encoding error with a handler that may require Effect services.
|
|
3901
4155
|
*
|
|
@@ -3916,14 +4170,21 @@ export declare function catchEncoding<S extends Top>(f: (issue: SchemaIssue.Issu
|
|
|
3916
4170
|
* @category error handling
|
|
3917
4171
|
* @since 4.0.0
|
|
3918
4172
|
*/
|
|
3919
|
-
export declare function catchEncodingWithContext<S extends
|
|
4173
|
+
export declare function catchEncodingWithContext<S extends Constraint, R = never>(f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Encoded"]>, SchemaIssue.Issue, R>): (self: S) => middlewareEncoding<S, S["EncodingServices"] | R>;
|
|
3920
4174
|
/**
|
|
3921
4175
|
* Type-level representation returned by {@link decodeTo}.
|
|
3922
4176
|
*
|
|
3923
4177
|
* @category transforming
|
|
3924
4178
|
* @since 4.0.0
|
|
3925
4179
|
*/
|
|
3926
|
-
export interface decodeTo<To extends
|
|
4180
|
+
export interface decodeTo<To extends Constraint, From extends Constraint, RD = never, RE = never> extends BottomLazy<To["ast"], decodeTo<To, From, RD, RE>, To["~type.parameters"], To["~type.mutability"], To["~type.optionality"], To["~type.constructor.default"], From["~encoded.mutability"], From["~encoded.optionality"]> {
|
|
4181
|
+
readonly "Type": To["Type"];
|
|
4182
|
+
readonly "Encoded": From["Encoded"];
|
|
4183
|
+
readonly "DecodingServices": To["DecodingServices"] | From["DecodingServices"] | RD;
|
|
4184
|
+
readonly "EncodingServices": To["EncodingServices"] | From["EncodingServices"] | RE;
|
|
4185
|
+
readonly "~type.make.in": To["~type.make.in"];
|
|
4186
|
+
readonly "~type.make": To["~type.make"];
|
|
4187
|
+
readonly "Iso": To["Iso"];
|
|
3927
4188
|
readonly from: From;
|
|
3928
4189
|
readonly to: To;
|
|
3929
4190
|
}
|
|
@@ -3933,7 +4194,7 @@ export interface decodeTo<To extends Top, From extends Top, RD = never, RE = nev
|
|
|
3933
4194
|
* @category transforming
|
|
3934
4195
|
* @since 3.10.0
|
|
3935
4196
|
*/
|
|
3936
|
-
export interface compose<To extends
|
|
4197
|
+
export interface compose<To extends Constraint, From extends Constraint> extends decodeTo<To, From> {
|
|
3937
4198
|
}
|
|
3938
4199
|
/**
|
|
3939
4200
|
* Creates a schema that transforms from a source schema to a target schema.
|
|
@@ -3983,8 +4244,8 @@ export interface compose<To extends Top, From extends Top> extends decodeTo<To,
|
|
|
3983
4244
|
* @category transforming
|
|
3984
4245
|
* @since 4.0.0
|
|
3985
4246
|
*/
|
|
3986
|
-
export declare function decodeTo<To extends
|
|
3987
|
-
export declare function decodeTo<To extends
|
|
4247
|
+
export declare function decodeTo<To extends Constraint>(to: To): <From extends Constraint>(from: From) => compose<To, From>;
|
|
4248
|
+
export declare function decodeTo<To extends Constraint, From extends Constraint, RD = never, RE = never>(to: To, transformation: {
|
|
3988
4249
|
readonly decode: SchemaGetter.Getter<NoInfer<To["Encoded"]>, NoInfer<From["Type"]>, RD>;
|
|
3989
4250
|
readonly encode: SchemaGetter.Getter<NoInfer<From["Type"]>, NoInfer<To["Encoded"]>, RE>;
|
|
3990
4251
|
}): (from: From) => decodeTo<To, From, RD, RE>;
|
|
@@ -4031,7 +4292,7 @@ export declare function decodeTo<To extends Top, From extends Top, RD = never, R
|
|
|
4031
4292
|
* @category transforming
|
|
4032
4293
|
* @since 3.10.0
|
|
4033
4294
|
*/
|
|
4034
|
-
export declare function decode<S extends
|
|
4295
|
+
export declare function decode<S extends Constraint, RD = never, RE = never>(transformation: {
|
|
4035
4296
|
readonly decode: SchemaGetter.Getter<S["Type"], S["Type"], RD>;
|
|
4036
4297
|
readonly encode: SchemaGetter.Getter<S["Type"], S["Type"], RE>;
|
|
4037
4298
|
}): (self: S) => decodeTo<toType<S>, S, RD, RE>;
|
|
@@ -4064,8 +4325,8 @@ export declare function decode<S extends Top, RD = never, RE = never>(transforma
|
|
|
4064
4325
|
* @category transforming
|
|
4065
4326
|
* @since 4.0.0
|
|
4066
4327
|
*/
|
|
4067
|
-
export declare function encodeTo<To extends
|
|
4068
|
-
export declare function encodeTo<To extends
|
|
4328
|
+
export declare function encodeTo<To extends Constraint>(to: To): <From extends Constraint>(from: From) => decodeTo<From, To>;
|
|
4329
|
+
export declare function encodeTo<To extends Constraint, From extends Constraint, RD = never, RE = never>(to: To, transformation: {
|
|
4069
4330
|
readonly decode: SchemaGetter.Getter<NoInfer<From["Encoded"]>, NoInfer<To["Type"]>, RD>;
|
|
4070
4331
|
readonly encode: SchemaGetter.Getter<NoInfer<To["Type"]>, NoInfer<From["Encoded"]>, RE>;
|
|
4071
4332
|
}): (from: From) => decodeTo<From, To, RD, RE>;
|
|
@@ -4094,7 +4355,7 @@ export declare function encodeTo<To extends Top, From extends Top, RD = never, R
|
|
|
4094
4355
|
* @category transforming
|
|
4095
4356
|
* @since 3.10.0
|
|
4096
4357
|
*/
|
|
4097
|
-
export declare function encode<S extends
|
|
4358
|
+
export declare function encode<S extends Constraint, RD = never, RE = never>(transformation: {
|
|
4098
4359
|
readonly decode: SchemaGetter.Getter<S["Encoded"], S["Encoded"], RD>;
|
|
4099
4360
|
readonly encode: SchemaGetter.Getter<S["Encoded"], S["Encoded"], RE>;
|
|
4100
4361
|
}): (self: S) => decodeTo<S, toEncoded<S>, RD, RE>;
|
|
@@ -4117,7 +4378,14 @@ export interface WithoutConstructorDefault {
|
|
|
4117
4378
|
* @category constructors
|
|
4118
4379
|
* @since 3.10.0
|
|
4119
4380
|
*/
|
|
4120
|
-
export interface withConstructorDefault<S extends
|
|
4381
|
+
export interface withConstructorDefault<S extends Constraint & WithoutConstructorDefault> extends BottomLazy<S["ast"], withConstructorDefault<S>, S["~type.parameters"], S["~type.mutability"], S["~type.optionality"], "with-default", S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
4382
|
+
readonly "Type": S["Type"];
|
|
4383
|
+
readonly "Encoded": S["Encoded"];
|
|
4384
|
+
readonly "DecodingServices": S["DecodingServices"];
|
|
4385
|
+
readonly "EncodingServices": S["EncodingServices"];
|
|
4386
|
+
readonly "~type.make.in": S["~type.make.in"];
|
|
4387
|
+
readonly "~type.make": S["~type.make"];
|
|
4388
|
+
readonly "Iso": S["Iso"];
|
|
4121
4389
|
readonly schema: S;
|
|
4122
4390
|
}
|
|
4123
4391
|
/**
|
|
@@ -4147,14 +4415,14 @@ export interface withConstructorDefault<S extends Top & WithoutConstructorDefaul
|
|
|
4147
4415
|
* @category constructors
|
|
4148
4416
|
* @since 3.10.0
|
|
4149
4417
|
*/
|
|
4150
|
-
export declare function withConstructorDefault<S extends
|
|
4418
|
+
export declare function withConstructorDefault<S extends Constraint & WithoutConstructorDefault>(defaultValue: Effect.Effect<S["~type.make.in"], SchemaError>): (schema: S) => withConstructorDefault<S>;
|
|
4151
4419
|
/**
|
|
4152
4420
|
* Type-level representation returned by {@link withDecodingDefaultKey}.
|
|
4153
4421
|
*
|
|
4154
4422
|
* @category decoding
|
|
4155
4423
|
* @since 4.0.0
|
|
4156
4424
|
*/
|
|
4157
|
-
export interface withDecodingDefaultKey<S extends
|
|
4425
|
+
export interface withDecodingDefaultKey<S extends Constraint, R = never> extends decodeTo<S, optionalKey<toEncoded<S>>, R> {
|
|
4158
4426
|
readonly "Rebuild": withDecodingDefaultKey<S, R>;
|
|
4159
4427
|
}
|
|
4160
4428
|
/**
|
|
@@ -4206,14 +4474,14 @@ export type DecodingDefaultOptions = {
|
|
|
4206
4474
|
* @category decoding
|
|
4207
4475
|
* @since 4.0.0
|
|
4208
4476
|
*/
|
|
4209
|
-
export declare function withDecodingDefaultKey<S extends
|
|
4477
|
+
export declare function withDecodingDefaultKey<S extends Constraint, R = never>(defaultValue: Effect.Effect<S["Encoded"], SchemaError, R>, options?: DecodingDefaultOptions): (self: S) => withDecodingDefaultKey<S, R>;
|
|
4210
4478
|
/**
|
|
4211
4479
|
* Type-level representation returned by {@link withDecodingDefaultTypeKey}.
|
|
4212
4480
|
*
|
|
4213
4481
|
* @category decoding
|
|
4214
4482
|
* @since 4.0.0
|
|
4215
4483
|
*/
|
|
4216
|
-
export interface withDecodingDefaultTypeKey<S extends
|
|
4484
|
+
export interface withDecodingDefaultTypeKey<S extends Constraint, R = never> extends decodeTo<withDecodingDefaultKey<toType<S>, R>, optionalKey<S>> {
|
|
4217
4485
|
readonly "Rebuild": withDecodingDefaultTypeKey<S, R>;
|
|
4218
4486
|
}
|
|
4219
4487
|
/**
|
|
@@ -4238,14 +4506,14 @@ export interface withDecodingDefaultTypeKey<S extends Top, R = never> extends de
|
|
|
4238
4506
|
* @category decoding
|
|
4239
4507
|
* @since 4.0.0
|
|
4240
4508
|
*/
|
|
4241
|
-
export declare function withDecodingDefaultTypeKey<S extends
|
|
4509
|
+
export declare function withDecodingDefaultTypeKey<S extends Constraint, R = never>(defaultValue: Effect.Effect<S["Type"], SchemaError, R>, options?: DecodingDefaultOptions): (self: S) => withDecodingDefaultTypeKey<S, R>;
|
|
4242
4510
|
/**
|
|
4243
4511
|
* Type-level representation returned by {@link withDecodingDefault}.
|
|
4244
4512
|
*
|
|
4245
4513
|
* @category decoding
|
|
4246
4514
|
* @since 3.10.0
|
|
4247
4515
|
*/
|
|
4248
|
-
export interface withDecodingDefault<S extends
|
|
4516
|
+
export interface withDecodingDefault<S extends Constraint, R = never> extends decodeTo<S, optional<toEncoded<S>>, R> {
|
|
4249
4517
|
readonly "Rebuild": withDecodingDefault<S, R>;
|
|
4250
4518
|
}
|
|
4251
4519
|
/**
|
|
@@ -4287,14 +4555,14 @@ export interface withDecodingDefault<S extends Top, R = never> extends decodeTo<
|
|
|
4287
4555
|
* @category decoding
|
|
4288
4556
|
* @since 3.10.0
|
|
4289
4557
|
*/
|
|
4290
|
-
export declare function withDecodingDefault<S extends
|
|
4558
|
+
export declare function withDecodingDefault<S extends Constraint, R = never>(defaultValue: Effect.Effect<S["Encoded"], SchemaError, R>, options?: DecodingDefaultOptions): (self: S) => withDecodingDefault<S, R>;
|
|
4291
4559
|
/**
|
|
4292
4560
|
* Type-level representation returned by {@link withDecodingDefaultType}.
|
|
4293
4561
|
*
|
|
4294
4562
|
* @category decoding
|
|
4295
4563
|
* @since 4.0.0
|
|
4296
4564
|
*/
|
|
4297
|
-
export interface withDecodingDefaultType<S extends
|
|
4565
|
+
export interface withDecodingDefaultType<S extends Constraint, R = never> extends decodeTo<withDecodingDefault<toType<S>, R>, optional<S>> {
|
|
4298
4566
|
readonly "Rebuild": withDecodingDefaultType<S, R>;
|
|
4299
4567
|
}
|
|
4300
4568
|
/**
|
|
@@ -4324,7 +4592,7 @@ export interface withDecodingDefaultType<S extends Top, R = never> extends decod
|
|
|
4324
4592
|
* @category decoding
|
|
4325
4593
|
* @since 4.0.0
|
|
4326
4594
|
*/
|
|
4327
|
-
export declare function withDecodingDefaultType<S extends
|
|
4595
|
+
export declare function withDecodingDefaultType<S extends Constraint, R = never>(defaultValue: Effect.Effect<S["Type"], SchemaError, R>, options?: DecodingDefaultOptions): (self: S) => withDecodingDefaultType<S, R>;
|
|
4328
4596
|
/**
|
|
4329
4597
|
* Type-level representation returned by {@link tag}.
|
|
4330
4598
|
*
|
|
@@ -4449,11 +4717,11 @@ export declare function TaggedStruct<const Tag extends SchemaAST.LiteralValue, c
|
|
|
4449
4717
|
* Recursively flatten any nested Schema.Union members into a single tuple of leaf schemas.
|
|
4450
4718
|
*/
|
|
4451
4719
|
type Flatten<Schemas> = Schemas extends readonly [infer Head, ...infer Tail] ? Head extends Union<infer Inner> ? [...Flatten<Inner>, ...Flatten<Tail>] : [Head, ...Flatten<Tail>] : [];
|
|
4452
|
-
type TaggedUnionUtils<Tag extends PropertyKey, Members extends ReadonlyArray<
|
|
4720
|
+
type TaggedUnionUtils<Tag extends PropertyKey, Members extends ReadonlyArray<Constraint & {
|
|
4453
4721
|
readonly Type: {
|
|
4454
4722
|
readonly [K in Tag]: PropertyKey;
|
|
4455
4723
|
};
|
|
4456
|
-
}>, Flattened extends ReadonlyArray<
|
|
4724
|
+
}>, Flattened extends ReadonlyArray<Constraint & {
|
|
4457
4725
|
readonly Type: {
|
|
4458
4726
|
readonly [K in Tag]: PropertyKey;
|
|
4459
4727
|
};
|
|
@@ -4482,7 +4750,7 @@ type TaggedUnionUtils<Tag extends PropertyKey, Members extends ReadonlyArray<Top
|
|
|
4482
4750
|
* @category combinators
|
|
4483
4751
|
* @since 4.0.0
|
|
4484
4752
|
*/
|
|
4485
|
-
export type toTaggedUnion<Tag extends PropertyKey, Members extends ReadonlyArray<
|
|
4753
|
+
export type toTaggedUnion<Tag extends PropertyKey, Members extends ReadonlyArray<Constraint & {
|
|
4486
4754
|
readonly Type: {
|
|
4487
4755
|
readonly [K in Tag]: PropertyKey;
|
|
4488
4756
|
};
|
|
@@ -4511,7 +4779,7 @@ export type toTaggedUnion<Tag extends PropertyKey, Members extends ReadonlyArray
|
|
|
4511
4779
|
* @category combinators
|
|
4512
4780
|
* @since 4.0.0
|
|
4513
4781
|
*/
|
|
4514
|
-
export declare function toTaggedUnion<const Tag extends PropertyKey>(tag: Tag): <const Members extends ReadonlyArray<
|
|
4782
|
+
export declare function toTaggedUnion<const Tag extends PropertyKey>(tag: Tag): <const Members extends ReadonlyArray<Constraint & {
|
|
4515
4783
|
readonly Type: { readonly [K in Tag]: PropertyKey; };
|
|
4516
4784
|
}>>(self: Union<Members>) => toTaggedUnion<Tag, Members>;
|
|
4517
4785
|
/**
|
|
@@ -4520,17 +4788,28 @@ export declare function toTaggedUnion<const Tag extends PropertyKey>(tag: Tag):
|
|
|
4520
4788
|
* @category models
|
|
4521
4789
|
* @since 4.0.0
|
|
4522
4790
|
*/
|
|
4523
|
-
export interface TaggedUnion<Cases extends Record<string,
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
[
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
}[keyof Cases]
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
[
|
|
4533
|
-
|
|
4791
|
+
export interface TaggedUnion<Cases extends Record<string, Constraint>> extends BottomLazy<SchemaAST.Union<SchemaAST.Objects>, TaggedUnion<Cases>> {
|
|
4792
|
+
readonly "Type": {
|
|
4793
|
+
[K in keyof Cases]: Cases[K]["Type"];
|
|
4794
|
+
}[keyof Cases];
|
|
4795
|
+
readonly "Encoded": {
|
|
4796
|
+
[K in keyof Cases]: Cases[K]["Encoded"];
|
|
4797
|
+
}[keyof Cases];
|
|
4798
|
+
readonly "DecodingServices": {
|
|
4799
|
+
[K in keyof Cases]: Cases[K]["DecodingServices"];
|
|
4800
|
+
}[keyof Cases];
|
|
4801
|
+
readonly "EncodingServices": {
|
|
4802
|
+
[K in keyof Cases]: Cases[K]["EncodingServices"];
|
|
4803
|
+
}[keyof Cases];
|
|
4804
|
+
readonly "~type.make.in": {
|
|
4805
|
+
[K in keyof Cases]: Cases[K]["~type.make"];
|
|
4806
|
+
}[keyof Cases];
|
|
4807
|
+
readonly "~type.make": {
|
|
4808
|
+
[K in keyof Cases]: Cases[K]["~type.make"];
|
|
4809
|
+
}[keyof Cases];
|
|
4810
|
+
readonly "Iso": {
|
|
4811
|
+
[K in keyof Cases]: Cases[K]["Type"];
|
|
4812
|
+
}[keyof Cases];
|
|
4534
4813
|
readonly cases: Cases;
|
|
4535
4814
|
readonly isAnyOf: <const Keys>(keys: ReadonlyArray<Keys>) => (value: Cases[keyof Cases]["Type"]) => value is Extract<Cases[keyof Cases]["Type"], {
|
|
4536
4815
|
_tag: Keys;
|
|
@@ -4582,7 +4861,14 @@ export declare function TaggedUnion<const CasesByTag extends Record<string, Stru
|
|
|
4582
4861
|
* @category models
|
|
4583
4862
|
* @since 4.0.0
|
|
4584
4863
|
*/
|
|
4585
|
-
export interface Opaque<Self, S extends Top, Brand> extends
|
|
4864
|
+
export interface Opaque<Self, S extends Top, Brand> extends BottomLazy<S["ast"], S["Rebuild"], S["~type.parameters"], S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
4865
|
+
readonly "Type": Self;
|
|
4866
|
+
readonly "Encoded": S["Encoded"];
|
|
4867
|
+
readonly "DecodingServices": S["DecodingServices"];
|
|
4868
|
+
readonly "EncodingServices": S["EncodingServices"];
|
|
4869
|
+
readonly "~type.make.in": S["~type.make.in"];
|
|
4870
|
+
readonly "~type.make": S["~type.make"];
|
|
4871
|
+
readonly "Iso": S["Iso"];
|
|
4586
4872
|
new (_: never): S["Type"] & Brand;
|
|
4587
4873
|
}
|
|
4588
4874
|
/**
|
|
@@ -4645,7 +4931,7 @@ export declare function instanceOf<C extends abstract new (...args: any) => any,
|
|
|
4645
4931
|
* @category transforming
|
|
4646
4932
|
* @since 4.0.0
|
|
4647
4933
|
*/
|
|
4648
|
-
export declare function link<T>(): <To extends
|
|
4934
|
+
export declare function link<T>(): <To extends Constraint>(encodeTo: To, transformation: {
|
|
4649
4935
|
readonly decode: SchemaGetter.Getter<T, NoInfer<To["Type"]>>;
|
|
4650
4936
|
readonly encode: SchemaGetter.Getter<NoInfer<To["Type"]>, T>;
|
|
4651
4937
|
}) => SchemaAST.Link;
|
|
@@ -5835,7 +6121,7 @@ export declare function isPropertiesLengthBetween(minimum: number, maximum: numb
|
|
|
5835
6121
|
* @category Object checks
|
|
5836
6122
|
* @since 4.0.0
|
|
5837
6123
|
*/
|
|
5838
|
-
export declare function isPropertyNames(keySchema:
|
|
6124
|
+
export declare function isPropertyNames(keySchema: Constraint, annotations?: Annotations.Filter): SchemaAST.Filter<object>;
|
|
5839
6125
|
/**
|
|
5840
6126
|
* Validates that all items in an array are unique according to Effect equality.
|
|
5841
6127
|
*
|
|
@@ -5905,7 +6191,7 @@ export declare const Char: Char;
|
|
|
5905
6191
|
* @category Option
|
|
5906
6192
|
* @since 3.10.0
|
|
5907
6193
|
*/
|
|
5908
|
-
export interface Option<A extends
|
|
6194
|
+
export interface Option<A extends Constraint> extends declareConstructor<Option_.Option<A["Type"]>, Option_.Option<A["Encoded"]>, readonly [A], OptionIso<A>> {
|
|
5909
6195
|
readonly "Rebuild": Option<A>;
|
|
5910
6196
|
readonly value: A;
|
|
5911
6197
|
}
|
|
@@ -5920,7 +6206,7 @@ export interface Option<A extends Top> extends declareConstructor<Option_.Option
|
|
|
5920
6206
|
* @category Option
|
|
5921
6207
|
* @since 4.0.0
|
|
5922
6208
|
*/
|
|
5923
|
-
export type OptionIso<A extends
|
|
6209
|
+
export type OptionIso<A extends Constraint> = {
|
|
5924
6210
|
readonly _tag: "None";
|
|
5925
6211
|
} | {
|
|
5926
6212
|
readonly _tag: "Some";
|
|
@@ -5932,14 +6218,14 @@ export type OptionIso<A extends Top> = {
|
|
|
5932
6218
|
* @category Option
|
|
5933
6219
|
* @since 3.10.0
|
|
5934
6220
|
*/
|
|
5935
|
-
export declare function Option<A extends
|
|
6221
|
+
export declare function Option<A extends Constraint>(value: A): Option<A>;
|
|
5936
6222
|
/**
|
|
5937
6223
|
* Type-level representation returned by {@link OptionFromNullOr}.
|
|
5938
6224
|
*
|
|
5939
6225
|
* @category Option
|
|
5940
6226
|
* @since 3.10.0
|
|
5941
6227
|
*/
|
|
5942
|
-
export interface OptionFromNullOr<S extends
|
|
6228
|
+
export interface OptionFromNullOr<S extends Constraint> extends decodeTo<Option<toType<S>>, NullOr<S>> {
|
|
5943
6229
|
readonly "Rebuild": OptionFromNullOr<S>;
|
|
5944
6230
|
}
|
|
5945
6231
|
/**
|
|
@@ -5953,14 +6239,14 @@ export interface OptionFromNullOr<S extends Top> extends decodeTo<Option<toType<
|
|
|
5953
6239
|
* @category Option
|
|
5954
6240
|
* @since 3.10.0
|
|
5955
6241
|
*/
|
|
5956
|
-
export declare function OptionFromNullOr<S extends
|
|
6242
|
+
export declare function OptionFromNullOr<S extends Constraint>(schema: S): OptionFromNullOr<S>;
|
|
5957
6243
|
/**
|
|
5958
6244
|
* Type-level representation returned by {@link OptionFromUndefinedOr}.
|
|
5959
6245
|
*
|
|
5960
6246
|
* @category Option
|
|
5961
6247
|
* @since 3.10.0
|
|
5962
6248
|
*/
|
|
5963
|
-
export interface OptionFromUndefinedOr<S extends
|
|
6249
|
+
export interface OptionFromUndefinedOr<S extends Constraint> extends decodeTo<Option<toType<S>>, UndefinedOr<S>> {
|
|
5964
6250
|
readonly "Rebuild": OptionFromUndefinedOr<S>;
|
|
5965
6251
|
}
|
|
5966
6252
|
/**
|
|
@@ -5975,14 +6261,14 @@ export interface OptionFromUndefinedOr<S extends Top> extends decodeTo<Option<to
|
|
|
5975
6261
|
* @category Option
|
|
5976
6262
|
* @since 3.10.0
|
|
5977
6263
|
*/
|
|
5978
|
-
export declare function OptionFromUndefinedOr<S extends
|
|
6264
|
+
export declare function OptionFromUndefinedOr<S extends Constraint>(schema: S): OptionFromUndefinedOr<S>;
|
|
5979
6265
|
/**
|
|
5980
6266
|
* Type-level representation returned by {@link OptionFromNullishOr}.
|
|
5981
6267
|
*
|
|
5982
6268
|
* @category Option
|
|
5983
6269
|
* @since 3.10.0
|
|
5984
6270
|
*/
|
|
5985
|
-
export interface OptionFromNullishOr<S extends
|
|
6271
|
+
export interface OptionFromNullishOr<S extends Constraint> extends decodeTo<Option<toType<S>>, NullishOr<S>> {
|
|
5986
6272
|
readonly "Rebuild": OptionFromNullishOr<S>;
|
|
5987
6273
|
}
|
|
5988
6274
|
/**
|
|
@@ -5998,7 +6284,7 @@ export interface OptionFromNullishOr<S extends Top> extends decodeTo<Option<toTy
|
|
|
5998
6284
|
* @category Option
|
|
5999
6285
|
* @since 3.10.0
|
|
6000
6286
|
*/
|
|
6001
|
-
export declare function OptionFromNullishOr<S extends
|
|
6287
|
+
export declare function OptionFromNullishOr<S extends Constraint>(schema: S, options?: {
|
|
6002
6288
|
onNoneEncoding: null | undefined;
|
|
6003
6289
|
}): OptionFromNullishOr<S>;
|
|
6004
6290
|
/**
|
|
@@ -6007,7 +6293,7 @@ export declare function OptionFromNullishOr<S extends Top>(schema: S, options?:
|
|
|
6007
6293
|
* @category Option
|
|
6008
6294
|
* @since 4.0.0
|
|
6009
6295
|
*/
|
|
6010
|
-
export interface OptionFromOptionalKey<S extends
|
|
6296
|
+
export interface OptionFromOptionalKey<S extends Constraint> extends decodeTo<Option<toType<S>>, optionalKey<S>> {
|
|
6011
6297
|
readonly "Rebuild": OptionFromOptionalKey<S>;
|
|
6012
6298
|
}
|
|
6013
6299
|
/**
|
|
@@ -6021,14 +6307,14 @@ export interface OptionFromOptionalKey<S extends Top> extends decodeTo<Option<to
|
|
|
6021
6307
|
* @category Option
|
|
6022
6308
|
* @since 4.0.0
|
|
6023
6309
|
*/
|
|
6024
|
-
export declare function OptionFromOptionalKey<S extends
|
|
6310
|
+
export declare function OptionFromOptionalKey<S extends Constraint>(schema: S): OptionFromOptionalKey<S>;
|
|
6025
6311
|
/**
|
|
6026
6312
|
* Type-level representation returned by {@link OptionFromOptional}.
|
|
6027
6313
|
*
|
|
6028
6314
|
* @category Option
|
|
6029
6315
|
* @since 4.0.0
|
|
6030
6316
|
*/
|
|
6031
|
-
export interface OptionFromOptional<S extends
|
|
6317
|
+
export interface OptionFromOptional<S extends Constraint> extends decodeTo<Option<toType<S>>, optional<S>> {
|
|
6032
6318
|
readonly "Rebuild": OptionFromOptional<S>;
|
|
6033
6319
|
}
|
|
6034
6320
|
/**
|
|
@@ -6044,14 +6330,14 @@ export interface OptionFromOptional<S extends Top> extends decodeTo<Option<toTyp
|
|
|
6044
6330
|
* @category Option
|
|
6045
6331
|
* @since 4.0.0
|
|
6046
6332
|
*/
|
|
6047
|
-
export declare function OptionFromOptional<S extends
|
|
6333
|
+
export declare function OptionFromOptional<S extends Constraint>(schema: S): OptionFromOptional<S>;
|
|
6048
6334
|
/**
|
|
6049
6335
|
* Type-level representation returned by {@link OptionFromOptionalNullOr}.
|
|
6050
6336
|
*
|
|
6051
6337
|
* @category Option
|
|
6052
6338
|
* @since 4.0.0
|
|
6053
6339
|
*/
|
|
6054
|
-
export interface OptionFromOptionalNullOr<S extends
|
|
6340
|
+
export interface OptionFromOptionalNullOr<S extends Constraint> extends decodeTo<Option<toType<S>>, optional<NullOr<S>>> {
|
|
6055
6341
|
readonly "Rebuild": OptionFromOptionalNullOr<S>;
|
|
6056
6342
|
}
|
|
6057
6343
|
/**
|
|
@@ -6068,7 +6354,7 @@ export interface OptionFromOptionalNullOr<S extends Top> extends decodeTo<Option
|
|
|
6068
6354
|
* @category Option
|
|
6069
6355
|
* @since 4.0.0
|
|
6070
6356
|
*/
|
|
6071
|
-
export declare function OptionFromOptionalNullOr<S extends
|
|
6357
|
+
export declare function OptionFromOptionalNullOr<S extends Constraint>(schema: S, options?: {
|
|
6072
6358
|
readonly onNoneEncoding: "omit" | null | undefined;
|
|
6073
6359
|
}): OptionFromOptionalNullOr<S>;
|
|
6074
6360
|
/**
|
|
@@ -6077,7 +6363,7 @@ export declare function OptionFromOptionalNullOr<S extends Top>(schema: S, optio
|
|
|
6077
6363
|
* @category schemas
|
|
6078
6364
|
* @since 4.0.0
|
|
6079
6365
|
*/
|
|
6080
|
-
export interface Result<A extends
|
|
6366
|
+
export interface Result<A extends Constraint, E extends Constraint> extends declareConstructor<Result_.Result<A["Type"], E["Type"]>, Result_.Result<A["Encoded"], E["Encoded"]>, readonly [A, E], ResultIso<A, E>> {
|
|
6081
6367
|
readonly "Rebuild": Result<A, E>;
|
|
6082
6368
|
readonly success: A;
|
|
6083
6369
|
readonly failure: E;
|
|
@@ -6093,7 +6379,7 @@ export interface Result<A extends Top, E extends Top> extends declareConstructor
|
|
|
6093
6379
|
* @category schemas
|
|
6094
6380
|
* @since 4.0.0
|
|
6095
6381
|
*/
|
|
6096
|
-
export type ResultIso<A extends
|
|
6382
|
+
export type ResultIso<A extends Constraint, E extends Constraint> = {
|
|
6097
6383
|
readonly _tag: "Success";
|
|
6098
6384
|
readonly success: A["Iso"];
|
|
6099
6385
|
} | {
|
|
@@ -6106,14 +6392,14 @@ export type ResultIso<A extends Top, E extends Top> = {
|
|
|
6106
6392
|
* @category schemas
|
|
6107
6393
|
* @since 4.0.0
|
|
6108
6394
|
*/
|
|
6109
|
-
export declare function Result<A extends
|
|
6395
|
+
export declare function Result<A extends Constraint, E extends Constraint>(success: A, failure: E): Result<A, E>;
|
|
6110
6396
|
/**
|
|
6111
6397
|
* Type-level representation returned by {@link Redacted}.
|
|
6112
6398
|
*
|
|
6113
6399
|
* @category Redacted
|
|
6114
6400
|
* @since 3.10.0
|
|
6115
6401
|
*/
|
|
6116
|
-
export interface Redacted<S extends
|
|
6402
|
+
export interface Redacted<S extends Constraint> extends declareConstructor<Redacted_.Redacted<S["Type"]>, Redacted_.Redacted<S["Encoded"]>, readonly [S]> {
|
|
6117
6403
|
readonly "Rebuild": Redacted<S>;
|
|
6118
6404
|
readonly value: S;
|
|
6119
6405
|
}
|
|
@@ -6137,10 +6423,11 @@ export interface Redacted<S extends Top> extends declareConstructor<Redacted_.Re
|
|
|
6137
6423
|
* into JSON, it will fail with an error. This is useful when the wrapped schema is
|
|
6138
6424
|
* sensitive and should not be exposed in JSON.
|
|
6139
6425
|
*
|
|
6426
|
+
* @see {@link RedactedFromValue} for decoding raw values and wrapping them in `Redacted`.
|
|
6140
6427
|
* @category Redacted
|
|
6141
6428
|
* @since 3.10.0
|
|
6142
6429
|
*/
|
|
6143
|
-
export declare function Redacted<S extends
|
|
6430
|
+
export declare function Redacted<S extends Constraint>(value: S, options?: {
|
|
6144
6431
|
readonly label?: string | undefined;
|
|
6145
6432
|
readonly disallowJsonEncode?: boolean | undefined;
|
|
6146
6433
|
}): Redacted<S>;
|
|
@@ -6150,7 +6437,7 @@ export declare function Redacted<S extends Top>(value: S, options?: {
|
|
|
6150
6437
|
* @category Redacted
|
|
6151
6438
|
* @since 4.0.0
|
|
6152
6439
|
*/
|
|
6153
|
-
export interface RedactedFromValue<S extends
|
|
6440
|
+
export interface RedactedFromValue<S extends Constraint> extends decodeTo<Redacted<toType<S>>, middlewareDecoding<S, S["DecodingServices"]>> {
|
|
6154
6441
|
readonly "Rebuild": RedactedFromValue<S>;
|
|
6155
6442
|
}
|
|
6156
6443
|
/**
|
|
@@ -6160,16 +6447,17 @@ export interface RedactedFromValue<S extends Top> extends decodeTo<Redacted<toTy
|
|
|
6160
6447
|
* @category Redacted
|
|
6161
6448
|
* @since 4.0.0
|
|
6162
6449
|
*/
|
|
6163
|
-
export declare function redact<S extends
|
|
6450
|
+
export declare function redact<S extends Constraint>(schema: S): middlewareDecoding<S, S["DecodingServices"]>;
|
|
6164
6451
|
/**
|
|
6165
6452
|
* Decodes a value and wraps it in `Redacted<A>`. Unlike {@link Redacted} which
|
|
6166
6453
|
* expects the input to already be a `Redacted` instance, this schema decodes
|
|
6167
6454
|
* the raw value and wraps it.
|
|
6168
6455
|
*
|
|
6456
|
+
* @see {@link Redacted} for schemas whose input is already a `Redacted` value.
|
|
6169
6457
|
* @category Redacted
|
|
6170
6458
|
* @since 4.0.0
|
|
6171
6459
|
*/
|
|
6172
|
-
export declare function RedactedFromValue<S extends
|
|
6460
|
+
export declare function RedactedFromValue<S extends Constraint>(value: S, options?: {
|
|
6173
6461
|
readonly label?: string | undefined;
|
|
6174
6462
|
readonly disallowEncode?: boolean | undefined;
|
|
6175
6463
|
}): RedactedFromValue<S>;
|
|
@@ -6179,7 +6467,7 @@ export declare function RedactedFromValue<S extends Top>(value: S, options?: {
|
|
|
6179
6467
|
* @category CauseReason
|
|
6180
6468
|
* @since 4.0.0
|
|
6181
6469
|
*/
|
|
6182
|
-
export interface CauseReason<E extends
|
|
6470
|
+
export interface CauseReason<E extends Constraint, D extends Constraint> extends declareConstructor<Cause_.Reason<E["Type"]>, Cause_.Reason<E["Encoded"]>, readonly [E, D], CauseReasonIso<E, D>> {
|
|
6183
6471
|
readonly "Rebuild": CauseReason<E, D>;
|
|
6184
6472
|
readonly error: E;
|
|
6185
6473
|
readonly defect: D;
|
|
@@ -6195,7 +6483,7 @@ export interface CauseReason<E extends Top, D extends Top> extends declareConstr
|
|
|
6195
6483
|
* @category CauseReason
|
|
6196
6484
|
* @since 4.0.0
|
|
6197
6485
|
*/
|
|
6198
|
-
export type CauseReasonIso<E extends
|
|
6486
|
+
export type CauseReasonIso<E extends Constraint, D extends Constraint> = {
|
|
6199
6487
|
readonly _tag: "Fail";
|
|
6200
6488
|
readonly error: E["Iso"];
|
|
6201
6489
|
} | {
|
|
@@ -6225,14 +6513,14 @@ export type CauseReasonIso<E extends Top, D extends Top> = {
|
|
|
6225
6513
|
* @category CauseReason
|
|
6226
6514
|
* @since 4.0.0
|
|
6227
6515
|
*/
|
|
6228
|
-
export declare function CauseReason<E extends
|
|
6516
|
+
export declare function CauseReason<E extends Constraint, D extends Constraint>(error: E, defect: D): CauseReason<E, D>;
|
|
6229
6517
|
/**
|
|
6230
6518
|
* Type-level representation returned by {@link Cause}.
|
|
6231
6519
|
*
|
|
6232
6520
|
* @category Cause
|
|
6233
6521
|
* @since 3.10.0
|
|
6234
6522
|
*/
|
|
6235
|
-
export interface Cause<E extends
|
|
6523
|
+
export interface Cause<E extends Constraint, D extends Constraint> extends declareConstructor<Cause_.Cause<E["Type"]>, Cause_.Cause<E["Encoded"]>, readonly [E, D], CauseIso<E, D>> {
|
|
6236
6524
|
readonly "Rebuild": Cause<E, D>;
|
|
6237
6525
|
readonly error: E;
|
|
6238
6526
|
readonly defect: D;
|
|
@@ -6252,7 +6540,7 @@ export interface Cause<E extends Top, D extends Top> extends declareConstructor<
|
|
|
6252
6540
|
* @category Cause
|
|
6253
6541
|
* @since 4.0.0
|
|
6254
6542
|
*/
|
|
6255
|
-
export type CauseIso<E extends
|
|
6543
|
+
export type CauseIso<E extends Constraint, D extends Constraint> = ReadonlyArray<CauseReasonIso<E, D>>;
|
|
6256
6544
|
/**
|
|
6257
6545
|
* Creates a schema for `Cause` values using separate schemas for typed failures
|
|
6258
6546
|
* and unexpected defects.
|
|
@@ -6274,7 +6562,7 @@ export type CauseIso<E extends Top, D extends Top> = ReadonlyArray<CauseReasonIs
|
|
|
6274
6562
|
* @category Cause
|
|
6275
6563
|
* @since 3.10.0
|
|
6276
6564
|
*/
|
|
6277
|
-
export declare function Cause<E extends
|
|
6565
|
+
export declare function Cause<E extends Constraint, D extends Constraint>(error: E, defect: D): Cause<E, D>;
|
|
6278
6566
|
/**
|
|
6279
6567
|
* Type-level representation of {@link Error}.
|
|
6280
6568
|
*
|
|
@@ -6378,7 +6666,7 @@ export declare function Defect(options?: ErrorOptions): Defect;
|
|
|
6378
6666
|
* @category Exit
|
|
6379
6667
|
* @since 3.10.0
|
|
6380
6668
|
*/
|
|
6381
|
-
export interface Exit<A extends
|
|
6669
|
+
export interface Exit<A extends Constraint, E extends Constraint, D extends Constraint> extends declareConstructor<Exit_.Exit<A["Type"], E["Type"]>, Exit_.Exit<A["Encoded"], E["Encoded"]>, readonly [A, E, D], ExitIso<A, E, D>> {
|
|
6382
6670
|
readonly "Rebuild": Exit<A, E, D>;
|
|
6383
6671
|
readonly value: A;
|
|
6384
6672
|
readonly error: E;
|
|
@@ -6395,7 +6683,7 @@ export interface Exit<A extends Top, E extends Top, D extends Top> extends decla
|
|
|
6395
6683
|
* @category Exit
|
|
6396
6684
|
* @since 4.0.0
|
|
6397
6685
|
*/
|
|
6398
|
-
export type ExitIso<A extends
|
|
6686
|
+
export type ExitIso<A extends Constraint, E extends Constraint, D extends Constraint> = {
|
|
6399
6687
|
readonly _tag: "Success";
|
|
6400
6688
|
readonly value: A["Iso"];
|
|
6401
6689
|
} | {
|
|
@@ -6414,14 +6702,14 @@ export type ExitIso<A extends Top, E extends Top, D extends Top> = {
|
|
|
6414
6702
|
* @category Exit
|
|
6415
6703
|
* @since 3.10.0
|
|
6416
6704
|
*/
|
|
6417
|
-
export declare function Exit<A extends
|
|
6705
|
+
export declare function Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>;
|
|
6418
6706
|
/**
|
|
6419
6707
|
* Type-level representation returned by {@link ReadonlyMap}.
|
|
6420
6708
|
*
|
|
6421
6709
|
* @category ReadonlyMap
|
|
6422
6710
|
* @since 4.0.0
|
|
6423
6711
|
*/
|
|
6424
|
-
export interface $ReadonlyMap<Key extends
|
|
6712
|
+
export interface $ReadonlyMap<Key extends Constraint, Value extends Constraint> extends declareConstructor<globalThis.ReadonlyMap<Key["Type"], Value["Type"]>, globalThis.ReadonlyMap<Key["Encoded"], Value["Encoded"]>, readonly [Key, Value], ReadonlyMapIso<Key, Value>> {
|
|
6425
6713
|
readonly "Rebuild": $ReadonlyMap<Key, Value>;
|
|
6426
6714
|
readonly key: Key;
|
|
6427
6715
|
readonly value: Value;
|
|
@@ -6433,7 +6721,7 @@ export interface $ReadonlyMap<Key extends Top, Value extends Top> extends declar
|
|
|
6433
6721
|
* @category ReadonlyMap
|
|
6434
6722
|
* @since 4.0.0
|
|
6435
6723
|
*/
|
|
6436
|
-
export type ReadonlyMapIso<Key extends
|
|
6724
|
+
export type ReadonlyMapIso<Key extends Constraint, Value extends Constraint> = ReadonlyArray<readonly [Key["Iso"], Value["Iso"]]>;
|
|
6437
6725
|
/**
|
|
6438
6726
|
* Schema for readonly maps whose keys and values conform to the provided
|
|
6439
6727
|
* schemas.
|
|
@@ -6441,14 +6729,14 @@ export type ReadonlyMapIso<Key extends Top, Value extends Top> = ReadonlyArray<r
|
|
|
6441
6729
|
* @category ReadonlyMap
|
|
6442
6730
|
* @since 3.10.0
|
|
6443
6731
|
*/
|
|
6444
|
-
export declare function ReadonlyMap<Key extends
|
|
6732
|
+
export declare function ReadonlyMap<Key extends Constraint, Value extends Constraint>(key: Key, value: Value): $ReadonlyMap<Key, Value>;
|
|
6445
6733
|
/**
|
|
6446
6734
|
* Type-level representation returned by {@link HashMap}.
|
|
6447
6735
|
*
|
|
6448
6736
|
* @category HashMap
|
|
6449
6737
|
* @since 3.10.0
|
|
6450
6738
|
*/
|
|
6451
|
-
export interface HashMap<Key extends
|
|
6739
|
+
export interface HashMap<Key extends Constraint, Value extends Constraint> extends declareConstructor<HashMap_.HashMap<Key["Type"], Value["Type"]>, HashMap_.HashMap<Key["Encoded"], Value["Encoded"]>, readonly [Key, Value], HashMapIso<Key, Value>> {
|
|
6452
6740
|
readonly "Rebuild": HashMap<Key, Value>;
|
|
6453
6741
|
readonly key: Key;
|
|
6454
6742
|
readonly value: Value;
|
|
@@ -6460,21 +6748,21 @@ export interface HashMap<Key extends Top, Value extends Top> extends declareCons
|
|
|
6460
6748
|
* @category HashMap
|
|
6461
6749
|
* @since 4.0.0
|
|
6462
6750
|
*/
|
|
6463
|
-
export type HashMapIso<Key extends
|
|
6751
|
+
export type HashMapIso<Key extends Constraint, Value extends Constraint> = ReadonlyArray<readonly [Key["Iso"], Value["Iso"]]>;
|
|
6464
6752
|
/**
|
|
6465
6753
|
* Schema for hash maps whose keys and values conform to the provided schemas.
|
|
6466
6754
|
*
|
|
6467
6755
|
* @category HashMap
|
|
6468
6756
|
* @since 3.10.0
|
|
6469
6757
|
*/
|
|
6470
|
-
export declare function HashMap<Key extends
|
|
6758
|
+
export declare function HashMap<Key extends Constraint, Value extends Constraint>(key: Key, value: Value): HashMap<Key, Value>;
|
|
6471
6759
|
/**
|
|
6472
6760
|
* Type-level representation returned by {@link ReadonlySet}.
|
|
6473
6761
|
*
|
|
6474
6762
|
* @category ReadonlySet
|
|
6475
6763
|
* @since 4.0.0
|
|
6476
6764
|
*/
|
|
6477
|
-
export interface $ReadonlySet<Value extends
|
|
6765
|
+
export interface $ReadonlySet<Value extends Constraint> extends declareConstructor<globalThis.ReadonlySet<Value["Type"]>, globalThis.ReadonlySet<Value["Encoded"]>, readonly [Value], ReadonlySetIso<Value>> {
|
|
6478
6766
|
readonly "Rebuild": $ReadonlySet<Value>;
|
|
6479
6767
|
readonly value: Value;
|
|
6480
6768
|
}
|
|
@@ -6485,21 +6773,21 @@ export interface $ReadonlySet<Value extends Top> extends declareConstructor<glob
|
|
|
6485
6773
|
* @category ReadonlySet
|
|
6486
6774
|
* @since 4.0.0
|
|
6487
6775
|
*/
|
|
6488
|
-
export type ReadonlySetIso<Value extends
|
|
6776
|
+
export type ReadonlySetIso<Value extends Constraint> = ReadonlyArray<Value["Iso"]>;
|
|
6489
6777
|
/**
|
|
6490
6778
|
* Schema for readonly sets whose values conform to the provided element schema.
|
|
6491
6779
|
*
|
|
6492
6780
|
* @category ReadonlySet
|
|
6493
6781
|
* @since 3.10.0
|
|
6494
6782
|
*/
|
|
6495
|
-
export declare function ReadonlySet<Value extends
|
|
6783
|
+
export declare function ReadonlySet<Value extends Constraint>(value: Value): $ReadonlySet<Value>;
|
|
6496
6784
|
/**
|
|
6497
6785
|
* Type-level representation returned by {@link HashSet}.
|
|
6498
6786
|
*
|
|
6499
6787
|
* @category HashSet
|
|
6500
6788
|
* @since 3.10.0
|
|
6501
6789
|
*/
|
|
6502
|
-
export interface HashSet<Value extends
|
|
6790
|
+
export interface HashSet<Value extends Constraint> extends declareConstructor<HashSet_.HashSet<Value["Type"]>, HashSet_.HashSet<Value["Encoded"]>, readonly [Value], HashSetIso<Value>> {
|
|
6503
6791
|
readonly "Rebuild": HashSet<Value>;
|
|
6504
6792
|
readonly value: Value;
|
|
6505
6793
|
}
|
|
@@ -6510,21 +6798,21 @@ export interface HashSet<Value extends Top> extends declareConstructor<HashSet_.
|
|
|
6510
6798
|
* @category HashSet
|
|
6511
6799
|
* @since 4.0.0
|
|
6512
6800
|
*/
|
|
6513
|
-
export type HashSetIso<Value extends
|
|
6801
|
+
export type HashSetIso<Value extends Constraint> = ReadonlyArray<Value["Iso"]>;
|
|
6514
6802
|
/**
|
|
6515
6803
|
* Schema for hash sets whose values conform to the provided element schema.
|
|
6516
6804
|
*
|
|
6517
6805
|
* @category HashSet
|
|
6518
6806
|
* @since 3.10.0
|
|
6519
6807
|
*/
|
|
6520
|
-
export declare function HashSet<Value extends
|
|
6808
|
+
export declare function HashSet<Value extends Constraint>(value: Value): HashSet<Value>;
|
|
6521
6809
|
/**
|
|
6522
6810
|
* Type-level representation returned by {@link Chunk}.
|
|
6523
6811
|
*
|
|
6524
6812
|
* @category Chunk
|
|
6525
6813
|
* @since 3.10.0
|
|
6526
6814
|
*/
|
|
6527
|
-
export interface Chunk<Value extends
|
|
6815
|
+
export interface Chunk<Value extends Constraint> extends declareConstructor<Chunk_.Chunk<Value["Type"]>, Chunk_.Chunk<Value["Encoded"]>, readonly [Value], ChunkIso<Value>> {
|
|
6528
6816
|
readonly "Rebuild": Chunk<Value>;
|
|
6529
6817
|
readonly value: Value;
|
|
6530
6818
|
}
|
|
@@ -6542,14 +6830,14 @@ export interface Chunk<Value extends Top> extends declareConstructor<Chunk_.Chun
|
|
|
6542
6830
|
* @category Chunk
|
|
6543
6831
|
* @since 4.0.0
|
|
6544
6832
|
*/
|
|
6545
|
-
export type ChunkIso<Value extends
|
|
6833
|
+
export type ChunkIso<Value extends Constraint> = ReadonlyArray<Value["Iso"]>;
|
|
6546
6834
|
/**
|
|
6547
6835
|
* Schema for chunks whose values conform to the provided element schema.
|
|
6548
6836
|
*
|
|
6549
6837
|
* @category Chunk
|
|
6550
6838
|
* @since 3.10.0
|
|
6551
6839
|
*/
|
|
6552
|
-
export declare function Chunk<Value extends
|
|
6840
|
+
export declare function Chunk<Value extends Constraint>(value: Value): Chunk<Value>;
|
|
6553
6841
|
/**
|
|
6554
6842
|
* Type-level representation of {@link RegExp}.
|
|
6555
6843
|
*
|
|
@@ -6930,7 +7218,7 @@ export declare const UnknownFromJsonString: UnknownFromJsonString;
|
|
|
6930
7218
|
* @category models
|
|
6931
7219
|
* @since 4.0.0
|
|
6932
7220
|
*/
|
|
6933
|
-
export interface fromJsonString<S extends
|
|
7221
|
+
export interface fromJsonString<S extends Constraint> extends decodeTo<S, String> {
|
|
6934
7222
|
readonly "Rebuild": fromJsonString<S>;
|
|
6935
7223
|
}
|
|
6936
7224
|
/**
|
|
@@ -6999,7 +7287,7 @@ export interface fromJsonString<S extends Top> extends decodeTo<S, String> {
|
|
|
6999
7287
|
* @category constructors
|
|
7000
7288
|
* @since 4.0.0
|
|
7001
7289
|
*/
|
|
7002
|
-
export declare function fromJsonString<S extends
|
|
7290
|
+
export declare function fromJsonString<S extends Constraint>(schema: S): fromJsonString<S>;
|
|
7003
7291
|
/**
|
|
7004
7292
|
* Type-level representation of {@link File}.
|
|
7005
7293
|
*
|
|
@@ -7048,7 +7336,7 @@ export declare const FormData: FormData;
|
|
|
7048
7336
|
* @category FormData
|
|
7049
7337
|
* @since 4.0.0
|
|
7050
7338
|
*/
|
|
7051
|
-
export interface fromFormData<S extends
|
|
7339
|
+
export interface fromFormData<S extends Constraint> extends decodeTo<S, FormData> {
|
|
7052
7340
|
readonly "Rebuild": fromFormData<S>;
|
|
7053
7341
|
}
|
|
7054
7342
|
/**
|
|
@@ -7067,10 +7355,8 @@ export interface fromFormData<S extends Top> extends decodeTo<S, FormData> {
|
|
|
7067
7355
|
*
|
|
7068
7356
|
* You can express nested values using bracket notation.
|
|
7069
7357
|
*
|
|
7070
|
-
* If you want to decode
|
|
7071
|
-
* `Schema.toCodecStringTree
|
|
7072
|
-
* This serializer preserves values such as numbers and `Blob` objects when
|
|
7073
|
-
* compatible with the schema.
|
|
7358
|
+
* If you want to decode string fields into non-string primitive values, use
|
|
7359
|
+
* `Schema.toCodecStringTree`.
|
|
7074
7360
|
*
|
|
7075
7361
|
* **Example** (Decoding a flat structure)
|
|
7076
7362
|
*
|
|
@@ -7124,8 +7410,7 @@ export interface fromFormData<S extends Top> extends decodeTo<S, FormData> {
|
|
|
7124
7410
|
* Schema.toCodecStringTree(
|
|
7125
7411
|
* Schema.Struct({
|
|
7126
7412
|
* a: Schema.Int
|
|
7127
|
-
* })
|
|
7128
|
-
* { keepDeclarations: true }
|
|
7413
|
+
* })
|
|
7129
7414
|
* )
|
|
7130
7415
|
* )
|
|
7131
7416
|
*
|
|
@@ -7139,7 +7424,7 @@ export interface fromFormData<S extends Top> extends decodeTo<S, FormData> {
|
|
|
7139
7424
|
* @category decoding
|
|
7140
7425
|
* @since 4.0.0
|
|
7141
7426
|
*/
|
|
7142
|
-
export declare function fromFormData<S extends
|
|
7427
|
+
export declare function fromFormData<S extends Constraint>(schema: S): fromFormData<S>;
|
|
7143
7428
|
/**
|
|
7144
7429
|
* Type-level representation of {@link URLSearchParams}.
|
|
7145
7430
|
*
|
|
@@ -7166,7 +7451,7 @@ export declare const URLSearchParams: URLSearchParams;
|
|
|
7166
7451
|
* @category search params
|
|
7167
7452
|
* @since 4.0.0
|
|
7168
7453
|
*/
|
|
7169
|
-
export interface fromURLSearchParams<S extends
|
|
7454
|
+
export interface fromURLSearchParams<S extends Constraint> extends decodeTo<S, URLSearchParams> {
|
|
7170
7455
|
readonly "Rebuild": fromURLSearchParams<S>;
|
|
7171
7456
|
}
|
|
7172
7457
|
/**
|
|
@@ -7249,7 +7534,7 @@ export interface fromURLSearchParams<S extends Top> extends decodeTo<S, URLSearc
|
|
|
7249
7534
|
* @category decoding
|
|
7250
7535
|
* @since 4.0.0
|
|
7251
7536
|
*/
|
|
7252
|
-
export declare function fromURLSearchParams<S extends
|
|
7537
|
+
export declare function fromURLSearchParams<S extends Constraint>(schema: S): fromURLSearchParams<S>;
|
|
7253
7538
|
/**
|
|
7254
7539
|
* Type-level representation of {@link Finite}.
|
|
7255
7540
|
*
|
|
@@ -7966,9 +8251,16 @@ export declare const DateTimeZonedFromString: DateTimeZonedFromString;
|
|
|
7966
8251
|
* @category models
|
|
7967
8252
|
* @since 3.10.0
|
|
7968
8253
|
*/
|
|
7969
|
-
export interface Class<Self, S extends
|
|
8254
|
+
export interface Class<Self, S extends Constraint & {
|
|
7970
8255
|
readonly fields: Struct.Fields;
|
|
7971
|
-
}, Inherited> extends
|
|
8256
|
+
}, Inherited> extends BottomLazy<SchemaAST.Declaration, decodeTo<declareConstructor<Self, S["Encoded"], readonly [S], S["Iso"]>, S>, readonly [S], S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
8257
|
+
readonly "Type": Self;
|
|
8258
|
+
readonly "Encoded": S["Encoded"];
|
|
8259
|
+
readonly "DecodingServices": S["DecodingServices"];
|
|
8260
|
+
readonly "EncodingServices": S["EncodingServices"];
|
|
8261
|
+
readonly "~type.make.in": RequiredKeys<S["~type.make.in"]> extends never ? void | S["~type.make.in"] : S["~type.make.in"];
|
|
8262
|
+
readonly "~type.make": Self;
|
|
8263
|
+
readonly "Iso": S["Iso"];
|
|
7972
8264
|
new (...args: {} extends S["~type.make.in"] ? [props?: S["~type.make.in"], options?: MakeOptions] : [props: S["~type.make.in"], options?: MakeOptions]): S["Type"] & Inherited;
|
|
7973
8265
|
readonly identifier: string;
|
|
7974
8266
|
readonly fields: S["fields"];
|
|
@@ -8626,7 +8918,7 @@ export type LazyArbitrary<T> = (fc: typeof FastCheck) => FastCheck.Arbitrary<T>;
|
|
|
8626
8918
|
* @category Arbitrary
|
|
8627
8919
|
* @since 4.0.0
|
|
8628
8920
|
*/
|
|
8629
|
-
export declare function toArbitraryLazy<S extends
|
|
8921
|
+
export declare function toArbitraryLazy<S extends Constraint>(schema: S): LazyArbitrary<S["Type"]>;
|
|
8630
8922
|
/**
|
|
8631
8923
|
* Derives a `fast-check` `Arbitrary` from a schema for property-based
|
|
8632
8924
|
* testing. The derived arbitrary generates values that satisfy the schema.
|
|
@@ -8656,8 +8948,8 @@ export declare function toArbitraryLazy<S extends Top>(schema: S): LazyArbitrary
|
|
|
8656
8948
|
* @category Arbitrary
|
|
8657
8949
|
* @since 4.0.0
|
|
8658
8950
|
*/
|
|
8659
|
-
export declare function toArbitrary<S extends
|
|
8660
|
-
export declare function toArbitrary<S extends
|
|
8951
|
+
export declare function toArbitrary<S extends Constraint>(schema: S): FastCheck.Arbitrary<S["Type"]>;
|
|
8952
|
+
export declare function toArbitrary<S extends Constraint>(schema: S, options: {
|
|
8661
8953
|
readonly report: true;
|
|
8662
8954
|
}): Annotations.ToArbitrary.WithReport<FastCheck.Arbitrary<S["Type"]>>;
|
|
8663
8955
|
/**
|
|
@@ -8686,9 +8978,9 @@ export declare function overrideToFormatter<S extends Top>(toFormatter: () => Fo
|
|
|
8686
8978
|
* @category Formatter
|
|
8687
8979
|
* @since 4.0.0
|
|
8688
8980
|
*/
|
|
8689
|
-
export declare function toFormatter<
|
|
8981
|
+
export declare function toFormatter<S extends Constraint>(schema: S, options?: {
|
|
8690
8982
|
readonly onBefore?: ((ast: SchemaAST.AST, recur: (ast: SchemaAST.AST) => Formatter<any>) => Formatter<any> | undefined) | undefined;
|
|
8691
|
-
}): Formatter<
|
|
8983
|
+
}): Formatter<S["Type"]>;
|
|
8692
8984
|
/**
|
|
8693
8985
|
* Overrides the equivalence derivation for a schema by supplying a custom
|
|
8694
8986
|
* `Equivalence`.
|
|
@@ -8730,7 +9022,7 @@ export declare function toEquivalence<T>(schema: Schema<T>): Equivalence.Equival
|
|
|
8730
9022
|
* @category Representation
|
|
8731
9023
|
* @since 4.0.0
|
|
8732
9024
|
*/
|
|
8733
|
-
export declare function toRepresentation(schema:
|
|
9025
|
+
export declare function toRepresentation(schema: Constraint): SchemaRepresentation.Document;
|
|
8734
9026
|
/**
|
|
8735
9027
|
* Options for {@link toJsonSchemaDocument}.
|
|
8736
9028
|
*
|
|
@@ -8823,7 +9115,22 @@ export interface ToJsonSchemaOptions {
|
|
|
8823
9115
|
* @category converting
|
|
8824
9116
|
* @since 4.0.0
|
|
8825
9117
|
*/
|
|
8826
|
-
export declare function toJsonSchemaDocument(schema:
|
|
9118
|
+
export declare function toJsonSchemaDocument(schema: Constraint, options?: ToJsonSchemaOptions): JsonSchema.Document<"draft-2020-12">;
|
|
9119
|
+
/**
|
|
9120
|
+
* Type-level representation returned by {@link toCodecJson}.
|
|
9121
|
+
*
|
|
9122
|
+
* @category Canonical Codecs
|
|
9123
|
+
* @since 4.0.0
|
|
9124
|
+
*/
|
|
9125
|
+
export interface toCodecJson<S extends Constraint> extends BottomLazy<S["ast"], toCodecJson<S>, S["~type.parameters"], S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
9126
|
+
readonly "Type": S["Type"];
|
|
9127
|
+
readonly "Encoded": Json;
|
|
9128
|
+
readonly "DecodingServices": S["DecodingServices"];
|
|
9129
|
+
readonly "EncodingServices": S["EncodingServices"];
|
|
9130
|
+
readonly "~type.make.in": S["~type.make.in"];
|
|
9131
|
+
readonly "~type.make": S["~type.make"];
|
|
9132
|
+
readonly "Iso": S["Iso"];
|
|
9133
|
+
}
|
|
8827
9134
|
/**
|
|
8828
9135
|
* Derives a canonical JSON codec from a schema. The encoded form is `Json`, and
|
|
8829
9136
|
* decoding produces the schema's `Type`.
|
|
@@ -8831,7 +9138,7 @@ export declare function toJsonSchemaDocument(schema: Top, options?: ToJsonSchema
|
|
|
8831
9138
|
* @category Canonical Codecs
|
|
8832
9139
|
* @since 4.0.0
|
|
8833
9140
|
*/
|
|
8834
|
-
export declare function toCodecJson<
|
|
9141
|
+
export declare function toCodecJson<S extends Constraint>(schema: S): toCodecJson<S>;
|
|
8835
9142
|
/**
|
|
8836
9143
|
* Derives an isomorphism codec from a schema. The encoded form is the
|
|
8837
9144
|
* schema's `Iso` type — the intermediate representation used for round-tripping.
|
|
@@ -8839,7 +9146,7 @@ export declare function toCodecJson<T, E, RD, RE>(schema: Codec<T, E, RD, RE>):
|
|
|
8839
9146
|
* @category Canonical Codecs
|
|
8840
9147
|
* @since 4.0.0
|
|
8841
9148
|
*/
|
|
8842
|
-
export declare function toCodecIso<S extends
|
|
9149
|
+
export declare function toCodecIso<S extends Constraint>(schema: S): Codec<S["Type"], S["Iso"]>;
|
|
8843
9150
|
/**
|
|
8844
9151
|
* A {@link Tree} of `string | undefined` nodes. Leaf values are either a
|
|
8845
9152
|
* string representation or `undefined` for opaque/declaration types.
|
|
@@ -8848,6 +9155,21 @@ export declare function toCodecIso<S extends Top>(schema: S): Codec<S["Type"], S
|
|
|
8848
9155
|
* @since 4.0.0
|
|
8849
9156
|
*/
|
|
8850
9157
|
export type StringTree = Tree<string | undefined>;
|
|
9158
|
+
/**
|
|
9159
|
+
* Type-level representation returned by {@link toCodecStringTree}.
|
|
9160
|
+
*
|
|
9161
|
+
* @category Canonical Codecs
|
|
9162
|
+
* @since 4.0.0
|
|
9163
|
+
*/
|
|
9164
|
+
export interface toCodecStringTree<S extends Constraint> extends BottomLazy<S["ast"], toCodecStringTree<S>, ReadonlyArray<Constraint>, S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
9165
|
+
readonly "Type": S["Type"];
|
|
9166
|
+
readonly "Encoded": StringTree;
|
|
9167
|
+
readonly "DecodingServices": S["DecodingServices"];
|
|
9168
|
+
readonly "EncodingServices": S["EncodingServices"];
|
|
9169
|
+
readonly "~type.make.in": S["~type.make.in"];
|
|
9170
|
+
readonly "~type.make": S["~type.make"];
|
|
9171
|
+
readonly "Iso": S["Iso"];
|
|
9172
|
+
}
|
|
8851
9173
|
/**
|
|
8852
9174
|
* Converts a schema to the StringTree canonical codec, where every leaf value
|
|
8853
9175
|
* becomes a string while preserving the original structure.
|
|
@@ -8857,21 +9179,44 @@ export type StringTree = Tree<string | undefined>;
|
|
|
8857
9179
|
* Declarations are converted to `undefined` (unless they have a
|
|
8858
9180
|
* `toCodecJson` or `toCodec` annotation).
|
|
8859
9181
|
*
|
|
8860
|
-
*
|
|
9182
|
+
* @category Canonical Codecs
|
|
9183
|
+
* @since 4.0.0
|
|
9184
|
+
*/
|
|
9185
|
+
export declare function toCodecStringTree<S extends Constraint>(schema: S): toCodecStringTree<S>;
|
|
9186
|
+
/**
|
|
9187
|
+
* Type-level representation returned by {@link toCodecArrayFromSingle}.
|
|
8861
9188
|
*
|
|
8862
|
-
*
|
|
8863
|
-
*
|
|
8864
|
-
|
|
9189
|
+
* @category Canonical Codecs
|
|
9190
|
+
* @since 4.0.0
|
|
9191
|
+
*/
|
|
9192
|
+
export interface toCodecArrayFromSingle<S extends Constraint> extends BottomLazy<S["ast"], toCodecArrayFromSingle<S>, S["~type.parameters"], S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
9193
|
+
readonly "Type": S["Type"];
|
|
9194
|
+
readonly "Encoded": S["Encoded"];
|
|
9195
|
+
readonly "DecodingServices": S["DecodingServices"];
|
|
9196
|
+
readonly "EncodingServices": S["EncodingServices"];
|
|
9197
|
+
readonly "~type.make.in": S["~type.make.in"];
|
|
9198
|
+
readonly "~type.make": S["~type.make"];
|
|
9199
|
+
readonly "Iso": S["Iso"];
|
|
9200
|
+
}
|
|
9201
|
+
/**
|
|
9202
|
+
* Allows array schemas to decode from either an array input or a single value
|
|
9203
|
+
* input.
|
|
8865
9204
|
*
|
|
8866
|
-
*
|
|
9205
|
+
* **When to use**
|
|
9206
|
+
*
|
|
9207
|
+
* Use when you need to accept transport formats that may represent a
|
|
9208
|
+
* single-item array as a bare value, such as query-string or form-data adapters.
|
|
9209
|
+
*
|
|
9210
|
+
* **Gotchas**
|
|
9211
|
+
*
|
|
9212
|
+
* This combinator is intentionally not part of `toCodecStringTree`; it adds a
|
|
9213
|
+
* decoding convenience rather than a canonical StringTree representation. It
|
|
9214
|
+
* does not parse comma-separated strings.
|
|
8867
9215
|
*
|
|
8868
9216
|
* @category Canonical Codecs
|
|
8869
9217
|
* @since 4.0.0
|
|
8870
9218
|
*/
|
|
8871
|
-
export declare function
|
|
8872
|
-
export declare function toCodecStringTree<T, E, RD, RE>(schema: Codec<T, E, RD, RE>, options: {
|
|
8873
|
-
readonly keepDeclarations: true;
|
|
8874
|
-
}): Codec<T, unknown, RD, RE>;
|
|
9219
|
+
export declare function toCodecArrayFromSingle<S extends Constraint>(schema: S): toCodecArrayFromSingle<S>;
|
|
8875
9220
|
type XmlEncoderOptions = {
|
|
8876
9221
|
/** Root element name for the returned XML string. Default: "root" */
|
|
8877
9222
|
readonly rootName?: string | undefined;
|
|
@@ -8904,28 +9249,35 @@ export declare function toEncoderXml<T, E, RD, RE>(codec: Codec<T, E, RD, RE>, o
|
|
|
8904
9249
|
* @category Optic
|
|
8905
9250
|
* @since 4.0.0
|
|
8906
9251
|
*/
|
|
8907
|
-
export declare function toIso<S extends
|
|
9252
|
+
export declare function toIso<S extends Constraint>(schema: S): Optic_.Iso<S["Type"], S["Iso"]>;
|
|
8908
9253
|
/**
|
|
8909
9254
|
* Returns an identity `Iso` over the schema's source (`Type`) side.
|
|
8910
9255
|
*
|
|
8911
9256
|
* @category Optic
|
|
8912
9257
|
* @since 4.0.0
|
|
8913
9258
|
*/
|
|
8914
|
-
export declare function toIsoSource<S extends
|
|
9259
|
+
export declare function toIsoSource<S extends Constraint>(_: S): Optic_.Iso<S["Type"], S["Type"]>;
|
|
8915
9260
|
/**
|
|
8916
9261
|
* Returns an identity `Iso` over the schema's focus (`Iso`) side.
|
|
8917
9262
|
*
|
|
8918
9263
|
* @category Optic
|
|
8919
9264
|
* @since 4.0.0
|
|
8920
9265
|
*/
|
|
8921
|
-
export declare function toIsoFocus<S extends
|
|
9266
|
+
export declare function toIsoFocus<S extends Constraint>(_: S): Optic_.Iso<S["Iso"], S["Iso"]>;
|
|
8922
9267
|
/**
|
|
8923
9268
|
* Type-level representation returned by {@link overrideToCodecIso}.
|
|
8924
9269
|
*
|
|
8925
9270
|
* @category Optic
|
|
8926
9271
|
* @since 4.0.0
|
|
8927
9272
|
*/
|
|
8928
|
-
export interface overrideToCodecIso<S extends
|
|
9273
|
+
export interface overrideToCodecIso<S extends Constraint, Iso> extends BottomLazy<S["ast"], overrideToCodecIso<S, Iso>, S["~type.parameters"], S["~type.mutability"], S["~type.optionality"], S["~type.constructor.default"], S["~encoded.mutability"], S["~encoded.optionality"]> {
|
|
9274
|
+
readonly "Type": S["Type"];
|
|
9275
|
+
readonly "Encoded": S["Encoded"];
|
|
9276
|
+
readonly "DecodingServices": S["DecodingServices"];
|
|
9277
|
+
readonly "EncodingServices": S["EncodingServices"];
|
|
9278
|
+
readonly "~type.make.in": S["~type.make.in"];
|
|
9279
|
+
readonly "~type.make": S["~type.make"];
|
|
9280
|
+
readonly "Iso": Iso;
|
|
8929
9281
|
readonly schema: S;
|
|
8930
9282
|
}
|
|
8931
9283
|
/**
|
|
@@ -8945,7 +9297,7 @@ export interface overrideToCodecIso<S extends Top, Iso> extends Bottom<S["Type"]
|
|
|
8945
9297
|
* @category Optic
|
|
8946
9298
|
* @since 4.0.0
|
|
8947
9299
|
*/
|
|
8948
|
-
export declare function overrideToCodecIso<S extends
|
|
9300
|
+
export declare function overrideToCodecIso<S extends Constraint, Iso>(to: Codec<Iso>, transformation: {
|
|
8949
9301
|
readonly decode: SchemaGetter.Getter<S["Type"], Iso>;
|
|
8950
9302
|
readonly encode: SchemaGetter.Getter<Iso, S["Type"]>;
|
|
8951
9303
|
}): (schema: S) => overrideToCodecIso<S, Iso>;
|
|
@@ -8984,7 +9336,7 @@ export interface TreeRecord<A> {
|
|
|
8984
9336
|
* @category Tree
|
|
8985
9337
|
* @since 4.0.0
|
|
8986
9338
|
*/
|
|
8987
|
-
export declare function Tree<S extends
|
|
9339
|
+
export declare function Tree<S extends Constraint>(node: S): Union<readonly [S, $Array<suspend<Codec<Tree<S["Type"]>, Tree<S["Encoded"]>, S["DecodingServices"], S["EncodingServices"]>>>, $Record<String, suspend<Codec<Tree<S["Type"]>, Tree<S["Encoded"]>, S["DecodingServices"], S["EncodingServices"]>>>]>;
|
|
8988
9340
|
/**
|
|
8989
9341
|
* Recursive TypeScript type for any valid immutable JSON value: `null`,
|
|
8990
9342
|
* `number`, `boolean`, `string`, a readonly array of `Json` values, or a
|
|
@@ -9070,7 +9422,7 @@ export declare const MutableJson: Codec<MutableJson>;
|
|
|
9070
9422
|
* @category Schema Resolvers
|
|
9071
9423
|
* @since 4.0.0
|
|
9072
9424
|
*/
|
|
9073
|
-
export declare function resolveAnnotations<S extends
|
|
9425
|
+
export declare function resolveAnnotations<S extends Constraint>(schema: S): Annotations.Bottom<S["Type"], S["~type.parameters"]> | undefined;
|
|
9074
9426
|
/**
|
|
9075
9427
|
* Resolves the context (key-level) annotations from a schema. Context
|
|
9076
9428
|
* annotations are those attached via `annotateKey` and live on the AST's
|
|
@@ -9079,7 +9431,7 @@ export declare function resolveAnnotations<S extends Top>(schema: S): Annotation
|
|
|
9079
9431
|
* @category Schema Resolvers
|
|
9080
9432
|
* @since 4.0.0
|
|
9081
9433
|
*/
|
|
9082
|
-
export declare function resolveAnnotationsKey<S extends
|
|
9434
|
+
export declare function resolveAnnotationsKey<S extends Constraint>(schema: S): Annotations.Key<S["Type"]> | undefined;
|
|
9083
9435
|
/**
|
|
9084
9436
|
* The `Annotations` namespace groups all annotation interfaces used to attach
|
|
9085
9437
|
* metadata to schemas. Annotations control documentation, validation messages,
|
|
@@ -9201,7 +9553,7 @@ export declare namespace Annotations {
|
|
|
9201
9553
|
* @category models
|
|
9202
9554
|
* @since 4.0.0
|
|
9203
9555
|
*/
|
|
9204
|
-
interface Bottom<T, TypeParameters extends ReadonlyArray<
|
|
9556
|
+
interface Bottom<T, TypeParameters extends ReadonlyArray<Constraint>> extends Documentation<T> {
|
|
9205
9557
|
/**
|
|
9206
9558
|
* Complete message to use when this schema node reports an issue.
|
|
9207
9559
|
*
|
|
@@ -9258,7 +9610,7 @@ export declare namespace Annotations {
|
|
|
9258
9610
|
* @category utility types
|
|
9259
9611
|
* @since 4.0.0
|
|
9260
9612
|
*/
|
|
9261
|
-
type Type<TypeParameters extends ReadonlyArray<
|
|
9613
|
+
type Type<TypeParameters extends ReadonlyArray<Constraint>> = {
|
|
9262
9614
|
readonly [K in keyof TypeParameters]: Codec<TypeParameters[K]["Type"]>;
|
|
9263
9615
|
};
|
|
9264
9616
|
/**
|
|
@@ -9267,7 +9619,7 @@ export declare namespace Annotations {
|
|
|
9267
9619
|
* @category utility types
|
|
9268
9620
|
* @since 4.0.0
|
|
9269
9621
|
*/
|
|
9270
|
-
type Encoded<TypeParameters extends ReadonlyArray<
|
|
9622
|
+
type Encoded<TypeParameters extends ReadonlyArray<Constraint>> = {
|
|
9271
9623
|
readonly [K in keyof TypeParameters]: Codec<TypeParameters[K]["Encoded"]>;
|
|
9272
9624
|
};
|
|
9273
9625
|
}
|
|
@@ -9281,7 +9633,7 @@ export declare namespace Annotations {
|
|
|
9281
9633
|
* @category models
|
|
9282
9634
|
* @since 4.0.0
|
|
9283
9635
|
*/
|
|
9284
|
-
interface Declaration<T, TypeParameters extends ReadonlyArray<
|
|
9636
|
+
interface Declaration<T, TypeParameters extends ReadonlyArray<Constraint> = readonly []> extends Bottom<T, TypeParameters> {
|
|
9285
9637
|
readonly toCodec?: ((typeParameters: TypeParameters.Encoded<TypeParameters>) => SchemaAST.Link) | undefined;
|
|
9286
9638
|
readonly toCodecJson?: ((typeParameters: TypeParameters.Encoded<TypeParameters>) => SchemaAST.Link) | undefined;
|
|
9287
9639
|
readonly toCodecIso?: ((typeParameters: TypeParameters.Type<TypeParameters>) => SchemaAST.Link) | undefined;
|
|
@@ -9376,7 +9728,7 @@ export declare namespace Annotations {
|
|
|
9376
9728
|
* @since 4.0.0
|
|
9377
9729
|
*/
|
|
9378
9730
|
interface Filter {
|
|
9379
|
-
readonly constraint?:
|
|
9731
|
+
readonly constraint?: GenerationConstraint | undefined;
|
|
9380
9732
|
readonly candidate?: Candidate | undefined;
|
|
9381
9733
|
}
|
|
9382
9734
|
/**
|
|
@@ -9422,10 +9774,10 @@ export declare namespace Annotations {
|
|
|
9422
9774
|
*
|
|
9423
9775
|
* **Details**
|
|
9424
9776
|
*
|
|
9425
|
-
* `
|
|
9426
|
-
* self-describing validation contract. Each generator consumes
|
|
9427
|
-
* understands for the current node and ignores the rest;
|
|
9428
|
-
* filters still validate every generated value.
|
|
9777
|
+
* `GenerationConstraint` is a generation hint for the current schema AST
|
|
9778
|
+
* node, not a self-describing validation contract. Each generator consumes
|
|
9779
|
+
* the fields it understands for the current node and ignores the rest;
|
|
9780
|
+
* final schema filters still validate every generated value.
|
|
9429
9781
|
*
|
|
9430
9782
|
* `minLength` and `maxLength` represent node-local cardinality: string
|
|
9431
9783
|
* length for strings, array length for arrays, final own-property count for
|
|
@@ -9438,7 +9790,7 @@ export declare namespace Annotations {
|
|
|
9438
9790
|
* @category models
|
|
9439
9791
|
* @since 4.0.0
|
|
9440
9792
|
*/
|
|
9441
|
-
interface
|
|
9793
|
+
interface GenerationConstraint {
|
|
9442
9794
|
readonly minLength?: number | undefined;
|
|
9443
9795
|
readonly maxLength?: number | undefined;
|
|
9444
9796
|
readonly patterns?: readonly [string, ...Array<string>];
|
|
@@ -9479,7 +9831,7 @@ export declare namespace Annotations {
|
|
|
9479
9831
|
* @since 4.0.0
|
|
9480
9832
|
*/
|
|
9481
9833
|
interface Context {
|
|
9482
|
-
readonly constraint?: ToArbitrary.
|
|
9834
|
+
readonly constraint?: ToArbitrary.GenerationConstraint | undefined;
|
|
9483
9835
|
readonly recursion?: ToArbitrary.Recursion | undefined;
|
|
9484
9836
|
}
|
|
9485
9837
|
/**
|
|
@@ -9541,7 +9893,7 @@ export declare namespace Annotations {
|
|
|
9541
9893
|
* @category models
|
|
9542
9894
|
* @since 4.0.0
|
|
9543
9895
|
*/
|
|
9544
|
-
interface Declaration<T, TypeParameters extends ReadonlyArray<
|
|
9896
|
+
interface Declaration<T, TypeParameters extends ReadonlyArray<Constraint>> {
|
|
9545
9897
|
(typeParameters: {
|
|
9546
9898
|
readonly [K in keyof TypeParameters]: TypeParameter<TypeParameters[K]["Type"]>;
|
|
9547
9899
|
}): (fc: typeof FastCheck, context: Context) => Output<T>;
|
|
@@ -9612,7 +9964,7 @@ export declare namespace Annotations {
|
|
|
9612
9964
|
* @category models
|
|
9613
9965
|
* @since 4.0.0
|
|
9614
9966
|
*/
|
|
9615
|
-
interface Declaration<T, TypeParameters extends ReadonlyArray<
|
|
9967
|
+
interface Declaration<T, TypeParameters extends ReadonlyArray<Constraint>> {
|
|
9616
9968
|
(typeParameters: {
|
|
9617
9969
|
readonly [K in keyof TypeParameters]: Formatter<TypeParameters[K]["Type"]>;
|
|
9618
9970
|
}): Formatter<T>;
|
|
@@ -9635,7 +9987,7 @@ export declare namespace Annotations {
|
|
|
9635
9987
|
* @category models
|
|
9636
9988
|
* @since 4.0.0
|
|
9637
9989
|
*/
|
|
9638
|
-
interface Declaration<T, TypeParameters extends ReadonlyArray<
|
|
9990
|
+
interface Declaration<T, TypeParameters extends ReadonlyArray<Constraint>> {
|
|
9639
9991
|
(typeParameters: {
|
|
9640
9992
|
readonly [K in keyof TypeParameters]: Equivalence.Equivalence<TypeParameters[K]["Type"]>;
|
|
9641
9993
|
}): Equivalence.Equivalence<T>;
|