effect 3.12.4 → 3.12.6
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/Arbitrary.js +72 -14
- package/dist/cjs/Arbitrary.js.map +1 -1
- package/dist/cjs/Array.js +11 -9
- package/dist/cjs/Array.js.map +1 -1
- package/dist/cjs/Cause.js +26 -2
- package/dist/cjs/Cause.js.map +1 -1
- package/dist/cjs/Cron.js +55 -23
- package/dist/cjs/Cron.js.map +1 -1
- package/dist/cjs/Duration.js.map +1 -1
- package/dist/cjs/Effect.js +32 -23
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/FiberHandle.js +8 -8
- package/dist/cjs/FiberMap.js +8 -8
- package/dist/cjs/FiberSet.js +8 -8
- package/dist/cjs/Inspectable.js +0 -4
- package/dist/cjs/Inspectable.js.map +1 -1
- package/dist/cjs/LogLevel.js +30 -2
- package/dist/cjs/LogLevel.js.map +1 -1
- package/dist/cjs/ParseResult.js +38 -18
- package/dist/cjs/ParseResult.js.map +1 -1
- package/dist/cjs/Schema.js +192 -118
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/internal/cause.js.map +1 -1
- package/dist/cjs/internal/core-effect.js +6 -5
- package/dist/cjs/internal/core-effect.js.map +1 -1
- package/dist/cjs/internal/core.js +6 -5
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/dateTime.js +12 -3
- package/dist/cjs/internal/dateTime.js.map +1 -1
- package/dist/cjs/internal/effect/circular.js +15 -2
- package/dist/cjs/internal/effect/circular.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/groupBy.js +7 -7
- package/dist/cjs/internal/groupBy.js.map +1 -1
- package/dist/cjs/internal/rateLimiter.js +8 -7
- package/dist/cjs/internal/rateLimiter.js.map +1 -1
- package/dist/cjs/internal/runtime.js +7 -11
- package/dist/cjs/internal/runtime.js.map +1 -1
- package/dist/cjs/internal/stream.js +5 -5
- package/dist/cjs/internal/stream.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Arbitrary.d.ts.map +1 -1
- package/dist/dts/Array.d.ts +62 -16
- package/dist/dts/Array.d.ts.map +1 -1
- package/dist/dts/Cause.d.ts +27 -3
- package/dist/dts/Cause.d.ts.map +1 -1
- package/dist/dts/Cron.d.ts +10 -3
- package/dist/dts/Cron.d.ts.map +1 -1
- package/dist/dts/Duration.d.ts +5 -5
- package/dist/dts/Duration.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts +31 -22
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/FiberHandle.d.ts +8 -8
- package/dist/dts/FiberMap.d.ts +8 -8
- package/dist/dts/FiberSet.d.ts +8 -8
- package/dist/dts/Inspectable.d.ts.map +1 -1
- package/dist/dts/LogLevel.d.ts +90 -6
- package/dist/dts/LogLevel.d.ts.map +1 -1
- package/dist/dts/ParseResult.d.ts +11 -0
- package/dist/dts/ParseResult.d.ts.map +1 -1
- package/dist/dts/Schema.d.ts +53 -33
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/dts/internal/core-effect.d.ts.map +1 -1
- package/dist/dts/internal/core.d.ts.map +1 -1
- package/dist/dts/internal/stream.d.ts.map +1 -1
- package/dist/esm/Arbitrary.js +72 -14
- package/dist/esm/Arbitrary.js.map +1 -1
- package/dist/esm/Array.js +11 -9
- package/dist/esm/Array.js.map +1 -1
- package/dist/esm/Cause.js +26 -2
- package/dist/esm/Cause.js.map +1 -1
- package/dist/esm/Cron.js +53 -22
- package/dist/esm/Cron.js.map +1 -1
- package/dist/esm/Duration.js.map +1 -1
- package/dist/esm/Effect.js +32 -23
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/FiberHandle.js +8 -8
- package/dist/esm/FiberMap.js +8 -8
- package/dist/esm/FiberSet.js +8 -8
- package/dist/esm/Inspectable.js +0 -3
- package/dist/esm/Inspectable.js.map +1 -1
- package/dist/esm/LogLevel.js +30 -2
- package/dist/esm/LogLevel.js.map +1 -1
- package/dist/esm/ParseResult.js +38 -18
- package/dist/esm/ParseResult.js.map +1 -1
- package/dist/esm/Schema.js +186 -110
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/internal/cause.js.map +1 -1
- package/dist/esm/internal/core-effect.js +6 -5
- package/dist/esm/internal/core-effect.js.map +1 -1
- package/dist/esm/internal/core.js +6 -5
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/dateTime.js +11 -2
- package/dist/esm/internal/dateTime.js.map +1 -1
- package/dist/esm/internal/effect/circular.js +15 -2
- package/dist/esm/internal/effect/circular.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/groupBy.js +7 -7
- package/dist/esm/internal/groupBy.js.map +1 -1
- package/dist/esm/internal/rateLimiter.js +8 -7
- package/dist/esm/internal/rateLimiter.js.map +1 -1
- package/dist/esm/internal/runtime.js +7 -11
- package/dist/esm/internal/runtime.js.map +1 -1
- package/dist/esm/internal/stream.js +5 -5
- package/dist/esm/internal/stream.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/Arbitrary.ts +84 -14
- package/src/Array.ts +65 -19
- package/src/Cause.ts +27 -3
- package/src/Cron.ts +30 -27
- package/src/Duration.ts +11 -3
- package/src/Effect.ts +35 -23
- package/src/FiberHandle.ts +8 -8
- package/src/FiberMap.ts +8 -8
- package/src/FiberSet.ts +8 -8
- package/src/Inspectable.ts +0 -1
- package/src/LogLevel.ts +90 -6
- package/src/ParseResult.ts +52 -28
- package/src/Schema.ts +233 -124
- package/src/internal/cause.ts +1 -1
- package/src/internal/core-effect.ts +16 -9
- package/src/internal/core.ts +9 -4
- package/src/internal/dateTime.ts +12 -2
- package/src/internal/effect/circular.ts +19 -17
- package/src/internal/fiberRuntime.ts +2 -1
- package/src/internal/groupBy.ts +35 -39
- package/src/internal/rateLimiter.ts +8 -7
- package/src/internal/runtime.ts +6 -14
- package/src/internal/stream.ts +13 -15
- package/src/internal/version.ts +1 -1
package/dist/esm/Schema.js
CHANGED
|
@@ -2179,22 +2179,21 @@ export const split = separator => transform(String$.annotations({
|
|
|
2179
2179
|
decode: string_.split(separator),
|
|
2180
2180
|
encode: array_.join(separator)
|
|
2181
2181
|
});
|
|
2182
|
-
const
|
|
2183
|
-
|
|
2184
|
-
[AST.
|
|
2185
|
-
|
|
2186
|
-
});
|
|
2187
|
-
const getParseJsonTransformation = options => transformOrFail(JsonString, Unknown, {
|
|
2182
|
+
const getErrorMessage = e => e instanceof Error ? e.message : String(e);
|
|
2183
|
+
const getParseJsonTransformation = options => transformOrFail(String$.annotations({
|
|
2184
|
+
[AST.DescriptionAnnotationId]: "a string to be decoded into JSON"
|
|
2185
|
+
}), Unknown, {
|
|
2188
2186
|
strict: true,
|
|
2189
2187
|
decode: (s, _, ast) => ParseResult.try({
|
|
2190
2188
|
try: () => JSON.parse(s, options?.reviver),
|
|
2191
|
-
catch: e => new ParseResult.Type(ast, s, e
|
|
2189
|
+
catch: e => new ParseResult.Type(ast, s, getErrorMessage(e))
|
|
2192
2190
|
}),
|
|
2193
2191
|
encode: (u, _, ast) => ParseResult.try({
|
|
2194
2192
|
try: () => JSON.stringify(u, options?.replacer, options?.space),
|
|
2195
|
-
catch: e => new ParseResult.Type(ast, u, e
|
|
2193
|
+
catch: e => new ParseResult.Type(ast, u, getErrorMessage(e))
|
|
2196
2194
|
})
|
|
2197
2195
|
}).annotations({
|
|
2196
|
+
title: "parseJson",
|
|
2198
2197
|
schemaId: AST.ParseJsonSchemaId
|
|
2199
2198
|
});
|
|
2200
2199
|
/**
|
|
@@ -2282,12 +2281,12 @@ export class URLFromSelf extends /*#__PURE__*/instanceOf(URL, {
|
|
|
2282
2281
|
}) {}
|
|
2283
2282
|
/** @ignore */
|
|
2284
2283
|
class URL$ extends /*#__PURE__*/transformOrFail(String$.annotations({
|
|
2285
|
-
description: "a string
|
|
2284
|
+
description: "a string to be decoded into a URL"
|
|
2286
2285
|
}), URLFromSelf, {
|
|
2287
2286
|
strict: true,
|
|
2288
|
-
decode: (
|
|
2289
|
-
try: () => new URL(
|
|
2290
|
-
catch:
|
|
2287
|
+
decode: (s, _, ast) => ParseResult.try({
|
|
2288
|
+
try: () => new URL(s),
|
|
2289
|
+
catch: e => new ParseResult.Type(ast, s, `Unable to decode ${JSON.stringify(s)} into a URL. ${getErrorMessage(e)}`)
|
|
2291
2290
|
}),
|
|
2292
2291
|
encode: url => ParseResult.succeed(url.toString())
|
|
2293
2292
|
}).annotations({
|
|
@@ -2538,7 +2537,7 @@ export const clamp = (minimum, maximum) => self => transform(self, self.pipe(typ
|
|
|
2538
2537
|
*/
|
|
2539
2538
|
export const parseNumber = self => transformOrFail(self, Number$, {
|
|
2540
2539
|
strict: false,
|
|
2541
|
-
decode: (s, _, ast) => ParseResult.fromOption(number_.parse(s), () => new ParseResult.Type(ast, s)),
|
|
2540
|
+
decode: (s, _, ast) => ParseResult.fromOption(number_.parse(s), () => new ParseResult.Type(ast, s, `Unable to decode ${JSON.stringify(s)} into a number`)),
|
|
2542
2541
|
encode: n => ParseResult.succeed(String(n))
|
|
2543
2542
|
});
|
|
2544
2543
|
/**
|
|
@@ -2552,7 +2551,7 @@ export const parseNumber = self => transformOrFail(self, Number$, {
|
|
|
2552
2551
|
* @since 3.10.0
|
|
2553
2552
|
*/
|
|
2554
2553
|
export class NumberFromString extends /*#__PURE__*/parseNumber(String$.annotations({
|
|
2555
|
-
description: "a string
|
|
2554
|
+
description: "a string to be decoded into a number"
|
|
2556
2555
|
})).annotations({
|
|
2557
2556
|
identifier: "NumberFromString"
|
|
2558
2557
|
}) {}
|
|
@@ -2645,24 +2644,43 @@ export class Not extends /*#__PURE__*/transform( /*#__PURE__*/Boolean$.annotatio
|
|
|
2645
2644
|
decode: boolean_.not,
|
|
2646
2645
|
encode: boolean_.not
|
|
2647
2646
|
}) {}
|
|
2647
|
+
const encodeSymbol = (sym, _, ast) => {
|
|
2648
|
+
const key = Symbol.keyFor(sym);
|
|
2649
|
+
return key === undefined ? ParseResult.fail(new ParseResult.Type(ast, sym, `Unable to encode a unique symbol ${String(sym)} into a string`)) : ParseResult.succeed(key);
|
|
2650
|
+
};
|
|
2651
|
+
const decodeSymbol = s => ParseResult.succeed(Symbol.for(s));
|
|
2648
2652
|
/** @ignore */
|
|
2649
|
-
class Symbol$ extends /*#__PURE__*/
|
|
2650
|
-
description: "a string
|
|
2653
|
+
class Symbol$ extends /*#__PURE__*/transformOrFail(String$.annotations({
|
|
2654
|
+
description: "a string to be decoded into a globally shared symbol"
|
|
2651
2655
|
}), SymbolFromSelf, {
|
|
2652
2656
|
strict: false,
|
|
2653
|
-
decode:
|
|
2654
|
-
encode:
|
|
2657
|
+
decode: decodeSymbol,
|
|
2658
|
+
encode: encodeSymbol
|
|
2655
2659
|
}).annotations({
|
|
2656
|
-
identifier: "
|
|
2660
|
+
identifier: "Symbol"
|
|
2657
2661
|
}) {}
|
|
2658
2662
|
export {
|
|
2659
2663
|
/**
|
|
2660
|
-
*
|
|
2664
|
+
* Converts a string key into a globally shared symbol.
|
|
2661
2665
|
*
|
|
2662
2666
|
* @category symbol transformations
|
|
2663
2667
|
* @since 3.10.0
|
|
2664
2668
|
*/
|
|
2665
2669
|
Symbol$ as Symbol };
|
|
2670
|
+
const SymbolStruct = /*#__PURE__*/TaggedStruct("symbol", {
|
|
2671
|
+
key: String$
|
|
2672
|
+
}).annotations({
|
|
2673
|
+
description: "an object to be decoded into a globally shared symbol"
|
|
2674
|
+
});
|
|
2675
|
+
const SymbolFromStruct = /*#__PURE__*/transformOrFail(SymbolStruct, SymbolFromSelf, {
|
|
2676
|
+
strict: true,
|
|
2677
|
+
decode: ({
|
|
2678
|
+
key
|
|
2679
|
+
}) => decodeSymbol(key),
|
|
2680
|
+
encode: (sym, _, ast) => ParseResult.map(encodeSymbol(sym, _, ast), key => SymbolStruct.make({
|
|
2681
|
+
key
|
|
2682
|
+
}))
|
|
2683
|
+
});
|
|
2666
2684
|
/**
|
|
2667
2685
|
* @category schema id
|
|
2668
2686
|
* @since 3.10.0
|
|
@@ -2802,13 +2820,13 @@ export const clampBigInt = (minimum, maximum) => self => transform(self, self.pi
|
|
|
2802
2820
|
});
|
|
2803
2821
|
/** @ignore */
|
|
2804
2822
|
class BigInt$ extends /*#__PURE__*/transformOrFail(String$.annotations({
|
|
2805
|
-
description: "a string
|
|
2823
|
+
description: "a string to be decoded into a bigint"
|
|
2806
2824
|
}), BigIntFromSelf, {
|
|
2807
2825
|
strict: true,
|
|
2808
|
-
decode: (s, _, ast) => ParseResult.fromOption(bigInt_.fromString(s), () => new ParseResult.Type(ast, s)),
|
|
2826
|
+
decode: (s, _, ast) => ParseResult.fromOption(bigInt_.fromString(s), () => new ParseResult.Type(ast, s, `Unable to decode ${JSON.stringify(s)} into a bigint`)),
|
|
2809
2827
|
encode: n => ParseResult.succeed(String(n))
|
|
2810
2828
|
}).annotations({
|
|
2811
|
-
identifier: "
|
|
2829
|
+
identifier: "BigInt"
|
|
2812
2830
|
}) {}
|
|
2813
2831
|
export {
|
|
2814
2832
|
/**
|
|
@@ -2885,13 +2903,13 @@ export const NonNegativeBigInt = /*#__PURE__*/BigInt$.pipe( /*#__PURE__*/nonNega
|
|
|
2885
2903
|
* @since 3.10.0
|
|
2886
2904
|
*/
|
|
2887
2905
|
export class BigIntFromNumber extends /*#__PURE__*/transformOrFail(Number$.annotations({
|
|
2888
|
-
description: "a number
|
|
2889
|
-
}), BigIntFromSelf, {
|
|
2906
|
+
description: "a number to be decoded into a bigint"
|
|
2907
|
+
}), BigIntFromSelf.pipe(betweenBigInt(BigInt(Number.MIN_SAFE_INTEGER), BigInt(Number.MAX_SAFE_INTEGER))), {
|
|
2890
2908
|
strict: true,
|
|
2891
|
-
decode: (n, _, ast) => ParseResult.fromOption(bigInt_.fromNumber(n), () => new ParseResult.Type(ast, n)),
|
|
2892
|
-
encode: (b, _, ast) => ParseResult.fromOption(bigInt_.toNumber(b), () => new ParseResult.Type(ast, b))
|
|
2909
|
+
decode: (n, _, ast) => ParseResult.fromOption(bigInt_.fromNumber(n), () => new ParseResult.Type(ast, n, `Unable to decode ${n} into a bigint`)),
|
|
2910
|
+
encode: (b, _, ast) => ParseResult.fromOption(bigInt_.toNumber(b), () => new ParseResult.Type(ast, b, `Unable to encode ${b}n into a number`))
|
|
2893
2911
|
}).annotations({
|
|
2894
|
-
identifier: "
|
|
2912
|
+
identifier: "BigIntFromNumber"
|
|
2895
2913
|
}) {}
|
|
2896
2914
|
const redactedArbitrary = value => fc => value(fc).map(redacted_.make);
|
|
2897
2915
|
const toComposite = (eff, onSuccess, ast, actual) => ParseResult.mapBoth(eff, {
|
|
@@ -2932,70 +2950,83 @@ export const Redacted = value => {
|
|
|
2932
2950
|
export class DurationFromSelf extends /*#__PURE__*/declare(duration_.isDuration, {
|
|
2933
2951
|
identifier: "DurationFromSelf",
|
|
2934
2952
|
pretty: () => String,
|
|
2935
|
-
arbitrary: () => fc => fc.oneof(fc.constant(duration_.infinity), fc.
|
|
2953
|
+
arbitrary: () => fc => fc.oneof(fc.constant(duration_.infinity), fc.bigInt({
|
|
2954
|
+
min: 0n
|
|
2955
|
+
}).map(_ => duration_.nanos(_)), fc.maxSafeNat().map(_ => duration_.millis(_))),
|
|
2936
2956
|
equivalence: () => duration_.Equivalence
|
|
2937
2957
|
}) {}
|
|
2938
2958
|
/**
|
|
2939
|
-
* A schema that transforms a `bigint`
|
|
2940
|
-
*
|
|
2959
|
+
* A schema that transforms a non negative `bigint` into a `Duration`. Treats
|
|
2960
|
+
* the value as the number of nanoseconds.
|
|
2941
2961
|
*
|
|
2942
2962
|
* @category Duration transformations
|
|
2943
2963
|
* @since 3.10.0
|
|
2944
2964
|
*/
|
|
2945
|
-
export class DurationFromNanos extends /*#__PURE__*/transformOrFail(
|
|
2946
|
-
description: "a bigint
|
|
2947
|
-
}), DurationFromSelf, {
|
|
2965
|
+
export class DurationFromNanos extends /*#__PURE__*/transformOrFail(NonNegativeBigIntFromSelf.annotations({
|
|
2966
|
+
description: "a bigint to be decoded into a Duration"
|
|
2967
|
+
}), DurationFromSelf.pipe(filter(duration => duration_.isFinite(duration), {
|
|
2968
|
+
description: "a finite duration"
|
|
2969
|
+
})), {
|
|
2948
2970
|
strict: true,
|
|
2949
2971
|
decode: nanos => ParseResult.succeed(duration_.nanos(nanos)),
|
|
2950
2972
|
encode: (duration, _, ast) => option_.match(duration_.toNanos(duration), {
|
|
2951
|
-
onNone: () => ParseResult.fail(new ParseResult.Type(ast, duration)),
|
|
2952
|
-
onSome:
|
|
2973
|
+
onNone: () => ParseResult.fail(new ParseResult.Type(ast, duration, `Unable to encode ${duration} into a bigint`)),
|
|
2974
|
+
onSome: nanos => ParseResult.succeed(nanos)
|
|
2953
2975
|
})
|
|
2954
2976
|
}).annotations({
|
|
2955
2977
|
identifier: "DurationFromNanos"
|
|
2956
2978
|
}) {}
|
|
2957
2979
|
/**
|
|
2958
|
-
* A
|
|
2959
|
-
*
|
|
2980
|
+
* A non-negative integer. +Infinity is excluded.
|
|
2981
|
+
*
|
|
2982
|
+
* @category number constructors
|
|
2983
|
+
* @since 3.11.10
|
|
2984
|
+
*/
|
|
2985
|
+
export const NonNegativeInt = /*#__PURE__*/NonNegative.pipe(int()).annotations({
|
|
2986
|
+
identifier: "NonNegativeInt"
|
|
2987
|
+
});
|
|
2988
|
+
/**
|
|
2989
|
+
* A schema that transforms a (possibly Infinite) non negative number into a
|
|
2990
|
+
* `Duration`. Treats the value as the number of milliseconds.
|
|
2960
2991
|
*
|
|
2961
2992
|
* @category Duration transformations
|
|
2962
2993
|
* @since 3.10.0
|
|
2963
2994
|
*/
|
|
2964
|
-
export class DurationFromMillis extends /*#__PURE__*/transform(
|
|
2965
|
-
description: "a number
|
|
2995
|
+
export class DurationFromMillis extends /*#__PURE__*/transform(NonNegative.annotations({
|
|
2996
|
+
description: "a non-negative number to be decoded into a Duration"
|
|
2966
2997
|
}), DurationFromSelf, {
|
|
2967
2998
|
strict: true,
|
|
2968
2999
|
decode: ms => duration_.millis(ms),
|
|
2969
|
-
encode:
|
|
3000
|
+
encode: duration => duration_.toMillis(duration)
|
|
2970
3001
|
}).annotations({
|
|
2971
3002
|
identifier: "DurationFromMillis"
|
|
2972
3003
|
}) {}
|
|
2973
|
-
|
|
2974
|
-
* @category number constructors
|
|
2975
|
-
* @since 3.11.10
|
|
2976
|
-
*/
|
|
2977
|
-
export const NonNegativeInt = /*#__PURE__*/NonNegative.pipe(int()).annotations({
|
|
2978
|
-
identifier: "NonNegativeInt"
|
|
2979
|
-
});
|
|
2980
|
-
const HRTime = /*#__PURE__*/Tuple(element(NonNegativeInt).annotations({
|
|
3004
|
+
const FiniteHRTime = /*#__PURE__*/Tuple(element(NonNegativeInt).annotations({
|
|
2981
3005
|
title: "seconds"
|
|
2982
3006
|
}), element(NonNegativeInt).annotations({
|
|
2983
3007
|
title: "nanos"
|
|
2984
3008
|
})).annotations({
|
|
2985
|
-
identifier: "
|
|
3009
|
+
identifier: "FiniteHRTime"
|
|
3010
|
+
});
|
|
3011
|
+
const InfiniteHRTime = /*#__PURE__*/Tuple(Literal(-1), Literal(0)).annotations({
|
|
3012
|
+
identifier: "InfiniteHRTime"
|
|
3013
|
+
});
|
|
3014
|
+
const HRTime = /*#__PURE__*/Union(FiniteHRTime, InfiniteHRTime).annotations({
|
|
3015
|
+
identifier: "HRTime",
|
|
3016
|
+
description: "a tuple of seconds and nanos to be decoded into a Duration"
|
|
2986
3017
|
});
|
|
2987
3018
|
/**
|
|
2988
3019
|
* A schema that transforms a `[number, number]` tuple into a `Duration`.
|
|
2989
3020
|
*
|
|
3021
|
+
* Infinite durations are encoded as `[-1, 0]`.
|
|
3022
|
+
*
|
|
2990
3023
|
* @category Duration transformations
|
|
2991
3024
|
* @since 3.10.0
|
|
2992
3025
|
*/
|
|
2993
|
-
export class Duration extends /*#__PURE__*/transform(HRTime
|
|
2994
|
-
description: "a tuple of seconds and nanos that will be parsed into a Duration"
|
|
2995
|
-
}), DurationFromSelf, {
|
|
3026
|
+
export class Duration extends /*#__PURE__*/transform(HRTime, DurationFromSelf, {
|
|
2996
3027
|
strict: true,
|
|
2997
|
-
decode: ([seconds, nanos]) => duration_.nanos(BigInt(seconds) * BigInt(1e9) + BigInt(nanos)),
|
|
2998
|
-
encode: duration => duration_.toHrTime(duration)
|
|
3028
|
+
decode: ([seconds, nanos]) => seconds === -1 ? duration_.infinity : duration_.nanos(BigInt(seconds) * BigInt(1e9) + BigInt(nanos)),
|
|
3029
|
+
encode: duration => duration.value._tag === "Infinity" ? [-1, 0] : duration_.toHrTime(duration)
|
|
2999
3030
|
}).annotations({
|
|
3000
3031
|
identifier: "Duration"
|
|
3001
3032
|
}) {}
|
|
@@ -3126,7 +3157,7 @@ export const Uint8 = /*#__PURE__*/Number$.pipe( /*#__PURE__*/between(0, 255, {
|
|
|
3126
3157
|
description: "a 8-bit unsigned integer"
|
|
3127
3158
|
}));
|
|
3128
3159
|
const Uint8Array$ = /*#__PURE__*/transform(Array$(Uint8).annotations({
|
|
3129
|
-
description: "an array of 8-bit unsigned integers
|
|
3160
|
+
description: "an array of 8-bit unsigned integers to be decoded into a Uint8Array"
|
|
3130
3161
|
}), Uint8ArrayFromSelf, {
|
|
3131
3162
|
strict: true,
|
|
3132
3163
|
decode: numbers => Uint8Array.from(numbers),
|
|
@@ -3143,7 +3174,7 @@ export {
|
|
|
3143
3174
|
*/
|
|
3144
3175
|
Uint8Array$ as Uint8Array };
|
|
3145
3176
|
const makeUint8ArrayTransformation = (id, decode, encode) => transformOrFail(String$.annotations({
|
|
3146
|
-
description: "a string
|
|
3177
|
+
description: "a string to be decoded into a Uint8Array"
|
|
3147
3178
|
}), Uint8ArrayFromSelf, {
|
|
3148
3179
|
strict: true,
|
|
3149
3180
|
decode: (s, _, ast) => either_.mapLeft(decode(s), decodeException => new ParseResult.Type(ast, s, decodeException.message)),
|
|
@@ -3267,16 +3298,22 @@ export const MaxItemsSchemaId = schemaId_.MaxItemsSchemaId;
|
|
|
3267
3298
|
* @category ReadonlyArray filters
|
|
3268
3299
|
* @since 3.10.0
|
|
3269
3300
|
*/
|
|
3270
|
-
export const maxItems = (n, annotations) => self =>
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3301
|
+
export const maxItems = (n, annotations) => self => {
|
|
3302
|
+
const maxItems = Math.floor(n);
|
|
3303
|
+
if (maxItems < 1) {
|
|
3304
|
+
throw new Error(errors_.getInvalidArgumentErrorMessage(`Expected an integer greater than or equal to 1, actual ${n}`));
|
|
3305
|
+
}
|
|
3306
|
+
return self.pipe(filter(a => a.length <= maxItems, {
|
|
3307
|
+
schemaId: MaxItemsSchemaId,
|
|
3308
|
+
title: `maxItems(${maxItems})`,
|
|
3309
|
+
description: `an array of at most ${maxItems} item(s)`,
|
|
3310
|
+
jsonSchema: {
|
|
3311
|
+
maxItems
|
|
3312
|
+
},
|
|
3313
|
+
[AST.StableFilterAnnotationId]: true,
|
|
3314
|
+
...annotations
|
|
3315
|
+
}));
|
|
3316
|
+
};
|
|
3280
3317
|
/**
|
|
3281
3318
|
* @category schema id
|
|
3282
3319
|
* @since 3.10.0
|
|
@@ -3286,17 +3323,23 @@ export const ItemsCountSchemaId = schemaId_.ItemsCountSchemaId;
|
|
|
3286
3323
|
* @category ReadonlyArray filters
|
|
3287
3324
|
* @since 3.10.0
|
|
3288
3325
|
*/
|
|
3289
|
-
export const itemsCount = (n, annotations) => self =>
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3326
|
+
export const itemsCount = (n, annotations) => self => {
|
|
3327
|
+
const itemsCount = Math.floor(n);
|
|
3328
|
+
if (itemsCount < 1) {
|
|
3329
|
+
throw new Error(errors_.getInvalidArgumentErrorMessage(`Expected an integer greater than or equal to 1, actual ${n}`));
|
|
3330
|
+
}
|
|
3331
|
+
return self.pipe(filter(a => a.length === itemsCount, {
|
|
3332
|
+
schemaId: ItemsCountSchemaId,
|
|
3333
|
+
title: `itemsCount(${itemsCount})`,
|
|
3334
|
+
description: `an array of exactly ${itemsCount} item(s)`,
|
|
3335
|
+
jsonSchema: {
|
|
3336
|
+
minItems: itemsCount,
|
|
3337
|
+
maxItems: itemsCount
|
|
3338
|
+
},
|
|
3339
|
+
[AST.StableFilterAnnotationId]: true,
|
|
3340
|
+
...annotations
|
|
3341
|
+
}));
|
|
3342
|
+
};
|
|
3300
3343
|
/**
|
|
3301
3344
|
* @category ReadonlyArray transformations
|
|
3302
3345
|
* @since 3.10.0
|
|
@@ -3337,7 +3380,7 @@ export const headNonEmpty = self => transform(self, getNumberIndexedAccess(typeS
|
|
|
3337
3380
|
*/
|
|
3338
3381
|
export const headOrElse = /*#__PURE__*/dual(args => isSchema(args[0]), (self, fallback) => transformOrFail(self, getNumberIndexedAccess(typeSchema(self)), {
|
|
3339
3382
|
strict: true,
|
|
3340
|
-
decode: (as, _, ast) => as.length > 0 ? ParseResult.succeed(as[0]) : fallback ? ParseResult.succeed(fallback()) : ParseResult.fail(new ParseResult.Type(ast, as)),
|
|
3383
|
+
decode: (as, _, ast) => as.length > 0 ? ParseResult.succeed(as[0]) : fallback ? ParseResult.succeed(fallback()) : ParseResult.fail(new ParseResult.Type(ast, as, "Unable to retrieve the first element of an empty array")),
|
|
3341
3384
|
encode: a => ParseResult.succeed(array_.of(a))
|
|
3342
3385
|
}));
|
|
3343
3386
|
/**
|
|
@@ -3503,7 +3546,7 @@ export class ValidDateFromSelf extends /*#__PURE__*/DateFromSelf.pipe( /*#__PURE
|
|
|
3503
3546
|
* @since 3.10.0
|
|
3504
3547
|
*/
|
|
3505
3548
|
export class DateFromString extends /*#__PURE__*/transform(String$.annotations({
|
|
3506
|
-
description: "a string
|
|
3549
|
+
description: "a string to be decoded into a Date"
|
|
3507
3550
|
}), DateFromSelf, {
|
|
3508
3551
|
strict: true,
|
|
3509
3552
|
decode: s => new Date(s),
|
|
@@ -3537,7 +3580,7 @@ Date$ as Date };
|
|
|
3537
3580
|
* @since 3.10.0
|
|
3538
3581
|
*/
|
|
3539
3582
|
export class DateFromNumber extends /*#__PURE__*/transform(Number$.annotations({
|
|
3540
|
-
description: "a number
|
|
3583
|
+
description: "a number to be decoded into a Date"
|
|
3541
3584
|
}), DateFromSelf, {
|
|
3542
3585
|
strict: true,
|
|
3543
3586
|
decode: n => new Date(n),
|
|
@@ -3555,12 +3598,14 @@ export class DateTimeUtcFromSelf extends /*#__PURE__*/declare(u => dateTime.isDa
|
|
|
3555
3598
|
identifier: "DateTimeUtcFromSelf",
|
|
3556
3599
|
description: "a DateTime.Utc instance",
|
|
3557
3600
|
pretty: () => dateTime => dateTime.toString(),
|
|
3558
|
-
arbitrary: () => fc => fc.date(
|
|
3601
|
+
arbitrary: () => fc => fc.date({
|
|
3602
|
+
noInvalidDate: true
|
|
3603
|
+
}).map(date => dateTime.unsafeFromDate(date)),
|
|
3559
3604
|
equivalence: () => dateTime.Equivalence
|
|
3560
3605
|
}) {}
|
|
3561
|
-
const
|
|
3606
|
+
const decodeDateTimeUtc = (input, _, ast) => ParseResult.try({
|
|
3562
3607
|
try: () => dateTime.unsafeMake(input),
|
|
3563
|
-
catch: () => new ParseResult.Type(ast, input)
|
|
3608
|
+
catch: () => new ParseResult.Type(ast, input, `Unable to decode ${util_.formatUnknown(input)} into a DateTime.Utc`)
|
|
3564
3609
|
});
|
|
3565
3610
|
/**
|
|
3566
3611
|
* Defines a schema that attempts to convert a `number` to a `DateTime.Utc` instance using the `DateTime.unsafeMake` constructor.
|
|
@@ -3569,10 +3614,10 @@ const decodeDateTime = (input, _, ast) => ParseResult.try({
|
|
|
3569
3614
|
* @since 3.10.0
|
|
3570
3615
|
*/
|
|
3571
3616
|
export class DateTimeUtcFromNumber extends /*#__PURE__*/transformOrFail(Number$.annotations({
|
|
3572
|
-
description: "a number
|
|
3617
|
+
description: "a number to be decoded into a DateTime.Utc"
|
|
3573
3618
|
}), DateTimeUtcFromSelf, {
|
|
3574
3619
|
strict: true,
|
|
3575
|
-
decode:
|
|
3620
|
+
decode: decodeDateTimeUtc,
|
|
3576
3621
|
encode: dt => ParseResult.succeed(dateTime.toEpochMillis(dt))
|
|
3577
3622
|
}).annotations({
|
|
3578
3623
|
identifier: "DateTimeUtcFromNumber"
|
|
@@ -3584,10 +3629,10 @@ export class DateTimeUtcFromNumber extends /*#__PURE__*/transformOrFail(Number$.
|
|
|
3584
3629
|
* @since 3.12.0
|
|
3585
3630
|
*/
|
|
3586
3631
|
export class DateTimeUtcFromDate extends /*#__PURE__*/transformOrFail(DateFromSelf.annotations({
|
|
3587
|
-
description: "a Date
|
|
3632
|
+
description: "a Date to be decoded into a DateTime.Utc"
|
|
3588
3633
|
}), DateTimeUtcFromSelf, {
|
|
3589
3634
|
strict: true,
|
|
3590
|
-
decode:
|
|
3635
|
+
decode: decodeDateTimeUtc,
|
|
3591
3636
|
encode: dt => ParseResult.succeed(dateTime.toDateUtc(dt))
|
|
3592
3637
|
}).annotations({
|
|
3593
3638
|
identifier: "DateTimeUtcFromDate"
|
|
@@ -3599,17 +3644,17 @@ export class DateTimeUtcFromDate extends /*#__PURE__*/transformOrFail(DateFromSe
|
|
|
3599
3644
|
* @since 3.10.0
|
|
3600
3645
|
*/
|
|
3601
3646
|
export class DateTimeUtc extends /*#__PURE__*/transformOrFail(String$.annotations({
|
|
3602
|
-
description: "a string
|
|
3647
|
+
description: "a string to be decoded into a DateTime.Utc"
|
|
3603
3648
|
}), DateTimeUtcFromSelf, {
|
|
3604
3649
|
strict: true,
|
|
3605
|
-
decode:
|
|
3650
|
+
decode: decodeDateTimeUtc,
|
|
3606
3651
|
encode: dt => ParseResult.succeed(dateTime.formatIso(dt))
|
|
3607
3652
|
}).annotations({
|
|
3608
3653
|
identifier: "DateTimeUtc"
|
|
3609
3654
|
}) {}
|
|
3610
3655
|
const timeZoneOffsetArbitrary = () => fc => fc.integer({
|
|
3611
3656
|
min: -12 * 60 * 60 * 1000,
|
|
3612
|
-
max:
|
|
3657
|
+
max: 14 * 60 * 60 * 1000
|
|
3613
3658
|
}).map(dateTime.zoneMakeOffset);
|
|
3614
3659
|
/**
|
|
3615
3660
|
* Describes a schema that represents a `TimeZone.Offset` instance.
|
|
@@ -3630,7 +3675,7 @@ export class TimeZoneOffsetFromSelf extends /*#__PURE__*/declare(dateTime.isTime
|
|
|
3630
3675
|
* @since 3.10.0
|
|
3631
3676
|
*/
|
|
3632
3677
|
export class TimeZoneOffset extends /*#__PURE__*/transform(Number$.annotations({
|
|
3633
|
-
description: "a number
|
|
3678
|
+
description: "a number to be decoded into a TimeZone.Offset"
|
|
3634
3679
|
}), TimeZoneOffsetFromSelf, {
|
|
3635
3680
|
strict: true,
|
|
3636
3681
|
decode: dateTime.zoneMakeOffset,
|
|
@@ -3658,12 +3703,12 @@ export class TimeZoneNamedFromSelf extends /*#__PURE__*/declare(dateTime.isTimeZ
|
|
|
3658
3703
|
* @since 3.10.0
|
|
3659
3704
|
*/
|
|
3660
3705
|
export class TimeZoneNamed extends /*#__PURE__*/transformOrFail(String$.annotations({
|
|
3661
|
-
description: "a string
|
|
3706
|
+
description: "a string to be decoded into a TimeZone.Named"
|
|
3662
3707
|
}), TimeZoneNamedFromSelf, {
|
|
3663
3708
|
strict: true,
|
|
3664
3709
|
decode: (s, _, ast) => ParseResult.try({
|
|
3665
3710
|
try: () => dateTime.zoneUnsafeMakeNamed(s),
|
|
3666
|
-
catch: () => new ParseResult.Type(ast, s)
|
|
3711
|
+
catch: () => new ParseResult.Type(ast, s, `Unable to decode ${JSON.stringify(s)} into a TimeZone.Named`)
|
|
3667
3712
|
}),
|
|
3668
3713
|
encode: tz => ParseResult.succeed(tz.id)
|
|
3669
3714
|
}).annotations({
|
|
@@ -3673,7 +3718,7 @@ export class TimeZoneNamed extends /*#__PURE__*/transformOrFail(String$.annotati
|
|
|
3673
3718
|
* @category TimeZone constructors
|
|
3674
3719
|
* @since 3.10.0
|
|
3675
3720
|
*/
|
|
3676
|
-
export
|
|
3721
|
+
export class TimeZoneFromSelf extends /*#__PURE__*/Union(TimeZoneOffsetFromSelf, TimeZoneNamedFromSelf) {}
|
|
3677
3722
|
/**
|
|
3678
3723
|
* Defines a schema that attempts to convert a `string` to a `TimeZone` using the `DateTime.zoneFromString` constructor.
|
|
3679
3724
|
*
|
|
@@ -3681,11 +3726,11 @@ export const TimeZoneFromSelf = /*#__PURE__*/Union(TimeZoneOffsetFromSelf, TimeZ
|
|
|
3681
3726
|
* @since 3.10.0
|
|
3682
3727
|
*/
|
|
3683
3728
|
export class TimeZone extends /*#__PURE__*/transformOrFail(String$.annotations({
|
|
3684
|
-
description: "a string
|
|
3729
|
+
description: "a string to be decoded into a TimeZone"
|
|
3685
3730
|
}), TimeZoneFromSelf, {
|
|
3686
3731
|
strict: true,
|
|
3687
3732
|
decode: (s, _, ast) => option_.match(dateTime.zoneFromString(s), {
|
|
3688
|
-
onNone: () => ParseResult.fail(new ParseResult.Type(ast, s)),
|
|
3733
|
+
onNone: () => ParseResult.fail(new ParseResult.Type(ast, s, `Unable to decode ${JSON.stringify(s)} into a TimeZone`)),
|
|
3689
3734
|
onSome: ParseResult.succeed
|
|
3690
3735
|
}),
|
|
3691
3736
|
encode: tz => ParseResult.succeed(dateTime.zoneToString(tz))
|
|
@@ -3703,9 +3748,13 @@ export class DateTimeZonedFromSelf extends /*#__PURE__*/declare(u => dateTime.is
|
|
|
3703
3748
|
identifier: "DateTimeZonedFromSelf",
|
|
3704
3749
|
description: "a DateTime.Zoned instance",
|
|
3705
3750
|
pretty: () => dateTime => dateTime.toString(),
|
|
3706
|
-
arbitrary: () => fc => fc.
|
|
3751
|
+
arbitrary: () => fc => fc.tuple(fc.integer({
|
|
3752
|
+
// time zone db supports +/- 1000 years or so
|
|
3753
|
+
min: -31536000000000,
|
|
3754
|
+
max: 31536000000000
|
|
3755
|
+
}), timeZoneArbitrary(fc)).map(([millis, timeZone]) => dateTime.unsafeMakeZoned(millis, {
|
|
3707
3756
|
timeZone
|
|
3708
|
-
}))
|
|
3757
|
+
})),
|
|
3709
3758
|
equivalence: () => dateTime.Equivalence
|
|
3710
3759
|
}) {}
|
|
3711
3760
|
/**
|
|
@@ -3715,11 +3764,11 @@ export class DateTimeZonedFromSelf extends /*#__PURE__*/declare(u => dateTime.is
|
|
|
3715
3764
|
* @since 3.10.0
|
|
3716
3765
|
*/
|
|
3717
3766
|
export class DateTimeZoned extends /*#__PURE__*/transformOrFail(String$.annotations({
|
|
3718
|
-
description: "a string
|
|
3767
|
+
description: "a string to be decoded into a DateTime.Zoned"
|
|
3719
3768
|
}), DateTimeZonedFromSelf, {
|
|
3720
3769
|
strict: true,
|
|
3721
3770
|
decode: (s, _, ast) => option_.match(dateTime.makeZonedFromString(s), {
|
|
3722
|
-
onNone: () => ParseResult.fail(new ParseResult.Type(ast, s)),
|
|
3771
|
+
onNone: () => ParseResult.fail(new ParseResult.Type(ast, s, `Unable to decode ${JSON.stringify(s)} into a DateTime.Zoned`)),
|
|
3723
3772
|
onSome: ParseResult.succeed
|
|
3724
3773
|
}),
|
|
3725
3774
|
encode: dt => ParseResult.succeed(dateTime.formatIsoZoned(dt))
|
|
@@ -4059,7 +4108,7 @@ export const ReadonlyMapFromRecord = ({
|
|
|
4059
4108
|
key: encodedBoundSchema(key),
|
|
4060
4109
|
value
|
|
4061
4110
|
}).annotations({
|
|
4062
|
-
description: "a record
|
|
4111
|
+
description: "a record to be decoded into a ReadonlyMap"
|
|
4063
4112
|
}), ReadonlyMapFromSelf({
|
|
4064
4113
|
key,
|
|
4065
4114
|
value: typeSchema(value)
|
|
@@ -4079,7 +4128,7 @@ export const MapFromRecord = ({
|
|
|
4079
4128
|
key: encodedBoundSchema(key),
|
|
4080
4129
|
value
|
|
4081
4130
|
}).annotations({
|
|
4082
|
-
description: "a record
|
|
4131
|
+
description: "a record to be decoded into a Map"
|
|
4083
4132
|
}), MapFromSelf({
|
|
4084
4133
|
key,
|
|
4085
4134
|
value: typeSchema(value)
|
|
@@ -4163,11 +4212,11 @@ export class BigDecimalFromSelf extends /*#__PURE__*/declare(bigDecimal_.isBigDe
|
|
|
4163
4212
|
* @since 3.10.0
|
|
4164
4213
|
*/
|
|
4165
4214
|
export class BigDecimal extends /*#__PURE__*/transformOrFail(String$.annotations({
|
|
4166
|
-
description: "a string
|
|
4215
|
+
description: "a string to be decoded into a BigDecimal"
|
|
4167
4216
|
}), BigDecimalFromSelf, {
|
|
4168
4217
|
strict: true,
|
|
4169
|
-
decode: (
|
|
4170
|
-
onNone: () => ParseResult.fail(new ParseResult.Type(ast,
|
|
4218
|
+
decode: (s, _, ast) => bigDecimal_.fromString(s).pipe(option_.match({
|
|
4219
|
+
onNone: () => ParseResult.fail(new ParseResult.Type(ast, s, `Unable to decode ${JSON.stringify(s)} into a BigDecimal`)),
|
|
4171
4220
|
onSome: val => ParseResult.succeed(bigDecimal_.normalize(val))
|
|
4172
4221
|
})),
|
|
4173
4222
|
encode: val => ParseResult.succeed(bigDecimal_.format(bigDecimal_.normalize(val)))
|
|
@@ -4181,12 +4230,12 @@ export class BigDecimal extends /*#__PURE__*/transformOrFail(String$.annotations
|
|
|
4181
4230
|
* @category BigDecimal transformations
|
|
4182
4231
|
* @since 3.10.0
|
|
4183
4232
|
*/
|
|
4184
|
-
export class BigDecimalFromNumber extends /*#__PURE__*/
|
|
4185
|
-
description: "a number
|
|
4233
|
+
export class BigDecimalFromNumber extends /*#__PURE__*/transform(Number$.annotations({
|
|
4234
|
+
description: "a number to be decoded into a BigDecimal"
|
|
4186
4235
|
}), BigDecimalFromSelf, {
|
|
4187
4236
|
strict: true,
|
|
4188
|
-
decode:
|
|
4189
|
-
encode:
|
|
4237
|
+
decode: bigDecimal_.unsafeFromNumber,
|
|
4238
|
+
encode: bigDecimal_.unsafeToNumber
|
|
4190
4239
|
}).annotations({
|
|
4191
4240
|
identifier: "BigDecimalFromNumber"
|
|
4192
4241
|
}) {}
|
|
@@ -5695,4 +5744,31 @@ const go = (ast, path) => {
|
|
|
5695
5744
|
}
|
|
5696
5745
|
}
|
|
5697
5746
|
};
|
|
5747
|
+
/** @ignore */
|
|
5748
|
+
class PropertyKey$ extends /*#__PURE__*/Union(String$, Number$, SymbolFromStruct).annotations({
|
|
5749
|
+
identifier: "PropertyKey"
|
|
5750
|
+
}) {}
|
|
5751
|
+
export {
|
|
5752
|
+
/**
|
|
5753
|
+
* @since 3.12.5
|
|
5754
|
+
*/
|
|
5755
|
+
PropertyKey$ as PropertyKey };
|
|
5756
|
+
/**
|
|
5757
|
+
* @category ArrayFormatter
|
|
5758
|
+
* @since 3.12.5
|
|
5759
|
+
*/
|
|
5760
|
+
export class ArrayFormatterIssue extends /*#__PURE__*/Struct({
|
|
5761
|
+
_tag: propertySignature(Literal("Pointer", "Unexpected", "Missing", "Composite", "Refinement", "Transformation", "Type", "Forbidden")).annotations({
|
|
5762
|
+
description: "The tag identifying the type of parse issue"
|
|
5763
|
+
}),
|
|
5764
|
+
path: propertySignature(Array$(PropertyKey$)).annotations({
|
|
5765
|
+
description: "The path to the property where the issue occurred"
|
|
5766
|
+
}),
|
|
5767
|
+
message: propertySignature(String$).annotations({
|
|
5768
|
+
description: "A descriptive message explaining the issue"
|
|
5769
|
+
})
|
|
5770
|
+
}).annotations({
|
|
5771
|
+
identifier: "ArrayFormatterIssue",
|
|
5772
|
+
description: "Represents an issue returned by the ArrayFormatter formatter"
|
|
5773
|
+
}) {}
|
|
5698
5774
|
//# sourceMappingURL=Schema.js.map
|