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/src/Schema.ts
CHANGED
|
@@ -3016,9 +3016,7 @@ export const pluck: {
|
|
|
3016
3016
|
* @category struct transformations
|
|
3017
3017
|
* @since 3.10.0
|
|
3018
3018
|
*/
|
|
3019
|
-
<A, I, K extends keyof A & keyof I>(
|
|
3020
|
-
key: K
|
|
3021
|
-
): <R>(schema: Schema<A, I, R>) => Schema<A[K], { readonly [P in K]: I[P] }, R>
|
|
3019
|
+
<A, I, K extends keyof A & keyof I>(key: K): <R>(schema: Schema<A, I, R>) => Schema<A[K], Simplify<Pick<I, K>>, R>
|
|
3022
3020
|
/**
|
|
3023
3021
|
* Given a schema `Schema<A, I, R>` and a key `key: K`, this function extracts a specific field from the `A` type,
|
|
3024
3022
|
* producing a new schema that represents a transformation from the `{ readonly [key]: I[K] }` type to `A[K]`.
|
|
@@ -3049,7 +3047,7 @@ export const pluck: {
|
|
|
3049
3047
|
* @category struct transformations
|
|
3050
3048
|
* @since 3.10.0
|
|
3051
3049
|
*/
|
|
3052
|
-
<A, I, R, K extends keyof A & keyof I>(schema: Schema<A, I, R>, key: K): Schema<A[K],
|
|
3050
|
+
<A, I, R, K extends keyof A & keyof I>(schema: Schema<A, I, R>, key: K): Schema<A[K], Simplify<Pick<I, K>>, R>
|
|
3053
3051
|
} = dual(
|
|
3054
3052
|
2,
|
|
3055
3053
|
<A, I, R, K extends keyof A & keyof I>(
|
|
@@ -3722,7 +3720,8 @@ export type RefineSchemaId = typeof RefineSchemaId
|
|
|
3722
3720
|
export interface refine<A, From extends Schema.Any>
|
|
3723
3721
|
extends AnnotableClass<refine<A, From>, A, Schema.Encoded<From>, Schema.Context<From>>
|
|
3724
3722
|
{
|
|
3725
|
-
|
|
3723
|
+
/** The following is required for {@link HasFields} to work */
|
|
3724
|
+
readonly [RefineSchemaId]: From
|
|
3726
3725
|
readonly from: From
|
|
3727
3726
|
readonly filter: (
|
|
3728
3727
|
a: Schema.Type<From>,
|
|
@@ -5008,30 +5007,31 @@ export type ParseJsonOptions = {
|
|
|
5008
5007
|
readonly space?: Parameters<typeof JSON.stringify>[2]
|
|
5009
5008
|
}
|
|
5010
5009
|
|
|
5011
|
-
const
|
|
5012
|
-
[AST.IdentifierAnnotationId]: "JsonString",
|
|
5013
|
-
[AST.TitleAnnotationId]: "JsonString",
|
|
5014
|
-
[AST.DescriptionAnnotationId]: "a string that will be parsed as JSON"
|
|
5015
|
-
})
|
|
5010
|
+
const getErrorMessage = (e: unknown): string => e instanceof Error ? e.message : String(e)
|
|
5016
5011
|
|
|
5017
5012
|
const getParseJsonTransformation = (options?: ParseJsonOptions) =>
|
|
5018
5013
|
transformOrFail(
|
|
5019
|
-
|
|
5014
|
+
String$.annotations({
|
|
5015
|
+
[AST.DescriptionAnnotationId]: "a string to be decoded into JSON"
|
|
5016
|
+
}),
|
|
5020
5017
|
Unknown,
|
|
5021
5018
|
{
|
|
5022
5019
|
strict: true,
|
|
5023
5020
|
decode: (s, _, ast) =>
|
|
5024
5021
|
ParseResult.try({
|
|
5025
5022
|
try: () => JSON.parse(s, options?.reviver),
|
|
5026
|
-
catch: (e
|
|
5023
|
+
catch: (e) => new ParseResult.Type(ast, s, getErrorMessage(e))
|
|
5027
5024
|
}),
|
|
5028
5025
|
encode: (u, _, ast) =>
|
|
5029
5026
|
ParseResult.try({
|
|
5030
5027
|
try: () => JSON.stringify(u, options?.replacer, options?.space),
|
|
5031
|
-
catch: (e
|
|
5028
|
+
catch: (e) => new ParseResult.Type(ast, u, getErrorMessage(e))
|
|
5032
5029
|
})
|
|
5033
5030
|
}
|
|
5034
|
-
).annotations({
|
|
5031
|
+
).annotations({
|
|
5032
|
+
title: "parseJson",
|
|
5033
|
+
schemaId: AST.ParseJsonSchemaId
|
|
5034
|
+
})
|
|
5035
5035
|
|
|
5036
5036
|
/**
|
|
5037
5037
|
* The `ParseJson` combinator provides a method to convert JSON strings into the `unknown` type using the underlying
|
|
@@ -5175,14 +5175,19 @@ export class URLFromSelf extends instanceOf(URL, {
|
|
|
5175
5175
|
|
|
5176
5176
|
/** @ignore */
|
|
5177
5177
|
class URL$ extends transformOrFail(
|
|
5178
|
-
String$.annotations({ description: "a string
|
|
5178
|
+
String$.annotations({ description: "a string to be decoded into a URL" }),
|
|
5179
5179
|
URLFromSelf,
|
|
5180
5180
|
{
|
|
5181
5181
|
strict: true,
|
|
5182
|
-
decode: (
|
|
5182
|
+
decode: (s, _, ast) =>
|
|
5183
5183
|
ParseResult.try({
|
|
5184
|
-
try: () => new URL(
|
|
5185
|
-
catch: () =>
|
|
5184
|
+
try: () => new URL(s),
|
|
5185
|
+
catch: (e) =>
|
|
5186
|
+
new ParseResult.Type(
|
|
5187
|
+
ast,
|
|
5188
|
+
s,
|
|
5189
|
+
`Unable to decode ${JSON.stringify(s)} into a URL. ${getErrorMessage(e)}`
|
|
5190
|
+
)
|
|
5186
5191
|
}),
|
|
5187
5192
|
encode: (url) => ParseResult.succeed(url.toString())
|
|
5188
5193
|
}
|
|
@@ -5547,8 +5552,11 @@ export const parseNumber = <A extends string, I, R>(
|
|
|
5547
5552
|
Number$,
|
|
5548
5553
|
{
|
|
5549
5554
|
strict: false,
|
|
5550
|
-
decode: (s, _, ast) =>
|
|
5551
|
-
|
|
5555
|
+
decode: (s, _, ast) =>
|
|
5556
|
+
ParseResult.fromOption(number_.parse(s), () =>
|
|
5557
|
+
new ParseResult.Type(ast, s, `Unable to decode ${JSON.stringify(s)} into a number`)),
|
|
5558
|
+
encode: (n) =>
|
|
5559
|
+
ParseResult.succeed(String(n))
|
|
5552
5560
|
}
|
|
5553
5561
|
)
|
|
5554
5562
|
|
|
@@ -5563,7 +5571,7 @@ export const parseNumber = <A extends string, I, R>(
|
|
|
5563
5571
|
* @since 3.10.0
|
|
5564
5572
|
*/
|
|
5565
5573
|
export class NumberFromString extends parseNumber(String$.annotations({
|
|
5566
|
-
description: "a string
|
|
5574
|
+
description: "a string to be decoded into a number"
|
|
5567
5575
|
})).annotations({ identifier: "NumberFromString" }) {}
|
|
5568
5576
|
|
|
5569
5577
|
/**
|
|
@@ -5665,16 +5673,31 @@ export class Not extends transform(Boolean$.annotations({ description: "a boolea
|
|
|
5665
5673
|
encode: boolean_.not
|
|
5666
5674
|
}) {}
|
|
5667
5675
|
|
|
5676
|
+
const encodeSymbol = (sym: symbol, _: AST.ParseOptions, ast: AST.AST) => {
|
|
5677
|
+
const key = Symbol.keyFor(sym)
|
|
5678
|
+
return key === undefined
|
|
5679
|
+
? ParseResult.fail(
|
|
5680
|
+
new ParseResult.Type(ast, sym, `Unable to encode a unique symbol ${String(sym)} into a string`)
|
|
5681
|
+
)
|
|
5682
|
+
: ParseResult.succeed(key)
|
|
5683
|
+
}
|
|
5684
|
+
|
|
5685
|
+
const decodeSymbol = (s: string) => ParseResult.succeed(Symbol.for(s))
|
|
5686
|
+
|
|
5668
5687
|
/** @ignore */
|
|
5669
|
-
class Symbol$ extends
|
|
5670
|
-
String$.annotations({ description: "a string
|
|
5688
|
+
class Symbol$ extends transformOrFail(
|
|
5689
|
+
String$.annotations({ description: "a string to be decoded into a globally shared symbol" }),
|
|
5671
5690
|
SymbolFromSelf,
|
|
5672
|
-
{
|
|
5673
|
-
|
|
5691
|
+
{
|
|
5692
|
+
strict: false,
|
|
5693
|
+
decode: decodeSymbol,
|
|
5694
|
+
encode: encodeSymbol
|
|
5695
|
+
}
|
|
5696
|
+
).annotations({ identifier: "Symbol" }) {}
|
|
5674
5697
|
|
|
5675
5698
|
export {
|
|
5676
5699
|
/**
|
|
5677
|
-
*
|
|
5700
|
+
* Converts a string key into a globally shared symbol.
|
|
5678
5701
|
*
|
|
5679
5702
|
* @category symbol transformations
|
|
5680
5703
|
* @since 3.10.0
|
|
@@ -5682,6 +5705,20 @@ export {
|
|
|
5682
5705
|
Symbol$ as Symbol
|
|
5683
5706
|
}
|
|
5684
5707
|
|
|
5708
|
+
const SymbolStruct = TaggedStruct("symbol", {
|
|
5709
|
+
key: String$
|
|
5710
|
+
}).annotations({ description: "an object to be decoded into a globally shared symbol" })
|
|
5711
|
+
|
|
5712
|
+
const SymbolFromStruct = transformOrFail(
|
|
5713
|
+
SymbolStruct,
|
|
5714
|
+
SymbolFromSelf,
|
|
5715
|
+
{
|
|
5716
|
+
strict: true,
|
|
5717
|
+
decode: ({ key }) => decodeSymbol(key),
|
|
5718
|
+
encode: (sym, _, ast) => ParseResult.map(encodeSymbol(sym, _, ast), (key) => SymbolStruct.make({ key }))
|
|
5719
|
+
}
|
|
5720
|
+
)
|
|
5721
|
+
|
|
5685
5722
|
/**
|
|
5686
5723
|
* @category schema id
|
|
5687
5724
|
* @since 3.10.0
|
|
@@ -5893,14 +5930,18 @@ export const clampBigInt =
|
|
|
5893
5930
|
|
|
5894
5931
|
/** @ignore */
|
|
5895
5932
|
class BigInt$ extends transformOrFail(
|
|
5896
|
-
String$.annotations({ description: "a string
|
|
5933
|
+
String$.annotations({ description: "a string to be decoded into a bigint" }),
|
|
5897
5934
|
BigIntFromSelf,
|
|
5898
5935
|
{
|
|
5899
5936
|
strict: true,
|
|
5900
|
-
decode: (s, _, ast) =>
|
|
5937
|
+
decode: (s, _, ast) =>
|
|
5938
|
+
ParseResult.fromOption(
|
|
5939
|
+
bigInt_.fromString(s),
|
|
5940
|
+
() => new ParseResult.Type(ast, s, `Unable to decode ${JSON.stringify(s)} into a bigint`)
|
|
5941
|
+
),
|
|
5901
5942
|
encode: (n) => ParseResult.succeed(String(n))
|
|
5902
5943
|
}
|
|
5903
|
-
).annotations({ identifier: "
|
|
5944
|
+
).annotations({ identifier: "BigInt" }) {}
|
|
5904
5945
|
|
|
5905
5946
|
export {
|
|
5906
5947
|
/**
|
|
@@ -5987,18 +6028,22 @@ export const NonNegativeBigInt: filter<Schema<bigint, string>> = BigInt$.pipe(
|
|
|
5987
6028
|
* @since 3.10.0
|
|
5988
6029
|
*/
|
|
5989
6030
|
export class BigIntFromNumber extends transformOrFail(
|
|
5990
|
-
Number$.annotations({ description: "a number
|
|
5991
|
-
BigIntFromSelf,
|
|
6031
|
+
Number$.annotations({ description: "a number to be decoded into a bigint" }),
|
|
6032
|
+
BigIntFromSelf.pipe(betweenBigInt(BigInt(Number.MIN_SAFE_INTEGER), BigInt(Number.MAX_SAFE_INTEGER))),
|
|
5992
6033
|
{
|
|
5993
6034
|
strict: true,
|
|
5994
6035
|
decode: (n, _, ast) =>
|
|
5995
6036
|
ParseResult.fromOption(
|
|
5996
6037
|
bigInt_.fromNumber(n),
|
|
5997
|
-
() => new ParseResult.Type(ast, n)
|
|
6038
|
+
() => new ParseResult.Type(ast, n, `Unable to decode ${n} into a bigint`)
|
|
5998
6039
|
),
|
|
5999
|
-
encode: (b, _, ast) =>
|
|
6040
|
+
encode: (b, _, ast) =>
|
|
6041
|
+
ParseResult.fromOption(
|
|
6042
|
+
bigInt_.toNumber(b),
|
|
6043
|
+
() => new ParseResult.Type(ast, b, `Unable to encode ${b}n into a number`)
|
|
6044
|
+
)
|
|
6000
6045
|
}
|
|
6001
|
-
).annotations({ identifier: "
|
|
6046
|
+
).annotations({ identifier: "BigIntFromNumber" }) {}
|
|
6002
6047
|
|
|
6003
6048
|
const redactedArbitrary = <A>(value: LazyArbitrary<A>): LazyArbitrary<redacted_.Redacted<A>> => (fc) =>
|
|
6004
6049
|
value(fc).map(redacted_.make)
|
|
@@ -6101,77 +6146,90 @@ export class DurationFromSelf extends declare(
|
|
|
6101
6146
|
arbitrary: (): LazyArbitrary<duration_.Duration> => (fc) =>
|
|
6102
6147
|
fc.oneof(
|
|
6103
6148
|
fc.constant(duration_.infinity),
|
|
6104
|
-
fc.
|
|
6105
|
-
fc.
|
|
6106
|
-
fc.maxSafeNat().map((_) => duration_.millis(_)),
|
|
6107
|
-
fc.maxSafeNat().map((_) => duration_.seconds(_)),
|
|
6108
|
-
fc.maxSafeNat().map((_) => duration_.minutes(_)),
|
|
6109
|
-
fc.maxSafeNat().map((_) => duration_.hours(_)),
|
|
6110
|
-
fc.maxSafeNat().map((_) => duration_.days(_)),
|
|
6111
|
-
fc.maxSafeNat().map((_) => duration_.weeks(_))
|
|
6149
|
+
fc.bigInt({ min: 0n }).map((_) => duration_.nanos(_)),
|
|
6150
|
+
fc.maxSafeNat().map((_) => duration_.millis(_))
|
|
6112
6151
|
),
|
|
6113
6152
|
equivalence: (): Equivalence.Equivalence<duration_.Duration> => duration_.Equivalence
|
|
6114
6153
|
}
|
|
6115
6154
|
) {}
|
|
6116
6155
|
|
|
6117
6156
|
/**
|
|
6118
|
-
* A schema that transforms a `bigint`
|
|
6119
|
-
*
|
|
6157
|
+
* A schema that transforms a non negative `bigint` into a `Duration`. Treats
|
|
6158
|
+
* the value as the number of nanoseconds.
|
|
6120
6159
|
*
|
|
6121
6160
|
* @category Duration transformations
|
|
6122
6161
|
* @since 3.10.0
|
|
6123
6162
|
*/
|
|
6124
6163
|
export class DurationFromNanos extends transformOrFail(
|
|
6125
|
-
|
|
6126
|
-
DurationFromSelf,
|
|
6164
|
+
NonNegativeBigIntFromSelf.annotations({ description: "a bigint to be decoded into a Duration" }),
|
|
6165
|
+
DurationFromSelf.pipe(filter((duration) => duration_.isFinite(duration), { description: "a finite duration" })),
|
|
6127
6166
|
{
|
|
6128
6167
|
strict: true,
|
|
6129
6168
|
decode: (nanos) => ParseResult.succeed(duration_.nanos(nanos)),
|
|
6130
6169
|
encode: (duration, _, ast) =>
|
|
6131
6170
|
option_.match(duration_.toNanos(duration), {
|
|
6132
|
-
onNone: () =>
|
|
6133
|
-
|
|
6171
|
+
onNone: () =>
|
|
6172
|
+
ParseResult.fail(new ParseResult.Type(ast, duration, `Unable to encode ${duration} into a bigint`)),
|
|
6173
|
+
onSome: (nanos) => ParseResult.succeed(nanos)
|
|
6134
6174
|
})
|
|
6135
6175
|
}
|
|
6136
6176
|
).annotations({ identifier: "DurationFromNanos" }) {}
|
|
6137
6177
|
|
|
6138
6178
|
/**
|
|
6139
|
-
* A
|
|
6140
|
-
*
|
|
6179
|
+
* A non-negative integer. +Infinity is excluded.
|
|
6180
|
+
*
|
|
6181
|
+
* @category number constructors
|
|
6182
|
+
* @since 3.11.10
|
|
6183
|
+
*/
|
|
6184
|
+
export const NonNegativeInt = NonNegative.pipe(int()).annotations({ identifier: "NonNegativeInt" })
|
|
6185
|
+
|
|
6186
|
+
/**
|
|
6187
|
+
* A schema that transforms a (possibly Infinite) non negative number into a
|
|
6188
|
+
* `Duration`. Treats the value as the number of milliseconds.
|
|
6141
6189
|
*
|
|
6142
6190
|
* @category Duration transformations
|
|
6143
6191
|
* @since 3.10.0
|
|
6144
6192
|
*/
|
|
6145
6193
|
export class DurationFromMillis extends transform(
|
|
6146
|
-
|
|
6194
|
+
NonNegative.annotations({
|
|
6195
|
+
description: "a non-negative number to be decoded into a Duration"
|
|
6196
|
+
}),
|
|
6147
6197
|
DurationFromSelf,
|
|
6148
|
-
{
|
|
6198
|
+
{
|
|
6199
|
+
strict: true,
|
|
6200
|
+
decode: (ms) => duration_.millis(ms),
|
|
6201
|
+
encode: (duration) => duration_.toMillis(duration)
|
|
6202
|
+
}
|
|
6149
6203
|
).annotations({ identifier: "DurationFromMillis" }) {}
|
|
6150
6204
|
|
|
6151
|
-
|
|
6152
|
-
* @category number constructors
|
|
6153
|
-
* @since 3.11.10
|
|
6154
|
-
*/
|
|
6155
|
-
export const NonNegativeInt = NonNegative.pipe(int()).annotations({ identifier: "NonNegativeInt" })
|
|
6156
|
-
|
|
6157
|
-
const HRTime: Schema<readonly [seconds: number, nanos: number]> = Tuple(
|
|
6205
|
+
const FiniteHRTime = Tuple(
|
|
6158
6206
|
element(NonNegativeInt).annotations({ title: "seconds" }),
|
|
6159
6207
|
element(NonNegativeInt).annotations({ title: "nanos" })
|
|
6160
|
-
).annotations({ identifier: "
|
|
6208
|
+
).annotations({ identifier: "FiniteHRTime" })
|
|
6209
|
+
|
|
6210
|
+
const InfiniteHRTime = Tuple(Literal(-1), Literal(0)).annotations({ identifier: "InfiniteHRTime" })
|
|
6211
|
+
|
|
6212
|
+
const HRTime: Schema<readonly [seconds: number, nanos: number]> = Union(FiniteHRTime, InfiniteHRTime).annotations({
|
|
6213
|
+
identifier: "HRTime",
|
|
6214
|
+
description: "a tuple of seconds and nanos to be decoded into a Duration"
|
|
6215
|
+
})
|
|
6161
6216
|
|
|
6162
6217
|
/**
|
|
6163
6218
|
* A schema that transforms a `[number, number]` tuple into a `Duration`.
|
|
6164
6219
|
*
|
|
6220
|
+
* Infinite durations are encoded as `[-1, 0]`.
|
|
6221
|
+
*
|
|
6165
6222
|
* @category Duration transformations
|
|
6166
6223
|
* @since 3.10.0
|
|
6167
6224
|
*/
|
|
6168
6225
|
export class Duration extends transform(
|
|
6169
|
-
HRTime
|
|
6226
|
+
HRTime,
|
|
6170
6227
|
DurationFromSelf,
|
|
6171
6228
|
{
|
|
6172
6229
|
strict: true,
|
|
6173
|
-
decode: ([seconds, nanos]) =>
|
|
6174
|
-
|
|
6230
|
+
decode: ([seconds, nanos]) =>
|
|
6231
|
+
seconds === -1 ? duration_.infinity : duration_.nanos(BigInt(seconds) * BigInt(1e9) + BigInt(nanos)),
|
|
6232
|
+
encode: (duration) => duration.value._tag === "Infinity" ? [-1, 0] as const : duration_.toHrTime(duration)
|
|
6175
6233
|
}
|
|
6176
6234
|
).annotations({ identifier: "Duration" }) {}
|
|
6177
6235
|
|
|
@@ -6347,7 +6405,7 @@ export const Uint8 = Number$.pipe(
|
|
|
6347
6405
|
|
|
6348
6406
|
const Uint8Array$: Schema<Uint8Array, ReadonlyArray<number>> = transform(
|
|
6349
6407
|
Array$(Uint8).annotations({
|
|
6350
|
-
description: "an array of 8-bit unsigned integers
|
|
6408
|
+
description: "an array of 8-bit unsigned integers to be decoded into a Uint8Array"
|
|
6351
6409
|
}),
|
|
6352
6410
|
Uint8ArrayFromSelf,
|
|
6353
6411
|
{ strict: true, decode: (numbers) => Uint8Array.from(numbers), encode: (uint8Array) => Array.from(uint8Array) }
|
|
@@ -6369,7 +6427,7 @@ const makeUint8ArrayTransformation = (
|
|
|
6369
6427
|
encode: (u: Uint8Array) => string
|
|
6370
6428
|
) =>
|
|
6371
6429
|
transformOrFail(
|
|
6372
|
-
String$.annotations({ description: "a string
|
|
6430
|
+
String$.annotations({ description: "a string to be decoded into a Uint8Array" }),
|
|
6373
6431
|
Uint8ArrayFromSelf,
|
|
6374
6432
|
{
|
|
6375
6433
|
strict: true,
|
|
@@ -6533,11 +6591,11 @@ export type MinItemsSchemaId = typeof MinItemsSchemaId
|
|
|
6533
6591
|
* @category ReadonlyArray filters
|
|
6534
6592
|
* @since 3.10.0
|
|
6535
6593
|
*/
|
|
6536
|
-
export const minItems = <A
|
|
6594
|
+
export const minItems = <A extends ReadonlyArray<any>>(
|
|
6537
6595
|
n: number,
|
|
6538
|
-
annotations?: Annotations.Filter<
|
|
6596
|
+
annotations?: Annotations.Filter<A>
|
|
6539
6597
|
) =>
|
|
6540
|
-
<I, R>(self: Schema<
|
|
6598
|
+
<I, R>(self: Schema<A, I, R>): filter<Schema<A, I, R>> => {
|
|
6541
6599
|
const minItems = Math.floor(n)
|
|
6542
6600
|
if (minItems < 1) {
|
|
6543
6601
|
throw new Error(
|
|
@@ -6575,21 +6633,28 @@ export type MaxItemsSchemaId = typeof MaxItemsSchemaId
|
|
|
6575
6633
|
* @category ReadonlyArray filters
|
|
6576
6634
|
* @since 3.10.0
|
|
6577
6635
|
*/
|
|
6578
|
-
export const maxItems = <A
|
|
6636
|
+
export const maxItems = <A extends ReadonlyArray<any>>(
|
|
6579
6637
|
n: number,
|
|
6580
|
-
annotations?: Annotations.Filter<
|
|
6638
|
+
annotations?: Annotations.Filter<A>
|
|
6581
6639
|
) =>
|
|
6582
|
-
<I, R>(self: Schema<
|
|
6583
|
-
|
|
6584
|
-
|
|
6640
|
+
<I, R>(self: Schema<A, I, R>): filter<Schema<A, I, R>> => {
|
|
6641
|
+
const maxItems = Math.floor(n)
|
|
6642
|
+
if (maxItems < 1) {
|
|
6643
|
+
throw new Error(
|
|
6644
|
+
errors_.getInvalidArgumentErrorMessage(`Expected an integer greater than or equal to 1, actual ${n}`)
|
|
6645
|
+
)
|
|
6646
|
+
}
|
|
6647
|
+
return self.pipe(
|
|
6648
|
+
filter((a) => a.length <= maxItems, {
|
|
6585
6649
|
schemaId: MaxItemsSchemaId,
|
|
6586
|
-
title: `maxItems(${
|
|
6587
|
-
description: `an array of at most ${
|
|
6588
|
-
jsonSchema: { maxItems
|
|
6650
|
+
title: `maxItems(${maxItems})`,
|
|
6651
|
+
description: `an array of at most ${maxItems} item(s)`,
|
|
6652
|
+
jsonSchema: { maxItems },
|
|
6589
6653
|
[AST.StableFilterAnnotationId]: true,
|
|
6590
6654
|
...annotations
|
|
6591
6655
|
})
|
|
6592
6656
|
)
|
|
6657
|
+
}
|
|
6593
6658
|
|
|
6594
6659
|
/**
|
|
6595
6660
|
* @category schema id
|
|
@@ -6607,21 +6672,28 @@ export type ItemsCountSchemaId = typeof ItemsCountSchemaId
|
|
|
6607
6672
|
* @category ReadonlyArray filters
|
|
6608
6673
|
* @since 3.10.0
|
|
6609
6674
|
*/
|
|
6610
|
-
export const itemsCount = <A
|
|
6675
|
+
export const itemsCount = <A extends ReadonlyArray<any>>(
|
|
6611
6676
|
n: number,
|
|
6612
|
-
annotations?: Annotations.Filter<
|
|
6677
|
+
annotations?: Annotations.Filter<A>
|
|
6613
6678
|
) =>
|
|
6614
|
-
<I, R>(self: Schema<
|
|
6615
|
-
|
|
6616
|
-
|
|
6679
|
+
<I, R>(self: Schema<A, I, R>): filter<Schema<A, I, R>> => {
|
|
6680
|
+
const itemsCount = Math.floor(n)
|
|
6681
|
+
if (itemsCount < 1) {
|
|
6682
|
+
throw new Error(
|
|
6683
|
+
errors_.getInvalidArgumentErrorMessage(`Expected an integer greater than or equal to 1, actual ${n}`)
|
|
6684
|
+
)
|
|
6685
|
+
}
|
|
6686
|
+
return self.pipe(
|
|
6687
|
+
filter((a) => a.length === itemsCount, {
|
|
6617
6688
|
schemaId: ItemsCountSchemaId,
|
|
6618
|
-
title: `itemsCount(${
|
|
6619
|
-
description: `an array of exactly ${
|
|
6620
|
-
jsonSchema: { minItems:
|
|
6689
|
+
title: `itemsCount(${itemsCount})`,
|
|
6690
|
+
description: `an array of exactly ${itemsCount} item(s)`,
|
|
6691
|
+
jsonSchema: { minItems: itemsCount, maxItems: itemsCount },
|
|
6621
6692
|
[AST.StableFilterAnnotationId]: true,
|
|
6622
6693
|
...annotations
|
|
6623
6694
|
})
|
|
6624
6695
|
)
|
|
6696
|
+
}
|
|
6625
6697
|
|
|
6626
6698
|
/**
|
|
6627
6699
|
* @category ReadonlyArray transformations
|
|
@@ -6697,7 +6769,7 @@ export const headOrElse: {
|
|
|
6697
6769
|
? ParseResult.succeed(as[0])
|
|
6698
6770
|
: fallback
|
|
6699
6771
|
? ParseResult.succeed(fallback())
|
|
6700
|
-
: ParseResult.fail(new ParseResult.Type(ast, as)),
|
|
6772
|
+
: ParseResult.fail(new ParseResult.Type(ast, as, "Unable to retrieve the first element of an empty array")),
|
|
6701
6773
|
encode: (a) => ParseResult.succeed(array_.of(a))
|
|
6702
6774
|
}
|
|
6703
6775
|
)
|
|
@@ -6919,7 +6991,7 @@ export class ValidDateFromSelf extends DateFromSelf.pipe(
|
|
|
6919
6991
|
* @since 3.10.0
|
|
6920
6992
|
*/
|
|
6921
6993
|
export class DateFromString extends transform(
|
|
6922
|
-
String$.annotations({ description: "a string
|
|
6994
|
+
String$.annotations({ description: "a string to be decoded into a Date" }),
|
|
6923
6995
|
DateFromSelf,
|
|
6924
6996
|
{ strict: true, decode: (s) => new Date(s), encode: (d) => util_.formatDate(d) }
|
|
6925
6997
|
).annotations({ identifier: "DateFromString" }) {}
|
|
@@ -6953,7 +7025,7 @@ export {
|
|
|
6953
7025
|
* @since 3.10.0
|
|
6954
7026
|
*/
|
|
6955
7027
|
export class DateFromNumber extends transform(
|
|
6956
|
-
Number$.annotations({ description: "a number
|
|
7028
|
+
Number$.annotations({ description: "a number to be decoded into a Date" }),
|
|
6957
7029
|
DateFromSelf,
|
|
6958
7030
|
{ strict: true, decode: (n) => new Date(n), encode: (d) => d.getTime() }
|
|
6959
7031
|
).annotations({ identifier: "DateFromNumber" }) {}
|
|
@@ -6970,15 +7042,16 @@ export class DateTimeUtcFromSelf extends declare(
|
|
|
6970
7042
|
identifier: "DateTimeUtcFromSelf",
|
|
6971
7043
|
description: "a DateTime.Utc instance",
|
|
6972
7044
|
pretty: (): pretty_.Pretty<dateTime.Utc> => (dateTime) => dateTime.toString(),
|
|
6973
|
-
arbitrary: (): LazyArbitrary<dateTime.Utc> => (fc) =>
|
|
7045
|
+
arbitrary: (): LazyArbitrary<dateTime.Utc> => (fc) =>
|
|
7046
|
+
fc.date({ noInvalidDate: true }).map((date) => dateTime.unsafeFromDate(date)),
|
|
6974
7047
|
equivalence: () => dateTime.Equivalence
|
|
6975
7048
|
}
|
|
6976
7049
|
) {}
|
|
6977
7050
|
|
|
6978
|
-
const
|
|
7051
|
+
const decodeDateTimeUtc = <A extends dateTime.DateTime.Input>(input: A, _: ParseOptions, ast: AST.AST) =>
|
|
6979
7052
|
ParseResult.try({
|
|
6980
7053
|
try: () => dateTime.unsafeMake(input),
|
|
6981
|
-
catch: () => new ParseResult.Type(ast, input)
|
|
7054
|
+
catch: () => new ParseResult.Type(ast, input, `Unable to decode ${util_.formatUnknown(input)} into a DateTime.Utc`)
|
|
6982
7055
|
})
|
|
6983
7056
|
|
|
6984
7057
|
/**
|
|
@@ -6988,11 +7061,11 @@ const decodeDateTime = <A extends dateTime.DateTime.Input>(input: A, _: ParseOpt
|
|
|
6988
7061
|
* @since 3.10.0
|
|
6989
7062
|
*/
|
|
6990
7063
|
export class DateTimeUtcFromNumber extends transformOrFail(
|
|
6991
|
-
Number$.annotations({ description: "a number
|
|
7064
|
+
Number$.annotations({ description: "a number to be decoded into a DateTime.Utc" }),
|
|
6992
7065
|
DateTimeUtcFromSelf,
|
|
6993
7066
|
{
|
|
6994
7067
|
strict: true,
|
|
6995
|
-
decode:
|
|
7068
|
+
decode: decodeDateTimeUtc,
|
|
6996
7069
|
encode: (dt) => ParseResult.succeed(dateTime.toEpochMillis(dt))
|
|
6997
7070
|
}
|
|
6998
7071
|
).annotations({ identifier: "DateTimeUtcFromNumber" }) {}
|
|
@@ -7004,11 +7077,11 @@ export class DateTimeUtcFromNumber extends transformOrFail(
|
|
|
7004
7077
|
* @since 3.12.0
|
|
7005
7078
|
*/
|
|
7006
7079
|
export class DateTimeUtcFromDate extends transformOrFail(
|
|
7007
|
-
DateFromSelf.annotations({ description: "a Date
|
|
7080
|
+
DateFromSelf.annotations({ description: "a Date to be decoded into a DateTime.Utc" }),
|
|
7008
7081
|
DateTimeUtcFromSelf,
|
|
7009
7082
|
{
|
|
7010
7083
|
strict: true,
|
|
7011
|
-
decode:
|
|
7084
|
+
decode: decodeDateTimeUtc,
|
|
7012
7085
|
encode: (dt) => ParseResult.succeed(dateTime.toDateUtc(dt))
|
|
7013
7086
|
}
|
|
7014
7087
|
).annotations({ identifier: "DateTimeUtcFromDate" }) {}
|
|
@@ -7020,17 +7093,17 @@ export class DateTimeUtcFromDate extends transformOrFail(
|
|
|
7020
7093
|
* @since 3.10.0
|
|
7021
7094
|
*/
|
|
7022
7095
|
export class DateTimeUtc extends transformOrFail(
|
|
7023
|
-
String$.annotations({ description: "a string
|
|
7096
|
+
String$.annotations({ description: "a string to be decoded into a DateTime.Utc" }),
|
|
7024
7097
|
DateTimeUtcFromSelf,
|
|
7025
7098
|
{
|
|
7026
7099
|
strict: true,
|
|
7027
|
-
decode:
|
|
7100
|
+
decode: decodeDateTimeUtc,
|
|
7028
7101
|
encode: (dt) => ParseResult.succeed(dateTime.formatIso(dt))
|
|
7029
7102
|
}
|
|
7030
7103
|
).annotations({ identifier: "DateTimeUtc" }) {}
|
|
7031
7104
|
|
|
7032
7105
|
const timeZoneOffsetArbitrary = (): LazyArbitrary<dateTime.TimeZone.Offset> => (fc) =>
|
|
7033
|
-
fc.integer({ min: -12 * 60 * 60 * 1000, max:
|
|
7106
|
+
fc.integer({ min: -12 * 60 * 60 * 1000, max: 14 * 60 * 60 * 1000 }).map(dateTime.zoneMakeOffset)
|
|
7034
7107
|
|
|
7035
7108
|
/**
|
|
7036
7109
|
* Describes a schema that represents a `TimeZone.Offset` instance.
|
|
@@ -7055,7 +7128,7 @@ export class TimeZoneOffsetFromSelf extends declare(
|
|
|
7055
7128
|
* @since 3.10.0
|
|
7056
7129
|
*/
|
|
7057
7130
|
export class TimeZoneOffset extends transform(
|
|
7058
|
-
Number$.annotations({ description: "a number
|
|
7131
|
+
Number$.annotations({ description: "a number to be decoded into a TimeZone.Offset" }),
|
|
7059
7132
|
TimeZoneOffsetFromSelf,
|
|
7060
7133
|
{ strict: true, decode: dateTime.zoneMakeOffset, encode: (tz) => tz.offset }
|
|
7061
7134
|
).annotations({ identifier: "TimeZoneOffset" }) {}
|
|
@@ -7086,32 +7159,24 @@ export class TimeZoneNamedFromSelf extends declare(
|
|
|
7086
7159
|
* @since 3.10.0
|
|
7087
7160
|
*/
|
|
7088
7161
|
export class TimeZoneNamed extends transformOrFail(
|
|
7089
|
-
String$.annotations({ description: "a string
|
|
7162
|
+
String$.annotations({ description: "a string to be decoded into a TimeZone.Named" }),
|
|
7090
7163
|
TimeZoneNamedFromSelf,
|
|
7091
7164
|
{
|
|
7092
7165
|
strict: true,
|
|
7093
7166
|
decode: (s, _, ast) =>
|
|
7094
7167
|
ParseResult.try({
|
|
7095
7168
|
try: () => dateTime.zoneUnsafeMakeNamed(s),
|
|
7096
|
-
catch: () => new ParseResult.Type(ast, s)
|
|
7169
|
+
catch: () => new ParseResult.Type(ast, s, `Unable to decode ${JSON.stringify(s)} into a TimeZone.Named`)
|
|
7097
7170
|
}),
|
|
7098
7171
|
encode: (tz) => ParseResult.succeed(tz.id)
|
|
7099
7172
|
}
|
|
7100
7173
|
).annotations({ identifier: "TimeZoneNamed" }) {}
|
|
7101
7174
|
|
|
7102
|
-
/**
|
|
7103
|
-
* @category api interface
|
|
7104
|
-
* @since 3.10.0
|
|
7105
|
-
*/
|
|
7106
|
-
export interface TimeZoneFromSelf extends Union<[typeof TimeZoneOffsetFromSelf, typeof TimeZoneNamedFromSelf]> {
|
|
7107
|
-
annotations(annotations: Annotations.Schema<dateTime.TimeZone>): TimeZoneFromSelf
|
|
7108
|
-
}
|
|
7109
|
-
|
|
7110
7175
|
/**
|
|
7111
7176
|
* @category TimeZone constructors
|
|
7112
7177
|
* @since 3.10.0
|
|
7113
7178
|
*/
|
|
7114
|
-
export
|
|
7179
|
+
export class TimeZoneFromSelf extends Union(TimeZoneOffsetFromSelf, TimeZoneNamedFromSelf) {}
|
|
7115
7180
|
|
|
7116
7181
|
/**
|
|
7117
7182
|
* Defines a schema that attempts to convert a `string` to a `TimeZone` using the `DateTime.zoneFromString` constructor.
|
|
@@ -7120,13 +7185,14 @@ export const TimeZoneFromSelf: TimeZoneFromSelf = Union(TimeZoneOffsetFromSelf,
|
|
|
7120
7185
|
* @since 3.10.0
|
|
7121
7186
|
*/
|
|
7122
7187
|
export class TimeZone extends transformOrFail(
|
|
7123
|
-
String$.annotations({ description: "a string
|
|
7188
|
+
String$.annotations({ description: "a string to be decoded into a TimeZone" }),
|
|
7124
7189
|
TimeZoneFromSelf,
|
|
7125
7190
|
{
|
|
7126
7191
|
strict: true,
|
|
7127
7192
|
decode: (s, _, ast) =>
|
|
7128
7193
|
option_.match(dateTime.zoneFromString(s), {
|
|
7129
|
-
onNone: () =>
|
|
7194
|
+
onNone: () =>
|
|
7195
|
+
ParseResult.fail(new ParseResult.Type(ast, s, `Unable to decode ${JSON.stringify(s)} into a TimeZone`)),
|
|
7130
7196
|
onSome: ParseResult.succeed
|
|
7131
7197
|
}),
|
|
7132
7198
|
encode: (tz) => ParseResult.succeed(dateTime.zoneToString(tz))
|
|
@@ -7152,7 +7218,14 @@ export class DateTimeZonedFromSelf extends declare(
|
|
|
7152
7218
|
description: "a DateTime.Zoned instance",
|
|
7153
7219
|
pretty: (): pretty_.Pretty<dateTime.Zoned> => (dateTime) => dateTime.toString(),
|
|
7154
7220
|
arbitrary: (): LazyArbitrary<dateTime.Zoned> => (fc) =>
|
|
7155
|
-
fc.
|
|
7221
|
+
fc.tuple(
|
|
7222
|
+
fc.integer({
|
|
7223
|
+
// time zone db supports +/- 1000 years or so
|
|
7224
|
+
min: -31536000000000,
|
|
7225
|
+
max: 31536000000000
|
|
7226
|
+
}),
|
|
7227
|
+
timeZoneArbitrary(fc)
|
|
7228
|
+
).map(([millis, timeZone]) => dateTime.unsafeMakeZoned(millis, { timeZone })),
|
|
7156
7229
|
equivalence: () => dateTime.Equivalence
|
|
7157
7230
|
}
|
|
7158
7231
|
) {}
|
|
@@ -7164,13 +7237,14 @@ export class DateTimeZonedFromSelf extends declare(
|
|
|
7164
7237
|
* @since 3.10.0
|
|
7165
7238
|
*/
|
|
7166
7239
|
export class DateTimeZoned extends transformOrFail(
|
|
7167
|
-
String$.annotations({ description: "a string
|
|
7240
|
+
String$.annotations({ description: "a string to be decoded into a DateTime.Zoned" }),
|
|
7168
7241
|
DateTimeZonedFromSelf,
|
|
7169
7242
|
{
|
|
7170
7243
|
strict: true,
|
|
7171
7244
|
decode: (s, _, ast) =>
|
|
7172
7245
|
option_.match(dateTime.makeZonedFromString(s), {
|
|
7173
|
-
onNone: () =>
|
|
7246
|
+
onNone: () =>
|
|
7247
|
+
ParseResult.fail(new ParseResult.Type(ast, s, `Unable to decode ${JSON.stringify(s)} into a DateTime.Zoned`)),
|
|
7174
7248
|
onSome: ParseResult.succeed
|
|
7175
7249
|
}),
|
|
7176
7250
|
encode: (dt) => ParseResult.succeed(dateTime.formatIsoZoned(dt))
|
|
@@ -7810,7 +7884,7 @@ export const ReadonlyMapFromRecord = <KA, KR, VA, VI, VR>({ key, value }: {
|
|
|
7810
7884
|
}): Schema<ReadonlyMap<KA, VA>, { readonly [x: string]: VI }, KR | VR> =>
|
|
7811
7885
|
transform(
|
|
7812
7886
|
Record({ key: encodedBoundSchema(key), value }).annotations({
|
|
7813
|
-
description: "a record
|
|
7887
|
+
description: "a record to be decoded into a ReadonlyMap"
|
|
7814
7888
|
}),
|
|
7815
7889
|
ReadonlyMapFromSelf({ key, value: typeSchema(value) }),
|
|
7816
7890
|
{
|
|
@@ -7830,7 +7904,7 @@ export const MapFromRecord = <KA, KR, VA, VI, VR>({ key, value }: {
|
|
|
7830
7904
|
}): Schema<Map<KA, VA>, { readonly [x: string]: VI }, KR | VR> =>
|
|
7831
7905
|
transform(
|
|
7832
7906
|
Record({ key: encodedBoundSchema(key), value }).annotations({
|
|
7833
|
-
description: "a record
|
|
7907
|
+
description: "a record to be decoded into a Map"
|
|
7834
7908
|
}),
|
|
7835
7909
|
MapFromSelf({ key, value: typeSchema(value) }),
|
|
7836
7910
|
{
|
|
@@ -8001,13 +8075,14 @@ export class BigDecimalFromSelf extends declare(
|
|
|
8001
8075
|
* @since 3.10.0
|
|
8002
8076
|
*/
|
|
8003
8077
|
export class BigDecimal extends transformOrFail(
|
|
8004
|
-
String$.annotations({ description: "a string
|
|
8078
|
+
String$.annotations({ description: "a string to be decoded into a BigDecimal" }),
|
|
8005
8079
|
BigDecimalFromSelf,
|
|
8006
8080
|
{
|
|
8007
8081
|
strict: true,
|
|
8008
|
-
decode: (
|
|
8009
|
-
bigDecimal_.fromString(
|
|
8010
|
-
onNone: () =>
|
|
8082
|
+
decode: (s, _, ast) =>
|
|
8083
|
+
bigDecimal_.fromString(s).pipe(option_.match({
|
|
8084
|
+
onNone: () =>
|
|
8085
|
+
ParseResult.fail(new ParseResult.Type(ast, s, `Unable to decode ${JSON.stringify(s)} into a BigDecimal`)),
|
|
8011
8086
|
onSome: (val) => ParseResult.succeed(bigDecimal_.normalize(val))
|
|
8012
8087
|
})),
|
|
8013
8088
|
encode: (val) => ParseResult.succeed(bigDecimal_.format(bigDecimal_.normalize(val)))
|
|
@@ -8021,13 +8096,13 @@ export class BigDecimal extends transformOrFail(
|
|
|
8021
8096
|
* @category BigDecimal transformations
|
|
8022
8097
|
* @since 3.10.0
|
|
8023
8098
|
*/
|
|
8024
|
-
export class BigDecimalFromNumber extends
|
|
8025
|
-
Number$.annotations({ description: "a number
|
|
8099
|
+
export class BigDecimalFromNumber extends transform(
|
|
8100
|
+
Number$.annotations({ description: "a number to be decoded into a BigDecimal" }),
|
|
8026
8101
|
BigDecimalFromSelf,
|
|
8027
8102
|
{
|
|
8028
8103
|
strict: true,
|
|
8029
|
-
decode:
|
|
8030
|
-
encode:
|
|
8104
|
+
decode: bigDecimal_.unsafeFromNumber,
|
|
8105
|
+
encode: bigDecimal_.unsafeToNumber
|
|
8031
8106
|
}
|
|
8032
8107
|
).annotations({ identifier: "BigDecimalFromNumber" }) {}
|
|
8033
8108
|
|
|
@@ -10915,3 +10990,37 @@ const go = (ast: AST.AST, path: ReadonlyArray<PropertyKey>): Equivalence.Equival
|
|
|
10915
10990
|
}
|
|
10916
10991
|
}
|
|
10917
10992
|
}
|
|
10993
|
+
|
|
10994
|
+
/** @ignore */
|
|
10995
|
+
class PropertyKey$ extends Union(String$, Number$, SymbolFromStruct).annotations({ identifier: "PropertyKey" }) {}
|
|
10996
|
+
|
|
10997
|
+
export {
|
|
10998
|
+
/**
|
|
10999
|
+
* @since 3.12.5
|
|
11000
|
+
*/
|
|
11001
|
+
PropertyKey$ as PropertyKey
|
|
11002
|
+
}
|
|
11003
|
+
|
|
11004
|
+
/**
|
|
11005
|
+
* @category ArrayFormatter
|
|
11006
|
+
* @since 3.12.5
|
|
11007
|
+
*/
|
|
11008
|
+
export class ArrayFormatterIssue extends Struct({
|
|
11009
|
+
_tag: propertySignature(Literal(
|
|
11010
|
+
"Pointer",
|
|
11011
|
+
"Unexpected",
|
|
11012
|
+
"Missing",
|
|
11013
|
+
"Composite",
|
|
11014
|
+
"Refinement",
|
|
11015
|
+
"Transformation",
|
|
11016
|
+
"Type",
|
|
11017
|
+
"Forbidden"
|
|
11018
|
+
)).annotations({ description: "The tag identifying the type of parse issue" }),
|
|
11019
|
+
path: propertySignature(Array$(PropertyKey$)).annotations({
|
|
11020
|
+
description: "The path to the property where the issue occurred"
|
|
11021
|
+
}),
|
|
11022
|
+
message: propertySignature(String$).annotations({ description: "A descriptive message explaining the issue" })
|
|
11023
|
+
}).annotations({
|
|
11024
|
+
identifier: "ArrayFormatterIssue",
|
|
11025
|
+
description: "Represents an issue returned by the ArrayFormatter formatter"
|
|
11026
|
+
}) {}
|