effect 3.13.2 → 3.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/FiberHandle.js +5 -3
- package/dist/cjs/FiberHandle.js.map +1 -1
- package/dist/cjs/FiberMap.js +5 -3
- package/dist/cjs/FiberMap.js.map +1 -1
- package/dist/cjs/FiberSet.js +6 -3
- package/dist/cjs/FiberSet.js.map +1 -1
- package/dist/cjs/JSONSchema.js +7 -7
- package/dist/cjs/JSONSchema.js.map +1 -1
- package/dist/cjs/Option.js +3 -15
- package/dist/cjs/Option.js.map +1 -1
- package/dist/cjs/ParseResult.js +1 -1
- package/dist/cjs/ParseResult.js.map +1 -1
- package/dist/cjs/Schema.js +593 -522
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/TRef.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js +4 -5
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/stm/core.js +5 -5
- package/dist/cjs/internal/stm/core.js.map +1 -1
- package/dist/cjs/internal/stm/entry.js.map +1 -0
- package/dist/cjs/internal/stm/journal.js.map +1 -0
- package/dist/cjs/internal/stm/stm.js +2 -2
- package/dist/cjs/internal/stm/stm.js.map +1 -1
- package/dist/cjs/internal/stm/{stm/stmState.js → stmState.js} +7 -7
- package/dist/cjs/internal/stm/stmState.js.map +1 -0
- package/dist/cjs/internal/stm/{stm/tExit.js → tExit.js} +5 -5
- package/dist/cjs/internal/stm/tExit.js.map +1 -0
- package/dist/cjs/internal/stm/tMap.js.map +1 -1
- package/dist/cjs/internal/stm/tRef.js +2 -2
- package/dist/cjs/internal/stm/tRef.js.map +1 -1
- package/dist/cjs/internal/stm/{stm/tryCommit.js → tryCommit.js} +1 -1
- package/dist/cjs/internal/stm/tryCommit.js.map +1 -0
- package/dist/cjs/internal/stm/txnId.js.map +1 -0
- package/dist/cjs/internal/stm/versioned.js.map +1 -0
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Array.d.ts +6 -6
- package/dist/dts/Array.d.ts.map +1 -1
- package/dist/dts/Context.d.ts +1 -1
- package/dist/dts/Context.d.ts.map +1 -1
- package/dist/dts/FiberHandle.d.ts.map +1 -1
- package/dist/dts/FiberMap.d.ts.map +1 -1
- package/dist/dts/FiberSet.d.ts.map +1 -1
- package/dist/dts/Option.d.ts +3 -42
- package/dist/dts/Option.d.ts.map +1 -1
- package/dist/dts/ParseResult.d.ts.map +1 -1
- package/dist/dts/Schema.d.ts +394 -271
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/dts/internal/stm/entry.d.ts.map +1 -0
- package/dist/dts/internal/stm/journal.d.ts.map +1 -0
- package/dist/dts/internal/stm/stmState.d.ts.map +1 -0
- package/dist/dts/internal/stm/tExit.d.ts.map +1 -0
- package/dist/dts/internal/stm/tryCommit.d.ts.map +1 -0
- package/dist/dts/internal/stm/txnId.d.ts.map +1 -0
- package/dist/dts/internal/stm/versioned.d.ts.map +1 -0
- package/dist/esm/FiberHandle.js +5 -3
- package/dist/esm/FiberHandle.js.map +1 -1
- package/dist/esm/FiberMap.js +5 -3
- package/dist/esm/FiberMap.js.map +1 -1
- package/dist/esm/FiberSet.js +6 -3
- package/dist/esm/FiberSet.js.map +1 -1
- package/dist/esm/JSONSchema.js +7 -7
- package/dist/esm/JSONSchema.js.map +1 -1
- package/dist/esm/Option.js +3 -15
- package/dist/esm/Option.js.map +1 -1
- package/dist/esm/ParseResult.js +1 -1
- package/dist/esm/ParseResult.js.map +1 -1
- package/dist/esm/Schema.js +538 -490
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/TRef.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js +4 -5
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/stm/core.js +5 -5
- package/dist/esm/internal/stm/core.js.map +1 -1
- package/dist/esm/internal/stm/entry.js.map +1 -0
- package/dist/esm/internal/stm/journal.js.map +1 -0
- package/dist/esm/internal/stm/stm.js +2 -2
- package/dist/esm/internal/stm/stm.js.map +1 -1
- package/dist/esm/internal/stm/{stm/stmState.js → stmState.js} +7 -7
- package/dist/esm/internal/stm/stmState.js.map +1 -0
- package/dist/esm/internal/stm/{stm/tExit.js → tExit.js} +5 -5
- package/dist/esm/internal/stm/tExit.js.map +1 -0
- package/dist/esm/internal/stm/tMap.js.map +1 -1
- package/dist/esm/internal/stm/tRef.js +2 -2
- package/dist/esm/internal/stm/tRef.js.map +1 -1
- package/dist/esm/internal/stm/{stm/tryCommit.js → tryCommit.js} +1 -1
- package/dist/esm/internal/stm/tryCommit.js.map +1 -0
- package/dist/esm/internal/stm/txnId.js.map +1 -0
- package/dist/esm/internal/stm/versioned.js.map +1 -0
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/Array.ts +6 -6
- package/src/Context.ts +1 -1
- package/src/FiberHandle.ts +11 -7
- package/src/FiberMap.ts +11 -7
- package/src/FiberSet.ts +9 -7
- package/src/JSONSchema.ts +7 -7
- package/src/Option.ts +7 -46
- package/src/ParseResult.ts +1 -3
- package/src/Schema.ts +1333 -1136
- package/src/TRef.ts +3 -3
- package/src/internal/fiberRuntime.ts +5 -4
- package/src/internal/stm/core.ts +5 -5
- package/src/internal/stm/{stm/entry.ts → entry.ts} +1 -1
- package/src/internal/stm/{stm/journal.ts → journal.ts} +1 -1
- package/src/internal/stm/stm.ts +2 -2
- package/src/internal/stm/{stm/stmState.ts → stmState.ts} +7 -7
- package/src/internal/stm/{stm/tExit.ts → tExit.ts} +7 -7
- package/src/internal/stm/tMap.ts +1 -1
- package/src/internal/stm/tRef.ts +4 -4
- package/src/internal/stm/{stm/tryCommit.ts → tryCommit.ts} +2 -2
- package/src/internal/version.ts +1 -1
- package/dist/cjs/internal/stm/stm/entry.js.map +0 -1
- package/dist/cjs/internal/stm/stm/journal.js.map +0 -1
- package/dist/cjs/internal/stm/stm/opCodes/stm.js +0 -31
- package/dist/cjs/internal/stm/stm/opCodes/stm.js.map +0 -1
- package/dist/cjs/internal/stm/stm/opCodes/stmState.js +0 -13
- package/dist/cjs/internal/stm/stm/opCodes/stmState.js.map +0 -1
- package/dist/cjs/internal/stm/stm/opCodes/strategy.js +0 -13
- package/dist/cjs/internal/stm/stm/opCodes/strategy.js.map +0 -1
- package/dist/cjs/internal/stm/stm/opCodes/tExit.js +0 -17
- package/dist/cjs/internal/stm/stm/opCodes/tExit.js.map +0 -1
- package/dist/cjs/internal/stm/stm/opCodes/tryCommit.js +0 -11
- package/dist/cjs/internal/stm/stm/opCodes/tryCommit.js.map +0 -1
- package/dist/cjs/internal/stm/stm/stmState.js.map +0 -1
- package/dist/cjs/internal/stm/stm/tExit.js.map +0 -1
- package/dist/cjs/internal/stm/stm/tryCommit.js.map +0 -1
- package/dist/cjs/internal/stm/stm/txnId.js.map +0 -1
- package/dist/cjs/internal/stm/stm/versioned.js.map +0 -1
- package/dist/dts/internal/stm/stm/entry.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/journal.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/opCodes/stm.d.ts +0 -2
- package/dist/dts/internal/stm/stm/opCodes/stm.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/opCodes/stmState.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/opCodes/strategy.d.ts +0 -2
- package/dist/dts/internal/stm/stm/opCodes/strategy.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/opCodes/tExit.d.ts +0 -2
- package/dist/dts/internal/stm/stm/opCodes/tExit.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/opCodes/tryCommit.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/stmState.d.ts +0 -2
- package/dist/dts/internal/stm/stm/stmState.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/tExit.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/tryCommit.d.ts +0 -2
- package/dist/dts/internal/stm/stm/tryCommit.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/txnId.d.ts.map +0 -1
- package/dist/dts/internal/stm/stm/versioned.d.ts.map +0 -1
- package/dist/esm/internal/stm/stm/entry.js.map +0 -1
- package/dist/esm/internal/stm/stm/journal.js.map +0 -1
- package/dist/esm/internal/stm/stm/opCodes/stm.js +0 -25
- package/dist/esm/internal/stm/stm/opCodes/stm.js.map +0 -1
- package/dist/esm/internal/stm/stm/opCodes/stmState.js +0 -7
- package/dist/esm/internal/stm/stm/opCodes/stmState.js.map +0 -1
- package/dist/esm/internal/stm/stm/opCodes/strategy.js +0 -7
- package/dist/esm/internal/stm/stm/opCodes/strategy.js.map +0 -1
- package/dist/esm/internal/stm/stm/opCodes/tExit.js +0 -11
- package/dist/esm/internal/stm/stm/opCodes/tExit.js.map +0 -1
- package/dist/esm/internal/stm/stm/opCodes/tryCommit.js +0 -5
- package/dist/esm/internal/stm/stm/opCodes/tryCommit.js.map +0 -1
- package/dist/esm/internal/stm/stm/stmState.js.map +0 -1
- package/dist/esm/internal/stm/stm/tExit.js.map +0 -1
- package/dist/esm/internal/stm/stm/tryCommit.js.map +0 -1
- package/dist/esm/internal/stm/stm/txnId.js.map +0 -1
- package/dist/esm/internal/stm/stm/versioned.js.map +0 -1
- package/src/internal/stm/stm/opCodes/stm.ts +0 -71
- package/src/internal/stm/stm/opCodes/stmState.ts +0 -17
- package/src/internal/stm/stm/opCodes/strategy.ts +0 -17
- package/src/internal/stm/stm/opCodes/tExit.ts +0 -29
- package/src/internal/stm/stm/opCodes/tryCommit.ts +0 -11
- /package/dist/cjs/internal/stm/{stm/entry.js → entry.js} +0 -0
- /package/dist/cjs/internal/stm/{stm/journal.js → journal.js} +0 -0
- /package/dist/cjs/internal/stm/{stm/txnId.js → txnId.js} +0 -0
- /package/dist/cjs/internal/stm/{stm/versioned.js → versioned.js} +0 -0
- /package/dist/dts/internal/stm/{stm/entry.d.ts → entry.d.ts} +0 -0
- /package/dist/dts/internal/stm/{stm/journal.d.ts → journal.d.ts} +0 -0
- /package/dist/dts/internal/stm/{stm/opCodes/stmState.d.ts → stmState.d.ts} +0 -0
- /package/dist/dts/internal/stm/{stm/tExit.d.ts → tExit.d.ts} +0 -0
- /package/dist/dts/internal/stm/{stm/opCodes/tryCommit.d.ts → tryCommit.d.ts} +0 -0
- /package/dist/dts/internal/stm/{stm/txnId.d.ts → txnId.d.ts} +0 -0
- /package/dist/dts/internal/stm/{stm/versioned.d.ts → versioned.d.ts} +0 -0
- /package/dist/esm/internal/stm/{stm/entry.js → entry.js} +0 -0
- /package/dist/esm/internal/stm/{stm/journal.js → journal.js} +0 -0
- /package/dist/esm/internal/stm/{stm/txnId.js → txnId.js} +0 -0
- /package/dist/esm/internal/stm/{stm/versioned.js → versioned.js} +0 -0
- /package/src/internal/stm/{stm/txnId.ts → txnId.ts} +0 -0
- /package/src/internal/stm/{stm/versioned.ts → versioned.ts} +0 -0
package/src/Schema.ts
CHANGED
|
@@ -42,7 +42,6 @@ import type { Pipeable } from "./Pipeable.js"
|
|
|
42
42
|
import { pipeArguments } from "./Pipeable.js"
|
|
43
43
|
import * as Predicate from "./Predicate.js"
|
|
44
44
|
import type * as pretty_ from "./Pretty.js"
|
|
45
|
-
import * as record_ from "./Record.js"
|
|
46
45
|
import * as redacted_ from "./Redacted.js"
|
|
47
46
|
import * as Request from "./Request.js"
|
|
48
47
|
import * as scheduler_ from "./Scheduler.js"
|
|
@@ -93,6 +92,22 @@ export interface Schema<in out A, in out I = A, out R = never> extends Schema.Va
|
|
|
93
92
|
annotations(annotations: Annotations.GenericSchema<A>): Schema<A, I, R>
|
|
94
93
|
}
|
|
95
94
|
|
|
95
|
+
/**
|
|
96
|
+
* @category annotations
|
|
97
|
+
* @since 3.10.0
|
|
98
|
+
*/
|
|
99
|
+
export interface Annotable<Self extends Schema<A, I, R>, A, I = A, R = never> extends Schema<A, I, R> {
|
|
100
|
+
annotations(annotations: Annotations.GenericSchema<A>): Self
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @category annotations
|
|
105
|
+
* @since 3.10.0
|
|
106
|
+
*/
|
|
107
|
+
export interface AnnotableClass<Self extends Schema<A, I, R>, A, I = A, R = never> extends Annotable<Self, A, I, R> {
|
|
108
|
+
new(_: never): Schema.Variance<A, I, R>
|
|
109
|
+
}
|
|
110
|
+
|
|
96
111
|
/**
|
|
97
112
|
* @category model
|
|
98
113
|
* @since 3.10.0
|
|
@@ -103,23 +118,25 @@ export interface SchemaClass<A, I = A, R = never> extends AnnotableClass<SchemaC
|
|
|
103
118
|
* @category constructors
|
|
104
119
|
* @since 3.10.0
|
|
105
120
|
*/
|
|
106
|
-
export
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
121
|
+
export function make<A, I = A, R = never>(ast: AST.AST): SchemaClass<A, I, R> {
|
|
122
|
+
return class SchemaClass {
|
|
123
|
+
[TypeId] = variance
|
|
124
|
+
static ast = ast
|
|
125
|
+
static annotations(annotations: Annotations.GenericSchema<A>) {
|
|
126
|
+
return make<A, I, R>(mergeSchemaAnnotations(this.ast, annotations))
|
|
127
|
+
}
|
|
128
|
+
static pipe() {
|
|
129
|
+
return pipeArguments(this, arguments)
|
|
130
|
+
}
|
|
131
|
+
static toString() {
|
|
132
|
+
return String(ast)
|
|
133
|
+
}
|
|
134
|
+
static Type: A
|
|
135
|
+
static Encoded: I
|
|
136
|
+
static Context: R
|
|
137
|
+
static [TypeId] = variance
|
|
117
138
|
}
|
|
118
|
-
|
|
119
|
-
static Encoded: I
|
|
120
|
-
static Context: R
|
|
121
|
-
static [TypeId] = variance
|
|
122
|
-
})
|
|
139
|
+
}
|
|
123
140
|
|
|
124
141
|
const variance = {
|
|
125
142
|
/* c8 ignore next */
|
|
@@ -277,28 +294,14 @@ export declare namespace Annotable {
|
|
|
277
294
|
| Annotable<any, never, never, unknown>
|
|
278
295
|
}
|
|
279
296
|
|
|
280
|
-
/**
|
|
281
|
-
* @category annotations
|
|
282
|
-
* @since 3.10.0
|
|
283
|
-
*/
|
|
284
|
-
export interface Annotable<Self extends Schema<A, I, R>, A, I = A, R = never> extends Schema<A, I, R> {
|
|
285
|
-
annotations(annotations: Annotations.GenericSchema<A>): Self
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* @category annotations
|
|
290
|
-
* @since 3.10.0
|
|
291
|
-
*/
|
|
292
|
-
export interface AnnotableClass<Self extends Schema<A, I, R>, A, I = A, R = never> extends Annotable<Self, A, I, R> {
|
|
293
|
-
new(_: never): Schema.Variance<A, I, R>
|
|
294
|
-
}
|
|
295
|
-
|
|
296
297
|
/**
|
|
297
298
|
* @since 3.10.0
|
|
298
299
|
*/
|
|
299
|
-
export
|
|
300
|
+
export function asSchema<S extends Schema.All>(
|
|
300
301
|
schema: S
|
|
301
|
-
): Schema<Schema.Type<S>, Schema.Encoded<S>, Schema.Context<S>>
|
|
302
|
+
): Schema<Schema.Type<S>, Schema.Encoded<S>, Schema.Context<S>> {
|
|
303
|
+
return schema as any
|
|
304
|
+
}
|
|
302
305
|
|
|
303
306
|
/**
|
|
304
307
|
* @category formatting
|
|
@@ -668,22 +671,25 @@ export interface Literal<Literals extends array_.NonEmptyReadonlyArray<AST.Liter
|
|
|
668
671
|
readonly literals: Readonly<Literals>
|
|
669
672
|
}
|
|
670
673
|
|
|
671
|
-
|
|
674
|
+
function getDefaultLiteralAST<Literals extends array_.NonEmptyReadonlyArray<AST.LiteralValue>>(
|
|
672
675
|
literals: Literals
|
|
673
|
-
)
|
|
674
|
-
AST.isMembers(literals)
|
|
676
|
+
): AST.AST {
|
|
677
|
+
return AST.isMembers(literals)
|
|
675
678
|
? AST.Union.make(AST.mapMembers(literals, (literal) => new AST.Literal(literal)))
|
|
676
679
|
: new AST.Literal(literals[0])
|
|
680
|
+
}
|
|
677
681
|
|
|
678
|
-
|
|
682
|
+
function makeLiteralClass<Literals extends array_.NonEmptyReadonlyArray<AST.LiteralValue>>(
|
|
679
683
|
literals: Literals,
|
|
680
684
|
ast: AST.AST = getDefaultLiteralAST(literals)
|
|
681
|
-
): Literal<Literals>
|
|
682
|
-
|
|
683
|
-
|
|
685
|
+
): Literal<Literals> {
|
|
686
|
+
return class LiteralClass extends make<Literals[number]>(ast) {
|
|
687
|
+
static override annotations(annotations: Annotations.Schema<Literals[number]>): Literal<Literals> {
|
|
688
|
+
return makeLiteralClass(this.literals, mergeSchemaAnnotations(this.ast, annotations))
|
|
689
|
+
}
|
|
690
|
+
static literals = [...literals] as Literals
|
|
684
691
|
}
|
|
685
|
-
|
|
686
|
-
})
|
|
692
|
+
}
|
|
687
693
|
|
|
688
694
|
/**
|
|
689
695
|
* @category constructors
|
|
@@ -695,10 +701,10 @@ export function Literal<Literals extends array_.NonEmptyReadonlyArray<AST.Litera
|
|
|
695
701
|
export function Literal(): Never
|
|
696
702
|
export function Literal<Literals extends ReadonlyArray<AST.LiteralValue>>(
|
|
697
703
|
...literals: Literals
|
|
698
|
-
):
|
|
704
|
+
): SchemaClass<Literals[number]>
|
|
699
705
|
export function Literal<Literals extends ReadonlyArray<AST.LiteralValue>>(
|
|
700
706
|
...literals: Literals
|
|
701
|
-
):
|
|
707
|
+
): SchemaClass<Literals[number]> | Never {
|
|
702
708
|
return array_.isNonEmptyReadonlyArray(literals) ? makeLiteralClass(literals) : Never
|
|
703
709
|
}
|
|
704
710
|
|
|
@@ -938,11 +944,11 @@ export const TemplateLiteralParser = <Params extends array_.NonEmptyReadonlyArra
|
|
|
938
944
|
}
|
|
939
945
|
return class TemplateLiteralParserClass extends transformOrFail(from, to, {
|
|
940
946
|
strict: false,
|
|
941
|
-
decode: (
|
|
942
|
-
const match = re.exec(
|
|
947
|
+
decode: (i, _, ast) => {
|
|
948
|
+
const match = re.exec(i)
|
|
943
949
|
return match
|
|
944
950
|
? ParseResult.succeed(match.slice(1, params.length + 1))
|
|
945
|
-
: ParseResult.fail(new ParseResult.Type(ast,
|
|
951
|
+
: ParseResult.fail(new ParseResult.Type(ast, i, `${re.source}: no match for ${JSON.stringify(i)}`))
|
|
946
952
|
},
|
|
947
953
|
encode: (tuple) => ParseResult.succeed(tuple.join(""))
|
|
948
954
|
}) {
|
|
@@ -986,7 +992,8 @@ const declareConstructor = <
|
|
|
986
992
|
},
|
|
987
993
|
annotations?: Annotations.Schema<A, TypeParameters>
|
|
988
994
|
): SchemaClass<A, I, Schema.Context<TypeParameters[number]>> =>
|
|
989
|
-
|
|
995
|
+
makeDeclareClass(
|
|
996
|
+
typeParameters,
|
|
990
997
|
new AST.Declaration(
|
|
991
998
|
typeParameters.map((tp) => tp.ast),
|
|
992
999
|
(...typeParameters) => options.decode(...typeParameters.map(make) as any),
|
|
@@ -1002,7 +1009,46 @@ const declarePrimitive = <A>(
|
|
|
1002
1009
|
const decodeUnknown = () => (input: unknown, _: ParseOptions, ast: AST.Declaration) =>
|
|
1003
1010
|
is(input) ? ParseResult.succeed(input) : ParseResult.fail(new ParseResult.Type(ast, input))
|
|
1004
1011
|
const encodeUnknown = decodeUnknown
|
|
1005
|
-
return
|
|
1012
|
+
return makeDeclareClass([], new AST.Declaration([], decodeUnknown, encodeUnknown, toASTAnnotations(annotations)))
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
/**
|
|
1016
|
+
* @category api interface
|
|
1017
|
+
* @since 3.13.3
|
|
1018
|
+
*/
|
|
1019
|
+
export interface declare<
|
|
1020
|
+
A,
|
|
1021
|
+
I = A,
|
|
1022
|
+
P extends ReadonlyArray<Schema.All> = readonly [],
|
|
1023
|
+
R = Schema.Context<P[number]>
|
|
1024
|
+
> extends AnnotableClass<declare<A, I, P, R>, A, I, R> {
|
|
1025
|
+
readonly typeParameters: Readonly<P>
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
/**
|
|
1029
|
+
* @category api interface
|
|
1030
|
+
* @since 3.13.3
|
|
1031
|
+
*/
|
|
1032
|
+
export interface AnnotableDeclare<
|
|
1033
|
+
Self extends declare<A, I, P, R>,
|
|
1034
|
+
A,
|
|
1035
|
+
I = A,
|
|
1036
|
+
P extends ReadonlyArray<Schema.All> = readonly [],
|
|
1037
|
+
R = Schema.Context<P[number]>
|
|
1038
|
+
> extends declare<A, I, P, R> {
|
|
1039
|
+
annotations(annotations: Annotations.Schema<A>): Self
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
function makeDeclareClass<P extends ReadonlyArray<Schema.All>, A, I, R>(
|
|
1043
|
+
typeParameters: P,
|
|
1044
|
+
ast: AST.AST
|
|
1045
|
+
): declare<A, I, P, R> {
|
|
1046
|
+
return class DeclareClass extends make<A, I, R>(ast) {
|
|
1047
|
+
static override annotations(annotations: Annotations.Schema<A>): declare<A, I, P, R> {
|
|
1048
|
+
return makeDeclareClass(this.typeParameters, mergeSchemaAnnotations(this.ast, annotations))
|
|
1049
|
+
}
|
|
1050
|
+
static typeParameters = [...typeParameters] as any as P
|
|
1051
|
+
}
|
|
1006
1052
|
}
|
|
1007
1053
|
|
|
1008
1054
|
/**
|
|
@@ -1020,7 +1066,7 @@ export const declare: {
|
|
|
1020
1066
|
* @category constructors
|
|
1021
1067
|
* @since 3.10.0
|
|
1022
1068
|
*/
|
|
1023
|
-
<A>(is: (input: unknown) => input is A, annotations?: Annotations.Schema<A>):
|
|
1069
|
+
<A>(is: (input: unknown) => input is A, annotations?: Annotations.Schema<A>): declare<A>
|
|
1024
1070
|
/**
|
|
1025
1071
|
* The constraint `R extends Schema.Context<P[number]>` enforces dependencies solely from `typeParameters`.
|
|
1026
1072
|
* This ensures that when you call `Schema.to` or `Schema.from`, you receive a schema with a `never` context.
|
|
@@ -1028,7 +1074,7 @@ export const declare: {
|
|
|
1028
1074
|
* @category constructors
|
|
1029
1075
|
* @since 3.10.0
|
|
1030
1076
|
*/
|
|
1031
|
-
<const P extends ReadonlyArray<Schema.All
|
|
1077
|
+
<A, I, const P extends ReadonlyArray<Schema.All>>(
|
|
1032
1078
|
typeParameters: P,
|
|
1033
1079
|
options: {
|
|
1034
1080
|
readonly decode: (
|
|
@@ -1047,7 +1093,7 @@ export const declare: {
|
|
|
1047
1093
|
) => Effect.Effect<I, ParseResult.ParseIssue, never>
|
|
1048
1094
|
},
|
|
1049
1095
|
annotations?: Annotations.Schema<A, { readonly [K in keyof P]: Schema.Type<P[K]> }>
|
|
1050
|
-
):
|
|
1096
|
+
): declare<A, I, P>
|
|
1051
1097
|
} = function() {
|
|
1052
1098
|
if (Array.isArray(arguments[0])) {
|
|
1053
1099
|
const typeParameters = arguments[0]
|
|
@@ -1074,8 +1120,9 @@ export const fromBrand = <C extends Brand<string | symbol>, A extends Brand.Unbr
|
|
|
1074
1120
|
constructor: Brand.Constructor<C>,
|
|
1075
1121
|
annotations?: Annotations.Filter<C, A>
|
|
1076
1122
|
) =>
|
|
1077
|
-
<I, R>(self: Schema<A, I, R>): BrandSchema<A & C, I, R> =>
|
|
1078
|
-
|
|
1123
|
+
<I, R>(self: Schema<A, I, R>): BrandSchema<A & C, I, R> => {
|
|
1124
|
+
const out = makeBrandClass(
|
|
1125
|
+
self,
|
|
1079
1126
|
new AST.Refinement(
|
|
1080
1127
|
self.ast,
|
|
1081
1128
|
function predicate(a: A, _: ParseOptions, ast: AST.AST): option_.Option<ParseResult.ParseIssue> {
|
|
@@ -1091,6 +1138,8 @@ export const fromBrand = <C extends Brand<string | symbol>, A extends Brand.Unbr
|
|
|
1091
1138
|
})
|
|
1092
1139
|
)
|
|
1093
1140
|
)
|
|
1141
|
+
return out as any
|
|
1142
|
+
}
|
|
1094
1143
|
|
|
1095
1144
|
/**
|
|
1096
1145
|
* @category schema id
|
|
@@ -1102,7 +1151,7 @@ export const InstanceOfSchemaId: unique symbol = Symbol.for("effect/SchemaId/Ins
|
|
|
1102
1151
|
* @category api interface
|
|
1103
1152
|
* @since 3.10.0
|
|
1104
1153
|
*/
|
|
1105
|
-
export interface instanceOf<A> extends
|
|
1154
|
+
export interface instanceOf<A> extends AnnotableDeclare<instanceOf<A>, A> {}
|
|
1106
1155
|
|
|
1107
1156
|
/**
|
|
1108
1157
|
* @category constructors
|
|
@@ -1220,26 +1269,27 @@ export interface Union<Members extends ReadonlyArray<Schema.All>> extends
|
|
|
1220
1269
|
>
|
|
1221
1270
|
{
|
|
1222
1271
|
readonly members: Readonly<Members>
|
|
1223
|
-
annotations(annotations: Annotations.Schema<Schema.Type<Members[number]>>): Union<Members>
|
|
1224
1272
|
}
|
|
1225
1273
|
|
|
1226
1274
|
const getDefaultUnionAST = <Members extends AST.Members<Schema.All>>(members: Members): AST.AST =>
|
|
1227
1275
|
AST.Union.make(members.map((m) => m.ast))
|
|
1228
1276
|
|
|
1229
|
-
|
|
1277
|
+
function makeUnionClass<Members extends AST.Members<Schema.All>>(
|
|
1230
1278
|
members: Members,
|
|
1231
1279
|
ast: AST.AST = getDefaultUnionAST(members)
|
|
1232
|
-
): Union<
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1280
|
+
): Union<Members> {
|
|
1281
|
+
return class UnionClass extends make<
|
|
1282
|
+
Schema.Type<Members[number]>,
|
|
1283
|
+
Schema.Encoded<Members[number]>,
|
|
1284
|
+
Schema.Context<Members[number]>
|
|
1285
|
+
>(ast) {
|
|
1286
|
+
static override annotations(annotations: Annotations.Schema<Schema.Type<Members[number]>>): Union<Members> {
|
|
1287
|
+
return makeUnionClass(this.members, mergeSchemaAnnotations(this.ast, annotations))
|
|
1288
|
+
}
|
|
1240
1289
|
|
|
1241
|
-
|
|
1242
|
-
}
|
|
1290
|
+
static members = [...members]
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1243
1293
|
|
|
1244
1294
|
/**
|
|
1245
1295
|
* @category combinators
|
|
@@ -1454,25 +1504,27 @@ const getDefaultTupleTypeAST = <Elements extends TupleType.Elements, Rest extend
|
|
|
1454
1504
|
true
|
|
1455
1505
|
)
|
|
1456
1506
|
|
|
1457
|
-
|
|
1507
|
+
function makeTupleTypeClass<Elements extends TupleType.Elements, Rest extends TupleType.Rest>(
|
|
1458
1508
|
elements: Elements,
|
|
1459
1509
|
rest: Rest,
|
|
1460
1510
|
ast: AST.AST = getDefaultTupleTypeAST(elements, rest)
|
|
1461
|
-
)
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
>
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1511
|
+
) {
|
|
1512
|
+
return class TupleTypeClass extends make<
|
|
1513
|
+
TupleType.Type<Elements, Rest>,
|
|
1514
|
+
TupleType.Encoded<Elements, Rest>,
|
|
1515
|
+
Schema.Context<Elements[number]> | Schema.Context<Rest[number]>
|
|
1516
|
+
>(ast) {
|
|
1517
|
+
static override annotations(
|
|
1518
|
+
annotations: Annotations.Schema<TupleType.Type<Elements, Rest>>
|
|
1519
|
+
): TupleType<Elements, Rest> {
|
|
1520
|
+
return makeTupleTypeClass(this.elements, this.rest, mergeSchemaAnnotations(this.ast, annotations))
|
|
1521
|
+
}
|
|
1471
1522
|
|
|
1472
|
-
|
|
1523
|
+
static elements = [...elements] as any as Elements
|
|
1473
1524
|
|
|
1474
|
-
|
|
1475
|
-
}
|
|
1525
|
+
static rest = [...rest] as any as Rest
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1476
1528
|
|
|
1477
1529
|
/**
|
|
1478
1530
|
* @category api interface
|
|
@@ -1482,6 +1534,22 @@ export interface Tuple<Elements extends TupleType.Elements> extends TupleType<El
|
|
|
1482
1534
|
annotations(annotations: Annotations.Schema<TupleType.Type<Elements, []>>): Tuple<Elements>
|
|
1483
1535
|
}
|
|
1484
1536
|
|
|
1537
|
+
/**
|
|
1538
|
+
* @category api interface
|
|
1539
|
+
* @since 3.13.3
|
|
1540
|
+
*/
|
|
1541
|
+
export interface Tuple2<Fst extends Schema.Any, Snd extends Schema.Any> extends
|
|
1542
|
+
AnnotableClass<
|
|
1543
|
+
Tuple2<Fst, Snd>,
|
|
1544
|
+
readonly [Schema.Type<Fst>, Schema.Type<Snd>],
|
|
1545
|
+
readonly [Schema.Encoded<Fst>, Schema.Encoded<Snd>],
|
|
1546
|
+
Schema.Context<Fst> | Schema.Context<Snd>
|
|
1547
|
+
>
|
|
1548
|
+
{
|
|
1549
|
+
readonly elements: readonly [Fst, Snd]
|
|
1550
|
+
readonly rest: readonly []
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1485
1553
|
/**
|
|
1486
1554
|
* @category constructors
|
|
1487
1555
|
* @since 3.10.0
|
|
@@ -1490,6 +1558,7 @@ export function Tuple<
|
|
|
1490
1558
|
const Elements extends TupleType.Elements,
|
|
1491
1559
|
Rest extends array_.NonEmptyReadonlyArray<TupleType.Rest[number]>
|
|
1492
1560
|
>(elements: Elements, ...rest: Rest): TupleType<Elements, Rest>
|
|
1561
|
+
export function Tuple<Fst extends Schema.Any, Snd extends Schema.Any>(fst: Fst, snd: Snd): Tuple2<Fst, Snd>
|
|
1493
1562
|
export function Tuple<Elements extends TupleType.Elements>(...elements: Elements): Tuple<Elements>
|
|
1494
1563
|
export function Tuple(...args: ReadonlyArray<any>): any {
|
|
1495
1564
|
return Array.isArray(args[0])
|
|
@@ -1506,16 +1575,18 @@ export interface Array$<Value extends Schema.Any> extends TupleType<[], [Value]>
|
|
|
1506
1575
|
annotations(annotations: Annotations.Schema<TupleType.Type<[], [Value]>>): Array$<Value>
|
|
1507
1576
|
}
|
|
1508
1577
|
|
|
1509
|
-
|
|
1578
|
+
function makeArrayClass<Value extends Schema.Any>(
|
|
1510
1579
|
value: Value,
|
|
1511
1580
|
ast?: AST.AST
|
|
1512
|
-
): Array$<Value>
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1581
|
+
): Array$<Value> {
|
|
1582
|
+
return class ArrayClass extends makeTupleTypeClass<[], [Value]>([], [value], ast) {
|
|
1583
|
+
static override annotations(annotations: Annotations.Schema<TupleType.Type<[], [Value]>>) {
|
|
1584
|
+
return makeArrayClass(this.value, mergeSchemaAnnotations(this.ast, annotations))
|
|
1585
|
+
}
|
|
1516
1586
|
|
|
1517
|
-
|
|
1518
|
-
}
|
|
1587
|
+
static value = value
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1519
1590
|
|
|
1520
1591
|
const Array$ = <Value extends Schema.Any>(value: Value): Array$<Value> => makeArrayClass(value)
|
|
1521
1592
|
|
|
@@ -1531,83 +1602,77 @@ export {
|
|
|
1531
1602
|
* @category api interface
|
|
1532
1603
|
* @since 3.10.0
|
|
1533
1604
|
*/
|
|
1534
|
-
export interface NonEmptyArray<Value extends Schema.Any> extends
|
|
1605
|
+
export interface NonEmptyArray<Value extends Schema.Any> extends
|
|
1606
|
+
AnnotableClass<
|
|
1607
|
+
NonEmptyArray<Value>,
|
|
1608
|
+
array_.NonEmptyReadonlyArray<Schema.Type<Value>>,
|
|
1609
|
+
array_.NonEmptyReadonlyArray<Schema.Encoded<Value>>,
|
|
1610
|
+
Schema.Context<Value>
|
|
1611
|
+
>
|
|
1612
|
+
{
|
|
1613
|
+
readonly elements: readonly [Value]
|
|
1614
|
+
readonly rest: readonly [Value]
|
|
1535
1615
|
readonly value: Value
|
|
1536
|
-
annotations(annotations: Annotations.Schema<TupleType.Type<[Value], [Value]>>): NonEmptyArray<Value>
|
|
1537
1616
|
}
|
|
1538
1617
|
|
|
1539
|
-
|
|
1618
|
+
function makeNonEmptyArrayClass<Value extends Schema.Any>(
|
|
1540
1619
|
value: Value,
|
|
1541
1620
|
ast?: AST.AST
|
|
1542
|
-
)
|
|
1543
|
-
Value
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
}
|
|
1621
|
+
) {
|
|
1622
|
+
return class NonEmptyArrayClass extends makeTupleTypeClass<[Value], [Value]>([value], [value], ast) {
|
|
1623
|
+
static override annotations(annotations: Annotations.Schema<TupleType.Type<[Value], [Value]>>) {
|
|
1624
|
+
return makeNonEmptyArrayClass(this.value, mergeSchemaAnnotations(this.ast, annotations))
|
|
1625
|
+
}
|
|
1548
1626
|
|
|
1549
|
-
|
|
1550
|
-
}
|
|
1627
|
+
static value = value
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1551
1630
|
|
|
1552
1631
|
/**
|
|
1553
1632
|
* @category constructors
|
|
1554
1633
|
* @since 3.10.0
|
|
1555
1634
|
*/
|
|
1556
1635
|
export const NonEmptyArray = <Value extends Schema.Any>(value: Value): NonEmptyArray<Value> =>
|
|
1557
|
-
makeNonEmptyArrayClass(value)
|
|
1636
|
+
makeNonEmptyArrayClass(value) as any
|
|
1558
1637
|
|
|
1559
1638
|
/**
|
|
1560
1639
|
* @category api interface
|
|
1561
1640
|
* @since 3.10.0
|
|
1562
1641
|
*/
|
|
1563
|
-
export interface ArrayEnsure<Value extends Schema.Any>
|
|
1564
|
-
|
|
1565
|
-
ArrayEnsure<Value>,
|
|
1566
|
-
ReadonlyArray<Schema.Type<Value>>,
|
|
1567
|
-
Schema.Encoded<Value> | ReadonlyArray<Schema.Encoded<Value>>,
|
|
1568
|
-
Schema.Context<Value>
|
|
1569
|
-
>
|
|
1642
|
+
export interface ArrayEnsure<Value extends Schema.Any>
|
|
1643
|
+
extends transform<Union<[Value, Array$<Value>]>, Array$<SchemaClass<Schema.Type<Value>>>>
|
|
1570
1644
|
{}
|
|
1571
1645
|
|
|
1572
1646
|
/**
|
|
1573
1647
|
* @category constructors
|
|
1574
1648
|
* @since 3.10.0
|
|
1575
1649
|
*/
|
|
1576
|
-
export
|
|
1577
|
-
|
|
1578
|
-
return class ArrayEnsureClass extends transform(Union(value_, Array$(value_)), Array$(typeSchema(value_)), {
|
|
1650
|
+
export function ArrayEnsure<Value extends Schema.Any>(value: Value): ArrayEnsure<Value> {
|
|
1651
|
+
return transform(Union(value, Array$(value)), Array$(typeSchema(asSchema(value))), {
|
|
1579
1652
|
strict: true,
|
|
1580
|
-
decode: array_.ensure,
|
|
1581
|
-
encode: (
|
|
1582
|
-
})
|
|
1653
|
+
decode: (i) => array_.ensure(i),
|
|
1654
|
+
encode: (a) => a.length === 1 ? a[0] : a
|
|
1655
|
+
})
|
|
1583
1656
|
}
|
|
1584
1657
|
|
|
1585
1658
|
/**
|
|
1586
1659
|
* @category api interface
|
|
1587
1660
|
* @since 3.10.0
|
|
1588
1661
|
*/
|
|
1589
|
-
export interface NonEmptyArrayEnsure<Value extends Schema.Any>
|
|
1590
|
-
|
|
1591
|
-
NonEmptyArrayEnsure<Value>,
|
|
1592
|
-
array_.NonEmptyReadonlyArray<Schema.Type<Value>>,
|
|
1593
|
-
Schema.Encoded<Value> | array_.NonEmptyReadonlyArray<Schema.Encoded<Value>>,
|
|
1594
|
-
Schema.Context<Value>
|
|
1595
|
-
>
|
|
1662
|
+
export interface NonEmptyArrayEnsure<Value extends Schema.Any>
|
|
1663
|
+
extends transform<Union<[Value, NonEmptyArray<Value>]>, NonEmptyArray<SchemaClass<Schema.Type<Value>>>>
|
|
1596
1664
|
{}
|
|
1597
1665
|
|
|
1598
1666
|
/**
|
|
1599
1667
|
* @category constructors
|
|
1600
1668
|
* @since 3.10.0
|
|
1601
1669
|
*/
|
|
1602
|
-
export
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
encode: (arr) => arr.length === 1 ? arr[0] : arr
|
|
1609
|
-
})
|
|
1610
|
-
{}
|
|
1670
|
+
export function NonEmptyArrayEnsure<Value extends Schema.Any>(value: Value): NonEmptyArrayEnsure<Value> {
|
|
1671
|
+
return transform(Union(value, NonEmptyArray(value)), NonEmptyArray(typeSchema(asSchema(value))), {
|
|
1672
|
+
strict: true,
|
|
1673
|
+
decode: (i) => array_.isNonEmptyReadonlyArray(i) ? i : array_.of(i),
|
|
1674
|
+
encode: (a) => a.length === 1 ? a[0] : a
|
|
1675
|
+
})
|
|
1611
1676
|
}
|
|
1612
1677
|
|
|
1613
1678
|
/**
|
|
@@ -2572,45 +2637,47 @@ export declare namespace Struct {
|
|
|
2572
2637
|
| PropertySignature.All
|
|
2573
2638
|
}
|
|
2574
2639
|
|
|
2575
|
-
type
|
|
2576
|
-
|
|
2577
|
-
|
|
2640
|
+
type OptionalEncodedPropertySignature =
|
|
2641
|
+
| PropertySignature<PropertySignature.Token, any, PropertyKey, "?:", any, boolean, unknown>
|
|
2642
|
+
| PropertySignature<PropertySignature.Token, any, PropertyKey, "?:", never, boolean, unknown>
|
|
2643
|
+
| PropertySignature<PropertySignature.Token, never, PropertyKey, "?:", any, boolean, unknown>
|
|
2644
|
+
| PropertySignature<PropertySignature.Token, never, PropertyKey, "?:", never, boolean, unknown>
|
|
2578
2645
|
|
|
2579
|
-
type
|
|
2580
|
-
[K in keyof Fields]: Fields[K] extends
|
|
2581
|
-
| PropertySignature<PropertySignature.Token, any, PropertyKey, "?:", any, boolean, unknown>
|
|
2582
|
-
| PropertySignature<PropertySignature.Token, any, PropertyKey, "?:", never, boolean, unknown>
|
|
2583
|
-
| PropertySignature<PropertySignature.Token, never, PropertyKey, "?:", any, boolean, unknown>
|
|
2584
|
-
| PropertySignature<PropertySignature.Token, never, PropertyKey, "?:", never, boolean, unknown> ? K
|
|
2646
|
+
type EncodedOptionalKeys<Fields extends Struct.Fields> = {
|
|
2647
|
+
[K in keyof Fields]: Fields[K] extends OptionalEncodedPropertySignature ? K
|
|
2585
2648
|
: never
|
|
2586
2649
|
}[keyof Fields]
|
|
2587
2650
|
|
|
2588
|
-
type
|
|
2589
|
-
[K in keyof Fields]: Fields[K] extends OptionalPropertySignature ? K : never
|
|
2590
|
-
}[keyof Fields]
|
|
2591
|
-
|
|
2592
|
-
type OptionalPropertySignature =
|
|
2651
|
+
type OptionalTypePropertySignature =
|
|
2593
2652
|
| PropertySignature<"?:", any, PropertyKey, PropertySignature.Token, any, boolean, unknown>
|
|
2594
2653
|
| PropertySignature<"?:", any, PropertyKey, PropertySignature.Token, never, boolean, unknown>
|
|
2595
2654
|
| PropertySignature<"?:", never, PropertyKey, PropertySignature.Token, any, boolean, unknown>
|
|
2596
2655
|
| PropertySignature<"?:", never, PropertyKey, PropertySignature.Token, never, boolean, unknown>
|
|
2597
2656
|
|
|
2657
|
+
// type TypeOptionalKeys<Fields extends Struct.Fields> = {
|
|
2658
|
+
// [K in keyof Fields]: Fields[K] extends OptionalTypePropertySignature ? K : never
|
|
2659
|
+
// }[keyof Fields]
|
|
2660
|
+
|
|
2598
2661
|
/**
|
|
2599
2662
|
* @since 3.10.0
|
|
2600
2663
|
*/
|
|
2601
2664
|
export type Type<F extends Fields> = Types.UnionToIntersection<
|
|
2602
2665
|
{
|
|
2603
|
-
[K in keyof F]: F[K] extends
|
|
2666
|
+
[K in keyof F]: F[K] extends OptionalTypePropertySignature ? { readonly [H in K]?: Schema.Type<F[H]> } :
|
|
2604
2667
|
{ readonly [h in K]: Schema.Type<F[h]> }
|
|
2605
2668
|
}[keyof F]
|
|
2606
2669
|
> extends infer Q ? Q : never
|
|
2607
2670
|
|
|
2671
|
+
type Key<F extends Fields, K extends keyof F> = [K] extends [never] ? never :
|
|
2672
|
+
F[K] extends PropertySignature.All<infer Key> ? [Key] extends [never] ? K : Key :
|
|
2673
|
+
K
|
|
2674
|
+
|
|
2608
2675
|
/**
|
|
2609
2676
|
* @since 3.10.0
|
|
2610
2677
|
*/
|
|
2611
2678
|
export type Encoded<F extends Fields> =
|
|
2612
|
-
& { readonly [K in Exclude<keyof F,
|
|
2613
|
-
& { readonly [K in
|
|
2679
|
+
& { readonly [K in Exclude<keyof F, EncodedOptionalKeys<F>> as Key<F, K>]: Schema.Encoded<F[K]> }
|
|
2680
|
+
& { readonly [K in EncodedOptionalKeys<F> as Key<F, K>]?: Schema.Encoded<F[K]> }
|
|
2614
2681
|
|
|
2615
2682
|
/**
|
|
2616
2683
|
* @since 3.10.0
|
|
@@ -2628,7 +2695,7 @@ export declare namespace Struct {
|
|
|
2628
2695
|
*/
|
|
2629
2696
|
export type Constructor<F extends Fields> = Types.UnionToIntersection<
|
|
2630
2697
|
{
|
|
2631
|
-
[K in keyof F]: F[K] extends
|
|
2698
|
+
[K in keyof F]: F[K] extends OptionalTypePropertySignature ? { readonly [H in K]?: Schema.Type<F[H]> } :
|
|
2632
2699
|
F[K] extends PropertySignatureWithDefault ? { readonly [H in K]?: Schema.Type<F[H]> } :
|
|
2633
2700
|
{ readonly [h in K]: Schema.Type<F[h]> }
|
|
2634
2701
|
}[keyof F]
|
|
@@ -3089,7 +3156,7 @@ export const pluck: {
|
|
|
3089
3156
|
* @category struct transformations
|
|
3090
3157
|
* @since 3.10.0
|
|
3091
3158
|
*/
|
|
3092
|
-
<A, I, K extends keyof A & keyof I>(key: K): <R>(schema: Schema<A, I, R>) =>
|
|
3159
|
+
<A, I, K extends keyof A & keyof I>(key: K): <R>(schema: Schema<A, I, R>) => SchemaClass<A[K], Simplify<Pick<I, K>>, R>
|
|
3093
3160
|
/**
|
|
3094
3161
|
* Given a schema `Schema<A, I, R>` and a key `key: K`, this function extracts a specific field from the `A` type,
|
|
3095
3162
|
* producing a new schema that represents a transformation from the `{ readonly [key]: I[K] }` type to `A[K]`.
|
|
@@ -3120,7 +3187,7 @@ export const pluck: {
|
|
|
3120
3187
|
* @category struct transformations
|
|
3121
3188
|
* @since 3.10.0
|
|
3122
3189
|
*/
|
|
3123
|
-
<A, I, R, K extends keyof A & keyof I>(schema: Schema<A, I, R>, key: K):
|
|
3190
|
+
<A, I, R, K extends keyof A & keyof I>(schema: Schema<A, I, R>, key: K): SchemaClass<A[K], Simplify<Pick<I, K>>, R>
|
|
3124
3191
|
} = dual(
|
|
3125
3192
|
2,
|
|
3126
3193
|
<A, I, R, K extends keyof A & keyof I>(
|
|
@@ -3219,15 +3286,16 @@ export const pluck: {
|
|
|
3219
3286
|
* @since 3.10.0
|
|
3220
3287
|
*/
|
|
3221
3288
|
R>(ps.isOptional ? AST.orUndefined(ps.type) : ps.type)
|
|
3222
|
-
|
|
3289
|
+
const out = transform(
|
|
3223
3290
|
schema.pipe(pick(key)),
|
|
3224
3291
|
value,
|
|
3225
3292
|
{
|
|
3226
3293
|
strict: true,
|
|
3227
|
-
decode: (
|
|
3228
|
-
encode: (
|
|
3294
|
+
decode: (i) => i[key],
|
|
3295
|
+
encode: (a) => ps.isOptional && a === undefined ? {} : { [key]: a } as any
|
|
3229
3296
|
}
|
|
3230
3297
|
)
|
|
3298
|
+
return out
|
|
3231
3299
|
}
|
|
3232
3300
|
)
|
|
3233
3301
|
|
|
@@ -3248,20 +3316,26 @@ export interface BrandSchema<A extends Brand<any>, I = A, R = never>
|
|
|
3248
3316
|
export interface brand<S extends Schema.Any, B extends string | symbol>
|
|
3249
3317
|
extends BrandSchema<Schema.Type<S> & Brand<B>, Schema.Encoded<S>, Schema.Context<S>>
|
|
3250
3318
|
{
|
|
3319
|
+
readonly from: S
|
|
3251
3320
|
annotations(annotations: Annotations.Schema<Schema.Type<S> & Brand<B>>): brand<S, B>
|
|
3252
3321
|
}
|
|
3253
3322
|
|
|
3254
|
-
|
|
3323
|
+
function makeBrandClass<S extends Schema.Any, B extends string | symbol>(
|
|
3324
|
+
from: S,
|
|
3255
3325
|
ast: AST.AST
|
|
3256
|
-
): brand<S, B>
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3326
|
+
): brand<S, B> {
|
|
3327
|
+
return class BrandClass extends make<Schema.Type<S> & Brand<B>, Schema.Encoded<S>, Schema.Context<S>>(ast) {
|
|
3328
|
+
static override annotations(annotations: Annotations.Schema<Schema.Type<S> & Brand<B>>): brand<S, B> {
|
|
3329
|
+
return makeBrandClass(this.from, mergeSchemaAnnotations(this.ast, annotations))
|
|
3330
|
+
}
|
|
3331
|
+
|
|
3332
|
+
static make = (a: Brand.Unbranded<Schema.Type<S> & Brand<B>>, options?: MakeOptions): Schema.Type<S> & Brand<B> => {
|
|
3333
|
+
return getDisableValidationMakeOption(options) ? a : ParseResult.validateSync(this)(a)
|
|
3334
|
+
}
|
|
3260
3335
|
|
|
3261
|
-
|
|
3262
|
-
return getDisableValidationMakeOption(options) ? a : ParseResult.validateSync(this)(a)
|
|
3336
|
+
static from = from
|
|
3263
3337
|
}
|
|
3264
|
-
}
|
|
3338
|
+
}
|
|
3265
3339
|
|
|
3266
3340
|
/**
|
|
3267
3341
|
* Returns a nominal branded schema by applying a brand to a given schema.
|
|
@@ -3300,7 +3374,7 @@ export const brand = <S extends Schema.AnyNoContext, B extends string | symbol>(
|
|
|
3300
3374
|
...annotations
|
|
3301
3375
|
})
|
|
3302
3376
|
)
|
|
3303
|
-
return makeBrandClass(ast)
|
|
3377
|
+
return makeBrandClass(self, ast)
|
|
3304
3378
|
}
|
|
3305
3379
|
|
|
3306
3380
|
/**
|
|
@@ -3700,55 +3774,55 @@ export const compose: {
|
|
|
3700
3774
|
* @category combinators
|
|
3701
3775
|
* @since 3.10.0
|
|
3702
3776
|
*/
|
|
3703
|
-
<
|
|
3777
|
+
<To extends Schema.Any, From extends Schema.Any, C extends Schema.Type<From>>(to: To & Schema<Schema.Type<To>, C, Schema.Context<To>>): (from: From) => transform<From, To>
|
|
3704
3778
|
/**
|
|
3705
3779
|
* @category combinators
|
|
3706
3780
|
* @since 3.10.0
|
|
3707
3781
|
*/
|
|
3708
|
-
<
|
|
3782
|
+
<To extends Schema.Any>(to: To): <From extends Schema.Any, B extends Schema.Encoded<To>>(
|
|
3783
|
+
from: From & Schema<B, Schema.Encoded<From>, Schema.Context<From>>
|
|
3784
|
+
) => transform<From, To>
|
|
3709
3785
|
/**
|
|
3710
3786
|
* @category combinators
|
|
3711
3787
|
* @since 3.10.0
|
|
3712
3788
|
*/
|
|
3713
|
-
<
|
|
3789
|
+
<To extends Schema.Any>(to: To, options?: { readonly strict: true }): <From extends Schema.Any>(
|
|
3790
|
+
from: From & Schema<Schema.Encoded<To>, Schema.Encoded<From>, Schema.Context<From>>
|
|
3791
|
+
) => transform<From, To>
|
|
3714
3792
|
/**
|
|
3715
3793
|
* @category combinators
|
|
3716
3794
|
* @since 3.10.0
|
|
3717
3795
|
*/
|
|
3718
|
-
<
|
|
3796
|
+
<To extends Schema.Any>(to: To, options: { readonly strict: false }): <From extends Schema.Any>(from: From) => transform<From, To>
|
|
3719
3797
|
|
|
3720
3798
|
/**
|
|
3721
3799
|
* @category combinators
|
|
3722
3800
|
* @since 3.10.0
|
|
3723
3801
|
*/
|
|
3724
|
-
<
|
|
3802
|
+
<From extends Schema.Any, To extends Schema.Any, C extends Schema.Type<From>>(from: From, to: To & Schema<Schema.Type<To>, C, Schema.Context<To>>): transform<From, To>
|
|
3725
3803
|
/**
|
|
3726
3804
|
* @category combinators
|
|
3727
3805
|
* @since 3.10.0
|
|
3728
3806
|
*/
|
|
3729
|
-
<
|
|
3807
|
+
<From extends Schema.Any, B extends Schema.Encoded<To>, To extends Schema.Any>(from: From & Schema<B, Schema.Encoded<From>, Schema.Context<From>>, to: To): transform<From, To>
|
|
3730
3808
|
/**
|
|
3731
3809
|
* @category combinators
|
|
3732
3810
|
* @since 3.10.0
|
|
3733
3811
|
*/
|
|
3734
|
-
<
|
|
3735
|
-
from: Schema<
|
|
3736
|
-
to:
|
|
3812
|
+
<From extends Schema.Any, To extends Schema.Any>(
|
|
3813
|
+
from: From & Schema<Schema.Encoded<To>, Schema.Encoded<From>, Schema.Context<From>>,
|
|
3814
|
+
to: To,
|
|
3737
3815
|
options?: { readonly strict: true }
|
|
3738
|
-
):
|
|
3816
|
+
): transform<From, To>
|
|
3739
3817
|
/**
|
|
3740
3818
|
* @category combinators
|
|
3741
3819
|
* @since 3.10.0
|
|
3742
3820
|
*/
|
|
3743
|
-
<
|
|
3744
|
-
from: Schema<B, A, R1>,
|
|
3745
|
-
to: Schema<D, C, R2>,
|
|
3746
|
-
options: { readonly strict: false }
|
|
3747
|
-
): SchemaClass<D, A, R1 | R2>
|
|
3821
|
+
<From extends Schema.Any, To extends Schema.Any>(from: From, to: To, options: { readonly strict: false }): transform<From, To>
|
|
3748
3822
|
} = dual(
|
|
3749
3823
|
(args) => isSchema(args[1]),
|
|
3750
3824
|
<B, A, R1, D, C, R2>(from: Schema<B, A, R1>, to: Schema<D, C, R2>): SchemaClass<D, A, R1 | R2> =>
|
|
3751
|
-
|
|
3825
|
+
makeTransformationClass(from, to, AST.compose(from.ast, to.ast))
|
|
3752
3826
|
)
|
|
3753
3827
|
|
|
3754
3828
|
/**
|
|
@@ -3793,29 +3867,27 @@ export interface refine<A, From extends Schema.Any>
|
|
|
3793
3867
|
make(a: Schema.Type<From>, options?: MakeOptions): A
|
|
3794
3868
|
}
|
|
3795
3869
|
|
|
3796
|
-
|
|
3870
|
+
function makeRefineClass<From extends Schema.Any, A>(
|
|
3797
3871
|
from: From,
|
|
3798
|
-
filter: (
|
|
3799
|
-
a: Schema.Type<From>,
|
|
3800
|
-
options: ParseOptions,
|
|
3801
|
-
self: AST.Refinement
|
|
3802
|
-
) => option_.Option<ParseResult.ParseIssue>,
|
|
3872
|
+
filter: (a: Schema.Type<From>, options: ParseOptions, self: AST.Refinement) => option_.Option<ParseResult.ParseIssue>,
|
|
3803
3873
|
ast: AST.AST
|
|
3804
|
-
): refine<A, From>
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3874
|
+
): refine<A, From> {
|
|
3875
|
+
return class RefineClass extends make<A, Schema.Encoded<From>, Schema.Context<From>>(ast) {
|
|
3876
|
+
static override annotations(annotations: Annotations.Schema<A>): refine<A, From> {
|
|
3877
|
+
return makeRefineClass(this.from, this.filter, mergeSchemaAnnotations(this.ast, annotations))
|
|
3878
|
+
}
|
|
3808
3879
|
|
|
3809
|
-
|
|
3880
|
+
static [RefineSchemaId] = from
|
|
3810
3881
|
|
|
3811
|
-
|
|
3882
|
+
static from = from
|
|
3812
3883
|
|
|
3813
|
-
|
|
3884
|
+
static filter = filter
|
|
3814
3885
|
|
|
3815
|
-
|
|
3816
|
-
|
|
3886
|
+
static make = (a: Schema.Type<From>, options?: MakeOptions): A => {
|
|
3887
|
+
return getDisableValidationMakeOption(options) ? a : ParseResult.validateSync(this)(a)
|
|
3888
|
+
}
|
|
3817
3889
|
}
|
|
3818
|
-
}
|
|
3890
|
+
}
|
|
3819
3891
|
|
|
3820
3892
|
/**
|
|
3821
3893
|
* @category api interface
|
|
@@ -3972,16 +4044,16 @@ export const filterEffect: {
|
|
|
3972
4044
|
typeSchema(self),
|
|
3973
4045
|
{
|
|
3974
4046
|
strict: true,
|
|
3975
|
-
decode: (
|
|
4047
|
+
decode: (i, options, ast) =>
|
|
3976
4048
|
ParseResult.flatMap(
|
|
3977
|
-
f(
|
|
4049
|
+
f(i, options, ast),
|
|
3978
4050
|
(filterReturnType) =>
|
|
3979
|
-
option_.match(toFilterParseIssue(filterReturnType, ast,
|
|
3980
|
-
onNone: () => ParseResult.succeed(
|
|
4051
|
+
option_.match(toFilterParseIssue(filterReturnType, ast, i), {
|
|
4052
|
+
onNone: () => ParseResult.succeed(i),
|
|
3981
4053
|
onSome: ParseResult.fail
|
|
3982
4054
|
})
|
|
3983
4055
|
),
|
|
3984
|
-
encode: ParseResult.succeed
|
|
4056
|
+
encode: (a) => ParseResult.succeed(a)
|
|
3985
4057
|
}
|
|
3986
4058
|
))
|
|
3987
4059
|
|
|
@@ -3989,7 +4061,7 @@ export const filterEffect: {
|
|
|
3989
4061
|
* @category api interface
|
|
3990
4062
|
* @since 3.10.0
|
|
3991
4063
|
*/
|
|
3992
|
-
export interface transformOrFail<From extends Schema.
|
|
4064
|
+
export interface transformOrFail<From extends Schema.All, To extends Schema.All, R = never> extends
|
|
3993
4065
|
AnnotableClass<
|
|
3994
4066
|
transformOrFail<From, To, R>,
|
|
3995
4067
|
Schema.Type<To>,
|
|
@@ -4001,29 +4073,27 @@ export interface transformOrFail<From extends Schema.Any, To extends Schema.Any,
|
|
|
4001
4073
|
readonly to: To
|
|
4002
4074
|
}
|
|
4003
4075
|
|
|
4004
|
-
|
|
4076
|
+
function makeTransformationClass<From extends Schema.Any, To extends Schema.Any, R>(
|
|
4005
4077
|
from: From,
|
|
4006
4078
|
to: To,
|
|
4007
4079
|
ast: AST.AST
|
|
4008
|
-
): transformOrFail<
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
mergeSchemaAnnotations(this.ast, annotations)
|
|
4020
|
-
)
|
|
4021
|
-
}
|
|
4080
|
+
): transformOrFail<From, To, R> {
|
|
4081
|
+
return class TransformationClass
|
|
4082
|
+
extends make<Schema.Type<To>, Schema.Encoded<From>, Schema.Context<From> | Schema.Context<To> | R>(ast)
|
|
4083
|
+
{
|
|
4084
|
+
static override annotations(annotations: Annotations.Schema<Schema.Type<To>>) {
|
|
4085
|
+
return makeTransformationClass<From, To, R>(
|
|
4086
|
+
this.from,
|
|
4087
|
+
this.to,
|
|
4088
|
+
mergeSchemaAnnotations(this.ast, annotations)
|
|
4089
|
+
)
|
|
4090
|
+
}
|
|
4022
4091
|
|
|
4023
|
-
|
|
4092
|
+
static from = from
|
|
4024
4093
|
|
|
4025
|
-
|
|
4026
|
-
}
|
|
4094
|
+
static to = to
|
|
4095
|
+
}
|
|
4096
|
+
}
|
|
4027
4097
|
|
|
4028
4098
|
/**
|
|
4029
4099
|
* Create a new `Schema` by transforming the input and output of an existing `Schema`
|
|
@@ -4144,7 +4214,7 @@ export const transformOrFail: {
|
|
|
4144
4214
|
* @category api interface
|
|
4145
4215
|
* @since 3.10.0
|
|
4146
4216
|
*/
|
|
4147
|
-
export interface transform<From extends Schema.
|
|
4217
|
+
export interface transform<From extends Schema.All, To extends Schema.All> extends transformOrFail<From, To> {
|
|
4148
4218
|
annotations(annotations: Annotations.Schema<Schema.Type<To>>): transform<From, To>
|
|
4149
4219
|
}
|
|
4150
4220
|
|
|
@@ -4220,7 +4290,11 @@ export const transform: {
|
|
|
4220
4290
|
* @category api interface
|
|
4221
4291
|
* @since 3.10.0
|
|
4222
4292
|
*/
|
|
4223
|
-
export interface transformLiteral<Type
|
|
4293
|
+
export interface transformLiteral<Type extends AST.LiteralValue, Encoded extends AST.LiteralValue>
|
|
4294
|
+
extends transform<Literal<[Encoded]>, Literal<[Type]>>
|
|
4295
|
+
{
|
|
4296
|
+
annotations(annotations: Annotations.Schema<Type>): transformLiteral<Type, Encoded>
|
|
4297
|
+
}
|
|
4224
4298
|
|
|
4225
4299
|
/**
|
|
4226
4300
|
* Creates a new `Schema` which transforms literal values.
|
|
@@ -4237,11 +4311,16 @@ export interface transformLiteral<Type, Encoded> extends Annotable<transformLite
|
|
|
4237
4311
|
* @category constructors
|
|
4238
4312
|
* @since 3.10.0
|
|
4239
4313
|
*/
|
|
4240
|
-
export
|
|
4314
|
+
export function transformLiteral<Encoded extends AST.LiteralValue, Type extends AST.LiteralValue>(
|
|
4241
4315
|
from: Encoded,
|
|
4242
4316
|
to: Type
|
|
4243
|
-
): transformLiteral<Type, Encoded>
|
|
4244
|
-
transform(Literal(from), Literal(to), {
|
|
4317
|
+
): transformLiteral<Type, Encoded> {
|
|
4318
|
+
return transform(Literal(from), Literal(to), {
|
|
4319
|
+
strict: true,
|
|
4320
|
+
decode: () => to,
|
|
4321
|
+
encode: () => from
|
|
4322
|
+
})
|
|
4323
|
+
}
|
|
4245
4324
|
|
|
4246
4325
|
/**
|
|
4247
4326
|
* Creates a new `Schema` which maps between corresponding literal values.
|
|
@@ -4557,17 +4636,19 @@ export const TrimmedSchemaId: unique symbol = Symbol.for("effect/SchemaId/Trimme
|
|
|
4557
4636
|
* @category string filters
|
|
4558
4637
|
* @since 3.10.0
|
|
4559
4638
|
*/
|
|
4560
|
-
export const trimmed =
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
}
|
|
4570
|
-
|
|
4639
|
+
export const trimmed = <S extends Schema.Any>(
|
|
4640
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
4641
|
+
) =>
|
|
4642
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
4643
|
+
self.pipe(
|
|
4644
|
+
filter((a) => a === a.trim(), {
|
|
4645
|
+
schemaId: TrimmedSchemaId,
|
|
4646
|
+
title: "trimmed",
|
|
4647
|
+
description: "a string with no leading or trailing whitespace",
|
|
4648
|
+
jsonSchema: { pattern: "^\\S[\\s\\S]*\\S$|^\\S$|^$" },
|
|
4649
|
+
...annotations
|
|
4650
|
+
})
|
|
4651
|
+
)
|
|
4571
4652
|
|
|
4572
4653
|
/**
|
|
4573
4654
|
* @category schema id
|
|
@@ -4585,23 +4666,21 @@ export type MaxLengthSchemaId = typeof MaxLengthSchemaId
|
|
|
4585
4666
|
* @category string filters
|
|
4586
4667
|
* @since 3.10.0
|
|
4587
4668
|
*/
|
|
4588
|
-
export const maxLength =
|
|
4589
|
-
maxLength: number,
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
}
|
|
4669
|
+
export const maxLength =
|
|
4670
|
+
<S extends Schema.Any>(maxLength: number, annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
4671
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
4672
|
+
self.pipe(
|
|
4673
|
+
filter(
|
|
4674
|
+
(a) => a.length <= maxLength,
|
|
4675
|
+
{
|
|
4676
|
+
schemaId: MaxLengthSchemaId,
|
|
4677
|
+
title: `maxLength(${maxLength})`,
|
|
4678
|
+
description: `a string at most ${maxLength} character(s) long`,
|
|
4679
|
+
jsonSchema: { maxLength },
|
|
4680
|
+
...annotations
|
|
4681
|
+
}
|
|
4682
|
+
)
|
|
4603
4683
|
)
|
|
4604
|
-
)
|
|
4605
4684
|
|
|
4606
4685
|
/**
|
|
4607
4686
|
* @category schema id
|
|
@@ -4619,11 +4698,11 @@ export type MinLengthSchemaId = typeof MinLengthSchemaId
|
|
|
4619
4698
|
* @category string filters
|
|
4620
4699
|
* @since 3.10.0
|
|
4621
4700
|
*/
|
|
4622
|
-
export const minLength = <
|
|
4701
|
+
export const minLength = <S extends Schema.Any>(
|
|
4623
4702
|
minLength: number,
|
|
4624
|
-
annotations?: Annotations.Filter<
|
|
4703
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
4625
4704
|
) =>
|
|
4626
|
-
<
|
|
4705
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
4627
4706
|
self.pipe(
|
|
4628
4707
|
filter(
|
|
4629
4708
|
(a) => a.length >= minLength,
|
|
@@ -4637,6 +4716,51 @@ export const minLength = <A extends string>(
|
|
|
4637
4716
|
)
|
|
4638
4717
|
)
|
|
4639
4718
|
|
|
4719
|
+
/**
|
|
4720
|
+
* @category schema id
|
|
4721
|
+
* @since 3.10.0
|
|
4722
|
+
*/
|
|
4723
|
+
export const LengthSchemaId: unique symbol = schemaId_.LengthSchemaId
|
|
4724
|
+
|
|
4725
|
+
/**
|
|
4726
|
+
* @category schema id
|
|
4727
|
+
* @since 3.10.0
|
|
4728
|
+
*/
|
|
4729
|
+
export type LengthSchemaId = typeof LengthSchemaId
|
|
4730
|
+
|
|
4731
|
+
/**
|
|
4732
|
+
* @category string filters
|
|
4733
|
+
* @since 3.10.0
|
|
4734
|
+
*/
|
|
4735
|
+
export const length = <S extends Schema.Any>(
|
|
4736
|
+
length: number | { readonly min: number; readonly max: number },
|
|
4737
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
4738
|
+
) =>
|
|
4739
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
4740
|
+
const minLength = Predicate.isObject(length) ? Math.max(0, Math.floor(length.min)) : Math.max(0, Math.floor(length))
|
|
4741
|
+
const maxLength = Predicate.isObject(length) ? Math.max(minLength, Math.floor(length.max)) : minLength
|
|
4742
|
+
if (minLength !== maxLength) {
|
|
4743
|
+
return self.pipe(
|
|
4744
|
+
filter((a) => a.length >= minLength && a.length <= maxLength, {
|
|
4745
|
+
schemaId: LengthSchemaId,
|
|
4746
|
+
title: `length({ min: ${minLength}, max: ${maxLength})`,
|
|
4747
|
+
description: `a string at least ${minLength} character(s) and at most ${maxLength} character(s) long`,
|
|
4748
|
+
jsonSchema: { minLength, maxLength },
|
|
4749
|
+
...annotations
|
|
4750
|
+
})
|
|
4751
|
+
)
|
|
4752
|
+
}
|
|
4753
|
+
return self.pipe(
|
|
4754
|
+
filter((a) => a.length === minLength, {
|
|
4755
|
+
schemaId: LengthSchemaId,
|
|
4756
|
+
title: `length(${minLength})`,
|
|
4757
|
+
description: minLength === 1 ? `a single character` : `a string ${minLength} character(s) long`,
|
|
4758
|
+
jsonSchema: { minLength, maxLength: minLength },
|
|
4759
|
+
...annotations
|
|
4760
|
+
})
|
|
4761
|
+
)
|
|
4762
|
+
}
|
|
4763
|
+
|
|
4640
4764
|
/**
|
|
4641
4765
|
* @category schema id
|
|
4642
4766
|
* @since 3.10.0
|
|
@@ -4647,15 +4771,15 @@ export const PatternSchemaId: unique symbol = Symbol.for("effect/SchemaId/Patter
|
|
|
4647
4771
|
* @category string filters
|
|
4648
4772
|
* @since 3.10.0
|
|
4649
4773
|
*/
|
|
4650
|
-
export const pattern = <
|
|
4774
|
+
export const pattern = <S extends Schema.Any>(
|
|
4651
4775
|
regex: RegExp,
|
|
4652
|
-
annotations?: Annotations.Filter<
|
|
4776
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
4653
4777
|
) =>
|
|
4654
|
-
<
|
|
4778
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
4655
4779
|
const source = regex.source
|
|
4656
4780
|
return self.pipe(
|
|
4657
4781
|
filter(
|
|
4658
|
-
(a)
|
|
4782
|
+
(a) => {
|
|
4659
4783
|
// The following line ensures that `lastIndex` is reset to `0` in case the user has specified the `g` flag
|
|
4660
4784
|
regex.lastIndex = 0
|
|
4661
4785
|
return regex.test(a)
|
|
@@ -4682,11 +4806,11 @@ export const StartsWithSchemaId: unique symbol = Symbol.for("effect/SchemaId/Sta
|
|
|
4682
4806
|
* @category string filters
|
|
4683
4807
|
* @since 3.10.0
|
|
4684
4808
|
*/
|
|
4685
|
-
export const startsWith = <
|
|
4809
|
+
export const startsWith = <S extends Schema.Any>(
|
|
4686
4810
|
startsWith: string,
|
|
4687
|
-
annotations?: Annotations.Filter<
|
|
4811
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
4688
4812
|
) =>
|
|
4689
|
-
<
|
|
4813
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
4690
4814
|
const formatted = JSON.stringify(startsWith)
|
|
4691
4815
|
return self.pipe(
|
|
4692
4816
|
filter(
|
|
@@ -4713,11 +4837,11 @@ export const EndsWithSchemaId: unique symbol = Symbol.for("effect/SchemaId/EndsW
|
|
|
4713
4837
|
* @category string filters
|
|
4714
4838
|
* @since 3.10.0
|
|
4715
4839
|
*/
|
|
4716
|
-
export const endsWith = <
|
|
4840
|
+
export const endsWith = <S extends Schema.Any>(
|
|
4717
4841
|
endsWith: string,
|
|
4718
|
-
annotations?: Annotations.Filter<
|
|
4842
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
4719
4843
|
) =>
|
|
4720
|
-
<
|
|
4844
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
4721
4845
|
const formatted = JSON.stringify(endsWith)
|
|
4722
4846
|
return self.pipe(
|
|
4723
4847
|
filter(
|
|
@@ -4744,11 +4868,11 @@ export const IncludesSchemaId: unique symbol = Symbol.for("effect/SchemaId/Inclu
|
|
|
4744
4868
|
* @category string filters
|
|
4745
4869
|
* @since 3.10.0
|
|
4746
4870
|
*/
|
|
4747
|
-
export const includes = <
|
|
4871
|
+
export const includes = <S extends Schema.Any>(
|
|
4748
4872
|
searchString: string,
|
|
4749
|
-
annotations?: Annotations.Filter<
|
|
4873
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
4750
4874
|
) =>
|
|
4751
|
-
<
|
|
4875
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
4752
4876
|
const formatted = JSON.stringify(searchString)
|
|
4753
4877
|
return self.pipe(
|
|
4754
4878
|
filter(
|
|
@@ -4778,7 +4902,8 @@ export const LowercasedSchemaId: unique symbol = Symbol.for("effect/SchemaId/Low
|
|
|
4778
4902
|
* @since 3.10.0
|
|
4779
4903
|
*/
|
|
4780
4904
|
export const lowercased =
|
|
4781
|
-
<
|
|
4905
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
4906
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
4782
4907
|
self.pipe(
|
|
4783
4908
|
filter((a) => a === a.toLowerCase(), {
|
|
4784
4909
|
schemaId: LowercasedSchemaId,
|
|
@@ -4801,23 +4926,24 @@ export class Lowercased extends String$.pipe(
|
|
|
4801
4926
|
* @category schema id
|
|
4802
4927
|
* @since 3.10.0
|
|
4803
4928
|
*/
|
|
4804
|
-
export const
|
|
4929
|
+
export const UppercasedSchemaId: unique symbol = Symbol.for("effect/SchemaId/Uppercased")
|
|
4805
4930
|
|
|
4806
4931
|
/**
|
|
4807
|
-
* Verifies that a string is
|
|
4932
|
+
* Verifies that a string is uppercased.
|
|
4808
4933
|
*
|
|
4809
4934
|
* @category string filters
|
|
4810
4935
|
* @since 3.10.0
|
|
4811
4936
|
*/
|
|
4812
|
-
export const
|
|
4813
|
-
<
|
|
4937
|
+
export const uppercased =
|
|
4938
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
4939
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
4814
4940
|
self.pipe(
|
|
4815
|
-
filter((a) => a
|
|
4816
|
-
schemaId:
|
|
4817
|
-
title: "
|
|
4818
|
-
description: "
|
|
4819
|
-
jsonSchema: { pattern: "^[^a-z]
|
|
4820
|
-
...annotations
|
|
4941
|
+
filter((a) => a === a.toUpperCase(), {
|
|
4942
|
+
schemaId: UppercasedSchemaId,
|
|
4943
|
+
title: "uppercased",
|
|
4944
|
+
description: "an uppercase string",
|
|
4945
|
+
jsonSchema: { pattern: "^[^a-z]*$" },
|
|
4946
|
+
...annotations
|
|
4821
4947
|
})
|
|
4822
4948
|
)
|
|
4823
4949
|
|
|
@@ -4825,30 +4951,31 @@ export const capitalized =
|
|
|
4825
4951
|
* @category string constructors
|
|
4826
4952
|
* @since 3.10.0
|
|
4827
4953
|
*/
|
|
4828
|
-
export class
|
|
4829
|
-
|
|
4954
|
+
export class Uppercased extends String$.pipe(
|
|
4955
|
+
uppercased({ identifier: "Uppercased" })
|
|
4830
4956
|
) {}
|
|
4831
4957
|
|
|
4832
4958
|
/**
|
|
4833
4959
|
* @category schema id
|
|
4834
4960
|
* @since 3.10.0
|
|
4835
4961
|
*/
|
|
4836
|
-
export const
|
|
4962
|
+
export const CapitalizedSchemaId: unique symbol = Symbol.for("effect/SchemaId/Capitalized")
|
|
4837
4963
|
|
|
4838
4964
|
/**
|
|
4839
|
-
* Verifies that a string is
|
|
4965
|
+
* Verifies that a string is capitalized.
|
|
4840
4966
|
*
|
|
4841
4967
|
* @category string filters
|
|
4842
4968
|
* @since 3.10.0
|
|
4843
4969
|
*/
|
|
4844
|
-
export const
|
|
4845
|
-
<
|
|
4970
|
+
export const capitalized =
|
|
4971
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
4972
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
4846
4973
|
self.pipe(
|
|
4847
|
-
filter((a) => a[0]?.
|
|
4848
|
-
schemaId:
|
|
4849
|
-
title: "
|
|
4850
|
-
description: "a
|
|
4851
|
-
jsonSchema: { pattern: "^[^
|
|
4974
|
+
filter((a) => a[0]?.toUpperCase() === a[0], {
|
|
4975
|
+
schemaId: CapitalizedSchemaId,
|
|
4976
|
+
title: "capitalized",
|
|
4977
|
+
description: "a capitalized string",
|
|
4978
|
+
jsonSchema: { pattern: "^[^a-z]?.*$" },
|
|
4852
4979
|
...annotations
|
|
4853
4980
|
})
|
|
4854
4981
|
)
|
|
@@ -4857,30 +4984,31 @@ export const uncapitalized =
|
|
|
4857
4984
|
* @category string constructors
|
|
4858
4985
|
* @since 3.10.0
|
|
4859
4986
|
*/
|
|
4860
|
-
export class
|
|
4861
|
-
|
|
4987
|
+
export class Capitalized extends String$.pipe(
|
|
4988
|
+
capitalized({ identifier: "Capitalized" })
|
|
4862
4989
|
) {}
|
|
4863
4990
|
|
|
4864
4991
|
/**
|
|
4865
4992
|
* @category schema id
|
|
4866
4993
|
* @since 3.10.0
|
|
4867
4994
|
*/
|
|
4868
|
-
export const
|
|
4995
|
+
export const UncapitalizedSchemaId: unique symbol = Symbol.for("effect/SchemaId/Uncapitalized")
|
|
4869
4996
|
|
|
4870
4997
|
/**
|
|
4871
|
-
* Verifies that a string is
|
|
4998
|
+
* Verifies that a string is uncapitalized.
|
|
4872
4999
|
*
|
|
4873
5000
|
* @category string filters
|
|
4874
5001
|
* @since 3.10.0
|
|
4875
5002
|
*/
|
|
4876
|
-
export const
|
|
4877
|
-
<
|
|
5003
|
+
export const uncapitalized =
|
|
5004
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
5005
|
+
<A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
4878
5006
|
self.pipe(
|
|
4879
|
-
filter((a) => a === a
|
|
4880
|
-
schemaId:
|
|
4881
|
-
title: "
|
|
4882
|
-
description: "
|
|
4883
|
-
jsonSchema: { pattern: "^[^
|
|
5007
|
+
filter((a) => a[0]?.toLowerCase() === a[0], {
|
|
5008
|
+
schemaId: UncapitalizedSchemaId,
|
|
5009
|
+
title: "uncapitalized",
|
|
5010
|
+
description: "a uncapitalized string",
|
|
5011
|
+
jsonSchema: { pattern: "^[^A-Z]?.*$" },
|
|
4884
5012
|
...annotations
|
|
4885
5013
|
})
|
|
4886
5014
|
)
|
|
@@ -4889,55 +5017,10 @@ export const uppercased =
|
|
|
4889
5017
|
* @category string constructors
|
|
4890
5018
|
* @since 3.10.0
|
|
4891
5019
|
*/
|
|
4892
|
-
export class
|
|
4893
|
-
|
|
5020
|
+
export class Uncapitalized extends String$.pipe(
|
|
5021
|
+
uncapitalized({ identifier: "Uncapitalized" })
|
|
4894
5022
|
) {}
|
|
4895
5023
|
|
|
4896
|
-
/**
|
|
4897
|
-
* @category schema id
|
|
4898
|
-
* @since 3.10.0
|
|
4899
|
-
*/
|
|
4900
|
-
export const LengthSchemaId: unique symbol = schemaId_.LengthSchemaId
|
|
4901
|
-
|
|
4902
|
-
/**
|
|
4903
|
-
* @category schema id
|
|
4904
|
-
* @since 3.10.0
|
|
4905
|
-
*/
|
|
4906
|
-
export type LengthSchemaId = typeof LengthSchemaId
|
|
4907
|
-
|
|
4908
|
-
/**
|
|
4909
|
-
* @category string filters
|
|
4910
|
-
* @since 3.10.0
|
|
4911
|
-
*/
|
|
4912
|
-
export const length = <A extends string>(
|
|
4913
|
-
length: number | { readonly min: number; readonly max: number },
|
|
4914
|
-
annotations?: Annotations.Filter<A>
|
|
4915
|
-
) =>
|
|
4916
|
-
<I, R>(self: Schema<A, I, R>): filter<Schema<A, I, R>> => {
|
|
4917
|
-
const minLength = Predicate.isObject(length) ? Math.max(0, Math.floor(length.min)) : Math.max(0, Math.floor(length))
|
|
4918
|
-
const maxLength = Predicate.isObject(length) ? Math.max(minLength, Math.floor(length.max)) : minLength
|
|
4919
|
-
if (minLength !== maxLength) {
|
|
4920
|
-
return self.pipe(
|
|
4921
|
-
filter((a) => a.length >= minLength && a.length <= maxLength, {
|
|
4922
|
-
schemaId: LengthSchemaId,
|
|
4923
|
-
title: `length({ min: ${minLength}, max: ${maxLength})`,
|
|
4924
|
-
description: `a string at least ${minLength} character(s) and at most ${maxLength} character(s) long`,
|
|
4925
|
-
jsonSchema: { minLength, maxLength },
|
|
4926
|
-
...annotations
|
|
4927
|
-
})
|
|
4928
|
-
)
|
|
4929
|
-
}
|
|
4930
|
-
return self.pipe(
|
|
4931
|
-
filter((a) => a.length === minLength, {
|
|
4932
|
-
schemaId: LengthSchemaId,
|
|
4933
|
-
title: `length(${minLength})`,
|
|
4934
|
-
description: minLength === 1 ? `a single character` : `a string ${minLength} character(s) long`,
|
|
4935
|
-
jsonSchema: { minLength, maxLength: minLength },
|
|
4936
|
-
...annotations
|
|
4937
|
-
})
|
|
4938
|
-
)
|
|
4939
|
-
}
|
|
4940
|
-
|
|
4941
5024
|
/**
|
|
4942
5025
|
* A schema representing a single character.
|
|
4943
5026
|
*
|
|
@@ -4950,9 +5033,9 @@ export class Char extends String$.pipe(length(1, { identifier: "Char" })) {}
|
|
|
4950
5033
|
* @category string filters
|
|
4951
5034
|
* @since 3.10.0
|
|
4952
5035
|
*/
|
|
4953
|
-
export const nonEmptyString = <
|
|
4954
|
-
annotations?: Annotations.Filter<
|
|
4955
|
-
): <
|
|
5036
|
+
export const nonEmptyString = <S extends Schema.Any>(
|
|
5037
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5038
|
+
): <A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>) => filter<S> =>
|
|
4956
5039
|
minLength(1, {
|
|
4957
5040
|
title: "nonEmptyString",
|
|
4958
5041
|
description: "a non empty string",
|
|
@@ -4968,7 +5051,11 @@ export const nonEmptyString = <A extends string>(
|
|
|
4968
5051
|
export class Lowercase extends transform(
|
|
4969
5052
|
String$.annotations({ description: "a string that will be converted to lowercase" }),
|
|
4970
5053
|
Lowercased,
|
|
4971
|
-
{
|
|
5054
|
+
{
|
|
5055
|
+
strict: true,
|
|
5056
|
+
decode: (i) => i.toLowerCase(),
|
|
5057
|
+
encode: identity
|
|
5058
|
+
}
|
|
4972
5059
|
).annotations({ identifier: "Lowercase" }) {}
|
|
4973
5060
|
|
|
4974
5061
|
/**
|
|
@@ -4980,7 +5067,11 @@ export class Lowercase extends transform(
|
|
|
4980
5067
|
export class Uppercase extends transform(
|
|
4981
5068
|
String$.annotations({ description: "a string that will be converted to uppercase" }),
|
|
4982
5069
|
Uppercased,
|
|
4983
|
-
{
|
|
5070
|
+
{
|
|
5071
|
+
strict: true,
|
|
5072
|
+
decode: (i) => i.toUpperCase(),
|
|
5073
|
+
encode: identity
|
|
5074
|
+
}
|
|
4984
5075
|
).annotations({ identifier: "Uppercase" }) {}
|
|
4985
5076
|
|
|
4986
5077
|
/**
|
|
@@ -4992,7 +5083,11 @@ export class Uppercase extends transform(
|
|
|
4992
5083
|
export class Capitalize extends transform(
|
|
4993
5084
|
String$.annotations({ description: "a string that will be converted to a capitalized format" }),
|
|
4994
5085
|
Capitalized,
|
|
4995
|
-
{
|
|
5086
|
+
{
|
|
5087
|
+
strict: true,
|
|
5088
|
+
decode: (i) => string_.capitalize(i),
|
|
5089
|
+
encode: identity
|
|
5090
|
+
}
|
|
4996
5091
|
).annotations({ identifier: "Capitalize" }) {}
|
|
4997
5092
|
|
|
4998
5093
|
/**
|
|
@@ -5004,7 +5099,11 @@ export class Capitalize extends transform(
|
|
|
5004
5099
|
export class Uncapitalize extends transform(
|
|
5005
5100
|
String$.annotations({ description: "a string that will be converted to an uncapitalized format" }),
|
|
5006
5101
|
Uncapitalized,
|
|
5007
|
-
{
|
|
5102
|
+
{
|
|
5103
|
+
strict: true,
|
|
5104
|
+
decode: (i) => string_.uncapitalize(i),
|
|
5105
|
+
encode: identity
|
|
5106
|
+
}
|
|
5008
5107
|
).annotations({ identifier: "Uncapitalize" }) {}
|
|
5009
5108
|
|
|
5010
5109
|
/**
|
|
@@ -5044,7 +5143,11 @@ export class NonEmptyTrimmedString extends Trimmed.pipe(
|
|
|
5044
5143
|
export class Trim extends transform(
|
|
5045
5144
|
String$.annotations({ description: "a string that will be trimmed" }),
|
|
5046
5145
|
Trimmed,
|
|
5047
|
-
{
|
|
5146
|
+
{
|
|
5147
|
+
strict: true,
|
|
5148
|
+
decode: (i) => i.trim(),
|
|
5149
|
+
encode: identity
|
|
5150
|
+
}
|
|
5048
5151
|
).annotations({ identifier: "Trim" }) {}
|
|
5049
5152
|
|
|
5050
5153
|
/**
|
|
@@ -5053,11 +5156,15 @@ export class Trim extends transform(
|
|
|
5053
5156
|
* @category string transformations
|
|
5054
5157
|
* @since 3.10.0
|
|
5055
5158
|
*/
|
|
5056
|
-
export const split = (separator: string): transform<
|
|
5159
|
+
export const split = (separator: string): transform<SchemaClass<string>, Array$<typeof String$>> =>
|
|
5057
5160
|
transform(
|
|
5058
5161
|
String$.annotations({ description: "a string that will be split" }),
|
|
5059
5162
|
Array$(String$),
|
|
5060
|
-
{
|
|
5163
|
+
{
|
|
5164
|
+
strict: true,
|
|
5165
|
+
decode: (i) => i.split(separator),
|
|
5166
|
+
encode: (a) => a.join(separator)
|
|
5167
|
+
}
|
|
5061
5168
|
)
|
|
5062
5169
|
|
|
5063
5170
|
/**
|
|
@@ -5071,23 +5178,21 @@ export type ParseJsonOptions = {
|
|
|
5071
5178
|
|
|
5072
5179
|
const getErrorMessage = (e: unknown): string => e instanceof Error ? e.message : String(e)
|
|
5073
5180
|
|
|
5074
|
-
const getParseJsonTransformation = (options?: ParseJsonOptions) =>
|
|
5181
|
+
const getParseJsonTransformation = (options?: ParseJsonOptions): SchemaClass<unknown, string> =>
|
|
5075
5182
|
transformOrFail(
|
|
5076
|
-
String$.annotations({
|
|
5077
|
-
[AST.DescriptionAnnotationId]: "a string to be decoded into JSON"
|
|
5078
|
-
}),
|
|
5183
|
+
String$.annotations({ description: "a string to be decoded into JSON" }),
|
|
5079
5184
|
Unknown,
|
|
5080
5185
|
{
|
|
5081
5186
|
strict: true,
|
|
5082
|
-
decode: (
|
|
5187
|
+
decode: (i, _, ast) =>
|
|
5083
5188
|
ParseResult.try({
|
|
5084
|
-
try: () => JSON.parse(
|
|
5085
|
-
catch: (e) => new ParseResult.Type(ast,
|
|
5189
|
+
try: () => JSON.parse(i, options?.reviver),
|
|
5190
|
+
catch: (e) => new ParseResult.Type(ast, i, getErrorMessage(e))
|
|
5086
5191
|
}),
|
|
5087
|
-
encode: (
|
|
5192
|
+
encode: (a, _, ast) =>
|
|
5088
5193
|
ParseResult.try({
|
|
5089
|
-
try: () => JSON.stringify(
|
|
5090
|
-
catch: (e) => new ParseResult.Type(ast,
|
|
5194
|
+
try: () => JSON.stringify(a, options?.replacer, options?.space),
|
|
5195
|
+
catch: (e) => new ParseResult.Type(ast, a, getErrorMessage(e))
|
|
5091
5196
|
})
|
|
5092
5197
|
}
|
|
5093
5198
|
).annotations({
|
|
@@ -5134,7 +5239,7 @@ export const parseJson: {
|
|
|
5134
5239
|
* @category string transformations
|
|
5135
5240
|
* @since 3.10.0
|
|
5136
5241
|
*/
|
|
5137
|
-
<
|
|
5242
|
+
<S extends Schema.Any>(schema: S, options?: ParseJsonOptions): transform<SchemaClass<unknown, string>, S>
|
|
5138
5243
|
/**
|
|
5139
5244
|
* The `ParseJson` combinator provides a method to convert JSON strings into the `unknown` type using the underlying
|
|
5140
5245
|
* functionality of `JSON.parse`. It also utilizes `JSON.stringify` for encoding.
|
|
@@ -5241,17 +5346,17 @@ class URL$ extends transformOrFail(
|
|
|
5241
5346
|
URLFromSelf,
|
|
5242
5347
|
{
|
|
5243
5348
|
strict: true,
|
|
5244
|
-
decode: (
|
|
5349
|
+
decode: (i, _, ast) =>
|
|
5245
5350
|
ParseResult.try({
|
|
5246
|
-
try: () => new URL(
|
|
5351
|
+
try: () => new URL(i),
|
|
5247
5352
|
catch: (e) =>
|
|
5248
5353
|
new ParseResult.Type(
|
|
5249
5354
|
ast,
|
|
5250
|
-
|
|
5251
|
-
`Unable to decode ${JSON.stringify(
|
|
5355
|
+
i,
|
|
5356
|
+
`Unable to decode ${JSON.stringify(i)} into a URL. ${getErrorMessage(e)}`
|
|
5252
5357
|
)
|
|
5253
5358
|
}),
|
|
5254
|
-
encode: (
|
|
5359
|
+
encode: (a) => ParseResult.succeed(a.toString())
|
|
5255
5360
|
}
|
|
5256
5361
|
).annotations({
|
|
5257
5362
|
identifier: "URL",
|
|
@@ -5288,7 +5393,8 @@ export type FiniteSchemaId = typeof FiniteSchemaId
|
|
|
5288
5393
|
* @since 3.10.0
|
|
5289
5394
|
*/
|
|
5290
5395
|
export const finite =
|
|
5291
|
-
<
|
|
5396
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
5397
|
+
<A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5292
5398
|
self.pipe(
|
|
5293
5399
|
filter(Number.isFinite, {
|
|
5294
5400
|
schemaId: FiniteSchemaId,
|
|
@@ -5317,11 +5423,11 @@ export type GreaterThanSchemaId = typeof GreaterThanSchemaId
|
|
|
5317
5423
|
* @category number filters
|
|
5318
5424
|
* @since 3.10.0
|
|
5319
5425
|
*/
|
|
5320
|
-
export const greaterThan = <
|
|
5426
|
+
export const greaterThan = <S extends Schema.Any>(
|
|
5321
5427
|
exclusiveMinimum: number,
|
|
5322
|
-
annotations?: Annotations.Filter<
|
|
5428
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5323
5429
|
) =>
|
|
5324
|
-
<
|
|
5430
|
+
<A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5325
5431
|
self.pipe(
|
|
5326
5432
|
filter((a) => a > exclusiveMinimum, {
|
|
5327
5433
|
schemaId: GreaterThanSchemaId,
|
|
@@ -5350,11 +5456,11 @@ export type GreaterThanOrEqualToSchemaId = typeof GreaterThanOrEqualToSchemaId
|
|
|
5350
5456
|
* @category number filters
|
|
5351
5457
|
* @since 3.10.0
|
|
5352
5458
|
*/
|
|
5353
|
-
export const greaterThanOrEqualTo = <
|
|
5459
|
+
export const greaterThanOrEqualTo = <S extends Schema.Any>(
|
|
5354
5460
|
minimum: number,
|
|
5355
|
-
annotations?: Annotations.Filter<
|
|
5461
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5356
5462
|
) =>
|
|
5357
|
-
<
|
|
5463
|
+
<A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5358
5464
|
self.pipe(
|
|
5359
5465
|
filter((a) => a >= minimum, {
|
|
5360
5466
|
schemaId: GreaterThanOrEqualToSchemaId,
|
|
@@ -5375,11 +5481,11 @@ export const MultipleOfSchemaId: unique symbol = Symbol.for("effect/SchemaId/Mul
|
|
|
5375
5481
|
* @category number filters
|
|
5376
5482
|
* @since 3.10.0
|
|
5377
5483
|
*/
|
|
5378
|
-
export const multipleOf = <
|
|
5484
|
+
export const multipleOf = <S extends Schema.Any>(
|
|
5379
5485
|
divisor: number,
|
|
5380
|
-
annotations?: Annotations.Filter<
|
|
5486
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5381
5487
|
) =>
|
|
5382
|
-
<
|
|
5488
|
+
<A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
5383
5489
|
const positiveDivisor = Math.abs(divisor) // spec requires positive divisor
|
|
5384
5490
|
return self.pipe(
|
|
5385
5491
|
filter((a) => number_.remainder(a, divisor) === 0, {
|
|
@@ -5411,7 +5517,8 @@ export type IntSchemaId = typeof IntSchemaId
|
|
|
5411
5517
|
* @since 3.10.0
|
|
5412
5518
|
*/
|
|
5413
5519
|
export const int =
|
|
5414
|
-
<
|
|
5520
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
5521
|
+
<A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5415
5522
|
self.pipe(
|
|
5416
5523
|
filter((a) => Number.isSafeInteger(a), {
|
|
5417
5524
|
schemaId: IntSchemaId,
|
|
@@ -5441,8 +5548,8 @@ export type LessThanSchemaId = typeof LessThanSchemaId
|
|
|
5441
5548
|
* @since 3.10.0
|
|
5442
5549
|
*/
|
|
5443
5550
|
export const lessThan =
|
|
5444
|
-
<
|
|
5445
|
-
<
|
|
5551
|
+
<S extends Schema.Any>(exclusiveMaximum: number, annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
5552
|
+
<A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5446
5553
|
self.pipe(
|
|
5447
5554
|
filter((a) => a < exclusiveMaximum, {
|
|
5448
5555
|
schemaId: LessThanSchemaId,
|
|
@@ -5471,11 +5578,11 @@ export type LessThanOrEqualToSchemaId = typeof LessThanOrEqualToSchemaId
|
|
|
5471
5578
|
* @category number filters
|
|
5472
5579
|
* @since 3.10.0
|
|
5473
5580
|
*/
|
|
5474
|
-
export const lessThanOrEqualTo = <
|
|
5581
|
+
export const lessThanOrEqualTo = <S extends Schema.Any>(
|
|
5475
5582
|
maximum: number,
|
|
5476
|
-
annotations?: Annotations.Filter<
|
|
5583
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5477
5584
|
) =>
|
|
5478
|
-
<
|
|
5585
|
+
<A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5479
5586
|
self.pipe(
|
|
5480
5587
|
filter((a) => a <= maximum, {
|
|
5481
5588
|
schemaId: LessThanOrEqualToSchemaId,
|
|
@@ -5504,12 +5611,12 @@ export type BetweenSchemaId = typeof BetweenSchemaId
|
|
|
5504
5611
|
* @category number filters
|
|
5505
5612
|
* @since 3.10.0
|
|
5506
5613
|
*/
|
|
5507
|
-
export const between = <
|
|
5614
|
+
export const between = <S extends Schema.Any>(
|
|
5508
5615
|
minimum: number,
|
|
5509
5616
|
maximum: number,
|
|
5510
|
-
annotations?: Annotations.Filter<
|
|
5617
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5511
5618
|
) =>
|
|
5512
|
-
<
|
|
5619
|
+
<A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5513
5620
|
self.pipe(
|
|
5514
5621
|
filter((a) => a >= minimum && a <= maximum, {
|
|
5515
5622
|
schemaId: BetweenSchemaId,
|
|
@@ -5537,7 +5644,8 @@ export type NonNaNSchemaId = typeof NonNaNSchemaId
|
|
|
5537
5644
|
* @since 3.10.0
|
|
5538
5645
|
*/
|
|
5539
5646
|
export const nonNaN =
|
|
5540
|
-
<
|
|
5647
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
5648
|
+
<A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5541
5649
|
self.pipe(
|
|
5542
5650
|
filter((a) => !Number.isNaN(a), {
|
|
5543
5651
|
schemaId: NonNaNSchemaId,
|
|
@@ -5551,34 +5659,36 @@ export const nonNaN =
|
|
|
5551
5659
|
* @category number filters
|
|
5552
5660
|
* @since 3.10.0
|
|
5553
5661
|
*/
|
|
5554
|
-
export const positive = <
|
|
5555
|
-
annotations?: Annotations.Filter<
|
|
5556
|
-
): <
|
|
5662
|
+
export const positive = <S extends Schema.Any>(
|
|
5663
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5664
|
+
): <A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>) => filter<S> =>
|
|
5665
|
+
greaterThan(0, { title: "positive", ...annotations })
|
|
5557
5666
|
|
|
5558
5667
|
/**
|
|
5559
5668
|
* @category number filters
|
|
5560
5669
|
* @since 3.10.0
|
|
5561
5670
|
*/
|
|
5562
|
-
export const negative = <
|
|
5563
|
-
annotations?: Annotations.Filter<
|
|
5564
|
-
): <
|
|
5671
|
+
export const negative = <S extends Schema.Any>(
|
|
5672
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5673
|
+
): <A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>) => filter<S> =>
|
|
5674
|
+
lessThan(0, { title: "negative", ...annotations })
|
|
5565
5675
|
|
|
5566
5676
|
/**
|
|
5567
5677
|
* @category number filters
|
|
5568
5678
|
* @since 3.10.0
|
|
5569
5679
|
*/
|
|
5570
|
-
export const nonPositive = <
|
|
5571
|
-
annotations?: Annotations.Filter<
|
|
5572
|
-
): <
|
|
5680
|
+
export const nonPositive = <S extends Schema.Any>(
|
|
5681
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5682
|
+
): <A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>) => filter<S> =>
|
|
5573
5683
|
lessThanOrEqualTo(0, { title: "nonPositive", ...annotations })
|
|
5574
5684
|
|
|
5575
5685
|
/**
|
|
5576
5686
|
* @category number filters
|
|
5577
5687
|
* @since 3.10.0
|
|
5578
5688
|
*/
|
|
5579
|
-
export const nonNegative = <
|
|
5580
|
-
annotations?: Annotations.Filter<
|
|
5581
|
-
): <
|
|
5689
|
+
export const nonNegative = <S extends Schema.Any>(
|
|
5690
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5691
|
+
): <A extends number>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>) => filter<S> =>
|
|
5582
5692
|
greaterThanOrEqualTo(0, { title: "nonNegative", ...annotations })
|
|
5583
5693
|
|
|
5584
5694
|
/**
|
|
@@ -5587,40 +5697,51 @@ export const nonNegative = <A extends number>(
|
|
|
5587
5697
|
* @category number transformations
|
|
5588
5698
|
* @since 3.10.0
|
|
5589
5699
|
*/
|
|
5590
|
-
export const clamp =
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5700
|
+
export const clamp = (minimum: number, maximum: number) =>
|
|
5701
|
+
<S extends Schema.Any, A extends number>(
|
|
5702
|
+
self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>
|
|
5703
|
+
): transform<S, filter<SchemaClass<A>>> => {
|
|
5704
|
+
return transform(
|
|
5705
|
+
self,
|
|
5706
|
+
typeSchema(self).pipe(between(minimum, maximum)),
|
|
5707
|
+
{
|
|
5708
|
+
strict: false,
|
|
5709
|
+
decode: (i) => number_.clamp(i, { minimum, maximum }),
|
|
5710
|
+
encode: identity
|
|
5711
|
+
}
|
|
5712
|
+
)
|
|
5713
|
+
}
|
|
5598
5714
|
|
|
5599
5715
|
/**
|
|
5600
|
-
* Transforms a `string` into a `number` by parsing the string using the `parse`
|
|
5716
|
+
* Transforms a `string` into a `number` by parsing the string using the `parse`
|
|
5717
|
+
* function of the `effect/Number` module.
|
|
5601
5718
|
*
|
|
5602
|
-
* It returns an error if the value can't be converted (for example when
|
|
5719
|
+
* It returns an error if the value can't be converted (for example when
|
|
5720
|
+
* non-numeric characters are provided).
|
|
5603
5721
|
*
|
|
5604
|
-
* The following special string values are supported: "NaN", "Infinity",
|
|
5722
|
+
* The following special string values are supported: "NaN", "Infinity",
|
|
5723
|
+
* "-Infinity".
|
|
5605
5724
|
*
|
|
5606
5725
|
* @category number transformations
|
|
5607
5726
|
* @since 3.10.0
|
|
5608
5727
|
*/
|
|
5609
|
-
export
|
|
5610
|
-
self: Schema<A,
|
|
5611
|
-
): transformOrFail<
|
|
5612
|
-
transformOrFail(
|
|
5728
|
+
export function parseNumber<S extends Schema.Any, A extends string>(
|
|
5729
|
+
self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>
|
|
5730
|
+
): transformOrFail<S, typeof Number$> {
|
|
5731
|
+
return transformOrFail(
|
|
5613
5732
|
self,
|
|
5614
5733
|
Number$,
|
|
5615
5734
|
{
|
|
5616
5735
|
strict: false,
|
|
5617
|
-
decode: (
|
|
5618
|
-
ParseResult.fromOption(
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5736
|
+
decode: (i, _, ast) =>
|
|
5737
|
+
ParseResult.fromOption(
|
|
5738
|
+
number_.parse(i),
|
|
5739
|
+
() => new ParseResult.Type(ast, i, `Unable to decode ${JSON.stringify(i)} into a number`)
|
|
5740
|
+
),
|
|
5741
|
+
encode: (a) => ParseResult.succeed(String(a))
|
|
5622
5742
|
}
|
|
5623
5743
|
)
|
|
5744
|
+
}
|
|
5624
5745
|
|
|
5625
5746
|
/**
|
|
5626
5747
|
* This schema transforms a `string` into a `number` by parsing the string using the `parse` function of the `effect/Number` module.
|
|
@@ -5731,11 +5852,11 @@ export class JsonNumber extends Number$.pipe(
|
|
|
5731
5852
|
*/
|
|
5732
5853
|
export class Not extends transform(Boolean$.annotations({ description: "a boolean that will be negated" }), Boolean$, {
|
|
5733
5854
|
strict: true,
|
|
5734
|
-
decode: boolean_.not,
|
|
5735
|
-
encode: boolean_.not
|
|
5855
|
+
decode: (i) => boolean_.not(i),
|
|
5856
|
+
encode: (a) => boolean_.not(a)
|
|
5736
5857
|
}) {}
|
|
5737
5858
|
|
|
5738
|
-
const encodeSymbol = (sym: symbol,
|
|
5859
|
+
const encodeSymbol = (sym: symbol, ast: AST.AST) => {
|
|
5739
5860
|
const key = Symbol.keyFor(sym)
|
|
5740
5861
|
return key === undefined
|
|
5741
5862
|
? ParseResult.fail(
|
|
@@ -5752,8 +5873,8 @@ class Symbol$ extends transformOrFail(
|
|
|
5752
5873
|
SymbolFromSelf,
|
|
5753
5874
|
{
|
|
5754
5875
|
strict: false,
|
|
5755
|
-
decode: decodeSymbol,
|
|
5756
|
-
encode: encodeSymbol
|
|
5876
|
+
decode: (i) => decodeSymbol(i),
|
|
5877
|
+
encode: (a, _, ast) => encodeSymbol(a, ast)
|
|
5757
5878
|
}
|
|
5758
5879
|
).annotations({ identifier: "Symbol" }) {}
|
|
5759
5880
|
|
|
@@ -5767,20 +5888,6 @@ export {
|
|
|
5767
5888
|
Symbol$ as Symbol
|
|
5768
5889
|
}
|
|
5769
5890
|
|
|
5770
|
-
const SymbolStruct = TaggedStruct("symbol", {
|
|
5771
|
-
key: String$
|
|
5772
|
-
}).annotations({ description: "an object to be decoded into a globally shared symbol" })
|
|
5773
|
-
|
|
5774
|
-
const SymbolFromStruct = transformOrFail(
|
|
5775
|
-
SymbolStruct,
|
|
5776
|
-
SymbolFromSelf,
|
|
5777
|
-
{
|
|
5778
|
-
strict: true,
|
|
5779
|
-
decode: ({ key }) => decodeSymbol(key),
|
|
5780
|
-
encode: (sym, _, ast) => ParseResult.map(encodeSymbol(sym, _, ast), (key) => SymbolStruct.make({ key }))
|
|
5781
|
-
}
|
|
5782
|
-
)
|
|
5783
|
-
|
|
5784
5891
|
/**
|
|
5785
5892
|
* @category schema id
|
|
5786
5893
|
* @since 3.10.0
|
|
@@ -5797,11 +5904,11 @@ export type GreaterThanBigIntSchemaId = typeof GreaterThanBigIntSchemaId
|
|
|
5797
5904
|
* @category bigint filters
|
|
5798
5905
|
* @since 3.10.0
|
|
5799
5906
|
*/
|
|
5800
|
-
export const greaterThanBigInt = <
|
|
5907
|
+
export const greaterThanBigInt = <S extends Schema.Any>(
|
|
5801
5908
|
min: bigint,
|
|
5802
|
-
annotations?: Annotations.Filter<
|
|
5909
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5803
5910
|
) =>
|
|
5804
|
-
<
|
|
5911
|
+
<A extends bigint>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5805
5912
|
self.pipe(
|
|
5806
5913
|
filter((a) => a > min, {
|
|
5807
5914
|
schemaId: GreaterThanBigIntSchemaId,
|
|
@@ -5828,11 +5935,11 @@ export type GreaterThanOrEqualToBigIntSchemaId = typeof GreaterThanOrEqualToBigI
|
|
|
5828
5935
|
* @category bigint filters
|
|
5829
5936
|
* @since 3.10.0
|
|
5830
5937
|
*/
|
|
5831
|
-
export const greaterThanOrEqualToBigInt = <
|
|
5938
|
+
export const greaterThanOrEqualToBigInt = <S extends Schema.Any>(
|
|
5832
5939
|
min: bigint,
|
|
5833
|
-
annotations?: Annotations.Filter<
|
|
5940
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5834
5941
|
) =>
|
|
5835
|
-
<
|
|
5942
|
+
<A extends bigint>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5836
5943
|
self.pipe(
|
|
5837
5944
|
filter((a) => a >= min, {
|
|
5838
5945
|
schemaId: GreaterThanOrEqualToBigIntSchemaId,
|
|
@@ -5861,11 +5968,11 @@ export type LessThanBigIntSchemaId = typeof LessThanBigIntSchemaId
|
|
|
5861
5968
|
* @category bigint filters
|
|
5862
5969
|
* @since 3.10.0
|
|
5863
5970
|
*/
|
|
5864
|
-
export const lessThanBigInt = <
|
|
5971
|
+
export const lessThanBigInt = <S extends Schema.Any>(
|
|
5865
5972
|
max: bigint,
|
|
5866
|
-
annotations?: Annotations.Filter<
|
|
5973
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5867
5974
|
) =>
|
|
5868
|
-
<
|
|
5975
|
+
<A extends bigint>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5869
5976
|
self.pipe(
|
|
5870
5977
|
filter((a) => a < max, {
|
|
5871
5978
|
schemaId: LessThanBigIntSchemaId,
|
|
@@ -5892,11 +5999,11 @@ export type LessThanOrEqualToBigIntSchemaId = typeof LessThanOrEqualToBigIntSche
|
|
|
5892
5999
|
* @category bigint filters
|
|
5893
6000
|
* @since 3.10.0
|
|
5894
6001
|
*/
|
|
5895
|
-
export const lessThanOrEqualToBigInt = <
|
|
6002
|
+
export const lessThanOrEqualToBigInt = <S extends Schema.Any>(
|
|
5896
6003
|
max: bigint,
|
|
5897
|
-
annotations?: Annotations.Filter<
|
|
6004
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5898
6005
|
) =>
|
|
5899
|
-
<
|
|
6006
|
+
<A extends bigint>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5900
6007
|
self.pipe(
|
|
5901
6008
|
filter((a) => a <= max, {
|
|
5902
6009
|
schemaId: LessThanOrEqualToBigIntSchemaId,
|
|
@@ -5923,12 +6030,12 @@ export type BetweenBigIntSchemaId = typeof BetweenBigIntSchemaId
|
|
|
5923
6030
|
* @category bigint filters
|
|
5924
6031
|
* @since 3.10.0
|
|
5925
6032
|
*/
|
|
5926
|
-
export const betweenBigInt = <
|
|
6033
|
+
export const betweenBigInt = <S extends Schema.Any>(
|
|
5927
6034
|
min: bigint,
|
|
5928
6035
|
max: bigint,
|
|
5929
|
-
annotations?: Annotations.Filter<
|
|
6036
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
5930
6037
|
) =>
|
|
5931
|
-
<
|
|
6038
|
+
<A extends bigint>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
5932
6039
|
self.pipe(
|
|
5933
6040
|
filter((a) => a >= min && a <= max, {
|
|
5934
6041
|
schemaId: BetweenBigIntSchemaId,
|
|
@@ -5943,36 +6050,36 @@ export const betweenBigInt = <A extends bigint>(
|
|
|
5943
6050
|
* @category bigint filters
|
|
5944
6051
|
* @since 3.10.0
|
|
5945
6052
|
*/
|
|
5946
|
-
export const positiveBigInt = <
|
|
5947
|
-
annotations?: Annotations.Filter<
|
|
5948
|
-
): <
|
|
6053
|
+
export const positiveBigInt = <S extends Schema.Any>(
|
|
6054
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6055
|
+
): <A extends bigint>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>) => filter<S> =>
|
|
5949
6056
|
greaterThanBigInt(0n, { title: "positiveBigInt", ...annotations })
|
|
5950
6057
|
|
|
5951
6058
|
/**
|
|
5952
6059
|
* @category bigint filters
|
|
5953
6060
|
* @since 3.10.0
|
|
5954
6061
|
*/
|
|
5955
|
-
export const negativeBigInt = <
|
|
5956
|
-
annotations?: Annotations.Filter<
|
|
5957
|
-
): <
|
|
6062
|
+
export const negativeBigInt = <S extends Schema.Any>(
|
|
6063
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6064
|
+
): <A extends bigint>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>) => filter<S> =>
|
|
5958
6065
|
lessThanBigInt(0n, { title: "negativeBigInt", ...annotations })
|
|
5959
6066
|
|
|
5960
6067
|
/**
|
|
5961
6068
|
* @category bigint filters
|
|
5962
6069
|
* @since 3.10.0
|
|
5963
6070
|
*/
|
|
5964
|
-
export const nonNegativeBigInt = <
|
|
5965
|
-
annotations?: Annotations.Filter<
|
|
5966
|
-
): <
|
|
6071
|
+
export const nonNegativeBigInt = <S extends Schema.Any>(
|
|
6072
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6073
|
+
): <A extends bigint>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>) => filter<S> =>
|
|
5967
6074
|
greaterThanOrEqualToBigInt(0n, { title: "nonNegativeBigInt", ...annotations })
|
|
5968
6075
|
|
|
5969
6076
|
/**
|
|
5970
6077
|
* @category bigint filters
|
|
5971
6078
|
* @since 3.10.0
|
|
5972
6079
|
*/
|
|
5973
|
-
export const nonPositiveBigInt = <
|
|
5974
|
-
annotations?: Annotations.Filter<
|
|
5975
|
-
): <
|
|
6080
|
+
export const nonPositiveBigInt = <S extends Schema.Any>(
|
|
6081
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6082
|
+
): <A extends bigint>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>) => filter<S> =>
|
|
5976
6083
|
lessThanOrEqualToBigInt(0n, { title: "nonPositiveBigInt", ...annotations })
|
|
5977
6084
|
|
|
5978
6085
|
/**
|
|
@@ -5981,14 +6088,19 @@ export const nonPositiveBigInt = <A extends bigint>(
|
|
|
5981
6088
|
* @category bigint transformations
|
|
5982
6089
|
* @since 3.10.0
|
|
5983
6090
|
*/
|
|
5984
|
-
export const clampBigInt =
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
|
|
6091
|
+
export const clampBigInt = (minimum: bigint, maximum: bigint) =>
|
|
6092
|
+
<S extends Schema.Any, A extends bigint>(
|
|
6093
|
+
self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>
|
|
6094
|
+
): transform<S, filter<SchemaClass<A>>> =>
|
|
6095
|
+
transform(
|
|
6096
|
+
self,
|
|
6097
|
+
self.pipe(typeSchema, betweenBigInt(minimum, maximum)),
|
|
6098
|
+
{
|
|
6099
|
+
strict: false,
|
|
6100
|
+
decode: (i) => bigInt_.clamp(i, { minimum, maximum }),
|
|
6101
|
+
encode: identity
|
|
6102
|
+
}
|
|
6103
|
+
)
|
|
5992
6104
|
|
|
5993
6105
|
/** @ignore */
|
|
5994
6106
|
class BigInt$ extends transformOrFail(
|
|
@@ -5996,12 +6108,12 @@ class BigInt$ extends transformOrFail(
|
|
|
5996
6108
|
BigIntFromSelf,
|
|
5997
6109
|
{
|
|
5998
6110
|
strict: true,
|
|
5999
|
-
decode: (
|
|
6111
|
+
decode: (i, _, ast) =>
|
|
6000
6112
|
ParseResult.fromOption(
|
|
6001
|
-
bigInt_.fromString(
|
|
6002
|
-
() => new ParseResult.Type(ast,
|
|
6113
|
+
bigInt_.fromString(i),
|
|
6114
|
+
() => new ParseResult.Type(ast, i, `Unable to decode ${JSON.stringify(i)} into a bigint`)
|
|
6003
6115
|
),
|
|
6004
|
-
encode: (
|
|
6116
|
+
encode: (a) => ParseResult.succeed(String(a))
|
|
6005
6117
|
}
|
|
6006
6118
|
).annotations({ identifier: "BigInt" }) {}
|
|
6007
6119
|
|
|
@@ -6094,15 +6206,15 @@ export class BigIntFromNumber extends transformOrFail(
|
|
|
6094
6206
|
BigIntFromSelf.pipe(betweenBigInt(BigInt(Number.MIN_SAFE_INTEGER), BigInt(Number.MAX_SAFE_INTEGER))),
|
|
6095
6207
|
{
|
|
6096
6208
|
strict: true,
|
|
6097
|
-
decode: (
|
|
6209
|
+
decode: (i, _, ast) =>
|
|
6098
6210
|
ParseResult.fromOption(
|
|
6099
|
-
bigInt_.fromNumber(
|
|
6100
|
-
() => new ParseResult.Type(ast,
|
|
6211
|
+
bigInt_.fromNumber(i),
|
|
6212
|
+
() => new ParseResult.Type(ast, i, `Unable to decode ${i} into a bigint`)
|
|
6101
6213
|
),
|
|
6102
|
-
encode: (
|
|
6214
|
+
encode: (a, _, ast) =>
|
|
6103
6215
|
ParseResult.fromOption(
|
|
6104
|
-
bigInt_.toNumber(
|
|
6105
|
-
() => new ParseResult.Type(ast,
|
|
6216
|
+
bigInt_.toNumber(a),
|
|
6217
|
+
() => new ParseResult.Type(ast, a, `Unable to encode ${a}n into a number`)
|
|
6106
6218
|
)
|
|
6107
6219
|
}
|
|
6108
6220
|
).annotations({ identifier: "BigIntFromNumber" }) {}
|
|
@@ -6134,11 +6246,11 @@ const redactedParse = <A, R>(
|
|
|
6134
6246
|
* @since 3.10.0
|
|
6135
6247
|
*/
|
|
6136
6248
|
export interface RedactedFromSelf<Value extends Schema.Any> extends
|
|
6137
|
-
|
|
6249
|
+
AnnotableDeclare<
|
|
6138
6250
|
RedactedFromSelf<Value>,
|
|
6139
6251
|
redacted_.Redacted<Schema.Type<Value>>,
|
|
6140
6252
|
redacted_.Redacted<Schema.Encoded<Value>>,
|
|
6141
|
-
|
|
6253
|
+
[Value]
|
|
6142
6254
|
>
|
|
6143
6255
|
{}
|
|
6144
6256
|
|
|
@@ -6146,9 +6258,7 @@ export interface RedactedFromSelf<Value extends Schema.Any> extends
|
|
|
6146
6258
|
* @category Redacted constructors
|
|
6147
6259
|
* @since 3.10.0
|
|
6148
6260
|
*/
|
|
6149
|
-
export const RedactedFromSelf = <Value extends Schema.Any>(
|
|
6150
|
-
value: Value
|
|
6151
|
-
): RedactedFromSelf<Value> =>
|
|
6261
|
+
export const RedactedFromSelf = <Value extends Schema.Any>(value: Value): RedactedFromSelf<Value> =>
|
|
6152
6262
|
declare(
|
|
6153
6263
|
[value],
|
|
6154
6264
|
{
|
|
@@ -6167,31 +6277,25 @@ export const RedactedFromSelf = <Value extends Schema.Any>(
|
|
|
6167
6277
|
* @category api interface
|
|
6168
6278
|
* @since 3.10.0
|
|
6169
6279
|
*/
|
|
6170
|
-
export interface Redacted<Value extends Schema.Any>
|
|
6171
|
-
|
|
6172
|
-
Redacted<Value>,
|
|
6173
|
-
redacted_.Redacted<Schema.Type<Value>>,
|
|
6174
|
-
Schema.Encoded<Value>,
|
|
6175
|
-
Schema.Context<Value>
|
|
6176
|
-
>
|
|
6280
|
+
export interface Redacted<Value extends Schema.Any>
|
|
6281
|
+
extends transform<Value, RedactedFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
6177
6282
|
{}
|
|
6178
6283
|
|
|
6179
6284
|
/**
|
|
6180
|
-
* A
|
|
6285
|
+
* A transformation that transform a `Schema<A, I, R>` into a
|
|
6286
|
+
* `RedactedFromSelf<A>`.
|
|
6181
6287
|
*
|
|
6182
6288
|
* @category Redacted transformations
|
|
6183
6289
|
* @since 3.10.0
|
|
6184
6290
|
*/
|
|
6185
|
-
export
|
|
6186
|
-
value: Value
|
|
6187
|
-
): Redacted<Value> => {
|
|
6291
|
+
export function Redacted<Value extends Schema.Any>(value: Value): Redacted<Value> {
|
|
6188
6292
|
return transform(
|
|
6189
6293
|
value,
|
|
6190
|
-
RedactedFromSelf(typeSchema(value)),
|
|
6294
|
+
RedactedFromSelf(typeSchema(asSchema(value))),
|
|
6191
6295
|
{
|
|
6192
6296
|
strict: true,
|
|
6193
|
-
decode: (
|
|
6194
|
-
encode: (
|
|
6297
|
+
decode: (i) => redacted_.make(i),
|
|
6298
|
+
encode: (a) => redacted_.value(a)
|
|
6195
6299
|
}
|
|
6196
6300
|
)
|
|
6197
6301
|
}
|
|
@@ -6227,11 +6331,10 @@ export class DurationFromNanos extends transformOrFail(
|
|
|
6227
6331
|
DurationFromSelf.pipe(filter((duration) => duration_.isFinite(duration), { description: "a finite duration" })),
|
|
6228
6332
|
{
|
|
6229
6333
|
strict: true,
|
|
6230
|
-
decode: (
|
|
6231
|
-
encode: (
|
|
6232
|
-
option_.match(duration_.toNanos(
|
|
6233
|
-
onNone: () =>
|
|
6234
|
-
ParseResult.fail(new ParseResult.Type(ast, duration, `Unable to encode ${duration} into a bigint`)),
|
|
6334
|
+
decode: (i) => ParseResult.succeed(duration_.nanos(i)),
|
|
6335
|
+
encode: (a, _, ast) =>
|
|
6336
|
+
option_.match(duration_.toNanos(a), {
|
|
6337
|
+
onNone: () => ParseResult.fail(new ParseResult.Type(ast, a, `Unable to encode ${a} into a bigint`)),
|
|
6235
6338
|
onSome: (nanos) => ParseResult.succeed(nanos)
|
|
6236
6339
|
})
|
|
6237
6340
|
}
|
|
@@ -6259,8 +6362,8 @@ export class DurationFromMillis extends transform(
|
|
|
6259
6362
|
DurationFromSelf,
|
|
6260
6363
|
{
|
|
6261
6364
|
strict: true,
|
|
6262
|
-
decode: (
|
|
6263
|
-
encode: (
|
|
6365
|
+
decode: (i) => duration_.millis(i),
|
|
6366
|
+
encode: (a) => duration_.toMillis(a)
|
|
6264
6367
|
}
|
|
6265
6368
|
).annotations({ identifier: "DurationFromMillis" }) {}
|
|
6266
6369
|
|
|
@@ -6322,26 +6425,26 @@ export class Duration extends transform(
|
|
|
6322
6425
|
DurationFromSelf,
|
|
6323
6426
|
{
|
|
6324
6427
|
strict: true,
|
|
6325
|
-
decode: (
|
|
6326
|
-
if (isDurationValue(
|
|
6327
|
-
switch (
|
|
6428
|
+
decode: (i) => {
|
|
6429
|
+
if (isDurationValue(i)) {
|
|
6430
|
+
switch (i._tag) {
|
|
6328
6431
|
case "Millis":
|
|
6329
|
-
return duration_.millis(
|
|
6432
|
+
return duration_.millis(i.millis)
|
|
6330
6433
|
case "Nanos":
|
|
6331
|
-
return duration_.nanos(
|
|
6434
|
+
return duration_.nanos(i.nanos)
|
|
6332
6435
|
case "Infinity":
|
|
6333
6436
|
return duration_.infinity
|
|
6334
6437
|
}
|
|
6335
6438
|
}
|
|
6336
|
-
const [seconds, nanos] =
|
|
6439
|
+
const [seconds, nanos] = i
|
|
6337
6440
|
return seconds === -1 ? duration_.infinity : duration_.nanos(BigInt(seconds) * BigInt(1e9) + BigInt(nanos))
|
|
6338
6441
|
},
|
|
6339
|
-
encode: (
|
|
6340
|
-
switch (
|
|
6442
|
+
encode: (a) => {
|
|
6443
|
+
switch (a.value._tag) {
|
|
6341
6444
|
case "Millis":
|
|
6342
|
-
return DurationValueMillis.make({ millis:
|
|
6445
|
+
return DurationValueMillis.make({ millis: a.value.millis })
|
|
6343
6446
|
case "Nanos":
|
|
6344
|
-
return DurationValueNanos.make({ nanos:
|
|
6447
|
+
return DurationValueNanos.make({ nanos: a.value.nanos })
|
|
6345
6448
|
case "Infinity":
|
|
6346
6449
|
return durationValueInfinity
|
|
6347
6450
|
}
|
|
@@ -6357,11 +6460,17 @@ export class Duration extends transform(
|
|
|
6357
6460
|
*/
|
|
6358
6461
|
export const clampDuration =
|
|
6359
6462
|
(minimum: duration_.DurationInput, maximum: duration_.DurationInput) =>
|
|
6360
|
-
<
|
|
6463
|
+
<S extends Schema.Any, A extends duration_.Duration>(
|
|
6464
|
+
self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>
|
|
6465
|
+
): transform<S, filter<SchemaClass<A>>> =>
|
|
6361
6466
|
transform(
|
|
6362
6467
|
self,
|
|
6363
6468
|
self.pipe(typeSchema, betweenDuration(minimum, maximum)),
|
|
6364
|
-
{
|
|
6469
|
+
{
|
|
6470
|
+
strict: false,
|
|
6471
|
+
decode: (i) => duration_.clamp(i, { minimum, maximum }),
|
|
6472
|
+
encode: identity
|
|
6473
|
+
}
|
|
6365
6474
|
)
|
|
6366
6475
|
|
|
6367
6476
|
/**
|
|
@@ -6374,11 +6483,11 @@ export const LessThanDurationSchemaId: unique symbol = Symbol.for("effect/Schema
|
|
|
6374
6483
|
* @category Duration filters
|
|
6375
6484
|
* @since 3.10.0
|
|
6376
6485
|
*/
|
|
6377
|
-
export const lessThanDuration = <
|
|
6486
|
+
export const lessThanDuration = <S extends Schema.Any>(
|
|
6378
6487
|
max: duration_.DurationInput,
|
|
6379
|
-
annotations?: Annotations.Filter<
|
|
6488
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6380
6489
|
) =>
|
|
6381
|
-
<
|
|
6490
|
+
<A extends duration_.Duration>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
6382
6491
|
self.pipe(
|
|
6383
6492
|
filter((a) => duration_.lessThan(a, max), {
|
|
6384
6493
|
schemaId: LessThanDurationSchemaId,
|
|
@@ -6401,11 +6510,11 @@ export const LessThanOrEqualToDurationSchemaId: unique symbol = Symbol.for(
|
|
|
6401
6510
|
* @category Duration filters
|
|
6402
6511
|
* @since 3.10.0
|
|
6403
6512
|
*/
|
|
6404
|
-
export const lessThanOrEqualToDuration = <
|
|
6513
|
+
export const lessThanOrEqualToDuration = <S extends Schema.Any>(
|
|
6405
6514
|
max: duration_.DurationInput,
|
|
6406
|
-
annotations?: Annotations.Filter<
|
|
6515
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6407
6516
|
) =>
|
|
6408
|
-
<
|
|
6517
|
+
<A extends duration_.Duration>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
6409
6518
|
self.pipe(
|
|
6410
6519
|
filter((a) => duration_.lessThanOrEqualTo(a, max), {
|
|
6411
6520
|
schemaId: LessThanDurationSchemaId,
|
|
@@ -6426,11 +6535,11 @@ export const GreaterThanDurationSchemaId: unique symbol = Symbol.for("effect/Sch
|
|
|
6426
6535
|
* @category Duration filters
|
|
6427
6536
|
* @since 3.10.0
|
|
6428
6537
|
*/
|
|
6429
|
-
export const greaterThanDuration = <
|
|
6538
|
+
export const greaterThanDuration = <S extends Schema.Any>(
|
|
6430
6539
|
min: duration_.DurationInput,
|
|
6431
|
-
annotations?: Annotations.Filter<
|
|
6540
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6432
6541
|
) =>
|
|
6433
|
-
<
|
|
6542
|
+
<A extends duration_.Duration>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
6434
6543
|
self.pipe(
|
|
6435
6544
|
filter((a) => duration_.greaterThan(a, min), {
|
|
6436
6545
|
schemaId: GreaterThanDurationSchemaId,
|
|
@@ -6453,11 +6562,11 @@ export const GreaterThanOrEqualToDurationSchemaId: unique symbol = Symbol.for(
|
|
|
6453
6562
|
* @category Duration filters
|
|
6454
6563
|
* @since 3.10.0
|
|
6455
6564
|
*/
|
|
6456
|
-
export const greaterThanOrEqualToDuration = <
|
|
6565
|
+
export const greaterThanOrEqualToDuration = <S extends Schema.Any>(
|
|
6457
6566
|
min: duration_.DurationInput,
|
|
6458
|
-
annotations?: Annotations.Filter<
|
|
6567
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6459
6568
|
) =>
|
|
6460
|
-
<
|
|
6569
|
+
<A extends duration_.Duration>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
6461
6570
|
self.pipe(
|
|
6462
6571
|
filter((a) => duration_.greaterThanOrEqualTo(a, min), {
|
|
6463
6572
|
schemaId: GreaterThanOrEqualToDurationSchemaId,
|
|
@@ -6478,12 +6587,12 @@ export const BetweenDurationSchemaId: unique symbol = Symbol.for("effect/SchemaI
|
|
|
6478
6587
|
* @category Duration filters
|
|
6479
6588
|
* @since 3.10.0
|
|
6480
6589
|
*/
|
|
6481
|
-
export const betweenDuration = <
|
|
6590
|
+
export const betweenDuration = <S extends Schema.Any>(
|
|
6482
6591
|
minimum: duration_.DurationInput,
|
|
6483
6592
|
maximum: duration_.DurationInput,
|
|
6484
|
-
annotations?: Annotations.Filter<
|
|
6593
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6485
6594
|
) =>
|
|
6486
|
-
<
|
|
6595
|
+
<A extends duration_.Duration>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
6487
6596
|
self.pipe(
|
|
6488
6597
|
filter((a) => duration_.between(a, { minimum, maximum }), {
|
|
6489
6598
|
schemaId: BetweenDurationSchemaId,
|
|
@@ -6498,7 +6607,7 @@ export const betweenDuration = <A extends duration_.Duration>(
|
|
|
6498
6607
|
* @category Uint8Array constructors
|
|
6499
6608
|
* @since 3.10.0
|
|
6500
6609
|
*/
|
|
6501
|
-
export
|
|
6610
|
+
export class Uint8ArrayFromSelf extends declare(
|
|
6502
6611
|
Predicate.isUint8Array,
|
|
6503
6612
|
{
|
|
6504
6613
|
identifier: "Uint8ArrayFromSelf",
|
|
@@ -6506,26 +6615,31 @@ export const Uint8ArrayFromSelf: Schema<Uint8Array> = declare(
|
|
|
6506
6615
|
arbitrary: (): LazyArbitrary<Uint8Array> => (fc) => fc.uint8Array(),
|
|
6507
6616
|
equivalence: (): Equivalence.Equivalence<Uint8Array> => array_.getEquivalence(Equal.equals) as any
|
|
6508
6617
|
}
|
|
6509
|
-
)
|
|
6618
|
+
) {}
|
|
6510
6619
|
|
|
6511
6620
|
/**
|
|
6512
6621
|
* @category number constructors
|
|
6513
6622
|
* @since 3.11.10
|
|
6514
6623
|
*/
|
|
6515
|
-
export
|
|
6624
|
+
export class Uint8 extends Number$.pipe(
|
|
6516
6625
|
between(0, 255, {
|
|
6517
6626
|
identifier: "Uint8",
|
|
6518
6627
|
description: "a 8-bit unsigned integer"
|
|
6519
6628
|
})
|
|
6520
|
-
)
|
|
6629
|
+
) {}
|
|
6521
6630
|
|
|
6522
|
-
|
|
6631
|
+
/** @ignore */
|
|
6632
|
+
class Uint8Array$ extends transform(
|
|
6523
6633
|
Array$(Uint8).annotations({
|
|
6524
6634
|
description: "an array of 8-bit unsigned integers to be decoded into a Uint8Array"
|
|
6525
6635
|
}),
|
|
6526
6636
|
Uint8ArrayFromSelf,
|
|
6527
|
-
{
|
|
6528
|
-
|
|
6637
|
+
{
|
|
6638
|
+
strict: true,
|
|
6639
|
+
decode: (i) => Uint8Array.from(i),
|
|
6640
|
+
encode: (a) => Array.from(a)
|
|
6641
|
+
}
|
|
6642
|
+
).annotations({ identifier: "Uint8Array" }) {}
|
|
6529
6643
|
|
|
6530
6644
|
export {
|
|
6531
6645
|
/**
|
|
@@ -6547,12 +6661,12 @@ const makeUint8ArrayTransformation = (
|
|
|
6547
6661
|
Uint8ArrayFromSelf,
|
|
6548
6662
|
{
|
|
6549
6663
|
strict: true,
|
|
6550
|
-
decode: (
|
|
6664
|
+
decode: (i, _, ast) =>
|
|
6551
6665
|
either_.mapLeft(
|
|
6552
|
-
decode(
|
|
6553
|
-
(decodeException) => new ParseResult.Type(ast,
|
|
6666
|
+
decode(i),
|
|
6667
|
+
(decodeException) => new ParseResult.Type(ast, i, decodeException.message)
|
|
6554
6668
|
),
|
|
6555
|
-
encode: (
|
|
6669
|
+
encode: (a) => ParseResult.succeed(encode(a))
|
|
6556
6670
|
}
|
|
6557
6671
|
).annotations({ identifier: id })
|
|
6558
6672
|
|
|
@@ -6604,12 +6718,12 @@ const makeEncodingTransformation = (
|
|
|
6604
6718
|
String$,
|
|
6605
6719
|
{
|
|
6606
6720
|
strict: true,
|
|
6607
|
-
decode: (
|
|
6721
|
+
decode: (i, _, ast) =>
|
|
6608
6722
|
either_.mapLeft(
|
|
6609
|
-
decode(
|
|
6610
|
-
(decodeException) => new ParseResult.Type(ast,
|
|
6723
|
+
decode(i),
|
|
6724
|
+
(decodeException) => new ParseResult.Type(ast, i, decodeException.message)
|
|
6611
6725
|
),
|
|
6612
|
-
encode: (
|
|
6726
|
+
encode: (a) => ParseResult.succeed(encode(a))
|
|
6613
6727
|
}
|
|
6614
6728
|
).annotations({ identifier: `StringFrom${id}` })
|
|
6615
6729
|
|
|
@@ -6678,15 +6792,15 @@ export const StringFromUriComponent = transformOrFail(
|
|
|
6678
6792
|
String$,
|
|
6679
6793
|
{
|
|
6680
6794
|
strict: true,
|
|
6681
|
-
decode: (
|
|
6795
|
+
decode: (i, _, ast) =>
|
|
6682
6796
|
either_.mapLeft(
|
|
6683
|
-
Encoding.decodeUriComponent(
|
|
6684
|
-
(decodeException) => new ParseResult.Type(ast,
|
|
6797
|
+
Encoding.decodeUriComponent(i),
|
|
6798
|
+
(decodeException) => new ParseResult.Type(ast, i, decodeException.message)
|
|
6685
6799
|
),
|
|
6686
|
-
encode: (
|
|
6800
|
+
encode: (a, _, ast) =>
|
|
6687
6801
|
either_.mapLeft(
|
|
6688
|
-
Encoding.encodeUriComponent(
|
|
6689
|
-
(encodeException) => new ParseResult.Type(ast,
|
|
6802
|
+
Encoding.encodeUriComponent(a),
|
|
6803
|
+
(encodeException) => new ParseResult.Type(ast, a, encodeException.message)
|
|
6690
6804
|
)
|
|
6691
6805
|
}
|
|
6692
6806
|
).annotations({ identifier: `StringFromUriComponent` })
|
|
@@ -6707,11 +6821,11 @@ export type MinItemsSchemaId = typeof MinItemsSchemaId
|
|
|
6707
6821
|
* @category ReadonlyArray filters
|
|
6708
6822
|
* @since 3.10.0
|
|
6709
6823
|
*/
|
|
6710
|
-
export const minItems = <
|
|
6824
|
+
export const minItems = <S extends Schema.Any>(
|
|
6711
6825
|
n: number,
|
|
6712
|
-
annotations?: Annotations.Filter<
|
|
6826
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6713
6827
|
) =>
|
|
6714
|
-
<
|
|
6828
|
+
<A extends ReadonlyArray<any>>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
6715
6829
|
const minItems = Math.floor(n)
|
|
6716
6830
|
if (minItems < 1) {
|
|
6717
6831
|
throw new Error(
|
|
@@ -6749,11 +6863,11 @@ export type MaxItemsSchemaId = typeof MaxItemsSchemaId
|
|
|
6749
6863
|
* @category ReadonlyArray filters
|
|
6750
6864
|
* @since 3.10.0
|
|
6751
6865
|
*/
|
|
6752
|
-
export const maxItems = <
|
|
6866
|
+
export const maxItems = <S extends Schema.Any>(
|
|
6753
6867
|
n: number,
|
|
6754
|
-
annotations?: Annotations.Filter<
|
|
6868
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6755
6869
|
) =>
|
|
6756
|
-
<
|
|
6870
|
+
<A extends ReadonlyArray<any>>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
6757
6871
|
const maxItems = Math.floor(n)
|
|
6758
6872
|
if (maxItems < 1) {
|
|
6759
6873
|
throw new Error(
|
|
@@ -6788,11 +6902,11 @@ export type ItemsCountSchemaId = typeof ItemsCountSchemaId
|
|
|
6788
6902
|
* @category ReadonlyArray filters
|
|
6789
6903
|
* @since 3.10.0
|
|
6790
6904
|
*/
|
|
6791
|
-
export const itemsCount = <
|
|
6905
|
+
export const itemsCount = <S extends Schema.Any>(
|
|
6792
6906
|
n: number,
|
|
6793
|
-
annotations?: Annotations.Filter<
|
|
6907
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6794
6908
|
) =>
|
|
6795
|
-
<
|
|
6909
|
+
<A extends ReadonlyArray<any>>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
6796
6910
|
const itemsCount = Math.floor(n)
|
|
6797
6911
|
if (itemsCount < 0) {
|
|
6798
6912
|
throw new Error(
|
|
@@ -6825,12 +6939,23 @@ export const getNumberIndexedAccess = <A extends ReadonlyArray<any>, I extends R
|
|
|
6825
6939
|
* @category ReadonlyArray transformations
|
|
6826
6940
|
* @since 3.10.0
|
|
6827
6941
|
*/
|
|
6828
|
-
export
|
|
6829
|
-
|
|
6942
|
+
export function head<S extends Schema.Any, A extends ReadonlyArray<unknown>>(
|
|
6943
|
+
self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>
|
|
6944
|
+
): transform<S, OptionFromSelf<SchemaClass<A[number]>>> {
|
|
6945
|
+
return transform(
|
|
6830
6946
|
self,
|
|
6831
6947
|
OptionFromSelf(getNumberIndexedAccess(typeSchema(self))),
|
|
6832
|
-
{
|
|
6948
|
+
{
|
|
6949
|
+
strict: false,
|
|
6950
|
+
decode: (i) => array_.head(i),
|
|
6951
|
+
encode: (a) =>
|
|
6952
|
+
option_.match(a, {
|
|
6953
|
+
onNone: () => [],
|
|
6954
|
+
onSome: array_.of
|
|
6955
|
+
})
|
|
6956
|
+
}
|
|
6833
6957
|
)
|
|
6958
|
+
}
|
|
6834
6959
|
|
|
6835
6960
|
/**
|
|
6836
6961
|
* Get the first element of a `NonEmptyReadonlyArray`.
|
|
@@ -6838,12 +6963,19 @@ export const head = <A, I, R>(self: Schema<ReadonlyArray<A>, I, R>): SchemaClass
|
|
|
6838
6963
|
* @category NonEmptyReadonlyArray transformations
|
|
6839
6964
|
* @since 3.12.0
|
|
6840
6965
|
*/
|
|
6841
|
-
export
|
|
6842
|
-
|
|
6966
|
+
export function headNonEmpty<S extends Schema.Any, A extends array_.NonEmptyReadonlyArray<unknown>>(
|
|
6967
|
+
self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>
|
|
6968
|
+
): transform<S, SchemaClass<A[number]>> {
|
|
6969
|
+
return transform(
|
|
6843
6970
|
self,
|
|
6844
6971
|
getNumberIndexedAccess(typeSchema(self)),
|
|
6845
|
-
{
|
|
6972
|
+
{
|
|
6973
|
+
strict: false,
|
|
6974
|
+
decode: (i) => array_.headNonEmpty(i),
|
|
6975
|
+
encode: (a) => array_.of(a)
|
|
6976
|
+
}
|
|
6846
6977
|
)
|
|
6978
|
+
}
|
|
6847
6979
|
|
|
6848
6980
|
/**
|
|
6849
6981
|
* Retrieves the first element of a `ReadonlyArray`.
|
|
@@ -6862,7 +6994,9 @@ export const headOrElse: {
|
|
|
6862
6994
|
* @category ReadonlyArray transformations
|
|
6863
6995
|
* @since 3.10.0
|
|
6864
6996
|
*/
|
|
6865
|
-
<A
|
|
6997
|
+
<S extends Schema.Any, A extends ReadonlyArray<unknown>>(fallback?: LazyArg<A[number]>): (
|
|
6998
|
+
self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>
|
|
6999
|
+
) => transform<S, SchemaClass<A[number]>>
|
|
6866
7000
|
/**
|
|
6867
7001
|
* Retrieves the first element of a `ReadonlyArray`.
|
|
6868
7002
|
*
|
|
@@ -6871,21 +7005,27 @@ export const headOrElse: {
|
|
|
6871
7005
|
* @category ReadonlyArray transformations
|
|
6872
7006
|
* @since 3.10.0
|
|
6873
7007
|
*/
|
|
6874
|
-
<
|
|
7008
|
+
<S extends Schema.Any, A extends ReadonlyArray<unknown>>(
|
|
7009
|
+
self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>,
|
|
7010
|
+
fallback?: LazyArg<A[number]>
|
|
7011
|
+
): transform<S, SchemaClass<A[number]>>
|
|
6875
7012
|
} = dual(
|
|
6876
7013
|
(args) => isSchema(args[0]),
|
|
6877
|
-
<A, I, R>(
|
|
7014
|
+
<A, I, R>(
|
|
7015
|
+
self: Schema<ReadonlyArray<A>, I, R>,
|
|
7016
|
+
fallback?: LazyArg<A>
|
|
7017
|
+
): transform<Schema<ReadonlyArray<A>, I, R>, SchemaClass<A>> =>
|
|
6878
7018
|
transformOrFail(
|
|
6879
7019
|
self,
|
|
6880
7020
|
getNumberIndexedAccess(typeSchema(self)),
|
|
6881
7021
|
{
|
|
6882
7022
|
strict: true,
|
|
6883
|
-
decode: (
|
|
6884
|
-
|
|
6885
|
-
? ParseResult.succeed(
|
|
7023
|
+
decode: (i, _, ast) =>
|
|
7024
|
+
i.length > 0
|
|
7025
|
+
? ParseResult.succeed(i[0])
|
|
6886
7026
|
: fallback
|
|
6887
7027
|
? ParseResult.succeed(fallback())
|
|
6888
|
-
: ParseResult.fail(new ParseResult.Type(ast,
|
|
7028
|
+
: ParseResult.fail(new ParseResult.Type(ast, i, "Unable to retrieve the first element of an empty array")),
|
|
6889
7029
|
encode: (a) => ParseResult.succeed(array_.of(a))
|
|
6890
7030
|
}
|
|
6891
7031
|
)
|
|
@@ -6907,7 +7047,8 @@ export const ValidDateSchemaId: unique symbol = Symbol.for("effect/SchemaId/Vali
|
|
|
6907
7047
|
* @since 3.10.0
|
|
6908
7048
|
*/
|
|
6909
7049
|
export const validDate =
|
|
6910
|
-
(annotations?: Annotations.Filter<
|
|
7050
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
7051
|
+
<A extends Date>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
6911
7052
|
self.pipe(
|
|
6912
7053
|
filter((a) => !Number.isNaN(a.getTime()), {
|
|
6913
7054
|
schemaId: ValidDateSchemaId,
|
|
@@ -6928,13 +7069,13 @@ export const LessThanDateSchemaId: unique symbol = Symbol.for("effect/SchemaId/L
|
|
|
6928
7069
|
* @category Date filters
|
|
6929
7070
|
* @since 3.10.0
|
|
6930
7071
|
*/
|
|
6931
|
-
export const lessThanDate = <
|
|
7072
|
+
export const lessThanDate = <S extends Schema.Any>(
|
|
6932
7073
|
max: Date,
|
|
6933
|
-
annotations?: Annotations.Filter<
|
|
7074
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6934
7075
|
) =>
|
|
6935
|
-
<
|
|
7076
|
+
<A extends Date>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
6936
7077
|
self.pipe(
|
|
6937
|
-
filter((a) => a < max, {
|
|
7078
|
+
filter((a: Date) => a < max, {
|
|
6938
7079
|
schemaId: LessThanDateSchemaId,
|
|
6939
7080
|
[LessThanDateSchemaId]: { max },
|
|
6940
7081
|
title: `lessThanDate(${util_.formatDate(max)})`,
|
|
@@ -6955,13 +7096,13 @@ export const LessThanOrEqualToDateSchemaId: unique symbol = Symbol.for(
|
|
|
6955
7096
|
* @category Date filters
|
|
6956
7097
|
* @since 3.10.0
|
|
6957
7098
|
*/
|
|
6958
|
-
export const lessThanOrEqualToDate = <
|
|
7099
|
+
export const lessThanOrEqualToDate = <S extends Schema.Any>(
|
|
6959
7100
|
max: Date,
|
|
6960
|
-
annotations?: Annotations.Filter<
|
|
7101
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6961
7102
|
) =>
|
|
6962
|
-
<
|
|
7103
|
+
<A extends Date>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
6963
7104
|
self.pipe(
|
|
6964
|
-
filter((a) => a <= max, {
|
|
7105
|
+
filter((a: Date) => a <= max, {
|
|
6965
7106
|
schemaId: LessThanDateSchemaId,
|
|
6966
7107
|
[LessThanDateSchemaId]: { max },
|
|
6967
7108
|
title: `lessThanOrEqualToDate(${util_.formatDate(max)})`,
|
|
@@ -6980,13 +7121,13 @@ export const GreaterThanDateSchemaId: unique symbol = Symbol.for("effect/SchemaI
|
|
|
6980
7121
|
* @category Date filters
|
|
6981
7122
|
* @since 3.10.0
|
|
6982
7123
|
*/
|
|
6983
|
-
export const greaterThanDate = <
|
|
7124
|
+
export const greaterThanDate = <S extends Schema.Any>(
|
|
6984
7125
|
min: Date,
|
|
6985
|
-
annotations?: Annotations.Filter<
|
|
7126
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
6986
7127
|
) =>
|
|
6987
|
-
<
|
|
7128
|
+
<A extends Date>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
6988
7129
|
self.pipe(
|
|
6989
|
-
filter((a) => a > min, {
|
|
7130
|
+
filter((a: Date) => a > min, {
|
|
6990
7131
|
schemaId: GreaterThanDateSchemaId,
|
|
6991
7132
|
[GreaterThanDateSchemaId]: { min },
|
|
6992
7133
|
title: `greaterThanDate(${util_.formatDate(min)})`,
|
|
@@ -7007,13 +7148,13 @@ export const GreaterThanOrEqualToDateSchemaId: unique symbol = Symbol.for(
|
|
|
7007
7148
|
* @category Date filters
|
|
7008
7149
|
* @since 3.10.0
|
|
7009
7150
|
*/
|
|
7010
|
-
export const greaterThanOrEqualToDate = <
|
|
7151
|
+
export const greaterThanOrEqualToDate = <S extends Schema.Any>(
|
|
7011
7152
|
min: Date,
|
|
7012
|
-
annotations?: Annotations.Filter<
|
|
7153
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
7013
7154
|
) =>
|
|
7014
|
-
<
|
|
7155
|
+
<A extends Date>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
7015
7156
|
self.pipe(
|
|
7016
|
-
filter((a) => a >= min, {
|
|
7157
|
+
filter((a: Date) => a >= min, {
|
|
7017
7158
|
schemaId: GreaterThanOrEqualToDateSchemaId,
|
|
7018
7159
|
[GreaterThanOrEqualToDateSchemaId]: { min },
|
|
7019
7160
|
title: `greaterThanOrEqualToDate(${util_.formatDate(min)})`,
|
|
@@ -7032,14 +7173,14 @@ export const BetweenDateSchemaId: unique symbol = Symbol.for("effect/SchemaId/Be
|
|
|
7032
7173
|
* @category Date filters
|
|
7033
7174
|
* @since 3.10.0
|
|
7034
7175
|
*/
|
|
7035
|
-
export const betweenDate = <
|
|
7176
|
+
export const betweenDate = <S extends Schema.Any>(
|
|
7036
7177
|
min: Date,
|
|
7037
7178
|
max: Date,
|
|
7038
|
-
annotations?: Annotations.Filter<
|
|
7179
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
7039
7180
|
) =>
|
|
7040
|
-
<
|
|
7181
|
+
<A extends Date>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
7041
7182
|
self.pipe(
|
|
7042
|
-
filter((a) => a <= max && a >= min, {
|
|
7183
|
+
filter((a: Date) => a <= max && a >= min, {
|
|
7043
7184
|
schemaId: BetweenDateSchemaId,
|
|
7044
7185
|
[BetweenDateSchemaId]: { max, min },
|
|
7045
7186
|
title: `betweenDate(${util_.formatDate(min)}, ${util_.formatDate(max)})`,
|
|
@@ -7109,7 +7250,11 @@ export class ValidDateFromSelf extends DateFromSelf.pipe(
|
|
|
7109
7250
|
export class DateFromString extends transform(
|
|
7110
7251
|
String$.annotations({ description: "a string to be decoded into a Date" }),
|
|
7111
7252
|
DateFromSelf,
|
|
7112
|
-
{
|
|
7253
|
+
{
|
|
7254
|
+
strict: true,
|
|
7255
|
+
decode: (i) => new Date(i),
|
|
7256
|
+
encode: (a) => util_.formatDate(a)
|
|
7257
|
+
}
|
|
7113
7258
|
).annotations({ identifier: "DateFromString" }) {}
|
|
7114
7259
|
|
|
7115
7260
|
/** @ignore */
|
|
@@ -7143,7 +7288,11 @@ export {
|
|
|
7143
7288
|
export class DateFromNumber extends transform(
|
|
7144
7289
|
Number$.annotations({ description: "a number to be decoded into a Date" }),
|
|
7145
7290
|
DateFromSelf,
|
|
7146
|
-
{
|
|
7291
|
+
{
|
|
7292
|
+
strict: true,
|
|
7293
|
+
decode: (i) => new Date(i),
|
|
7294
|
+
encode: (a) => a.getTime()
|
|
7295
|
+
}
|
|
7147
7296
|
).annotations({ identifier: "DateFromNumber" }) {}
|
|
7148
7297
|
|
|
7149
7298
|
/**
|
|
@@ -7164,7 +7313,7 @@ export class DateTimeUtcFromSelf extends declare(
|
|
|
7164
7313
|
}
|
|
7165
7314
|
) {}
|
|
7166
7315
|
|
|
7167
|
-
const decodeDateTimeUtc = <A extends dateTime.DateTime.Input>(input: A,
|
|
7316
|
+
const decodeDateTimeUtc = <A extends dateTime.DateTime.Input>(input: A, ast: AST.AST) =>
|
|
7168
7317
|
ParseResult.try({
|
|
7169
7318
|
try: () => dateTime.unsafeMake(input),
|
|
7170
7319
|
catch: () => new ParseResult.Type(ast, input, `Unable to decode ${util_.formatUnknown(input)} into a DateTime.Utc`)
|
|
@@ -7181,8 +7330,8 @@ export class DateTimeUtcFromNumber extends transformOrFail(
|
|
|
7181
7330
|
DateTimeUtcFromSelf,
|
|
7182
7331
|
{
|
|
7183
7332
|
strict: true,
|
|
7184
|
-
decode: decodeDateTimeUtc,
|
|
7185
|
-
encode: (
|
|
7333
|
+
decode: (i, _, ast) => decodeDateTimeUtc(i, ast),
|
|
7334
|
+
encode: (a) => ParseResult.succeed(dateTime.toEpochMillis(a))
|
|
7186
7335
|
}
|
|
7187
7336
|
).annotations({ identifier: "DateTimeUtcFromNumber" }) {}
|
|
7188
7337
|
|
|
@@ -7197,8 +7346,8 @@ export class DateTimeUtcFromDate extends transformOrFail(
|
|
|
7197
7346
|
DateTimeUtcFromSelf,
|
|
7198
7347
|
{
|
|
7199
7348
|
strict: true,
|
|
7200
|
-
decode: decodeDateTimeUtc,
|
|
7201
|
-
encode: (
|
|
7349
|
+
decode: (i, _, ast) => decodeDateTimeUtc(i, ast),
|
|
7350
|
+
encode: (a) => ParseResult.succeed(dateTime.toDateUtc(a))
|
|
7202
7351
|
}
|
|
7203
7352
|
).annotations({ identifier: "DateTimeUtcFromDate" }) {}
|
|
7204
7353
|
|
|
@@ -7213,8 +7362,8 @@ export class DateTimeUtc extends transformOrFail(
|
|
|
7213
7362
|
DateTimeUtcFromSelf,
|
|
7214
7363
|
{
|
|
7215
7364
|
strict: true,
|
|
7216
|
-
decode: decodeDateTimeUtc,
|
|
7217
|
-
encode: (
|
|
7365
|
+
decode: (i, _, ast) => decodeDateTimeUtc(i, ast),
|
|
7366
|
+
encode: (a) => ParseResult.succeed(dateTime.formatIso(a))
|
|
7218
7367
|
}
|
|
7219
7368
|
).annotations({ identifier: "DateTimeUtc" }) {}
|
|
7220
7369
|
|
|
@@ -7246,7 +7395,11 @@ export class TimeZoneOffsetFromSelf extends declare(
|
|
|
7246
7395
|
export class TimeZoneOffset extends transform(
|
|
7247
7396
|
Number$.annotations({ description: "a number to be decoded into a TimeZone.Offset" }),
|
|
7248
7397
|
TimeZoneOffsetFromSelf,
|
|
7249
|
-
{
|
|
7398
|
+
{
|
|
7399
|
+
strict: true,
|
|
7400
|
+
decode: (i) => dateTime.zoneMakeOffset(i),
|
|
7401
|
+
encode: (a) => a.offset
|
|
7402
|
+
}
|
|
7250
7403
|
).annotations({ identifier: "TimeZoneOffset" }) {}
|
|
7251
7404
|
|
|
7252
7405
|
const timeZoneNamedArbitrary = (): LazyArbitrary<dateTime.TimeZone.Named> => (fc) =>
|
|
@@ -7279,12 +7432,12 @@ export class TimeZoneNamed extends transformOrFail(
|
|
|
7279
7432
|
TimeZoneNamedFromSelf,
|
|
7280
7433
|
{
|
|
7281
7434
|
strict: true,
|
|
7282
|
-
decode: (
|
|
7435
|
+
decode: (i, _, ast) =>
|
|
7283
7436
|
ParseResult.try({
|
|
7284
|
-
try: () => dateTime.zoneUnsafeMakeNamed(
|
|
7285
|
-
catch: () => new ParseResult.Type(ast,
|
|
7437
|
+
try: () => dateTime.zoneUnsafeMakeNamed(i),
|
|
7438
|
+
catch: () => new ParseResult.Type(ast, i, `Unable to decode ${JSON.stringify(i)} into a TimeZone.Named`)
|
|
7286
7439
|
}),
|
|
7287
|
-
encode: (
|
|
7440
|
+
encode: (a) => ParseResult.succeed(a.id)
|
|
7288
7441
|
}
|
|
7289
7442
|
).annotations({ identifier: "TimeZoneNamed" }) {}
|
|
7290
7443
|
|
|
@@ -7305,13 +7458,13 @@ export class TimeZone extends transformOrFail(
|
|
|
7305
7458
|
TimeZoneFromSelf,
|
|
7306
7459
|
{
|
|
7307
7460
|
strict: true,
|
|
7308
|
-
decode: (
|
|
7309
|
-
option_.match(dateTime.zoneFromString(
|
|
7461
|
+
decode: (i, _, ast) =>
|
|
7462
|
+
option_.match(dateTime.zoneFromString(i), {
|
|
7310
7463
|
onNone: () =>
|
|
7311
|
-
ParseResult.fail(new ParseResult.Type(ast,
|
|
7464
|
+
ParseResult.fail(new ParseResult.Type(ast, i, `Unable to decode ${JSON.stringify(i)} into a TimeZone`)),
|
|
7312
7465
|
onSome: ParseResult.succeed
|
|
7313
7466
|
}),
|
|
7314
|
-
encode: (
|
|
7467
|
+
encode: (a) => ParseResult.succeed(dateTime.zoneToString(a))
|
|
7315
7468
|
}
|
|
7316
7469
|
).annotations({ identifier: "TimeZone" }) {}
|
|
7317
7470
|
|
|
@@ -7357,13 +7510,13 @@ export class DateTimeZoned extends transformOrFail(
|
|
|
7357
7510
|
DateTimeZonedFromSelf,
|
|
7358
7511
|
{
|
|
7359
7512
|
strict: true,
|
|
7360
|
-
decode: (
|
|
7361
|
-
option_.match(dateTime.makeZonedFromString(
|
|
7513
|
+
decode: (i, _, ast) =>
|
|
7514
|
+
option_.match(dateTime.makeZonedFromString(i), {
|
|
7362
7515
|
onNone: () =>
|
|
7363
|
-
ParseResult.fail(new ParseResult.Type(ast,
|
|
7516
|
+
ParseResult.fail(new ParseResult.Type(ast, i, `Unable to decode ${JSON.stringify(i)} into a DateTime.Zoned`)),
|
|
7364
7517
|
onSome: ParseResult.succeed
|
|
7365
7518
|
}),
|
|
7366
|
-
encode: (
|
|
7519
|
+
encode: (a) => ParseResult.succeed(dateTime.formatIsoZoned(a))
|
|
7367
7520
|
}
|
|
7368
7521
|
).annotations({ identifier: "DateTimeZoned" }) {}
|
|
7369
7522
|
|
|
@@ -7384,13 +7537,13 @@ const OptionNoneEncoded = Struct({
|
|
|
7384
7537
|
_tag: Literal("None")
|
|
7385
7538
|
}).annotations({ description: "NoneEncoded" })
|
|
7386
7539
|
|
|
7387
|
-
const optionSomeEncoded = <
|
|
7540
|
+
const optionSomeEncoded = <Value extends Schema.Any>(value: Value) =>
|
|
7388
7541
|
Struct({
|
|
7389
7542
|
_tag: Literal("Some"),
|
|
7390
7543
|
value
|
|
7391
7544
|
}).annotations({ description: `SomeEncoded<${format(value)}>` })
|
|
7392
7545
|
|
|
7393
|
-
const optionEncoded = <
|
|
7546
|
+
const optionEncoded = <Value extends Schema.Any>(value: Value) =>
|
|
7394
7547
|
Union(
|
|
7395
7548
|
OptionNoneEncoded,
|
|
7396
7549
|
optionSomeEncoded(value)
|
|
@@ -7429,11 +7582,11 @@ const optionParse =
|
|
|
7429
7582
|
* @since 3.10.0
|
|
7430
7583
|
*/
|
|
7431
7584
|
export interface OptionFromSelf<Value extends Schema.Any> extends
|
|
7432
|
-
|
|
7585
|
+
AnnotableDeclare<
|
|
7433
7586
|
OptionFromSelf<Value>,
|
|
7434
7587
|
option_.Option<Schema.Type<Value>>,
|
|
7435
7588
|
option_.Option<Schema.Encoded<Value>>,
|
|
7436
|
-
|
|
7589
|
+
[Value]
|
|
7437
7590
|
>
|
|
7438
7591
|
{}
|
|
7439
7592
|
|
|
@@ -7441,9 +7594,7 @@ export interface OptionFromSelf<Value extends Schema.Any> extends
|
|
|
7441
7594
|
* @category Option transformations
|
|
7442
7595
|
* @since 3.10.0
|
|
7443
7596
|
*/
|
|
7444
|
-
export const OptionFromSelf = <Value extends Schema.Any>(
|
|
7445
|
-
value: Value
|
|
7446
|
-
): OptionFromSelf<Value> => {
|
|
7597
|
+
export const OptionFromSelf = <Value extends Schema.Any>(value: Value): OptionFromSelf<Value> => {
|
|
7447
7598
|
return declare(
|
|
7448
7599
|
[value],
|
|
7449
7600
|
{
|
|
@@ -7459,72 +7610,68 @@ export const OptionFromSelf = <Value extends Schema.Any>(
|
|
|
7459
7610
|
)
|
|
7460
7611
|
}
|
|
7461
7612
|
|
|
7462
|
-
const makeNoneEncoded = {
|
|
7463
|
-
_tag: "None"
|
|
7464
|
-
} as const
|
|
7465
|
-
const makeSomeEncoded = <A>(value: A) => ({
|
|
7466
|
-
_tag: "Some",
|
|
7467
|
-
value
|
|
7468
|
-
} as const)
|
|
7469
|
-
|
|
7470
7613
|
/**
|
|
7471
7614
|
* @category api interface
|
|
7472
7615
|
* @since 3.10.0
|
|
7473
7616
|
*/
|
|
7474
7617
|
export interface Option<Value extends Schema.Any> extends
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7618
|
+
transform<
|
|
7619
|
+
Union<[
|
|
7620
|
+
Struct<{ _tag: Literal<["None"]> }>,
|
|
7621
|
+
Struct<{ _tag: Literal<["Some"]>; value: Value }>
|
|
7622
|
+
]>,
|
|
7623
|
+
OptionFromSelf<SchemaClass<Schema.Type<Value>>>
|
|
7480
7624
|
>
|
|
7481
7625
|
{}
|
|
7482
7626
|
|
|
7627
|
+
const makeNoneEncoded = {
|
|
7628
|
+
_tag: "None"
|
|
7629
|
+
} as const
|
|
7630
|
+
|
|
7631
|
+
const makeSomeEncoded = <A>(value: A) => ({
|
|
7632
|
+
_tag: "Some",
|
|
7633
|
+
value
|
|
7634
|
+
} as const)
|
|
7635
|
+
|
|
7483
7636
|
/**
|
|
7484
7637
|
* @category Option transformations
|
|
7485
7638
|
* @since 3.10.0
|
|
7486
7639
|
*/
|
|
7487
|
-
export
|
|
7640
|
+
export function Option<Value extends Schema.Any>(value: Value): Option<Value> {
|
|
7488
7641
|
const value_ = asSchema(value)
|
|
7489
|
-
|
|
7642
|
+
const out = transform(
|
|
7490
7643
|
optionEncoded(value_),
|
|
7491
7644
|
OptionFromSelf(typeSchema(value_)),
|
|
7492
7645
|
{
|
|
7493
7646
|
strict: true,
|
|
7494
|
-
decode: optionDecode,
|
|
7495
|
-
encode:
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7647
|
+
decode: (i) => optionDecode(i),
|
|
7648
|
+
encode: (a) =>
|
|
7649
|
+
option_.match(a, {
|
|
7650
|
+
onNone: () => makeNoneEncoded,
|
|
7651
|
+
onSome: makeSomeEncoded
|
|
7652
|
+
})
|
|
7499
7653
|
}
|
|
7500
7654
|
)
|
|
7655
|
+
return out as any
|
|
7501
7656
|
}
|
|
7502
7657
|
|
|
7503
7658
|
/**
|
|
7504
7659
|
* @category api interface
|
|
7505
7660
|
* @since 3.10.0
|
|
7506
7661
|
*/
|
|
7507
|
-
export interface OptionFromNullOr<Value extends Schema.Any>
|
|
7508
|
-
|
|
7509
|
-
OptionFromNullOr<Value>,
|
|
7510
|
-
option_.Option<Schema.Type<Value>>,
|
|
7511
|
-
Schema.Encoded<Value> | null,
|
|
7512
|
-
Schema.Context<Value>
|
|
7513
|
-
>
|
|
7662
|
+
export interface OptionFromNullOr<Value extends Schema.Any>
|
|
7663
|
+
extends transform<NullOr<Value>, OptionFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
7514
7664
|
{}
|
|
7515
7665
|
|
|
7516
7666
|
/**
|
|
7517
7667
|
* @category Option transformations
|
|
7518
7668
|
* @since 3.10.0
|
|
7519
7669
|
*/
|
|
7520
|
-
export
|
|
7521
|
-
value
|
|
7522
|
-
): OptionFromNullOr<Value> => {
|
|
7523
|
-
const value_ = asSchema(value)
|
|
7524
|
-
return transform(NullOr(value_), OptionFromSelf(typeSchema(value_)), {
|
|
7670
|
+
export function OptionFromNullOr<Value extends Schema.Any>(value: Value): OptionFromNullOr<Value> {
|
|
7671
|
+
return transform(NullOr(value), OptionFromSelf(typeSchema(asSchema(value))), {
|
|
7525
7672
|
strict: true,
|
|
7526
|
-
decode: option_.fromNullable,
|
|
7527
|
-
encode: option_.getOrNull
|
|
7673
|
+
decode: (i) => option_.fromNullable(i),
|
|
7674
|
+
encode: (a) => option_.getOrNull(a)
|
|
7528
7675
|
})
|
|
7529
7676
|
}
|
|
7530
7677
|
|
|
@@ -7532,31 +7679,27 @@ export const OptionFromNullOr = <Value extends Schema.Any>(
|
|
|
7532
7679
|
* @category api interface
|
|
7533
7680
|
* @since 3.10.0
|
|
7534
7681
|
*/
|
|
7535
|
-
export interface OptionFromNullishOr<Value extends Schema.Any>
|
|
7536
|
-
|
|
7537
|
-
OptionFromNullishOr<Value>,
|
|
7538
|
-
option_.Option<Schema.Type<Value>>,
|
|
7539
|
-
Schema.Encoded<Value> | null | undefined,
|
|
7540
|
-
Schema.Context<Value>
|
|
7541
|
-
>
|
|
7682
|
+
export interface OptionFromNullishOr<Value extends Schema.Any>
|
|
7683
|
+
extends transform<NullishOr<Value>, OptionFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
7542
7684
|
{}
|
|
7543
7685
|
|
|
7544
7686
|
/**
|
|
7545
7687
|
* @category Option transformations
|
|
7546
7688
|
* @since 3.10.0
|
|
7547
7689
|
*/
|
|
7548
|
-
export
|
|
7690
|
+
export function OptionFromNullishOr<Value extends Schema.Any>(
|
|
7549
7691
|
value: Value,
|
|
7550
7692
|
onNoneEncoding: null | undefined
|
|
7551
|
-
): OptionFromNullishOr<Value>
|
|
7552
|
-
const value_ = asSchema(value)
|
|
7693
|
+
): OptionFromNullishOr<Value> {
|
|
7553
7694
|
return transform(
|
|
7554
|
-
NullishOr(
|
|
7555
|
-
OptionFromSelf(typeSchema(
|
|
7695
|
+
NullishOr(value),
|
|
7696
|
+
OptionFromSelf(typeSchema(asSchema(value))),
|
|
7556
7697
|
{
|
|
7557
7698
|
strict: true,
|
|
7558
|
-
decode: option_.fromNullable,
|
|
7559
|
-
encode: onNoneEncoding === null ?
|
|
7699
|
+
decode: (i) => option_.fromNullable(i),
|
|
7700
|
+
encode: onNoneEncoding === null ?
|
|
7701
|
+
(a) => option_.getOrNull(a) :
|
|
7702
|
+
(a) => option_.getOrUndefined(a)
|
|
7560
7703
|
}
|
|
7561
7704
|
)
|
|
7562
7705
|
}
|
|
@@ -7565,27 +7708,19 @@ export const OptionFromNullishOr = <Value extends Schema.Any>(
|
|
|
7565
7708
|
* @category api interface
|
|
7566
7709
|
* @since 3.10.0
|
|
7567
7710
|
*/
|
|
7568
|
-
export interface OptionFromUndefinedOr<Value extends Schema.Any>
|
|
7569
|
-
|
|
7570
|
-
OptionFromUndefinedOr<Value>,
|
|
7571
|
-
option_.Option<Schema.Type<Value>>,
|
|
7572
|
-
Schema.Encoded<Value> | undefined,
|
|
7573
|
-
Schema.Context<Value>
|
|
7574
|
-
>
|
|
7711
|
+
export interface OptionFromUndefinedOr<Value extends Schema.Any>
|
|
7712
|
+
extends transform<UndefinedOr<Value>, OptionFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
7575
7713
|
{}
|
|
7576
7714
|
|
|
7577
7715
|
/**
|
|
7578
7716
|
* @category Option transformations
|
|
7579
7717
|
* @since 3.10.0
|
|
7580
7718
|
*/
|
|
7581
|
-
export
|
|
7582
|
-
value
|
|
7583
|
-
): OptionFromUndefinedOr<Value> => {
|
|
7584
|
-
const value_ = asSchema(value)
|
|
7585
|
-
return transform(UndefinedOr(value_), OptionFromSelf(typeSchema(value_)), {
|
|
7719
|
+
export function OptionFromUndefinedOr<Value extends Schema.Any>(value: Value): OptionFromUndefinedOr<Value> {
|
|
7720
|
+
return transform(UndefinedOr(value), OptionFromSelf(typeSchema(asSchema(value))), {
|
|
7586
7721
|
strict: true,
|
|
7587
|
-
decode: option_.fromNullable,
|
|
7588
|
-
encode: option_.getOrUndefined
|
|
7722
|
+
decode: (i) => option_.fromNullable(i),
|
|
7723
|
+
encode: (a) => option_.getOrUndefined(a)
|
|
7589
7724
|
})
|
|
7590
7725
|
}
|
|
7591
7726
|
|
|
@@ -7606,11 +7741,11 @@ export const OptionFromUndefinedOr = <Value extends Schema.Any>(
|
|
|
7606
7741
|
* @category Option transformations
|
|
7607
7742
|
* @since 3.10.0
|
|
7608
7743
|
*/
|
|
7609
|
-
export
|
|
7744
|
+
export class OptionFromNonEmptyTrimmedString extends transform(String$, OptionFromSelf(NonEmptyTrimmedString), {
|
|
7610
7745
|
strict: true,
|
|
7611
|
-
decode: (
|
|
7612
|
-
encode: option_.getOrElse(() => "")
|
|
7613
|
-
})
|
|
7746
|
+
decode: (i) => option_.filter(option_.some(i.trim()), string_.isNonEmpty),
|
|
7747
|
+
encode: (a) => option_.getOrElse(a, () => "")
|
|
7748
|
+
}) {}
|
|
7614
7749
|
|
|
7615
7750
|
/**
|
|
7616
7751
|
* @category Either utils
|
|
@@ -7636,21 +7771,21 @@ export type LeftEncoded<IE> = {
|
|
|
7636
7771
|
*/
|
|
7637
7772
|
export type EitherEncoded<IR, IL> = RightEncoded<IR> | LeftEncoded<IL>
|
|
7638
7773
|
|
|
7639
|
-
const rightEncoded = <
|
|
7774
|
+
const rightEncoded = <Right extends Schema.All>(right: Right) =>
|
|
7640
7775
|
Struct({
|
|
7641
7776
|
_tag: Literal("Right"),
|
|
7642
7777
|
right
|
|
7643
7778
|
}).annotations({ description: `RightEncoded<${format(right)}>` })
|
|
7644
7779
|
|
|
7645
|
-
const leftEncoded = <
|
|
7780
|
+
const leftEncoded = <Left extends Schema.All>(left: Left) =>
|
|
7646
7781
|
Struct({
|
|
7647
7782
|
_tag: Literal("Left"),
|
|
7648
7783
|
left
|
|
7649
7784
|
}).annotations({ description: `LeftEncoded<${format(left)}>` })
|
|
7650
7785
|
|
|
7651
|
-
const eitherEncoded = <
|
|
7652
|
-
right:
|
|
7653
|
-
left:
|
|
7786
|
+
const eitherEncoded = <Right extends Schema.All, Left extends Schema.All>(
|
|
7787
|
+
right: Right,
|
|
7788
|
+
left: Left
|
|
7654
7789
|
) =>
|
|
7655
7790
|
Union(rightEncoded(right), leftEncoded(left)).annotations({
|
|
7656
7791
|
description: `EitherEncoded<${format(left)}, ${format(right)}>`
|
|
@@ -7695,11 +7830,11 @@ const eitherParse = <RR, R, LR, L>(
|
|
|
7695
7830
|
* @since 3.10.0
|
|
7696
7831
|
*/
|
|
7697
7832
|
export interface EitherFromSelf<R extends Schema.All, L extends Schema.All> extends
|
|
7698
|
-
|
|
7833
|
+
AnnotableDeclare<
|
|
7699
7834
|
EitherFromSelf<R, L>,
|
|
7700
7835
|
either_.Either<Schema.Type<R>, Schema.Type<L>>,
|
|
7701
7836
|
either_.Either<Schema.Encoded<R>, Schema.Encoded<L>>,
|
|
7702
|
-
|
|
7837
|
+
[R, L]
|
|
7703
7838
|
>
|
|
7704
7839
|
{}
|
|
7705
7840
|
|
|
@@ -7739,12 +7874,19 @@ const makeRightEncoded = <A>(right: A) => (({
|
|
|
7739
7874
|
* @category api interface
|
|
7740
7875
|
* @since 3.10.0
|
|
7741
7876
|
*/
|
|
7742
|
-
export interface Either<
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7877
|
+
export interface Either<Right extends Schema.All, Left extends Schema.All> extends
|
|
7878
|
+
transform<
|
|
7879
|
+
Union<[
|
|
7880
|
+
Struct<{
|
|
7881
|
+
_tag: Literal<["Right"]>
|
|
7882
|
+
right: Right
|
|
7883
|
+
}>,
|
|
7884
|
+
Struct<{
|
|
7885
|
+
_tag: Literal<["Left"]>
|
|
7886
|
+
left: Left
|
|
7887
|
+
}>
|
|
7888
|
+
]>,
|
|
7889
|
+
EitherFromSelf<SchemaClass<Schema.Type<Right>>, SchemaClass<Schema.Type<Left>>>
|
|
7748
7890
|
>
|
|
7749
7891
|
{}
|
|
7750
7892
|
|
|
@@ -7758,27 +7900,33 @@ export const Either = <R extends Schema.All, L extends Schema.All>({ left, right
|
|
|
7758
7900
|
}): Either<R, L> => {
|
|
7759
7901
|
const right_ = asSchema(right)
|
|
7760
7902
|
const left_ = asSchema(left)
|
|
7761
|
-
|
|
7903
|
+
const out = transform(
|
|
7762
7904
|
eitherEncoded(right_, left_),
|
|
7763
7905
|
EitherFromSelf({ left: typeSchema(left_), right: typeSchema(right_) }),
|
|
7764
7906
|
{
|
|
7765
7907
|
strict: true,
|
|
7766
|
-
decode: eitherDecode,
|
|
7767
|
-
encode:
|
|
7908
|
+
decode: (i) => eitherDecode(i),
|
|
7909
|
+
encode: (a) =>
|
|
7910
|
+
either_.match(a, {
|
|
7911
|
+
onLeft: makeLeftEncoded,
|
|
7912
|
+
onRight: makeRightEncoded
|
|
7913
|
+
})
|
|
7768
7914
|
}
|
|
7769
7915
|
)
|
|
7916
|
+
return out as any
|
|
7770
7917
|
}
|
|
7771
7918
|
|
|
7772
7919
|
/**
|
|
7773
7920
|
* @category api interface
|
|
7774
7921
|
* @since 3.10.0
|
|
7775
7922
|
*/
|
|
7776
|
-
export interface EitherFromUnion<
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7923
|
+
export interface EitherFromUnion<Right extends Schema.All, Left extends Schema.All> extends
|
|
7924
|
+
transform<
|
|
7925
|
+
Union<[
|
|
7926
|
+
transform<Right, Struct<{ _tag: Literal<["Right"]>; right: SchemaClass<Schema.Type<Right>> }>>,
|
|
7927
|
+
transform<Left, Struct<{ _tag: Literal<["Left"]>; right: SchemaClass<Schema.Type<Left>> }>>
|
|
7928
|
+
]>,
|
|
7929
|
+
EitherFromSelf<SchemaClass<Schema.Type<Right>>, SchemaClass<Schema.Type<Left>>>
|
|
7782
7930
|
>
|
|
7783
7931
|
{}
|
|
7784
7932
|
|
|
@@ -7794,33 +7942,38 @@ export interface EitherFromUnion<R extends Schema.All, L extends Schema.All> ext
|
|
|
7794
7942
|
* @category Either transformations
|
|
7795
7943
|
* @since 3.10.0
|
|
7796
7944
|
*/
|
|
7797
|
-
export const EitherFromUnion = <
|
|
7798
|
-
readonly left:
|
|
7799
|
-
readonly right:
|
|
7800
|
-
}): EitherFromUnion<
|
|
7945
|
+
export const EitherFromUnion = <Right extends Schema.All, Left extends Schema.All>({ left, right }: {
|
|
7946
|
+
readonly left: Left
|
|
7947
|
+
readonly right: Right
|
|
7948
|
+
}): EitherFromUnion<Right, Left> => {
|
|
7801
7949
|
const right_ = asSchema(right)
|
|
7802
7950
|
const left_ = asSchema(left)
|
|
7803
7951
|
const toright = typeSchema(right_)
|
|
7804
7952
|
const toleft = typeSchema(left_)
|
|
7805
7953
|
const fromRight = transform(right_, rightEncoded(toright), {
|
|
7806
7954
|
strict: true,
|
|
7807
|
-
decode: makeRightEncoded,
|
|
7808
|
-
encode: (
|
|
7955
|
+
decode: (i) => makeRightEncoded(i),
|
|
7956
|
+
encode: (a) => a.right
|
|
7809
7957
|
})
|
|
7810
7958
|
const fromLeft = transform(left_, leftEncoded(toleft), {
|
|
7811
7959
|
strict: true,
|
|
7812
|
-
decode: makeLeftEncoded,
|
|
7813
|
-
encode: (
|
|
7960
|
+
decode: (i) => makeLeftEncoded(i),
|
|
7961
|
+
encode: (a) => a.left
|
|
7814
7962
|
})
|
|
7815
|
-
|
|
7963
|
+
const out = transform(
|
|
7816
7964
|
Union(fromRight, fromLeft),
|
|
7817
7965
|
EitherFromSelf({ left: toleft, right: toright }),
|
|
7818
7966
|
{
|
|
7819
7967
|
strict: true,
|
|
7820
|
-
decode: (
|
|
7821
|
-
encode:
|
|
7968
|
+
decode: (i) => i._tag === "Left" ? either_.left(i.left) : either_.right(i.right),
|
|
7969
|
+
encode: (a) =>
|
|
7970
|
+
either_.match(a, {
|
|
7971
|
+
onLeft: makeLeftEncoded,
|
|
7972
|
+
onRight: makeRightEncoded
|
|
7973
|
+
})
|
|
7822
7974
|
}
|
|
7823
7975
|
)
|
|
7976
|
+
return out as any
|
|
7824
7977
|
}
|
|
7825
7978
|
|
|
7826
7979
|
const mapArbitrary = <K, V>(
|
|
@@ -7868,11 +8021,11 @@ const readonlyMapParse = <R, K, V>(
|
|
|
7868
8021
|
* @since 3.10.0
|
|
7869
8022
|
*/
|
|
7870
8023
|
export interface ReadonlyMapFromSelf<K extends Schema.Any, V extends Schema.Any> extends
|
|
7871
|
-
|
|
8024
|
+
AnnotableDeclare<
|
|
7872
8025
|
ReadonlyMapFromSelf<K, V>,
|
|
7873
8026
|
ReadonlyMap<Schema.Type<K>, Schema.Type<V>>,
|
|
7874
8027
|
ReadonlyMap<Schema.Encoded<K>, Schema.Encoded<V>>,
|
|
7875
|
-
|
|
8028
|
+
[K, V]
|
|
7876
8029
|
>
|
|
7877
8030
|
{}
|
|
7878
8031
|
|
|
@@ -7909,11 +8062,11 @@ export const ReadonlyMapFromSelf = <K extends Schema.Any, V extends Schema.Any>(
|
|
|
7909
8062
|
* @since 3.10.0
|
|
7910
8063
|
*/
|
|
7911
8064
|
export interface MapFromSelf<K extends Schema.Any, V extends Schema.Any> extends
|
|
7912
|
-
|
|
8065
|
+
AnnotableDeclare<
|
|
7913
8066
|
MapFromSelf<K, V>,
|
|
7914
8067
|
Map<Schema.Type<K>, Schema.Type<V>>,
|
|
7915
8068
|
ReadonlyMap<Schema.Encoded<K>, Schema.Encoded<V>>,
|
|
7916
|
-
|
|
8069
|
+
[K, V]
|
|
7917
8070
|
>
|
|
7918
8071
|
{}
|
|
7919
8072
|
|
|
@@ -7930,29 +8083,26 @@ export const MapFromSelf = <K extends Schema.Any, V extends Schema.Any>({ key, v
|
|
|
7930
8083
|
* @category api interface
|
|
7931
8084
|
* @since 3.10.0
|
|
7932
8085
|
*/
|
|
7933
|
-
export interface ReadonlyMap$<K extends Schema.Any, V extends Schema.Any>
|
|
7934
|
-
|
|
7935
|
-
ReadonlyMap$<K, V>,
|
|
7936
|
-
ReadonlyMap<Schema.Type<K>, Schema.Type<V>>,
|
|
7937
|
-
ReadonlyArray<readonly [Schema.Encoded<K>, Schema.Encoded<V>]>,
|
|
7938
|
-
Schema.Context<K> | Schema.Context<V>
|
|
7939
|
-
>
|
|
8086
|
+
export interface ReadonlyMap$<K extends Schema.Any, V extends Schema.Any>
|
|
8087
|
+
extends transform<Array$<Tuple2<K, V>>, ReadonlyMapFromSelf<SchemaClass<Schema.Type<K>>, SchemaClass<Schema.Type<V>>>>
|
|
7940
8088
|
{}
|
|
7941
8089
|
|
|
7942
8090
|
/**
|
|
7943
8091
|
* @category ReadonlyMap transformations
|
|
7944
8092
|
* @since 3.10.0
|
|
7945
8093
|
*/
|
|
7946
|
-
export
|
|
8094
|
+
export function ReadonlyMap<K extends Schema.Any, V extends Schema.Any>({ key, value }: {
|
|
7947
8095
|
readonly key: K
|
|
7948
8096
|
readonly value: V
|
|
7949
|
-
}): ReadonlyMap$<K, V>
|
|
7950
|
-
const key_ = asSchema(key)
|
|
7951
|
-
const value_ = asSchema(value)
|
|
8097
|
+
}): ReadonlyMap$<K, V> {
|
|
7952
8098
|
return transform(
|
|
7953
|
-
Array$(Tuple(
|
|
7954
|
-
ReadonlyMapFromSelf({ key: typeSchema(
|
|
7955
|
-
{
|
|
8099
|
+
Array$(Tuple(key, value)),
|
|
8100
|
+
ReadonlyMapFromSelf({ key: typeSchema(asSchema(key)), value: typeSchema(asSchema(value)) }),
|
|
8101
|
+
{
|
|
8102
|
+
strict: true,
|
|
8103
|
+
decode: (i) => new Map(i),
|
|
8104
|
+
encode: (a) => Array.from(a.entries())
|
|
8105
|
+
}
|
|
7956
8106
|
)
|
|
7957
8107
|
}
|
|
7958
8108
|
|
|
@@ -7960,25 +8110,23 @@ export const ReadonlyMap = <K extends Schema.Any, V extends Schema.Any>({ key, v
|
|
|
7960
8110
|
* @category api interface
|
|
7961
8111
|
* @since 3.10.0
|
|
7962
8112
|
*/
|
|
7963
|
-
export interface Map$<K extends Schema.Any, V extends Schema.Any>
|
|
7964
|
-
|
|
7965
|
-
Map$<K, V>,
|
|
7966
|
-
Map<Schema.Type<K>, Schema.Type<V>>,
|
|
7967
|
-
ReadonlyArray<readonly [Schema.Encoded<K>, Schema.Encoded<V>]>,
|
|
7968
|
-
Schema.Context<K> | Schema.Context<V>
|
|
7969
|
-
>
|
|
8113
|
+
export interface Map$<K extends Schema.Any, V extends Schema.Any>
|
|
8114
|
+
extends transform<Array$<Tuple2<K, V>>, MapFromSelf<SchemaClass<Schema.Type<K>>, SchemaClass<Schema.Type<V>>>>
|
|
7970
8115
|
{}
|
|
7971
8116
|
|
|
7972
|
-
|
|
8117
|
+
/** @ignore */
|
|
8118
|
+
function map<K extends Schema.Any, V extends Schema.Any>({ key, value }: {
|
|
7973
8119
|
readonly key: K
|
|
7974
8120
|
readonly value: V
|
|
7975
|
-
}): Map$<K, V>
|
|
7976
|
-
const key_ = asSchema(key)
|
|
7977
|
-
const value_ = asSchema(value)
|
|
8121
|
+
}): Map$<K, V> {
|
|
7978
8122
|
return transform(
|
|
7979
|
-
Array$(Tuple(
|
|
7980
|
-
MapFromSelf({ key: typeSchema(
|
|
7981
|
-
{
|
|
8123
|
+
Array$(Tuple(key, value)),
|
|
8124
|
+
MapFromSelf({ key: typeSchema(asSchema(key)), value: typeSchema(asSchema(value)) }),
|
|
8125
|
+
{
|
|
8126
|
+
strict: true,
|
|
8127
|
+
decode: (i) => new Map(i),
|
|
8128
|
+
encode: (a) => Array.from(a.entries())
|
|
8129
|
+
}
|
|
7982
8130
|
)
|
|
7983
8131
|
}
|
|
7984
8132
|
|
|
@@ -7997,7 +8145,7 @@ export {
|
|
|
7997
8145
|
export const ReadonlyMapFromRecord = <KA, KR, VA, VI, VR>({ key, value }: {
|
|
7998
8146
|
key: Schema<KA, string, KR>
|
|
7999
8147
|
value: Schema<VA, VI, VR>
|
|
8000
|
-
}):
|
|
8148
|
+
}): SchemaClass<ReadonlyMap<KA, VA>, { readonly [x: string]: VI }, KR | VR> =>
|
|
8001
8149
|
transform(
|
|
8002
8150
|
Record({ key: encodedBoundSchema(key), value }).annotations({
|
|
8003
8151
|
description: "a record to be decoded into a ReadonlyMap"
|
|
@@ -8005,8 +8153,8 @@ export const ReadonlyMapFromRecord = <KA, KR, VA, VI, VR>({ key, value }: {
|
|
|
8005
8153
|
ReadonlyMapFromSelf({ key, value: typeSchema(value) }),
|
|
8006
8154
|
{
|
|
8007
8155
|
strict: true,
|
|
8008
|
-
decode: (
|
|
8009
|
-
encode:
|
|
8156
|
+
decode: (i) => new Map(Object.entries(i)),
|
|
8157
|
+
encode: (a) => Object.fromEntries(a)
|
|
8010
8158
|
}
|
|
8011
8159
|
)
|
|
8012
8160
|
|
|
@@ -8017,7 +8165,7 @@ export const ReadonlyMapFromRecord = <KA, KR, VA, VI, VR>({ key, value }: {
|
|
|
8017
8165
|
export const MapFromRecord = <KA, KR, VA, VI, VR>({ key, value }: {
|
|
8018
8166
|
key: Schema<KA, string, KR>
|
|
8019
8167
|
value: Schema<VA, VI, VR>
|
|
8020
|
-
}):
|
|
8168
|
+
}): SchemaClass<Map<KA, VA>, { readonly [x: string]: VI }, KR | VR> =>
|
|
8021
8169
|
transform(
|
|
8022
8170
|
Record({ key: encodedBoundSchema(key), value }).annotations({
|
|
8023
8171
|
description: "a record to be decoded into a Map"
|
|
@@ -8025,8 +8173,8 @@ export const MapFromRecord = <KA, KR, VA, VI, VR>({ key, value }: {
|
|
|
8025
8173
|
MapFromSelf({ key, value: typeSchema(value) }),
|
|
8026
8174
|
{
|
|
8027
8175
|
strict: true,
|
|
8028
|
-
decode: (
|
|
8029
|
-
encode:
|
|
8176
|
+
decode: (i) => new Map(Object.entries(i)),
|
|
8177
|
+
encode: (a) => Object.fromEntries(a)
|
|
8030
8178
|
}
|
|
8031
8179
|
)
|
|
8032
8180
|
|
|
@@ -8059,11 +8207,11 @@ const readonlySetParse = <A, R>(
|
|
|
8059
8207
|
* @since 3.10.0
|
|
8060
8208
|
*/
|
|
8061
8209
|
export interface ReadonlySetFromSelf<Value extends Schema.Any> extends
|
|
8062
|
-
|
|
8210
|
+
AnnotableDeclare<
|
|
8063
8211
|
ReadonlySetFromSelf<Value>,
|
|
8064
8212
|
ReadonlySet<Schema.Type<Value>>,
|
|
8065
8213
|
ReadonlySet<Schema.Encoded<Value>>,
|
|
8066
|
-
|
|
8214
|
+
[Value]
|
|
8067
8215
|
>
|
|
8068
8216
|
{}
|
|
8069
8217
|
|
|
@@ -8094,11 +8242,11 @@ export const ReadonlySetFromSelf = <Value extends Schema.Any>(value: Value): Rea
|
|
|
8094
8242
|
* @since 3.10.0
|
|
8095
8243
|
*/
|
|
8096
8244
|
export interface SetFromSelf<Value extends Schema.Any> extends
|
|
8097
|
-
|
|
8245
|
+
AnnotableDeclare<
|
|
8098
8246
|
SetFromSelf<Value>,
|
|
8099
8247
|
Set<Schema.Type<Value>>,
|
|
8100
8248
|
ReadonlySet<Schema.Encoded<Value>>,
|
|
8101
|
-
|
|
8249
|
+
[Value]
|
|
8102
8250
|
>
|
|
8103
8251
|
{}
|
|
8104
8252
|
|
|
@@ -8113,25 +8261,23 @@ export const SetFromSelf = <Value extends Schema.Any>(value: Value): SetFromSelf
|
|
|
8113
8261
|
* @category api interface
|
|
8114
8262
|
* @since 3.10.0
|
|
8115
8263
|
*/
|
|
8116
|
-
export interface ReadonlySet$<Value extends Schema.Any>
|
|
8117
|
-
|
|
8118
|
-
ReadonlySet$<Value>,
|
|
8119
|
-
ReadonlySet<Schema.Type<Value>>,
|
|
8120
|
-
ReadonlyArray<Schema.Encoded<Value>>,
|
|
8121
|
-
Schema.Context<Value>
|
|
8122
|
-
>
|
|
8264
|
+
export interface ReadonlySet$<Value extends Schema.Any>
|
|
8265
|
+
extends transform<Array$<Value>, ReadonlySetFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
8123
8266
|
{}
|
|
8124
8267
|
|
|
8125
8268
|
/**
|
|
8126
8269
|
* @category ReadonlySet transformations
|
|
8127
8270
|
* @since 3.10.0
|
|
8128
8271
|
*/
|
|
8129
|
-
export
|
|
8130
|
-
const value_ = asSchema(value)
|
|
8272
|
+
export function ReadonlySet<Value extends Schema.Any>(value: Value): ReadonlySet$<Value> {
|
|
8131
8273
|
return transform(
|
|
8132
|
-
Array$(
|
|
8133
|
-
ReadonlySetFromSelf(typeSchema(
|
|
8134
|
-
{
|
|
8274
|
+
Array$(value),
|
|
8275
|
+
ReadonlySetFromSelf(typeSchema(asSchema(value))),
|
|
8276
|
+
{
|
|
8277
|
+
strict: true,
|
|
8278
|
+
decode: (i) => new Set(i),
|
|
8279
|
+
encode: (a) => Array.from(a)
|
|
8280
|
+
}
|
|
8135
8281
|
)
|
|
8136
8282
|
}
|
|
8137
8283
|
|
|
@@ -8139,21 +8285,20 @@ export const ReadonlySet = <Value extends Schema.Any>(value: Value): ReadonlySet
|
|
|
8139
8285
|
* @category api interface
|
|
8140
8286
|
* @since 3.10.0
|
|
8141
8287
|
*/
|
|
8142
|
-
export interface Set$<Value extends Schema.Any>
|
|
8143
|
-
|
|
8144
|
-
Set$<Value>,
|
|
8145
|
-
Set<Schema.Type<Value>>,
|
|
8146
|
-
ReadonlyArray<Schema.Encoded<Value>>,
|
|
8147
|
-
Schema.Context<Value>
|
|
8148
|
-
>
|
|
8288
|
+
export interface Set$<Value extends Schema.Any>
|
|
8289
|
+
extends transform<Array$<Value>, SetFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
8149
8290
|
{}
|
|
8150
8291
|
|
|
8151
|
-
|
|
8152
|
-
|
|
8292
|
+
/** @ignore */
|
|
8293
|
+
function set<Value extends Schema.Any>(value: Value): Set$<Value> {
|
|
8153
8294
|
return transform(
|
|
8154
|
-
Array$(
|
|
8155
|
-
SetFromSelf(typeSchema(
|
|
8156
|
-
{
|
|
8295
|
+
Array$(value),
|
|
8296
|
+
SetFromSelf(typeSchema(asSchema(value))),
|
|
8297
|
+
{
|
|
8298
|
+
strict: true,
|
|
8299
|
+
decode: (i) => new Set(i),
|
|
8300
|
+
encode: (a) => Array.from(a)
|
|
8301
|
+
}
|
|
8157
8302
|
)
|
|
8158
8303
|
}
|
|
8159
8304
|
|
|
@@ -8195,13 +8340,13 @@ export class BigDecimal extends transformOrFail(
|
|
|
8195
8340
|
BigDecimalFromSelf,
|
|
8196
8341
|
{
|
|
8197
8342
|
strict: true,
|
|
8198
|
-
decode: (
|
|
8199
|
-
bigDecimal_.fromString(
|
|
8343
|
+
decode: (i, _, ast) =>
|
|
8344
|
+
bigDecimal_.fromString(i).pipe(option_.match({
|
|
8200
8345
|
onNone: () =>
|
|
8201
|
-
ParseResult.fail(new ParseResult.Type(ast,
|
|
8346
|
+
ParseResult.fail(new ParseResult.Type(ast, i, `Unable to decode ${JSON.stringify(i)} into a BigDecimal`)),
|
|
8202
8347
|
onSome: (val) => ParseResult.succeed(bigDecimal_.normalize(val))
|
|
8203
8348
|
})),
|
|
8204
|
-
encode: (
|
|
8349
|
+
encode: (a) => ParseResult.succeed(bigDecimal_.format(bigDecimal_.normalize(a)))
|
|
8205
8350
|
}
|
|
8206
8351
|
).annotations({ identifier: "BigDecimal" }) {}
|
|
8207
8352
|
|
|
@@ -8217,8 +8362,8 @@ export class BigDecimalFromNumber extends transform(
|
|
|
8217
8362
|
BigDecimalFromSelf,
|
|
8218
8363
|
{
|
|
8219
8364
|
strict: true,
|
|
8220
|
-
decode: bigDecimal_.unsafeFromNumber,
|
|
8221
|
-
encode: bigDecimal_.unsafeToNumber
|
|
8365
|
+
decode: (i) => bigDecimal_.unsafeFromNumber(i),
|
|
8366
|
+
encode: (a) => bigDecimal_.unsafeToNumber(a)
|
|
8222
8367
|
}
|
|
8223
8368
|
).annotations({ identifier: "BigDecimalFromNumber" }) {}
|
|
8224
8369
|
|
|
@@ -8232,22 +8377,20 @@ export const GreaterThanBigDecimalSchemaId: unique symbol = Symbol.for("effect/S
|
|
|
8232
8377
|
* @category BigDecimal filters
|
|
8233
8378
|
* @since 3.10.0
|
|
8234
8379
|
*/
|
|
8235
|
-
export const greaterThanBigDecimal =
|
|
8236
|
-
min: bigDecimal_.BigDecimal,
|
|
8237
|
-
|
|
8238
|
-
)
|
|
8239
|
-
|
|
8240
|
-
|
|
8241
|
-
|
|
8242
|
-
|
|
8243
|
-
|
|
8244
|
-
|
|
8245
|
-
|
|
8246
|
-
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
)
|
|
8250
|
-
}
|
|
8380
|
+
export const greaterThanBigDecimal =
|
|
8381
|
+
<S extends Schema.Any>(min: bigDecimal_.BigDecimal, annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
8382
|
+
<A extends bigDecimal_.BigDecimal>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
8383
|
+
const formatted = bigDecimal_.format(min)
|
|
8384
|
+
return self.pipe(
|
|
8385
|
+
filter((a) => bigDecimal_.greaterThan(a, min), {
|
|
8386
|
+
schemaId: GreaterThanBigDecimalSchemaId,
|
|
8387
|
+
[GreaterThanBigDecimalSchemaId]: { min },
|
|
8388
|
+
title: `greaterThanBigDecimal(${formatted})`,
|
|
8389
|
+
description: `a BigDecimal greater than ${formatted}`,
|
|
8390
|
+
...annotations
|
|
8391
|
+
})
|
|
8392
|
+
)
|
|
8393
|
+
}
|
|
8251
8394
|
|
|
8252
8395
|
/**
|
|
8253
8396
|
* @category schema id
|
|
@@ -8261,22 +8404,20 @@ export const GreaterThanOrEqualToBigDecimalSchemaId: unique symbol = Symbol.for(
|
|
|
8261
8404
|
* @category BigDecimal filters
|
|
8262
8405
|
* @since 3.10.0
|
|
8263
8406
|
*/
|
|
8264
|
-
export const greaterThanOrEqualToBigDecimal =
|
|
8265
|
-
min: bigDecimal_.BigDecimal,
|
|
8266
|
-
|
|
8267
|
-
)
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
)
|
|
8279
|
-
}
|
|
8407
|
+
export const greaterThanOrEqualToBigDecimal =
|
|
8408
|
+
<S extends Schema.Any>(min: bigDecimal_.BigDecimal, annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
8409
|
+
<A extends bigDecimal_.BigDecimal>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
8410
|
+
const formatted = bigDecimal_.format(min)
|
|
8411
|
+
return self.pipe(
|
|
8412
|
+
filter((a) => bigDecimal_.greaterThanOrEqualTo(a, min), {
|
|
8413
|
+
schemaId: GreaterThanOrEqualToBigDecimalSchemaId,
|
|
8414
|
+
[GreaterThanOrEqualToBigDecimalSchemaId]: { min },
|
|
8415
|
+
title: `greaterThanOrEqualToBigDecimal(${formatted})`,
|
|
8416
|
+
description: `a BigDecimal greater than or equal to ${formatted}`,
|
|
8417
|
+
...annotations
|
|
8418
|
+
})
|
|
8419
|
+
)
|
|
8420
|
+
}
|
|
8280
8421
|
|
|
8281
8422
|
/**
|
|
8282
8423
|
* @category schema id
|
|
@@ -8288,22 +8429,20 @@ export const LessThanBigDecimalSchemaId: unique symbol = Symbol.for("effect/Sche
|
|
|
8288
8429
|
* @category BigDecimal filters
|
|
8289
8430
|
* @since 3.10.0
|
|
8290
8431
|
*/
|
|
8291
|
-
export const lessThanBigDecimal =
|
|
8292
|
-
max: bigDecimal_.BigDecimal,
|
|
8293
|
-
|
|
8294
|
-
)
|
|
8295
|
-
|
|
8296
|
-
|
|
8297
|
-
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
|
|
8301
|
-
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
)
|
|
8306
|
-
}
|
|
8432
|
+
export const lessThanBigDecimal =
|
|
8433
|
+
<S extends Schema.Any>(max: bigDecimal_.BigDecimal, annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
8434
|
+
<A extends bigDecimal_.BigDecimal>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
8435
|
+
const formatted = bigDecimal_.format(max)
|
|
8436
|
+
return self.pipe(
|
|
8437
|
+
filter((a) => bigDecimal_.lessThan(a, max), {
|
|
8438
|
+
schemaId: LessThanBigDecimalSchemaId,
|
|
8439
|
+
[LessThanBigDecimalSchemaId]: { max },
|
|
8440
|
+
title: `lessThanBigDecimal(${formatted})`,
|
|
8441
|
+
description: `a BigDecimal less than ${formatted}`,
|
|
8442
|
+
...annotations
|
|
8443
|
+
})
|
|
8444
|
+
)
|
|
8445
|
+
}
|
|
8307
8446
|
|
|
8308
8447
|
/**
|
|
8309
8448
|
* @category schema id
|
|
@@ -8317,22 +8456,20 @@ export const LessThanOrEqualToBigDecimalSchemaId: unique symbol = Symbol.for(
|
|
|
8317
8456
|
* @category BigDecimal filters
|
|
8318
8457
|
* @since 3.10.0
|
|
8319
8458
|
*/
|
|
8320
|
-
export const lessThanOrEqualToBigDecimal =
|
|
8321
|
-
max: bigDecimal_.BigDecimal,
|
|
8322
|
-
|
|
8323
|
-
)
|
|
8324
|
-
|
|
8325
|
-
|
|
8326
|
-
|
|
8327
|
-
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
|
|
8331
|
-
|
|
8332
|
-
|
|
8333
|
-
|
|
8334
|
-
)
|
|
8335
|
-
}
|
|
8459
|
+
export const lessThanOrEqualToBigDecimal =
|
|
8460
|
+
<S extends Schema.Any>(max: bigDecimal_.BigDecimal, annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
8461
|
+
<A extends bigDecimal_.BigDecimal>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
8462
|
+
const formatted = bigDecimal_.format(max)
|
|
8463
|
+
return self.pipe(
|
|
8464
|
+
filter((a) => bigDecimal_.lessThanOrEqualTo(a, max), {
|
|
8465
|
+
schemaId: LessThanOrEqualToBigDecimalSchemaId,
|
|
8466
|
+
[LessThanOrEqualToBigDecimalSchemaId]: { max },
|
|
8467
|
+
title: `lessThanOrEqualToBigDecimal(${formatted})`,
|
|
8468
|
+
description: `a BigDecimal less than or equal to ${formatted}`,
|
|
8469
|
+
...annotations
|
|
8470
|
+
})
|
|
8471
|
+
)
|
|
8472
|
+
}
|
|
8336
8473
|
|
|
8337
8474
|
/**
|
|
8338
8475
|
* @category schema id
|
|
@@ -8346,18 +8483,17 @@ export const PositiveBigDecimalSchemaId: unique symbol = Symbol.for(
|
|
|
8346
8483
|
* @category BigDecimal filters
|
|
8347
8484
|
* @since 3.10.0
|
|
8348
8485
|
*/
|
|
8349
|
-
export const positiveBigDecimal =
|
|
8350
|
-
annotations?: Annotations.Filter<
|
|
8351
|
-
) =>
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
)
|
|
8486
|
+
export const positiveBigDecimal =
|
|
8487
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
8488
|
+
<A extends bigDecimal_.BigDecimal>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
8489
|
+
self.pipe(
|
|
8490
|
+
filter((a) => bigDecimal_.isPositive(a), {
|
|
8491
|
+
schemaId: PositiveBigDecimalSchemaId,
|
|
8492
|
+
title: "positiveBigDecimal",
|
|
8493
|
+
description: `a positive BigDecimal`,
|
|
8494
|
+
...annotations
|
|
8495
|
+
})
|
|
8496
|
+
)
|
|
8361
8497
|
|
|
8362
8498
|
/**
|
|
8363
8499
|
* @category BigDecimal constructors
|
|
@@ -8379,18 +8515,17 @@ export const NonNegativeBigDecimalSchemaId: unique symbol = Symbol.for(
|
|
|
8379
8515
|
* @category BigDecimal filters
|
|
8380
8516
|
* @since 3.10.0
|
|
8381
8517
|
*/
|
|
8382
|
-
export const nonNegativeBigDecimal =
|
|
8383
|
-
annotations?: Annotations.Filter<
|
|
8384
|
-
) =>
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
|
|
8393
|
-
)
|
|
8518
|
+
export const nonNegativeBigDecimal =
|
|
8519
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
8520
|
+
<A extends bigDecimal_.BigDecimal>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
8521
|
+
self.pipe(
|
|
8522
|
+
filter((a) => a.value >= 0n, {
|
|
8523
|
+
schemaId: NonNegativeBigDecimalSchemaId,
|
|
8524
|
+
title: "nonNegativeBigDecimal",
|
|
8525
|
+
description: `a non-negative BigDecimal`,
|
|
8526
|
+
...annotations
|
|
8527
|
+
})
|
|
8528
|
+
)
|
|
8394
8529
|
|
|
8395
8530
|
/**
|
|
8396
8531
|
* @category BigDecimal constructors
|
|
@@ -8412,18 +8547,17 @@ export const NegativeBigDecimalSchemaId: unique symbol = Symbol.for(
|
|
|
8412
8547
|
* @category BigDecimal filters
|
|
8413
8548
|
* @since 3.10.0
|
|
8414
8549
|
*/
|
|
8415
|
-
export const negativeBigDecimal =
|
|
8416
|
-
annotations?: Annotations.Filter<
|
|
8417
|
-
) =>
|
|
8418
|
-
|
|
8419
|
-
|
|
8420
|
-
|
|
8421
|
-
|
|
8422
|
-
|
|
8423
|
-
|
|
8424
|
-
|
|
8425
|
-
|
|
8426
|
-
)
|
|
8550
|
+
export const negativeBigDecimal =
|
|
8551
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
8552
|
+
<A extends bigDecimal_.BigDecimal>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
8553
|
+
self.pipe(
|
|
8554
|
+
filter((a) => bigDecimal_.isNegative(a), {
|
|
8555
|
+
schemaId: NegativeBigDecimalSchemaId,
|
|
8556
|
+
title: "negativeBigDecimal",
|
|
8557
|
+
description: `a negative BigDecimal`,
|
|
8558
|
+
...annotations
|
|
8559
|
+
})
|
|
8560
|
+
)
|
|
8427
8561
|
|
|
8428
8562
|
/**
|
|
8429
8563
|
* @category BigDecimal constructors
|
|
@@ -8445,18 +8579,17 @@ export const NonPositiveBigDecimalSchemaId: unique symbol = Symbol.for(
|
|
|
8445
8579
|
* @category BigDecimal filters
|
|
8446
8580
|
* @since 3.10.0
|
|
8447
8581
|
*/
|
|
8448
|
-
export const nonPositiveBigDecimal =
|
|
8449
|
-
annotations?: Annotations.Filter<
|
|
8450
|
-
) =>
|
|
8451
|
-
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
|
|
8455
|
-
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
|
|
8459
|
-
)
|
|
8582
|
+
export const nonPositiveBigDecimal =
|
|
8583
|
+
<S extends Schema.Any>(annotations?: Annotations.Filter<Schema.Type<S>>) =>
|
|
8584
|
+
<A extends bigDecimal_.BigDecimal>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
8585
|
+
self.pipe(
|
|
8586
|
+
filter((a) => a.value <= 0n, {
|
|
8587
|
+
schemaId: NonPositiveBigDecimalSchemaId,
|
|
8588
|
+
title: "nonPositiveBigDecimal",
|
|
8589
|
+
description: `a non-positive BigDecimal`,
|
|
8590
|
+
...annotations
|
|
8591
|
+
})
|
|
8592
|
+
)
|
|
8460
8593
|
|
|
8461
8594
|
/**
|
|
8462
8595
|
* @category BigDecimal constructors
|
|
@@ -8476,12 +8609,12 @@ export const BetweenBigDecimalSchemaId: unique symbol = Symbol.for("effect/Schem
|
|
|
8476
8609
|
* @category BigDecimal filters
|
|
8477
8610
|
* @since 3.10.0
|
|
8478
8611
|
*/
|
|
8479
|
-
export const betweenBigDecimal = <
|
|
8612
|
+
export const betweenBigDecimal = <S extends Schema.Any>(
|
|
8480
8613
|
minimum: bigDecimal_.BigDecimal,
|
|
8481
8614
|
maximum: bigDecimal_.BigDecimal,
|
|
8482
|
-
annotations?: Annotations.Filter<
|
|
8615
|
+
annotations?: Annotations.Filter<Schema.Type<S>>
|
|
8483
8616
|
) =>
|
|
8484
|
-
<
|
|
8617
|
+
<A extends bigDecimal_.BigDecimal>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => {
|
|
8485
8618
|
const formattedMinimum = bigDecimal_.format(minimum)
|
|
8486
8619
|
const formattedMaximum = bigDecimal_.format(maximum)
|
|
8487
8620
|
return self.pipe(
|
|
@@ -8503,11 +8636,17 @@ export const betweenBigDecimal = <A extends bigDecimal_.BigDecimal>(
|
|
|
8503
8636
|
*/
|
|
8504
8637
|
export const clampBigDecimal =
|
|
8505
8638
|
(minimum: bigDecimal_.BigDecimal, maximum: bigDecimal_.BigDecimal) =>
|
|
8506
|
-
<
|
|
8639
|
+
<S extends Schema.Any, A extends bigDecimal_.BigDecimal>(
|
|
8640
|
+
self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>
|
|
8641
|
+
): transform<S, filter<SchemaClass<A>>> =>
|
|
8507
8642
|
transform(
|
|
8508
8643
|
self,
|
|
8509
8644
|
self.pipe(typeSchema, betweenBigDecimal(minimum, maximum)),
|
|
8510
|
-
{
|
|
8645
|
+
{
|
|
8646
|
+
strict: false,
|
|
8647
|
+
decode: (i) => bigDecimal_.clamp(i, { minimum, maximum }),
|
|
8648
|
+
encode: identity
|
|
8649
|
+
}
|
|
8511
8650
|
)
|
|
8512
8651
|
|
|
8513
8652
|
const chunkArbitrary =
|
|
@@ -8534,11 +8673,11 @@ const chunkParse = <A, R>(
|
|
|
8534
8673
|
* @since 3.10.0
|
|
8535
8674
|
*/
|
|
8536
8675
|
export interface ChunkFromSelf<Value extends Schema.Any> extends
|
|
8537
|
-
|
|
8676
|
+
AnnotableDeclare<
|
|
8538
8677
|
ChunkFromSelf<Value>,
|
|
8539
8678
|
chunk_.Chunk<Schema.Type<Value>>,
|
|
8540
8679
|
chunk_.Chunk<Schema.Encoded<Value>>,
|
|
8541
|
-
|
|
8680
|
+
[Value]
|
|
8542
8681
|
>
|
|
8543
8682
|
{}
|
|
8544
8683
|
|
|
@@ -8566,28 +8705,22 @@ export const ChunkFromSelf = <Value extends Schema.Any>(value: Value): ChunkFrom
|
|
|
8566
8705
|
* @category api interface
|
|
8567
8706
|
* @since 3.10.0
|
|
8568
8707
|
*/
|
|
8569
|
-
export interface Chunk<Value extends Schema.Any>
|
|
8570
|
-
|
|
8571
|
-
Chunk<Value>,
|
|
8572
|
-
chunk_.Chunk<Schema.Type<Value>>,
|
|
8573
|
-
ReadonlyArray<Schema.Encoded<Value>>,
|
|
8574
|
-
Schema.Context<Value>
|
|
8575
|
-
>
|
|
8708
|
+
export interface Chunk<Value extends Schema.Any>
|
|
8709
|
+
extends transform<Array$<Value>, ChunkFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
8576
8710
|
{}
|
|
8577
8711
|
|
|
8578
8712
|
/**
|
|
8579
8713
|
* @category Chunk transformations
|
|
8580
8714
|
* @since 3.10.0
|
|
8581
8715
|
*/
|
|
8582
|
-
export
|
|
8583
|
-
const value_ = asSchema(value)
|
|
8716
|
+
export function Chunk<Value extends Schema.Any>(value: Value): Chunk<Value> {
|
|
8584
8717
|
return transform(
|
|
8585
|
-
Array$(
|
|
8586
|
-
ChunkFromSelf(typeSchema(
|
|
8718
|
+
Array$(value),
|
|
8719
|
+
ChunkFromSelf(typeSchema(asSchema(value))),
|
|
8587
8720
|
{
|
|
8588
8721
|
strict: true,
|
|
8589
|
-
decode: (
|
|
8590
|
-
encode: chunk_.toReadonlyArray
|
|
8722
|
+
decode: (i) => i.length === 0 ? chunk_.empty() : chunk_.fromIterable(i),
|
|
8723
|
+
encode: (a) => chunk_.toReadonlyArray(a)
|
|
8591
8724
|
}
|
|
8592
8725
|
)
|
|
8593
8726
|
}
|
|
@@ -8597,11 +8730,11 @@ export const Chunk = <Value extends Schema.Any>(value: Value): Chunk<Value> => {
|
|
|
8597
8730
|
* @since 3.10.0
|
|
8598
8731
|
*/
|
|
8599
8732
|
export interface NonEmptyChunkFromSelf<Value extends Schema.Any> extends
|
|
8600
|
-
|
|
8733
|
+
AnnotableDeclare<
|
|
8601
8734
|
NonEmptyChunkFromSelf<Value>,
|
|
8602
8735
|
chunk_.NonEmptyChunk<Schema.Type<Value>>,
|
|
8603
8736
|
chunk_.NonEmptyChunk<Schema.Encoded<Value>>,
|
|
8604
|
-
|
|
8737
|
+
[Value]
|
|
8605
8738
|
>
|
|
8606
8739
|
{}
|
|
8607
8740
|
|
|
@@ -8643,89 +8776,116 @@ export const NonEmptyChunkFromSelf = <Value extends Schema.Any>(value: Value): N
|
|
|
8643
8776
|
* @category api interface
|
|
8644
8777
|
* @since 3.10.0
|
|
8645
8778
|
*/
|
|
8646
|
-
export interface NonEmptyChunk<Value extends Schema.Any>
|
|
8647
|
-
|
|
8648
|
-
NonEmptyChunk<Value>,
|
|
8649
|
-
chunk_.NonEmptyChunk<Schema.Type<Value>>,
|
|
8650
|
-
array_.NonEmptyReadonlyArray<Schema.Encoded<Value>>,
|
|
8651
|
-
Schema.Context<Value>
|
|
8652
|
-
>
|
|
8779
|
+
export interface NonEmptyChunk<Value extends Schema.Any>
|
|
8780
|
+
extends transform<NonEmptyArray<Value>, NonEmptyChunkFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
8653
8781
|
{}
|
|
8654
8782
|
|
|
8655
8783
|
/**
|
|
8656
8784
|
* @category Chunk transformations
|
|
8657
8785
|
* @since 3.10.0
|
|
8658
8786
|
*/
|
|
8659
|
-
export
|
|
8660
|
-
const value_ = asSchema(value)
|
|
8787
|
+
export function NonEmptyChunk<Value extends Schema.Any>(value: Value): NonEmptyChunk<Value> {
|
|
8661
8788
|
return transform(
|
|
8662
|
-
NonEmptyArray(
|
|
8663
|
-
NonEmptyChunkFromSelf(typeSchema(
|
|
8664
|
-
{
|
|
8789
|
+
NonEmptyArray(value),
|
|
8790
|
+
NonEmptyChunkFromSelf(typeSchema(asSchema(value))),
|
|
8791
|
+
{
|
|
8792
|
+
strict: true,
|
|
8793
|
+
decode: (i) => chunk_.unsafeFromNonEmptyArray(i),
|
|
8794
|
+
encode: (a) => chunk_.toReadonlyArray(a)
|
|
8795
|
+
}
|
|
8665
8796
|
)
|
|
8666
8797
|
}
|
|
8667
8798
|
|
|
8668
|
-
const
|
|
8799
|
+
const decodeData = <A extends Readonly<Record<string, unknown>> | ReadonlyArray<unknown>>(a: A): A =>
|
|
8669
8800
|
Array.isArray(a) ? data_.array(a) : data_.struct(a)
|
|
8670
8801
|
|
|
8671
|
-
const dataArbitrary = <A extends Readonly<Record<string,
|
|
8802
|
+
const dataArbitrary = <A extends Readonly<Record<string, unknown>> | ReadonlyArray<unknown>>(
|
|
8672
8803
|
item: LazyArbitrary<A>
|
|
8673
8804
|
): LazyArbitrary<A> =>
|
|
8674
|
-
(fc) => item(fc).map(
|
|
8805
|
+
(fc) => item(fc).map(decodeData)
|
|
8675
8806
|
|
|
8676
|
-
const dataPretty = <A extends Readonly<Record<string,
|
|
8807
|
+
const dataPretty = <A extends Readonly<Record<string, unknown>> | ReadonlyArray<unknown>>(
|
|
8677
8808
|
item: pretty_.Pretty<A>
|
|
8678
8809
|
): pretty_.Pretty<A> =>
|
|
8679
8810
|
(d) => `Data(${item(d)})`
|
|
8680
8811
|
|
|
8681
|
-
const dataParse = <R, A extends Readonly<Record<string,
|
|
8812
|
+
const dataParse = <R, A extends Readonly<Record<string, unknown>> | ReadonlyArray<unknown>>(
|
|
8682
8813
|
decodeUnknown: ParseResult.DecodeUnknown<A, R>
|
|
8683
8814
|
): ParseResult.DeclarationDecodeUnknown<A, R> =>
|
|
8684
8815
|
(u, options, ast) =>
|
|
8685
8816
|
Equal.isEqual(u) ?
|
|
8686
|
-
toComposite(decodeUnknown(u, options),
|
|
8817
|
+
toComposite(decodeUnknown(u, options), decodeData, ast, u)
|
|
8687
8818
|
: ParseResult.fail(new ParseResult.Type(ast, u))
|
|
8688
8819
|
|
|
8689
8820
|
/**
|
|
8821
|
+
* @category api interface
|
|
8822
|
+
* @since 3.13.3
|
|
8823
|
+
*/
|
|
8824
|
+
export interface DataFromSelf<Value extends Schema.Any> extends
|
|
8825
|
+
AnnotableDeclare<
|
|
8826
|
+
DataFromSelf<Value>,
|
|
8827
|
+
Schema.Type<Value>,
|
|
8828
|
+
Schema.Encoded<Value>,
|
|
8829
|
+
[Value]
|
|
8830
|
+
>
|
|
8831
|
+
{}
|
|
8832
|
+
|
|
8833
|
+
/**
|
|
8834
|
+
* Type and Encoded must extend `Readonly<Record<string, any>> |
|
|
8835
|
+
* ReadonlyArray<any>` to be compatible with this API.
|
|
8836
|
+
*
|
|
8690
8837
|
* @category Data transformations
|
|
8691
8838
|
* @since 3.10.0
|
|
8692
8839
|
*/
|
|
8693
8840
|
export const DataFromSelf = <
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
>(
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
declare(
|
|
8701
|
-
[item],
|
|
8841
|
+
S extends Schema.Any,
|
|
8842
|
+
A extends Readonly<Record<string, unknown>> | ReadonlyArray<unknown>,
|
|
8843
|
+
I extends Readonly<Record<string, unknown>> | ReadonlyArray<unknown>
|
|
8844
|
+
>(value: S & Schema<A & Schema.Type<S>, I & Schema.Encoded<S>, Schema.Context<S>>): DataFromSelf<S> => {
|
|
8845
|
+
return declare(
|
|
8846
|
+
[value],
|
|
8702
8847
|
{
|
|
8703
8848
|
decode: (item) => dataParse(ParseResult.decodeUnknown(item)),
|
|
8704
8849
|
encode: (item) => dataParse(ParseResult.encodeUnknown(item))
|
|
8705
8850
|
},
|
|
8706
8851
|
{
|
|
8707
|
-
description: `Data<${format(
|
|
8852
|
+
description: `Data<${format(value)}>`,
|
|
8708
8853
|
pretty: dataPretty,
|
|
8709
8854
|
arbitrary: dataArbitrary
|
|
8710
8855
|
}
|
|
8711
8856
|
)
|
|
8857
|
+
}
|
|
8858
|
+
|
|
8859
|
+
/**
|
|
8860
|
+
* @category api interface
|
|
8861
|
+
* @since 3.13.3
|
|
8862
|
+
*/
|
|
8863
|
+
export interface Data<Value extends Schema.Any>
|
|
8864
|
+
extends transform<Value, DataFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
8865
|
+
{}
|
|
8712
8866
|
|
|
8713
8867
|
/**
|
|
8868
|
+
* Type and Encoded must extend `Readonly<Record<string, any>> |
|
|
8869
|
+
* ReadonlyArray<any>` to be compatible with this API.
|
|
8870
|
+
*
|
|
8714
8871
|
* @category Data transformations
|
|
8715
8872
|
* @since 3.10.0
|
|
8716
8873
|
*/
|
|
8717
8874
|
export const Data = <
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
>(
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8875
|
+
S extends Schema.Any,
|
|
8876
|
+
A extends Readonly<Record<string, unknown>> | ReadonlyArray<unknown>,
|
|
8877
|
+
I extends Readonly<Record<string, unknown>> | ReadonlyArray<unknown>
|
|
8878
|
+
>(value: S & Schema<A & Schema.Type<S>, I & Schema.Encoded<S>, Schema.Context<S>>): Data<S> => {
|
|
8879
|
+
return transform(
|
|
8880
|
+
value,
|
|
8881
|
+
DataFromSelf(typeSchema(value)),
|
|
8882
|
+
{
|
|
8883
|
+
strict: false,
|
|
8884
|
+
decode: (i) => decodeData(i),
|
|
8885
|
+
encode: (a) => Array.isArray(a) ? Array.from(a) : Object.assign({}, a)
|
|
8886
|
+
}
|
|
8728
8887
|
)
|
|
8888
|
+
}
|
|
8729
8889
|
|
|
8730
8890
|
type MissingSelfGeneric<Usage extends string, Params extends string = ""> =
|
|
8731
8891
|
`Missing \`Self\` generic - use \`class Self extends ${Usage}<Self>()(${Params}{ ... })\``
|
|
@@ -8789,7 +8949,7 @@ export interface Class<Self, Fields extends Struct.Fields, I, R, C, Inherited, P
|
|
|
8789
8949
|
*/
|
|
8790
8950
|
extend<Extended = never>(identifier: string): <NewFields extends Struct.Fields>(
|
|
8791
8951
|
fields: NewFields | HasFields<NewFields>,
|
|
8792
|
-
annotations?: ClassAnnotations<Extended, Struct.Type<Fields & NewFields
|
|
8952
|
+
annotations?: ClassAnnotations<Extended, Simplify<Struct.Type<Fields & NewFields>>>
|
|
8793
8953
|
) => [Extended] extends [never] ? MissingSelfGeneric<"Base.extend">
|
|
8794
8954
|
: Class<
|
|
8795
8955
|
Extended,
|
|
@@ -8848,7 +9008,7 @@ export interface Class<Self, Fields extends Struct.Fields, I, R, C, Inherited, P
|
|
|
8848
9008
|
ast: AST.Transformation
|
|
8849
9009
|
) => Effect.Effect<Struct.Type<Fields>, ParseResult.ParseIssue, R3>
|
|
8850
9010
|
},
|
|
8851
|
-
annotations?: ClassAnnotations<Transformed, Struct.Type<Fields & NewFields
|
|
9011
|
+
annotations?: ClassAnnotations<Transformed, Simplify<Struct.Type<Fields & NewFields>>>
|
|
8852
9012
|
) => [Transformed] extends [never] ? MissingSelfGeneric<"Base.transformOrFail">
|
|
8853
9013
|
: Class<
|
|
8854
9014
|
Transformed,
|
|
@@ -8907,7 +9067,7 @@ export interface Class<Self, Fields extends Struct.Fields, I, R, C, Inherited, P
|
|
|
8907
9067
|
ast: AST.Transformation
|
|
8908
9068
|
) => Effect.Effect<I, ParseResult.ParseIssue, R3>
|
|
8909
9069
|
},
|
|
8910
|
-
annotations?: ClassAnnotations<Transformed, Struct.Type<Fields & NewFields
|
|
9070
|
+
annotations?: ClassAnnotations<Transformed, Simplify<Struct.Type<Fields & NewFields>>>
|
|
8911
9071
|
) => [Transformed] extends [never] ? MissingSelfGeneric<"Base.transformOrFailFrom">
|
|
8912
9072
|
: Class<
|
|
8913
9073
|
Transformed,
|
|
@@ -8958,7 +9118,7 @@ const getFieldsFromFieldsOr = <Fields extends Struct.Fields>(fieldsOr: Fields |
|
|
|
8958
9118
|
export const Class = <Self = never>(identifier: string) =>
|
|
8959
9119
|
<Fields extends Struct.Fields>(
|
|
8960
9120
|
fieldsOr: Fields | HasFields<Fields>,
|
|
8961
|
-
annotations?: ClassAnnotations<Self, Struct.Type<Fields
|
|
9121
|
+
annotations?: ClassAnnotations<Self, Simplify<Struct.Type<Fields>>>
|
|
8962
9122
|
): [Self] extends [never] ? MissingSelfGeneric<"Class">
|
|
8963
9123
|
: Class<
|
|
8964
9124
|
Self,
|
|
@@ -9017,7 +9177,7 @@ export const TaggedClass = <Self = never>(identifier?: string) =>
|
|
|
9017
9177
|
<Tag extends string, Fields extends Struct.Fields>(
|
|
9018
9178
|
tag: Tag,
|
|
9019
9179
|
fieldsOr: Fields | HasFields<Fields>,
|
|
9020
|
-
annotations?: ClassAnnotations<Self, Struct.Type<{ readonly _tag: tag<Tag> } & Fields
|
|
9180
|
+
annotations?: ClassAnnotations<Self, Simplify<Struct.Type<{ readonly _tag: tag<Tag> } & Fields>>>
|
|
9021
9181
|
): [Self] extends [never] ? MissingSelfGeneric<"TaggedClass", `"Tag", `>
|
|
9022
9182
|
: TaggedClass<Self, Tag, { readonly _tag: tag<Tag> } & Fields> =>
|
|
9023
9183
|
{
|
|
@@ -9080,7 +9240,7 @@ export const TaggedError = <Self = never>(identifier?: string) =>
|
|
|
9080
9240
|
<Tag extends string, Fields extends Struct.Fields>(
|
|
9081
9241
|
tag: Tag,
|
|
9082
9242
|
fieldsOr: Fields | HasFields<Fields>,
|
|
9083
|
-
annotations?: ClassAnnotations<Self, Struct.Type<{ readonly _tag: tag<Tag> } & Fields
|
|
9243
|
+
annotations?: ClassAnnotations<Self, Simplify<Struct.Type<{ readonly _tag: tag<Tag> } & Fields>>>
|
|
9084
9244
|
): [Self] extends [never] ? MissingSelfGeneric<"TaggedError", `"Tag", `>
|
|
9085
9245
|
: TaggedErrorClass<
|
|
9086
9246
|
Self,
|
|
@@ -9124,7 +9284,8 @@ const extendFields = (a: Struct.Fields, b: Struct.Fields): Struct.Fields => {
|
|
|
9124
9284
|
return out
|
|
9125
9285
|
}
|
|
9126
9286
|
|
|
9127
|
-
|
|
9287
|
+
/** @internal */
|
|
9288
|
+
export type MakeOptions = boolean | {
|
|
9128
9289
|
readonly disableValidation?: boolean
|
|
9129
9290
|
}
|
|
9130
9291
|
|
|
@@ -9249,7 +9410,11 @@ const makeClass = <Fields extends Struct.Fields>(
|
|
|
9249
9410
|
out = transform(
|
|
9250
9411
|
encodedSide,
|
|
9251
9412
|
declaration,
|
|
9252
|
-
{
|
|
9413
|
+
{
|
|
9414
|
+
strict: true,
|
|
9415
|
+
decode: (i) => new this(i, true),
|
|
9416
|
+
encode: identity
|
|
9417
|
+
}
|
|
9253
9418
|
).annotations({
|
|
9254
9419
|
[AST.SurrogateAnnotationId]: transformationSurrogate.ast,
|
|
9255
9420
|
...transformationAnnotations
|
|
@@ -9287,7 +9452,7 @@ const makeClass = <Fields extends Struct.Fields>(
|
|
|
9287
9452
|
static extend<Extended, NewFields extends Struct.Fields>(identifier: string) {
|
|
9288
9453
|
return (
|
|
9289
9454
|
newFieldsOr: NewFields | HasFields<NewFields>,
|
|
9290
|
-
annotations?: ClassAnnotations<Extended, Struct.Type<Fields & NewFields
|
|
9455
|
+
annotations?: ClassAnnotations<Extended, Simplify<Struct.Type<Fields & NewFields>>>
|
|
9291
9456
|
) => {
|
|
9292
9457
|
const newFields = getFieldsFromFieldsOr(newFieldsOr)
|
|
9293
9458
|
const newSchema = getSchemaFromFieldsOr(newFieldsOr)
|
|
@@ -9307,7 +9472,7 @@ const makeClass = <Fields extends Struct.Fields>(
|
|
|
9307
9472
|
return (
|
|
9308
9473
|
newFieldsOr: NewFields,
|
|
9309
9474
|
options: any,
|
|
9310
|
-
annotations?: ClassAnnotations<Transformed, Struct.Type<Fields & NewFields
|
|
9475
|
+
annotations?: ClassAnnotations<Transformed, Simplify<Struct.Type<Fields & NewFields>>>
|
|
9311
9476
|
) => {
|
|
9312
9477
|
const transformedFields: Struct.Fields = extendFields(fields, newFieldsOr)
|
|
9313
9478
|
return makeClass({
|
|
@@ -9329,7 +9494,7 @@ const makeClass = <Fields extends Struct.Fields>(
|
|
|
9329
9494
|
return (
|
|
9330
9495
|
newFields: NewFields,
|
|
9331
9496
|
options: any,
|
|
9332
|
-
annotations?: ClassAnnotations<Transformed, Struct.Type<Fields & NewFields
|
|
9497
|
+
annotations?: ClassAnnotations<Transformed, Simplify<Struct.Type<Fields & NewFields>>>
|
|
9333
9498
|
) => {
|
|
9334
9499
|
const transformedFields: Struct.Fields = extendFields(fields, newFields)
|
|
9335
9500
|
return makeClass({
|
|
@@ -9475,7 +9640,11 @@ const fiberIdEncode = (input: fiberId_.FiberId): FiberIdEncoded => {
|
|
|
9475
9640
|
export class FiberId extends transform(
|
|
9476
9641
|
FiberIdEncoded,
|
|
9477
9642
|
FiberIdFromSelf,
|
|
9478
|
-
{
|
|
9643
|
+
{
|
|
9644
|
+
strict: true,
|
|
9645
|
+
decode: (i) => fiberIdDecode(i),
|
|
9646
|
+
encode: (a) => fiberIdEncode(a)
|
|
9647
|
+
}
|
|
9479
9648
|
).annotations({ identifier: "FiberId" }) {}
|
|
9480
9649
|
|
|
9481
9650
|
/**
|
|
@@ -9509,7 +9678,7 @@ export type CauseEncoded<E, D> =
|
|
|
9509
9678
|
readonly right: CauseEncoded<E, D>
|
|
9510
9679
|
}
|
|
9511
9680
|
|
|
9512
|
-
const causeDieEncoded = <
|
|
9681
|
+
const causeDieEncoded = <Defect extends Schema.Any>(defect: Defect) =>
|
|
9513
9682
|
Struct({
|
|
9514
9683
|
_tag: Literal("Die"),
|
|
9515
9684
|
defect
|
|
@@ -9519,7 +9688,7 @@ const CauseEmptyEncoded = Struct({
|
|
|
9519
9688
|
_tag: Literal("Empty")
|
|
9520
9689
|
})
|
|
9521
9690
|
|
|
9522
|
-
const causeFailEncoded = <E
|
|
9691
|
+
const causeFailEncoded = <E extends Schema.Any>(error: E) =>
|
|
9523
9692
|
Struct({
|
|
9524
9693
|
_tag: Literal("Fail"),
|
|
9525
9694
|
error
|
|
@@ -9530,32 +9699,36 @@ const CauseInterruptEncoded = Struct({
|
|
|
9530
9699
|
fiberId: FiberIdEncoded
|
|
9531
9700
|
})
|
|
9532
9701
|
|
|
9533
|
-
const
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
|
|
9541
|
-
|
|
9542
|
-
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
|
|
9546
|
-
|
|
9547
|
-
|
|
9548
|
-
|
|
9549
|
-
defect: Schema<D, DI, R2>
|
|
9550
|
-
): Schema<CauseEncoded<E, D>, CauseEncoded<EI, DI>, R1 | R2> => {
|
|
9551
|
-
const recur = suspend(() => out)
|
|
9552
|
-
const out: Schema<CauseEncoded<E, D>, CauseEncoded<EI, DI>, R1 | R2> = Union(
|
|
9702
|
+
const causeEncoded = <E extends Schema.All, D extends Schema.All>(
|
|
9703
|
+
error: E,
|
|
9704
|
+
defect: D
|
|
9705
|
+
): SchemaClass<
|
|
9706
|
+
CauseEncoded<Schema.Type<E>, Schema.Type<D>>,
|
|
9707
|
+
CauseEncoded<Schema.Encoded<E>, Schema.Encoded<D>>,
|
|
9708
|
+
Schema.Context<E> | Schema.Context<D>
|
|
9709
|
+
> => {
|
|
9710
|
+
const error_ = asSchema(error)
|
|
9711
|
+
const defect_ = asSchema(defect)
|
|
9712
|
+
const suspended = suspend((): Schema<
|
|
9713
|
+
CauseEncoded<Schema.Type<E>, Schema.Type<D>>,
|
|
9714
|
+
CauseEncoded<Schema.Encoded<E>, Schema.Encoded<D>>,
|
|
9715
|
+
Schema.Context<E> | Schema.Context<D>
|
|
9716
|
+
> => out)
|
|
9717
|
+
const out = Union(
|
|
9553
9718
|
CauseEmptyEncoded,
|
|
9554
|
-
causeFailEncoded(
|
|
9555
|
-
causeDieEncoded(
|
|
9719
|
+
causeFailEncoded(error_),
|
|
9720
|
+
causeDieEncoded(defect_),
|
|
9556
9721
|
CauseInterruptEncoded,
|
|
9557
|
-
|
|
9558
|
-
|
|
9722
|
+
Struct({
|
|
9723
|
+
_tag: Literal("Sequential"),
|
|
9724
|
+
left: suspended,
|
|
9725
|
+
right: suspended
|
|
9726
|
+
}),
|
|
9727
|
+
Struct({
|
|
9728
|
+
_tag: Literal("Parallel"),
|
|
9729
|
+
left: suspended,
|
|
9730
|
+
right: suspended
|
|
9731
|
+
})
|
|
9559
9732
|
).annotations({ title: `CauseEncoded<${format(error)}>` })
|
|
9560
9733
|
return out
|
|
9561
9734
|
}
|
|
@@ -9615,11 +9788,11 @@ const causeParse = <A, D, R>(
|
|
|
9615
9788
|
* @since 3.10.0
|
|
9616
9789
|
*/
|
|
9617
9790
|
export interface CauseFromSelf<E extends Schema.All, D extends Schema.All> extends
|
|
9618
|
-
|
|
9791
|
+
AnnotableDeclare<
|
|
9619
9792
|
CauseFromSelf<E, D>,
|
|
9620
9793
|
cause_.Cause<Schema.Type<E>>,
|
|
9621
9794
|
cause_.Cause<Schema.Encoded<E>>,
|
|
9622
|
-
|
|
9795
|
+
[E, D]
|
|
9623
9796
|
>
|
|
9624
9797
|
{}
|
|
9625
9798
|
|
|
@@ -9692,11 +9865,13 @@ function causeEncode<E>(cause: cause_.Cause<E>): CauseEncoded<E, unknown> {
|
|
|
9692
9865
|
* @since 3.10.0
|
|
9693
9866
|
*/
|
|
9694
9867
|
export interface Cause<E extends Schema.All, D extends Schema.All> extends
|
|
9695
|
-
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
9868
|
+
transform<
|
|
9869
|
+
SchemaClass<
|
|
9870
|
+
CauseEncoded<Schema.Type<E>, Schema.Type<Defect>>,
|
|
9871
|
+
CauseEncoded<Schema.Encoded<E>, Schema.Encoded<Defect>>,
|
|
9872
|
+
Schema.Context<E> | Schema.Context<D>
|
|
9873
|
+
>,
|
|
9874
|
+
CauseFromSelf<SchemaClass<Schema.Type<E>>, SchemaClass<Schema.Type<D>>>
|
|
9700
9875
|
>
|
|
9701
9876
|
{}
|
|
9702
9877
|
|
|
@@ -9710,19 +9885,18 @@ export const Cause = <E extends Schema.All, D extends Schema.All>({ defect, erro
|
|
|
9710
9885
|
}): Cause<E, D> => {
|
|
9711
9886
|
const error_ = asSchema(error)
|
|
9712
9887
|
const defect_ = asSchema(defect)
|
|
9713
|
-
|
|
9888
|
+
const out = transform(
|
|
9714
9889
|
causeEncoded(error_, defect_),
|
|
9715
|
-
CauseFromSelf({ error: typeSchema(error_), defect:
|
|
9716
|
-
{
|
|
9890
|
+
CauseFromSelf({ error: typeSchema(error_), defect: typeSchema(defect_) }),
|
|
9891
|
+
{
|
|
9892
|
+
strict: false,
|
|
9893
|
+
decode: (i) => causeDecode(i),
|
|
9894
|
+
encode: (a) => causeEncode(a)
|
|
9895
|
+
}
|
|
9717
9896
|
)
|
|
9897
|
+
return out as any
|
|
9718
9898
|
}
|
|
9719
9899
|
|
|
9720
|
-
/**
|
|
9721
|
-
* @category api interface
|
|
9722
|
-
* @since 3.10.0
|
|
9723
|
-
*/
|
|
9724
|
-
export interface Defect extends transform<typeof Unknown, typeof Unknown> {}
|
|
9725
|
-
|
|
9726
9900
|
/**
|
|
9727
9901
|
* Defines a schema for handling JavaScript errors (`Error` instances) and other types of defects.
|
|
9728
9902
|
* It decodes objects into Error instances if they match the expected structure (i.e., have a `message` and optionally a `name` and `stack`),
|
|
@@ -9736,34 +9910,34 @@ export interface Defect extends transform<typeof Unknown, typeof Unknown> {}
|
|
|
9736
9910
|
* @category defect
|
|
9737
9911
|
* @since 3.10.0
|
|
9738
9912
|
*/
|
|
9739
|
-
export
|
|
9913
|
+
export class Defect extends transform(
|
|
9740
9914
|
Unknown,
|
|
9741
9915
|
Unknown,
|
|
9742
9916
|
{
|
|
9743
9917
|
strict: true,
|
|
9744
|
-
decode: (
|
|
9745
|
-
if (Predicate.isObject(
|
|
9746
|
-
const err = new Error(
|
|
9747
|
-
if ("name" in
|
|
9748
|
-
err.name =
|
|
9918
|
+
decode: (i) => {
|
|
9919
|
+
if (Predicate.isObject(i) && "message" in i && typeof i.message === "string") {
|
|
9920
|
+
const err = new Error(i.message, { cause: i })
|
|
9921
|
+
if ("name" in i && typeof i.name === "string") {
|
|
9922
|
+
err.name = i.name
|
|
9749
9923
|
}
|
|
9750
|
-
err.stack = "stack" in
|
|
9924
|
+
err.stack = "stack" in i && typeof i.stack === "string" ? i.stack : ""
|
|
9751
9925
|
return err
|
|
9752
9926
|
}
|
|
9753
|
-
return String(
|
|
9927
|
+
return String(i)
|
|
9754
9928
|
},
|
|
9755
|
-
encode: (
|
|
9756
|
-
if (
|
|
9929
|
+
encode: (a) => {
|
|
9930
|
+
if (a instanceof Error) {
|
|
9757
9931
|
return {
|
|
9758
|
-
name:
|
|
9759
|
-
message:
|
|
9932
|
+
name: a.name,
|
|
9933
|
+
message: a.message
|
|
9760
9934
|
// no stack because of security reasons
|
|
9761
9935
|
}
|
|
9762
9936
|
}
|
|
9763
|
-
return internalCause_.prettyErrorMessage(
|
|
9937
|
+
return internalCause_.prettyErrorMessage(a)
|
|
9764
9938
|
}
|
|
9765
9939
|
}
|
|
9766
|
-
).annotations({ identifier: "Defect" })
|
|
9940
|
+
).annotations({ identifier: "Defect" }) {}
|
|
9767
9941
|
|
|
9768
9942
|
/**
|
|
9769
9943
|
* @category Exit utils
|
|
@@ -9779,34 +9953,35 @@ export type ExitEncoded<A, E, D> =
|
|
|
9779
9953
|
readonly value: A
|
|
9780
9954
|
}
|
|
9781
9955
|
|
|
9782
|
-
const exitFailureEncoded = <E
|
|
9783
|
-
error:
|
|
9784
|
-
defect:
|
|
9956
|
+
const exitFailureEncoded = <E extends Schema.All, D extends Schema.All>(
|
|
9957
|
+
error: E,
|
|
9958
|
+
defect: D
|
|
9785
9959
|
) =>
|
|
9786
9960
|
Struct({
|
|
9787
9961
|
_tag: Literal("Failure"),
|
|
9788
9962
|
cause: causeEncoded(error, defect)
|
|
9789
9963
|
})
|
|
9790
9964
|
|
|
9791
|
-
const exitSuccessEncoded = <A
|
|
9792
|
-
value:
|
|
9965
|
+
const exitSuccessEncoded = <A extends Schema.All>(
|
|
9966
|
+
value: A
|
|
9793
9967
|
) =>
|
|
9794
9968
|
Struct({
|
|
9795
9969
|
_tag: Literal("Success"),
|
|
9796
9970
|
value
|
|
9797
9971
|
})
|
|
9798
9972
|
|
|
9799
|
-
const exitEncoded = <A
|
|
9800
|
-
value:
|
|
9801
|
-
error:
|
|
9802
|
-
defect:
|
|
9803
|
-
)
|
|
9804
|
-
Union(
|
|
9973
|
+
const exitEncoded = <A extends Schema.All, E extends Schema.All, D extends Schema.Any>(
|
|
9974
|
+
value: A,
|
|
9975
|
+
error: E,
|
|
9976
|
+
defect: D
|
|
9977
|
+
) => {
|
|
9978
|
+
return Union(
|
|
9805
9979
|
exitFailureEncoded(error, defect),
|
|
9806
9980
|
exitSuccessEncoded(value)
|
|
9807
9981
|
).annotations({
|
|
9808
9982
|
title: `ExitEncoded<${format(value)}, ${format(error)}, ${format(defect)}>`
|
|
9809
9983
|
})
|
|
9984
|
+
}
|
|
9810
9985
|
|
|
9811
9986
|
const exitDecode = <A, E>(input: ExitEncoded<A, E, unknown>): exit_.Exit<A, E> => {
|
|
9812
9987
|
switch (input._tag) {
|
|
@@ -9850,13 +10025,14 @@ const exitParse = <A, R, E, ER>(
|
|
|
9850
10025
|
* @category api interface
|
|
9851
10026
|
* @since 3.10.0
|
|
9852
10027
|
*/
|
|
9853
|
-
export interface ExitFromSelf<A extends Schema.All, E extends Schema.All, D extends Schema.All>
|
|
9854
|
-
|
|
9855
|
-
|
|
9856
|
-
|
|
9857
|
-
|
|
9858
|
-
|
|
9859
|
-
|
|
10028
|
+
export interface ExitFromSelf<A extends Schema.All, E extends Schema.All, D extends Schema.All>
|
|
10029
|
+
extends
|
|
10030
|
+
AnnotableDeclare<
|
|
10031
|
+
ExitFromSelf<A, E, D>,
|
|
10032
|
+
exit_.Exit<Schema.Type<A>, Schema.Type<E>>,
|
|
10033
|
+
exit_.Exit<Schema.Encoded<A>, Schema.Encoded<E>>,
|
|
10034
|
+
[A, E, D]
|
|
10035
|
+
>
|
|
9860
10036
|
{}
|
|
9861
10037
|
|
|
9862
10038
|
/**
|
|
@@ -9896,11 +10072,22 @@ export const ExitFromSelf = <A extends Schema.All, E extends Schema.All, D exten
|
|
|
9896
10072
|
* @since 3.10.0
|
|
9897
10073
|
*/
|
|
9898
10074
|
export interface Exit<A extends Schema.All, E extends Schema.All, D extends Schema.All> extends
|
|
9899
|
-
|
|
9900
|
-
|
|
9901
|
-
|
|
9902
|
-
|
|
9903
|
-
|
|
10075
|
+
transform<
|
|
10076
|
+
Union<[
|
|
10077
|
+
Struct<{
|
|
10078
|
+
_tag: Literal<["Failure"]>
|
|
10079
|
+
cause: SchemaClass<
|
|
10080
|
+
CauseEncoded<Schema.Type<E>, Schema.Type<D>>,
|
|
10081
|
+
CauseEncoded<Schema.Encoded<E>, Schema.Encoded<D>>,
|
|
10082
|
+
Schema.Context<E> | Schema.Context<D>
|
|
10083
|
+
>
|
|
10084
|
+
}>,
|
|
10085
|
+
Struct<{
|
|
10086
|
+
_tag: Literal<["Success"]>
|
|
10087
|
+
value: A
|
|
10088
|
+
}>
|
|
10089
|
+
]>,
|
|
10090
|
+
ExitFromSelf<SchemaClass<Schema.Type<A>>, SchemaClass<Schema.Type<E>>, SchemaClass<Schema.Type<D>>>
|
|
9904
10091
|
>
|
|
9905
10092
|
{}
|
|
9906
10093
|
|
|
@@ -9918,18 +10105,19 @@ export const Exit = <A extends Schema.All, E extends Schema.All, D extends Schem
|
|
|
9918
10105
|
const success_ = asSchema(success)
|
|
9919
10106
|
const failure_ = asSchema(failure)
|
|
9920
10107
|
const defect_ = asSchema(defect)
|
|
9921
|
-
|
|
10108
|
+
const out = transform(
|
|
9922
10109
|
exitEncoded(success_, failure_, defect_),
|
|
9923
|
-
ExitFromSelf({ failure: typeSchema(failure_), success: typeSchema(success_), defect:
|
|
10110
|
+
ExitFromSelf({ failure: typeSchema(failure_), success: typeSchema(success_), defect: typeSchema(defect_) }),
|
|
9924
10111
|
{
|
|
9925
10112
|
strict: false,
|
|
9926
|
-
decode: exitDecode,
|
|
9927
|
-
encode: (
|
|
9928
|
-
|
|
9929
|
-
? { _tag: "Failure", cause:
|
|
9930
|
-
: { _tag: "Success", value:
|
|
10113
|
+
decode: (i) => exitDecode(i),
|
|
10114
|
+
encode: (a) =>
|
|
10115
|
+
a._tag === "Failure"
|
|
10116
|
+
? { _tag: "Failure", cause: a.cause } as const
|
|
10117
|
+
: { _tag: "Success", value: a.value } as const
|
|
9931
10118
|
}
|
|
9932
10119
|
)
|
|
10120
|
+
return out as any
|
|
9933
10121
|
}
|
|
9934
10122
|
|
|
9935
10123
|
const hashSetArbitrary =
|
|
@@ -9963,11 +10151,11 @@ const hashSetParse = <A, R>(
|
|
|
9963
10151
|
* @since 3.10.0
|
|
9964
10152
|
*/
|
|
9965
10153
|
export interface HashSetFromSelf<Value extends Schema.Any> extends
|
|
9966
|
-
|
|
10154
|
+
AnnotableDeclare<
|
|
9967
10155
|
HashSetFromSelf<Value>,
|
|
9968
10156
|
hashSet_.HashSet<Schema.Type<Value>>,
|
|
9969
10157
|
hashSet_.HashSet<Schema.Encoded<Value>>,
|
|
9970
|
-
|
|
10158
|
+
[Value]
|
|
9971
10159
|
>
|
|
9972
10160
|
{}
|
|
9973
10161
|
|
|
@@ -9997,25 +10185,23 @@ export const HashSetFromSelf = <Value extends Schema.Any>(
|
|
|
9997
10185
|
* @category api interface
|
|
9998
10186
|
* @since 3.10.0
|
|
9999
10187
|
*/
|
|
10000
|
-
export interface HashSet<Value extends Schema.Any>
|
|
10001
|
-
|
|
10002
|
-
HashSet<Value>,
|
|
10003
|
-
hashSet_.HashSet<Schema.Type<Value>>,
|
|
10004
|
-
ReadonlyArray<Schema.Encoded<Value>>,
|
|
10005
|
-
Schema.Context<Value>
|
|
10006
|
-
>
|
|
10188
|
+
export interface HashSet<Value extends Schema.Any>
|
|
10189
|
+
extends transform<Array$<Value>, HashSetFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
10007
10190
|
{}
|
|
10008
10191
|
|
|
10009
10192
|
/**
|
|
10010
10193
|
* @category HashSet transformations
|
|
10011
10194
|
* @since 3.10.0
|
|
10012
10195
|
*/
|
|
10013
|
-
export
|
|
10014
|
-
const value_ = asSchema(value)
|
|
10196
|
+
export function HashSet<Value extends Schema.Any>(value: Value): HashSet<Value> {
|
|
10015
10197
|
return transform(
|
|
10016
|
-
Array$(
|
|
10017
|
-
HashSetFromSelf(typeSchema(
|
|
10018
|
-
{
|
|
10198
|
+
Array$(value),
|
|
10199
|
+
HashSetFromSelf(typeSchema(asSchema(value))),
|
|
10200
|
+
{
|
|
10201
|
+
strict: true,
|
|
10202
|
+
decode: (i) => hashSet_.fromIterable(i),
|
|
10203
|
+
encode: (a) => Array.from(a)
|
|
10204
|
+
}
|
|
10019
10205
|
)
|
|
10020
10206
|
}
|
|
10021
10207
|
|
|
@@ -10063,11 +10249,11 @@ const hashMapParse = <R, K, V>(
|
|
|
10063
10249
|
* @since 3.10.0
|
|
10064
10250
|
*/
|
|
10065
10251
|
export interface HashMapFromSelf<K extends Schema.Any, V extends Schema.Any> extends
|
|
10066
|
-
|
|
10252
|
+
AnnotableDeclare<
|
|
10067
10253
|
HashMapFromSelf<K, V>,
|
|
10068
10254
|
hashMap_.HashMap<Schema.Type<K>, Schema.Type<V>>,
|
|
10069
10255
|
hashMap_.HashMap<Schema.Encoded<K>, Schema.Encoded<V>>,
|
|
10070
|
-
|
|
10256
|
+
[K, V]
|
|
10071
10257
|
>
|
|
10072
10258
|
{}
|
|
10073
10259
|
|
|
@@ -10098,13 +10284,8 @@ export const HashMapFromSelf = <K extends Schema.Any, V extends Schema.Any>({ ke
|
|
|
10098
10284
|
* @category api interface
|
|
10099
10285
|
* @since 3.10.0
|
|
10100
10286
|
*/
|
|
10101
|
-
export interface HashMap<K extends Schema.Any, V extends Schema.Any>
|
|
10102
|
-
|
|
10103
|
-
HashMap<K, V>,
|
|
10104
|
-
hashMap_.HashMap<Schema.Type<K>, Schema.Type<V>>,
|
|
10105
|
-
ReadonlyArray<readonly [Schema.Encoded<K>, Schema.Encoded<V>]>,
|
|
10106
|
-
Schema.Context<K> | Schema.Context<V>
|
|
10107
|
-
>
|
|
10287
|
+
export interface HashMap<K extends Schema.Any, V extends Schema.Any>
|
|
10288
|
+
extends transform<Array$<Tuple2<K, V>>, HashMapFromSelf<SchemaClass<Schema.Type<K>>, SchemaClass<Schema.Type<V>>>>
|
|
10108
10289
|
{}
|
|
10109
10290
|
|
|
10110
10291
|
/**
|
|
@@ -10115,12 +10296,14 @@ export const HashMap = <K extends Schema.Any, V extends Schema.Any>({ key, value
|
|
|
10115
10296
|
readonly key: K
|
|
10116
10297
|
readonly value: V
|
|
10117
10298
|
}): HashMap<K, V> => {
|
|
10118
|
-
const key_ = asSchema(key)
|
|
10119
|
-
const value_ = asSchema(value)
|
|
10120
10299
|
return transform(
|
|
10121
|
-
Array$(Tuple(
|
|
10122
|
-
HashMapFromSelf({ key: typeSchema(
|
|
10123
|
-
{
|
|
10300
|
+
Array$(Tuple(key, value)),
|
|
10301
|
+
HashMapFromSelf({ key: typeSchema(asSchema(key)), value: typeSchema(asSchema(value)) }),
|
|
10302
|
+
{
|
|
10303
|
+
strict: true,
|
|
10304
|
+
decode: (i) => hashMap_.fromIterable(i),
|
|
10305
|
+
encode: (a) => Array.from(a)
|
|
10306
|
+
}
|
|
10124
10307
|
)
|
|
10125
10308
|
}
|
|
10126
10309
|
|
|
@@ -10153,11 +10336,11 @@ const listParse = <A, R>(
|
|
|
10153
10336
|
* @since 3.10.0
|
|
10154
10337
|
*/
|
|
10155
10338
|
export interface ListFromSelf<Value extends Schema.Any> extends
|
|
10156
|
-
|
|
10339
|
+
AnnotableDeclare<
|
|
10157
10340
|
ListFromSelf<Value>,
|
|
10158
10341
|
list_.List<Schema.Type<Value>>,
|
|
10159
10342
|
list_.List<Schema.Encoded<Value>>,
|
|
10160
|
-
|
|
10343
|
+
[Value]
|
|
10161
10344
|
>
|
|
10162
10345
|
{}
|
|
10163
10346
|
|
|
@@ -10187,25 +10370,23 @@ export const ListFromSelf = <Value extends Schema.Any>(
|
|
|
10187
10370
|
* @category api interface
|
|
10188
10371
|
* @since 3.10.0
|
|
10189
10372
|
*/
|
|
10190
|
-
export interface List<Value extends Schema.Any>
|
|
10191
|
-
|
|
10192
|
-
List<Value>,
|
|
10193
|
-
list_.List<Schema.Type<Value>>,
|
|
10194
|
-
ReadonlyArray<Schema.Encoded<Value>>,
|
|
10195
|
-
Schema.Context<Value>
|
|
10196
|
-
>
|
|
10373
|
+
export interface List<Value extends Schema.Any>
|
|
10374
|
+
extends transform<Array$<Value>, ListFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
10197
10375
|
{}
|
|
10198
10376
|
|
|
10199
10377
|
/**
|
|
10200
10378
|
* @category List transformations
|
|
10201
10379
|
* @since 3.10.0
|
|
10202
10380
|
*/
|
|
10203
|
-
export
|
|
10204
|
-
const value_ = asSchema(value)
|
|
10381
|
+
export function List<Value extends Schema.Any>(value: Value): List<Value> {
|
|
10205
10382
|
return transform(
|
|
10206
|
-
Array$(
|
|
10207
|
-
ListFromSelf(typeSchema(
|
|
10208
|
-
{
|
|
10383
|
+
Array$(value),
|
|
10384
|
+
ListFromSelf(typeSchema(asSchema(value))),
|
|
10385
|
+
{
|
|
10386
|
+
strict: true,
|
|
10387
|
+
decode: (i) => list_.fromIterable(i),
|
|
10388
|
+
encode: (a) => Array.from(a)
|
|
10389
|
+
}
|
|
10209
10390
|
)
|
|
10210
10391
|
}
|
|
10211
10392
|
|
|
@@ -10243,11 +10424,11 @@ const sortedSetParse = <A, R>(
|
|
|
10243
10424
|
* @since 3.10.0
|
|
10244
10425
|
*/
|
|
10245
10426
|
export interface SortedSetFromSelf<Value extends Schema.Any> extends
|
|
10246
|
-
|
|
10427
|
+
AnnotableDeclare<
|
|
10247
10428
|
SortedSetFromSelf<Value>,
|
|
10248
10429
|
sortedSet_.SortedSet<Schema.Type<Value>>,
|
|
10249
10430
|
sortedSet_.SortedSet<Schema.Encoded<Value>>,
|
|
10250
|
-
|
|
10431
|
+
[Value]
|
|
10251
10432
|
>
|
|
10252
10433
|
{}
|
|
10253
10434
|
|
|
@@ -10279,32 +10460,26 @@ export const SortedSetFromSelf = <Value extends Schema.Any>(
|
|
|
10279
10460
|
* @category api interface
|
|
10280
10461
|
* @since 3.10.0
|
|
10281
10462
|
*/
|
|
10282
|
-
export interface SortedSet<Value extends Schema.Any>
|
|
10283
|
-
|
|
10284
|
-
SortedSet<Value>,
|
|
10285
|
-
sortedSet_.SortedSet<Schema.Type<Value>>,
|
|
10286
|
-
ReadonlyArray<Schema.Encoded<Value>>,
|
|
10287
|
-
Schema.Context<Value>
|
|
10288
|
-
>
|
|
10463
|
+
export interface SortedSet<Value extends Schema.Any>
|
|
10464
|
+
extends transform<Array$<Value>, SortedSetFromSelf<SchemaClass<Schema.Type<Value>>>>
|
|
10289
10465
|
{}
|
|
10290
10466
|
|
|
10291
10467
|
/**
|
|
10292
10468
|
* @category SortedSet transformations
|
|
10293
10469
|
* @since 3.10.0
|
|
10294
10470
|
*/
|
|
10295
|
-
export
|
|
10471
|
+
export function SortedSet<Value extends Schema.Any>(
|
|
10296
10472
|
value: Value,
|
|
10297
10473
|
ordA: Order.Order<Schema.Type<Value>>
|
|
10298
|
-
): SortedSet<Value>
|
|
10299
|
-
const
|
|
10300
|
-
const to = typeSchema(value_)
|
|
10474
|
+
): SortedSet<Value> {
|
|
10475
|
+
const to = typeSchema(asSchema(value))
|
|
10301
10476
|
return transform(
|
|
10302
|
-
Array$(
|
|
10477
|
+
Array$(value),
|
|
10303
10478
|
SortedSetFromSelf<typeof to>(to, ordA, ordA),
|
|
10304
10479
|
{
|
|
10305
10480
|
strict: true,
|
|
10306
|
-
decode: (
|
|
10307
|
-
encode: (
|
|
10481
|
+
decode: (i) => sortedSet_.fromIterable(i, ordA),
|
|
10482
|
+
encode: (a) => Array.from(sortedSet_.values(a))
|
|
10308
10483
|
}
|
|
10309
10484
|
)
|
|
10310
10485
|
}
|
|
@@ -10320,7 +10495,11 @@ export const SortedSet = <Value extends Schema.Any>(
|
|
|
10320
10495
|
export class BooleanFromUnknown extends transform(
|
|
10321
10496
|
Unknown,
|
|
10322
10497
|
Boolean$,
|
|
10323
|
-
{
|
|
10498
|
+
{
|
|
10499
|
+
strict: true,
|
|
10500
|
+
decode: (i) => Predicate.isTruthy(i),
|
|
10501
|
+
encode: identity
|
|
10502
|
+
}
|
|
10324
10503
|
).annotations({ identifier: "BooleanFromUnknown" }) {}
|
|
10325
10504
|
|
|
10326
10505
|
/**
|
|
@@ -10333,7 +10512,11 @@ export class BooleanFromUnknown extends transform(
|
|
|
10333
10512
|
export class BooleanFromString extends transform(
|
|
10334
10513
|
Literal("true", "false").annotations({ description: "a string to be decoded into a boolean" }),
|
|
10335
10514
|
Boolean$,
|
|
10336
|
-
{
|
|
10515
|
+
{
|
|
10516
|
+
strict: true,
|
|
10517
|
+
decode: (i) => i === "true",
|
|
10518
|
+
encode: (a) => a ? "true" : "false"
|
|
10519
|
+
}
|
|
10337
10520
|
).annotations({ identifier: "BooleanFromString" }) {}
|
|
10338
10521
|
|
|
10339
10522
|
/**
|
|
@@ -10878,7 +11061,7 @@ export const TaggedRequest =
|
|
|
10878
11061
|
success: Success
|
|
10879
11062
|
payload: Payload
|
|
10880
11063
|
},
|
|
10881
|
-
annotations?: ClassAnnotations<Self, Struct.Type<{ readonly _tag: tag<Tag> } & Payload
|
|
11064
|
+
annotations?: ClassAnnotations<Self, Simplify<Struct.Type<{ readonly _tag: tag<Tag> } & Payload>>>
|
|
10882
11065
|
): [Self] extends [never] ? MissingSelfGeneric<"TaggedRequest", `"Tag", SuccessSchema, FailureSchema, `>
|
|
10883
11066
|
: TaggedRequestClass<
|
|
10884
11067
|
Self,
|
|
@@ -11100,6 +11283,20 @@ const go = (ast: AST.AST, path: ReadonlyArray<PropertyKey>): Equivalence.Equival
|
|
|
11100
11283
|
}
|
|
11101
11284
|
}
|
|
11102
11285
|
|
|
11286
|
+
const SymbolStruct = TaggedStruct("symbol", {
|
|
11287
|
+
key: String$
|
|
11288
|
+
}).annotations({ description: "an object to be decoded into a globally shared symbol" })
|
|
11289
|
+
|
|
11290
|
+
const SymbolFromStruct = transformOrFail(
|
|
11291
|
+
SymbolStruct,
|
|
11292
|
+
SymbolFromSelf,
|
|
11293
|
+
{
|
|
11294
|
+
strict: true,
|
|
11295
|
+
decode: (i) => decodeSymbol(i.key),
|
|
11296
|
+
encode: (a, _, ast) => ParseResult.map(encodeSymbol(a, ast), (key) => SymbolStruct.make({ key }))
|
|
11297
|
+
}
|
|
11298
|
+
)
|
|
11299
|
+
|
|
11103
11300
|
/** @ignore */
|
|
11104
11301
|
class PropertyKey$ extends Union(String$, Number$, SymbolFromStruct).annotations({ identifier: "PropertyKey" }) {}
|
|
11105
11302
|
|