effect 3.12.3 → 3.12.5
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/DateTime.js.map +1 -1
- package/dist/cjs/Inspectable.js +0 -4
- package/dist/cjs/Inspectable.js.map +1 -1
- package/dist/cjs/ParseResult.js +2 -2
- package/dist/cjs/ParseResult.js.map +1 -1
- package/dist/cjs/Schema.js +154 -93
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/internal/dateTime.js +32 -4
- 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/version.js +1 -1
- package/dist/dts/Arbitrary.d.ts.map +1 -1
- package/dist/dts/DateTime.d.ts +40 -36
- package/dist/dts/DateTime.d.ts.map +1 -1
- package/dist/dts/Inspectable.d.ts.map +1 -1
- package/dist/dts/Layer.d.ts +1 -1
- package/dist/dts/Layer.d.ts.map +1 -1
- package/dist/dts/MetricPolling.d.ts +1 -1
- package/dist/dts/MetricPolling.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 +34 -15
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/esm/Arbitrary.js +72 -14
- package/dist/esm/Arbitrary.js.map +1 -1
- package/dist/esm/DateTime.js.map +1 -1
- package/dist/esm/Inspectable.js +0 -3
- package/dist/esm/Inspectable.js.map +1 -1
- package/dist/esm/ParseResult.js +2 -2
- package/dist/esm/ParseResult.js.map +1 -1
- package/dist/esm/Schema.js +149 -86
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/internal/dateTime.js +31 -3
- 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/version.js +1 -1
- package/package.json +1 -1
- package/src/Arbitrary.ts +84 -14
- package/src/DateTime.ts +45 -56
- package/src/Inspectable.ts +0 -1
- package/src/Layer.ts +1 -1
- package/src/MetricPolling.ts +1 -1
- package/src/ParseResult.ts +15 -2
- package/src/Schema.ts +191 -93
- package/src/internal/dateTime.ts +67 -33
- package/src/internal/effect/circular.ts +19 -17
- package/src/internal/fiberRuntime.ts +2 -1
- package/src/internal/version.ts +1 -1
package/src/Schema.ts
CHANGED
|
@@ -5008,30 +5008,31 @@ export type ParseJsonOptions = {
|
|
|
5008
5008
|
readonly space?: Parameters<typeof JSON.stringify>[2]
|
|
5009
5009
|
}
|
|
5010
5010
|
|
|
5011
|
-
const
|
|
5012
|
-
[AST.IdentifierAnnotationId]: "JsonString",
|
|
5013
|
-
[AST.TitleAnnotationId]: "JsonString",
|
|
5014
|
-
[AST.DescriptionAnnotationId]: "a string that will be parsed as JSON"
|
|
5015
|
-
})
|
|
5011
|
+
const getErrorMessage = (e: unknown): string => e instanceof Error ? e.message : String(e)
|
|
5016
5012
|
|
|
5017
5013
|
const getParseJsonTransformation = (options?: ParseJsonOptions) =>
|
|
5018
5014
|
transformOrFail(
|
|
5019
|
-
|
|
5015
|
+
String$.annotations({
|
|
5016
|
+
[AST.DescriptionAnnotationId]: "a string to be decoded into JSON"
|
|
5017
|
+
}),
|
|
5020
5018
|
Unknown,
|
|
5021
5019
|
{
|
|
5022
5020
|
strict: true,
|
|
5023
5021
|
decode: (s, _, ast) =>
|
|
5024
5022
|
ParseResult.try({
|
|
5025
5023
|
try: () => JSON.parse(s, options?.reviver),
|
|
5026
|
-
catch: (e
|
|
5024
|
+
catch: (e) => new ParseResult.Type(ast, s, getErrorMessage(e))
|
|
5027
5025
|
}),
|
|
5028
5026
|
encode: (u, _, ast) =>
|
|
5029
5027
|
ParseResult.try({
|
|
5030
5028
|
try: () => JSON.stringify(u, options?.replacer, options?.space),
|
|
5031
|
-
catch: (e
|
|
5029
|
+
catch: (e) => new ParseResult.Type(ast, u, getErrorMessage(e))
|
|
5032
5030
|
})
|
|
5033
5031
|
}
|
|
5034
|
-
).annotations({
|
|
5032
|
+
).annotations({
|
|
5033
|
+
title: "parseJson",
|
|
5034
|
+
schemaId: AST.ParseJsonSchemaId
|
|
5035
|
+
})
|
|
5035
5036
|
|
|
5036
5037
|
/**
|
|
5037
5038
|
* The `ParseJson` combinator provides a method to convert JSON strings into the `unknown` type using the underlying
|
|
@@ -5175,14 +5176,19 @@ export class URLFromSelf extends instanceOf(URL, {
|
|
|
5175
5176
|
|
|
5176
5177
|
/** @ignore */
|
|
5177
5178
|
class URL$ extends transformOrFail(
|
|
5178
|
-
String$.annotations({ description: "a string
|
|
5179
|
+
String$.annotations({ description: "a string to be decoded into a URL" }),
|
|
5179
5180
|
URLFromSelf,
|
|
5180
5181
|
{
|
|
5181
5182
|
strict: true,
|
|
5182
|
-
decode: (
|
|
5183
|
+
decode: (s, _, ast) =>
|
|
5183
5184
|
ParseResult.try({
|
|
5184
|
-
try: () => new URL(
|
|
5185
|
-
catch: () =>
|
|
5185
|
+
try: () => new URL(s),
|
|
5186
|
+
catch: (e) =>
|
|
5187
|
+
new ParseResult.Type(
|
|
5188
|
+
ast,
|
|
5189
|
+
s,
|
|
5190
|
+
`Unable to decode ${JSON.stringify(s)} into a URL. ${getErrorMessage(e)}`
|
|
5191
|
+
)
|
|
5186
5192
|
}),
|
|
5187
5193
|
encode: (url) => ParseResult.succeed(url.toString())
|
|
5188
5194
|
}
|
|
@@ -5547,8 +5553,11 @@ export const parseNumber = <A extends string, I, R>(
|
|
|
5547
5553
|
Number$,
|
|
5548
5554
|
{
|
|
5549
5555
|
strict: false,
|
|
5550
|
-
decode: (s, _, ast) =>
|
|
5551
|
-
|
|
5556
|
+
decode: (s, _, ast) =>
|
|
5557
|
+
ParseResult.fromOption(number_.parse(s), () =>
|
|
5558
|
+
new ParseResult.Type(ast, s, `Unable to decode ${JSON.stringify(s)} into a number`)),
|
|
5559
|
+
encode: (n) =>
|
|
5560
|
+
ParseResult.succeed(String(n))
|
|
5552
5561
|
}
|
|
5553
5562
|
)
|
|
5554
5563
|
|
|
@@ -5563,7 +5572,7 @@ export const parseNumber = <A extends string, I, R>(
|
|
|
5563
5572
|
* @since 3.10.0
|
|
5564
5573
|
*/
|
|
5565
5574
|
export class NumberFromString extends parseNumber(String$.annotations({
|
|
5566
|
-
description: "a string
|
|
5575
|
+
description: "a string to be decoded into a number"
|
|
5567
5576
|
})).annotations({ identifier: "NumberFromString" }) {}
|
|
5568
5577
|
|
|
5569
5578
|
/**
|
|
@@ -5665,16 +5674,31 @@ export class Not extends transform(Boolean$.annotations({ description: "a boolea
|
|
|
5665
5674
|
encode: boolean_.not
|
|
5666
5675
|
}) {}
|
|
5667
5676
|
|
|
5677
|
+
const encodeSymbol = (sym: symbol, _: AST.ParseOptions, ast: AST.AST) => {
|
|
5678
|
+
const key = Symbol.keyFor(sym)
|
|
5679
|
+
return key === undefined
|
|
5680
|
+
? ParseResult.fail(
|
|
5681
|
+
new ParseResult.Type(ast, sym, `Unable to encode a unique symbol ${String(sym)} into a string`)
|
|
5682
|
+
)
|
|
5683
|
+
: ParseResult.succeed(key)
|
|
5684
|
+
}
|
|
5685
|
+
|
|
5686
|
+
const decodeSymbol = (s: string) => ParseResult.succeed(Symbol.for(s))
|
|
5687
|
+
|
|
5668
5688
|
/** @ignore */
|
|
5669
|
-
class Symbol$ extends
|
|
5670
|
-
String$.annotations({ description: "a string
|
|
5689
|
+
class Symbol$ extends transformOrFail(
|
|
5690
|
+
String$.annotations({ description: "a string to be decoded into a globally shared symbol" }),
|
|
5671
5691
|
SymbolFromSelf,
|
|
5672
|
-
{
|
|
5673
|
-
|
|
5692
|
+
{
|
|
5693
|
+
strict: false,
|
|
5694
|
+
decode: decodeSymbol,
|
|
5695
|
+
encode: encodeSymbol
|
|
5696
|
+
}
|
|
5697
|
+
).annotations({ identifier: "Symbol" }) {}
|
|
5674
5698
|
|
|
5675
5699
|
export {
|
|
5676
5700
|
/**
|
|
5677
|
-
*
|
|
5701
|
+
* Converts a string key into a globally shared symbol.
|
|
5678
5702
|
*
|
|
5679
5703
|
* @category symbol transformations
|
|
5680
5704
|
* @since 3.10.0
|
|
@@ -5682,6 +5706,20 @@ export {
|
|
|
5682
5706
|
Symbol$ as Symbol
|
|
5683
5707
|
}
|
|
5684
5708
|
|
|
5709
|
+
const SymbolStruct = TaggedStruct("symbol", {
|
|
5710
|
+
key: String$
|
|
5711
|
+
}).annotations({ description: "an object to be decoded into a globally shared symbol" })
|
|
5712
|
+
|
|
5713
|
+
const SymbolFromStruct = transformOrFail(
|
|
5714
|
+
SymbolStruct,
|
|
5715
|
+
SymbolFromSelf,
|
|
5716
|
+
{
|
|
5717
|
+
strict: true,
|
|
5718
|
+
decode: ({ key }) => decodeSymbol(key),
|
|
5719
|
+
encode: (sym, _, ast) => ParseResult.map(encodeSymbol(sym, _, ast), (key) => SymbolStruct.make({ key }))
|
|
5720
|
+
}
|
|
5721
|
+
)
|
|
5722
|
+
|
|
5685
5723
|
/**
|
|
5686
5724
|
* @category schema id
|
|
5687
5725
|
* @since 3.10.0
|
|
@@ -5893,14 +5931,18 @@ export const clampBigInt =
|
|
|
5893
5931
|
|
|
5894
5932
|
/** @ignore */
|
|
5895
5933
|
class BigInt$ extends transformOrFail(
|
|
5896
|
-
String$.annotations({ description: "a string
|
|
5934
|
+
String$.annotations({ description: "a string to be decoded into a bigint" }),
|
|
5897
5935
|
BigIntFromSelf,
|
|
5898
5936
|
{
|
|
5899
5937
|
strict: true,
|
|
5900
|
-
decode: (s, _, ast) =>
|
|
5938
|
+
decode: (s, _, ast) =>
|
|
5939
|
+
ParseResult.fromOption(
|
|
5940
|
+
bigInt_.fromString(s),
|
|
5941
|
+
() => new ParseResult.Type(ast, s, `Unable to decode ${JSON.stringify(s)} into a bigint`)
|
|
5942
|
+
),
|
|
5901
5943
|
encode: (n) => ParseResult.succeed(String(n))
|
|
5902
5944
|
}
|
|
5903
|
-
).annotations({ identifier: "
|
|
5945
|
+
).annotations({ identifier: "BigInt" }) {}
|
|
5904
5946
|
|
|
5905
5947
|
export {
|
|
5906
5948
|
/**
|
|
@@ -5987,18 +6029,22 @@ export const NonNegativeBigInt: filter<Schema<bigint, string>> = BigInt$.pipe(
|
|
|
5987
6029
|
* @since 3.10.0
|
|
5988
6030
|
*/
|
|
5989
6031
|
export class BigIntFromNumber extends transformOrFail(
|
|
5990
|
-
Number$.annotations({ description: "a number
|
|
6032
|
+
Number$.annotations({ description: "a number to be decoded into a bigint" }),
|
|
5991
6033
|
BigIntFromSelf,
|
|
5992
6034
|
{
|
|
5993
6035
|
strict: true,
|
|
5994
6036
|
decode: (n, _, ast) =>
|
|
5995
6037
|
ParseResult.fromOption(
|
|
5996
6038
|
bigInt_.fromNumber(n),
|
|
5997
|
-
() => new ParseResult.Type(ast, n)
|
|
6039
|
+
() => new ParseResult.Type(ast, n, `Unable to decode ${n} into a bigint`)
|
|
5998
6040
|
),
|
|
5999
|
-
encode: (b, _, ast) =>
|
|
6041
|
+
encode: (b, _, ast) =>
|
|
6042
|
+
ParseResult.fromOption(
|
|
6043
|
+
bigInt_.toNumber(b),
|
|
6044
|
+
() => new ParseResult.Type(ast, b, `Unable to encode ${b}n into a number`)
|
|
6045
|
+
)
|
|
6000
6046
|
}
|
|
6001
|
-
).annotations({ identifier: "
|
|
6047
|
+
).annotations({ identifier: "BigIntFromNumber" }) {}
|
|
6002
6048
|
|
|
6003
6049
|
const redactedArbitrary = <A>(value: LazyArbitrary<A>): LazyArbitrary<redacted_.Redacted<A>> => (fc) =>
|
|
6004
6050
|
value(fc).map(redacted_.make)
|
|
@@ -6122,14 +6168,15 @@ export class DurationFromSelf extends declare(
|
|
|
6122
6168
|
* @since 3.10.0
|
|
6123
6169
|
*/
|
|
6124
6170
|
export class DurationFromNanos extends transformOrFail(
|
|
6125
|
-
BigIntFromSelf.annotations({ description: "a bigint
|
|
6171
|
+
BigIntFromSelf.annotations({ description: "a bigint to be decoded into a Duration" }),
|
|
6126
6172
|
DurationFromSelf,
|
|
6127
6173
|
{
|
|
6128
6174
|
strict: true,
|
|
6129
6175
|
decode: (nanos) => ParseResult.succeed(duration_.nanos(nanos)),
|
|
6130
6176
|
encode: (duration, _, ast) =>
|
|
6131
6177
|
option_.match(duration_.toNanos(duration), {
|
|
6132
|
-
onNone: () =>
|
|
6178
|
+
onNone: () =>
|
|
6179
|
+
ParseResult.fail(new ParseResult.Type(ast, duration, `Unable to encode ${duration} into a bigint`)),
|
|
6133
6180
|
onSome: (val) => ParseResult.succeed(val)
|
|
6134
6181
|
})
|
|
6135
6182
|
}
|
|
@@ -6143,7 +6190,7 @@ export class DurationFromNanos extends transformOrFail(
|
|
|
6143
6190
|
* @since 3.10.0
|
|
6144
6191
|
*/
|
|
6145
6192
|
export class DurationFromMillis extends transform(
|
|
6146
|
-
Number$.annotations({ description: "a number
|
|
6193
|
+
Number$.annotations({ description: "a number to be decoded into a Duration" }),
|
|
6147
6194
|
DurationFromSelf,
|
|
6148
6195
|
{ strict: true, decode: (ms) => duration_.millis(ms), encode: (n) => duration_.toMillis(n) }
|
|
6149
6196
|
).annotations({ identifier: "DurationFromMillis" }) {}
|
|
@@ -6166,7 +6213,7 @@ const HRTime: Schema<readonly [seconds: number, nanos: number]> = Tuple(
|
|
|
6166
6213
|
* @since 3.10.0
|
|
6167
6214
|
*/
|
|
6168
6215
|
export class Duration extends transform(
|
|
6169
|
-
HRTime.annotations({ description: "a tuple of seconds and nanos
|
|
6216
|
+
HRTime.annotations({ description: "a tuple of seconds and nanos to be decoded into a Duration" }),
|
|
6170
6217
|
DurationFromSelf,
|
|
6171
6218
|
{
|
|
6172
6219
|
strict: true,
|
|
@@ -6347,7 +6394,7 @@ export const Uint8 = Number$.pipe(
|
|
|
6347
6394
|
|
|
6348
6395
|
const Uint8Array$: Schema<Uint8Array, ReadonlyArray<number>> = transform(
|
|
6349
6396
|
Array$(Uint8).annotations({
|
|
6350
|
-
description: "an array of 8-bit unsigned integers
|
|
6397
|
+
description: "an array of 8-bit unsigned integers to be decoded into a Uint8Array"
|
|
6351
6398
|
}),
|
|
6352
6399
|
Uint8ArrayFromSelf,
|
|
6353
6400
|
{ strict: true, decode: (numbers) => Uint8Array.from(numbers), encode: (uint8Array) => Array.from(uint8Array) }
|
|
@@ -6369,7 +6416,7 @@ const makeUint8ArrayTransformation = (
|
|
|
6369
6416
|
encode: (u: Uint8Array) => string
|
|
6370
6417
|
) =>
|
|
6371
6418
|
transformOrFail(
|
|
6372
|
-
String$.annotations({ description: "a string
|
|
6419
|
+
String$.annotations({ description: "a string to be decoded into a Uint8Array" }),
|
|
6373
6420
|
Uint8ArrayFromSelf,
|
|
6374
6421
|
{
|
|
6375
6422
|
strict: true,
|
|
@@ -6533,11 +6580,11 @@ export type MinItemsSchemaId = typeof MinItemsSchemaId
|
|
|
6533
6580
|
* @category ReadonlyArray filters
|
|
6534
6581
|
* @since 3.10.0
|
|
6535
6582
|
*/
|
|
6536
|
-
export const minItems = <A
|
|
6583
|
+
export const minItems = <A extends ReadonlyArray<any>>(
|
|
6537
6584
|
n: number,
|
|
6538
|
-
annotations?: Annotations.Filter<
|
|
6585
|
+
annotations?: Annotations.Filter<A>
|
|
6539
6586
|
) =>
|
|
6540
|
-
<I, R>(self: Schema<
|
|
6587
|
+
<I, R>(self: Schema<A, I, R>): filter<Schema<A, I, R>> => {
|
|
6541
6588
|
const minItems = Math.floor(n)
|
|
6542
6589
|
if (minItems < 1) {
|
|
6543
6590
|
throw new Error(
|
|
@@ -6575,21 +6622,28 @@ export type MaxItemsSchemaId = typeof MaxItemsSchemaId
|
|
|
6575
6622
|
* @category ReadonlyArray filters
|
|
6576
6623
|
* @since 3.10.0
|
|
6577
6624
|
*/
|
|
6578
|
-
export const maxItems = <A
|
|
6625
|
+
export const maxItems = <A extends ReadonlyArray<any>>(
|
|
6579
6626
|
n: number,
|
|
6580
|
-
annotations?: Annotations.Filter<
|
|
6627
|
+
annotations?: Annotations.Filter<A>
|
|
6581
6628
|
) =>
|
|
6582
|
-
<I, R>(self: Schema<
|
|
6583
|
-
|
|
6584
|
-
|
|
6629
|
+
<I, R>(self: Schema<A, I, R>): filter<Schema<A, I, R>> => {
|
|
6630
|
+
const maxItems = Math.floor(n)
|
|
6631
|
+
if (maxItems < 1) {
|
|
6632
|
+
throw new Error(
|
|
6633
|
+
errors_.getInvalidArgumentErrorMessage(`Expected an integer greater than or equal to 1, actual ${n}`)
|
|
6634
|
+
)
|
|
6635
|
+
}
|
|
6636
|
+
return self.pipe(
|
|
6637
|
+
filter((a) => a.length <= maxItems, {
|
|
6585
6638
|
schemaId: MaxItemsSchemaId,
|
|
6586
|
-
title: `maxItems(${
|
|
6587
|
-
description: `an array of at most ${
|
|
6588
|
-
jsonSchema: { maxItems
|
|
6639
|
+
title: `maxItems(${maxItems})`,
|
|
6640
|
+
description: `an array of at most ${maxItems} item(s)`,
|
|
6641
|
+
jsonSchema: { maxItems },
|
|
6589
6642
|
[AST.StableFilterAnnotationId]: true,
|
|
6590
6643
|
...annotations
|
|
6591
6644
|
})
|
|
6592
6645
|
)
|
|
6646
|
+
}
|
|
6593
6647
|
|
|
6594
6648
|
/**
|
|
6595
6649
|
* @category schema id
|
|
@@ -6607,21 +6661,28 @@ export type ItemsCountSchemaId = typeof ItemsCountSchemaId
|
|
|
6607
6661
|
* @category ReadonlyArray filters
|
|
6608
6662
|
* @since 3.10.0
|
|
6609
6663
|
*/
|
|
6610
|
-
export const itemsCount = <A
|
|
6664
|
+
export const itemsCount = <A extends ReadonlyArray<any>>(
|
|
6611
6665
|
n: number,
|
|
6612
|
-
annotations?: Annotations.Filter<
|
|
6666
|
+
annotations?: Annotations.Filter<A>
|
|
6613
6667
|
) =>
|
|
6614
|
-
<I, R>(self: Schema<
|
|
6615
|
-
|
|
6616
|
-
|
|
6668
|
+
<I, R>(self: Schema<A, I, R>): filter<Schema<A, I, R>> => {
|
|
6669
|
+
const itemsCount = Math.floor(n)
|
|
6670
|
+
if (itemsCount < 1) {
|
|
6671
|
+
throw new Error(
|
|
6672
|
+
errors_.getInvalidArgumentErrorMessage(`Expected an integer greater than or equal to 1, actual ${n}`)
|
|
6673
|
+
)
|
|
6674
|
+
}
|
|
6675
|
+
return self.pipe(
|
|
6676
|
+
filter((a) => a.length === itemsCount, {
|
|
6617
6677
|
schemaId: ItemsCountSchemaId,
|
|
6618
|
-
title: `itemsCount(${
|
|
6619
|
-
description: `an array of exactly ${
|
|
6620
|
-
jsonSchema: { minItems:
|
|
6678
|
+
title: `itemsCount(${itemsCount})`,
|
|
6679
|
+
description: `an array of exactly ${itemsCount} item(s)`,
|
|
6680
|
+
jsonSchema: { minItems: itemsCount, maxItems: itemsCount },
|
|
6621
6681
|
[AST.StableFilterAnnotationId]: true,
|
|
6622
6682
|
...annotations
|
|
6623
6683
|
})
|
|
6624
6684
|
)
|
|
6685
|
+
}
|
|
6625
6686
|
|
|
6626
6687
|
/**
|
|
6627
6688
|
* @category ReadonlyArray transformations
|
|
@@ -6697,7 +6758,7 @@ export const headOrElse: {
|
|
|
6697
6758
|
? ParseResult.succeed(as[0])
|
|
6698
6759
|
: fallback
|
|
6699
6760
|
? ParseResult.succeed(fallback())
|
|
6700
|
-
: ParseResult.fail(new ParseResult.Type(ast, as)),
|
|
6761
|
+
: ParseResult.fail(new ParseResult.Type(ast, as, "Unable to retrieve the first element of an empty array")),
|
|
6701
6762
|
encode: (a) => ParseResult.succeed(array_.of(a))
|
|
6702
6763
|
}
|
|
6703
6764
|
)
|
|
@@ -6919,7 +6980,7 @@ export class ValidDateFromSelf extends DateFromSelf.pipe(
|
|
|
6919
6980
|
* @since 3.10.0
|
|
6920
6981
|
*/
|
|
6921
6982
|
export class DateFromString extends transform(
|
|
6922
|
-
String$.annotations({ description: "a string
|
|
6983
|
+
String$.annotations({ description: "a string to be decoded into a Date" }),
|
|
6923
6984
|
DateFromSelf,
|
|
6924
6985
|
{ strict: true, decode: (s) => new Date(s), encode: (d) => util_.formatDate(d) }
|
|
6925
6986
|
).annotations({ identifier: "DateFromString" }) {}
|
|
@@ -6953,7 +7014,7 @@ export {
|
|
|
6953
7014
|
* @since 3.10.0
|
|
6954
7015
|
*/
|
|
6955
7016
|
export class DateFromNumber extends transform(
|
|
6956
|
-
Number$.annotations({ description: "a number
|
|
7017
|
+
Number$.annotations({ description: "a number to be decoded into a Date" }),
|
|
6957
7018
|
DateFromSelf,
|
|
6958
7019
|
{ strict: true, decode: (n) => new Date(n), encode: (d) => d.getTime() }
|
|
6959
7020
|
).annotations({ identifier: "DateFromNumber" }) {}
|
|
@@ -6970,15 +7031,16 @@ export class DateTimeUtcFromSelf extends declare(
|
|
|
6970
7031
|
identifier: "DateTimeUtcFromSelf",
|
|
6971
7032
|
description: "a DateTime.Utc instance",
|
|
6972
7033
|
pretty: (): pretty_.Pretty<dateTime.Utc> => (dateTime) => dateTime.toString(),
|
|
6973
|
-
arbitrary: (): LazyArbitrary<dateTime.Utc> => (fc) =>
|
|
7034
|
+
arbitrary: (): LazyArbitrary<dateTime.Utc> => (fc) =>
|
|
7035
|
+
fc.date({ noInvalidDate: true }).map((date) => dateTime.unsafeFromDate(date)),
|
|
6974
7036
|
equivalence: () => dateTime.Equivalence
|
|
6975
7037
|
}
|
|
6976
7038
|
) {}
|
|
6977
7039
|
|
|
6978
|
-
const
|
|
7040
|
+
const decodeDateTimeUtc = <A extends dateTime.DateTime.Input>(input: A, _: ParseOptions, ast: AST.AST) =>
|
|
6979
7041
|
ParseResult.try({
|
|
6980
7042
|
try: () => dateTime.unsafeMake(input),
|
|
6981
|
-
catch: () => new ParseResult.Type(ast, input)
|
|
7043
|
+
catch: () => new ParseResult.Type(ast, input, `Unable to decode ${util_.formatUnknown(input)} into a DateTime.Utc`)
|
|
6982
7044
|
})
|
|
6983
7045
|
|
|
6984
7046
|
/**
|
|
@@ -6988,11 +7050,11 @@ const decodeDateTime = <A extends dateTime.DateTime.Input>(input: A, _: ParseOpt
|
|
|
6988
7050
|
* @since 3.10.0
|
|
6989
7051
|
*/
|
|
6990
7052
|
export class DateTimeUtcFromNumber extends transformOrFail(
|
|
6991
|
-
Number$.annotations({ description: "a number
|
|
7053
|
+
Number$.annotations({ description: "a number to be decoded into a DateTime.Utc" }),
|
|
6992
7054
|
DateTimeUtcFromSelf,
|
|
6993
7055
|
{
|
|
6994
7056
|
strict: true,
|
|
6995
|
-
decode:
|
|
7057
|
+
decode: decodeDateTimeUtc,
|
|
6996
7058
|
encode: (dt) => ParseResult.succeed(dateTime.toEpochMillis(dt))
|
|
6997
7059
|
}
|
|
6998
7060
|
).annotations({ identifier: "DateTimeUtcFromNumber" }) {}
|
|
@@ -7004,11 +7066,11 @@ export class DateTimeUtcFromNumber extends transformOrFail(
|
|
|
7004
7066
|
* @since 3.12.0
|
|
7005
7067
|
*/
|
|
7006
7068
|
export class DateTimeUtcFromDate extends transformOrFail(
|
|
7007
|
-
DateFromSelf.annotations({ description: "a Date
|
|
7069
|
+
DateFromSelf.annotations({ description: "a Date to be decoded into a DateTime.Utc" }),
|
|
7008
7070
|
DateTimeUtcFromSelf,
|
|
7009
7071
|
{
|
|
7010
7072
|
strict: true,
|
|
7011
|
-
decode:
|
|
7073
|
+
decode: decodeDateTimeUtc,
|
|
7012
7074
|
encode: (dt) => ParseResult.succeed(dateTime.toDateUtc(dt))
|
|
7013
7075
|
}
|
|
7014
7076
|
).annotations({ identifier: "DateTimeUtcFromDate" }) {}
|
|
@@ -7020,17 +7082,17 @@ export class DateTimeUtcFromDate extends transformOrFail(
|
|
|
7020
7082
|
* @since 3.10.0
|
|
7021
7083
|
*/
|
|
7022
7084
|
export class DateTimeUtc extends transformOrFail(
|
|
7023
|
-
String$.annotations({ description: "a string
|
|
7085
|
+
String$.annotations({ description: "a string to be decoded into a DateTime.Utc" }),
|
|
7024
7086
|
DateTimeUtcFromSelf,
|
|
7025
7087
|
{
|
|
7026
7088
|
strict: true,
|
|
7027
|
-
decode:
|
|
7089
|
+
decode: decodeDateTimeUtc,
|
|
7028
7090
|
encode: (dt) => ParseResult.succeed(dateTime.formatIso(dt))
|
|
7029
7091
|
}
|
|
7030
7092
|
).annotations({ identifier: "DateTimeUtc" }) {}
|
|
7031
7093
|
|
|
7032
7094
|
const timeZoneOffsetArbitrary = (): LazyArbitrary<dateTime.TimeZone.Offset> => (fc) =>
|
|
7033
|
-
fc.integer({ min: -12 * 60 * 60 * 1000, max:
|
|
7095
|
+
fc.integer({ min: -12 * 60 * 60 * 1000, max: 14 * 60 * 60 * 1000 }).map(dateTime.zoneMakeOffset)
|
|
7034
7096
|
|
|
7035
7097
|
/**
|
|
7036
7098
|
* Describes a schema that represents a `TimeZone.Offset` instance.
|
|
@@ -7055,7 +7117,7 @@ export class TimeZoneOffsetFromSelf extends declare(
|
|
|
7055
7117
|
* @since 3.10.0
|
|
7056
7118
|
*/
|
|
7057
7119
|
export class TimeZoneOffset extends transform(
|
|
7058
|
-
Number$.annotations({ description: "a number
|
|
7120
|
+
Number$.annotations({ description: "a number to be decoded into a TimeZone.Offset" }),
|
|
7059
7121
|
TimeZoneOffsetFromSelf,
|
|
7060
7122
|
{ strict: true, decode: dateTime.zoneMakeOffset, encode: (tz) => tz.offset }
|
|
7061
7123
|
).annotations({ identifier: "TimeZoneOffset" }) {}
|
|
@@ -7086,32 +7148,24 @@ export class TimeZoneNamedFromSelf extends declare(
|
|
|
7086
7148
|
* @since 3.10.0
|
|
7087
7149
|
*/
|
|
7088
7150
|
export class TimeZoneNamed extends transformOrFail(
|
|
7089
|
-
String$.annotations({ description: "a string
|
|
7151
|
+
String$.annotations({ description: "a string to be decoded into a TimeZone.Named" }),
|
|
7090
7152
|
TimeZoneNamedFromSelf,
|
|
7091
7153
|
{
|
|
7092
7154
|
strict: true,
|
|
7093
7155
|
decode: (s, _, ast) =>
|
|
7094
7156
|
ParseResult.try({
|
|
7095
7157
|
try: () => dateTime.zoneUnsafeMakeNamed(s),
|
|
7096
|
-
catch: () => new ParseResult.Type(ast, s)
|
|
7158
|
+
catch: () => new ParseResult.Type(ast, s, `Unable to decode ${JSON.stringify(s)} into a TimeZone.Named`)
|
|
7097
7159
|
}),
|
|
7098
7160
|
encode: (tz) => ParseResult.succeed(tz.id)
|
|
7099
7161
|
}
|
|
7100
7162
|
).annotations({ identifier: "TimeZoneNamed" }) {}
|
|
7101
7163
|
|
|
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
7164
|
/**
|
|
7111
7165
|
* @category TimeZone constructors
|
|
7112
7166
|
* @since 3.10.0
|
|
7113
7167
|
*/
|
|
7114
|
-
export
|
|
7168
|
+
export class TimeZoneFromSelf extends Union(TimeZoneOffsetFromSelf, TimeZoneNamedFromSelf) {}
|
|
7115
7169
|
|
|
7116
7170
|
/**
|
|
7117
7171
|
* Defines a schema that attempts to convert a `string` to a `TimeZone` using the `DateTime.zoneFromString` constructor.
|
|
@@ -7120,13 +7174,14 @@ export const TimeZoneFromSelf: TimeZoneFromSelf = Union(TimeZoneOffsetFromSelf,
|
|
|
7120
7174
|
* @since 3.10.0
|
|
7121
7175
|
*/
|
|
7122
7176
|
export class TimeZone extends transformOrFail(
|
|
7123
|
-
String$.annotations({ description: "a string
|
|
7177
|
+
String$.annotations({ description: "a string to be decoded into a TimeZone" }),
|
|
7124
7178
|
TimeZoneFromSelf,
|
|
7125
7179
|
{
|
|
7126
7180
|
strict: true,
|
|
7127
7181
|
decode: (s, _, ast) =>
|
|
7128
7182
|
option_.match(dateTime.zoneFromString(s), {
|
|
7129
|
-
onNone: () =>
|
|
7183
|
+
onNone: () =>
|
|
7184
|
+
ParseResult.fail(new ParseResult.Type(ast, s, `Unable to decode ${JSON.stringify(s)} into a TimeZone`)),
|
|
7130
7185
|
onSome: ParseResult.succeed
|
|
7131
7186
|
}),
|
|
7132
7187
|
encode: (tz) => ParseResult.succeed(dateTime.zoneToString(tz))
|
|
@@ -7152,7 +7207,14 @@ export class DateTimeZonedFromSelf extends declare(
|
|
|
7152
7207
|
description: "a DateTime.Zoned instance",
|
|
7153
7208
|
pretty: (): pretty_.Pretty<dateTime.Zoned> => (dateTime) => dateTime.toString(),
|
|
7154
7209
|
arbitrary: (): LazyArbitrary<dateTime.Zoned> => (fc) =>
|
|
7155
|
-
fc.
|
|
7210
|
+
fc.tuple(
|
|
7211
|
+
fc.integer({
|
|
7212
|
+
// time zone db supports +/- 1000 years or so
|
|
7213
|
+
min: -31536000000000,
|
|
7214
|
+
max: 31536000000000
|
|
7215
|
+
}),
|
|
7216
|
+
timeZoneArbitrary(fc)
|
|
7217
|
+
).map(([millis, timeZone]) => dateTime.unsafeMakeZoned(millis, { timeZone })),
|
|
7156
7218
|
equivalence: () => dateTime.Equivalence
|
|
7157
7219
|
}
|
|
7158
7220
|
) {}
|
|
@@ -7164,13 +7226,14 @@ export class DateTimeZonedFromSelf extends declare(
|
|
|
7164
7226
|
* @since 3.10.0
|
|
7165
7227
|
*/
|
|
7166
7228
|
export class DateTimeZoned extends transformOrFail(
|
|
7167
|
-
String$.annotations({ description: "a string
|
|
7229
|
+
String$.annotations({ description: "a string to be decoded into a DateTime.Zoned" }),
|
|
7168
7230
|
DateTimeZonedFromSelf,
|
|
7169
7231
|
{
|
|
7170
7232
|
strict: true,
|
|
7171
7233
|
decode: (s, _, ast) =>
|
|
7172
7234
|
option_.match(dateTime.makeZonedFromString(s), {
|
|
7173
|
-
onNone: () =>
|
|
7235
|
+
onNone: () =>
|
|
7236
|
+
ParseResult.fail(new ParseResult.Type(ast, s, `Unable to decode ${JSON.stringify(s)} into a DateTime.Zoned`)),
|
|
7174
7237
|
onSome: ParseResult.succeed
|
|
7175
7238
|
}),
|
|
7176
7239
|
encode: (dt) => ParseResult.succeed(dateTime.formatIsoZoned(dt))
|
|
@@ -7810,7 +7873,7 @@ export const ReadonlyMapFromRecord = <KA, KR, VA, VI, VR>({ key, value }: {
|
|
|
7810
7873
|
}): Schema<ReadonlyMap<KA, VA>, { readonly [x: string]: VI }, KR | VR> =>
|
|
7811
7874
|
transform(
|
|
7812
7875
|
Record({ key: encodedBoundSchema(key), value }).annotations({
|
|
7813
|
-
description: "a record
|
|
7876
|
+
description: "a record to be decoded into a ReadonlyMap"
|
|
7814
7877
|
}),
|
|
7815
7878
|
ReadonlyMapFromSelf({ key, value: typeSchema(value) }),
|
|
7816
7879
|
{
|
|
@@ -7830,7 +7893,7 @@ export const MapFromRecord = <KA, KR, VA, VI, VR>({ key, value }: {
|
|
|
7830
7893
|
}): Schema<Map<KA, VA>, { readonly [x: string]: VI }, KR | VR> =>
|
|
7831
7894
|
transform(
|
|
7832
7895
|
Record({ key: encodedBoundSchema(key), value }).annotations({
|
|
7833
|
-
description: "a record
|
|
7896
|
+
description: "a record to be decoded into a Map"
|
|
7834
7897
|
}),
|
|
7835
7898
|
MapFromSelf({ key, value: typeSchema(value) }),
|
|
7836
7899
|
{
|
|
@@ -8001,13 +8064,14 @@ export class BigDecimalFromSelf extends declare(
|
|
|
8001
8064
|
* @since 3.10.0
|
|
8002
8065
|
*/
|
|
8003
8066
|
export class BigDecimal extends transformOrFail(
|
|
8004
|
-
String$.annotations({ description: "a string
|
|
8067
|
+
String$.annotations({ description: "a string to be decoded into a BigDecimal" }),
|
|
8005
8068
|
BigDecimalFromSelf,
|
|
8006
8069
|
{
|
|
8007
8070
|
strict: true,
|
|
8008
|
-
decode: (
|
|
8009
|
-
bigDecimal_.fromString(
|
|
8010
|
-
onNone: () =>
|
|
8071
|
+
decode: (s, _, ast) =>
|
|
8072
|
+
bigDecimal_.fromString(s).pipe(option_.match({
|
|
8073
|
+
onNone: () =>
|
|
8074
|
+
ParseResult.fail(new ParseResult.Type(ast, s, `Unable to decode ${JSON.stringify(s)} into a BigDecimal`)),
|
|
8011
8075
|
onSome: (val) => ParseResult.succeed(bigDecimal_.normalize(val))
|
|
8012
8076
|
})),
|
|
8013
8077
|
encode: (val) => ParseResult.succeed(bigDecimal_.format(bigDecimal_.normalize(val)))
|
|
@@ -8021,13 +8085,13 @@ export class BigDecimal extends transformOrFail(
|
|
|
8021
8085
|
* @category BigDecimal transformations
|
|
8022
8086
|
* @since 3.10.0
|
|
8023
8087
|
*/
|
|
8024
|
-
export class BigDecimalFromNumber extends
|
|
8025
|
-
Number$.annotations({ description: "a number
|
|
8088
|
+
export class BigDecimalFromNumber extends transform(
|
|
8089
|
+
Number$.annotations({ description: "a number to be decoded into a BigDecimal" }),
|
|
8026
8090
|
BigDecimalFromSelf,
|
|
8027
8091
|
{
|
|
8028
8092
|
strict: true,
|
|
8029
|
-
decode:
|
|
8030
|
-
encode:
|
|
8093
|
+
decode: bigDecimal_.unsafeFromNumber,
|
|
8094
|
+
encode: bigDecimal_.unsafeToNumber
|
|
8031
8095
|
}
|
|
8032
8096
|
).annotations({ identifier: "BigDecimalFromNumber" }) {}
|
|
8033
8097
|
|
|
@@ -10915,3 +10979,37 @@ const go = (ast: AST.AST, path: ReadonlyArray<PropertyKey>): Equivalence.Equival
|
|
|
10915
10979
|
}
|
|
10916
10980
|
}
|
|
10917
10981
|
}
|
|
10982
|
+
|
|
10983
|
+
/** @ignore */
|
|
10984
|
+
class PropertyKey$ extends Union(String$, Number$, SymbolFromStruct).annotations({ identifier: "PropertyKey" }) {}
|
|
10985
|
+
|
|
10986
|
+
export {
|
|
10987
|
+
/**
|
|
10988
|
+
* @since 3.12.5
|
|
10989
|
+
*/
|
|
10990
|
+
PropertyKey$ as PropertyKey
|
|
10991
|
+
}
|
|
10992
|
+
|
|
10993
|
+
/**
|
|
10994
|
+
* @category ArrayFormatter
|
|
10995
|
+
* @since 3.12.5
|
|
10996
|
+
*/
|
|
10997
|
+
export class ArrayFormatterIssue extends Struct({
|
|
10998
|
+
_tag: propertySignature(Literal(
|
|
10999
|
+
"Pointer",
|
|
11000
|
+
"Unexpected",
|
|
11001
|
+
"Missing",
|
|
11002
|
+
"Composite",
|
|
11003
|
+
"Refinement",
|
|
11004
|
+
"Transformation",
|
|
11005
|
+
"Type",
|
|
11006
|
+
"Forbidden"
|
|
11007
|
+
)).annotations({ description: "The tag identifying the type of parse issue" }),
|
|
11008
|
+
path: propertySignature(Array$(PropertyKey$)).annotations({
|
|
11009
|
+
description: "The path to the property where the issue occurred"
|
|
11010
|
+
}),
|
|
11011
|
+
message: propertySignature(String$).annotations({ description: "A descriptive message explaining the issue" })
|
|
11012
|
+
}).annotations({
|
|
11013
|
+
identifier: "ArrayFormatterIssue",
|
|
11014
|
+
description: "Represents an issue returned by the ArrayFormatter formatter"
|
|
11015
|
+
}) {}
|