effect 3.13.2 → 3.13.4
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/cjs/FiberHandle.js +5 -3
- package/dist/cjs/FiberHandle.js.map +1 -1
- package/dist/cjs/FiberMap.js +5 -3
- package/dist/cjs/FiberMap.js.map +1 -1
- package/dist/cjs/FiberSet.js +6 -3
- package/dist/cjs/FiberSet.js.map +1 -1
- package/dist/cjs/JSONSchema.js +7 -7
- package/dist/cjs/JSONSchema.js.map +1 -1
- package/dist/cjs/Option.js +3 -15
- package/dist/cjs/Option.js.map +1 -1
- package/dist/cjs/ParseResult.js +1 -1
- package/dist/cjs/ParseResult.js.map +1 -1
- package/dist/cjs/Schema.js +593 -522
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/TRef.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js +4 -5
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/stm/core.js +5 -5
- package/dist/cjs/internal/stm/core.js.map +1 -1
- package/dist/cjs/internal/stm/entry.js.map +1 -0
- package/dist/cjs/internal/stm/journal.js.map +1 -0
- package/dist/cjs/internal/stm/stm.js +2 -2
- package/dist/cjs/internal/stm/stm.js.map +1 -1
- package/dist/cjs/internal/stm/{stm/stmState.js → stmState.js} +7 -7
- package/dist/cjs/internal/stm/stmState.js.map +1 -0
- package/dist/cjs/internal/stm/{stm/tExit.js → tExit.js} +5 -5
- package/dist/cjs/internal/stm/tExit.js.map +1 -0
- package/dist/cjs/internal/stm/tMap.js.map +1 -1
- package/dist/cjs/internal/stm/tRef.js +2 -2
- package/dist/cjs/internal/stm/tRef.js.map +1 -1
- package/dist/cjs/internal/stm/{stm/tryCommit.js → tryCommit.js} +1 -1
- package/dist/cjs/internal/stm/tryCommit.js.map +1 -0
- package/dist/cjs/internal/stm/txnId.js.map +1 -0
- package/dist/cjs/internal/stm/versioned.js.map +1 -0
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Array.d.ts +6 -6
- package/dist/dts/Array.d.ts.map +1 -1
- package/dist/dts/Context.d.ts +1 -1
- package/dist/dts/Context.d.ts.map +1 -1
- package/dist/dts/FiberHandle.d.ts.map +1 -1
- package/dist/dts/FiberMap.d.ts.map +1 -1
- package/dist/dts/FiberSet.d.ts.map +1 -1
- package/dist/dts/Option.d.ts +3 -42
- package/dist/dts/Option.d.ts.map +1 -1
- package/dist/dts/ParseResult.d.ts.map +1 -1
- package/dist/dts/Schema.d.ts +400 -270
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/dts/internal/stm/entry.d.ts.map +1 -0
- package/dist/dts/internal/stm/journal.d.ts.map +1 -0
- package/dist/dts/internal/stm/stmState.d.ts.map +1 -0
- package/dist/dts/internal/stm/tExit.d.ts.map +1 -0
- package/dist/dts/internal/stm/tryCommit.d.ts.map +1 -0
- package/dist/dts/internal/stm/txnId.d.ts.map +1 -0
- package/dist/dts/internal/stm/versioned.d.ts.map +1 -0
- package/dist/esm/FiberHandle.js +5 -3
- package/dist/esm/FiberHandle.js.map +1 -1
- package/dist/esm/FiberMap.js +5 -3
- package/dist/esm/FiberMap.js.map +1 -1
- package/dist/esm/FiberSet.js +6 -3
- package/dist/esm/FiberSet.js.map +1 -1
- package/dist/esm/JSONSchema.js +7 -7
- package/dist/esm/JSONSchema.js.map +1 -1
- package/dist/esm/Option.js +3 -15
- package/dist/esm/Option.js.map +1 -1
- package/dist/esm/ParseResult.js +1 -1
- package/dist/esm/ParseResult.js.map +1 -1
- package/dist/esm/Schema.js +538 -490
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/TRef.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js +4 -5
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/stm/core.js +5 -5
- package/dist/esm/internal/stm/core.js.map +1 -1
- package/dist/esm/internal/stm/entry.js.map +1 -0
- package/dist/esm/internal/stm/journal.js.map +1 -0
- package/dist/esm/internal/stm/stm.js +2 -2
- package/dist/esm/internal/stm/stm.js.map +1 -1
- package/dist/esm/internal/stm/{stm/stmState.js → stmState.js} +7 -7
- package/dist/esm/internal/stm/stmState.js.map +1 -0
- package/dist/esm/internal/stm/{stm/tExit.js → tExit.js} +5 -5
- package/dist/esm/internal/stm/tExit.js.map +1 -0
- package/dist/esm/internal/stm/tMap.js.map +1 -1
- package/dist/esm/internal/stm/tRef.js +2 -2
- package/dist/esm/internal/stm/tRef.js.map +1 -1
- package/dist/esm/internal/stm/{stm/tryCommit.js → tryCommit.js} +1 -1
- package/dist/esm/internal/stm/tryCommit.js.map +1 -0
- package/dist/esm/internal/stm/txnId.js.map +1 -0
- package/dist/esm/internal/stm/versioned.js.map +1 -0
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/Array.ts +6 -6
- package/src/Context.ts +1 -1
- package/src/FiberHandle.ts +11 -7
- package/src/FiberMap.ts +11 -7
- package/src/FiberSet.ts +9 -7
- package/src/JSONSchema.ts +7 -7
- package/src/Option.ts +7 -46
- package/src/ParseResult.ts +1 -3
- package/src/Schema.ts +1337 -1137
- package/src/TRef.ts +3 -3
- package/src/internal/fiberRuntime.ts +5 -4
- package/src/internal/stm/core.ts +5 -5
- package/src/internal/stm/{stm/entry.ts → entry.ts} +1 -1
- package/src/internal/stm/{stm/journal.ts → journal.ts} +1 -1
- package/src/internal/stm/stm.ts +2 -2
- package/src/internal/stm/{stm/stmState.ts → stmState.ts} +7 -7
- package/src/internal/stm/{stm/tExit.ts → tExit.ts} +7 -7
- package/src/internal/stm/tMap.ts +1 -1
- package/src/internal/stm/tRef.ts +4 -4
- package/src/internal/stm/{stm/tryCommit.ts → tryCommit.ts} +2 -2
- package/src/internal/version.ts +1 -1
- package/dist/cjs/internal/stm/stm/entry.js.map +0 -1
- package/dist/cjs/internal/stm/stm/journal.js.map +0 -1
- package/dist/cjs/internal/stm/stm/opCodes/stm.js +0 -31
- package/dist/cjs/internal/stm/stm/opCodes/stm.js.map +0 -1
- package/dist/cjs/internal/stm/stm/opCodes/stmState.js +0 -13
- package/dist/cjs/internal/stm/stm/opCodes/stmState.js.map +0 -1
- package/dist/cjs/internal/stm/stm/opCodes/strategy.js +0 -13
- package/dist/cjs/internal/stm/stm/opCodes/strategy.js.map +0 -1
- package/dist/cjs/internal/stm/stm/opCodes/tExit.js +0 -17
- package/dist/cjs/internal/stm/stm/opCodes/tExit.js.map +0 -1
- package/dist/cjs/internal/stm/stm/opCodes/tryCommit.js +0 -11
- package/dist/cjs/internal/stm/stm/opCodes/tryCommit.js.map +0 -1
- package/dist/cjs/internal/stm/stm/stmState.js.map +0 -1
- package/dist/cjs/internal/stm/stm/tExit.js.map +0 -1
- package/dist/cjs/internal/stm/stm/tryCommit.js.map +0 -1
- package/dist/cjs/internal/stm/stm/txnId.js.map +0 -1
- package/dist/cjs/internal/stm/stm/versioned.js.map +0 -1
- package/dist/dts/internal/stm/stm/entry.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/journal.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/opCodes/stm.d.ts +0 -2
- package/dist/dts/internal/stm/stm/opCodes/stm.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/opCodes/stmState.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/opCodes/strategy.d.ts +0 -2
- package/dist/dts/internal/stm/stm/opCodes/strategy.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/opCodes/tExit.d.ts +0 -2
- package/dist/dts/internal/stm/stm/opCodes/tExit.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/opCodes/tryCommit.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/stmState.d.ts +0 -2
- package/dist/dts/internal/stm/stm/stmState.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/tExit.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/tryCommit.d.ts +0 -2
- package/dist/dts/internal/stm/stm/tryCommit.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/txnId.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/versioned.d.ts.map +0 -1
- package/dist/esm/internal/stm/stm/entry.js.map +0 -1
- package/dist/esm/internal/stm/stm/journal.js.map +0 -1
- package/dist/esm/internal/stm/stm/opCodes/stm.js +0 -25
- package/dist/esm/internal/stm/stm/opCodes/stm.js.map +0 -1
- package/dist/esm/internal/stm/stm/opCodes/stmState.js +0 -7
- package/dist/esm/internal/stm/stm/opCodes/stmState.js.map +0 -1
- package/dist/esm/internal/stm/stm/opCodes/strategy.js +0 -7
- package/dist/esm/internal/stm/stm/opCodes/strategy.js.map +0 -1
- package/dist/esm/internal/stm/stm/opCodes/tExit.js +0 -11
- package/dist/esm/internal/stm/stm/opCodes/tExit.js.map +0 -1
- package/dist/esm/internal/stm/stm/opCodes/tryCommit.js +0 -5
- package/dist/esm/internal/stm/stm/opCodes/tryCommit.js.map +0 -1
- package/dist/esm/internal/stm/stm/stmState.js.map +0 -1
- package/dist/esm/internal/stm/stm/tExit.js.map +0 -1
- package/dist/esm/internal/stm/stm/tryCommit.js.map +0 -1
- package/dist/esm/internal/stm/stm/txnId.js.map +0 -1
- package/dist/esm/internal/stm/stm/versioned.js.map +0 -1
- package/src/internal/stm/stm/opCodes/stm.ts +0 -71
- package/src/internal/stm/stm/opCodes/stmState.ts +0 -17
- package/src/internal/stm/stm/opCodes/strategy.ts +0 -17
- package/src/internal/stm/stm/opCodes/tExit.ts +0 -29
- package/src/internal/stm/stm/opCodes/tryCommit.ts +0 -11
- /package/dist/cjs/internal/stm/{stm/entry.js → entry.js} +0 -0
- /package/dist/cjs/internal/stm/{stm/journal.js → journal.js} +0 -0
- /package/dist/cjs/internal/stm/{stm/txnId.js → txnId.js} +0 -0
- /package/dist/cjs/internal/stm/{stm/versioned.js → versioned.js} +0 -0
- /package/dist/dts/internal/stm/{stm/entry.d.ts → entry.d.ts} +0 -0
- /package/dist/dts/internal/stm/{stm/journal.d.ts → journal.d.ts} +0 -0
- /package/dist/dts/internal/stm/{stm/opCodes/stmState.d.ts → stmState.d.ts} +0 -0
- /package/dist/dts/internal/stm/{stm/tExit.d.ts → tExit.d.ts} +0 -0
- /package/dist/dts/internal/stm/{stm/opCodes/tryCommit.d.ts → tryCommit.d.ts} +0 -0
- /package/dist/dts/internal/stm/{stm/txnId.d.ts → txnId.d.ts} +0 -0
- /package/dist/dts/internal/stm/{stm/versioned.d.ts → versioned.d.ts} +0 -0
- /package/dist/esm/internal/stm/{stm/entry.js → entry.js} +0 -0
- /package/dist/esm/internal/stm/{stm/journal.js → journal.js} +0 -0
- /package/dist/esm/internal/stm/{stm/txnId.js → txnId.js} +0 -0
- /package/dist/esm/internal/stm/{stm/versioned.js → versioned.js} +0 -0
- /package/src/internal/stm/{stm/txnId.ts → txnId.ts} +0 -0
- /package/src/internal/stm/{stm/versioned.ts → versioned.ts} +0 -0
package/dist/cjs/Schema.js
CHANGED
|
@@ -3,17 +3,49 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.Array = exports.Any = void 0;
|
|
7
|
+
exports.ArrayEnsure = ArrayEnsure;
|
|
8
|
+
exports.Char = exports.CauseFromSelf = exports.Cause = exports.CapitalizedSchemaId = exports.Capitalized = exports.Capitalize = exports.BrandSchemaId = exports.BooleanFromUnknown = exports.BooleanFromString = exports.Boolean = exports.BigIntFromSelf = exports.BigIntFromNumber = exports.BigInt = exports.BigDecimalFromSelf = exports.BigDecimalFromNumber = exports.BigDecimal = exports.BetweenSchemaId = exports.BetweenDurationSchemaId = exports.BetweenDateSchemaId = exports.BetweenBigIntSchemaId = exports.BetweenBigDecimalSchemaId = exports.ArrayFormatterIssue = void 0;
|
|
9
|
+
exports.Chunk = Chunk;
|
|
10
|
+
exports.HashMapFromSelf = exports.HashMap = exports.GreaterThanSchemaId = exports.GreaterThanOrEqualToSchemaId = exports.GreaterThanOrEqualToDurationSchemaId = exports.GreaterThanOrEqualToDateSchemaId = exports.GreaterThanOrEqualToBigIntSchemaId = exports.GreaterThanOrEqualToBigDecimalSchemaId = exports.GreaterThanDurationSchemaId = exports.GreaterThanDateSchemaId = exports.GreaterThanBigIntSchemaId = exports.GreaterThanBigDecimalSchemaId = exports.FromPropertySignature = exports.FiniteSchemaId = exports.Finite = exports.FiberIdFromSelf = exports.FiberId = exports.ExitFromSelf = exports.Exit = exports.Enums = exports.EndsWithSchemaId = exports.EitherFromUnion = exports.EitherFromSelf = exports.Either = exports.DurationFromSelf = exports.DurationFromNanos = exports.DurationFromMillis = exports.Duration = exports.Defect = exports.DateTimeZonedFromSelf = exports.DateTimeZoned = exports.DateTimeUtcFromSelf = exports.DateTimeUtcFromNumber = exports.DateTimeUtcFromDate = exports.DateTimeUtc = exports.DateFromString = exports.DateFromSelfSchemaId = exports.DateFromSelf = exports.DateFromNumber = exports.Date = exports.DataFromSelf = exports.Data = exports.Config = exports.Class = exports.ChunkFromSelf = void 0;
|
|
11
|
+
exports.HashSet = HashSet;
|
|
12
|
+
exports.LessThanSchemaId = exports.LessThanOrEqualToSchemaId = exports.LessThanOrEqualToDurationSchemaId = exports.LessThanOrEqualToDateSchemaId = exports.LessThanOrEqualToBigIntSchemaId = exports.LessThanOrEqualToBigDecimalSchemaId = exports.LessThanDurationSchemaId = exports.LessThanDateSchemaId = exports.LessThanBigIntSchemaId = exports.LessThanBigDecimalSchemaId = exports.LengthSchemaId = exports.JsonNumberSchemaId = exports.JsonNumber = exports.ItemsCountSchemaId = exports.IntSchemaId = exports.Int = exports.InstanceOfSchemaId = exports.IncludesSchemaId = exports.HashSetFromSelf = void 0;
|
|
13
|
+
exports.List = List;
|
|
14
|
+
exports.ListFromSelf = void 0;
|
|
7
15
|
exports.Literal = Literal;
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
16
|
+
exports.LowercasedSchemaId = exports.Lowercased = exports.Lowercase = void 0;
|
|
17
|
+
exports.Map = map;
|
|
18
|
+
exports.MapFromSelf = exports.MapFromRecord = void 0;
|
|
19
|
+
exports.NonEmptyArray = exports.Never = exports.NegativeBigIntFromSelf = exports.NegativeBigInt = exports.NegativeBigDecimalSchemaId = exports.NegativeBigDecimalFromSelf = exports.Negative = exports.MultipleOfSchemaId = exports.MinLengthSchemaId = exports.MinItemsSchemaId = exports.MaxLengthSchemaId = exports.MaxItemsSchemaId = void 0;
|
|
20
|
+
exports.NonEmptyArrayEnsure = NonEmptyArrayEnsure;
|
|
21
|
+
exports.NonEmptyChunk = NonEmptyChunk;
|
|
22
|
+
exports.Object = exports.NumberFromString = exports.Number = exports.NullishOr = exports.NullOr = exports.Null = exports.Not = exports.NonPositiveBigIntFromSelf = exports.NonPositiveBigInt = exports.NonPositiveBigDecimalSchemaId = exports.NonPositiveBigDecimalFromSelf = exports.NonPositive = exports.NonNegativeInt = exports.NonNegativeBigIntFromSelf = exports.NonNegativeBigInt = exports.NonNegativeBigDecimalSchemaId = exports.NonNegativeBigDecimalFromSelf = exports.NonNegative = exports.NonNaNSchemaId = exports.NonNaN = exports.NonEmptyTrimmedString = exports.NonEmptyString = exports.NonEmptyChunkFromSelf = void 0;
|
|
23
|
+
exports.Option = Option;
|
|
24
|
+
exports.OptionFromNonEmptyTrimmedString = void 0;
|
|
25
|
+
exports.OptionFromNullOr = OptionFromNullOr;
|
|
26
|
+
exports.OptionFromNullishOr = OptionFromNullishOr;
|
|
27
|
+
exports.OptionFromSelf = void 0;
|
|
28
|
+
exports.OptionFromUndefinedOr = OptionFromUndefinedOr;
|
|
29
|
+
exports.PropertySignatureTypeId = exports.PropertySignatureTransformation = exports.PropertySignatureDeclaration = exports.PropertyKey = exports.PositiveBigIntFromSelf = exports.PositiveBigInt = exports.PositiveBigDecimalSchemaId = exports.PositiveBigDecimalFromSelf = exports.Positive = exports.PatternSchemaId = void 0;
|
|
30
|
+
exports.ReadonlyMap = ReadonlyMap;
|
|
31
|
+
exports.ReadonlyMapFromSelf = exports.ReadonlyMapFromRecord = void 0;
|
|
32
|
+
exports.ReadonlySet = ReadonlySet;
|
|
33
|
+
exports.Record = exports.ReadonlySetFromSelf = void 0;
|
|
34
|
+
exports.Redacted = Redacted;
|
|
35
|
+
exports.RefineSchemaId = exports.RedactedFromSelf = void 0;
|
|
36
|
+
exports.Set = set;
|
|
37
|
+
exports.SetFromSelf = void 0;
|
|
38
|
+
exports.SortedSet = SortedSet;
|
|
39
|
+
exports.StringFromUriComponent = exports.StringFromHex = exports.StringFromBase64Url = exports.StringFromBase64 = exports.String = exports.StartsWithSchemaId = exports.SortedSetFromSelf = void 0;
|
|
10
40
|
exports.Struct = Struct;
|
|
11
41
|
exports.TrimmedSchemaId = exports.Trimmed = exports.Trim = exports.ToPropertySignature = exports.TimeZoneOffsetFromSelf = exports.TimeZoneOffset = exports.TimeZoneNamedFromSelf = exports.TimeZoneNamed = exports.TimeZoneFromSelf = exports.TimeZone = exports.TemplateLiteralParser = exports.TemplateLiteral = exports.TaggedStruct = exports.TaggedRequest = exports.TaggedError = exports.TaggedClass = exports.SymbolFromSelf = exports.Symbol = void 0;
|
|
12
42
|
exports.Tuple = Tuple;
|
|
13
43
|
exports.Uint8 = exports.UUIDSchemaId = exports.UUID = exports.URLFromSelf = exports.URL = exports.ULIDSchemaId = exports.ULID = exports.TypeId = void 0;
|
|
14
44
|
exports.UndefinedOr = exports.Undefined = exports.UncapitalizedSchemaId = exports.Uncapitalized = exports.Uncapitalize = exports.Uint8ArrayFromSelf = exports.Uint8ArrayFromHex = exports.Uint8ArrayFromBase64Url = exports.Uint8ArrayFromBase64 = exports.Uint8Array = void 0;
|
|
15
45
|
exports.Union = Union;
|
|
16
|
-
exports.
|
|
46
|
+
exports.annotations = exports.Void = exports.ValidDateSchemaId = exports.ValidDateFromSelf = exports.UppercasedSchemaId = exports.Uppercased = exports.Uppercase = exports.Unknown = exports.UniqueSymbolFromSelf = void 0;
|
|
47
|
+
exports.asSchema = asSchema;
|
|
48
|
+
exports.asWithResult = exports.asSerializableWithResult = exports.asSerializable = void 0;
|
|
17
49
|
Object.defineProperty(exports, "asserts", {
|
|
18
50
|
enumerable: true,
|
|
19
51
|
get: function () {
|
|
@@ -78,7 +110,10 @@ Object.defineProperty(exports, "encodeUnknownSync", {
|
|
|
78
110
|
});
|
|
79
111
|
exports.failureSchema = exports.extend = exports.exitSchema = exports.equivalence = exports.endsWith = exports.encodedSchema = exports.encodedBoundSchema = void 0;
|
|
80
112
|
exports.filter = filter;
|
|
81
|
-
exports.
|
|
113
|
+
exports.greaterThanOrEqualToDuration = exports.greaterThanOrEqualToDate = exports.greaterThanOrEqualToBigInt = exports.greaterThanOrEqualToBigDecimal = exports.greaterThanOrEqualTo = exports.greaterThanDuration = exports.greaterThanDate = exports.greaterThanBigInt = exports.greaterThanBigDecimal = exports.greaterThan = exports.getNumberIndexedAccess = exports.getClassTag = exports.fromKey = exports.fromBrand = exports.format = exports.finite = exports.filterEffect = void 0;
|
|
114
|
+
exports.head = head;
|
|
115
|
+
exports.headNonEmpty = headNonEmpty;
|
|
116
|
+
exports.int = exports.instanceOf = exports.includes = exports.headOrElse = void 0;
|
|
82
117
|
Object.defineProperty(exports, "is", {
|
|
83
118
|
enumerable: true,
|
|
84
119
|
get: function () {
|
|
@@ -86,7 +121,12 @@ Object.defineProperty(exports, "is", {
|
|
|
86
121
|
}
|
|
87
122
|
});
|
|
88
123
|
exports.keyof = exports.itemsCount = exports.isSchema = exports.isPropertySignature = void 0;
|
|
89
|
-
exports.
|
|
124
|
+
exports.lowercased = exports.lessThanOrEqualToDuration = exports.lessThanOrEqualToDate = exports.lessThanOrEqualToBigInt = exports.lessThanOrEqualToBigDecimal = exports.lessThanOrEqualTo = exports.lessThanDuration = exports.lessThanDate = exports.lessThanBigInt = exports.lessThanBigDecimal = exports.lessThan = exports.length = void 0;
|
|
125
|
+
exports.make = make;
|
|
126
|
+
exports.parseJson = exports.optionalWith = exports.optionalToRequired = exports.optionalToOptional = exports.optionalElement = exports.optional = exports.omit = exports.nonPositiveBigInt = exports.nonPositiveBigDecimal = exports.nonPositive = exports.nonNegativeBigInt = exports.nonNegativeBigDecimal = exports.nonNegative = exports.nonNaN = exports.nonEmptyString = exports.negativeBigInt = exports.negativeBigDecimal = exports.negative = exports.mutable = exports.multipleOf = exports.minLength = exports.minItems = exports.maxLength = exports.maxItems = exports.makePropertySignature = void 0;
|
|
127
|
+
exports.parseNumber = parseNumber;
|
|
128
|
+
exports.transform = exports.tag = exports.symbolWithResult = exports.symbolSerializable = exports.suspend = exports.successSchema = exports.startsWith = exports.standardSchemaV1 = exports.split = exports.serializeSuccess = exports.serializeFailure = exports.serializeExit = exports.serialize = exports.serializableSchema = exports.requiredToOptional = exports.required = exports.rename = exports.propertySignature = exports.positiveBigInt = exports.positiveBigDecimal = exports.positive = exports.pluck = exports.pickLiteral = exports.pick = exports.pattern = exports.partialWith = exports.partial = void 0;
|
|
129
|
+
exports.transformLiteral = transformLiteral;
|
|
90
130
|
exports.transformLiterals = transformLiterals;
|
|
91
131
|
exports.validateEither = exports.validate = exports.validDate = exports.uppercased = exports.uncapitalized = exports.typeSchema = exports.trimmed = exports.transformOrFail = void 0;
|
|
92
132
|
Object.defineProperty(exports, "validateOption", {
|
|
@@ -136,7 +176,6 @@ var option_ = _interopRequireWildcard(require("./Option.js"));
|
|
|
136
176
|
var ParseResult = _interopRequireWildcard(require("./ParseResult.js"));
|
|
137
177
|
var _Pipeable = require("./Pipeable.js");
|
|
138
178
|
var Predicate = _interopRequireWildcard(require("./Predicate.js"));
|
|
139
|
-
var record_ = _interopRequireWildcard(require("./Record.js"));
|
|
140
179
|
var redacted_ = _interopRequireWildcard(require("./Redacted.js"));
|
|
141
180
|
var Request = _interopRequireWildcard(require("./Request.js"));
|
|
142
181
|
var scheduler_ = _interopRequireWildcard(require("./Scheduler.js"));
|
|
@@ -159,24 +198,25 @@ const TypeId = exports.TypeId = /*#__PURE__*/Symbol.for("effect/Schema");
|
|
|
159
198
|
* @category constructors
|
|
160
199
|
* @since 3.10.0
|
|
161
200
|
*/
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
201
|
+
function make(ast) {
|
|
202
|
+
return class SchemaClass {
|
|
203
|
+
[TypeId] = variance;
|
|
204
|
+
static ast = ast;
|
|
205
|
+
static annotations(annotations) {
|
|
206
|
+
return make(mergeSchemaAnnotations(this.ast, annotations));
|
|
207
|
+
}
|
|
208
|
+
static pipe() {
|
|
209
|
+
return (0, _Pipeable.pipeArguments)(this, arguments);
|
|
210
|
+
}
|
|
211
|
+
static toString() {
|
|
212
|
+
return String(ast);
|
|
213
|
+
}
|
|
214
|
+
static Type;
|
|
215
|
+
static Encoded;
|
|
216
|
+
static Context;
|
|
217
|
+
static [TypeId] = variance;
|
|
218
|
+
};
|
|
219
|
+
}
|
|
180
220
|
const variance = {
|
|
181
221
|
/* c8 ignore next */
|
|
182
222
|
_A: _ => _,
|
|
@@ -296,12 +336,13 @@ const mergeSchemaAnnotations = (ast, annotations) => AST.annotations(ast, toASTA
|
|
|
296
336
|
/**
|
|
297
337
|
* @since 3.10.0
|
|
298
338
|
*/
|
|
299
|
-
|
|
339
|
+
function asSchema(schema) {
|
|
340
|
+
return schema;
|
|
341
|
+
}
|
|
300
342
|
/**
|
|
301
343
|
* @category formatting
|
|
302
344
|
* @since 3.10.0
|
|
303
345
|
*/
|
|
304
|
-
exports.asSchema = asSchema;
|
|
305
346
|
const format = schema => String(schema.ast);
|
|
306
347
|
/**
|
|
307
348
|
* The `encodedSchema` function allows you to extract the `Encoded` portion of a
|
|
@@ -453,13 +494,17 @@ const validatePromise = (schema, options) => {
|
|
|
453
494
|
exports.validatePromise = validatePromise;
|
|
454
495
|
const isSchema = u => Predicate.hasProperty(u, TypeId) && Predicate.isObject(u[TypeId]);
|
|
455
496
|
exports.isSchema = isSchema;
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
497
|
+
function getDefaultLiteralAST(literals) {
|
|
498
|
+
return AST.isMembers(literals) ? AST.Union.make(AST.mapMembers(literals, literal => new AST.Literal(literal))) : new AST.Literal(literals[0]);
|
|
499
|
+
}
|
|
500
|
+
function makeLiteralClass(literals, ast = getDefaultLiteralAST(literals)) {
|
|
501
|
+
return class LiteralClass extends make(ast) {
|
|
502
|
+
static annotations(annotations) {
|
|
503
|
+
return makeLiteralClass(this.literals, mergeSchemaAnnotations(this.ast, annotations));
|
|
504
|
+
}
|
|
505
|
+
static literals = [...literals];
|
|
506
|
+
};
|
|
507
|
+
}
|
|
463
508
|
function Literal(...literals) {
|
|
464
509
|
return array_.isNonEmptyReadonlyArray(literals) ? makeLiteralClass(literals) : Never;
|
|
465
510
|
}
|
|
@@ -618,9 +663,9 @@ const TemplateLiteralParser = (...params) => {
|
|
|
618
663
|
}
|
|
619
664
|
return class TemplateLiteralParserClass extends transformOrFail(from, to, {
|
|
620
665
|
strict: false,
|
|
621
|
-
decode: (
|
|
622
|
-
const match = re.exec(
|
|
623
|
-
return match ? ParseResult.succeed(match.slice(1, params.length + 1)) : ParseResult.fail(new ParseResult.Type(ast,
|
|
666
|
+
decode: (i, _, ast) => {
|
|
667
|
+
const match = re.exec(i);
|
|
668
|
+
return match ? ParseResult.succeed(match.slice(1, params.length + 1)) : ParseResult.fail(new ParseResult.Type(ast, i, `${re.source}: no match for ${JSON.stringify(i)}`));
|
|
624
669
|
},
|
|
625
670
|
encode: tuple => ParseResult.succeed(tuple.join(""))
|
|
626
671
|
}) {
|
|
@@ -628,12 +673,20 @@ const TemplateLiteralParser = (...params) => {
|
|
|
628
673
|
};
|
|
629
674
|
};
|
|
630
675
|
exports.TemplateLiteralParser = TemplateLiteralParser;
|
|
631
|
-
const declareConstructor = (typeParameters, options, annotations) =>
|
|
676
|
+
const declareConstructor = (typeParameters, options, annotations) => makeDeclareClass(typeParameters, new AST.Declaration(typeParameters.map(tp => tp.ast), (...typeParameters) => options.decode(...typeParameters.map(make)), (...typeParameters) => options.encode(...typeParameters.map(make)), toASTAnnotations(annotations)));
|
|
632
677
|
const declarePrimitive = (is, annotations) => {
|
|
633
678
|
const decodeUnknown = () => (input, _, ast) => is(input) ? ParseResult.succeed(input) : ParseResult.fail(new ParseResult.Type(ast, input));
|
|
634
679
|
const encodeUnknown = decodeUnknown;
|
|
635
|
-
return
|
|
680
|
+
return makeDeclareClass([], new AST.Declaration([], decodeUnknown, encodeUnknown, toASTAnnotations(annotations)));
|
|
636
681
|
};
|
|
682
|
+
function makeDeclareClass(typeParameters, ast) {
|
|
683
|
+
return class DeclareClass extends make(ast) {
|
|
684
|
+
static annotations(annotations) {
|
|
685
|
+
return makeDeclareClass(this.typeParameters, mergeSchemaAnnotations(this.ast, annotations));
|
|
686
|
+
}
|
|
687
|
+
static typeParameters = [...typeParameters];
|
|
688
|
+
};
|
|
689
|
+
}
|
|
637
690
|
/**
|
|
638
691
|
* The constraint `R extends Schema.Context<P[number]>` enforces dependencies solely from `typeParameters`.
|
|
639
692
|
* This ensures that when you call `Schema.to` or `Schema.from`, you receive a schema with a `never` context.
|
|
@@ -662,16 +715,19 @@ const BrandSchemaId = exports.BrandSchemaId = /*#__PURE__*/Symbol.for("effect/Sc
|
|
|
662
715
|
* @category constructors
|
|
663
716
|
* @since 3.10.0
|
|
664
717
|
*/
|
|
665
|
-
const fromBrand = (constructor, annotations) => self =>
|
|
666
|
-
const
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
718
|
+
const fromBrand = (constructor, annotations) => self => {
|
|
719
|
+
const out = makeBrandClass(self, new AST.Refinement(self.ast, function predicate(a, _, ast) {
|
|
720
|
+
const either = constructor.either(a);
|
|
721
|
+
return either_.isLeft(either) ? option_.some(new ParseResult.Type(ast, a, either.left.map(v => v.message).join(", "))) : option_.none();
|
|
722
|
+
}, toASTAnnotations({
|
|
723
|
+
schemaId: BrandSchemaId,
|
|
724
|
+
[BrandSchemaId]: {
|
|
725
|
+
constructor
|
|
726
|
+
},
|
|
727
|
+
...annotations
|
|
728
|
+
})));
|
|
729
|
+
return out;
|
|
730
|
+
};
|
|
675
731
|
/**
|
|
676
732
|
* @category schema id
|
|
677
733
|
* @since 3.10.0
|
|
@@ -754,12 +810,14 @@ exports.Boolean = Boolean$;
|
|
|
754
810
|
class Object$ extends /*#__PURE__*/make(AST.objectKeyword) {}
|
|
755
811
|
exports.Object = Object$;
|
|
756
812
|
const getDefaultUnionAST = members => AST.Union.make(members.map(m => m.ast));
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
813
|
+
function makeUnionClass(members, ast = getDefaultUnionAST(members)) {
|
|
814
|
+
return class UnionClass extends make(ast) {
|
|
815
|
+
static annotations(annotations) {
|
|
816
|
+
return makeUnionClass(this.members, mergeSchemaAnnotations(this.ast, annotations));
|
|
817
|
+
}
|
|
818
|
+
static members = [...members];
|
|
819
|
+
};
|
|
820
|
+
}
|
|
763
821
|
function Union(...members) {
|
|
764
822
|
return AST.isMembers(members) ? makeUnionClass(members) : array_.isNonEmptyReadonlyArray(members) ? members[0] : Never;
|
|
765
823
|
}
|
|
@@ -817,30 +875,36 @@ class ElementImpl {
|
|
|
817
875
|
}
|
|
818
876
|
}
|
|
819
877
|
const getDefaultTupleTypeAST = (elements, rest) => new AST.TupleType(elements.map(el => isSchema(el) ? new AST.OptionalType(el.ast, false) : el.ast), rest.map(el => isSchema(el) ? new AST.Type(el.ast) : el.ast), true);
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
878
|
+
function makeTupleTypeClass(elements, rest, ast = getDefaultTupleTypeAST(elements, rest)) {
|
|
879
|
+
return class TupleTypeClass extends make(ast) {
|
|
880
|
+
static annotations(annotations) {
|
|
881
|
+
return makeTupleTypeClass(this.elements, this.rest, mergeSchemaAnnotations(this.ast, annotations));
|
|
882
|
+
}
|
|
883
|
+
static elements = [...elements];
|
|
884
|
+
static rest = [...rest];
|
|
885
|
+
};
|
|
886
|
+
}
|
|
827
887
|
function Tuple(...args) {
|
|
828
888
|
return Array.isArray(args[0]) ? makeTupleTypeClass(args[0], args.slice(1)) : makeTupleTypeClass(args, []);
|
|
829
889
|
}
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
890
|
+
function makeArrayClass(value, ast) {
|
|
891
|
+
return class ArrayClass extends makeTupleTypeClass([], [value], ast) {
|
|
892
|
+
static annotations(annotations) {
|
|
893
|
+
return makeArrayClass(this.value, mergeSchemaAnnotations(this.ast, annotations));
|
|
894
|
+
}
|
|
895
|
+
static value = value;
|
|
896
|
+
};
|
|
897
|
+
}
|
|
836
898
|
const Array$ = value => makeArrayClass(value);
|
|
837
899
|
exports.Array = Array$;
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
900
|
+
function makeNonEmptyArrayClass(value, ast) {
|
|
901
|
+
return class NonEmptyArrayClass extends makeTupleTypeClass([value], [value], ast) {
|
|
902
|
+
static annotations(annotations) {
|
|
903
|
+
return makeNonEmptyArrayClass(this.value, mergeSchemaAnnotations(this.ast, annotations));
|
|
904
|
+
}
|
|
905
|
+
static value = value;
|
|
906
|
+
};
|
|
907
|
+
}
|
|
844
908
|
/**
|
|
845
909
|
* @category constructors
|
|
846
910
|
* @since 3.10.0
|
|
@@ -851,28 +915,24 @@ const NonEmptyArray = value => makeNonEmptyArrayClass(value);
|
|
|
851
915
|
* @since 3.10.0
|
|
852
916
|
*/
|
|
853
917
|
exports.NonEmptyArray = NonEmptyArray;
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
return class ArrayEnsureClass extends transform(Union(value_, Array$(value_)), Array$(typeSchema(value_)), {
|
|
918
|
+
function ArrayEnsure(value) {
|
|
919
|
+
return transform(Union(value, Array$(value)), Array$(typeSchema(asSchema(value))), {
|
|
857
920
|
strict: true,
|
|
858
|
-
decode: array_.ensure,
|
|
859
|
-
encode:
|
|
860
|
-
})
|
|
861
|
-
}
|
|
921
|
+
decode: i => array_.ensure(i),
|
|
922
|
+
encode: a => a.length === 1 ? a[0] : a
|
|
923
|
+
});
|
|
924
|
+
}
|
|
862
925
|
/**
|
|
863
926
|
* @category constructors
|
|
864
927
|
* @since 3.10.0
|
|
865
928
|
*/
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
const value_ = asSchema(value);
|
|
869
|
-
return class NonEmptyArrayEnsureClass extends transform(Union(value_, NonEmptyArray(value_)), NonEmptyArray(typeSchema(value_)), {
|
|
929
|
+
function NonEmptyArrayEnsure(value) {
|
|
930
|
+
return transform(Union(value, NonEmptyArray(value)), NonEmptyArray(typeSchema(asSchema(value))), {
|
|
870
931
|
strict: true,
|
|
871
|
-
decode: array_.
|
|
872
|
-
encode:
|
|
873
|
-
})
|
|
874
|
-
}
|
|
875
|
-
exports.NonEmptyArrayEnsure = NonEmptyArrayEnsure;
|
|
932
|
+
decode: i => array_.isNonEmptyReadonlyArray(i) ? i : array_.of(i),
|
|
933
|
+
encode: a => a.length === 1 ? a[0] : a
|
|
934
|
+
});
|
|
935
|
+
}
|
|
876
936
|
const formatPropertySignatureToken = isOptional => isOptional ? "\"?:\"" : "\":\"";
|
|
877
937
|
/**
|
|
878
938
|
* @category PropertySignature
|
|
@@ -1475,22 +1535,26 @@ exports.omit = omit;
|
|
|
1475
1535
|
const pluck = exports.pluck = /*#__PURE__*/(0, _Function.dual)(2, (schema, key) => {
|
|
1476
1536
|
const ps = AST.getPropertyKeyIndexedAccess(AST.typeAST(schema.ast), key);
|
|
1477
1537
|
const value = make(ps.isOptional ? AST.orUndefined(ps.type) : ps.type);
|
|
1478
|
-
|
|
1538
|
+
const out = transform(schema.pipe(pick(key)), value, {
|
|
1479
1539
|
strict: true,
|
|
1480
|
-
decode:
|
|
1481
|
-
encode:
|
|
1482
|
-
[key]:
|
|
1540
|
+
decode: i => i[key],
|
|
1541
|
+
encode: a => ps.isOptional && a === undefined ? {} : {
|
|
1542
|
+
[key]: a
|
|
1483
1543
|
}
|
|
1484
1544
|
});
|
|
1545
|
+
return out;
|
|
1485
1546
|
});
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1547
|
+
function makeBrandClass(from, ast) {
|
|
1548
|
+
return class BrandClass extends make(ast) {
|
|
1549
|
+
static annotations(annotations) {
|
|
1550
|
+
return makeBrandClass(this.from, mergeSchemaAnnotations(this.ast, annotations));
|
|
1551
|
+
}
|
|
1552
|
+
static make = (a, options) => {
|
|
1553
|
+
return getDisableValidationMakeOption(options) ? a : ParseResult.validateSync(this)(a);
|
|
1554
|
+
};
|
|
1555
|
+
static from = from;
|
|
1492
1556
|
};
|
|
1493
|
-
}
|
|
1557
|
+
}
|
|
1494
1558
|
/**
|
|
1495
1559
|
* Returns a nominal branded schema by applying a brand to a given schema.
|
|
1496
1560
|
*
|
|
@@ -1521,7 +1585,7 @@ const brand = (brand, annotations) => self => {
|
|
|
1521
1585
|
[AST.BrandAnnotationId]: annotation,
|
|
1522
1586
|
...annotations
|
|
1523
1587
|
}));
|
|
1524
|
-
return makeBrandClass(ast);
|
|
1588
|
+
return makeBrandClass(self, ast);
|
|
1525
1589
|
};
|
|
1526
1590
|
/**
|
|
1527
1591
|
* @category combinators
|
|
@@ -1724,7 +1788,7 @@ const extend = exports.extend = /*#__PURE__*/(0, _Function.dual)(2, (self, that)
|
|
|
1724
1788
|
* @category combinators
|
|
1725
1789
|
* @since 3.10.0
|
|
1726
1790
|
*/
|
|
1727
|
-
const compose = exports.compose = /*#__PURE__*/(0, _Function.dual)(args => isSchema(args[1]), (from, to) =>
|
|
1791
|
+
const compose = exports.compose = /*#__PURE__*/(0, _Function.dual)(args => isSchema(args[1]), (from, to) => makeTransformationClass(from, to, AST.compose(from.ast, to.ast)));
|
|
1728
1792
|
/**
|
|
1729
1793
|
* @category constructors
|
|
1730
1794
|
* @since 3.10.0
|
|
@@ -1736,17 +1800,19 @@ const suspend = f => make(new AST.Suspend(() => f().ast));
|
|
|
1736
1800
|
*/
|
|
1737
1801
|
exports.suspend = suspend;
|
|
1738
1802
|
const RefineSchemaId = exports.RefineSchemaId = /*#__PURE__*/Symbol.for("effect/SchemaId/Refine");
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1803
|
+
function makeRefineClass(from, filter, ast) {
|
|
1804
|
+
return class RefineClass extends make(ast) {
|
|
1805
|
+
static annotations(annotations) {
|
|
1806
|
+
return makeRefineClass(this.from, this.filter, mergeSchemaAnnotations(this.ast, annotations));
|
|
1807
|
+
}
|
|
1808
|
+
static [RefineSchemaId] = from;
|
|
1809
|
+
static from = from;
|
|
1810
|
+
static filter = filter;
|
|
1811
|
+
static make = (a, options) => {
|
|
1812
|
+
return getDisableValidationMakeOption(options) ? a : ParseResult.validateSync(this)(a);
|
|
1813
|
+
};
|
|
1748
1814
|
};
|
|
1749
|
-
}
|
|
1815
|
+
}
|
|
1750
1816
|
const fromFilterPredicateReturnTypeItem = (item, ast, input) => {
|
|
1751
1817
|
if (Predicate.isBoolean(item)) {
|
|
1752
1818
|
return item ? option_.none() : option_.some(new ParseResult.Type(ast, input));
|
|
@@ -1790,19 +1856,21 @@ function filter(predicate, annotations) {
|
|
|
1790
1856
|
*/
|
|
1791
1857
|
const filterEffect = exports.filterEffect = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => transformOrFail(self, typeSchema(self), {
|
|
1792
1858
|
strict: true,
|
|
1793
|
-
decode: (
|
|
1794
|
-
onNone: () => ParseResult.succeed(
|
|
1859
|
+
decode: (i, options, ast) => ParseResult.flatMap(f(i, options, ast), filterReturnType => option_.match(toFilterParseIssue(filterReturnType, ast, i), {
|
|
1860
|
+
onNone: () => ParseResult.succeed(i),
|
|
1795
1861
|
onSome: ParseResult.fail
|
|
1796
1862
|
})),
|
|
1797
|
-
encode: ParseResult.succeed
|
|
1863
|
+
encode: a => ParseResult.succeed(a)
|
|
1798
1864
|
}));
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1865
|
+
function makeTransformationClass(from, to, ast) {
|
|
1866
|
+
return class TransformationClass extends make(ast) {
|
|
1867
|
+
static annotations(annotations) {
|
|
1868
|
+
return makeTransformationClass(this.from, this.to, mergeSchemaAnnotations(this.ast, annotations));
|
|
1869
|
+
}
|
|
1870
|
+
static from = from;
|
|
1871
|
+
static to = to;
|
|
1872
|
+
};
|
|
1873
|
+
}
|
|
1806
1874
|
/**
|
|
1807
1875
|
* Create a new `Schema` by transforming the input and output of an existing `Schema`
|
|
1808
1876
|
* using the provided decoding functions.
|
|
@@ -1838,12 +1906,13 @@ const transform = exports.transform = /*#__PURE__*/(0, _Function.dual)(args => i
|
|
|
1838
1906
|
* @category constructors
|
|
1839
1907
|
* @since 3.10.0
|
|
1840
1908
|
*/
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1909
|
+
function transformLiteral(from, to) {
|
|
1910
|
+
return transform(Literal(from), Literal(to), {
|
|
1911
|
+
strict: true,
|
|
1912
|
+
decode: () => to,
|
|
1913
|
+
encode: () => from
|
|
1914
|
+
});
|
|
1915
|
+
}
|
|
1847
1916
|
function transformLiterals(...pairs) {
|
|
1848
1917
|
return Union(...pairs.map(([from, to]) => transformLiteral(from, to)));
|
|
1849
1918
|
}
|
|
@@ -1962,6 +2031,42 @@ const minLength = (minLength, annotations) => self => self.pipe(filter(a => a.le
|
|
|
1962
2031
|
* @since 3.10.0
|
|
1963
2032
|
*/
|
|
1964
2033
|
exports.minLength = minLength;
|
|
2034
|
+
const LengthSchemaId = exports.LengthSchemaId = schemaId_.LengthSchemaId;
|
|
2035
|
+
/**
|
|
2036
|
+
* @category string filters
|
|
2037
|
+
* @since 3.10.0
|
|
2038
|
+
*/
|
|
2039
|
+
const length = (length, annotations) => self => {
|
|
2040
|
+
const minLength = Predicate.isObject(length) ? Math.max(0, Math.floor(length.min)) : Math.max(0, Math.floor(length));
|
|
2041
|
+
const maxLength = Predicate.isObject(length) ? Math.max(minLength, Math.floor(length.max)) : minLength;
|
|
2042
|
+
if (minLength !== maxLength) {
|
|
2043
|
+
return self.pipe(filter(a => a.length >= minLength && a.length <= maxLength, {
|
|
2044
|
+
schemaId: LengthSchemaId,
|
|
2045
|
+
title: `length({ min: ${minLength}, max: ${maxLength})`,
|
|
2046
|
+
description: `a string at least ${minLength} character(s) and at most ${maxLength} character(s) long`,
|
|
2047
|
+
jsonSchema: {
|
|
2048
|
+
minLength,
|
|
2049
|
+
maxLength
|
|
2050
|
+
},
|
|
2051
|
+
...annotations
|
|
2052
|
+
}));
|
|
2053
|
+
}
|
|
2054
|
+
return self.pipe(filter(a => a.length === minLength, {
|
|
2055
|
+
schemaId: LengthSchemaId,
|
|
2056
|
+
title: `length(${minLength})`,
|
|
2057
|
+
description: minLength === 1 ? `a single character` : `a string ${minLength} character(s) long`,
|
|
2058
|
+
jsonSchema: {
|
|
2059
|
+
minLength,
|
|
2060
|
+
maxLength: minLength
|
|
2061
|
+
},
|
|
2062
|
+
...annotations
|
|
2063
|
+
}));
|
|
2064
|
+
};
|
|
2065
|
+
/**
|
|
2066
|
+
* @category schema id
|
|
2067
|
+
* @since 3.10.0
|
|
2068
|
+
*/
|
|
2069
|
+
exports.length = length;
|
|
1965
2070
|
const PatternSchemaId = exports.PatternSchemaId = /*#__PURE__*/Symbol.for("effect/SchemaId/Pattern");
|
|
1966
2071
|
/**
|
|
1967
2072
|
* @category string filters
|
|
@@ -2095,6 +2200,35 @@ class Lowercased extends /*#__PURE__*/String$.pipe( /*#__PURE__*/lowercased({
|
|
|
2095
2200
|
* @since 3.10.0
|
|
2096
2201
|
*/
|
|
2097
2202
|
exports.Lowercased = Lowercased;
|
|
2203
|
+
const UppercasedSchemaId = exports.UppercasedSchemaId = /*#__PURE__*/Symbol.for("effect/SchemaId/Uppercased");
|
|
2204
|
+
/**
|
|
2205
|
+
* Verifies that a string is uppercased.
|
|
2206
|
+
*
|
|
2207
|
+
* @category string filters
|
|
2208
|
+
* @since 3.10.0
|
|
2209
|
+
*/
|
|
2210
|
+
const uppercased = annotations => self => self.pipe(filter(a => a === a.toUpperCase(), {
|
|
2211
|
+
schemaId: UppercasedSchemaId,
|
|
2212
|
+
title: "uppercased",
|
|
2213
|
+
description: "an uppercase string",
|
|
2214
|
+
jsonSchema: {
|
|
2215
|
+
pattern: "^[^a-z]*$"
|
|
2216
|
+
},
|
|
2217
|
+
...annotations
|
|
2218
|
+
}));
|
|
2219
|
+
/**
|
|
2220
|
+
* @category string constructors
|
|
2221
|
+
* @since 3.10.0
|
|
2222
|
+
*/
|
|
2223
|
+
exports.uppercased = uppercased;
|
|
2224
|
+
class Uppercased extends /*#__PURE__*/String$.pipe( /*#__PURE__*/uppercased({
|
|
2225
|
+
identifier: "Uppercased"
|
|
2226
|
+
})) {}
|
|
2227
|
+
/**
|
|
2228
|
+
* @category schema id
|
|
2229
|
+
* @since 3.10.0
|
|
2230
|
+
*/
|
|
2231
|
+
exports.Uppercased = Uppercased;
|
|
2098
2232
|
const CapitalizedSchemaId = exports.CapitalizedSchemaId = /*#__PURE__*/Symbol.for("effect/SchemaId/Capitalized");
|
|
2099
2233
|
/**
|
|
2100
2234
|
* Verifies that a string is capitalized.
|
|
@@ -2148,78 +2282,13 @@ exports.uncapitalized = uncapitalized;
|
|
|
2148
2282
|
class Uncapitalized extends /*#__PURE__*/String$.pipe( /*#__PURE__*/uncapitalized({
|
|
2149
2283
|
identifier: "Uncapitalized"
|
|
2150
2284
|
})) {}
|
|
2151
|
-
/**
|
|
2152
|
-
* @category schema id
|
|
2153
|
-
* @since 3.10.0
|
|
2154
|
-
*/
|
|
2155
|
-
exports.Uncapitalized = Uncapitalized;
|
|
2156
|
-
const UppercasedSchemaId = exports.UppercasedSchemaId = /*#__PURE__*/Symbol.for("effect/SchemaId/Uppercased");
|
|
2157
|
-
/**
|
|
2158
|
-
* Verifies that a string is uppercased.
|
|
2159
|
-
*
|
|
2160
|
-
* @category string filters
|
|
2161
|
-
* @since 3.10.0
|
|
2162
|
-
*/
|
|
2163
|
-
const uppercased = annotations => self => self.pipe(filter(a => a === a.toUpperCase(), {
|
|
2164
|
-
schemaId: UppercasedSchemaId,
|
|
2165
|
-
title: "uppercased",
|
|
2166
|
-
description: "an uppercase string",
|
|
2167
|
-
jsonSchema: {
|
|
2168
|
-
pattern: "^[^a-z]*$"
|
|
2169
|
-
},
|
|
2170
|
-
...annotations
|
|
2171
|
-
}));
|
|
2172
|
-
/**
|
|
2173
|
-
* @category string constructors
|
|
2174
|
-
* @since 3.10.0
|
|
2175
|
-
*/
|
|
2176
|
-
exports.uppercased = uppercased;
|
|
2177
|
-
class Uppercased extends /*#__PURE__*/String$.pipe( /*#__PURE__*/uppercased({
|
|
2178
|
-
identifier: "Uppercased"
|
|
2179
|
-
})) {}
|
|
2180
|
-
/**
|
|
2181
|
-
* @category schema id
|
|
2182
|
-
* @since 3.10.0
|
|
2183
|
-
*/
|
|
2184
|
-
exports.Uppercased = Uppercased;
|
|
2185
|
-
const LengthSchemaId = exports.LengthSchemaId = schemaId_.LengthSchemaId;
|
|
2186
|
-
/**
|
|
2187
|
-
* @category string filters
|
|
2188
|
-
* @since 3.10.0
|
|
2189
|
-
*/
|
|
2190
|
-
const length = (length, annotations) => self => {
|
|
2191
|
-
const minLength = Predicate.isObject(length) ? Math.max(0, Math.floor(length.min)) : Math.max(0, Math.floor(length));
|
|
2192
|
-
const maxLength = Predicate.isObject(length) ? Math.max(minLength, Math.floor(length.max)) : minLength;
|
|
2193
|
-
if (minLength !== maxLength) {
|
|
2194
|
-
return self.pipe(filter(a => a.length >= minLength && a.length <= maxLength, {
|
|
2195
|
-
schemaId: LengthSchemaId,
|
|
2196
|
-
title: `length({ min: ${minLength}, max: ${maxLength})`,
|
|
2197
|
-
description: `a string at least ${minLength} character(s) and at most ${maxLength} character(s) long`,
|
|
2198
|
-
jsonSchema: {
|
|
2199
|
-
minLength,
|
|
2200
|
-
maxLength
|
|
2201
|
-
},
|
|
2202
|
-
...annotations
|
|
2203
|
-
}));
|
|
2204
|
-
}
|
|
2205
|
-
return self.pipe(filter(a => a.length === minLength, {
|
|
2206
|
-
schemaId: LengthSchemaId,
|
|
2207
|
-
title: `length(${minLength})`,
|
|
2208
|
-
description: minLength === 1 ? `a single character` : `a string ${minLength} character(s) long`,
|
|
2209
|
-
jsonSchema: {
|
|
2210
|
-
minLength,
|
|
2211
|
-
maxLength: minLength
|
|
2212
|
-
},
|
|
2213
|
-
...annotations
|
|
2214
|
-
}));
|
|
2215
|
-
};
|
|
2216
2285
|
/**
|
|
2217
2286
|
* A schema representing a single character.
|
|
2218
2287
|
*
|
|
2219
2288
|
* @category string constructors
|
|
2220
2289
|
* @since 3.10.0
|
|
2221
2290
|
*/
|
|
2222
|
-
exports.
|
|
2291
|
+
exports.Uncapitalized = Uncapitalized;
|
|
2223
2292
|
class Char extends /*#__PURE__*/String$.pipe( /*#__PURE__*/length(1, {
|
|
2224
2293
|
identifier: "Char"
|
|
2225
2294
|
})) {}
|
|
@@ -2244,7 +2313,7 @@ class Lowercase extends /*#__PURE__*/transform(String$.annotations({
|
|
|
2244
2313
|
description: "a string that will be converted to lowercase"
|
|
2245
2314
|
}), Lowercased, {
|
|
2246
2315
|
strict: true,
|
|
2247
|
-
decode:
|
|
2316
|
+
decode: i => i.toLowerCase(),
|
|
2248
2317
|
encode: _Function.identity
|
|
2249
2318
|
}).annotations({
|
|
2250
2319
|
identifier: "Lowercase"
|
|
@@ -2260,7 +2329,7 @@ class Uppercase extends /*#__PURE__*/transform(String$.annotations({
|
|
|
2260
2329
|
description: "a string that will be converted to uppercase"
|
|
2261
2330
|
}), Uppercased, {
|
|
2262
2331
|
strict: true,
|
|
2263
|
-
decode:
|
|
2332
|
+
decode: i => i.toUpperCase(),
|
|
2264
2333
|
encode: _Function.identity
|
|
2265
2334
|
}).annotations({
|
|
2266
2335
|
identifier: "Uppercase"
|
|
@@ -2276,7 +2345,7 @@ class Capitalize extends /*#__PURE__*/transform(String$.annotations({
|
|
|
2276
2345
|
description: "a string that will be converted to a capitalized format"
|
|
2277
2346
|
}), Capitalized, {
|
|
2278
2347
|
strict: true,
|
|
2279
|
-
decode:
|
|
2348
|
+
decode: i => string_.capitalize(i),
|
|
2280
2349
|
encode: _Function.identity
|
|
2281
2350
|
}).annotations({
|
|
2282
2351
|
identifier: "Capitalize"
|
|
@@ -2292,7 +2361,7 @@ class Uncapitalize extends /*#__PURE__*/transform(String$.annotations({
|
|
|
2292
2361
|
description: "a string that will be converted to an uncapitalized format"
|
|
2293
2362
|
}), Uncapitalized, {
|
|
2294
2363
|
strict: true,
|
|
2295
|
-
decode:
|
|
2364
|
+
decode: i => string_.uncapitalize(i),
|
|
2296
2365
|
encode: _Function.identity
|
|
2297
2366
|
}).annotations({
|
|
2298
2367
|
identifier: "Uncapitalize"
|
|
@@ -2336,7 +2405,7 @@ class Trim extends /*#__PURE__*/transform(String$.annotations({
|
|
|
2336
2405
|
description: "a string that will be trimmed"
|
|
2337
2406
|
}), Trimmed, {
|
|
2338
2407
|
strict: true,
|
|
2339
|
-
decode:
|
|
2408
|
+
decode: i => i.trim(),
|
|
2340
2409
|
encode: _Function.identity
|
|
2341
2410
|
}).annotations({
|
|
2342
2411
|
identifier: "Trim"
|
|
@@ -2352,22 +2421,22 @@ const split = separator => transform(String$.annotations({
|
|
|
2352
2421
|
description: "a string that will be split"
|
|
2353
2422
|
}), Array$(String$), {
|
|
2354
2423
|
strict: true,
|
|
2355
|
-
decode:
|
|
2356
|
-
encode:
|
|
2424
|
+
decode: i => i.split(separator),
|
|
2425
|
+
encode: a => a.join(separator)
|
|
2357
2426
|
});
|
|
2358
2427
|
exports.split = split;
|
|
2359
2428
|
const getErrorMessage = e => e instanceof Error ? e.message : String(e);
|
|
2360
2429
|
const getParseJsonTransformation = options => transformOrFail(String$.annotations({
|
|
2361
|
-
|
|
2430
|
+
description: "a string to be decoded into JSON"
|
|
2362
2431
|
}), Unknown, {
|
|
2363
2432
|
strict: true,
|
|
2364
|
-
decode: (
|
|
2365
|
-
try: () => JSON.parse(
|
|
2366
|
-
catch: e => new ParseResult.Type(ast,
|
|
2433
|
+
decode: (i, _, ast) => ParseResult.try({
|
|
2434
|
+
try: () => JSON.parse(i, options?.reviver),
|
|
2435
|
+
catch: e => new ParseResult.Type(ast, i, getErrorMessage(e))
|
|
2367
2436
|
}),
|
|
2368
|
-
encode: (
|
|
2369
|
-
try: () => JSON.stringify(
|
|
2370
|
-
catch: e => new ParseResult.Type(ast,
|
|
2437
|
+
encode: (a, _, ast) => ParseResult.try({
|
|
2438
|
+
try: () => JSON.stringify(a, options?.replacer, options?.space),
|
|
2439
|
+
catch: e => new ParseResult.Type(ast, a, getErrorMessage(e))
|
|
2371
2440
|
})
|
|
2372
2441
|
}).annotations({
|
|
2373
2442
|
title: "parseJson",
|
|
@@ -2466,11 +2535,11 @@ class URL$ extends /*#__PURE__*/transformOrFail(String$.annotations({
|
|
|
2466
2535
|
description: "a string to be decoded into a URL"
|
|
2467
2536
|
}), URLFromSelf, {
|
|
2468
2537
|
strict: true,
|
|
2469
|
-
decode: (
|
|
2470
|
-
try: () => new URL(
|
|
2471
|
-
catch: e => new ParseResult.Type(ast,
|
|
2538
|
+
decode: (i, _, ast) => ParseResult.try({
|
|
2539
|
+
try: () => new URL(i),
|
|
2540
|
+
catch: e => new ParseResult.Type(ast, i, `Unable to decode ${JSON.stringify(i)} into a URL. ${getErrorMessage(e)}`)
|
|
2472
2541
|
}),
|
|
2473
|
-
encode:
|
|
2542
|
+
encode: a => ParseResult.succeed(a.toString())
|
|
2474
2543
|
}).annotations({
|
|
2475
2544
|
identifier: "URL",
|
|
2476
2545
|
pretty: () => url => url.toString()
|
|
@@ -2704,30 +2773,37 @@ const nonNegative = annotations => greaterThanOrEqualTo(0, {
|
|
|
2704
2773
|
* @since 3.10.0
|
|
2705
2774
|
*/
|
|
2706
2775
|
exports.nonNegative = nonNegative;
|
|
2707
|
-
const clamp = (minimum, maximum) => self =>
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2776
|
+
const clamp = (minimum, maximum) => self => {
|
|
2777
|
+
return transform(self, typeSchema(self).pipe(between(minimum, maximum)), {
|
|
2778
|
+
strict: false,
|
|
2779
|
+
decode: i => number_.clamp(i, {
|
|
2780
|
+
minimum,
|
|
2781
|
+
maximum
|
|
2782
|
+
}),
|
|
2783
|
+
encode: _Function.identity
|
|
2784
|
+
});
|
|
2785
|
+
};
|
|
2715
2786
|
/**
|
|
2716
|
-
* Transforms a `string` into a `number` by parsing the string using the `parse`
|
|
2787
|
+
* Transforms a `string` into a `number` by parsing the string using the `parse`
|
|
2788
|
+
* function of the `effect/Number` module.
|
|
2717
2789
|
*
|
|
2718
|
-
* It returns an error if the value can't be converted (for example when
|
|
2790
|
+
* It returns an error if the value can't be converted (for example when
|
|
2791
|
+
* non-numeric characters are provided).
|
|
2719
2792
|
*
|
|
2720
|
-
* The following special string values are supported: "NaN", "Infinity",
|
|
2793
|
+
* The following special string values are supported: "NaN", "Infinity",
|
|
2794
|
+
* "-Infinity".
|
|
2721
2795
|
*
|
|
2722
2796
|
* @category number transformations
|
|
2723
2797
|
* @since 3.10.0
|
|
2724
2798
|
*/
|
|
2725
2799
|
exports.clamp = clamp;
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2800
|
+
function parseNumber(self) {
|
|
2801
|
+
return transformOrFail(self, Number$, {
|
|
2802
|
+
strict: false,
|
|
2803
|
+
decode: (i, _, ast) => ParseResult.fromOption(number_.parse(i), () => new ParseResult.Type(ast, i, `Unable to decode ${JSON.stringify(i)} into a number`)),
|
|
2804
|
+
encode: a => ParseResult.succeed(String(a))
|
|
2805
|
+
});
|
|
2806
|
+
}
|
|
2731
2807
|
/**
|
|
2732
2808
|
* This schema transforms a `string` into a `number` by parsing the string using the `parse` function of the `effect/Number` module.
|
|
2733
2809
|
*
|
|
@@ -2738,7 +2814,6 @@ const parseNumber = self => transformOrFail(self, Number$, {
|
|
|
2738
2814
|
* @category number transformations
|
|
2739
2815
|
* @since 3.10.0
|
|
2740
2816
|
*/
|
|
2741
|
-
exports.parseNumber = parseNumber;
|
|
2742
2817
|
class NumberFromString extends /*#__PURE__*/parseNumber(String$.annotations({
|
|
2743
2818
|
description: "a string to be decoded into a number"
|
|
2744
2819
|
})).annotations({
|
|
@@ -2839,11 +2914,11 @@ class Not extends /*#__PURE__*/transform( /*#__PURE__*/Boolean$.annotations({
|
|
|
2839
2914
|
description: "a boolean that will be negated"
|
|
2840
2915
|
}), Boolean$, {
|
|
2841
2916
|
strict: true,
|
|
2842
|
-
decode: boolean_.not,
|
|
2843
|
-
encode: boolean_.not
|
|
2917
|
+
decode: i => boolean_.not(i),
|
|
2918
|
+
encode: a => boolean_.not(a)
|
|
2844
2919
|
}) {}
|
|
2845
2920
|
exports.Not = Not;
|
|
2846
|
-
const encodeSymbol = (sym,
|
|
2921
|
+
const encodeSymbol = (sym, ast) => {
|
|
2847
2922
|
const key = Symbol.keyFor(sym);
|
|
2848
2923
|
return key === undefined ? ParseResult.fail(new ParseResult.Type(ast, sym, `Unable to encode a unique symbol ${String(sym)} into a string`)) : ParseResult.succeed(key);
|
|
2849
2924
|
};
|
|
@@ -2853,26 +2928,12 @@ class Symbol$ extends /*#__PURE__*/transformOrFail(String$.annotations({
|
|
|
2853
2928
|
description: "a string to be decoded into a globally shared symbol"
|
|
2854
2929
|
}), SymbolFromSelf, {
|
|
2855
2930
|
strict: false,
|
|
2856
|
-
decode: decodeSymbol,
|
|
2857
|
-
encode: encodeSymbol
|
|
2931
|
+
decode: i => decodeSymbol(i),
|
|
2932
|
+
encode: (a, _, ast) => encodeSymbol(a, ast)
|
|
2858
2933
|
}).annotations({
|
|
2859
2934
|
identifier: "Symbol"
|
|
2860
2935
|
}) {}
|
|
2861
2936
|
exports.Symbol = Symbol$;
|
|
2862
|
-
const SymbolStruct = /*#__PURE__*/TaggedStruct("symbol", {
|
|
2863
|
-
key: String$
|
|
2864
|
-
}).annotations({
|
|
2865
|
-
description: "an object to be decoded into a globally shared symbol"
|
|
2866
|
-
});
|
|
2867
|
-
const SymbolFromStruct = /*#__PURE__*/transformOrFail(SymbolStruct, SymbolFromSelf, {
|
|
2868
|
-
strict: true,
|
|
2869
|
-
decode: ({
|
|
2870
|
-
key
|
|
2871
|
-
}) => decodeSymbol(key),
|
|
2872
|
-
encode: (sym, _, ast) => ParseResult.map(encodeSymbol(sym, _, ast), key => SymbolStruct.make({
|
|
2873
|
-
key
|
|
2874
|
-
}))
|
|
2875
|
-
});
|
|
2876
2937
|
/**
|
|
2877
2938
|
* @category schema id
|
|
2878
2939
|
* @since 3.10.0
|
|
@@ -3013,7 +3074,7 @@ const nonPositiveBigInt = annotations => lessThanOrEqualToBigInt(0n, {
|
|
|
3013
3074
|
exports.nonPositiveBigInt = nonPositiveBigInt;
|
|
3014
3075
|
const clampBigInt = (minimum, maximum) => self => transform(self, self.pipe(typeSchema, betweenBigInt(minimum, maximum)), {
|
|
3015
3076
|
strict: false,
|
|
3016
|
-
decode:
|
|
3077
|
+
decode: i => bigInt_.clamp(i, {
|
|
3017
3078
|
minimum,
|
|
3018
3079
|
maximum
|
|
3019
3080
|
}),
|
|
@@ -3025,8 +3086,8 @@ class BigInt$ extends /*#__PURE__*/transformOrFail(String$.annotations({
|
|
|
3025
3086
|
description: "a string to be decoded into a bigint"
|
|
3026
3087
|
}), BigIntFromSelf, {
|
|
3027
3088
|
strict: true,
|
|
3028
|
-
decode: (
|
|
3029
|
-
encode:
|
|
3089
|
+
decode: (i, _, ast) => ParseResult.fromOption(bigInt_.fromString(i), () => new ParseResult.Type(ast, i, `Unable to decode ${JSON.stringify(i)} into a bigint`)),
|
|
3090
|
+
encode: a => ParseResult.succeed(String(a))
|
|
3030
3091
|
}).annotations({
|
|
3031
3092
|
identifier: "BigInt"
|
|
3032
3093
|
}) {}
|
|
@@ -3099,8 +3160,8 @@ class BigIntFromNumber extends /*#__PURE__*/transformOrFail(Number$.annotations(
|
|
|
3099
3160
|
description: "a number to be decoded into a bigint"
|
|
3100
3161
|
}), BigIntFromSelf.pipe(betweenBigInt(BigInt(Number.MIN_SAFE_INTEGER), BigInt(Number.MAX_SAFE_INTEGER))), {
|
|
3101
3162
|
strict: true,
|
|
3102
|
-
decode: (
|
|
3103
|
-
encode: (
|
|
3163
|
+
decode: (i, _, ast) => ParseResult.fromOption(bigInt_.fromNumber(i), () => new ParseResult.Type(ast, i, `Unable to decode ${i} into a bigint`)),
|
|
3164
|
+
encode: (a, _, ast) => ParseResult.fromOption(bigInt_.toNumber(a), () => new ParseResult.Type(ast, a, `Unable to encode ${a}n into a number`))
|
|
3104
3165
|
}).annotations({
|
|
3105
3166
|
identifier: "BigIntFromNumber"
|
|
3106
3167
|
}) {}
|
|
@@ -3125,24 +3186,24 @@ const RedactedFromSelf = value => declare([value], {
|
|
|
3125
3186
|
equivalence: redacted_.getEquivalence
|
|
3126
3187
|
});
|
|
3127
3188
|
/**
|
|
3128
|
-
* A
|
|
3189
|
+
* A transformation that transform a `Schema<A, I, R>` into a
|
|
3190
|
+
* `RedactedFromSelf<A>`.
|
|
3129
3191
|
*
|
|
3130
3192
|
* @category Redacted transformations
|
|
3131
3193
|
* @since 3.10.0
|
|
3132
3194
|
*/
|
|
3133
3195
|
exports.RedactedFromSelf = RedactedFromSelf;
|
|
3134
|
-
|
|
3135
|
-
return transform(value, RedactedFromSelf(typeSchema(value)), {
|
|
3196
|
+
function Redacted(value) {
|
|
3197
|
+
return transform(value, RedactedFromSelf(typeSchema(asSchema(value))), {
|
|
3136
3198
|
strict: true,
|
|
3137
|
-
decode:
|
|
3138
|
-
encode:
|
|
3199
|
+
decode: i => redacted_.make(i),
|
|
3200
|
+
encode: a => redacted_.value(a)
|
|
3139
3201
|
});
|
|
3140
|
-
}
|
|
3202
|
+
}
|
|
3141
3203
|
/**
|
|
3142
3204
|
* @category Duration constructors
|
|
3143
3205
|
* @since 3.10.0
|
|
3144
3206
|
*/
|
|
3145
|
-
exports.Redacted = Redacted;
|
|
3146
3207
|
class DurationFromSelf extends /*#__PURE__*/declare(duration_.isDuration, {
|
|
3147
3208
|
identifier: "DurationFromSelf",
|
|
3148
3209
|
pretty: () => String,
|
|
@@ -3165,9 +3226,9 @@ class DurationFromNanos extends /*#__PURE__*/transformOrFail(NonNegativeBigIntFr
|
|
|
3165
3226
|
description: "a finite duration"
|
|
3166
3227
|
})), {
|
|
3167
3228
|
strict: true,
|
|
3168
|
-
decode:
|
|
3169
|
-
encode: (
|
|
3170
|
-
onNone: () => ParseResult.fail(new ParseResult.Type(ast,
|
|
3229
|
+
decode: i => ParseResult.succeed(duration_.nanos(i)),
|
|
3230
|
+
encode: (a, _, ast) => option_.match(duration_.toNanos(a), {
|
|
3231
|
+
onNone: () => ParseResult.fail(new ParseResult.Type(ast, a, `Unable to encode ${a} into a bigint`)),
|
|
3171
3232
|
onSome: nanos => ParseResult.succeed(nanos)
|
|
3172
3233
|
})
|
|
3173
3234
|
}).annotations({
|
|
@@ -3194,8 +3255,8 @@ class DurationFromMillis extends /*#__PURE__*/transform(NonNegative.annotations(
|
|
|
3194
3255
|
description: "a non-negative number to be decoded into a Duration"
|
|
3195
3256
|
}), DurationFromSelf, {
|
|
3196
3257
|
strict: true,
|
|
3197
|
-
decode:
|
|
3198
|
-
encode:
|
|
3258
|
+
decode: i => duration_.millis(i),
|
|
3259
|
+
encode: a => duration_.toMillis(a)
|
|
3199
3260
|
}).annotations({
|
|
3200
3261
|
identifier: "DurationFromMillis"
|
|
3201
3262
|
}) {}
|
|
@@ -3236,29 +3297,29 @@ const isDurationValue = u => typeof u === "object";
|
|
|
3236
3297
|
*/
|
|
3237
3298
|
class Duration extends /*#__PURE__*/transform(Union(DurationValue, HRTime), DurationFromSelf, {
|
|
3238
3299
|
strict: true,
|
|
3239
|
-
decode:
|
|
3240
|
-
if (isDurationValue(
|
|
3241
|
-
switch (
|
|
3300
|
+
decode: i => {
|
|
3301
|
+
if (isDurationValue(i)) {
|
|
3302
|
+
switch (i._tag) {
|
|
3242
3303
|
case "Millis":
|
|
3243
|
-
return duration_.millis(
|
|
3304
|
+
return duration_.millis(i.millis);
|
|
3244
3305
|
case "Nanos":
|
|
3245
|
-
return duration_.nanos(
|
|
3306
|
+
return duration_.nanos(i.nanos);
|
|
3246
3307
|
case "Infinity":
|
|
3247
3308
|
return duration_.infinity;
|
|
3248
3309
|
}
|
|
3249
3310
|
}
|
|
3250
|
-
const [seconds, nanos] =
|
|
3311
|
+
const [seconds, nanos] = i;
|
|
3251
3312
|
return seconds === -1 ? duration_.infinity : duration_.nanos(BigInt(seconds) * BigInt(1e9) + BigInt(nanos));
|
|
3252
3313
|
},
|
|
3253
|
-
encode:
|
|
3254
|
-
switch (
|
|
3314
|
+
encode: a => {
|
|
3315
|
+
switch (a.value._tag) {
|
|
3255
3316
|
case "Millis":
|
|
3256
3317
|
return DurationValueMillis.make({
|
|
3257
|
-
millis:
|
|
3318
|
+
millis: a.value.millis
|
|
3258
3319
|
});
|
|
3259
3320
|
case "Nanos":
|
|
3260
3321
|
return DurationValueNanos.make({
|
|
3261
|
-
nanos:
|
|
3322
|
+
nanos: a.value.nanos
|
|
3262
3323
|
});
|
|
3263
3324
|
case "Infinity":
|
|
3264
3325
|
return durationValueInfinity;
|
|
@@ -3276,7 +3337,7 @@ class Duration extends /*#__PURE__*/transform(Union(DurationValue, HRTime), Dura
|
|
|
3276
3337
|
exports.Duration = Duration;
|
|
3277
3338
|
const clampDuration = (minimum, maximum) => self => transform(self, self.pipe(typeSchema, betweenDuration(minimum, maximum)), {
|
|
3278
3339
|
strict: false,
|
|
3279
|
-
decode:
|
|
3340
|
+
decode: i => duration_.clamp(i, {
|
|
3280
3341
|
minimum,
|
|
3281
3342
|
maximum
|
|
3282
3343
|
}),
|
|
@@ -3386,35 +3447,39 @@ const betweenDuration = (minimum, maximum, annotations) => self => self.pipe(fil
|
|
|
3386
3447
|
* @since 3.10.0
|
|
3387
3448
|
*/
|
|
3388
3449
|
exports.betweenDuration = betweenDuration;
|
|
3389
|
-
|
|
3450
|
+
class Uint8ArrayFromSelf extends /*#__PURE__*/declare(Predicate.isUint8Array, {
|
|
3390
3451
|
identifier: "Uint8ArrayFromSelf",
|
|
3391
3452
|
pretty: () => u8arr => `new Uint8Array(${JSON.stringify(Array.from(u8arr))})`,
|
|
3392
3453
|
arbitrary: () => fc => fc.uint8Array(),
|
|
3393
3454
|
equivalence: () => array_.getEquivalence(Equal.equals)
|
|
3394
|
-
})
|
|
3455
|
+
}) {}
|
|
3395
3456
|
/**
|
|
3396
3457
|
* @category number constructors
|
|
3397
3458
|
* @since 3.11.10
|
|
3398
3459
|
*/
|
|
3399
|
-
|
|
3460
|
+
exports.Uint8ArrayFromSelf = Uint8ArrayFromSelf;
|
|
3461
|
+
class Uint8 extends /*#__PURE__*/Number$.pipe( /*#__PURE__*/between(0, 255, {
|
|
3400
3462
|
identifier: "Uint8",
|
|
3401
3463
|
description: "a 8-bit unsigned integer"
|
|
3402
|
-
}))
|
|
3403
|
-
|
|
3464
|
+
})) {}
|
|
3465
|
+
/** @ignore */
|
|
3466
|
+
exports.Uint8 = Uint8;
|
|
3467
|
+
class Uint8Array$ extends /*#__PURE__*/transform(Array$(Uint8).annotations({
|
|
3404
3468
|
description: "an array of 8-bit unsigned integers to be decoded into a Uint8Array"
|
|
3405
3469
|
}), Uint8ArrayFromSelf, {
|
|
3406
3470
|
strict: true,
|
|
3407
|
-
decode:
|
|
3408
|
-
encode:
|
|
3471
|
+
decode: i => Uint8Array.from(i),
|
|
3472
|
+
encode: a => Array.from(a)
|
|
3409
3473
|
}).annotations({
|
|
3410
3474
|
identifier: "Uint8Array"
|
|
3411
|
-
})
|
|
3475
|
+
}) {}
|
|
3476
|
+
exports.Uint8Array = Uint8Array$;
|
|
3412
3477
|
const makeUint8ArrayTransformation = (id, decode, encode) => transformOrFail(String$.annotations({
|
|
3413
3478
|
description: "a string to be decoded into a Uint8Array"
|
|
3414
3479
|
}), Uint8ArrayFromSelf, {
|
|
3415
3480
|
strict: true,
|
|
3416
|
-
decode: (
|
|
3417
|
-
encode:
|
|
3481
|
+
decode: (i, _, ast) => either_.mapLeft(decode(i), decodeException => new ParseResult.Type(ast, i, decodeException.message)),
|
|
3482
|
+
encode: a => ParseResult.succeed(encode(a))
|
|
3418
3483
|
}).annotations({
|
|
3419
3484
|
identifier: id
|
|
3420
3485
|
});
|
|
@@ -3443,8 +3508,8 @@ const makeEncodingTransformation = (id, decode, encode) => transformOrFail(Strin
|
|
|
3443
3508
|
description: `A string that is interpreted as being ${id}-encoded and will be decoded into a UTF-8 string`
|
|
3444
3509
|
}), String$, {
|
|
3445
3510
|
strict: true,
|
|
3446
|
-
decode: (
|
|
3447
|
-
encode:
|
|
3511
|
+
decode: (i, _, ast) => either_.mapLeft(decode(i), decodeException => new ParseResult.Type(ast, i, decodeException.message)),
|
|
3512
|
+
encode: a => ParseResult.succeed(encode(a))
|
|
3448
3513
|
}).annotations({
|
|
3449
3514
|
identifier: `StringFrom${id}`
|
|
3450
3515
|
});
|
|
@@ -3495,8 +3560,8 @@ const StringFromUriComponent = exports.StringFromUriComponent = /*#__PURE__*/tra
|
|
|
3495
3560
|
description: `A string that is interpreted as being UriComponent-encoded and will be decoded into a UTF-8 string`
|
|
3496
3561
|
}), String$, {
|
|
3497
3562
|
strict: true,
|
|
3498
|
-
decode: (
|
|
3499
|
-
encode: (
|
|
3563
|
+
decode: (i, _, ast) => either_.mapLeft(Encoding.decodeUriComponent(i), decodeException => new ParseResult.Type(ast, i, decodeException.message)),
|
|
3564
|
+
encode: (a, _, ast) => either_.mapLeft(Encoding.encodeUriComponent(a), encodeException => new ParseResult.Type(ast, a, encodeException.message))
|
|
3500
3565
|
}).annotations({
|
|
3501
3566
|
identifier: `StringFromUriComponent`
|
|
3502
3567
|
});
|
|
@@ -3591,26 +3656,29 @@ const getNumberIndexedAccess = self => make(AST.getNumberIndexedAccess(self.ast)
|
|
|
3591
3656
|
* @since 3.10.0
|
|
3592
3657
|
*/
|
|
3593
3658
|
exports.getNumberIndexedAccess = getNumberIndexedAccess;
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
})
|
|
3659
|
+
function head(self) {
|
|
3660
|
+
return transform(self, OptionFromSelf(getNumberIndexedAccess(typeSchema(self))), {
|
|
3661
|
+
strict: false,
|
|
3662
|
+
decode: i => array_.head(i),
|
|
3663
|
+
encode: a => option_.match(a, {
|
|
3664
|
+
onNone: () => [],
|
|
3665
|
+
onSome: array_.of
|
|
3666
|
+
})
|
|
3667
|
+
});
|
|
3668
|
+
}
|
|
3602
3669
|
/**
|
|
3603
3670
|
* Get the first element of a `NonEmptyReadonlyArray`.
|
|
3604
3671
|
*
|
|
3605
3672
|
* @category NonEmptyReadonlyArray transformations
|
|
3606
3673
|
* @since 3.12.0
|
|
3607
3674
|
*/
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
});
|
|
3675
|
+
function headNonEmpty(self) {
|
|
3676
|
+
return transform(self, getNumberIndexedAccess(typeSchema(self)), {
|
|
3677
|
+
strict: false,
|
|
3678
|
+
decode: i => array_.headNonEmpty(i),
|
|
3679
|
+
encode: a => array_.of(a)
|
|
3680
|
+
});
|
|
3681
|
+
}
|
|
3614
3682
|
/**
|
|
3615
3683
|
* Retrieves the first element of a `ReadonlyArray`.
|
|
3616
3684
|
*
|
|
@@ -3619,10 +3687,9 @@ const headNonEmpty = self => transform(self, getNumberIndexedAccess(typeSchema(s
|
|
|
3619
3687
|
* @category ReadonlyArray transformations
|
|
3620
3688
|
* @since 3.10.0
|
|
3621
3689
|
*/
|
|
3622
|
-
exports.headNonEmpty = headNonEmpty;
|
|
3623
3690
|
const headOrElse = exports.headOrElse = /*#__PURE__*/(0, _Function.dual)(args => isSchema(args[0]), (self, fallback) => transformOrFail(self, getNumberIndexedAccess(typeSchema(self)), {
|
|
3624
3691
|
strict: true,
|
|
3625
|
-
decode: (
|
|
3692
|
+
decode: (i, _, ast) => i.length > 0 ? ParseResult.succeed(i[0]) : fallback ? ParseResult.succeed(fallback()) : ParseResult.fail(new ParseResult.Type(ast, i, "Unable to retrieve the first element of an empty array")),
|
|
3626
3693
|
encode: a => ParseResult.succeed(array_.of(a))
|
|
3627
3694
|
}));
|
|
3628
3695
|
/**
|
|
@@ -3799,8 +3866,8 @@ class DateFromString extends /*#__PURE__*/transform(String$.annotations({
|
|
|
3799
3866
|
description: "a string to be decoded into a Date"
|
|
3800
3867
|
}), DateFromSelf, {
|
|
3801
3868
|
strict: true,
|
|
3802
|
-
decode:
|
|
3803
|
-
encode:
|
|
3869
|
+
decode: i => new Date(i),
|
|
3870
|
+
encode: a => util_.formatDate(a)
|
|
3804
3871
|
}).annotations({
|
|
3805
3872
|
identifier: "DateFromString"
|
|
3806
3873
|
}) {}
|
|
@@ -3824,8 +3891,8 @@ class DateFromNumber extends /*#__PURE__*/transform(Number$.annotations({
|
|
|
3824
3891
|
description: "a number to be decoded into a Date"
|
|
3825
3892
|
}), DateFromSelf, {
|
|
3826
3893
|
strict: true,
|
|
3827
|
-
decode:
|
|
3828
|
-
encode:
|
|
3894
|
+
decode: i => new Date(i),
|
|
3895
|
+
encode: a => a.getTime()
|
|
3829
3896
|
}).annotations({
|
|
3830
3897
|
identifier: "DateFromNumber"
|
|
3831
3898
|
}) {}
|
|
@@ -3846,7 +3913,7 @@ class DateTimeUtcFromSelf extends /*#__PURE__*/declare(u => dateTime.isDateTime(
|
|
|
3846
3913
|
equivalence: () => dateTime.Equivalence
|
|
3847
3914
|
}) {}
|
|
3848
3915
|
exports.DateTimeUtcFromSelf = DateTimeUtcFromSelf;
|
|
3849
|
-
const decodeDateTimeUtc = (input,
|
|
3916
|
+
const decodeDateTimeUtc = (input, ast) => ParseResult.try({
|
|
3850
3917
|
try: () => dateTime.unsafeMake(input),
|
|
3851
3918
|
catch: () => new ParseResult.Type(ast, input, `Unable to decode ${util_.formatUnknown(input)} into a DateTime.Utc`)
|
|
3852
3919
|
});
|
|
@@ -3860,8 +3927,8 @@ class DateTimeUtcFromNumber extends /*#__PURE__*/transformOrFail(Number$.annotat
|
|
|
3860
3927
|
description: "a number to be decoded into a DateTime.Utc"
|
|
3861
3928
|
}), DateTimeUtcFromSelf, {
|
|
3862
3929
|
strict: true,
|
|
3863
|
-
decode: decodeDateTimeUtc,
|
|
3864
|
-
encode:
|
|
3930
|
+
decode: (i, _, ast) => decodeDateTimeUtc(i, ast),
|
|
3931
|
+
encode: a => ParseResult.succeed(dateTime.toEpochMillis(a))
|
|
3865
3932
|
}).annotations({
|
|
3866
3933
|
identifier: "DateTimeUtcFromNumber"
|
|
3867
3934
|
}) {}
|
|
@@ -3876,8 +3943,8 @@ class DateTimeUtcFromDate extends /*#__PURE__*/transformOrFail(DateFromSelf.anno
|
|
|
3876
3943
|
description: "a Date to be decoded into a DateTime.Utc"
|
|
3877
3944
|
}), DateTimeUtcFromSelf, {
|
|
3878
3945
|
strict: true,
|
|
3879
|
-
decode: decodeDateTimeUtc,
|
|
3880
|
-
encode:
|
|
3946
|
+
decode: (i, _, ast) => decodeDateTimeUtc(i, ast),
|
|
3947
|
+
encode: a => ParseResult.succeed(dateTime.toDateUtc(a))
|
|
3881
3948
|
}).annotations({
|
|
3882
3949
|
identifier: "DateTimeUtcFromDate"
|
|
3883
3950
|
}) {}
|
|
@@ -3892,8 +3959,8 @@ class DateTimeUtc extends /*#__PURE__*/transformOrFail(String$.annotations({
|
|
|
3892
3959
|
description: "a string to be decoded into a DateTime.Utc"
|
|
3893
3960
|
}), DateTimeUtcFromSelf, {
|
|
3894
3961
|
strict: true,
|
|
3895
|
-
decode: decodeDateTimeUtc,
|
|
3896
|
-
encode:
|
|
3962
|
+
decode: (i, _, ast) => decodeDateTimeUtc(i, ast),
|
|
3963
|
+
encode: a => ParseResult.succeed(dateTime.formatIso(a))
|
|
3897
3964
|
}).annotations({
|
|
3898
3965
|
identifier: "DateTimeUtc"
|
|
3899
3966
|
}) {}
|
|
@@ -3925,8 +3992,8 @@ class TimeZoneOffset extends /*#__PURE__*/transform(Number$.annotations({
|
|
|
3925
3992
|
description: "a number to be decoded into a TimeZone.Offset"
|
|
3926
3993
|
}), TimeZoneOffsetFromSelf, {
|
|
3927
3994
|
strict: true,
|
|
3928
|
-
decode: dateTime.zoneMakeOffset,
|
|
3929
|
-
encode:
|
|
3995
|
+
decode: i => dateTime.zoneMakeOffset(i),
|
|
3996
|
+
encode: a => a.offset
|
|
3930
3997
|
}).annotations({
|
|
3931
3998
|
identifier: "TimeZoneOffset"
|
|
3932
3999
|
}) {}
|
|
@@ -3955,11 +4022,11 @@ class TimeZoneNamed extends /*#__PURE__*/transformOrFail(String$.annotations({
|
|
|
3955
4022
|
description: "a string to be decoded into a TimeZone.Named"
|
|
3956
4023
|
}), TimeZoneNamedFromSelf, {
|
|
3957
4024
|
strict: true,
|
|
3958
|
-
decode: (
|
|
3959
|
-
try: () => dateTime.zoneUnsafeMakeNamed(
|
|
3960
|
-
catch: () => new ParseResult.Type(ast,
|
|
4025
|
+
decode: (i, _, ast) => ParseResult.try({
|
|
4026
|
+
try: () => dateTime.zoneUnsafeMakeNamed(i),
|
|
4027
|
+
catch: () => new ParseResult.Type(ast, i, `Unable to decode ${JSON.stringify(i)} into a TimeZone.Named`)
|
|
3961
4028
|
}),
|
|
3962
|
-
encode:
|
|
4029
|
+
encode: a => ParseResult.succeed(a.id)
|
|
3963
4030
|
}).annotations({
|
|
3964
4031
|
identifier: "TimeZoneNamed"
|
|
3965
4032
|
}) {}
|
|
@@ -3980,11 +4047,11 @@ class TimeZone extends /*#__PURE__*/transformOrFail(String$.annotations({
|
|
|
3980
4047
|
description: "a string to be decoded into a TimeZone"
|
|
3981
4048
|
}), TimeZoneFromSelf, {
|
|
3982
4049
|
strict: true,
|
|
3983
|
-
decode: (
|
|
3984
|
-
onNone: () => ParseResult.fail(new ParseResult.Type(ast,
|
|
4050
|
+
decode: (i, _, ast) => option_.match(dateTime.zoneFromString(i), {
|
|
4051
|
+
onNone: () => ParseResult.fail(new ParseResult.Type(ast, i, `Unable to decode ${JSON.stringify(i)} into a TimeZone`)),
|
|
3985
4052
|
onSome: ParseResult.succeed
|
|
3986
4053
|
}),
|
|
3987
|
-
encode:
|
|
4054
|
+
encode: a => ParseResult.succeed(dateTime.zoneToString(a))
|
|
3988
4055
|
}).annotations({
|
|
3989
4056
|
identifier: "TimeZone"
|
|
3990
4057
|
}) {}
|
|
@@ -4020,11 +4087,11 @@ class DateTimeZoned extends /*#__PURE__*/transformOrFail(String$.annotations({
|
|
|
4020
4087
|
description: "a string to be decoded into a DateTime.Zoned"
|
|
4021
4088
|
}), DateTimeZonedFromSelf, {
|
|
4022
4089
|
strict: true,
|
|
4023
|
-
decode: (
|
|
4024
|
-
onNone: () => ParseResult.fail(new ParseResult.Type(ast,
|
|
4090
|
+
decode: (i, _, ast) => option_.match(dateTime.makeZonedFromString(i), {
|
|
4091
|
+
onNone: () => ParseResult.fail(new ParseResult.Type(ast, i, `Unable to decode ${JSON.stringify(i)} into a DateTime.Zoned`)),
|
|
4025
4092
|
onSome: ParseResult.succeed
|
|
4026
4093
|
}),
|
|
4027
|
-
encode:
|
|
4094
|
+
encode: a => ParseResult.succeed(dateTime.formatIsoZoned(a))
|
|
4028
4095
|
}).annotations({
|
|
4029
4096
|
identifier: "DateTimeZoned"
|
|
4030
4097
|
}) {}
|
|
@@ -4082,56 +4149,51 @@ const makeSomeEncoded = value => ({
|
|
|
4082
4149
|
* @category Option transformations
|
|
4083
4150
|
* @since 3.10.0
|
|
4084
4151
|
*/
|
|
4085
|
-
|
|
4152
|
+
function Option(value) {
|
|
4086
4153
|
const value_ = asSchema(value);
|
|
4087
|
-
|
|
4154
|
+
const out = transform(optionEncoded(value_), OptionFromSelf(typeSchema(value_)), {
|
|
4088
4155
|
strict: true,
|
|
4089
|
-
decode: optionDecode,
|
|
4090
|
-
encode: option_.match({
|
|
4156
|
+
decode: i => optionDecode(i),
|
|
4157
|
+
encode: a => option_.match(a, {
|
|
4091
4158
|
onNone: () => makeNoneEncoded,
|
|
4092
4159
|
onSome: makeSomeEncoded
|
|
4093
4160
|
})
|
|
4094
4161
|
});
|
|
4095
|
-
|
|
4162
|
+
return out;
|
|
4163
|
+
}
|
|
4096
4164
|
/**
|
|
4097
4165
|
* @category Option transformations
|
|
4098
4166
|
* @since 3.10.0
|
|
4099
4167
|
*/
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
const value_ = asSchema(value);
|
|
4103
|
-
return transform(NullOr(value_), OptionFromSelf(typeSchema(value_)), {
|
|
4168
|
+
function OptionFromNullOr(value) {
|
|
4169
|
+
return transform(NullOr(value), OptionFromSelf(typeSchema(asSchema(value))), {
|
|
4104
4170
|
strict: true,
|
|
4105
|
-
decode: option_.fromNullable,
|
|
4106
|
-
encode: option_.getOrNull
|
|
4171
|
+
decode: i => option_.fromNullable(i),
|
|
4172
|
+
encode: a => option_.getOrNull(a)
|
|
4107
4173
|
});
|
|
4108
|
-
}
|
|
4174
|
+
}
|
|
4109
4175
|
/**
|
|
4110
4176
|
* @category Option transformations
|
|
4111
4177
|
* @since 3.10.0
|
|
4112
4178
|
*/
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
const value_ = asSchema(value);
|
|
4116
|
-
return transform(NullishOr(value_), OptionFromSelf(typeSchema(value_)), {
|
|
4179
|
+
function OptionFromNullishOr(value, onNoneEncoding) {
|
|
4180
|
+
return transform(NullishOr(value), OptionFromSelf(typeSchema(asSchema(value))), {
|
|
4117
4181
|
strict: true,
|
|
4118
|
-
decode: option_.fromNullable,
|
|
4119
|
-
encode: onNoneEncoding === null ? option_.getOrNull : option_.getOrUndefined
|
|
4182
|
+
decode: i => option_.fromNullable(i),
|
|
4183
|
+
encode: onNoneEncoding === null ? a => option_.getOrNull(a) : a => option_.getOrUndefined(a)
|
|
4120
4184
|
});
|
|
4121
|
-
}
|
|
4185
|
+
}
|
|
4122
4186
|
/**
|
|
4123
4187
|
* @category Option transformations
|
|
4124
4188
|
* @since 3.10.0
|
|
4125
4189
|
*/
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
const value_ = asSchema(value);
|
|
4129
|
-
return transform(UndefinedOr(value_), OptionFromSelf(typeSchema(value_)), {
|
|
4190
|
+
function OptionFromUndefinedOr(value) {
|
|
4191
|
+
return transform(UndefinedOr(value), OptionFromSelf(typeSchema(asSchema(value))), {
|
|
4130
4192
|
strict: true,
|
|
4131
|
-
decode: option_.fromNullable,
|
|
4132
|
-
encode: option_.getOrUndefined
|
|
4193
|
+
decode: i => option_.fromNullable(i),
|
|
4194
|
+
encode: a => option_.getOrUndefined(a)
|
|
4133
4195
|
});
|
|
4134
|
-
}
|
|
4196
|
+
}
|
|
4135
4197
|
/**
|
|
4136
4198
|
* Transforms strings into an Option type, effectively filtering out empty or
|
|
4137
4199
|
* whitespace-only strings by trimming them and checking their length. Returns
|
|
@@ -4149,12 +4211,12 @@ const OptionFromUndefinedOr = value => {
|
|
|
4149
4211
|
* @category Option transformations
|
|
4150
4212
|
* @since 3.10.0
|
|
4151
4213
|
*/
|
|
4152
|
-
|
|
4153
|
-
const OptionFromNonEmptyTrimmedString = exports.OptionFromNonEmptyTrimmedString = /*#__PURE__*/transform(String$, /*#__PURE__*/OptionFromSelf(NonEmptyTrimmedString), {
|
|
4214
|
+
class OptionFromNonEmptyTrimmedString extends /*#__PURE__*/transform(String$, /*#__PURE__*/OptionFromSelf(NonEmptyTrimmedString), {
|
|
4154
4215
|
strict: true,
|
|
4155
|
-
decode:
|
|
4156
|
-
encode:
|
|
4157
|
-
})
|
|
4216
|
+
decode: i => option_.filter(option_.some(i.trim()), string_.isNonEmpty),
|
|
4217
|
+
encode: a => option_.getOrElse(a, () => "")
|
|
4218
|
+
}) {}
|
|
4219
|
+
exports.OptionFromNonEmptyTrimmedString = OptionFromNonEmptyTrimmedString;
|
|
4158
4220
|
const rightEncoded = right => Struct({
|
|
4159
4221
|
_tag: Literal("Right"),
|
|
4160
4222
|
right
|
|
@@ -4226,17 +4288,18 @@ const Either = ({
|
|
|
4226
4288
|
}) => {
|
|
4227
4289
|
const right_ = asSchema(right);
|
|
4228
4290
|
const left_ = asSchema(left);
|
|
4229
|
-
|
|
4291
|
+
const out = transform(eitherEncoded(right_, left_), EitherFromSelf({
|
|
4230
4292
|
left: typeSchema(left_),
|
|
4231
4293
|
right: typeSchema(right_)
|
|
4232
4294
|
}), {
|
|
4233
4295
|
strict: true,
|
|
4234
|
-
decode: eitherDecode,
|
|
4235
|
-
encode: either_.match({
|
|
4296
|
+
decode: i => eitherDecode(i),
|
|
4297
|
+
encode: a => either_.match(a, {
|
|
4236
4298
|
onLeft: makeLeftEncoded,
|
|
4237
4299
|
onRight: makeRightEncoded
|
|
4238
4300
|
})
|
|
4239
4301
|
});
|
|
4302
|
+
return out;
|
|
4240
4303
|
};
|
|
4241
4304
|
/**
|
|
4242
4305
|
* @example
|
|
@@ -4261,25 +4324,26 @@ const EitherFromUnion = ({
|
|
|
4261
4324
|
const toleft = typeSchema(left_);
|
|
4262
4325
|
const fromRight = transform(right_, rightEncoded(toright), {
|
|
4263
4326
|
strict: true,
|
|
4264
|
-
decode: makeRightEncoded,
|
|
4265
|
-
encode:
|
|
4327
|
+
decode: i => makeRightEncoded(i),
|
|
4328
|
+
encode: a => a.right
|
|
4266
4329
|
});
|
|
4267
4330
|
const fromLeft = transform(left_, leftEncoded(toleft), {
|
|
4268
4331
|
strict: true,
|
|
4269
|
-
decode: makeLeftEncoded,
|
|
4270
|
-
encode:
|
|
4332
|
+
decode: i => makeLeftEncoded(i),
|
|
4333
|
+
encode: a => a.left
|
|
4271
4334
|
});
|
|
4272
|
-
|
|
4335
|
+
const out = transform(Union(fromRight, fromLeft), EitherFromSelf({
|
|
4273
4336
|
left: toleft,
|
|
4274
4337
|
right: toright
|
|
4275
4338
|
}), {
|
|
4276
4339
|
strict: true,
|
|
4277
|
-
decode:
|
|
4278
|
-
encode: either_.match({
|
|
4340
|
+
decode: i => i._tag === "Left" ? either_.left(i.left) : either_.right(i.right),
|
|
4341
|
+
encode: a => either_.match(a, {
|
|
4279
4342
|
onLeft: makeLeftEncoded,
|
|
4280
4343
|
onRight: makeRightEncoded
|
|
4281
4344
|
})
|
|
4282
4345
|
});
|
|
4346
|
+
return out;
|
|
4283
4347
|
};
|
|
4284
4348
|
exports.EitherFromUnion = EitherFromUnion;
|
|
4285
4349
|
const mapArbitrary = (key, value, ctx) => {
|
|
@@ -4325,38 +4389,33 @@ const MapFromSelf = ({
|
|
|
4325
4389
|
* @since 3.10.0
|
|
4326
4390
|
*/
|
|
4327
4391
|
exports.MapFromSelf = MapFromSelf;
|
|
4328
|
-
|
|
4392
|
+
function ReadonlyMap({
|
|
4329
4393
|
key,
|
|
4330
4394
|
value
|
|
4331
|
-
})
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
key: typeSchema(key_),
|
|
4336
|
-
value: typeSchema(value_)
|
|
4395
|
+
}) {
|
|
4396
|
+
return transform(Array$(Tuple(key, value)), ReadonlyMapFromSelf({
|
|
4397
|
+
key: typeSchema(asSchema(key)),
|
|
4398
|
+
value: typeSchema(asSchema(value))
|
|
4337
4399
|
}), {
|
|
4338
4400
|
strict: true,
|
|
4339
|
-
decode:
|
|
4340
|
-
encode:
|
|
4401
|
+
decode: i => new Map(i),
|
|
4402
|
+
encode: a => Array.from(a.entries())
|
|
4341
4403
|
});
|
|
4342
|
-
}
|
|
4343
|
-
|
|
4344
|
-
|
|
4404
|
+
}
|
|
4405
|
+
/** @ignore */
|
|
4406
|
+
function map({
|
|
4345
4407
|
key,
|
|
4346
4408
|
value
|
|
4347
|
-
})
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
key: typeSchema(key_),
|
|
4352
|
-
value: typeSchema(value_)
|
|
4409
|
+
}) {
|
|
4410
|
+
return transform(Array$(Tuple(key, value)), MapFromSelf({
|
|
4411
|
+
key: typeSchema(asSchema(key)),
|
|
4412
|
+
value: typeSchema(asSchema(value))
|
|
4353
4413
|
}), {
|
|
4354
4414
|
strict: true,
|
|
4355
|
-
decode:
|
|
4356
|
-
encode:
|
|
4415
|
+
decode: i => new Map(i),
|
|
4416
|
+
encode: a => Array.from(a.entries())
|
|
4357
4417
|
});
|
|
4358
|
-
}
|
|
4359
|
-
exports.Map = map;
|
|
4418
|
+
}
|
|
4360
4419
|
/**
|
|
4361
4420
|
* @category ReadonlyMap transformations
|
|
4362
4421
|
* @since 3.10.0
|
|
@@ -4374,8 +4433,8 @@ const ReadonlyMapFromRecord = ({
|
|
|
4374
4433
|
value: typeSchema(value)
|
|
4375
4434
|
}), {
|
|
4376
4435
|
strict: true,
|
|
4377
|
-
decode:
|
|
4378
|
-
encode:
|
|
4436
|
+
decode: i => new Map(Object.entries(i)),
|
|
4437
|
+
encode: a => Object.fromEntries(a)
|
|
4379
4438
|
});
|
|
4380
4439
|
/**
|
|
4381
4440
|
* @category Map transformations
|
|
@@ -4395,8 +4454,8 @@ const MapFromRecord = ({
|
|
|
4395
4454
|
value: typeSchema(value)
|
|
4396
4455
|
}), {
|
|
4397
4456
|
strict: true,
|
|
4398
|
-
decode:
|
|
4399
|
-
encode:
|
|
4457
|
+
decode: i => new Map(Object.entries(i)),
|
|
4458
|
+
encode: a => Object.fromEntries(a)
|
|
4400
4459
|
});
|
|
4401
4460
|
exports.MapFromRecord = MapFromRecord;
|
|
4402
4461
|
const setArbitrary = (item, ctx) => fc => {
|
|
@@ -4434,24 +4493,21 @@ const SetFromSelf = value => setFromSelf_(value, `Set<${format(value)}>`);
|
|
|
4434
4493
|
* @since 3.10.0
|
|
4435
4494
|
*/
|
|
4436
4495
|
exports.SetFromSelf = SetFromSelf;
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
return transform(Array$(value_), ReadonlySetFromSelf(typeSchema(value_)), {
|
|
4496
|
+
function ReadonlySet(value) {
|
|
4497
|
+
return transform(Array$(value), ReadonlySetFromSelf(typeSchema(asSchema(value))), {
|
|
4440
4498
|
strict: true,
|
|
4441
|
-
decode:
|
|
4442
|
-
encode:
|
|
4499
|
+
decode: i => new Set(i),
|
|
4500
|
+
encode: a => Array.from(a)
|
|
4443
4501
|
});
|
|
4444
|
-
}
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
return transform(Array$(value_), SetFromSelf(typeSchema(value_)), {
|
|
4502
|
+
}
|
|
4503
|
+
/** @ignore */
|
|
4504
|
+
function set(value) {
|
|
4505
|
+
return transform(Array$(value), SetFromSelf(typeSchema(asSchema(value))), {
|
|
4449
4506
|
strict: true,
|
|
4450
|
-
decode:
|
|
4451
|
-
encode:
|
|
4507
|
+
decode: i => new Set(i),
|
|
4508
|
+
encode: a => Array.from(a)
|
|
4452
4509
|
});
|
|
4453
|
-
}
|
|
4454
|
-
exports.Set = set;
|
|
4510
|
+
}
|
|
4455
4511
|
const bigDecimalPretty = () => val => `BigDecimal(${bigDecimal_.format(bigDecimal_.normalize(val))})`;
|
|
4456
4512
|
const bigDecimalArbitrary = () => fc => fc.tuple(fc.bigInt(), fc.integer({
|
|
4457
4513
|
min: 0,
|
|
@@ -4476,11 +4532,11 @@ class BigDecimal extends /*#__PURE__*/transformOrFail(String$.annotations({
|
|
|
4476
4532
|
description: "a string to be decoded into a BigDecimal"
|
|
4477
4533
|
}), BigDecimalFromSelf, {
|
|
4478
4534
|
strict: true,
|
|
4479
|
-
decode: (
|
|
4480
|
-
onNone: () => ParseResult.fail(new ParseResult.Type(ast,
|
|
4535
|
+
decode: (i, _, ast) => bigDecimal_.fromString(i).pipe(option_.match({
|
|
4536
|
+
onNone: () => ParseResult.fail(new ParseResult.Type(ast, i, `Unable to decode ${JSON.stringify(i)} into a BigDecimal`)),
|
|
4481
4537
|
onSome: val => ParseResult.succeed(bigDecimal_.normalize(val))
|
|
4482
4538
|
})),
|
|
4483
|
-
encode:
|
|
4539
|
+
encode: a => ParseResult.succeed(bigDecimal_.format(bigDecimal_.normalize(a)))
|
|
4484
4540
|
}).annotations({
|
|
4485
4541
|
identifier: "BigDecimal"
|
|
4486
4542
|
}) {}
|
|
@@ -4496,8 +4552,8 @@ class BigDecimalFromNumber extends /*#__PURE__*/transform(Number$.annotations({
|
|
|
4496
4552
|
description: "a number to be decoded into a BigDecimal"
|
|
4497
4553
|
}), BigDecimalFromSelf, {
|
|
4498
4554
|
strict: true,
|
|
4499
|
-
decode: bigDecimal_.unsafeFromNumber,
|
|
4500
|
-
encode: bigDecimal_.unsafeToNumber
|
|
4555
|
+
decode: i => bigDecimal_.unsafeFromNumber(i),
|
|
4556
|
+
encode: a => bigDecimal_.unsafeToNumber(a)
|
|
4501
4557
|
}).annotations({
|
|
4502
4558
|
identifier: "BigDecimalFromNumber"
|
|
4503
4559
|
}) {}
|
|
@@ -4717,7 +4773,7 @@ const betweenBigDecimal = (minimum, maximum, annotations) => self => {
|
|
|
4717
4773
|
exports.betweenBigDecimal = betweenBigDecimal;
|
|
4718
4774
|
const clampBigDecimal = (minimum, maximum) => self => transform(self, self.pipe(typeSchema, betweenBigDecimal(minimum, maximum)), {
|
|
4719
4775
|
strict: false,
|
|
4720
|
-
decode:
|
|
4776
|
+
decode: i => bigDecimal_.clamp(i, {
|
|
4721
4777
|
minimum,
|
|
4722
4778
|
maximum
|
|
4723
4779
|
}),
|
|
@@ -4750,15 +4806,13 @@ const ChunkFromSelf = value => {
|
|
|
4750
4806
|
* @since 3.10.0
|
|
4751
4807
|
*/
|
|
4752
4808
|
exports.ChunkFromSelf = ChunkFromSelf;
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
return transform(Array$(value_), ChunkFromSelf(typeSchema(value_)), {
|
|
4809
|
+
function Chunk(value) {
|
|
4810
|
+
return transform(Array$(value), ChunkFromSelf(typeSchema(asSchema(value))), {
|
|
4756
4811
|
strict: true,
|
|
4757
|
-
decode:
|
|
4758
|
-
encode: chunk_.toReadonlyArray
|
|
4812
|
+
decode: i => i.length === 0 ? chunk_.empty() : chunk_.fromIterable(i),
|
|
4813
|
+
encode: a => chunk_.toReadonlyArray(a)
|
|
4759
4814
|
});
|
|
4760
|
-
}
|
|
4761
|
-
exports.Chunk = Chunk;
|
|
4815
|
+
}
|
|
4762
4816
|
const nonEmptyChunkArbitrary = item => fc => fastCheck_.array(item(fc), {
|
|
4763
4817
|
minLength: 1
|
|
4764
4818
|
}).map(as => chunk_.unsafeFromNonEmptyArray(as));
|
|
@@ -4784,41 +4838,49 @@ const NonEmptyChunkFromSelf = value => {
|
|
|
4784
4838
|
* @since 3.10.0
|
|
4785
4839
|
*/
|
|
4786
4840
|
exports.NonEmptyChunkFromSelf = NonEmptyChunkFromSelf;
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
return transform(NonEmptyArray(value_), NonEmptyChunkFromSelf(typeSchema(value_)), {
|
|
4841
|
+
function NonEmptyChunk(value) {
|
|
4842
|
+
return transform(NonEmptyArray(value), NonEmptyChunkFromSelf(typeSchema(asSchema(value))), {
|
|
4790
4843
|
strict: true,
|
|
4791
|
-
decode: chunk_.unsafeFromNonEmptyArray,
|
|
4792
|
-
encode: chunk_.toReadonlyArray
|
|
4844
|
+
decode: i => chunk_.unsafeFromNonEmptyArray(i),
|
|
4845
|
+
encode: a => chunk_.toReadonlyArray(a)
|
|
4793
4846
|
});
|
|
4794
|
-
}
|
|
4795
|
-
|
|
4796
|
-
const
|
|
4797
|
-
const dataArbitrary = item => fc => item(fc).map(toData);
|
|
4847
|
+
}
|
|
4848
|
+
const decodeData = a => Array.isArray(a) ? data_.array(a) : data_.struct(a);
|
|
4849
|
+
const dataArbitrary = item => fc => item(fc).map(decodeData);
|
|
4798
4850
|
const dataPretty = item => d => `Data(${item(d)})`;
|
|
4799
|
-
const dataParse = decodeUnknown => (u, options, ast) => Equal.isEqual(u) ? toComposite(decodeUnknown(u, options),
|
|
4851
|
+
const dataParse = decodeUnknown => (u, options, ast) => Equal.isEqual(u) ? toComposite(decodeUnknown(u, options), decodeData, ast, u) : ParseResult.fail(new ParseResult.Type(ast, u));
|
|
4800
4852
|
/**
|
|
4853
|
+
* Type and Encoded must extend `Readonly<Record<string, any>> |
|
|
4854
|
+
* ReadonlyArray<any>` to be compatible with this API.
|
|
4855
|
+
*
|
|
4801
4856
|
* @category Data transformations
|
|
4802
4857
|
* @since 3.10.0
|
|
4803
4858
|
*/
|
|
4804
|
-
const DataFromSelf =
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4859
|
+
const DataFromSelf = value => {
|
|
4860
|
+
return declare([value], {
|
|
4861
|
+
decode: item => dataParse(ParseResult.decodeUnknown(item)),
|
|
4862
|
+
encode: item => dataParse(ParseResult.encodeUnknown(item))
|
|
4863
|
+
}, {
|
|
4864
|
+
description: `Data<${format(value)}>`,
|
|
4865
|
+
pretty: dataPretty,
|
|
4866
|
+
arbitrary: dataArbitrary
|
|
4867
|
+
});
|
|
4868
|
+
};
|
|
4812
4869
|
/**
|
|
4870
|
+
* Type and Encoded must extend `Readonly<Record<string, any>> |
|
|
4871
|
+
* ReadonlyArray<any>` to be compatible with this API.
|
|
4872
|
+
*
|
|
4813
4873
|
* @category Data transformations
|
|
4814
4874
|
* @since 3.10.0
|
|
4815
4875
|
*/
|
|
4816
4876
|
exports.DataFromSelf = DataFromSelf;
|
|
4817
|
-
const Data =
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
})
|
|
4877
|
+
const Data = value => {
|
|
4878
|
+
return transform(value, DataFromSelf(typeSchema(value)), {
|
|
4879
|
+
strict: false,
|
|
4880
|
+
decode: i => decodeData(i),
|
|
4881
|
+
encode: a => Array.isArray(a) ? Array.from(a) : Object.assign({}, a)
|
|
4882
|
+
});
|
|
4883
|
+
};
|
|
4822
4884
|
exports.Data = Data;
|
|
4823
4885
|
const isField = u => isSchema(u) || isPropertySignature(u);
|
|
4824
4886
|
const isFields = fields => util_.ownKeys(fields).every(key => isField(fields[key]));
|
|
@@ -5030,7 +5092,7 @@ const makeClass = ({
|
|
|
5030
5092
|
});
|
|
5031
5093
|
out = transform(encodedSide, declaration, {
|
|
5032
5094
|
strict: true,
|
|
5033
|
-
decode:
|
|
5095
|
+
decode: i => new this(i, true),
|
|
5034
5096
|
encode: _Function.identity
|
|
5035
5097
|
}).annotations({
|
|
5036
5098
|
[AST.SurrogateAnnotationId]: transformationSurrogate.ast,
|
|
@@ -5210,8 +5272,8 @@ const fiberIdEncode = input => {
|
|
|
5210
5272
|
*/
|
|
5211
5273
|
class FiberId extends /*#__PURE__*/transform(FiberIdEncoded, FiberIdFromSelf, {
|
|
5212
5274
|
strict: true,
|
|
5213
|
-
decode: fiberIdDecode,
|
|
5214
|
-
encode: fiberIdEncode
|
|
5275
|
+
decode: i => fiberIdDecode(i),
|
|
5276
|
+
encode: a => fiberIdEncode(a)
|
|
5215
5277
|
}).annotations({
|
|
5216
5278
|
identifier: "FiberId"
|
|
5217
5279
|
}) {}
|
|
@@ -5231,19 +5293,19 @@ const CauseInterruptEncoded = /*#__PURE__*/Struct({
|
|
|
5231
5293
|
_tag: /*#__PURE__*/Literal("Interrupt"),
|
|
5232
5294
|
fiberId: FiberIdEncoded
|
|
5233
5295
|
});
|
|
5234
|
-
const causeParallelEncoded = causeEncoded => Struct({
|
|
5235
|
-
_tag: Literal("Parallel"),
|
|
5236
|
-
left: causeEncoded,
|
|
5237
|
-
right: causeEncoded
|
|
5238
|
-
});
|
|
5239
|
-
const causeSequentialEncoded = causeEncoded => Struct({
|
|
5240
|
-
_tag: Literal("Sequential"),
|
|
5241
|
-
left: causeEncoded,
|
|
5242
|
-
right: causeEncoded
|
|
5243
|
-
});
|
|
5244
5296
|
const causeEncoded = (error, defect) => {
|
|
5245
|
-
const
|
|
5246
|
-
const
|
|
5297
|
+
const error_ = asSchema(error);
|
|
5298
|
+
const defect_ = asSchema(defect);
|
|
5299
|
+
const suspended = suspend(() => out);
|
|
5300
|
+
const out = Union(CauseEmptyEncoded, causeFailEncoded(error_), causeDieEncoded(defect_), CauseInterruptEncoded, Struct({
|
|
5301
|
+
_tag: Literal("Sequential"),
|
|
5302
|
+
left: suspended,
|
|
5303
|
+
right: suspended
|
|
5304
|
+
}), Struct({
|
|
5305
|
+
_tag: Literal("Parallel"),
|
|
5306
|
+
left: suspended,
|
|
5307
|
+
right: suspended
|
|
5308
|
+
})).annotations({
|
|
5247
5309
|
title: `CauseEncoded<${format(error)}>`
|
|
5248
5310
|
});
|
|
5249
5311
|
return out;
|
|
@@ -5375,14 +5437,15 @@ const Cause = ({
|
|
|
5375
5437
|
}) => {
|
|
5376
5438
|
const error_ = asSchema(error);
|
|
5377
5439
|
const defect_ = asSchema(defect);
|
|
5378
|
-
|
|
5440
|
+
const out = transform(causeEncoded(error_, defect_), CauseFromSelf({
|
|
5379
5441
|
error: typeSchema(error_),
|
|
5380
|
-
defect:
|
|
5442
|
+
defect: typeSchema(defect_)
|
|
5381
5443
|
}), {
|
|
5382
5444
|
strict: false,
|
|
5383
|
-
decode: causeDecode,
|
|
5384
|
-
encode: causeEncode
|
|
5445
|
+
decode: i => causeDecode(i),
|
|
5446
|
+
encode: a => causeEncode(a)
|
|
5385
5447
|
});
|
|
5448
|
+
return out;
|
|
5386
5449
|
};
|
|
5387
5450
|
/**
|
|
5388
5451
|
* Defines a schema for handling JavaScript errors (`Error` instances) and other types of defects.
|
|
@@ -5398,34 +5461,35 @@ const Cause = ({
|
|
|
5398
5461
|
* @since 3.10.0
|
|
5399
5462
|
*/
|
|
5400
5463
|
exports.Cause = Cause;
|
|
5401
|
-
|
|
5464
|
+
class Defect extends /*#__PURE__*/transform(Unknown, Unknown, {
|
|
5402
5465
|
strict: true,
|
|
5403
|
-
decode:
|
|
5404
|
-
if (Predicate.isObject(
|
|
5405
|
-
const err = new Error(
|
|
5406
|
-
cause:
|
|
5466
|
+
decode: i => {
|
|
5467
|
+
if (Predicate.isObject(i) && "message" in i && typeof i.message === "string") {
|
|
5468
|
+
const err = new Error(i.message, {
|
|
5469
|
+
cause: i
|
|
5407
5470
|
});
|
|
5408
|
-
if ("name" in
|
|
5409
|
-
err.name =
|
|
5471
|
+
if ("name" in i && typeof i.name === "string") {
|
|
5472
|
+
err.name = i.name;
|
|
5410
5473
|
}
|
|
5411
|
-
err.stack = "stack" in
|
|
5474
|
+
err.stack = "stack" in i && typeof i.stack === "string" ? i.stack : "";
|
|
5412
5475
|
return err;
|
|
5413
5476
|
}
|
|
5414
|
-
return String(
|
|
5477
|
+
return String(i);
|
|
5415
5478
|
},
|
|
5416
|
-
encode:
|
|
5417
|
-
if (
|
|
5479
|
+
encode: a => {
|
|
5480
|
+
if (a instanceof Error) {
|
|
5418
5481
|
return {
|
|
5419
|
-
name:
|
|
5420
|
-
message:
|
|
5482
|
+
name: a.name,
|
|
5483
|
+
message: a.message
|
|
5421
5484
|
// no stack because of security reasons
|
|
5422
5485
|
};
|
|
5423
5486
|
}
|
|
5424
|
-
return internalCause_.prettyErrorMessage(
|
|
5487
|
+
return internalCause_.prettyErrorMessage(a);
|
|
5425
5488
|
}
|
|
5426
5489
|
}).annotations({
|
|
5427
5490
|
identifier: "Defect"
|
|
5428
|
-
})
|
|
5491
|
+
}) {}
|
|
5492
|
+
exports.Defect = Defect;
|
|
5429
5493
|
const exitFailureEncoded = (error, defect) => Struct({
|
|
5430
5494
|
_tag: Literal("Failure"),
|
|
5431
5495
|
cause: causeEncoded(error, defect)
|
|
@@ -5434,9 +5498,11 @@ const exitSuccessEncoded = value => Struct({
|
|
|
5434
5498
|
_tag: Literal("Success"),
|
|
5435
5499
|
value
|
|
5436
5500
|
});
|
|
5437
|
-
const exitEncoded = (value, error, defect) =>
|
|
5438
|
-
|
|
5439
|
-
})
|
|
5501
|
+
const exitEncoded = (value, error, defect) => {
|
|
5502
|
+
return Union(exitFailureEncoded(error, defect), exitSuccessEncoded(value)).annotations({
|
|
5503
|
+
title: `ExitEncoded<${format(value)}, ${format(error)}, ${format(defect)}>`
|
|
5504
|
+
});
|
|
5505
|
+
};
|
|
5440
5506
|
const exitDecode = input => {
|
|
5441
5507
|
switch (input._tag) {
|
|
5442
5508
|
case "Failure":
|
|
@@ -5492,21 +5558,22 @@ const Exit = ({
|
|
|
5492
5558
|
const success_ = asSchema(success);
|
|
5493
5559
|
const failure_ = asSchema(failure);
|
|
5494
5560
|
const defect_ = asSchema(defect);
|
|
5495
|
-
|
|
5561
|
+
const out = transform(exitEncoded(success_, failure_, defect_), ExitFromSelf({
|
|
5496
5562
|
failure: typeSchema(failure_),
|
|
5497
5563
|
success: typeSchema(success_),
|
|
5498
|
-
defect:
|
|
5564
|
+
defect: typeSchema(defect_)
|
|
5499
5565
|
}), {
|
|
5500
5566
|
strict: false,
|
|
5501
|
-
decode: exitDecode,
|
|
5502
|
-
encode:
|
|
5567
|
+
decode: i => exitDecode(i),
|
|
5568
|
+
encode: a => a._tag === "Failure" ? {
|
|
5503
5569
|
_tag: "Failure",
|
|
5504
|
-
cause:
|
|
5570
|
+
cause: a.cause
|
|
5505
5571
|
} : {
|
|
5506
5572
|
_tag: "Success",
|
|
5507
|
-
value:
|
|
5573
|
+
value: a.value
|
|
5508
5574
|
}
|
|
5509
5575
|
});
|
|
5576
|
+
return out;
|
|
5510
5577
|
};
|
|
5511
5578
|
exports.Exit = Exit;
|
|
5512
5579
|
const hashSetArbitrary = (item, ctx) => fc => {
|
|
@@ -5539,15 +5606,13 @@ const HashSetFromSelf = value => {
|
|
|
5539
5606
|
* @since 3.10.0
|
|
5540
5607
|
*/
|
|
5541
5608
|
exports.HashSetFromSelf = HashSetFromSelf;
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
return transform(Array$(value_), HashSetFromSelf(typeSchema(value_)), {
|
|
5609
|
+
function HashSet(value) {
|
|
5610
|
+
return transform(Array$(value), HashSetFromSelf(typeSchema(asSchema(value))), {
|
|
5545
5611
|
strict: true,
|
|
5546
|
-
decode:
|
|
5547
|
-
encode:
|
|
5612
|
+
decode: i => hashSet_.fromIterable(i),
|
|
5613
|
+
encode: a => Array.from(a)
|
|
5548
5614
|
});
|
|
5549
|
-
}
|
|
5550
|
-
exports.HashSet = HashSet;
|
|
5615
|
+
}
|
|
5551
5616
|
const hashMapArbitrary = (key, value, ctx) => fc => {
|
|
5552
5617
|
const items = fc.array(fc.tuple(key(fc), value(fc)));
|
|
5553
5618
|
return (ctx.depthIdentifier !== undefined ? fc.oneof(ctx, fc.constant([]), items) : items).map(hashMap_.fromIterable);
|
|
@@ -5585,15 +5650,13 @@ const HashMap = ({
|
|
|
5585
5650
|
key,
|
|
5586
5651
|
value
|
|
5587
5652
|
}) => {
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
key: typeSchema(key_),
|
|
5592
|
-
value: typeSchema(value_)
|
|
5653
|
+
return transform(Array$(Tuple(key, value)), HashMapFromSelf({
|
|
5654
|
+
key: typeSchema(asSchema(key)),
|
|
5655
|
+
value: typeSchema(asSchema(value))
|
|
5593
5656
|
}), {
|
|
5594
5657
|
strict: true,
|
|
5595
|
-
decode:
|
|
5596
|
-
encode:
|
|
5658
|
+
decode: i => hashMap_.fromIterable(i),
|
|
5659
|
+
encode: a => Array.from(a)
|
|
5597
5660
|
});
|
|
5598
5661
|
};
|
|
5599
5662
|
exports.HashMap = HashMap;
|
|
@@ -5627,15 +5690,13 @@ const ListFromSelf = value => {
|
|
|
5627
5690
|
* @since 3.10.0
|
|
5628
5691
|
*/
|
|
5629
5692
|
exports.ListFromSelf = ListFromSelf;
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
return transform(Array$(value_), ListFromSelf(typeSchema(value_)), {
|
|
5693
|
+
function List(value) {
|
|
5694
|
+
return transform(Array$(value), ListFromSelf(typeSchema(asSchema(value))), {
|
|
5633
5695
|
strict: true,
|
|
5634
|
-
decode:
|
|
5635
|
-
encode:
|
|
5696
|
+
decode: i => list_.fromIterable(i),
|
|
5697
|
+
encode: a => Array.from(a)
|
|
5636
5698
|
});
|
|
5637
|
-
}
|
|
5638
|
-
exports.List = List;
|
|
5699
|
+
}
|
|
5639
5700
|
const sortedSetArbitrary = (item, ord, ctx) => fc => {
|
|
5640
5701
|
const items = fc.array(item(fc));
|
|
5641
5702
|
return (ctx.depthIdentifier !== undefined ? fc.oneof(ctx, fc.constant([]), items) : items).map(as => sortedSet_.fromIterable(as, ord));
|
|
@@ -5662,15 +5723,14 @@ const SortedSetFromSelf = (value, ordA, ordI) => {
|
|
|
5662
5723
|
* @since 3.10.0
|
|
5663
5724
|
*/
|
|
5664
5725
|
exports.SortedSetFromSelf = SortedSetFromSelf;
|
|
5665
|
-
|
|
5666
|
-
const
|
|
5667
|
-
|
|
5668
|
-
return transform(Array$(value_), SortedSetFromSelf(to, ordA, ordA), {
|
|
5726
|
+
function SortedSet(value, ordA) {
|
|
5727
|
+
const to = typeSchema(asSchema(value));
|
|
5728
|
+
return transform(Array$(value), SortedSetFromSelf(to, ordA, ordA), {
|
|
5669
5729
|
strict: true,
|
|
5670
|
-
decode:
|
|
5671
|
-
encode:
|
|
5730
|
+
decode: i => sortedSet_.fromIterable(i, ordA),
|
|
5731
|
+
encode: a => Array.from(sortedSet_.values(a))
|
|
5672
5732
|
});
|
|
5673
|
-
}
|
|
5733
|
+
}
|
|
5674
5734
|
/**
|
|
5675
5735
|
* Converts an arbitrary value to a `boolean` by testing whether it is truthy.
|
|
5676
5736
|
* Uses `!!val` to coerce the value to a `boolean`.
|
|
@@ -5679,10 +5739,9 @@ const SortedSet = (value, ordA) => {
|
|
|
5679
5739
|
* @category boolean constructors
|
|
5680
5740
|
* @since 3.10.0
|
|
5681
5741
|
*/
|
|
5682
|
-
exports.SortedSet = SortedSet;
|
|
5683
5742
|
class BooleanFromUnknown extends /*#__PURE__*/transform(Unknown, Boolean$, {
|
|
5684
5743
|
strict: true,
|
|
5685
|
-
decode: Predicate.isTruthy,
|
|
5744
|
+
decode: i => Predicate.isTruthy(i),
|
|
5686
5745
|
encode: _Function.identity
|
|
5687
5746
|
}).annotations({
|
|
5688
5747
|
identifier: "BooleanFromUnknown"
|
|
@@ -5699,8 +5758,8 @@ class BooleanFromString extends /*#__PURE__*/transform(Literal("true", "false").
|
|
|
5699
5758
|
description: "a string to be decoded into a boolean"
|
|
5700
5759
|
}), Boolean$, {
|
|
5701
5760
|
strict: true,
|
|
5702
|
-
decode:
|
|
5703
|
-
encode:
|
|
5761
|
+
decode: i => i === "true",
|
|
5762
|
+
encode: a => a ? "true" : "false"
|
|
5704
5763
|
}).annotations({
|
|
5705
5764
|
identifier: "BooleanFromString"
|
|
5706
5765
|
}) {}
|
|
@@ -6058,6 +6117,18 @@ const go = (ast, path) => {
|
|
|
6058
6117
|
}
|
|
6059
6118
|
}
|
|
6060
6119
|
};
|
|
6120
|
+
const SymbolStruct = /*#__PURE__*/TaggedStruct("symbol", {
|
|
6121
|
+
key: String$
|
|
6122
|
+
}).annotations({
|
|
6123
|
+
description: "an object to be decoded into a globally shared symbol"
|
|
6124
|
+
});
|
|
6125
|
+
const SymbolFromStruct = /*#__PURE__*/transformOrFail(SymbolStruct, SymbolFromSelf, {
|
|
6126
|
+
strict: true,
|
|
6127
|
+
decode: i => decodeSymbol(i.key),
|
|
6128
|
+
encode: (a, _, ast) => ParseResult.map(encodeSymbol(a, ast), key => SymbolStruct.make({
|
|
6129
|
+
key
|
|
6130
|
+
}))
|
|
6131
|
+
});
|
|
6061
6132
|
/** @ignore */
|
|
6062
6133
|
class PropertyKey$ extends /*#__PURE__*/Union(String$, Number$, SymbolFromStruct).annotations({
|
|
6063
6134
|
identifier: "PropertyKey"
|