effect 4.0.0-beta.83 → 4.0.0-beta.85
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/Array.d.ts +64 -64
- package/dist/Array.js +26 -26
- package/dist/Cache.d.ts +1 -1
- package/dist/Cache.js +1 -1
- package/dist/Cause.d.ts +68 -68
- package/dist/Cause.js +47 -47
- package/dist/Channel.d.ts +5 -5
- package/dist/Channel.js +3 -3
- package/dist/Clock.d.ts +1 -1
- package/dist/Clock.js +1 -1
- package/dist/Combiner.d.ts +9 -9
- package/dist/Combiner.js +8 -8
- package/dist/Config.d.ts +15 -94
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +22 -70
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +58 -74
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +66 -41
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Console.d.ts +1 -1
- package/dist/Console.js +1 -1
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js +4 -3
- package/dist/Context.js.map +1 -1
- package/dist/Data.d.ts +15 -15
- package/dist/Data.js +3 -3
- package/dist/DateTime.d.ts +6 -6
- package/dist/DateTime.js +2 -2
- package/dist/Duration.d.ts +3 -3
- package/dist/Duration.js +3 -3
- package/dist/Effect.d.ts +84 -45
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +72 -33
- package/dist/Effect.js.map +1 -1
- package/dist/Equal.d.ts +7 -7
- package/dist/Equal.js +5 -5
- package/dist/Equivalence.d.ts +17 -17
- package/dist/Equivalence.js +13 -13
- package/dist/Exit.d.ts +3 -3
- package/dist/Exit.js +3 -3
- package/dist/Formatter.d.ts +5 -5
- package/dist/Formatter.js +4 -4
- package/dist/Function.d.ts +10 -10
- package/dist/Function.js +3 -3
- package/dist/HashMap.d.ts +3 -3
- package/dist/HashMap.js +1 -1
- package/dist/Iterable.d.ts +6 -6
- package/dist/Iterable.js +2 -2
- package/dist/JsonPatch.d.ts +2 -2
- package/dist/Layer.d.ts +1 -1
- package/dist/Layer.js +5 -4
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +4 -3
- package/dist/LayerMap.js.map +1 -1
- package/dist/Logger.d.ts +1 -1
- package/dist/Logger.js +1 -1
- package/dist/Match.d.ts +8 -8
- package/dist/Match.js +8 -8
- package/dist/Metric.d.ts +3 -3
- package/dist/Metric.js +3 -3
- package/dist/Optic.d.ts +30 -30
- package/dist/Optic.js +12 -12
- package/dist/Option.d.ts +7 -7
- package/dist/Option.js +7 -7
- package/dist/Order.d.ts +23 -23
- package/dist/Order.js +20 -20
- package/dist/Pool.d.ts +1 -1
- package/dist/Pool.js +1 -1
- package/dist/Predicate.d.ts +88 -88
- package/dist/Predicate.js +47 -47
- package/dist/PubSub.d.ts +3 -3
- package/dist/PubSub.js +3 -3
- package/dist/Random.d.ts +31 -0
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +32 -0
- package/dist/Random.js.map +1 -1
- package/dist/Reducer.d.ts +1 -1
- package/dist/Reducer.js +1 -1
- package/dist/Result.d.ts +18 -18
- package/dist/Result.js +8 -8
- package/dist/Runtime.d.ts +1 -1
- package/dist/Runtime.js +1 -1
- package/dist/Schema.d.ts +313 -126
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +316 -127
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +9 -8
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +203 -140
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +48 -48
- package/dist/SchemaGetter.js +44 -44
- package/dist/SchemaIssue.d.ts +3 -3
- package/dist/SchemaIssue.js +3 -3
- package/dist/SchemaParser.d.ts +122 -22
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +186 -50
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +1 -1
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +96 -2
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +20 -20
- package/dist/SchemaTransformation.js +18 -18
- package/dist/Stream.d.ts +3 -3
- package/dist/Stream.js +2 -2
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +1 -1
- package/dist/String.js +1 -1
- package/dist/Struct.d.ts +1 -1
- package/dist/Struct.js +1 -1
- package/dist/Types.d.ts +13 -13
- package/dist/internal/effect.js +33 -20
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/schema/arbitrary.js +17 -1
- package/dist/internal/schema/arbitrary.js.map +1 -1
- package/dist/internal/schema/cause.d.ts +2 -0
- package/dist/internal/schema/cause.d.ts.map +1 -0
- package/dist/internal/schema/cause.js +24 -0
- package/dist/internal/schema/cause.js.map +1 -0
- package/dist/internal/schema/schema.d.ts +8 -4
- package/dist/internal/schema/schema.d.ts.map +1 -1
- package/dist/internal/schema/schema.js +21 -8
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/stackTraceLimit.d.ts +2 -0
- package/dist/internal/stackTraceLimit.d.ts.map +1 -0
- package/dist/internal/stackTraceLimit.js +40 -0
- package/dist/internal/stackTraceLimit.js.map +1 -0
- package/dist/internal/tracer.d.ts.map +1 -1
- package/dist/internal/tracer.js +4 -3
- package/dist/internal/tracer.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +3 -3
- package/dist/testing/TestSchema.js +1 -1
- package/dist/unstable/ai/AiError.d.ts +1 -1
- package/dist/unstable/ai/AiError.js +1 -1
- package/dist/unstable/ai/Chat.d.ts +1 -1
- package/dist/unstable/ai/Chat.js +1 -1
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +4 -5
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/cli/Prompt.js +2 -2
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +4 -3
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts +2 -2
- package/dist/unstable/persistence/PersistedQueue.js +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +1 -1
- package/dist/unstable/rpc/Rpc.js +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcGroup.js +3 -4
- package/dist/unstable/rpc/RpcGroup.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js +4 -3
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
- package/dist/unstable/sql/SqlResolver.js +15 -2
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +1 -0
- package/dist/unstable/workflow/Activity.d.ts.map +1 -1
- package/dist/unstable/workflow/Activity.js +1 -0
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +65 -65
- package/src/Cache.ts +1 -1
- package/src/Cause.ts +68 -68
- package/src/Channel.ts +5 -5
- package/src/Clock.ts +1 -1
- package/src/Combiner.ts +9 -9
- package/src/Config.ts +40 -108
- package/src/ConfigProvider.ts +139 -100
- package/src/Console.ts +1 -1
- package/src/Context.ts +4 -5
- package/src/Data.ts +15 -15
- package/src/DateTime.ts +6 -6
- package/src/Duration.ts +3 -3
- package/src/Effect.ts +89 -45
- package/src/Equal.ts +7 -7
- package/src/Equivalence.ts +17 -17
- package/src/Exit.ts +3 -3
- package/src/Formatter.ts +5 -5
- package/src/Function.ts +10 -10
- package/src/HashMap.ts +3 -3
- package/src/Iterable.ts +6 -6
- package/src/JsonPatch.ts +2 -2
- package/src/Layer.ts +5 -5
- package/src/LayerMap.ts +4 -3
- package/src/Logger.ts +1 -1
- package/src/Match.ts +8 -8
- package/src/Metric.ts +3 -3
- package/src/Optic.ts +30 -30
- package/src/Option.ts +7 -7
- package/src/Order.ts +23 -23
- package/src/Pool.ts +1 -1
- package/src/Predicate.ts +88 -88
- package/src/PubSub.ts +3 -3
- package/src/Random.ts +42 -0
- package/src/Reducer.ts +1 -1
- package/src/Result.ts +20 -20
- package/src/Runtime.ts +1 -1
- package/src/Schema.ts +389 -153
- package/src/SchemaAST.ts +237 -148
- package/src/SchemaGetter.ts +48 -48
- package/src/SchemaIssue.ts +3 -3
- package/src/SchemaParser.ts +197 -58
- package/src/SchemaRepresentation.ts +73 -3
- package/src/SchemaTransformation.ts +20 -20
- package/src/Stream.ts +4 -4
- package/src/String.ts +1 -1
- package/src/Struct.ts +1 -1
- package/src/Types.ts +13 -13
- package/src/internal/effect.ts +40 -21
- package/src/internal/schema/arbitrary.ts +23 -2
- package/src/internal/schema/cause.ts +26 -0
- package/src/internal/schema/schema.ts +36 -10
- package/src/internal/stackTraceLimit.ts +63 -0
- package/src/internal/tracer.ts +4 -3
- package/src/testing/TestSchema.ts +3 -3
- package/src/unstable/ai/AiError.ts +1 -1
- package/src/unstable/ai/Chat.ts +1 -1
- package/src/unstable/ai/Tool.ts +4 -3
- package/src/unstable/cli/Prompt.ts +1 -1
- package/src/unstable/httpapi/HttpApiMiddleware.ts +4 -3
- package/src/unstable/httpapi/HttpApiScalar.ts +2 -2
- package/src/unstable/persistence/PersistedQueue.ts +1 -1
- package/src/unstable/rpc/Rpc.ts +1 -1
- package/src/unstable/rpc/RpcGroup.ts +3 -4
- package/src/unstable/rpc/RpcMiddleware.ts +4 -3
- package/src/unstable/sql/SqlResolver.ts +15 -2
- package/src/unstable/workflow/Activity.ts +2 -0
- package/src/unstable/workflow/WorkflowEngine.ts +1 -1
package/src/Schema.ts
CHANGED
|
@@ -202,6 +202,8 @@ export interface Bottom<
|
|
|
202
202
|
*
|
|
203
203
|
* Throws an `Error` with the schema issue in its `cause` when validation
|
|
204
204
|
* fails.
|
|
205
|
+
* Causes that contain defects, interruptions, or other non-schema reasons
|
|
206
|
+
* throw with the underlying `Cause` attached instead.
|
|
205
207
|
*
|
|
206
208
|
* @see {@link Bottom.makeOption} — construct synchronously and discard validation details
|
|
207
209
|
* @see {@link Bottom.makeEffect} — construct through `Effect` when validation failure should stay in the error channel
|
|
@@ -221,6 +223,12 @@ export interface Bottom<
|
|
|
221
223
|
* Applies constructor defaults and type-side validation according to
|
|
222
224
|
* `MakeOptions`.
|
|
223
225
|
*
|
|
226
|
+
* **Gotchas**
|
|
227
|
+
*
|
|
228
|
+
* Only causes made entirely of schema issues are converted to `None`. Causes
|
|
229
|
+
* that contain defects, interruptions, or other non-schema reasons throw
|
|
230
|
+
* instead.
|
|
231
|
+
*
|
|
224
232
|
* @see {@link Bottom.make} — construct synchronously when validation failure should throw
|
|
225
233
|
* @see {@link Bottom.makeEffect} — construct through `Effect` when validation details should stay in the error channel
|
|
226
234
|
*/
|
|
@@ -358,7 +366,7 @@ export interface declare<T, Iso = T> extends declareConstructor<T, T, readonly [
|
|
|
358
366
|
* Use when you are defining a schema for an opaque type with no type parameters
|
|
359
367
|
* and validation can be expressed as a type guard.
|
|
360
368
|
*
|
|
361
|
-
* **Example** (
|
|
369
|
+
* **Example** (Defining a schema for a custom `UserId` branded type)
|
|
362
370
|
*
|
|
363
371
|
* ```ts
|
|
364
372
|
* import { Schema } from "effect"
|
|
@@ -522,7 +530,7 @@ export function annotateEncoded<S extends Top>(annotations: Annotations.Bottom<S
|
|
|
522
530
|
* as well as standard documentation fields such as `title`, `description`,
|
|
523
531
|
* and `examples`.
|
|
524
532
|
*
|
|
525
|
-
* **Example** (
|
|
533
|
+
* **Example** (Customizing the missing-key message for a required field)
|
|
526
534
|
*
|
|
527
535
|
* ```ts
|
|
528
536
|
* import { Schema } from "effect"
|
|
@@ -622,7 +630,7 @@ export declare namespace Schema {
|
|
|
622
630
|
* constructors in this module (e.g. {@link Struct}, {@link String}, {@link Number}).
|
|
623
631
|
* When you also need the encoded type or service requirements, use {@link Codec}.
|
|
624
632
|
*
|
|
625
|
-
* **Example** (
|
|
633
|
+
* **Example** (Accepting any schema decoding to `string`)
|
|
626
634
|
*
|
|
627
635
|
* ```ts
|
|
628
636
|
* import { Schema } from "effect"
|
|
@@ -777,7 +785,7 @@ export interface Codec<out T, out E = T, out RD = never, out RE = never> extends
|
|
|
777
785
|
* constraining or depending on the encoded representation (`Encoded` is
|
|
778
786
|
* `unknown`) or encoding services.
|
|
779
787
|
*
|
|
780
|
-
* **Example** (
|
|
788
|
+
* **Example** (Accepting schemas that only need to decode)
|
|
781
789
|
*
|
|
782
790
|
* ```ts
|
|
783
791
|
* import { Schema } from "effect"
|
|
@@ -804,7 +812,7 @@ export interface Decoder<out T, out RD = never> extends Codec<T, unknown, RD, un
|
|
|
804
812
|
* constraining or depending on the decoded `Type` (`Type` is `unknown`) or
|
|
805
813
|
* decoding services.
|
|
806
814
|
*
|
|
807
|
-
* **Example** (
|
|
815
|
+
* **Example** (Accepting schemas that only need to encode)
|
|
808
816
|
*
|
|
809
817
|
* ```ts
|
|
810
818
|
* import { Schema } from "effect"
|
|
@@ -889,7 +897,7 @@ export {
|
|
|
889
897
|
/**
|
|
890
898
|
* Returns `true` if `u` is a {@link SchemaError}.
|
|
891
899
|
*
|
|
892
|
-
* **Example** (
|
|
900
|
+
* **Example** (Narrowing Schema errors in a catch block)
|
|
893
901
|
*
|
|
894
902
|
* ```ts
|
|
895
903
|
* import { Schema } from "effect"
|
|
@@ -1090,10 +1098,16 @@ export function toStandardJSONSchemaV1<S extends Top>(self: S): StandardJSONSche
|
|
|
1090
1098
|
* **Details**
|
|
1091
1099
|
*
|
|
1092
1100
|
* This function returns a predicate that performs a type-safe check, narrowing
|
|
1093
|
-
* the type of the input value if the check passes.
|
|
1094
|
-
*
|
|
1101
|
+
* the type of the input value if the check passes. The predicate returns `false`
|
|
1102
|
+
* for schema mismatches.
|
|
1095
1103
|
*
|
|
1096
|
-
* **
|
|
1104
|
+
* **Gotchas**
|
|
1105
|
+
*
|
|
1106
|
+
* Only causes made entirely of schema issues are converted to `false`. Causes
|
|
1107
|
+
* that contain defects, interruptions, or other non-schema reasons throw
|
|
1108
|
+
* instead.
|
|
1109
|
+
*
|
|
1110
|
+
* **Example** (Defining a basic type guard)
|
|
1097
1111
|
*
|
|
1098
1112
|
* ```ts
|
|
1099
1113
|
* import { Schema } from "effect"
|
|
@@ -1117,7 +1131,7 @@ export function toStandardJSONSchemaV1<S extends Top>(self: S): StandardJSONSche
|
|
|
1117
1131
|
export const is = SchemaParser.is
|
|
1118
1132
|
|
|
1119
1133
|
/**
|
|
1120
|
-
* Creates an assertion function that throws an error if the input
|
|
1134
|
+
* Creates an assertion function that throws an error if the input does not match
|
|
1121
1135
|
* the schema.
|
|
1122
1136
|
*
|
|
1123
1137
|
* **When to use**
|
|
@@ -1127,10 +1141,16 @@ export const is = SchemaParser.is
|
|
|
1127
1141
|
*
|
|
1128
1142
|
* **Details**
|
|
1129
1143
|
*
|
|
1130
|
-
* The input is narrowed if the assertion succeeds. If validation fails,
|
|
1131
|
-
* assertion throws.
|
|
1144
|
+
* The input is narrowed if the assertion succeeds. If schema validation fails,
|
|
1145
|
+
* the assertion throws an `Error` whose cause is `SchemaIssue.Issue`.
|
|
1146
|
+
*
|
|
1147
|
+
* **Gotchas**
|
|
1132
1148
|
*
|
|
1133
|
-
*
|
|
1149
|
+
* Causes that contain defects, interruptions, or other non-schema reasons throw
|
|
1150
|
+
* with the underlying `Cause` attached instead of being converted to schema
|
|
1151
|
+
* validation errors.
|
|
1152
|
+
*
|
|
1153
|
+
* **Example** (Asserting and narrowing an input)
|
|
1134
1154
|
*
|
|
1135
1155
|
* ```ts
|
|
1136
1156
|
* import { Schema } from "effect"
|
|
@@ -1182,7 +1202,7 @@ export function decodeUnknownEffect<S extends Top>(schema: S, options?: SchemaAS
|
|
|
1182
1202
|
input: unknown,
|
|
1183
1203
|
options?: SchemaAST.ParseOptions
|
|
1184
1204
|
): Effect.Effect<S["Type"], SchemaError, S["DecodingServices"]> => {
|
|
1185
|
-
return
|
|
1205
|
+
return InternalSchema.mapSchemaIssueEffect(parser(input, options))
|
|
1186
1206
|
}
|
|
1187
1207
|
}
|
|
1188
1208
|
|
|
@@ -1215,15 +1235,52 @@ export const decodeEffect: <S extends Top>(
|
|
|
1215
1235
|
options?: SchemaAST.ParseOptions
|
|
1216
1236
|
) => Effect.Effect<S["Type"], SchemaError, S["DecodingServices"]> = decodeUnknownEffect
|
|
1217
1237
|
|
|
1238
|
+
function getSchemaErrorOrThrow(
|
|
1239
|
+
cause: Cause_.Cause<SchemaError>,
|
|
1240
|
+
message: string
|
|
1241
|
+
): SchemaError {
|
|
1242
|
+
let schemaError: SchemaError | undefined
|
|
1243
|
+
for (const reason of cause.reasons) {
|
|
1244
|
+
if (!Cause_.isFailReason(reason) || !isSchemaError(reason.error)) {
|
|
1245
|
+
throw new globalThis.Error(message, { cause })
|
|
1246
|
+
}
|
|
1247
|
+
schemaError ??= reason.error
|
|
1248
|
+
}
|
|
1249
|
+
if (schemaError === undefined) {
|
|
1250
|
+
throw new globalThis.Error(message, { cause })
|
|
1251
|
+
}
|
|
1252
|
+
return schemaError
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
function runSchemaErrorPromise<A>(
|
|
1256
|
+
self: Effect.Effect<A, SchemaError>
|
|
1257
|
+
): Promise<A> {
|
|
1258
|
+
return Effect.runPromiseExit(self).then((exit) => {
|
|
1259
|
+
if (Exit_.isSuccess(exit)) {
|
|
1260
|
+
return exit.value
|
|
1261
|
+
}
|
|
1262
|
+
throw getSchemaErrorOrThrow(exit.cause, "Promise adapter can only reject schema errors")
|
|
1263
|
+
})
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
function runSchemaErrorSync<A>(
|
|
1267
|
+
self: Effect.Effect<A, SchemaError>
|
|
1268
|
+
): A {
|
|
1269
|
+
const exit = Effect.runSyncExit(self)
|
|
1270
|
+
if (Exit_.isSuccess(exit)) {
|
|
1271
|
+
return exit.value
|
|
1272
|
+
}
|
|
1273
|
+
throw getSchemaErrorOrThrow(exit.cause, "Sync adapter can only throw schema errors")
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1218
1276
|
/**
|
|
1219
1277
|
* Decodes an `unknown` input against a schema synchronously, returning an
|
|
1220
|
-
* `Exit` that is either a `Success` with the decoded value or a `Failure
|
|
1221
|
-
* a {@link SchemaError}.
|
|
1278
|
+
* `Exit` that is either a `Success` with the decoded value or a `Failure`.
|
|
1222
1279
|
*
|
|
1223
1280
|
* **When to use**
|
|
1224
1281
|
*
|
|
1225
|
-
* Use when you need to decode unknown input into an `Exit`
|
|
1226
|
-
*
|
|
1282
|
+
* Use when you need to decode unknown input into an `Exit` and capture schema
|
|
1283
|
+
* mismatches as `SchemaError`.
|
|
1227
1284
|
*
|
|
1228
1285
|
* **Details**
|
|
1229
1286
|
*
|
|
@@ -1232,6 +1289,14 @@ export const decodeEffect: <S extends Top>(
|
|
|
1232
1289
|
* type.
|
|
1233
1290
|
* Options may be provided either when creating the decoder or when applying it;
|
|
1234
1291
|
* application options override creation options.
|
|
1292
|
+
* Schema mismatches are represented by a `Failure` cause containing
|
|
1293
|
+
* `SchemaError`.
|
|
1294
|
+
*
|
|
1295
|
+
* **Gotchas**
|
|
1296
|
+
*
|
|
1297
|
+
* Schema issue fail reasons are wrapped as `SchemaError`. Defects,
|
|
1298
|
+
* interruptions, and other non-schema reasons remain in the returned `Cause`,
|
|
1299
|
+
* including when they are mixed with schema issues.
|
|
1235
1300
|
*
|
|
1236
1301
|
* @see {@link SchemaParser.decodeUnknownExit} for the adapter whose failure contains `SchemaIssue.Issue` directly
|
|
1237
1302
|
*
|
|
@@ -1241,19 +1306,19 @@ export const decodeEffect: <S extends Top>(
|
|
|
1241
1306
|
export function decodeUnknownExit<S extends Decoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
|
|
1242
1307
|
const parser = SchemaParser.decodeUnknownExit(schema, options)
|
|
1243
1308
|
return (input: unknown, options?: SchemaAST.ParseOptions): Exit_.Exit<S["Type"], SchemaError> => {
|
|
1244
|
-
return
|
|
1309
|
+
return InternalSchema.mapSchemaIssueExit(parser(input, options))
|
|
1245
1310
|
}
|
|
1246
1311
|
}
|
|
1247
1312
|
|
|
1248
1313
|
/**
|
|
1249
1314
|
* Decodes a typed input (the schema's `Encoded` type) against a schema
|
|
1250
|
-
* synchronously, returning an `Exit` that is either a `Success` with the
|
|
1251
|
-
*
|
|
1315
|
+
* synchronously, returning an `Exit` that is either a `Success` with the decoded
|
|
1316
|
+
* value or a `Failure`.
|
|
1252
1317
|
*
|
|
1253
1318
|
* **When to use**
|
|
1254
1319
|
*
|
|
1255
|
-
* Use when you need to decode already typed `Encoded` input into an `Exit`
|
|
1256
|
-
*
|
|
1320
|
+
* Use when you need to decode already typed `Encoded` input into an `Exit` and
|
|
1321
|
+
* capture schema mismatches as `SchemaError`.
|
|
1257
1322
|
*
|
|
1258
1323
|
* **Details**
|
|
1259
1324
|
*
|
|
@@ -1261,6 +1326,14 @@ export function decodeUnknownExit<S extends Decoder<unknown>>(schema: S, options
|
|
|
1261
1326
|
* `unknown` input use {@link decodeUnknownExit}.
|
|
1262
1327
|
* Options may be provided either when creating the decoder or when applying it;
|
|
1263
1328
|
* application options override creation options.
|
|
1329
|
+
* Schema mismatches are represented by a `Failure` cause containing
|
|
1330
|
+
* `SchemaError`.
|
|
1331
|
+
*
|
|
1332
|
+
* **Gotchas**
|
|
1333
|
+
*
|
|
1334
|
+
* Schema issue fail reasons are wrapped as `SchemaError`. Defects,
|
|
1335
|
+
* interruptions, and other non-schema reasons remain in the returned `Cause`,
|
|
1336
|
+
* including when they are mixed with schema issues.
|
|
1264
1337
|
*
|
|
1265
1338
|
* @see {@link SchemaParser.decodeExit} for the adapter whose failure contains `SchemaIssue.Issue` directly
|
|
1266
1339
|
*
|
|
@@ -1274,7 +1347,7 @@ export const decodeExit: <S extends Decoder<unknown>>(
|
|
|
1274
1347
|
|
|
1275
1348
|
/**
|
|
1276
1349
|
* Decodes an `unknown` input against a schema, returning an `Option` that is
|
|
1277
|
-
* `Some` with the decoded value on success or `None`
|
|
1350
|
+
* `Some` with the decoded value on success or `None` for schema mismatches.
|
|
1278
1351
|
*
|
|
1279
1352
|
* **When to use**
|
|
1280
1353
|
*
|
|
@@ -1289,6 +1362,12 @@ export const decodeExit: <S extends Decoder<unknown>>(
|
|
|
1289
1362
|
* Options may be provided either when creating the decoder or when applying it;
|
|
1290
1363
|
* application options override creation options.
|
|
1291
1364
|
*
|
|
1365
|
+
* **Gotchas**
|
|
1366
|
+
*
|
|
1367
|
+
* Only causes made entirely of schema issues are converted to `None`. Causes
|
|
1368
|
+
* that contain defects, interruptions, or other non-schema reasons throw
|
|
1369
|
+
* instead.
|
|
1370
|
+
*
|
|
1292
1371
|
* @category decoding
|
|
1293
1372
|
* @since 3.10.0
|
|
1294
1373
|
*/
|
|
@@ -1300,7 +1379,7 @@ export const decodeUnknownOption: <S extends Decoder<unknown>>(
|
|
|
1300
1379
|
/**
|
|
1301
1380
|
* Decodes a typed input (the schema's `Encoded` type) against a schema,
|
|
1302
1381
|
* returning an `Option` that is `Some` with the decoded value on success or
|
|
1303
|
-
* `None`
|
|
1382
|
+
* `None` for schema mismatches.
|
|
1304
1383
|
*
|
|
1305
1384
|
* **When to use**
|
|
1306
1385
|
*
|
|
@@ -1313,6 +1392,12 @@ export const decodeUnknownOption: <S extends Decoder<unknown>>(
|
|
|
1313
1392
|
* Options may be provided either when creating the decoder or when applying it;
|
|
1314
1393
|
* application options override creation options.
|
|
1315
1394
|
*
|
|
1395
|
+
* **Gotchas**
|
|
1396
|
+
*
|
|
1397
|
+
* Only causes made entirely of schema issues are converted to `None`. Causes
|
|
1398
|
+
* that contain defects, interruptions, or other non-schema reasons throw
|
|
1399
|
+
* instead.
|
|
1400
|
+
*
|
|
1316
1401
|
* @category decoding
|
|
1317
1402
|
* @since 3.10.0
|
|
1318
1403
|
*/
|
|
@@ -1323,12 +1408,13 @@ export const decodeOption: <S extends Decoder<unknown>>(
|
|
|
1323
1408
|
|
|
1324
1409
|
/**
|
|
1325
1410
|
* Decodes an `unknown` input against a schema, returning a `Result` that
|
|
1326
|
-
* succeeds with the decoded value or fails with a {@link SchemaError}
|
|
1411
|
+
* succeeds with the decoded value or fails with a {@link SchemaError} for schema
|
|
1412
|
+
* mismatches.
|
|
1327
1413
|
*
|
|
1328
1414
|
* **When to use**
|
|
1329
1415
|
*
|
|
1330
|
-
* Use when you do not know the input type statically and want
|
|
1331
|
-
*
|
|
1416
|
+
* Use when you do not know the input type statically and want schema mismatches
|
|
1417
|
+
* returned as `Result.fail` with `SchemaError`.
|
|
1332
1418
|
*
|
|
1333
1419
|
* **Details**
|
|
1334
1420
|
*
|
|
@@ -1336,6 +1422,13 @@ export const decodeOption: <S extends Decoder<unknown>>(
|
|
|
1336
1422
|
* {@link decodeResult}.
|
|
1337
1423
|
* Options may be provided either when creating the decoder or when applying it;
|
|
1338
1424
|
* application options override creation options.
|
|
1425
|
+
* Schema mismatches are returned as `Result.fail` with `SchemaError`.
|
|
1426
|
+
*
|
|
1427
|
+
* **Gotchas**
|
|
1428
|
+
*
|
|
1429
|
+
* Only causes made entirely of schema issues are returned as `Result.fail`.
|
|
1430
|
+
* Causes that contain defects, interruptions, or other non-schema reasons throw
|
|
1431
|
+
* instead.
|
|
1339
1432
|
*
|
|
1340
1433
|
* @see {@link SchemaParser.decodeUnknownResult} for the adapter that fails with `SchemaIssue.Issue` directly
|
|
1341
1434
|
*
|
|
@@ -1352,18 +1445,25 @@ export function decodeUnknownResult<S extends Decoder<unknown>>(schema: S, optio
|
|
|
1352
1445
|
/**
|
|
1353
1446
|
* Decodes a typed input (the schema's `Encoded` type) against a schema,
|
|
1354
1447
|
* returning a `Result` that succeeds with the decoded value or fails with a
|
|
1355
|
-
* {@link SchemaError}.
|
|
1448
|
+
* {@link SchemaError} for schema mismatches.
|
|
1356
1449
|
*
|
|
1357
1450
|
* **When to use**
|
|
1358
1451
|
*
|
|
1359
|
-
* Use when you already have input typed as the schema's `Encoded` type and
|
|
1360
|
-
*
|
|
1452
|
+
* Use when you already have input typed as the schema's `Encoded` type and want
|
|
1453
|
+
* schema mismatches returned as `Result.fail` with `SchemaError`.
|
|
1361
1454
|
*
|
|
1362
1455
|
* **Details**
|
|
1363
1456
|
*
|
|
1364
1457
|
* For `unknown` input use {@link decodeUnknownResult}.
|
|
1365
1458
|
* Options may be provided either when creating the decoder or when applying it;
|
|
1366
1459
|
* application options override creation options.
|
|
1460
|
+
* Schema mismatches are returned as `Result.fail` with `SchemaError`.
|
|
1461
|
+
*
|
|
1462
|
+
* **Gotchas**
|
|
1463
|
+
*
|
|
1464
|
+
* Only causes made entirely of schema issues are returned as `Result.fail`.
|
|
1465
|
+
* Causes that contain defects, interruptions, or other non-schema reasons throw
|
|
1466
|
+
* instead.
|
|
1367
1467
|
*
|
|
1368
1468
|
* @see {@link SchemaParser.decodeResult} for the adapter that fails with `SchemaIssue.Issue` directly
|
|
1369
1469
|
*
|
|
@@ -1378,12 +1478,13 @@ export const decodeResult: <S extends Decoder<unknown>>(
|
|
|
1378
1478
|
|
|
1379
1479
|
/**
|
|
1380
1480
|
* Decodes an `unknown` input against a schema, returning a `Promise` that
|
|
1381
|
-
* resolves with the decoded value or rejects with a {@link SchemaError}
|
|
1481
|
+
* resolves with the decoded value or rejects with a {@link SchemaError} for
|
|
1482
|
+
* schema mismatches.
|
|
1382
1483
|
*
|
|
1383
1484
|
* **When to use**
|
|
1384
1485
|
*
|
|
1385
1486
|
* Use when you need decoding of unknown input to return a JavaScript `Promise`
|
|
1386
|
-
* that rejects with `SchemaError
|
|
1487
|
+
* that rejects with `SchemaError` for schema mismatches.
|
|
1387
1488
|
*
|
|
1388
1489
|
* **Details**
|
|
1389
1490
|
*
|
|
@@ -1392,7 +1493,12 @@ export const decodeResult: <S extends Decoder<unknown>>(
|
|
|
1392
1493
|
* Options may be provided either when creating the decoder or when applying it;
|
|
1393
1494
|
* application options override creation options.
|
|
1394
1495
|
*
|
|
1395
|
-
*
|
|
1496
|
+
* **Gotchas**
|
|
1497
|
+
*
|
|
1498
|
+
* Non-schema failures may reject with a runtime failure instead of
|
|
1499
|
+
* `SchemaError`.
|
|
1500
|
+
*
|
|
1501
|
+
* @see {@link SchemaParser.decodeUnknownPromise} for the adapter that rejects with an `Error` whose cause is `SchemaIssue.Issue`
|
|
1396
1502
|
*
|
|
1397
1503
|
* @category decoding
|
|
1398
1504
|
* @since 3.10.0
|
|
@@ -1400,20 +1506,20 @@ export const decodeResult: <S extends Decoder<unknown>>(
|
|
|
1400
1506
|
export function decodeUnknownPromise<S extends Decoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
|
|
1401
1507
|
const parser = decodeUnknownEffect(schema, options)
|
|
1402
1508
|
return (input: unknown, options?: SchemaAST.ParseOptions): Promise<S["Type"]> => {
|
|
1403
|
-
return
|
|
1509
|
+
return runSchemaErrorPromise(parser(input, options))
|
|
1404
1510
|
}
|
|
1405
1511
|
}
|
|
1406
1512
|
|
|
1407
1513
|
/**
|
|
1408
1514
|
* Decodes a typed input (the schema's `Encoded` type) against a schema,
|
|
1409
1515
|
* returning a `Promise` that resolves with the decoded value or rejects with a
|
|
1410
|
-
* {@link SchemaError}.
|
|
1516
|
+
* {@link SchemaError} for schema mismatches.
|
|
1411
1517
|
*
|
|
1412
1518
|
* **When to use**
|
|
1413
1519
|
*
|
|
1414
1520
|
* Use when you already have input typed as the schema's `Encoded` type and
|
|
1415
1521
|
* need decoding to return a JavaScript `Promise` that rejects with
|
|
1416
|
-
* `SchemaError
|
|
1522
|
+
* `SchemaError` for schema mismatches.
|
|
1417
1523
|
*
|
|
1418
1524
|
* **Details**
|
|
1419
1525
|
*
|
|
@@ -1421,7 +1527,12 @@ export function decodeUnknownPromise<S extends Decoder<unknown>>(schema: S, opti
|
|
|
1421
1527
|
* Options may be provided either when creating the decoder or when applying it;
|
|
1422
1528
|
* application options override creation options.
|
|
1423
1529
|
*
|
|
1424
|
-
*
|
|
1530
|
+
* **Gotchas**
|
|
1531
|
+
*
|
|
1532
|
+
* Non-schema failures may reject with a runtime failure instead of
|
|
1533
|
+
* `SchemaError`.
|
|
1534
|
+
*
|
|
1535
|
+
* @see {@link SchemaParser.decodePromise} for the adapter that rejects with an `Error` whose cause is `SchemaIssue.Issue`
|
|
1425
1536
|
*
|
|
1426
1537
|
* @category decoding
|
|
1427
1538
|
* @since 3.10.0
|
|
@@ -1433,7 +1544,7 @@ export const decodePromise: <S extends Decoder<unknown>>(
|
|
|
1433
1544
|
|
|
1434
1545
|
/**
|
|
1435
1546
|
* Decodes an `unknown` input against a schema synchronously, returning the
|
|
1436
|
-
* decoded value or throwing a {@link SchemaError}.
|
|
1547
|
+
* decoded value or throwing a {@link SchemaError} for schema mismatches.
|
|
1437
1548
|
*
|
|
1438
1549
|
* **When to use**
|
|
1439
1550
|
*
|
|
@@ -1443,10 +1554,15 @@ export const decodePromise: <S extends Decoder<unknown>>(
|
|
|
1443
1554
|
* **Details**
|
|
1444
1555
|
*
|
|
1445
1556
|
* For input already typed as the schema's `Encoded` type use `decodeSync`.
|
|
1446
|
-
* Only service-free schemas can be decoded synchronously. For
|
|
1447
|
-
*
|
|
1448
|
-
* `decodeUnknownEffect`. Options may be provided either
|
|
1449
|
-
* decoder or when applying it; application options override
|
|
1557
|
+
* Only service-free schemas can be decoded synchronously. For alternatives that
|
|
1558
|
+
* do not throw on schema mismatches, see `decodeUnknownOption`,
|
|
1559
|
+
* `decodeUnknownExit`, or `decodeUnknownEffect`. Options may be provided either
|
|
1560
|
+
* when creating the decoder or when applying it; application options override
|
|
1561
|
+
* creation options.
|
|
1562
|
+
*
|
|
1563
|
+
* **Gotchas**
|
|
1564
|
+
*
|
|
1565
|
+
* Non-schema failures may throw a runtime failure instead of `SchemaError`.
|
|
1450
1566
|
*
|
|
1451
1567
|
* **Example** (Decoding with a transformation schema)
|
|
1452
1568
|
*
|
|
@@ -1473,13 +1589,14 @@ export const decodePromise: <S extends Decoder<unknown>>(
|
|
|
1473
1589
|
export function decodeUnknownSync<S extends Decoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
|
|
1474
1590
|
const parser = decodeUnknownEffect(schema, options)
|
|
1475
1591
|
return (input: unknown, options?: SchemaAST.ParseOptions): S["Type"] => {
|
|
1476
|
-
return
|
|
1592
|
+
return runSchemaErrorSync(parser(input, options))
|
|
1477
1593
|
}
|
|
1478
1594
|
}
|
|
1479
1595
|
|
|
1480
1596
|
/**
|
|
1481
1597
|
* Decodes a typed input (the schema's `Encoded` type) against a schema
|
|
1482
|
-
* synchronously, returning the decoded value or throwing a {@link SchemaError}
|
|
1598
|
+
* synchronously, returning the decoded value or throwing a {@link SchemaError}
|
|
1599
|
+
* for schema mismatches.
|
|
1483
1600
|
*
|
|
1484
1601
|
* **When to use**
|
|
1485
1602
|
*
|
|
@@ -1493,6 +1610,10 @@ export function decodeUnknownSync<S extends Decoder<unknown>>(schema: S, options
|
|
|
1493
1610
|
* provided either when creating the decoder or when applying it; application
|
|
1494
1611
|
* options override creation options.
|
|
1495
1612
|
*
|
|
1613
|
+
* **Gotchas**
|
|
1614
|
+
*
|
|
1615
|
+
* Non-schema failures may throw a runtime failure instead of `SchemaError`.
|
|
1616
|
+
*
|
|
1496
1617
|
* @see {@link SchemaParser.decodeSync} for the adapter that throws an `Error` whose cause is `SchemaIssue.Issue`
|
|
1497
1618
|
*
|
|
1498
1619
|
* @category decoding
|
|
@@ -1541,7 +1662,7 @@ export function encodeUnknownEffect<S extends Top>(schema: S, options?: SchemaAS
|
|
|
1541
1662
|
input: unknown,
|
|
1542
1663
|
options?: SchemaAST.ParseOptions
|
|
1543
1664
|
): Effect.Effect<S["Encoded"], SchemaError, S["EncodingServices"]> => {
|
|
1544
|
-
return
|
|
1665
|
+
return InternalSchema.mapSchemaIssueEffect(parser(input, options))
|
|
1545
1666
|
}
|
|
1546
1667
|
}
|
|
1547
1668
|
|
|
@@ -1576,13 +1697,12 @@ export const encodeEffect: <S extends Top>(
|
|
|
1576
1697
|
|
|
1577
1698
|
/**
|
|
1578
1699
|
* Encodes an `unknown` input against a schema synchronously, returning an
|
|
1579
|
-
* `Exit` that is either a `Success` with the encoded value or a `Failure
|
|
1580
|
-
* a {@link SchemaError}.
|
|
1700
|
+
* `Exit` that is either a `Success` with the encoded value or a `Failure`.
|
|
1581
1701
|
*
|
|
1582
1702
|
* **When to use**
|
|
1583
1703
|
*
|
|
1584
|
-
* Use when you need to encode unknown input into an `Exit`
|
|
1585
|
-
*
|
|
1704
|
+
* Use when you need to encode unknown input into an `Exit` and capture schema
|
|
1705
|
+
* mismatches as `SchemaError`.
|
|
1586
1706
|
*
|
|
1587
1707
|
* **Details**
|
|
1588
1708
|
*
|
|
@@ -1590,6 +1710,14 @@ export const encodeEffect: <S extends Top>(
|
|
|
1590
1710
|
* {@link encodeExit} when the value is already typed as the schema's `Type`.
|
|
1591
1711
|
* Options may be provided either when creating the encoder or when applying it;
|
|
1592
1712
|
* application options override creation options.
|
|
1713
|
+
* Schema mismatches are represented by a `Failure` cause containing
|
|
1714
|
+
* `SchemaError`.
|
|
1715
|
+
*
|
|
1716
|
+
* **Gotchas**
|
|
1717
|
+
*
|
|
1718
|
+
* Schema issue fail reasons are wrapped as `SchemaError`. Defects,
|
|
1719
|
+
* interruptions, and other non-schema reasons remain in the returned `Cause`,
|
|
1720
|
+
* including when they are mixed with schema issues.
|
|
1593
1721
|
*
|
|
1594
1722
|
* @see {@link SchemaParser.encodeUnknownExit} for the adapter whose failure contains `SchemaIssue.Issue` directly
|
|
1595
1723
|
*
|
|
@@ -1599,19 +1727,19 @@ export const encodeEffect: <S extends Top>(
|
|
|
1599
1727
|
export function encodeUnknownExit<S extends Encoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
|
|
1600
1728
|
const parser = SchemaParser.encodeUnknownExit(schema, options)
|
|
1601
1729
|
return (input: unknown, options?: SchemaAST.ParseOptions): Exit_.Exit<S["Encoded"], SchemaError> => {
|
|
1602
|
-
return
|
|
1730
|
+
return InternalSchema.mapSchemaIssueExit(parser(input, options))
|
|
1603
1731
|
}
|
|
1604
1732
|
}
|
|
1605
1733
|
|
|
1606
1734
|
/**
|
|
1607
1735
|
* Encodes a typed input (the schema's `Type`) against a schema synchronously,
|
|
1608
1736
|
* returning an `Exit` that is either a `Success` with the encoded value or a
|
|
1609
|
-
* `Failure
|
|
1737
|
+
* `Failure`.
|
|
1610
1738
|
*
|
|
1611
1739
|
* **When to use**
|
|
1612
1740
|
*
|
|
1613
|
-
* Use when you need to encode already typed schema values into an `Exit`
|
|
1614
|
-
*
|
|
1741
|
+
* Use when you need to encode already typed schema values into an `Exit` and
|
|
1742
|
+
* capture schema mismatches as `SchemaError`.
|
|
1615
1743
|
*
|
|
1616
1744
|
* **Details**
|
|
1617
1745
|
*
|
|
@@ -1619,6 +1747,14 @@ export function encodeUnknownExit<S extends Encoder<unknown>>(schema: S, options
|
|
|
1619
1747
|
* `unknown` input use {@link encodeUnknownExit}.
|
|
1620
1748
|
* Options may be provided either when creating the encoder or when applying it;
|
|
1621
1749
|
* application options override creation options.
|
|
1750
|
+
* Schema mismatches are represented by a `Failure` cause containing
|
|
1751
|
+
* `SchemaError`.
|
|
1752
|
+
*
|
|
1753
|
+
* **Gotchas**
|
|
1754
|
+
*
|
|
1755
|
+
* Schema issue fail reasons are wrapped as `SchemaError`. Defects,
|
|
1756
|
+
* interruptions, and other non-schema reasons remain in the returned `Cause`,
|
|
1757
|
+
* including when they are mixed with schema issues.
|
|
1622
1758
|
*
|
|
1623
1759
|
* @see {@link SchemaParser.encodeExit} for the adapter whose failure contains `SchemaIssue.Issue` directly
|
|
1624
1760
|
*
|
|
@@ -1632,7 +1768,7 @@ export const encodeExit: <S extends Encoder<unknown>>(
|
|
|
1632
1768
|
|
|
1633
1769
|
/**
|
|
1634
1770
|
* Encodes an `unknown` input against a schema, returning an `Option` that is
|
|
1635
|
-
* `Some` with the encoded value on success or `None`
|
|
1771
|
+
* `Some` with the encoded value on success or `None` for schema mismatches.
|
|
1636
1772
|
*
|
|
1637
1773
|
* **When to use**
|
|
1638
1774
|
*
|
|
@@ -1647,6 +1783,12 @@ export const encodeExit: <S extends Encoder<unknown>>(
|
|
|
1647
1783
|
* Options may be provided either when creating the encoder or when applying it;
|
|
1648
1784
|
* application options override creation options.
|
|
1649
1785
|
*
|
|
1786
|
+
* **Gotchas**
|
|
1787
|
+
*
|
|
1788
|
+
* Only causes made entirely of schema issues are converted to `None`. Causes
|
|
1789
|
+
* that contain defects, interruptions, or other non-schema reasons throw
|
|
1790
|
+
* instead.
|
|
1791
|
+
*
|
|
1650
1792
|
* @category encoding
|
|
1651
1793
|
* @since 3.10.0
|
|
1652
1794
|
*/
|
|
@@ -1658,8 +1800,8 @@ export const encodeUnknownOption: <S extends Encoder<unknown>>(
|
|
|
1658
1800
|
|
|
1659
1801
|
/**
|
|
1660
1802
|
* Encodes a typed input (the schema's `Type`) against a schema, returning an
|
|
1661
|
-
* `Option` that is `Some` with the encoded value on success or `None`
|
|
1662
|
-
*
|
|
1803
|
+
* `Option` that is `Some` with the encoded value on success or `None` for schema
|
|
1804
|
+
* mismatches.
|
|
1663
1805
|
*
|
|
1664
1806
|
* **When to use**
|
|
1665
1807
|
*
|
|
@@ -1672,6 +1814,12 @@ export const encodeUnknownOption: <S extends Encoder<unknown>>(
|
|
|
1672
1814
|
* Options may be provided either when creating the encoder or when applying it;
|
|
1673
1815
|
* application options override creation options.
|
|
1674
1816
|
*
|
|
1817
|
+
* **Gotchas**
|
|
1818
|
+
*
|
|
1819
|
+
* Only causes made entirely of schema issues are converted to `None`. Causes
|
|
1820
|
+
* that contain defects, interruptions, or other non-schema reasons throw
|
|
1821
|
+
* instead.
|
|
1822
|
+
*
|
|
1675
1823
|
* @category encoding
|
|
1676
1824
|
* @since 3.10.0
|
|
1677
1825
|
*/
|
|
@@ -1682,18 +1830,26 @@ export const encodeOption: <S extends Encoder<unknown>>(
|
|
|
1682
1830
|
|
|
1683
1831
|
/**
|
|
1684
1832
|
* Encodes an `unknown` input against a schema, returning a `Result` that
|
|
1685
|
-
* succeeds with the encoded value or fails with a {@link SchemaError}
|
|
1833
|
+
* succeeds with the encoded value or fails with a {@link SchemaError} for schema
|
|
1834
|
+
* mismatches.
|
|
1686
1835
|
*
|
|
1687
1836
|
* **When to use**
|
|
1688
1837
|
*
|
|
1689
|
-
* Use when you do not know the input type statically and want
|
|
1690
|
-
*
|
|
1838
|
+
* Use when you do not know the input type statically and want schema mismatches
|
|
1839
|
+
* returned as `Result.fail` with `SchemaError`.
|
|
1691
1840
|
*
|
|
1692
1841
|
* **Details**
|
|
1693
1842
|
*
|
|
1694
1843
|
* For values already typed as the schema's `Type` use {@link encodeResult}.
|
|
1695
1844
|
* Options may be provided either when creating the encoder or when applying it;
|
|
1696
1845
|
* application options override creation options.
|
|
1846
|
+
* Schema mismatches are returned as `Result.fail` with `SchemaError`.
|
|
1847
|
+
*
|
|
1848
|
+
* **Gotchas**
|
|
1849
|
+
*
|
|
1850
|
+
* Only causes made entirely of schema issues are returned as `Result.fail`.
|
|
1851
|
+
* Causes that contain defects, interruptions, or other non-schema reasons throw
|
|
1852
|
+
* instead.
|
|
1697
1853
|
*
|
|
1698
1854
|
* @see {@link SchemaParser.encodeUnknownResult} for the adapter that fails with `SchemaIssue.Issue` directly
|
|
1699
1855
|
*
|
|
@@ -1710,18 +1866,25 @@ export function encodeUnknownResult<S extends Encoder<unknown>>(schema: S, optio
|
|
|
1710
1866
|
/**
|
|
1711
1867
|
* Encodes a typed input (the schema's `Type`) against a schema, returning a
|
|
1712
1868
|
* `Result` that succeeds with the encoded value or fails with a
|
|
1713
|
-
* {@link SchemaError}.
|
|
1869
|
+
* {@link SchemaError} for schema mismatches.
|
|
1714
1870
|
*
|
|
1715
1871
|
* **When to use**
|
|
1716
1872
|
*
|
|
1717
|
-
* Use when you already have a value typed as the schema's `Type` and want
|
|
1718
|
-
*
|
|
1873
|
+
* Use when you already have a value typed as the schema's `Type` and want schema
|
|
1874
|
+
* mismatches returned as `Result.fail` with `SchemaError`.
|
|
1719
1875
|
*
|
|
1720
1876
|
* **Details**
|
|
1721
1877
|
*
|
|
1722
1878
|
* For `unknown` input use {@link encodeUnknownResult}.
|
|
1723
1879
|
* Options may be provided either when creating the encoder or when applying it;
|
|
1724
1880
|
* application options override creation options.
|
|
1881
|
+
* Schema mismatches are returned as `Result.fail` with `SchemaError`.
|
|
1882
|
+
*
|
|
1883
|
+
* **Gotchas**
|
|
1884
|
+
*
|
|
1885
|
+
* Only causes made entirely of schema issues are returned as `Result.fail`.
|
|
1886
|
+
* Causes that contain defects, interruptions, or other non-schema reasons throw
|
|
1887
|
+
* instead.
|
|
1725
1888
|
*
|
|
1726
1889
|
* @see {@link SchemaParser.encodeResult} for the adapter that fails with `SchemaIssue.Issue` directly
|
|
1727
1890
|
*
|
|
@@ -1736,12 +1899,13 @@ export const encodeResult: <S extends Encoder<unknown>>(
|
|
|
1736
1899
|
|
|
1737
1900
|
/**
|
|
1738
1901
|
* Encodes an `unknown` input against a schema, returning a `Promise` that
|
|
1739
|
-
* resolves with the encoded value or rejects with a {@link SchemaError}
|
|
1902
|
+
* resolves with the encoded value or rejects with a {@link SchemaError} for
|
|
1903
|
+
* schema mismatches.
|
|
1740
1904
|
*
|
|
1741
1905
|
* **When to use**
|
|
1742
1906
|
*
|
|
1743
1907
|
* Use when you need encoding of unknown input to return a JavaScript `Promise`
|
|
1744
|
-
* that rejects with `SchemaError
|
|
1908
|
+
* that rejects with `SchemaError` for schema mismatches.
|
|
1745
1909
|
*
|
|
1746
1910
|
* **Details**
|
|
1747
1911
|
*
|
|
@@ -1749,7 +1913,12 @@ export const encodeResult: <S extends Encoder<unknown>>(
|
|
|
1749
1913
|
* Options may be provided either when creating the encoder or when applying it;
|
|
1750
1914
|
* application options override creation options.
|
|
1751
1915
|
*
|
|
1752
|
-
*
|
|
1916
|
+
* **Gotchas**
|
|
1917
|
+
*
|
|
1918
|
+
* Non-schema failures may reject with a runtime failure instead of
|
|
1919
|
+
* `SchemaError`.
|
|
1920
|
+
*
|
|
1921
|
+
* @see {@link SchemaParser.encodeUnknownPromise} for the adapter that rejects with an `Error` whose cause is `SchemaIssue.Issue`
|
|
1753
1922
|
*
|
|
1754
1923
|
* @category encoding
|
|
1755
1924
|
* @since 3.10.0
|
|
@@ -1757,19 +1926,20 @@ export const encodeResult: <S extends Encoder<unknown>>(
|
|
|
1757
1926
|
export function encodeUnknownPromise<S extends Encoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
|
|
1758
1927
|
const parser = encodeUnknownEffect(schema, options)
|
|
1759
1928
|
return (input: unknown, options?: SchemaAST.ParseOptions): Promise<S["Encoded"]> => {
|
|
1760
|
-
return
|
|
1929
|
+
return runSchemaErrorPromise(parser(input, options))
|
|
1761
1930
|
}
|
|
1762
1931
|
}
|
|
1763
1932
|
|
|
1764
1933
|
/**
|
|
1765
1934
|
* Encodes a typed input (the schema's `Type`) against a schema, returning a
|
|
1766
1935
|
* `Promise` that resolves with the encoded value or rejects with a
|
|
1767
|
-
* {@link SchemaError}.
|
|
1936
|
+
* {@link SchemaError} for schema mismatches.
|
|
1768
1937
|
*
|
|
1769
1938
|
* **When to use**
|
|
1770
1939
|
*
|
|
1771
1940
|
* Use when you already have a value typed as the schema's `Type` and need
|
|
1772
|
-
* encoding to return a JavaScript `Promise` that rejects with `SchemaError
|
|
1941
|
+
* encoding to return a JavaScript `Promise` that rejects with `SchemaError` for
|
|
1942
|
+
* schema mismatches.
|
|
1773
1943
|
*
|
|
1774
1944
|
* **Details**
|
|
1775
1945
|
*
|
|
@@ -1777,7 +1947,12 @@ export function encodeUnknownPromise<S extends Encoder<unknown>>(schema: S, opti
|
|
|
1777
1947
|
* Options may be provided either when creating the encoder or when applying it;
|
|
1778
1948
|
* application options override creation options.
|
|
1779
1949
|
*
|
|
1780
|
-
*
|
|
1950
|
+
* **Gotchas**
|
|
1951
|
+
*
|
|
1952
|
+
* Non-schema failures may reject with a runtime failure instead of
|
|
1953
|
+
* `SchemaError`.
|
|
1954
|
+
*
|
|
1955
|
+
* @see {@link SchemaParser.encodePromise} for the adapter that rejects with an `Error` whose cause is `SchemaIssue.Issue`
|
|
1781
1956
|
*
|
|
1782
1957
|
* @category encoding
|
|
1783
1958
|
* @since 3.10.0
|
|
@@ -1789,7 +1964,7 @@ export const encodePromise: <S extends Encoder<unknown>>(
|
|
|
1789
1964
|
|
|
1790
1965
|
/**
|
|
1791
1966
|
* Encodes an `unknown` input against a schema synchronously, throwing a
|
|
1792
|
-
* {@link SchemaError}
|
|
1967
|
+
* {@link SchemaError} for schema mismatches.
|
|
1793
1968
|
*
|
|
1794
1969
|
* **When to use**
|
|
1795
1970
|
*
|
|
@@ -1798,11 +1973,15 @@ export const encodePromise: <S extends Encoder<unknown>>(
|
|
|
1798
1973
|
*
|
|
1799
1974
|
* **Details**
|
|
1800
1975
|
*
|
|
1801
|
-
* For
|
|
1802
|
-
* {@link
|
|
1803
|
-
* already typed as the schema's `Type`
|
|
1804
|
-
* Options may be provided either when creating the
|
|
1805
|
-
* application options override creation options.
|
|
1976
|
+
* For alternatives that do not throw on schema mismatches, see
|
|
1977
|
+
* {@link encodeUnknownOption}, {@link encodeUnknownExit}, or
|
|
1978
|
+
* {@link encodeUnknownEffect}. For values already typed as the schema's `Type`
|
|
1979
|
+
* use {@link encodeSync}. Options may be provided either when creating the
|
|
1980
|
+
* encoder or when applying it; application options override creation options.
|
|
1981
|
+
*
|
|
1982
|
+
* **Gotchas**
|
|
1983
|
+
*
|
|
1984
|
+
* Non-schema failures may throw a runtime failure instead of `SchemaError`.
|
|
1806
1985
|
*
|
|
1807
1986
|
* @see {@link SchemaParser.encodeUnknownSync} for the adapter that throws an `Error` whose cause is `SchemaIssue.Issue`
|
|
1808
1987
|
*
|
|
@@ -1812,13 +1991,13 @@ export const encodePromise: <S extends Encoder<unknown>>(
|
|
|
1812
1991
|
export function encodeUnknownSync<S extends Encoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions) {
|
|
1813
1992
|
const parser = encodeUnknownEffect(schema, options)
|
|
1814
1993
|
return (input: unknown, options?: SchemaAST.ParseOptions): S["Encoded"] => {
|
|
1815
|
-
return
|
|
1994
|
+
return runSchemaErrorSync(parser(input, options) as Effect.Effect<S["Encoded"], SchemaError>)
|
|
1816
1995
|
}
|
|
1817
1996
|
}
|
|
1818
1997
|
|
|
1819
1998
|
/**
|
|
1820
1999
|
* Encodes a typed input (the schema's `Type`) against a schema synchronously,
|
|
1821
|
-
* throwing a {@link SchemaError}
|
|
2000
|
+
* throwing a {@link SchemaError} for schema mismatches.
|
|
1822
2001
|
*
|
|
1823
2002
|
* **When to use**
|
|
1824
2003
|
*
|
|
@@ -1831,6 +2010,10 @@ export function encodeUnknownSync<S extends Encoder<unknown>>(schema: S, options
|
|
|
1831
2010
|
* Options may be provided either when creating the encoder or when applying it;
|
|
1832
2011
|
* application options override creation options.
|
|
1833
2012
|
*
|
|
2013
|
+
* **Gotchas**
|
|
2014
|
+
*
|
|
2015
|
+
* Non-schema failures may throw a runtime failure instead of `SchemaError`.
|
|
2016
|
+
*
|
|
1834
2017
|
* @see {@link SchemaParser.encodeSync} for the adapter that throws an `Error` whose cause is `SchemaIssue.Issue`
|
|
1835
2018
|
*
|
|
1836
2019
|
* @category encoding
|
|
@@ -2002,7 +2185,7 @@ interface optionalLambda extends Lambda {
|
|
|
2002
2185
|
* Use {@link optionalKey} instead if you want exact optional semantics (absent
|
|
2003
2186
|
* only, not `undefined`).
|
|
2004
2187
|
*
|
|
2005
|
-
* **Example** (
|
|
2188
|
+
* **Example** (Defining an optional field accepting undefined)
|
|
2006
2189
|
*
|
|
2007
2190
|
* ```ts
|
|
2008
2191
|
* import { Schema } from "effect"
|
|
@@ -2233,7 +2416,7 @@ function isFlip$(schema: Top): schema is flip<any> {
|
|
|
2233
2416
|
*
|
|
2234
2417
|
* Calling `flip` twice returns the original schema.
|
|
2235
2418
|
*
|
|
2236
|
-
* **Example** (
|
|
2419
|
+
* **Example** (Flipping a number-from-string schema)
|
|
2237
2420
|
*
|
|
2238
2421
|
* ```ts
|
|
2239
2422
|
* import { Schema } from "effect"
|
|
@@ -2270,7 +2453,7 @@ export interface Literal<L extends SchemaAST.LiteralValue>
|
|
|
2270
2453
|
/**
|
|
2271
2454
|
* Creates a schema for a single literal value (string, number, bigint, boolean, or null).
|
|
2272
2455
|
*
|
|
2273
|
-
* **Example** (
|
|
2456
|
+
* **Example** (Defining a string literal)
|
|
2274
2457
|
*
|
|
2275
2458
|
* ```ts
|
|
2276
2459
|
* import { Schema } from "effect"
|
|
@@ -2386,15 +2569,21 @@ function templateLiteralFromParts<Parts extends TemplateLiteral.Parts>(parts: Pa
|
|
|
2386
2569
|
}
|
|
2387
2570
|
|
|
2388
2571
|
/**
|
|
2389
|
-
* Creates a schema that validates strings matching
|
|
2390
|
-
*
|
|
2572
|
+
* Creates a schema that validates strings by matching ordered template literal
|
|
2573
|
+
* parts.
|
|
2391
2574
|
*
|
|
2392
2575
|
* **When to use**
|
|
2393
2576
|
*
|
|
2394
2577
|
* Use when the decoded value should remain the matched string and you do not
|
|
2395
2578
|
* need the individual template parts parsed into a tuple.
|
|
2396
2579
|
*
|
|
2397
|
-
* **
|
|
2580
|
+
* **Details**
|
|
2581
|
+
*
|
|
2582
|
+
* Each part can be a literal `string`, `number`, or `bigint`, or a schema whose
|
|
2583
|
+
* encoded type is `string`, `number`, or `bigint`. Checks on string, number,
|
|
2584
|
+
* and bigint schema parts are applied while matching each segment.
|
|
2585
|
+
*
|
|
2586
|
+
* **Example** (Defining a URL path pattern)
|
|
2398
2587
|
*
|
|
2399
2588
|
* ```ts
|
|
2400
2589
|
* import { Schema } from "effect"
|
|
@@ -2457,7 +2646,7 @@ export interface TemplateLiteralParser<Parts extends TemplateLiteral.Parts> exte
|
|
|
2457
2646
|
}
|
|
2458
2647
|
|
|
2459
2648
|
/**
|
|
2460
|
-
* Schema for parsing template literal
|
|
2649
|
+
* Schema for parsing matched template literal strings into typed tuple parts.
|
|
2461
2650
|
*
|
|
2462
2651
|
* **When to use**
|
|
2463
2652
|
*
|
|
@@ -2467,9 +2656,10 @@ export interface TemplateLiteralParser<Parts extends TemplateLiteral.Parts> exte
|
|
|
2467
2656
|
* **Details**
|
|
2468
2657
|
*
|
|
2469
2658
|
* Unlike {@link TemplateLiteral}, this schema decodes the matched string into a
|
|
2470
|
-
* readonly tuple with one element per schema part.
|
|
2659
|
+
* readonly tuple with one element per schema part. Checks on string, number,
|
|
2660
|
+
* and bigint schema parts are applied while matching each segment.
|
|
2471
2661
|
*
|
|
2472
|
-
* **Example** (
|
|
2662
|
+
* **Example** (Parsing path parameters)
|
|
2473
2663
|
*
|
|
2474
2664
|
* ```ts
|
|
2475
2665
|
* import { Schema } from "effect"
|
|
@@ -2503,7 +2693,7 @@ export interface Enum<A extends { [x: string]: string | number }>
|
|
|
2503
2693
|
/**
|
|
2504
2694
|
* Creates a schema from a TypeScript enum object. Validates that the input is one of the enum's values.
|
|
2505
2695
|
*
|
|
2506
|
-
* **Example** (
|
|
2696
|
+
* **Example** (Defining a direction enum)
|
|
2507
2697
|
*
|
|
2508
2698
|
* ```ts
|
|
2509
2699
|
* import { Schema } from "effect"
|
|
@@ -2768,7 +2958,7 @@ export interface UniqueSymbol<sym extends symbol>
|
|
|
2768
2958
|
/**
|
|
2769
2959
|
* Creates a schema for a specific symbol. Only that exact symbol satisfies the schema.
|
|
2770
2960
|
*
|
|
2771
|
-
* **Example** (
|
|
2961
|
+
* **Example** (Defining a specific symbol)
|
|
2772
2962
|
*
|
|
2773
2963
|
* ```ts
|
|
2774
2964
|
* import { Schema } from "effect"
|
|
@@ -3037,7 +3227,7 @@ function makeStruct<const Fields extends Struct.Fields>(ast: SchemaAST.Objects,
|
|
|
3037
3227
|
* The resulting schema's `Type` is a readonly object type with the fields'
|
|
3038
3228
|
* decoded types. The `Encoded` form mirrors the field schemas' encoded types.
|
|
3039
3229
|
*
|
|
3040
|
-
* **Example** (
|
|
3230
|
+
* **Example** (Defining a basic struct)
|
|
3041
3231
|
*
|
|
3042
3232
|
* ```ts
|
|
3043
3233
|
* import { Schema } from "effect"
|
|
@@ -3139,7 +3329,7 @@ const canonicalPropertyKey = (key: PropertyKey): string | symbol =>
|
|
|
3139
3329
|
* If two existing fields would produce the same encoded key, construction
|
|
3140
3330
|
* fails.
|
|
3141
3331
|
*
|
|
3142
|
-
* **Example** (
|
|
3332
|
+
* **Example** (Renaming `name` to `full_name` in the encoded form)
|
|
3143
3333
|
*
|
|
3144
3334
|
* ```ts
|
|
3145
3335
|
* import { Schema } from "effect"
|
|
@@ -3200,7 +3390,7 @@ export function encodeKeys<
|
|
|
3200
3390
|
* computed or enriched fields to live in the decoded type without appearing in
|
|
3201
3391
|
* the encoded form.
|
|
3202
3392
|
*
|
|
3203
|
-
* **Example** (
|
|
3393
|
+
* **Example** (Adding a computed `fullName` field)
|
|
3204
3394
|
*
|
|
3205
3395
|
* ```ts
|
|
3206
3396
|
* import { Option, Schema } from "effect"
|
|
@@ -3404,9 +3594,20 @@ export interface $Record<Key extends Record.Key, Value extends Top> extends
|
|
|
3404
3594
|
}
|
|
3405
3595
|
|
|
3406
3596
|
/**
|
|
3407
|
-
* Defines a record
|
|
3597
|
+
* Defines a record schema whose dynamic properties are selected by a key schema
|
|
3598
|
+
* and decoded with a value schema.
|
|
3599
|
+
*
|
|
3600
|
+
* **Details**
|
|
3601
|
+
*
|
|
3602
|
+
* For dynamic keys, the key schema selects matching own properties and the
|
|
3603
|
+
* value schema decodes or encodes only those selected properties. Checks on
|
|
3604
|
+
* string, number, symbol, and template literal key schemas narrow which
|
|
3605
|
+
* properties are selected.
|
|
3408
3606
|
*
|
|
3409
|
-
*
|
|
3607
|
+
* For transformed key schemas, property selection is based on encoded property
|
|
3608
|
+
* names before the selected key is decoded.
|
|
3609
|
+
*
|
|
3610
|
+
* **Example** (Defining a string-keyed record of numbers)
|
|
3410
3611
|
*
|
|
3411
3612
|
* ```ts
|
|
3412
3613
|
* import { Schema } from "effect"
|
|
@@ -3614,7 +3815,7 @@ export interface StructWithRest<
|
|
|
3614
3815
|
* Extends a struct schema with one or more record (index-signature) schemas,
|
|
3615
3816
|
* producing a schema whose decoded type intersects the struct and all records.
|
|
3616
3817
|
*
|
|
3617
|
-
* **Example** (
|
|
3818
|
+
* **Example** (Defining structs with string-indexed extra keys)
|
|
3618
3819
|
*
|
|
3619
3820
|
* ```ts
|
|
3620
3821
|
* import { Schema } from "effect"
|
|
@@ -3834,7 +4035,7 @@ function makeTuple<Elements extends Tuple.Elements>(ast: SchemaAST.Arrays, eleme
|
|
|
3834
4035
|
/**
|
|
3835
4036
|
* Defines a fixed-length tuple schema from an array of element schemas.
|
|
3836
4037
|
*
|
|
3837
|
-
* **Example** (
|
|
4038
|
+
* **Example** (Defining a pair of string and number)
|
|
3838
4039
|
*
|
|
3839
4040
|
* ```ts
|
|
3840
4041
|
* import { Schema } from "effect"
|
|
@@ -4011,7 +4212,7 @@ export interface TupleWithRest<
|
|
|
4011
4212
|
* example, `[Schema.Boolean, Schema.String]` represents zero or more booleans
|
|
4012
4213
|
* followed by a final string.
|
|
4013
4214
|
*
|
|
4014
|
-
* **Example** (
|
|
4215
|
+
* **Example** (Defining tuples with rest elements)
|
|
4015
4216
|
*
|
|
4016
4217
|
* ```ts
|
|
4017
4218
|
* import { Schema } from "effect"
|
|
@@ -4075,7 +4276,7 @@ export {
|
|
|
4075
4276
|
/**
|
|
4076
4277
|
* Defines a `ReadonlyArray` schema for a given element schema.
|
|
4077
4278
|
*
|
|
4078
|
-
* **Example** (
|
|
4279
|
+
* **Example** (Defining an array of strings)
|
|
4079
4280
|
*
|
|
4080
4281
|
* ```ts
|
|
4081
4282
|
* import { Schema } from "effect"
|
|
@@ -4123,7 +4324,7 @@ interface NonEmptyArrayLambda extends Lambda {
|
|
|
4123
4324
|
* Defines a non-empty `ReadonlyArray` schema — at least one element required.
|
|
4124
4325
|
* Type is `readonly [T, ...T[]]`.
|
|
4125
4326
|
*
|
|
4126
|
-
* **Example** (
|
|
4327
|
+
* **Example** (Defining a non-empty array of numbers)
|
|
4127
4328
|
*
|
|
4128
4329
|
* ```ts
|
|
4129
4330
|
* import { Schema } from "effect"
|
|
@@ -4251,7 +4452,7 @@ interface mutableLambda extends Lambda {
|
|
|
4251
4452
|
/**
|
|
4252
4453
|
* Makes an array or tuple schema mutable, removing the `readonly` modifier.
|
|
4253
4454
|
*
|
|
4254
|
-
* **Example** (
|
|
4455
|
+
* **Example** (Defining mutable arrays)
|
|
4255
4456
|
*
|
|
4256
4457
|
* ```ts
|
|
4257
4458
|
* import { Schema } from "effect"
|
|
@@ -4344,7 +4545,7 @@ function makeUnion<Members extends ReadonlyArray<Top>>(
|
|
|
4344
4545
|
* - `"anyOf"` (default) — matches if any member matches.
|
|
4345
4546
|
* - `"oneOf"` — matches if exactly one member matches.
|
|
4346
4547
|
*
|
|
4347
|
-
* **Example** (
|
|
4548
|
+
* **Example** (Defining a string or number union)
|
|
4348
4549
|
*
|
|
4349
4550
|
* ```ts
|
|
4350
4551
|
* import { Schema } from "effect"
|
|
@@ -4391,7 +4592,7 @@ export interface Literals<L extends ReadonlyArray<SchemaAST.LiteralValue>>
|
|
|
4391
4592
|
/**
|
|
4392
4593
|
* Creates a union schema from an array of literal values.
|
|
4393
4594
|
*
|
|
4394
|
-
* **Example** (
|
|
4595
|
+
* **Example** (Defining status codes)
|
|
4395
4596
|
*
|
|
4396
4597
|
* ```ts
|
|
4397
4598
|
* import { Schema } from "effect"
|
|
@@ -4526,7 +4727,7 @@ export interface suspend<S extends Top> extends
|
|
|
4526
4727
|
* essential for creating recursive schemas where a schema references itself,
|
|
4527
4728
|
* preventing infinite recursion during schema definition.
|
|
4528
4729
|
*
|
|
4529
|
-
* **Example** (
|
|
4730
|
+
* **Example** (Defining recursive tree schemas)
|
|
4530
4731
|
*
|
|
4531
4732
|
* ```ts
|
|
4532
4733
|
* import { Schema } from "effect"
|
|
@@ -4988,7 +5189,7 @@ export interface compose<To extends Top, From extends Top> extends decodeTo<To,
|
|
|
4988
5189
|
* and is used on the encoding path, while `encode` maps `To["Encoded"]` to
|
|
4989
5190
|
* `From["Type"]` and is used on the decoding path.
|
|
4990
5191
|
*
|
|
4991
|
-
* **Example** (
|
|
5192
|
+
* **Example** (Transforming strings to numbers with a schema transformation)
|
|
4992
5193
|
*
|
|
4993
5194
|
* ```ts
|
|
4994
5195
|
* import { Schema, SchemaGetter } from "effect"
|
|
@@ -5105,7 +5306,7 @@ export function decode<S extends Top, RD = never, RE = never>(transformation: {
|
|
|
5105
5306
|
* `encodeTo(to)(from)` is equivalent to `to.pipe(decodeTo(from))`. The `from`
|
|
5106
5307
|
* schema acts as the target decoded schema and `to` acts as the encoded source.
|
|
5107
5308
|
*
|
|
5108
|
-
* **Example** (
|
|
5309
|
+
* **Example** (Encoding a number back to a string)
|
|
5109
5310
|
*
|
|
5110
5311
|
* ```ts
|
|
5111
5312
|
* import { Schema, SchemaGetter } from "effect"
|
|
@@ -5229,7 +5430,7 @@ export interface withConstructorDefault<S extends Top & WithoutConstructorDefaul
|
|
|
5229
5430
|
* Constructor defaults are applied only during `make*`, not during decoding or
|
|
5230
5431
|
* encoding.
|
|
5231
5432
|
*
|
|
5232
|
-
* **Example** (
|
|
5433
|
+
* **Example** (Defining an optional field with a static default)
|
|
5233
5434
|
*
|
|
5234
5435
|
* ```ts
|
|
5235
5436
|
* import { Effect, Schema } from "effect"
|
|
@@ -5254,7 +5455,7 @@ export function withConstructorDefault<S extends Top & WithoutConstructorDefault
|
|
|
5254
5455
|
defaultValue: Effect.Effect<S["~type.make.in"], SchemaError>
|
|
5255
5456
|
) {
|
|
5256
5457
|
return (schema: S): withConstructorDefault<S> =>
|
|
5257
|
-
make(SchemaAST.withConstructorDefault(schema.ast,
|
|
5458
|
+
make(SchemaAST.withConstructorDefault(schema.ast, InternalSchema.mapSchemaErrorEffect(defaultValue)), { schema })
|
|
5258
5459
|
}
|
|
5259
5460
|
|
|
5260
5461
|
/**
|
|
@@ -5299,7 +5500,7 @@ export type DecodingDefaultOptions = {
|
|
|
5299
5500
|
* - `"passthrough"` (default): include the value in the encoded output.
|
|
5300
5501
|
* - `"omit"`: omit the key from the encoded output.
|
|
5301
5502
|
*
|
|
5302
|
-
* **Example** (
|
|
5503
|
+
* **Example** (Providing a default for a missing struct key)
|
|
5303
5504
|
*
|
|
5304
5505
|
* ```ts
|
|
5305
5506
|
* import { Effect, Schema } from "effect"
|
|
@@ -5324,7 +5525,7 @@ export function withDecodingDefaultKey<S extends Top, R = never>(
|
|
|
5324
5525
|
const encode = options?.encodingStrategy === "omit" ? SchemaGetter.omit() : SchemaGetter.passthrough()
|
|
5325
5526
|
return (self: S): withDecodingDefaultKey<S, R> => {
|
|
5326
5527
|
return optionalKey(toEncoded(self)).pipe(decodeTo(self, {
|
|
5327
|
-
decode: SchemaGetter.withDefault(
|
|
5528
|
+
decode: SchemaGetter.withDefault(InternalSchema.mapSchemaErrorEffect(defaultValue)),
|
|
5328
5529
|
encode
|
|
5329
5530
|
}))
|
|
5330
5531
|
}
|
|
@@ -5407,7 +5608,7 @@ export interface withDecodingDefault<S extends Top, R = never> extends decodeTo<
|
|
|
5407
5608
|
* - `"passthrough"` (default): include the value in the encoded output.
|
|
5408
5609
|
* - `"omit"`: omit the key from the encoded output.
|
|
5409
5610
|
*
|
|
5410
|
-
* **Example** (
|
|
5611
|
+
* **Example** (Providing a default for an optional field value)
|
|
5411
5612
|
*
|
|
5412
5613
|
* ```ts
|
|
5413
5614
|
* import { Effect, Schema } from "effect"
|
|
@@ -5432,7 +5633,7 @@ export function withDecodingDefault<S extends Top, R = never>(
|
|
|
5432
5633
|
const encode = options?.encodingStrategy === "omit" ? SchemaGetter.omit() : SchemaGetter.passthrough()
|
|
5433
5634
|
return (self: S): withDecodingDefault<S, R> => {
|
|
5434
5635
|
return optional(toEncoded(self)).pipe(decodeTo(self, {
|
|
5435
|
-
decode: SchemaGetter.withDefault(
|
|
5636
|
+
decode: SchemaGetter.withDefault(InternalSchema.mapSchemaErrorEffect(defaultValue)),
|
|
5436
5637
|
encode
|
|
5437
5638
|
}))
|
|
5438
5639
|
}
|
|
@@ -5502,7 +5703,7 @@ export interface tag<Tag extends SchemaAST.LiteralValue> extends withConstructor
|
|
|
5502
5703
|
* for discriminator fields in tagged unions. When constructing via `make`, the
|
|
5503
5704
|
* `_tag` field can be omitted and will be filled automatically.
|
|
5504
5705
|
*
|
|
5505
|
-
* **Example** (
|
|
5706
|
+
* **Example** (Defining a discriminated union tag)
|
|
5506
5707
|
*
|
|
5507
5708
|
* ```ts
|
|
5508
5709
|
* import { Schema } from "effect"
|
|
@@ -5536,7 +5737,7 @@ export function tag<Tag extends SchemaAST.LiteralValue>(literal: Tag): tag<Tag>
|
|
|
5536
5737
|
* The tag is filled during decoding and construction, like {@link tag}, but is
|
|
5537
5738
|
* omitted when encoding.
|
|
5538
5739
|
*
|
|
5539
|
-
* **Example** (
|
|
5740
|
+
* **Example** (Omitting tags during encoding)
|
|
5540
5741
|
*
|
|
5541
5742
|
* ```ts
|
|
5542
5743
|
* import { Schema } from "effect"
|
|
@@ -5582,7 +5783,7 @@ export type TaggedStruct<Tag extends SchemaAST.LiteralValue, Fields extends Stru
|
|
|
5582
5783
|
* added automatically. However, when decoding or encoding, the `_tag` field
|
|
5583
5784
|
* must be present in the input.
|
|
5584
5785
|
*
|
|
5585
|
-
* **Example** (
|
|
5786
|
+
* **Example** (Defining a tagged struct shorthand)
|
|
5586
5787
|
*
|
|
5587
5788
|
* ```ts
|
|
5588
5789
|
* import { Schema } from "effect"
|
|
@@ -5781,7 +5982,7 @@ export interface TaggedUnion<Cases extends Record<string, Top>> extends
|
|
|
5781
5982
|
* Each key becomes the `_tag` literal and the value is passed to {@link TaggedStruct}.
|
|
5782
5983
|
* The result includes `cases`, `guards`, `isAnyOf`, and `match` utilities.
|
|
5783
5984
|
*
|
|
5784
|
-
* **Example** (
|
|
5985
|
+
* **Example** (Pattern matching a discriminated union)
|
|
5785
5986
|
*
|
|
5786
5987
|
* ```ts
|
|
5787
5988
|
* import { Schema } from "effect"
|
|
@@ -5848,7 +6049,7 @@ export interface Opaque<Self, S extends Top, Brand> extends
|
|
|
5848
6049
|
* Useful for creating opaque types that are structurally identical to a base struct
|
|
5849
6050
|
* but type-incompatible with it.
|
|
5850
6051
|
*
|
|
5851
|
-
* **Example** (
|
|
6052
|
+
* **Example** (Defining opaque structs)
|
|
5852
6053
|
*
|
|
5853
6054
|
* ```ts
|
|
5854
6055
|
* import { Schema } from "effect"
|
|
@@ -5889,7 +6090,7 @@ export interface instanceOf<T, Iso = T> extends declare<T, Iso> {
|
|
|
5889
6090
|
* Creates a schema that validates values using `instanceof`.
|
|
5890
6091
|
* Decoding and encoding pass the value through unchanged.
|
|
5891
6092
|
*
|
|
5892
|
-
* **Example** (
|
|
6093
|
+
* **Example** (Defining a schema for a built-in class)
|
|
5893
6094
|
*
|
|
5894
6095
|
* ```ts
|
|
5895
6096
|
* import { Schema } from "effect"
|
|
@@ -5947,7 +6148,7 @@ export function link<T>() {
|
|
|
5947
6148
|
* When `abort` is `true`, parsing stops after this filter fails instead of
|
|
5948
6149
|
* collecting later check failures.
|
|
5949
6150
|
*
|
|
5950
|
-
* **Example** (
|
|
6151
|
+
* **Example** (Reporting failure at a nested path)
|
|
5951
6152
|
*
|
|
5952
6153
|
* ```ts
|
|
5953
6154
|
* import { Schema } from "effect"
|
|
@@ -7517,7 +7718,7 @@ export const isBetweenBigDecimal = makeIsBetween({
|
|
|
7517
7718
|
* constraint to ensure generated strings or arrays have at least the required
|
|
7518
7719
|
* length.
|
|
7519
7720
|
*
|
|
7520
|
-
* **Example** (
|
|
7721
|
+
* **Example** (Checking minimum length)
|
|
7521
7722
|
*
|
|
7522
7723
|
* ```ts
|
|
7523
7724
|
* import { Schema } from "effect"
|
|
@@ -9981,7 +10182,7 @@ const DateString = String.annotate({ expected: "a string in ISO 8601 format that
|
|
|
9981
10182
|
* JSON serializer encodes valid dates as ISO 8601 strings; invalid dates encode
|
|
9982
10183
|
* as `"Invalid Date"`.
|
|
9983
10184
|
*
|
|
9984
|
-
* **Example** (Date schema)
|
|
10185
|
+
* **Example** (Defining a Date schema)
|
|
9985
10186
|
*
|
|
9986
10187
|
* ```ts
|
|
9987
10188
|
* import { Schema } from "effect"
|
|
@@ -10099,7 +10300,7 @@ export interface Duration extends declare<Duration_.Duration> {
|
|
|
10099
10300
|
* The default JSON serializer encodes `Duration` as a tagged object with the
|
|
10100
10301
|
* duration type and value.
|
|
10101
10302
|
*
|
|
10102
|
-
* **Example** (Duration schema)
|
|
10303
|
+
* **Example** (Defining a Duration schema)
|
|
10103
10304
|
*
|
|
10104
10305
|
* ```ts
|
|
10105
10306
|
* import { Duration, Schema } from "effect"
|
|
@@ -10762,7 +10963,7 @@ export interface fromFormData<S extends Top> extends decodeTo<S, FormData> {
|
|
|
10762
10963
|
* // Success({"a":"1"})
|
|
10763
10964
|
* ```
|
|
10764
10965
|
*
|
|
10765
|
-
* **Example** (
|
|
10966
|
+
* **Example** (Decoding nested fields)
|
|
10766
10967
|
*
|
|
10767
10968
|
* ```ts
|
|
10768
10969
|
* import { Schema } from "effect"
|
|
@@ -10900,7 +11101,7 @@ export interface fromURLSearchParams<S extends Top> extends decodeTo<S, URLSearc
|
|
|
10900
11101
|
* // Success({"a":"1"})
|
|
10901
11102
|
* ```
|
|
10902
11103
|
*
|
|
10903
|
-
* **Example** (
|
|
11104
|
+
* **Example** (Decoding nested fields)
|
|
10904
11105
|
*
|
|
10905
11106
|
* ```ts
|
|
10906
11107
|
* import { Schema } from "effect"
|
|
@@ -12011,15 +12212,48 @@ export interface Class<Self, S extends Top & { readonly fields: Struct.Fields },
|
|
|
12011
12212
|
} | undefined
|
|
12012
12213
|
): Struct<Simplify<Readonly<To>>>
|
|
12013
12214
|
|
|
12215
|
+
/**
|
|
12216
|
+
* Returns a function that creates a schema-backed subclass with this class's
|
|
12217
|
+
* fields plus additional fields.
|
|
12218
|
+
*
|
|
12219
|
+
* **When to use**
|
|
12220
|
+
*
|
|
12221
|
+
* Use when you need a subclass whose constructor validates both inherited
|
|
12222
|
+
* fields and newly added fields.
|
|
12223
|
+
*
|
|
12224
|
+
* **Details**
|
|
12225
|
+
*
|
|
12226
|
+
* The returned function accepts either a field map or a `Struct`. When you
|
|
12227
|
+
* pass a `Struct`, checks attached to that extension schema are preserved and
|
|
12228
|
+
* combined with checks from the base class schema.
|
|
12229
|
+
*
|
|
12230
|
+
* **Gotchas**
|
|
12231
|
+
*
|
|
12232
|
+
* Checks from a `Struct` argument are evaluated against the full subclass
|
|
12233
|
+
* value after inherited and extension fields are merged. Object-wide checks
|
|
12234
|
+
* such as `isMaxProperties` count inherited fields too.
|
|
12235
|
+
*/
|
|
12014
12236
|
extend<Extended = never, Static = {}, Brand = {}>(
|
|
12015
12237
|
identifier: string
|
|
12016
|
-
):
|
|
12017
|
-
|
|
12018
|
-
|
|
12019
|
-
|
|
12020
|
-
|
|
12021
|
-
|
|
12022
|
-
|
|
12238
|
+
): {
|
|
12239
|
+
<NewFields extends Struct.Fields>(
|
|
12240
|
+
fields: NewFields,
|
|
12241
|
+
annotations?: Annotations.Declaration<Extended, readonly [Struct<Simplify<Assign<S["fields"], NewFields>>>]>
|
|
12242
|
+
): [Extended] extends [never] ? MissingSelfGeneric<"Base.extend"> : InheritStaticMembers<
|
|
12243
|
+
Class<Extended, Struct<Simplify<Assign<S["fields"], NewFields>>>, Self & Brand>,
|
|
12244
|
+
Static
|
|
12245
|
+
>
|
|
12246
|
+
<Extension extends Struct<Struct.Fields>>(
|
|
12247
|
+
schema: Extension,
|
|
12248
|
+
annotations?: Annotations.Declaration<
|
|
12249
|
+
Extended,
|
|
12250
|
+
readonly [Struct<Simplify<Assign<S["fields"], Extension["fields"]>>>]
|
|
12251
|
+
>
|
|
12252
|
+
): [Extended] extends [never] ? MissingSelfGeneric<"Base.extend"> : InheritStaticMembers<
|
|
12253
|
+
Class<Extended, Struct<Simplify<Assign<S["fields"], Extension["fields"]>>>, Self & Brand>,
|
|
12254
|
+
Static
|
|
12255
|
+
>
|
|
12256
|
+
}
|
|
12023
12257
|
}
|
|
12024
12258
|
|
|
12025
12259
|
// Merges custom static members from a parent class onto the extended class,
|
|
@@ -12087,18 +12321,20 @@ function makeClass<
|
|
|
12087
12321
|
static check(...checks: readonly [SchemaAST.Check<Self>, ...Array<SchemaAST.Check<Self>>]) {
|
|
12088
12322
|
return this.rebuild(SchemaAST.appendChecks(this.ast, checks))
|
|
12089
12323
|
}
|
|
12090
|
-
static extend
|
|
12324
|
+
static extend(
|
|
12091
12325
|
identifier: string
|
|
12092
|
-
)
|
|
12093
|
-
|
|
12094
|
-
|
|
12095
|
-
|
|
12096
|
-
|
|
12097
|
-
const
|
|
12326
|
+
) {
|
|
12327
|
+
return (
|
|
12328
|
+
schema: Struct.Fields | Struct<Struct.Fields>,
|
|
12329
|
+
annotations?: Annotations.Declaration<any, readonly [any]>
|
|
12330
|
+
) => {
|
|
12331
|
+
const extension = isStruct(schema) ? schema : Struct(schema)
|
|
12332
|
+
const fields = { ...struct.fields, ...extension.fields }
|
|
12333
|
+
const ast = SchemaAST.struct(fields, struct.ast.checks, { identifier })
|
|
12098
12334
|
return makeClass(
|
|
12099
12335
|
this,
|
|
12100
12336
|
identifier,
|
|
12101
|
-
makeStruct(SchemaAST.
|
|
12337
|
+
makeStruct(SchemaAST.appendChecks(ast, extension.ast.checks), fields),
|
|
12102
12338
|
annotations,
|
|
12103
12339
|
proto
|
|
12104
12340
|
)
|
|
@@ -12198,7 +12434,7 @@ type MissingSelfGeneric<Usage extends string> =
|
|
|
12198
12434
|
*
|
|
12199
12435
|
* Passing `disableChecks` in the options skips constructor validation.
|
|
12200
12436
|
*
|
|
12201
|
-
* **Example** (
|
|
12437
|
+
* **Example** (Defining a basic class)
|
|
12202
12438
|
*
|
|
12203
12439
|
* ```ts
|
|
12204
12440
|
* import { Schema } from "effect"
|
|
@@ -12258,7 +12494,7 @@ export const Class: {
|
|
|
12258
12494
|
*
|
|
12259
12495
|
* Passing `disableChecks` in the options skips constructor validation.
|
|
12260
12496
|
*
|
|
12261
|
-
* **Example** (
|
|
12497
|
+
* **Example** (Defining a basic class)
|
|
12262
12498
|
*
|
|
12263
12499
|
* ```ts
|
|
12264
12500
|
* import { Schema } from "effect"
|
|
@@ -12318,7 +12554,7 @@ export const Class: {
|
|
|
12318
12554
|
*
|
|
12319
12555
|
* Passing `disableChecks` in the options skips constructor validation.
|
|
12320
12556
|
*
|
|
12321
|
-
* **Example** (
|
|
12557
|
+
* **Example** (Defining a basic class)
|
|
12322
12558
|
*
|
|
12323
12559
|
* ```ts
|
|
12324
12560
|
* import { Schema } from "effect"
|
|
@@ -12381,7 +12617,7 @@ export const Class: {
|
|
|
12381
12617
|
*
|
|
12382
12618
|
* Passing `disableChecks` in the options skips constructor validation.
|
|
12383
12619
|
*
|
|
12384
|
-
* **Example** (
|
|
12620
|
+
* **Example** (Defining a basic class)
|
|
12385
12621
|
*
|
|
12386
12622
|
* ```ts
|
|
12387
12623
|
* import { Schema } from "effect"
|
|
@@ -12455,7 +12691,7 @@ export const Class: {
|
|
|
12455
12691
|
* The optional `identifier` parameter overrides the schema identifier;
|
|
12456
12692
|
* it defaults to the `tag` value.
|
|
12457
12693
|
*
|
|
12458
|
-
* **Example** (
|
|
12694
|
+
* **Example** (Defining a tagged class)
|
|
12459
12695
|
*
|
|
12460
12696
|
* ```ts
|
|
12461
12697
|
* import { Schema } from "effect"
|
|
@@ -12486,7 +12722,7 @@ export const TaggedClass: {
|
|
|
12486
12722
|
* The optional `identifier` parameter overrides the schema identifier;
|
|
12487
12723
|
* it defaults to the `tag` value.
|
|
12488
12724
|
*
|
|
12489
|
-
* **Example** (
|
|
12725
|
+
* **Example** (Defining a tagged class)
|
|
12490
12726
|
*
|
|
12491
12727
|
* ```ts
|
|
12492
12728
|
* import { Schema } from "effect"
|
|
@@ -12517,7 +12753,7 @@ export const TaggedClass: {
|
|
|
12517
12753
|
* The optional `identifier` parameter overrides the schema identifier;
|
|
12518
12754
|
* it defaults to the `tag` value.
|
|
12519
12755
|
*
|
|
12520
|
-
* **Example** (
|
|
12756
|
+
* **Example** (Defining a tagged class)
|
|
12521
12757
|
*
|
|
12522
12758
|
* ```ts
|
|
12523
12759
|
* import { Schema } from "effect"
|
|
@@ -12552,7 +12788,7 @@ export const TaggedClass: {
|
|
|
12552
12788
|
* The optional `identifier` parameter overrides the schema identifier;
|
|
12553
12789
|
* it defaults to the `tag` value.
|
|
12554
12790
|
*
|
|
12555
|
-
* **Example** (
|
|
12791
|
+
* **Example** (Defining a tagged class)
|
|
12556
12792
|
*
|
|
12557
12793
|
* ```ts
|
|
12558
12794
|
* import { Schema } from "effect"
|
|
@@ -12727,7 +12963,7 @@ export const ErrorClass: {
|
|
|
12727
12963
|
* Use to define typed errors that are schema validated, yielded in `Effect.gen`,
|
|
12728
12964
|
* and matched as tagged union members.
|
|
12729
12965
|
*
|
|
12730
|
-
* **Example** (
|
|
12966
|
+
* **Example** (Defining a tagged error class)
|
|
12731
12967
|
*
|
|
12732
12968
|
* ```ts
|
|
12733
12969
|
* import { Effect, Schema } from "effect"
|
|
@@ -12754,7 +12990,7 @@ export const TaggedErrorClass: {
|
|
|
12754
12990
|
* Use to define typed errors that are schema validated, yielded in `Effect.gen`,
|
|
12755
12991
|
* and matched as tagged union members.
|
|
12756
12992
|
*
|
|
12757
|
-
* **Example** (
|
|
12993
|
+
* **Example** (Defining a tagged error class)
|
|
12758
12994
|
*
|
|
12759
12995
|
* ```ts
|
|
12760
12996
|
* import { Effect, Schema } from "effect"
|
|
@@ -12781,7 +13017,7 @@ export const TaggedErrorClass: {
|
|
|
12781
13017
|
* Use to define typed errors that are schema validated, yielded in `Effect.gen`,
|
|
12782
13018
|
* and matched as tagged union members.
|
|
12783
13019
|
*
|
|
12784
|
-
* **Example** (
|
|
13020
|
+
* **Example** (Defining a tagged error class)
|
|
12785
13021
|
*
|
|
12786
13022
|
* ```ts
|
|
12787
13023
|
* import { Effect, Schema } from "effect"
|
|
@@ -12813,7 +13049,7 @@ export const TaggedErrorClass: {
|
|
|
12813
13049
|
* Use to define typed errors that are schema validated, yielded in `Effect.gen`,
|
|
12814
13050
|
* and matched as tagged union members.
|
|
12815
13051
|
*
|
|
12816
|
-
* **Example** (
|
|
13052
|
+
* **Example** (Defining a tagged error class)
|
|
12817
13053
|
*
|
|
12818
13054
|
* ```ts
|
|
12819
13055
|
* import { Effect, Schema } from "effect"
|
|
@@ -13137,7 +13373,7 @@ export function overrideToEquivalence<S extends Top>(toEquivalence: () => Equiva
|
|
|
13137
13373
|
* every field (and nested field) compares equal according to the schema
|
|
13138
13374
|
* structure.
|
|
13139
13375
|
*
|
|
13140
|
-
* **Example** (
|
|
13376
|
+
* **Example** (Comparing structs)
|
|
13141
13377
|
*
|
|
13142
13378
|
* ```ts
|
|
13143
13379
|
* import { Schema } from "effect"
|
|
@@ -13328,7 +13564,7 @@ function toCodecJsonBase(ast: SchemaAST.AST, recur: (ast: SchemaAST.AST) => Sche
|
|
|
13328
13564
|
if (ast.propertySignatures.some((ps) => typeof ps.name !== "string")) {
|
|
13329
13565
|
throw new globalThis.Error("Objects property names must be strings", { cause: ast })
|
|
13330
13566
|
}
|
|
13331
|
-
return ast.recur(recur)
|
|
13567
|
+
return ast.recur(recur, SchemaAST.parameterFromString)
|
|
13332
13568
|
}
|
|
13333
13569
|
case "Union": {
|
|
13334
13570
|
const sortedTypes = InternalSchema.jsonReorder(ast.types)
|
|
@@ -13608,7 +13844,7 @@ function serializerTree(
|
|
|
13608
13844
|
if (ast.propertySignatures.some((ps) => typeof ps.name !== "string")) {
|
|
13609
13845
|
throw new globalThis.Error("Objects property names must be strings", { cause: ast })
|
|
13610
13846
|
}
|
|
13611
|
-
return ast.recur(recur)
|
|
13847
|
+
return ast.recur(recur, SchemaAST.parameterFromString)
|
|
13612
13848
|
}
|
|
13613
13849
|
case "Union": {
|
|
13614
13850
|
const sortedTypes = treeReorder(ast.types)
|