effect 3.11.5 → 3.11.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Arbitrary.js +357 -343
- package/dist/cjs/Arbitrary.js.map +1 -1
- package/dist/cjs/JSONSchema.js +157 -38
- package/dist/cjs/JSONSchema.js.map +1 -1
- package/dist/cjs/Schema.js +49 -33
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/internal/schema/filters.js +24 -18
- package/dist/cjs/internal/schema/filters.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Arbitrary.d.ts +21 -1
- package/dist/dts/Arbitrary.d.ts.map +1 -1
- package/dist/dts/JSONSchema.d.ts +11 -2
- package/dist/dts/JSONSchema.d.ts.map +1 -1
- package/dist/dts/Schema.d.ts +46 -18
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/esm/Arbitrary.js +351 -335
- package/dist/esm/Arbitrary.js.map +1 -1
- package/dist/esm/JSONSchema.js +157 -38
- package/dist/esm/JSONSchema.js.map +1 -1
- package/dist/esm/Schema.js +49 -33
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/internal/schema/filters.js +23 -17
- package/dist/esm/internal/schema/filters.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/Arbitrary.ts +410 -361
- package/src/JSONSchema.ts +185 -40
- package/src/Schema.ts +161 -74
- package/src/internal/schema/filters.ts +32 -17
- package/src/internal/version.ts +1 -1
package/src/Schema.ts
CHANGED
|
@@ -87,7 +87,7 @@ export interface Schema<in out A, in out I = A, out R = never> extends Schema.Va
|
|
|
87
87
|
* Merges a set of new annotations with existing ones, potentially overwriting
|
|
88
88
|
* any duplicates.
|
|
89
89
|
*/
|
|
90
|
-
annotations(annotations: Annotations.
|
|
90
|
+
annotations(annotations: Annotations.GenericSchema<A>): Schema<A, I, R>
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
/**
|
|
@@ -107,7 +107,7 @@ export const make = <A, I = A, R = never>(ast: AST.AST): SchemaClass<A, I, R> =>
|
|
|
107
107
|
static Context: R
|
|
108
108
|
static [TypeId] = variance
|
|
109
109
|
static ast = ast
|
|
110
|
-
static annotations(annotations: Annotations.
|
|
110
|
+
static annotations(annotations: Annotations.GenericSchema<A>) {
|
|
111
111
|
return make<A, I, R>(mergeSchemaAnnotations(this.ast, annotations))
|
|
112
112
|
}
|
|
113
113
|
static pipe() {
|
|
@@ -204,7 +204,7 @@ export declare namespace Annotable {
|
|
|
204
204
|
* @since 3.10.0
|
|
205
205
|
*/
|
|
206
206
|
export interface Annotable<Self extends Schema<A, I, R>, A, I = A, R = never> extends Schema<A, I, R> {
|
|
207
|
-
annotations(annotations: Annotations.
|
|
207
|
+
annotations(annotations: Annotations.GenericSchema<A>): Self
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
/**
|
|
@@ -4357,6 +4357,15 @@ export declare namespace Annotations {
|
|
|
4357
4357
|
readonly decodingFallback?: AST.DecodingFallbackAnnotation<A>
|
|
4358
4358
|
}
|
|
4359
4359
|
|
|
4360
|
+
/**
|
|
4361
|
+
* @since 3.11.6
|
|
4362
|
+
*/
|
|
4363
|
+
export interface GenericSchema<A> extends Schema<A> {
|
|
4364
|
+
readonly arbitrary?: (..._: any) => LazyArbitrary<A>
|
|
4365
|
+
readonly pretty?: (..._: any) => pretty_.Pretty<A>
|
|
4366
|
+
readonly equivalence?: (..._: any) => Equivalence.Equivalence<A>
|
|
4367
|
+
}
|
|
4368
|
+
|
|
4360
4369
|
/**
|
|
4361
4370
|
* @since 3.10.0
|
|
4362
4371
|
*/
|
|
@@ -4378,7 +4387,7 @@ export const annotations: {
|
|
|
4378
4387
|
* @category annotations
|
|
4379
4388
|
* @since 3.10.0
|
|
4380
4389
|
*/
|
|
4381
|
-
<S extends Annotable.All>(annotations: Annotations.
|
|
4390
|
+
<S extends Annotable.All>(annotations: Annotations.GenericSchema<Schema.Type<S>>): (self: S) => Annotable.Self<S>
|
|
4382
4391
|
/**
|
|
4383
4392
|
* Merges a set of new annotations with existing ones, potentially overwriting
|
|
4384
4393
|
* any duplicates.
|
|
@@ -4386,10 +4395,11 @@ export const annotations: {
|
|
|
4386
4395
|
* @category annotations
|
|
4387
4396
|
* @since 3.10.0
|
|
4388
4397
|
*/
|
|
4389
|
-
<S extends Annotable.All>(self: S, annotations: Annotations.
|
|
4398
|
+
<S extends Annotable.All>(self: S, annotations: Annotations.GenericSchema<Schema.Type<S>>): Annotable.Self<S>
|
|
4390
4399
|
} = dual(
|
|
4391
4400
|
2,
|
|
4392
|
-
<A, I, R>(self: Schema<A, I, R>, annotations: Annotations.
|
|
4401
|
+
<A, I, R>(self: Schema<A, I, R>, annotations: Annotations.GenericSchema<A>): Schema<A, I, R> =>
|
|
4402
|
+
self.annotations(annotations)
|
|
4393
4403
|
)
|
|
4394
4404
|
|
|
4395
4405
|
type Rename<A, M> = {
|
|
@@ -4562,7 +4572,6 @@ export const pattern = <A extends string>(
|
|
|
4562
4572
|
[PatternSchemaId]: { regex },
|
|
4563
4573
|
description: `a string matching the pattern ${pattern}`,
|
|
4564
4574
|
jsonSchema: { pattern },
|
|
4565
|
-
arbitrary: () => (fc) => fc.stringMatching(regex) as any,
|
|
4566
4575
|
...annotations
|
|
4567
4576
|
}
|
|
4568
4577
|
)
|
|
@@ -5152,7 +5161,13 @@ export {
|
|
|
5152
5161
|
* @category schema id
|
|
5153
5162
|
* @since 3.10.0
|
|
5154
5163
|
*/
|
|
5155
|
-
export const FiniteSchemaId: unique symbol =
|
|
5164
|
+
export const FiniteSchemaId: unique symbol = filters_.FiniteSchemaId
|
|
5165
|
+
|
|
5166
|
+
/**
|
|
5167
|
+
* @category schema id
|
|
5168
|
+
* @since 3.10.0
|
|
5169
|
+
*/
|
|
5170
|
+
export type FiniteSchemaId = typeof FiniteSchemaId
|
|
5156
5171
|
|
|
5157
5172
|
/**
|
|
5158
5173
|
* Ensures that the provided value is a finite number.
|
|
@@ -5165,9 +5180,10 @@ export const FiniteSchemaId: unique symbol = Symbol.for("effect/SchemaId/Finite"
|
|
|
5165
5180
|
export const finite =
|
|
5166
5181
|
<A extends number>(annotations?: Annotations.Filter<A>) => <I, R>(self: Schema<A, I, R>): filter<Schema<A, I, R>> =>
|
|
5167
5182
|
self.pipe(
|
|
5168
|
-
filter(
|
|
5183
|
+
filter(Number.isFinite, {
|
|
5169
5184
|
schemaId: FiniteSchemaId,
|
|
5170
5185
|
description: "a finite number",
|
|
5186
|
+
jsonSchema: { "type": "number" },
|
|
5171
5187
|
...annotations
|
|
5172
5188
|
})
|
|
5173
5189
|
)
|
|
@@ -5387,7 +5403,13 @@ export const between = <A extends number>(
|
|
|
5387
5403
|
* @category schema id
|
|
5388
5404
|
* @since 3.10.0
|
|
5389
5405
|
*/
|
|
5390
|
-
export const NonNaNSchemaId: unique symbol =
|
|
5406
|
+
export const NonNaNSchemaId: unique symbol = filters_.NonNaNSchemaId
|
|
5407
|
+
|
|
5408
|
+
/**
|
|
5409
|
+
* @category schema id
|
|
5410
|
+
* @since 3.10.0
|
|
5411
|
+
*/
|
|
5412
|
+
export type NonNaNSchemaId = typeof NonNaNSchemaId
|
|
5391
5413
|
|
|
5392
5414
|
/**
|
|
5393
5415
|
* @category number filters
|
|
@@ -5541,7 +5563,13 @@ export class NonNegative extends Number$.pipe(
|
|
|
5541
5563
|
* @category schema id
|
|
5542
5564
|
* @since 3.10.0
|
|
5543
5565
|
*/
|
|
5544
|
-
export const JsonNumberSchemaId: unique symbol =
|
|
5566
|
+
export const JsonNumberSchemaId: unique symbol = filters_.JsonNumberSchemaId
|
|
5567
|
+
|
|
5568
|
+
/**
|
|
5569
|
+
* @category schema id
|
|
5570
|
+
* @since 3.10.0
|
|
5571
|
+
*/
|
|
5572
|
+
export type JsonNumberSchemaId = typeof JsonNumberSchemaId
|
|
5545
5573
|
|
|
5546
5574
|
/**
|
|
5547
5575
|
* The `JsonNumber` is a schema for representing JSON numbers. It ensures that the provided value is a valid
|
|
@@ -5564,12 +5592,11 @@ export const JsonNumberSchemaId: unique symbol = Symbol.for("effect/SchemaId/Jso
|
|
|
5564
5592
|
* @since 3.10.0
|
|
5565
5593
|
*/
|
|
5566
5594
|
export class JsonNumber extends Number$.pipe(
|
|
5567
|
-
|
|
5595
|
+
finite({
|
|
5568
5596
|
schemaId: JsonNumberSchemaId,
|
|
5569
5597
|
identifier: "JsonNumber",
|
|
5570
5598
|
title: "JSON-compatible number",
|
|
5571
|
-
description: "a JSON-compatible number, excluding NaN, +Infinity, and -Infinity"
|
|
5572
|
-
jsonSchema: { type: "number" }
|
|
5599
|
+
description: "a JSON-compatible number, excluding NaN, +Infinity, and -Infinity"
|
|
5573
5600
|
})
|
|
5574
5601
|
) {}
|
|
5575
5602
|
|
|
@@ -6707,8 +6734,8 @@ export class DateFromSelf extends declare(
|
|
|
6707
6734
|
{
|
|
6708
6735
|
identifier: "DateFromSelf",
|
|
6709
6736
|
description: "a potentially invalid Date instance",
|
|
6710
|
-
pretty: ()
|
|
6711
|
-
arbitrary: ()
|
|
6737
|
+
pretty: () => (date) => `new Date(${JSON.stringify(date)})`,
|
|
6738
|
+
arbitrary: () => (fc) => fc.date({ noInvalidDate: false }),
|
|
6712
6739
|
equivalence: () => Equivalence.Date
|
|
6713
6740
|
}
|
|
6714
6741
|
) {}
|
|
@@ -8343,6 +8370,14 @@ type RequiredKeys<T> = {
|
|
|
8343
8370
|
[K in keyof T]-?: {} extends Pick<T, K> ? never : K
|
|
8344
8371
|
}[keyof T]
|
|
8345
8372
|
|
|
8373
|
+
type ClassAnnotations<Self, A> =
|
|
8374
|
+
| Annotations.Schema<Self>
|
|
8375
|
+
| readonly [
|
|
8376
|
+
Annotations.Schema<Self> | undefined,
|
|
8377
|
+
Annotations.Schema<Self>?,
|
|
8378
|
+
Annotations.Schema<A>?
|
|
8379
|
+
]
|
|
8380
|
+
|
|
8346
8381
|
/**
|
|
8347
8382
|
* @category api interface
|
|
8348
8383
|
* @since 3.10.0
|
|
@@ -8388,16 +8423,16 @@ export interface Class<Self, Fields extends Struct.Fields, I, R, C, Inherited, P
|
|
|
8388
8423
|
* }
|
|
8389
8424
|
* ```
|
|
8390
8425
|
*/
|
|
8391
|
-
extend<Extended = never>(identifier: string): <
|
|
8392
|
-
fields:
|
|
8393
|
-
annotations?:
|
|
8426
|
+
extend<Extended = never>(identifier: string): <NewFields extends Struct.Fields>(
|
|
8427
|
+
fields: NewFields | HasFields<NewFields>,
|
|
8428
|
+
annotations?: ClassAnnotations<Extended, Struct.Type<Fields & NewFields>>
|
|
8394
8429
|
) => [Extended] extends [never] ? MissingSelfGeneric<"Base.extend">
|
|
8395
8430
|
: Class<
|
|
8396
8431
|
Extended,
|
|
8397
|
-
Fields &
|
|
8398
|
-
I & Struct.Encoded<
|
|
8399
|
-
R | Struct.Context<
|
|
8400
|
-
C & Struct.Constructor<
|
|
8432
|
+
Fields & NewFields,
|
|
8433
|
+
I & Struct.Encoded<NewFields>,
|
|
8434
|
+
R | Struct.Context<NewFields>,
|
|
8435
|
+
C & Struct.Constructor<NewFields>,
|
|
8401
8436
|
Self,
|
|
8402
8437
|
Proto
|
|
8403
8438
|
>
|
|
@@ -8432,31 +8467,31 @@ export interface Class<Self, Fields extends Struct.Fields, I, R, C, Inherited, P
|
|
|
8432
8467
|
* ```
|
|
8433
8468
|
*/
|
|
8434
8469
|
transformOrFail<Transformed = never>(identifier: string): <
|
|
8435
|
-
|
|
8470
|
+
NewFields extends Struct.Fields,
|
|
8436
8471
|
R2,
|
|
8437
8472
|
R3
|
|
8438
8473
|
>(
|
|
8439
|
-
fields:
|
|
8474
|
+
fields: NewFields,
|
|
8440
8475
|
options: {
|
|
8441
8476
|
readonly decode: (
|
|
8442
8477
|
input: Simplify<Struct.Type<Fields>>,
|
|
8443
8478
|
options: ParseOptions,
|
|
8444
8479
|
ast: AST.Transformation
|
|
8445
|
-
) => Effect.Effect<Simplify<Struct.Type<Fields &
|
|
8480
|
+
) => Effect.Effect<Simplify<Struct.Type<Fields & NewFields>>, ParseResult.ParseIssue, R2>
|
|
8446
8481
|
readonly encode: (
|
|
8447
|
-
input: Simplify<Struct.Type<Fields &
|
|
8482
|
+
input: Simplify<Struct.Type<Fields & NewFields>>,
|
|
8448
8483
|
options: ParseOptions,
|
|
8449
8484
|
ast: AST.Transformation
|
|
8450
8485
|
) => Effect.Effect<Struct.Type<Fields>, ParseResult.ParseIssue, R3>
|
|
8451
8486
|
},
|
|
8452
|
-
annotations?:
|
|
8487
|
+
annotations?: ClassAnnotations<Transformed, Struct.Type<Fields & NewFields>>
|
|
8453
8488
|
) => [Transformed] extends [never] ? MissingSelfGeneric<"Base.transformOrFail">
|
|
8454
8489
|
: Class<
|
|
8455
8490
|
Transformed,
|
|
8456
|
-
Fields &
|
|
8491
|
+
Fields & NewFields,
|
|
8457
8492
|
I,
|
|
8458
|
-
R | Struct.Context<
|
|
8459
|
-
C & Struct.Constructor<
|
|
8493
|
+
R | Struct.Context<NewFields> | R2 | R3,
|
|
8494
|
+
C & Struct.Constructor<NewFields>,
|
|
8460
8495
|
Self,
|
|
8461
8496
|
Proto
|
|
8462
8497
|
>
|
|
@@ -8491,31 +8526,31 @@ export interface Class<Self, Fields extends Struct.Fields, I, R, C, Inherited, P
|
|
|
8491
8526
|
* ```
|
|
8492
8527
|
*/
|
|
8493
8528
|
transformOrFailFrom<Transformed = never>(identifier: string): <
|
|
8494
|
-
|
|
8529
|
+
NewFields extends Struct.Fields,
|
|
8495
8530
|
R2,
|
|
8496
8531
|
R3
|
|
8497
8532
|
>(
|
|
8498
|
-
fields:
|
|
8533
|
+
fields: NewFields,
|
|
8499
8534
|
options: {
|
|
8500
8535
|
readonly decode: (
|
|
8501
8536
|
input: Simplify<I>,
|
|
8502
8537
|
options: ParseOptions,
|
|
8503
8538
|
ast: AST.Transformation
|
|
8504
|
-
) => Effect.Effect<Simplify<I & Struct.Encoded<
|
|
8539
|
+
) => Effect.Effect<Simplify<I & Struct.Encoded<NewFields>>, ParseResult.ParseIssue, R2>
|
|
8505
8540
|
readonly encode: (
|
|
8506
|
-
input: Simplify<I & Struct.Encoded<
|
|
8541
|
+
input: Simplify<I & Struct.Encoded<NewFields>>,
|
|
8507
8542
|
options: ParseOptions,
|
|
8508
8543
|
ast: AST.Transformation
|
|
8509
8544
|
) => Effect.Effect<I, ParseResult.ParseIssue, R3>
|
|
8510
8545
|
},
|
|
8511
|
-
annotations?:
|
|
8546
|
+
annotations?: ClassAnnotations<Transformed, Struct.Type<Fields & NewFields>>
|
|
8512
8547
|
) => [Transformed] extends [never] ? MissingSelfGeneric<"Base.transformOrFailFrom">
|
|
8513
8548
|
: Class<
|
|
8514
8549
|
Transformed,
|
|
8515
|
-
Fields &
|
|
8550
|
+
Fields & NewFields,
|
|
8516
8551
|
I,
|
|
8517
|
-
R | Struct.Context<
|
|
8518
|
-
C & Struct.Constructor<
|
|
8552
|
+
R | Struct.Context<NewFields> | R2 | R3,
|
|
8553
|
+
C & Struct.Constructor<NewFields>,
|
|
8519
8554
|
Self,
|
|
8520
8555
|
Proto
|
|
8521
8556
|
>
|
|
@@ -8559,7 +8594,7 @@ const getFieldsFromFieldsOr = <Fields extends Struct.Fields>(fieldsOr: Fields |
|
|
|
8559
8594
|
export const Class = <Self = never>(identifier: string) =>
|
|
8560
8595
|
<Fields extends Struct.Fields>(
|
|
8561
8596
|
fieldsOr: Fields | HasFields<Fields>,
|
|
8562
|
-
annotations?:
|
|
8597
|
+
annotations?: ClassAnnotations<Self, Struct.Type<Fields>>
|
|
8563
8598
|
): [Self] extends [never] ? MissingSelfGeneric<"Class">
|
|
8564
8599
|
: Class<
|
|
8565
8600
|
Self,
|
|
@@ -8618,7 +8653,7 @@ export const TaggedClass = <Self = never>(identifier?: string) =>
|
|
|
8618
8653
|
<Tag extends string, Fields extends Struct.Fields>(
|
|
8619
8654
|
tag: Tag,
|
|
8620
8655
|
fieldsOr: Fields | HasFields<Fields>,
|
|
8621
|
-
annotations?:
|
|
8656
|
+
annotations?: ClassAnnotations<Self, Struct.Type<Fields>>
|
|
8622
8657
|
): [Self] extends [never] ? MissingSelfGeneric<"TaggedClass", `"Tag", `>
|
|
8623
8658
|
: TaggedClass<Self, Tag, { readonly _tag: tag<Tag> } & Fields> =>
|
|
8624
8659
|
{
|
|
@@ -8681,7 +8716,7 @@ export const TaggedError = <Self = never>(identifier?: string) =>
|
|
|
8681
8716
|
<Tag extends string, Fields extends Struct.Fields>(
|
|
8682
8717
|
tag: Tag,
|
|
8683
8718
|
fieldsOr: Fields | HasFields<Fields>,
|
|
8684
|
-
annotations?:
|
|
8719
|
+
annotations?: ClassAnnotations<Self, Struct.Type<Fields>>
|
|
8685
8720
|
): [Self] extends [never] ? MissingSelfGeneric<"TaggedError", `"Tag", `>
|
|
8686
8721
|
: TaggedErrorClass<
|
|
8687
8722
|
Self,
|
|
@@ -8734,23 +8769,61 @@ const getDisableValidationMakeOption = (options: MakeOptions | undefined): boole
|
|
|
8734
8769
|
|
|
8735
8770
|
const astCache = globalValue("effect/Schema/astCache", () => new WeakMap<any, AST.AST>())
|
|
8736
8771
|
|
|
8737
|
-
const
|
|
8738
|
-
|
|
8739
|
-
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
|
|
8772
|
+
const getClassAnnotations = <Self, A>(
|
|
8773
|
+
annotations: ClassAnnotations<Self, A> | undefined
|
|
8774
|
+
): [Annotations.Schema<Self>?, Annotations.Schema<Self>?, Annotations.Schema<A>?] => {
|
|
8775
|
+
if (annotations === undefined) {
|
|
8776
|
+
return []
|
|
8777
|
+
} else if (Array.isArray(annotations)) {
|
|
8778
|
+
return annotations as any
|
|
8779
|
+
} else {
|
|
8780
|
+
return [annotations] as any
|
|
8781
|
+
}
|
|
8782
|
+
}
|
|
8783
|
+
|
|
8784
|
+
const makeClass = <Fields extends Struct.Fields>(
|
|
8785
|
+
{ Base, annotations, disableToString, fields, identifier, kind, schema }: {
|
|
8786
|
+
kind: "Class" | "TaggedClass" | "TaggedError" | "TaggedRequest"
|
|
8787
|
+
identifier: string
|
|
8788
|
+
schema: Schema.Any
|
|
8789
|
+
fields: Fields
|
|
8790
|
+
Base: new(...args: ReadonlyArray<any>) => any
|
|
8791
|
+
annotations?: ClassAnnotations<any, any> | undefined
|
|
8792
|
+
disableToString?: boolean | undefined
|
|
8793
|
+
}
|
|
8794
|
+
): any => {
|
|
8746
8795
|
const classSymbol = Symbol.for(`effect/Schema/${kind}/${identifier}`)
|
|
8747
8796
|
|
|
8748
|
-
const
|
|
8749
|
-
|
|
8750
|
-
const
|
|
8751
|
-
|
|
8752
|
-
const
|
|
8753
|
-
|
|
8797
|
+
const [typeAnnotations, transformationAnnotations, encodedAnnotations] = getClassAnnotations(annotations)
|
|
8798
|
+
|
|
8799
|
+
const typeSchema_ = typeSchema(schema)
|
|
8800
|
+
|
|
8801
|
+
const declarationSurrogate = typeSchema_.annotations({
|
|
8802
|
+
identifier,
|
|
8803
|
+
...typeAnnotations
|
|
8804
|
+
})
|
|
8805
|
+
|
|
8806
|
+
const typeSide = typeSchema_.annotations({
|
|
8807
|
+
[AST.AutoTitleAnnotationId]: `${identifier} (Type side)`,
|
|
8808
|
+
...typeAnnotations
|
|
8809
|
+
})
|
|
8810
|
+
|
|
8811
|
+
const constructorSchema = schema.annotations({
|
|
8812
|
+
[AST.AutoTitleAnnotationId]: `${identifier} (Constructor)`,
|
|
8813
|
+
...typeAnnotations
|
|
8814
|
+
})
|
|
8815
|
+
|
|
8816
|
+
const encodedSide = schema.annotations({
|
|
8817
|
+
[AST.AutoTitleAnnotationId]: `${identifier} (Encoded side)`,
|
|
8818
|
+
...encodedAnnotations
|
|
8819
|
+
})
|
|
8820
|
+
|
|
8821
|
+
const transformationSurrogate = schema.annotations({
|
|
8822
|
+
[AST.JSONIdentifierAnnotationId]: identifier,
|
|
8823
|
+
...encodedAnnotations,
|
|
8824
|
+
...typeAnnotations,
|
|
8825
|
+
...transformationAnnotations
|
|
8826
|
+
})
|
|
8754
8827
|
|
|
8755
8828
|
const fallbackInstanceOf = (u: unknown) => Predicate.hasProperty(u, classSymbol) && ParseResult.is(typeSide)(u)
|
|
8756
8829
|
|
|
@@ -8765,7 +8838,7 @@ const makeClass = ({ Base, annotations, disableToString, fields, identifier, kin
|
|
|
8765
8838
|
}
|
|
8766
8839
|
props = lazilyMergeDefaults(fields, props)
|
|
8767
8840
|
if (!getDisableValidationMakeOption(options)) {
|
|
8768
|
-
props = ParseResult.validateSync(
|
|
8841
|
+
props = ParseResult.validateSync(constructorSchema)(props)
|
|
8769
8842
|
}
|
|
8770
8843
|
super(props, true)
|
|
8771
8844
|
}
|
|
@@ -8777,8 +8850,9 @@ const makeClass = ({ Base, annotations, disableToString, fields, identifier, kin
|
|
|
8777
8850
|
static [TypeId] = variance
|
|
8778
8851
|
|
|
8779
8852
|
static get ast(): AST.AST {
|
|
8780
|
-
|
|
8781
|
-
|
|
8853
|
+
let out = astCache.get(this)
|
|
8854
|
+
if (out) {
|
|
8855
|
+
return out
|
|
8782
8856
|
}
|
|
8783
8857
|
|
|
8784
8858
|
const declaration: Schema.Any = declare(
|
|
@@ -8803,20 +8877,22 @@ const makeClass = ({ Base, annotations, disableToString, fields, identifier, kin
|
|
|
8803
8877
|
arbitrary: (arb) => (fc) => arb(fc).map((props) => new this(props)),
|
|
8804
8878
|
equivalence: identity,
|
|
8805
8879
|
[AST.SurrogateAnnotationId]: declarationSurrogate.ast,
|
|
8806
|
-
...
|
|
8880
|
+
...typeAnnotations
|
|
8807
8881
|
}
|
|
8808
8882
|
)
|
|
8809
8883
|
|
|
8810
|
-
|
|
8884
|
+
out = transform(
|
|
8811
8885
|
encodedSide,
|
|
8812
8886
|
declaration,
|
|
8813
8887
|
{ strict: true, decode: (input) => new this(input, true), encode: identity }
|
|
8814
8888
|
).annotations({
|
|
8815
|
-
[AST.
|
|
8816
|
-
|
|
8817
|
-
})
|
|
8818
|
-
|
|
8819
|
-
|
|
8889
|
+
[AST.SurrogateAnnotationId]: transformationSurrogate.ast,
|
|
8890
|
+
...transformationAnnotations
|
|
8891
|
+
}).ast
|
|
8892
|
+
|
|
8893
|
+
astCache.set(this, out)
|
|
8894
|
+
|
|
8895
|
+
return out
|
|
8820
8896
|
}
|
|
8821
8897
|
|
|
8822
8898
|
static pipe() {
|
|
@@ -8843,8 +8919,11 @@ const makeClass = ({ Base, annotations, disableToString, fields, identifier, kin
|
|
|
8843
8919
|
|
|
8844
8920
|
static identifier = identifier
|
|
8845
8921
|
|
|
8846
|
-
static extend<Extended>(identifier: string) {
|
|
8847
|
-
return (
|
|
8922
|
+
static extend<Extended, NewFields extends Struct.Fields>(identifier: string) {
|
|
8923
|
+
return (
|
|
8924
|
+
newFieldsOr: NewFields | HasFields<NewFields>,
|
|
8925
|
+
annotations?: ClassAnnotations<Extended, Struct.Type<Fields & NewFields>>
|
|
8926
|
+
) => {
|
|
8848
8927
|
const newFields = getFieldsFromFieldsOr(newFieldsOr)
|
|
8849
8928
|
const newSchema = getSchemaFromFieldsOr(newFieldsOr)
|
|
8850
8929
|
const extendedFields = extendFields(fields, newFields)
|
|
@@ -8859,9 +8938,13 @@ const makeClass = ({ Base, annotations, disableToString, fields, identifier, kin
|
|
|
8859
8938
|
}
|
|
8860
8939
|
}
|
|
8861
8940
|
|
|
8862
|
-
static transformOrFail<Transformed>(identifier: string) {
|
|
8863
|
-
return (
|
|
8864
|
-
|
|
8941
|
+
static transformOrFail<Transformed, NewFields extends Struct.Fields>(identifier: string) {
|
|
8942
|
+
return (
|
|
8943
|
+
newFieldsOr: NewFields,
|
|
8944
|
+
options: any,
|
|
8945
|
+
annotations?: ClassAnnotations<Transformed, Struct.Type<Fields & NewFields>>
|
|
8946
|
+
) => {
|
|
8947
|
+
const transformedFields: Struct.Fields = extendFields(fields, newFieldsOr)
|
|
8865
8948
|
return makeClass({
|
|
8866
8949
|
kind,
|
|
8867
8950
|
identifier,
|
|
@@ -8877,8 +8960,12 @@ const makeClass = ({ Base, annotations, disableToString, fields, identifier, kin
|
|
|
8877
8960
|
}
|
|
8878
8961
|
}
|
|
8879
8962
|
|
|
8880
|
-
static transformOrFailFrom<Transformed>(identifier: string) {
|
|
8881
|
-
return (
|
|
8963
|
+
static transformOrFailFrom<Transformed, NewFields extends Struct.Fields>(identifier: string) {
|
|
8964
|
+
return (
|
|
8965
|
+
newFields: NewFields,
|
|
8966
|
+
options: any,
|
|
8967
|
+
annotations?: ClassAnnotations<Transformed, Struct.Type<Fields & NewFields>>
|
|
8968
|
+
) => {
|
|
8882
8969
|
const transformedFields: Struct.Fields = extendFields(fields, newFields)
|
|
8883
8970
|
return makeClass({
|
|
8884
8971
|
kind,
|
|
@@ -2,85 +2,100 @@ import type * as Schema from "../../Schema.js"
|
|
|
2
2
|
|
|
3
3
|
/** @internal */
|
|
4
4
|
export const GreaterThanSchemaId: Schema.GreaterThanSchemaId = Symbol.for(
|
|
5
|
-
"effect/
|
|
5
|
+
"effect/SchemaId/GreaterThan"
|
|
6
6
|
) as Schema.GreaterThanSchemaId
|
|
7
7
|
|
|
8
8
|
/** @internal */
|
|
9
9
|
export const GreaterThanOrEqualToSchemaId: Schema.GreaterThanOrEqualToSchemaId = Symbol.for(
|
|
10
|
-
"effect/
|
|
10
|
+
"effect/SchemaId/GreaterThanOrEqualTo"
|
|
11
11
|
) as Schema.GreaterThanOrEqualToSchemaId
|
|
12
12
|
|
|
13
13
|
/** @internal */
|
|
14
14
|
export const LessThanSchemaId: Schema.LessThanSchemaId = Symbol.for(
|
|
15
|
-
"effect/
|
|
15
|
+
"effect/SchemaId/LessThan"
|
|
16
16
|
) as Schema.LessThanSchemaId
|
|
17
17
|
|
|
18
18
|
/** @internal */
|
|
19
19
|
export const LessThanOrEqualToSchemaId: Schema.LessThanOrEqualToSchemaId = Symbol.for(
|
|
20
|
-
"effect/
|
|
20
|
+
"effect/SchemaId/LessThanOrEqualTo"
|
|
21
21
|
) as Schema.LessThanOrEqualToSchemaId
|
|
22
22
|
|
|
23
23
|
/** @internal */
|
|
24
24
|
export const IntSchemaId: Schema.IntSchemaId = Symbol.for(
|
|
25
|
-
"effect/
|
|
25
|
+
"effect/SchemaId/Int"
|
|
26
26
|
) as Schema.IntSchemaId
|
|
27
27
|
|
|
28
|
+
/** @internal */
|
|
29
|
+
export const NonNaNSchemaId: Schema.NonNaNSchemaId = Symbol.for(
|
|
30
|
+
"effect/SchemaId/NonNaN"
|
|
31
|
+
) as Schema.NonNaNSchemaId
|
|
32
|
+
|
|
33
|
+
/** @internal */
|
|
34
|
+
export const FiniteSchemaId: Schema.FiniteSchemaId = Symbol.for(
|
|
35
|
+
"effect/SchemaId/Finite"
|
|
36
|
+
) as Schema.FiniteSchemaId
|
|
37
|
+
|
|
38
|
+
/** @internal */
|
|
39
|
+
export const JsonNumberSchemaId: Schema.JsonNumberSchemaId = Symbol.for(
|
|
40
|
+
"effect/SchemaId/JsonNumber"
|
|
41
|
+
) as Schema.JsonNumberSchemaId
|
|
42
|
+
|
|
28
43
|
/** @internal */
|
|
29
44
|
export const BetweenSchemaId: Schema.BetweenSchemaId = Symbol.for(
|
|
30
|
-
"effect/
|
|
45
|
+
"effect/SchemaId/Between"
|
|
31
46
|
) as Schema.BetweenSchemaId
|
|
32
47
|
|
|
33
48
|
/** @internal */
|
|
34
49
|
export const GreaterThanBigintSchemaId: Schema.GreaterThanBigIntSchemaId = Symbol.for(
|
|
35
|
-
"effect/
|
|
50
|
+
"effect/SchemaId/GreaterThanBigint"
|
|
36
51
|
) as Schema.GreaterThanBigIntSchemaId
|
|
37
52
|
|
|
38
53
|
/** @internal */
|
|
39
54
|
export const GreaterThanOrEqualToBigIntSchemaId: Schema.GreaterThanOrEqualToBigIntSchemaId = Symbol.for(
|
|
40
|
-
"effect/
|
|
55
|
+
"effect/SchemaId/GreaterThanOrEqualToBigint"
|
|
41
56
|
) as Schema.GreaterThanOrEqualToBigIntSchemaId
|
|
42
57
|
|
|
43
58
|
/** @internal */
|
|
44
59
|
export const LessThanBigIntSchemaId: Schema.LessThanBigIntSchemaId = Symbol.for(
|
|
45
|
-
"effect/
|
|
60
|
+
"effect/SchemaId/LessThanBigint"
|
|
46
61
|
) as Schema.LessThanBigIntSchemaId
|
|
47
62
|
|
|
48
63
|
/** @internal */
|
|
49
64
|
export const LessThanOrEqualToBigIntSchemaId: Schema.LessThanOrEqualToBigIntSchemaId = Symbol.for(
|
|
50
|
-
"effect/
|
|
65
|
+
"effect/SchemaId/LessThanOrEqualToBigint"
|
|
51
66
|
) as Schema.LessThanOrEqualToBigIntSchemaId
|
|
52
67
|
|
|
53
68
|
/** @internal */
|
|
54
69
|
export const BetweenBigintSchemaId: Schema.BetweenBigIntSchemaId = Symbol.for(
|
|
55
|
-
"effect/
|
|
70
|
+
"effect/SchemaId/BetweenBigint"
|
|
56
71
|
) as Schema.BetweenBigIntSchemaId
|
|
57
72
|
|
|
58
73
|
/** @internal */
|
|
59
74
|
export const MinLengthSchemaId: Schema.MinLengthSchemaId = Symbol.for(
|
|
60
|
-
"effect/
|
|
75
|
+
"effect/SchemaId/MinLength"
|
|
61
76
|
) as Schema.MinLengthSchemaId
|
|
62
77
|
|
|
63
78
|
/** @internal */
|
|
64
79
|
export const MaxLengthSchemaId: Schema.MaxLengthSchemaId = Symbol.for(
|
|
65
|
-
"effect/
|
|
80
|
+
"effect/SchemaId/MaxLength"
|
|
66
81
|
) as Schema.MaxLengthSchemaId
|
|
67
82
|
|
|
68
83
|
/** @internal */
|
|
69
84
|
export const LengthSchemaId: Schema.LengthSchemaId = Symbol.for(
|
|
70
|
-
"effect/
|
|
85
|
+
"effect/SchemaId/Length"
|
|
71
86
|
) as Schema.LengthSchemaId
|
|
72
87
|
|
|
73
88
|
/** @internal */
|
|
74
89
|
export const MinItemsSchemaId: Schema.MinItemsSchemaId = Symbol.for(
|
|
75
|
-
"effect/
|
|
90
|
+
"effect/SchemaId/MinItems"
|
|
76
91
|
) as Schema.MinItemsSchemaId
|
|
77
92
|
|
|
78
93
|
/** @internal */
|
|
79
94
|
export const MaxItemsSchemaId: Schema.MaxItemsSchemaId = Symbol.for(
|
|
80
|
-
"effect/
|
|
95
|
+
"effect/SchemaId/MaxItems"
|
|
81
96
|
) as Schema.MaxItemsSchemaId
|
|
82
97
|
|
|
83
98
|
/** @internal */
|
|
84
99
|
export const ItemsCountSchemaId: Schema.ItemsCountSchemaId = Symbol.for(
|
|
85
|
-
"effect/
|
|
100
|
+
"effect/SchemaId/ItemsCount"
|
|
86
101
|
) as Schema.ItemsCountSchemaId
|
package/src/internal/version.ts
CHANGED