@arrirpc/schema 0.78.0 → 0.79.0
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/README.md +57 -1
- package/dist/adapters.d.cts +2 -2
- package/dist/adapters.d.mts +2 -2
- package/dist/adapters.d.ts +2 -2
- package/dist/index.cjs +111 -90
- package/dist/index.d.cts +22 -9
- package/dist/index.d.mts +22 -9
- package/dist/index.d.ts +22 -9
- package/dist/index.mjs +111 -91
- package/dist/shared/{schema.hMebmI3A.d.cts → schema.CS4qvHhE.d.cts} +21 -14
- package/dist/shared/{schema.hMebmI3A.d.mts → schema.CS4qvHhE.d.mts} +21 -14
- package/dist/shared/{schema.hMebmI3A.d.ts → schema.CS4qvHhE.d.ts} +21 -14
- package/package.json +7 -6
|
@@ -52,9 +52,9 @@ interface ValidationContext {
|
|
|
52
52
|
}
|
|
53
53
|
declare function newValidationContext(exitOnFirstError?: boolean, maxDepth?: number): ValidationContext;
|
|
54
54
|
declare const VALIDATOR_KEY: " Symbol.for(arri/schema/validator/v1)";
|
|
55
|
-
interface SchemaValidator<T> {
|
|
55
|
+
interface SchemaValidator<T, TOptional extends boolean = false> {
|
|
56
56
|
output: T;
|
|
57
|
-
optional
|
|
57
|
+
optional: TOptional;
|
|
58
58
|
validate: (input: unknown) => input is T;
|
|
59
59
|
parse: (input: unknown, context: ValidationContext) => T | undefined;
|
|
60
60
|
coerce: (input: unknown, context: ValidationContext) => T | undefined;
|
|
@@ -67,14 +67,14 @@ interface SchemaMetadata {
|
|
|
67
67
|
isDeprecated?: boolean;
|
|
68
68
|
}
|
|
69
69
|
type WithAdapters<T = any> = StandardSchemaV1<T>;
|
|
70
|
-
interface ASchema<T = any> {
|
|
70
|
+
interface ASchema<T = any, TOptional extends boolean = false> {
|
|
71
71
|
metadata?: SchemaMetadata;
|
|
72
|
-
|
|
73
|
-
[VALIDATOR_KEY]: SchemaValidator<T>;
|
|
72
|
+
isNullable?: boolean;
|
|
73
|
+
[VALIDATOR_KEY]: SchemaValidator<T, TOptional>;
|
|
74
74
|
}
|
|
75
75
|
type ASchemaStrict<TSchema extends ASchema> = Omit<TSchema, typeof VALIDATOR_KEY>;
|
|
76
76
|
declare function isASchema(input: unknown): input is ASchema;
|
|
77
|
-
type ASchemaWithAdapters<T = any> = ASchema<T> & WithAdapters<T>;
|
|
77
|
+
type ASchemaWithAdapters<T = any, TOptional extends boolean = false> = ASchema<T, TOptional> & WithAdapters<T>;
|
|
78
78
|
interface ASchemaOptions {
|
|
79
79
|
id?: string;
|
|
80
80
|
description?: string;
|
|
@@ -148,20 +148,27 @@ type ARecordSchemaWithAdapters<TInnerSchema extends ASchema<any>> = ARecordSchem
|
|
|
148
148
|
interface AObjectSchema<TVal = any, TStrict extends boolean = false> extends ASchema<TVal> {
|
|
149
149
|
properties: Record<string, ASchema>;
|
|
150
150
|
optionalProperties?: Record<string, ASchema>;
|
|
151
|
-
|
|
151
|
+
isStrict?: TStrict;
|
|
152
152
|
}
|
|
153
153
|
declare function isAObjectSchema(input: unknown): input is AObjectSchema;
|
|
154
154
|
type AObjectSchemaWithAdapters<T = any, TStrict extends boolean = false> = AObjectSchema<T, TStrict> & WithAdapters<T>;
|
|
155
155
|
interface AObjectSchemaOptions<TAdditionalProps extends boolean = false> extends ASchemaOptions {
|
|
156
156
|
/**
|
|
157
|
-
*
|
|
157
|
+
* @deprecated use "isStrict" instead
|
|
158
158
|
*/
|
|
159
159
|
strict?: TAdditionalProps;
|
|
160
|
+
/**
|
|
161
|
+
* Allow this object to include additional properties not specified here
|
|
162
|
+
*/
|
|
163
|
+
isStrict?: TAdditionalProps;
|
|
160
164
|
}
|
|
161
|
-
type InferObjectOutput<TInput = any> = ResolveObject<InferObjectRawType<TInput
|
|
162
|
-
type
|
|
163
|
-
[
|
|
164
|
-
}
|
|
165
|
+
type InferObjectOutput<TInput extends Record<any, ASchema<any, any>> = any> = ResolveObject<PartialBy<InferObjectRawType<TInput>, InferObjectOptionalKeys<TInput>>>;
|
|
166
|
+
type InferObjectOptionalKeys<TInput extends Record<any, ASchema<any, any>>> = {
|
|
167
|
+
[K in keyof TInput]: TInput[K][typeof VALIDATOR_KEY]['optional'] extends true ? K : never;
|
|
168
|
+
}[keyof TInput];
|
|
169
|
+
type InferObjectRawType<TInput extends Record<any, ASchema<any, any>>> = {
|
|
170
|
+
[TKey in keyof TInput]: TInput[TKey][typeof VALIDATOR_KEY]['output'];
|
|
171
|
+
};
|
|
165
172
|
declare function isObject(input: unknown): input is Record<any, any>;
|
|
166
173
|
interface ARefSchema<T> extends ASchema<T> {
|
|
167
174
|
ref: string;
|
|
@@ -169,5 +176,5 @@ interface ARefSchema<T> extends ASchema<T> {
|
|
|
169
176
|
declare function isARefSchema(input: unknown): input is ARefSchema<any>;
|
|
170
177
|
type ARefSchemaWithAdapters<T> = ARefSchema<T> & WithAdapters<T>;
|
|
171
178
|
|
|
172
|
-
export { isAScalarSchema as D, isAAraySchema as F, isAStringEnumSchema as J, isADiscriminatorSchema as L, NumberTypeValues as N, isARecordSchema as Q, isAObjectSchema as T,
|
|
173
|
-
export type { ASchema as A, Resolve as B, AScalarSchema as C, NumberType as E, AArraySchemaWithAdapters as G, AStringEnumSchema as H, InferType as I, ADiscriminatorSchema as K, MaybeNullable as M, ARecordSchema as O, PartialBy as P, Result as R, SchemaValidator as S,
|
|
179
|
+
export { isAScalarSchema as D, isAAraySchema as F, isAStringEnumSchema as J, isADiscriminatorSchema as L, NumberTypeValues as N, isARecordSchema as Q, isAObjectSchema as T, VALIDATOR_KEY as V, isObject as Y, isARefSchema as Z, isValueError as r, errorMessageFromErrors as s, ValidationException as t, isValidationException as u, newValidationContext as x, isASchema as z };
|
|
180
|
+
export type { ASchema as A, Resolve as B, AScalarSchema as C, NumberType as E, AArraySchemaWithAdapters as G, AStringEnumSchema as H, InferType as I, ADiscriminatorSchema as K, MaybeNullable as M, ARecordSchema as O, PartialBy as P, Result as R, SchemaValidator as S, InferObjectOptionalKeys as U, WithAdapters as W, InferObjectRawType as X, ARefSchemaWithAdapters as _, ASchemaStrict as a, ASchemaOptions as b, ASchemaWithAdapters as c, AArraySchema as d, AScalarSchemaWithAdapters as e, AObjectSchema as f, ADiscriminatorSchemaWithAdapters as g, ResolveObject as h, AStringEnumSchemaWithAdapters as i, AObjectSchemaWithAdapters as j, AObjectSchemaOptions as k, InferObjectOutput as l, ValidationContext as m, ARecordSchemaWithAdapters as n, ARefSchema as o, ValueError as p, InferSubType as q, ResultSuccess as v, ResultFailure as w, SchemaMetadata as y };
|
|
@@ -52,9 +52,9 @@ interface ValidationContext {
|
|
|
52
52
|
}
|
|
53
53
|
declare function newValidationContext(exitOnFirstError?: boolean, maxDepth?: number): ValidationContext;
|
|
54
54
|
declare const VALIDATOR_KEY: " Symbol.for(arri/schema/validator/v1)";
|
|
55
|
-
interface SchemaValidator<T> {
|
|
55
|
+
interface SchemaValidator<T, TOptional extends boolean = false> {
|
|
56
56
|
output: T;
|
|
57
|
-
optional
|
|
57
|
+
optional: TOptional;
|
|
58
58
|
validate: (input: unknown) => input is T;
|
|
59
59
|
parse: (input: unknown, context: ValidationContext) => T | undefined;
|
|
60
60
|
coerce: (input: unknown, context: ValidationContext) => T | undefined;
|
|
@@ -67,14 +67,14 @@ interface SchemaMetadata {
|
|
|
67
67
|
isDeprecated?: boolean;
|
|
68
68
|
}
|
|
69
69
|
type WithAdapters<T = any> = StandardSchemaV1<T>;
|
|
70
|
-
interface ASchema<T = any> {
|
|
70
|
+
interface ASchema<T = any, TOptional extends boolean = false> {
|
|
71
71
|
metadata?: SchemaMetadata;
|
|
72
|
-
|
|
73
|
-
[VALIDATOR_KEY]: SchemaValidator<T>;
|
|
72
|
+
isNullable?: boolean;
|
|
73
|
+
[VALIDATOR_KEY]: SchemaValidator<T, TOptional>;
|
|
74
74
|
}
|
|
75
75
|
type ASchemaStrict<TSchema extends ASchema> = Omit<TSchema, typeof VALIDATOR_KEY>;
|
|
76
76
|
declare function isASchema(input: unknown): input is ASchema;
|
|
77
|
-
type ASchemaWithAdapters<T = any> = ASchema<T> & WithAdapters<T>;
|
|
77
|
+
type ASchemaWithAdapters<T = any, TOptional extends boolean = false> = ASchema<T, TOptional> & WithAdapters<T>;
|
|
78
78
|
interface ASchemaOptions {
|
|
79
79
|
id?: string;
|
|
80
80
|
description?: string;
|
|
@@ -148,20 +148,27 @@ type ARecordSchemaWithAdapters<TInnerSchema extends ASchema<any>> = ARecordSchem
|
|
|
148
148
|
interface AObjectSchema<TVal = any, TStrict extends boolean = false> extends ASchema<TVal> {
|
|
149
149
|
properties: Record<string, ASchema>;
|
|
150
150
|
optionalProperties?: Record<string, ASchema>;
|
|
151
|
-
|
|
151
|
+
isStrict?: TStrict;
|
|
152
152
|
}
|
|
153
153
|
declare function isAObjectSchema(input: unknown): input is AObjectSchema;
|
|
154
154
|
type AObjectSchemaWithAdapters<T = any, TStrict extends boolean = false> = AObjectSchema<T, TStrict> & WithAdapters<T>;
|
|
155
155
|
interface AObjectSchemaOptions<TAdditionalProps extends boolean = false> extends ASchemaOptions {
|
|
156
156
|
/**
|
|
157
|
-
*
|
|
157
|
+
* @deprecated use "isStrict" instead
|
|
158
158
|
*/
|
|
159
159
|
strict?: TAdditionalProps;
|
|
160
|
+
/**
|
|
161
|
+
* Allow this object to include additional properties not specified here
|
|
162
|
+
*/
|
|
163
|
+
isStrict?: TAdditionalProps;
|
|
160
164
|
}
|
|
161
|
-
type InferObjectOutput<TInput = any> = ResolveObject<InferObjectRawType<TInput
|
|
162
|
-
type
|
|
163
|
-
[
|
|
164
|
-
}
|
|
165
|
+
type InferObjectOutput<TInput extends Record<any, ASchema<any, any>> = any> = ResolveObject<PartialBy<InferObjectRawType<TInput>, InferObjectOptionalKeys<TInput>>>;
|
|
166
|
+
type InferObjectOptionalKeys<TInput extends Record<any, ASchema<any, any>>> = {
|
|
167
|
+
[K in keyof TInput]: TInput[K][typeof VALIDATOR_KEY]['optional'] extends true ? K : never;
|
|
168
|
+
}[keyof TInput];
|
|
169
|
+
type InferObjectRawType<TInput extends Record<any, ASchema<any, any>>> = {
|
|
170
|
+
[TKey in keyof TInput]: TInput[TKey][typeof VALIDATOR_KEY]['output'];
|
|
171
|
+
};
|
|
165
172
|
declare function isObject(input: unknown): input is Record<any, any>;
|
|
166
173
|
interface ARefSchema<T> extends ASchema<T> {
|
|
167
174
|
ref: string;
|
|
@@ -169,5 +176,5 @@ interface ARefSchema<T> extends ASchema<T> {
|
|
|
169
176
|
declare function isARefSchema(input: unknown): input is ARefSchema<any>;
|
|
170
177
|
type ARefSchemaWithAdapters<T> = ARefSchema<T> & WithAdapters<T>;
|
|
171
178
|
|
|
172
|
-
export { isAScalarSchema as D, isAAraySchema as F, isAStringEnumSchema as J, isADiscriminatorSchema as L, NumberTypeValues as N, isARecordSchema as Q, isAObjectSchema as T,
|
|
173
|
-
export type { ASchema as A, Resolve as B, AScalarSchema as C, NumberType as E, AArraySchemaWithAdapters as G, AStringEnumSchema as H, InferType as I, ADiscriminatorSchema as K, MaybeNullable as M, ARecordSchema as O, PartialBy as P, Result as R, SchemaValidator as S,
|
|
179
|
+
export { isAScalarSchema as D, isAAraySchema as F, isAStringEnumSchema as J, isADiscriminatorSchema as L, NumberTypeValues as N, isARecordSchema as Q, isAObjectSchema as T, VALIDATOR_KEY as V, isObject as Y, isARefSchema as Z, isValueError as r, errorMessageFromErrors as s, ValidationException as t, isValidationException as u, newValidationContext as x, isASchema as z };
|
|
180
|
+
export type { ASchema as A, Resolve as B, AScalarSchema as C, NumberType as E, AArraySchemaWithAdapters as G, AStringEnumSchema as H, InferType as I, ADiscriminatorSchema as K, MaybeNullable as M, ARecordSchema as O, PartialBy as P, Result as R, SchemaValidator as S, InferObjectOptionalKeys as U, WithAdapters as W, InferObjectRawType as X, ARefSchemaWithAdapters as _, ASchemaStrict as a, ASchemaOptions as b, ASchemaWithAdapters as c, AArraySchema as d, AScalarSchemaWithAdapters as e, AObjectSchema as f, ADiscriminatorSchemaWithAdapters as g, ResolveObject as h, AStringEnumSchemaWithAdapters as i, AObjectSchemaWithAdapters as j, AObjectSchemaOptions as k, InferObjectOutput as l, ValidationContext as m, ARecordSchemaWithAdapters as n, ARefSchema as o, ValueError as p, InferSubType as q, ResultSuccess as v, ResultFailure as w, SchemaMetadata as y };
|
|
@@ -52,9 +52,9 @@ interface ValidationContext {
|
|
|
52
52
|
}
|
|
53
53
|
declare function newValidationContext(exitOnFirstError?: boolean, maxDepth?: number): ValidationContext;
|
|
54
54
|
declare const VALIDATOR_KEY: " Symbol.for(arri/schema/validator/v1)";
|
|
55
|
-
interface SchemaValidator<T> {
|
|
55
|
+
interface SchemaValidator<T, TOptional extends boolean = false> {
|
|
56
56
|
output: T;
|
|
57
|
-
optional
|
|
57
|
+
optional: TOptional;
|
|
58
58
|
validate: (input: unknown) => input is T;
|
|
59
59
|
parse: (input: unknown, context: ValidationContext) => T | undefined;
|
|
60
60
|
coerce: (input: unknown, context: ValidationContext) => T | undefined;
|
|
@@ -67,14 +67,14 @@ interface SchemaMetadata {
|
|
|
67
67
|
isDeprecated?: boolean;
|
|
68
68
|
}
|
|
69
69
|
type WithAdapters<T = any> = StandardSchemaV1<T>;
|
|
70
|
-
interface ASchema<T = any> {
|
|
70
|
+
interface ASchema<T = any, TOptional extends boolean = false> {
|
|
71
71
|
metadata?: SchemaMetadata;
|
|
72
|
-
|
|
73
|
-
[VALIDATOR_KEY]: SchemaValidator<T>;
|
|
72
|
+
isNullable?: boolean;
|
|
73
|
+
[VALIDATOR_KEY]: SchemaValidator<T, TOptional>;
|
|
74
74
|
}
|
|
75
75
|
type ASchemaStrict<TSchema extends ASchema> = Omit<TSchema, typeof VALIDATOR_KEY>;
|
|
76
76
|
declare function isASchema(input: unknown): input is ASchema;
|
|
77
|
-
type ASchemaWithAdapters<T = any> = ASchema<T> & WithAdapters<T>;
|
|
77
|
+
type ASchemaWithAdapters<T = any, TOptional extends boolean = false> = ASchema<T, TOptional> & WithAdapters<T>;
|
|
78
78
|
interface ASchemaOptions {
|
|
79
79
|
id?: string;
|
|
80
80
|
description?: string;
|
|
@@ -148,20 +148,27 @@ type ARecordSchemaWithAdapters<TInnerSchema extends ASchema<any>> = ARecordSchem
|
|
|
148
148
|
interface AObjectSchema<TVal = any, TStrict extends boolean = false> extends ASchema<TVal> {
|
|
149
149
|
properties: Record<string, ASchema>;
|
|
150
150
|
optionalProperties?: Record<string, ASchema>;
|
|
151
|
-
|
|
151
|
+
isStrict?: TStrict;
|
|
152
152
|
}
|
|
153
153
|
declare function isAObjectSchema(input: unknown): input is AObjectSchema;
|
|
154
154
|
type AObjectSchemaWithAdapters<T = any, TStrict extends boolean = false> = AObjectSchema<T, TStrict> & WithAdapters<T>;
|
|
155
155
|
interface AObjectSchemaOptions<TAdditionalProps extends boolean = false> extends ASchemaOptions {
|
|
156
156
|
/**
|
|
157
|
-
*
|
|
157
|
+
* @deprecated use "isStrict" instead
|
|
158
158
|
*/
|
|
159
159
|
strict?: TAdditionalProps;
|
|
160
|
+
/**
|
|
161
|
+
* Allow this object to include additional properties not specified here
|
|
162
|
+
*/
|
|
163
|
+
isStrict?: TAdditionalProps;
|
|
160
164
|
}
|
|
161
|
-
type InferObjectOutput<TInput = any> = ResolveObject<InferObjectRawType<TInput
|
|
162
|
-
type
|
|
163
|
-
[
|
|
164
|
-
}
|
|
165
|
+
type InferObjectOutput<TInput extends Record<any, ASchema<any, any>> = any> = ResolveObject<PartialBy<InferObjectRawType<TInput>, InferObjectOptionalKeys<TInput>>>;
|
|
166
|
+
type InferObjectOptionalKeys<TInput extends Record<any, ASchema<any, any>>> = {
|
|
167
|
+
[K in keyof TInput]: TInput[K][typeof VALIDATOR_KEY]['optional'] extends true ? K : never;
|
|
168
|
+
}[keyof TInput];
|
|
169
|
+
type InferObjectRawType<TInput extends Record<any, ASchema<any, any>>> = {
|
|
170
|
+
[TKey in keyof TInput]: TInput[TKey][typeof VALIDATOR_KEY]['output'];
|
|
171
|
+
};
|
|
165
172
|
declare function isObject(input: unknown): input is Record<any, any>;
|
|
166
173
|
interface ARefSchema<T> extends ASchema<T> {
|
|
167
174
|
ref: string;
|
|
@@ -169,5 +176,5 @@ interface ARefSchema<T> extends ASchema<T> {
|
|
|
169
176
|
declare function isARefSchema(input: unknown): input is ARefSchema<any>;
|
|
170
177
|
type ARefSchemaWithAdapters<T> = ARefSchema<T> & WithAdapters<T>;
|
|
171
178
|
|
|
172
|
-
export { isAScalarSchema as D, isAAraySchema as F, isAStringEnumSchema as J, isADiscriminatorSchema as L, NumberTypeValues as N, isARecordSchema as Q, isAObjectSchema as T,
|
|
173
|
-
export type { ASchema as A, Resolve as B, AScalarSchema as C, NumberType as E, AArraySchemaWithAdapters as G, AStringEnumSchema as H, InferType as I, ADiscriminatorSchema as K, MaybeNullable as M, ARecordSchema as O, PartialBy as P, Result as R, SchemaValidator as S,
|
|
179
|
+
export { isAScalarSchema as D, isAAraySchema as F, isAStringEnumSchema as J, isADiscriminatorSchema as L, NumberTypeValues as N, isARecordSchema as Q, isAObjectSchema as T, VALIDATOR_KEY as V, isObject as Y, isARefSchema as Z, isValueError as r, errorMessageFromErrors as s, ValidationException as t, isValidationException as u, newValidationContext as x, isASchema as z };
|
|
180
|
+
export type { ASchema as A, Resolve as B, AScalarSchema as C, NumberType as E, AArraySchemaWithAdapters as G, AStringEnumSchema as H, InferType as I, ADiscriminatorSchema as K, MaybeNullable as M, ARecordSchema as O, PartialBy as P, Result as R, SchemaValidator as S, InferObjectOptionalKeys as U, WithAdapters as W, InferObjectRawType as X, ARefSchemaWithAdapters as _, ASchemaStrict as a, ASchemaOptions as b, ASchemaWithAdapters as c, AArraySchema as d, AScalarSchemaWithAdapters as e, AObjectSchema as f, ADiscriminatorSchemaWithAdapters as g, ResolveObject as h, AStringEnumSchemaWithAdapters as i, AObjectSchemaWithAdapters as j, AObjectSchemaOptions as k, InferObjectOutput as l, ValidationContext as m, ARecordSchemaWithAdapters as n, ARefSchema as o, ValueError as p, InferSubType as q, ResultSuccess as v, ResultFailure as w, SchemaMetadata as y };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arrirpc/schema",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.79.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -25,15 +25,16 @@
|
|
|
25
25
|
"@standard-schema/spec": "1.0.0",
|
|
26
26
|
"scule": "^1.3.0",
|
|
27
27
|
"uncrypto": "^0.1.3",
|
|
28
|
-
"@arrirpc/type-defs": "0.
|
|
28
|
+
"@arrirpc/type-defs": "0.79.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@ryoppippi/unplugin-typia": "^2.
|
|
32
|
-
"@
|
|
31
|
+
"@ryoppippi/unplugin-typia": "^2.2.0",
|
|
32
|
+
"@samchon/openapi": "^4.0.0",
|
|
33
|
+
"@sinclair/typebox": "^0.34.33",
|
|
33
34
|
"ajv": "^8.17.1",
|
|
34
|
-
"arktype": "^2.1.
|
|
35
|
+
"arktype": "^2.1.19",
|
|
35
36
|
"benny": "^3.7.1",
|
|
36
|
-
"typia": "^
|
|
37
|
+
"typia": "^9.1.1",
|
|
37
38
|
"valibot": "1.0.0",
|
|
38
39
|
"zod": "^3.24.2"
|
|
39
40
|
}
|