@arrirpc/schema 0.45.4 → 0.45.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -22,6 +22,7 @@ To represent the data-models in a language agnostic way this library heavily rel
22
22
 
23
23
  - [Installation](#installation)
24
24
  - [Basic Example](#basic-example)
25
+ - [Usage With @arrirpc/server](#usage-with-@arrirpc/server)
25
26
  - [Supported Types](#supported-types)
26
27
  - [Primitives](#primitives)
27
28
  - [Enums](#enums)
@@ -86,6 +87,30 @@ a.validate(User, { id: "1", name: null });
86
87
  a.serialize(User, { id: "1", name: "John Doe" });
87
88
  ```
88
89
 
90
+ ## Usage With @arrirpc/server
91
+
92
+ See [here](/languages/ts/ts-server/README.md) for full details.
93
+
94
+ ```ts
95
+ import { a } from "@arrirpc/schema";
96
+ import { defineRpc } from "@arrirpc/server";
97
+
98
+ export default defineRpc({
99
+ params: a.object({
100
+ name: a.string(),
101
+ }),
102
+ response: a.object({
103
+ message: a.string(),
104
+ }),
105
+ handler({ params }) {
106
+ // can now access params.name here
107
+ return {
108
+ message: `Hello ${params.name}`,
109
+ };
110
+ },
111
+ });
112
+ ```
113
+
89
114
  ## Supported Types
90
115
 
91
116
  ### Primitives
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- const timestamp = require('./shared/schema.34cb5fb7.cjs');
4
3
  const jtdUtils = require('jtd-utils');
5
4
  const scule = require('scule');
5
+ const timestamp = require('./shared/schema.4c9064ee.cjs');
6
6
 
7
7
  function createParsingTemplate(input, schema) {
8
8
  const fallbackTemplate = `
package/dist/index.d.cts CHANGED
@@ -1,7 +1,50 @@
1
- import { A as ASchemaOptions, a as ASchema, b as AArraySchema, c as AScalarSchema, d as AObjectSchema, e as ADiscriminatorSchema, I as InferType, R as ResolveObject, f as AStringEnumSchema, g as AObjectSchemaOptions, h as InferObjectOutput, V as ValidationData, i as ARecordSchema, j as ARefSchema, S as SafeResult, k as coerce, l as errors, m as InferSubType, p as parse, s as safeCoerce, n as safeParse, o as serialize, v as validate, q as SchemaValidator, r as SchemaMetadata, t as SCHEMA_METADATA } from './shared/schema.b7c77149.cjs';
2
- export { K as InferObjectRawType, M as MaybeNullable, D as NumberType, N as NumberTypeValues, P as PartialBy, B as Resolve, x as ValidationError, w as ValueError, E as isAAraySchema, G as isADiscriminatorSchema, J as isAObjectSchema, H as isARecordSchema, O as isARefSchema, C as isAScalarSchema, z as isASchema, F as isAStringEnumSchema, L as isObject, y as isValidationError, u as sanitizeJson } from './shared/schema.b7c77149.cjs';
1
+ import { A as ASchema, I as InferType, S as SafeResult, a as ASchemaOptions, b as AArraySchema, c as AScalarSchema, d as AObjectSchema, e as ADiscriminatorSchema, R as ResolveObject, f as AStringEnumSchema, g as AObjectSchemaOptions, h as InferObjectOutput, V as ValidationData, i as ARecordSchema, j as ARefSchema, k as coerce, l as errors, m as InferSubType, p as parse, s as safeCoerce, n as safeParse, o as serialize, v as validate, q as SchemaValidator, r as SchemaMetadata, t as SCHEMA_METADATA } from './shared/schema.7414d46a.cjs';
2
+ export { K as InferObjectRawType, M as MaybeNullable, D as NumberType, N as NumberTypeValues, P as PartialBy, B as Resolve, x as ValidationError, w as ValueError, E as isAAraySchema, G as isADiscriminatorSchema, J as isAObjectSchema, H as isARecordSchema, O as isARefSchema, C as isAScalarSchema, z as isASchema, F as isAStringEnumSchema, L as isObject, y as isValidationError, u as sanitizeJson } from './shared/schema.7414d46a.cjs';
3
3
  import { Schema } from 'jtd-utils';
4
4
 
5
+ declare function createParsingTemplate(input: string, schema: Schema): string;
6
+
7
+ declare function createSerializationV2Template(inputName: string, schema: Schema): string;
8
+
9
+ declare function createValidationTemplate(inputName: string, schema: ASchema<any>): string;
10
+
11
+ interface CompiledValidator<TSchema extends ASchema<any>> {
12
+ /**
13
+ * Determine if a type matches a schema. This is a type guard.
14
+ */
15
+ validate: (input: unknown) => input is InferType<TSchema>;
16
+ /**
17
+ * Parse a JSON string or the result of JSON.parse(). Throws an error if parsing fails.
18
+ */
19
+ parse: (input: unknown) => InferType<TSchema>;
20
+ /**
21
+ * Parse a JSON string or the result of JSON.parse() without throwing an error
22
+ */
23
+ safeParse: (input: unknown) => SafeResult<InferType<TSchema>>;
24
+ /**
25
+ * Serialize to JSON
26
+ */
27
+ serialize: (input: InferType<TSchema>) => string;
28
+ compiledCode: {
29
+ serialize: string;
30
+ parse: string;
31
+ validate: string;
32
+ };
33
+ }
34
+ /**
35
+ * Create compiled versions of the `parse()`, `validate()`, and `serialize()` functions
36
+ */
37
+ declare function compile<TSchema extends ASchema<any>>(schema: TSchema): CompiledValidator<TSchema>;
38
+ type CompiledParser<TSchema extends ASchema<any>> = CompiledValidator<TSchema>["parse"];
39
+ declare function getCompiledParser<TSchema extends ASchema<any>>(input: string, schema: TSchema): {
40
+ fn: CompiledParser<TSchema>;
41
+ code: string;
42
+ };
43
+ declare function getCompiledSerializer<TSchema extends ASchema>(schema: TSchema): {
44
+ fn: (input: InferType<TSchema>) => string;
45
+ code: string;
46
+ };
47
+
5
48
  /**
6
49
  * Create a schema that accepts anything
7
50
  */
@@ -254,49 +297,6 @@ declare function serializeSmallString(input: string): string;
254
297
  */
255
298
  declare function timestamp(opts?: ASchemaOptions): AScalarSchema<"timestamp", Date>;
256
299
 
257
- declare function createParsingTemplate(input: string, schema: Schema): string;
258
-
259
- declare function createSerializationV2Template(inputName: string, schema: Schema): string;
260
-
261
- declare function createValidationTemplate(inputName: string, schema: ASchema<any>): string;
262
-
263
- interface CompiledValidator<TSchema extends ASchema<any>> {
264
- /**
265
- * Determine if a type matches a schema. This is a type guard.
266
- */
267
- validate: (input: unknown) => input is InferType<TSchema>;
268
- /**
269
- * Parse a JSON string or the result of JSON.parse(). Throws an error if parsing fails.
270
- */
271
- parse: (input: unknown) => InferType<TSchema>;
272
- /**
273
- * Parse a JSON string or the result of JSON.parse() without throwing an error
274
- */
275
- safeParse: (input: unknown) => SafeResult<InferType<TSchema>>;
276
- /**
277
- * Serialize to JSON
278
- */
279
- serialize: (input: InferType<TSchema>) => string;
280
- compiledCode: {
281
- serialize: string;
282
- parse: string;
283
- validate: string;
284
- };
285
- }
286
- /**
287
- * Create compiled versions of the `parse()`, `validate()`, and `serialize()` functions
288
- */
289
- declare function compile<TSchema extends ASchema<any>>(schema: TSchema): CompiledValidator<TSchema>;
290
- type CompiledParser<TSchema extends ASchema<any>> = CompiledValidator<TSchema>["parse"];
291
- declare function getCompiledParser<TSchema extends ASchema<any>>(input: string, schema: TSchema): {
292
- fn: CompiledParser<TSchema>;
293
- code: string;
294
- };
295
- declare function getCompiledSerializer<TSchema extends ASchema>(schema: TSchema): {
296
- fn: (input: InferType<TSchema>) => string;
297
- code: string;
298
- };
299
-
300
300
  declare const _namespace_any: typeof any;
301
301
  declare const _namespace_array: typeof array;
302
302
  declare const _namespace_boolean: typeof boolean;
@@ -338,23 +338,6 @@ declare namespace _namespace {
338
338
  export { _namespace_any as any, _namespace_array as array, _namespace_boolean as boolean, _namespace_clone as clone, _namespace_coerce as coerce, _namespace_compile as compile, _namespace_discriminator as discriminator, _namespace_enumerator as enumerator, _namespace_errors as errors, _namespace_extend as extend, _namespace_float32 as float32, _namespace_float64 as float64, InferType as infer, InferSubType as inferSubType, _namespace_int16 as int16, _namespace_int32 as int32, _namespace_int64 as int64, _namespace_int8 as int8, _namespace_nullable as nullable, _namespace_number as number, _namespace_object as object, _namespace_omit as omit, _namespace_optional as optional, _namespace_parse as parse, _namespace_partial as partial, _namespace_pick as pick, _namespace_record as record, _namespace_recursive as recursive, _namespace_safeCoerce as safeCoerce, _namespace_safeParse as safeParse, _namespace_serialize as serialize, _namespace_string as string, _namespace_stringEnum as stringEnum, _namespace_timestamp as timestamp, _namespace_uint16 as uint16, _namespace_uint32 as uint32, _namespace_uint64 as uint64, _namespace_uint8 as uint8, _namespace_validate as validate };
339
339
  }
340
340
 
341
- declare const int8Min = -128;
342
- declare const int8Max = 127;
343
- declare const uint8Min = 0;
344
- declare const uint8Max = 255;
345
- declare const int16Min = -32768;
346
- declare const int16Max = 32767;
347
- declare const uint16Min = 0;
348
- declare const uint16Max = 65535;
349
- declare const int32Min = -2147483648;
350
- declare const int32Max = 2147483647;
351
- declare const uint32Min = 0;
352
- declare const uint32Max = 4294967295;
353
- declare const int64Min: bigint;
354
- declare const int64Max: bigint;
355
- declare const uint64Min: bigint;
356
- declare const uint64Max: bigint;
357
-
358
341
  interface AAdaptedSchemaValidator<T> extends SchemaValidator<T> {
359
342
  _isAdaptedSchema: true;
360
343
  }
@@ -376,4 +359,21 @@ interface AAdaptedDiscriminatorSchema<T> extends ADiscriminatorSchema<T> {
376
359
  declare function isAAdaptedSchema<T = any>(input: unknown): input is AAdaptedSchema<T>;
377
360
  type ValidationAdapter = <T>(input: any) => AAdaptedSchema<T>;
378
361
 
362
+ declare const int8Min = -128;
363
+ declare const int8Max = 127;
364
+ declare const uint8Min = 0;
365
+ declare const uint8Max = 255;
366
+ declare const int16Min = -32768;
367
+ declare const int16Max = 32767;
368
+ declare const uint16Min = 0;
369
+ declare const uint16Max = 65535;
370
+ declare const int32Min = -2147483648;
371
+ declare const int32Max = 2147483647;
372
+ declare const uint32Min = 0;
373
+ declare const uint32Max = 4294967295;
374
+ declare const int64Min: bigint;
375
+ declare const int64Max: bigint;
376
+ declare const uint64Min: bigint;
377
+ declare const uint64Max: bigint;
378
+
379
379
  export { type AAdaptedDiscriminatorSchema, type AAdaptedObjectSchema, type AAdaptedRecordSchema, type AAdaptedSchema, type AAdaptedSchemaMetadata, type AAdaptedSchemaValidator, AArraySchema, ADiscriminatorSchema, AObjectSchema, AObjectSchemaOptions, ARecordSchema, ARefSchema, AScalarSchema, ASchema, ASchemaOptions, AStringEnumSchema, type CompiledValidator, InferObjectOutput, InferSubType, InferType, ResolveObject, SCHEMA_METADATA, SafeResult, SchemaMetadata, SchemaValidator, type ValidationAdapter, ValidationData, _namespace as a, any, array, boolean, clone, coerce, compile, discriminator, enumerator, errors, extend, float32, float64, getCompiledParser, getCompiledSerializer, createParsingTemplate as getSchemaParsingCode, createSerializationV2Template as getSchemaSerializationCode, createValidationTemplate as getSchemaValidationCode, int16, int16Max, int16Min, int32, int32Max, int32Min, int64, int64Max, int64Min, int8, int8Max, int8Min, isAAdaptedSchema, nullable, number, object, omit, optional, parse, parseObjectSchema, partial, pick, record, recursive, safeCoerce, safeParse, serialize, serializeObject, serializeSmallString, string, stringEnum, timestamp, uint16, uint16Max, uint16Min, uint32, uint32Max, uint32Min, uint64, uint64Max, uint64Min, uint8, uint8Max, uint8Min, validate, validateObjectSchema };
package/dist/index.d.mts CHANGED
@@ -1,7 +1,50 @@
1
- import { A as ASchemaOptions, a as ASchema, b as AArraySchema, c as AScalarSchema, d as AObjectSchema, e as ADiscriminatorSchema, I as InferType, R as ResolveObject, f as AStringEnumSchema, g as AObjectSchemaOptions, h as InferObjectOutput, V as ValidationData, i as ARecordSchema, j as ARefSchema, S as SafeResult, k as coerce, l as errors, m as InferSubType, p as parse, s as safeCoerce, n as safeParse, o as serialize, v as validate, q as SchemaValidator, r as SchemaMetadata, t as SCHEMA_METADATA } from './shared/schema.b7c77149.mjs';
2
- export { K as InferObjectRawType, M as MaybeNullable, D as NumberType, N as NumberTypeValues, P as PartialBy, B as Resolve, x as ValidationError, w as ValueError, E as isAAraySchema, G as isADiscriminatorSchema, J as isAObjectSchema, H as isARecordSchema, O as isARefSchema, C as isAScalarSchema, z as isASchema, F as isAStringEnumSchema, L as isObject, y as isValidationError, u as sanitizeJson } from './shared/schema.b7c77149.mjs';
1
+ import { A as ASchema, I as InferType, S as SafeResult, a as ASchemaOptions, b as AArraySchema, c as AScalarSchema, d as AObjectSchema, e as ADiscriminatorSchema, R as ResolveObject, f as AStringEnumSchema, g as AObjectSchemaOptions, h as InferObjectOutput, V as ValidationData, i as ARecordSchema, j as ARefSchema, k as coerce, l as errors, m as InferSubType, p as parse, s as safeCoerce, n as safeParse, o as serialize, v as validate, q as SchemaValidator, r as SchemaMetadata, t as SCHEMA_METADATA } from './shared/schema.7414d46a.mjs';
2
+ export { K as InferObjectRawType, M as MaybeNullable, D as NumberType, N as NumberTypeValues, P as PartialBy, B as Resolve, x as ValidationError, w as ValueError, E as isAAraySchema, G as isADiscriminatorSchema, J as isAObjectSchema, H as isARecordSchema, O as isARefSchema, C as isAScalarSchema, z as isASchema, F as isAStringEnumSchema, L as isObject, y as isValidationError, u as sanitizeJson } from './shared/schema.7414d46a.mjs';
3
3
  import { Schema } from 'jtd-utils';
4
4
 
5
+ declare function createParsingTemplate(input: string, schema: Schema): string;
6
+
7
+ declare function createSerializationV2Template(inputName: string, schema: Schema): string;
8
+
9
+ declare function createValidationTemplate(inputName: string, schema: ASchema<any>): string;
10
+
11
+ interface CompiledValidator<TSchema extends ASchema<any>> {
12
+ /**
13
+ * Determine if a type matches a schema. This is a type guard.
14
+ */
15
+ validate: (input: unknown) => input is InferType<TSchema>;
16
+ /**
17
+ * Parse a JSON string or the result of JSON.parse(). Throws an error if parsing fails.
18
+ */
19
+ parse: (input: unknown) => InferType<TSchema>;
20
+ /**
21
+ * Parse a JSON string or the result of JSON.parse() without throwing an error
22
+ */
23
+ safeParse: (input: unknown) => SafeResult<InferType<TSchema>>;
24
+ /**
25
+ * Serialize to JSON
26
+ */
27
+ serialize: (input: InferType<TSchema>) => string;
28
+ compiledCode: {
29
+ serialize: string;
30
+ parse: string;
31
+ validate: string;
32
+ };
33
+ }
34
+ /**
35
+ * Create compiled versions of the `parse()`, `validate()`, and `serialize()` functions
36
+ */
37
+ declare function compile<TSchema extends ASchema<any>>(schema: TSchema): CompiledValidator<TSchema>;
38
+ type CompiledParser<TSchema extends ASchema<any>> = CompiledValidator<TSchema>["parse"];
39
+ declare function getCompiledParser<TSchema extends ASchema<any>>(input: string, schema: TSchema): {
40
+ fn: CompiledParser<TSchema>;
41
+ code: string;
42
+ };
43
+ declare function getCompiledSerializer<TSchema extends ASchema>(schema: TSchema): {
44
+ fn: (input: InferType<TSchema>) => string;
45
+ code: string;
46
+ };
47
+
5
48
  /**
6
49
  * Create a schema that accepts anything
7
50
  */
@@ -254,49 +297,6 @@ declare function serializeSmallString(input: string): string;
254
297
  */
255
298
  declare function timestamp(opts?: ASchemaOptions): AScalarSchema<"timestamp", Date>;
256
299
 
257
- declare function createParsingTemplate(input: string, schema: Schema): string;
258
-
259
- declare function createSerializationV2Template(inputName: string, schema: Schema): string;
260
-
261
- declare function createValidationTemplate(inputName: string, schema: ASchema<any>): string;
262
-
263
- interface CompiledValidator<TSchema extends ASchema<any>> {
264
- /**
265
- * Determine if a type matches a schema. This is a type guard.
266
- */
267
- validate: (input: unknown) => input is InferType<TSchema>;
268
- /**
269
- * Parse a JSON string or the result of JSON.parse(). Throws an error if parsing fails.
270
- */
271
- parse: (input: unknown) => InferType<TSchema>;
272
- /**
273
- * Parse a JSON string or the result of JSON.parse() without throwing an error
274
- */
275
- safeParse: (input: unknown) => SafeResult<InferType<TSchema>>;
276
- /**
277
- * Serialize to JSON
278
- */
279
- serialize: (input: InferType<TSchema>) => string;
280
- compiledCode: {
281
- serialize: string;
282
- parse: string;
283
- validate: string;
284
- };
285
- }
286
- /**
287
- * Create compiled versions of the `parse()`, `validate()`, and `serialize()` functions
288
- */
289
- declare function compile<TSchema extends ASchema<any>>(schema: TSchema): CompiledValidator<TSchema>;
290
- type CompiledParser<TSchema extends ASchema<any>> = CompiledValidator<TSchema>["parse"];
291
- declare function getCompiledParser<TSchema extends ASchema<any>>(input: string, schema: TSchema): {
292
- fn: CompiledParser<TSchema>;
293
- code: string;
294
- };
295
- declare function getCompiledSerializer<TSchema extends ASchema>(schema: TSchema): {
296
- fn: (input: InferType<TSchema>) => string;
297
- code: string;
298
- };
299
-
300
300
  declare const _namespace_any: typeof any;
301
301
  declare const _namespace_array: typeof array;
302
302
  declare const _namespace_boolean: typeof boolean;
@@ -338,23 +338,6 @@ declare namespace _namespace {
338
338
  export { _namespace_any as any, _namespace_array as array, _namespace_boolean as boolean, _namespace_clone as clone, _namespace_coerce as coerce, _namespace_compile as compile, _namespace_discriminator as discriminator, _namespace_enumerator as enumerator, _namespace_errors as errors, _namespace_extend as extend, _namespace_float32 as float32, _namespace_float64 as float64, InferType as infer, InferSubType as inferSubType, _namespace_int16 as int16, _namespace_int32 as int32, _namespace_int64 as int64, _namespace_int8 as int8, _namespace_nullable as nullable, _namespace_number as number, _namespace_object as object, _namespace_omit as omit, _namespace_optional as optional, _namespace_parse as parse, _namespace_partial as partial, _namespace_pick as pick, _namespace_record as record, _namespace_recursive as recursive, _namespace_safeCoerce as safeCoerce, _namespace_safeParse as safeParse, _namespace_serialize as serialize, _namespace_string as string, _namespace_stringEnum as stringEnum, _namespace_timestamp as timestamp, _namespace_uint16 as uint16, _namespace_uint32 as uint32, _namespace_uint64 as uint64, _namespace_uint8 as uint8, _namespace_validate as validate };
339
339
  }
340
340
 
341
- declare const int8Min = -128;
342
- declare const int8Max = 127;
343
- declare const uint8Min = 0;
344
- declare const uint8Max = 255;
345
- declare const int16Min = -32768;
346
- declare const int16Max = 32767;
347
- declare const uint16Min = 0;
348
- declare const uint16Max = 65535;
349
- declare const int32Min = -2147483648;
350
- declare const int32Max = 2147483647;
351
- declare const uint32Min = 0;
352
- declare const uint32Max = 4294967295;
353
- declare const int64Min: bigint;
354
- declare const int64Max: bigint;
355
- declare const uint64Min: bigint;
356
- declare const uint64Max: bigint;
357
-
358
341
  interface AAdaptedSchemaValidator<T> extends SchemaValidator<T> {
359
342
  _isAdaptedSchema: true;
360
343
  }
@@ -376,4 +359,21 @@ interface AAdaptedDiscriminatorSchema<T> extends ADiscriminatorSchema<T> {
376
359
  declare function isAAdaptedSchema<T = any>(input: unknown): input is AAdaptedSchema<T>;
377
360
  type ValidationAdapter = <T>(input: any) => AAdaptedSchema<T>;
378
361
 
362
+ declare const int8Min = -128;
363
+ declare const int8Max = 127;
364
+ declare const uint8Min = 0;
365
+ declare const uint8Max = 255;
366
+ declare const int16Min = -32768;
367
+ declare const int16Max = 32767;
368
+ declare const uint16Min = 0;
369
+ declare const uint16Max = 65535;
370
+ declare const int32Min = -2147483648;
371
+ declare const int32Max = 2147483647;
372
+ declare const uint32Min = 0;
373
+ declare const uint32Max = 4294967295;
374
+ declare const int64Min: bigint;
375
+ declare const int64Max: bigint;
376
+ declare const uint64Min: bigint;
377
+ declare const uint64Max: bigint;
378
+
379
379
  export { type AAdaptedDiscriminatorSchema, type AAdaptedObjectSchema, type AAdaptedRecordSchema, type AAdaptedSchema, type AAdaptedSchemaMetadata, type AAdaptedSchemaValidator, AArraySchema, ADiscriminatorSchema, AObjectSchema, AObjectSchemaOptions, ARecordSchema, ARefSchema, AScalarSchema, ASchema, ASchemaOptions, AStringEnumSchema, type CompiledValidator, InferObjectOutput, InferSubType, InferType, ResolveObject, SCHEMA_METADATA, SafeResult, SchemaMetadata, SchemaValidator, type ValidationAdapter, ValidationData, _namespace as a, any, array, boolean, clone, coerce, compile, discriminator, enumerator, errors, extend, float32, float64, getCompiledParser, getCompiledSerializer, createParsingTemplate as getSchemaParsingCode, createSerializationV2Template as getSchemaSerializationCode, createValidationTemplate as getSchemaValidationCode, int16, int16Max, int16Min, int32, int32Max, int32Min, int64, int64Max, int64Min, int8, int8Max, int8Min, isAAdaptedSchema, nullable, number, object, omit, optional, parse, parseObjectSchema, partial, pick, record, recursive, safeCoerce, safeParse, serialize, serializeObject, serializeSmallString, string, stringEnum, timestamp, uint16, uint16Max, uint16Min, uint32, uint32Max, uint32Min, uint64, uint64Max, uint64Min, uint8, uint8Max, uint8Min, validate, validateObjectSchema };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,50 @@
1
- import { A as ASchemaOptions, a as ASchema, b as AArraySchema, c as AScalarSchema, d as AObjectSchema, e as ADiscriminatorSchema, I as InferType, R as ResolveObject, f as AStringEnumSchema, g as AObjectSchemaOptions, h as InferObjectOutput, V as ValidationData, i as ARecordSchema, j as ARefSchema, S as SafeResult, k as coerce, l as errors, m as InferSubType, p as parse, s as safeCoerce, n as safeParse, o as serialize, v as validate, q as SchemaValidator, r as SchemaMetadata, t as SCHEMA_METADATA } from './shared/schema.b7c77149.js';
2
- export { K as InferObjectRawType, M as MaybeNullable, D as NumberType, N as NumberTypeValues, P as PartialBy, B as Resolve, x as ValidationError, w as ValueError, E as isAAraySchema, G as isADiscriminatorSchema, J as isAObjectSchema, H as isARecordSchema, O as isARefSchema, C as isAScalarSchema, z as isASchema, F as isAStringEnumSchema, L as isObject, y as isValidationError, u as sanitizeJson } from './shared/schema.b7c77149.js';
1
+ import { A as ASchema, I as InferType, S as SafeResult, a as ASchemaOptions, b as AArraySchema, c as AScalarSchema, d as AObjectSchema, e as ADiscriminatorSchema, R as ResolveObject, f as AStringEnumSchema, g as AObjectSchemaOptions, h as InferObjectOutput, V as ValidationData, i as ARecordSchema, j as ARefSchema, k as coerce, l as errors, m as InferSubType, p as parse, s as safeCoerce, n as safeParse, o as serialize, v as validate, q as SchemaValidator, r as SchemaMetadata, t as SCHEMA_METADATA } from './shared/schema.7414d46a.js';
2
+ export { K as InferObjectRawType, M as MaybeNullable, D as NumberType, N as NumberTypeValues, P as PartialBy, B as Resolve, x as ValidationError, w as ValueError, E as isAAraySchema, G as isADiscriminatorSchema, J as isAObjectSchema, H as isARecordSchema, O as isARefSchema, C as isAScalarSchema, z as isASchema, F as isAStringEnumSchema, L as isObject, y as isValidationError, u as sanitizeJson } from './shared/schema.7414d46a.js';
3
3
  import { Schema } from 'jtd-utils';
4
4
 
5
+ declare function createParsingTemplate(input: string, schema: Schema): string;
6
+
7
+ declare function createSerializationV2Template(inputName: string, schema: Schema): string;
8
+
9
+ declare function createValidationTemplate(inputName: string, schema: ASchema<any>): string;
10
+
11
+ interface CompiledValidator<TSchema extends ASchema<any>> {
12
+ /**
13
+ * Determine if a type matches a schema. This is a type guard.
14
+ */
15
+ validate: (input: unknown) => input is InferType<TSchema>;
16
+ /**
17
+ * Parse a JSON string or the result of JSON.parse(). Throws an error if parsing fails.
18
+ */
19
+ parse: (input: unknown) => InferType<TSchema>;
20
+ /**
21
+ * Parse a JSON string or the result of JSON.parse() without throwing an error
22
+ */
23
+ safeParse: (input: unknown) => SafeResult<InferType<TSchema>>;
24
+ /**
25
+ * Serialize to JSON
26
+ */
27
+ serialize: (input: InferType<TSchema>) => string;
28
+ compiledCode: {
29
+ serialize: string;
30
+ parse: string;
31
+ validate: string;
32
+ };
33
+ }
34
+ /**
35
+ * Create compiled versions of the `parse()`, `validate()`, and `serialize()` functions
36
+ */
37
+ declare function compile<TSchema extends ASchema<any>>(schema: TSchema): CompiledValidator<TSchema>;
38
+ type CompiledParser<TSchema extends ASchema<any>> = CompiledValidator<TSchema>["parse"];
39
+ declare function getCompiledParser<TSchema extends ASchema<any>>(input: string, schema: TSchema): {
40
+ fn: CompiledParser<TSchema>;
41
+ code: string;
42
+ };
43
+ declare function getCompiledSerializer<TSchema extends ASchema>(schema: TSchema): {
44
+ fn: (input: InferType<TSchema>) => string;
45
+ code: string;
46
+ };
47
+
5
48
  /**
6
49
  * Create a schema that accepts anything
7
50
  */
@@ -254,49 +297,6 @@ declare function serializeSmallString(input: string): string;
254
297
  */
255
298
  declare function timestamp(opts?: ASchemaOptions): AScalarSchema<"timestamp", Date>;
256
299
 
257
- declare function createParsingTemplate(input: string, schema: Schema): string;
258
-
259
- declare function createSerializationV2Template(inputName: string, schema: Schema): string;
260
-
261
- declare function createValidationTemplate(inputName: string, schema: ASchema<any>): string;
262
-
263
- interface CompiledValidator<TSchema extends ASchema<any>> {
264
- /**
265
- * Determine if a type matches a schema. This is a type guard.
266
- */
267
- validate: (input: unknown) => input is InferType<TSchema>;
268
- /**
269
- * Parse a JSON string or the result of JSON.parse(). Throws an error if parsing fails.
270
- */
271
- parse: (input: unknown) => InferType<TSchema>;
272
- /**
273
- * Parse a JSON string or the result of JSON.parse() without throwing an error
274
- */
275
- safeParse: (input: unknown) => SafeResult<InferType<TSchema>>;
276
- /**
277
- * Serialize to JSON
278
- */
279
- serialize: (input: InferType<TSchema>) => string;
280
- compiledCode: {
281
- serialize: string;
282
- parse: string;
283
- validate: string;
284
- };
285
- }
286
- /**
287
- * Create compiled versions of the `parse()`, `validate()`, and `serialize()` functions
288
- */
289
- declare function compile<TSchema extends ASchema<any>>(schema: TSchema): CompiledValidator<TSchema>;
290
- type CompiledParser<TSchema extends ASchema<any>> = CompiledValidator<TSchema>["parse"];
291
- declare function getCompiledParser<TSchema extends ASchema<any>>(input: string, schema: TSchema): {
292
- fn: CompiledParser<TSchema>;
293
- code: string;
294
- };
295
- declare function getCompiledSerializer<TSchema extends ASchema>(schema: TSchema): {
296
- fn: (input: InferType<TSchema>) => string;
297
- code: string;
298
- };
299
-
300
300
  declare const _namespace_any: typeof any;
301
301
  declare const _namespace_array: typeof array;
302
302
  declare const _namespace_boolean: typeof boolean;
@@ -338,23 +338,6 @@ declare namespace _namespace {
338
338
  export { _namespace_any as any, _namespace_array as array, _namespace_boolean as boolean, _namespace_clone as clone, _namespace_coerce as coerce, _namespace_compile as compile, _namespace_discriminator as discriminator, _namespace_enumerator as enumerator, _namespace_errors as errors, _namespace_extend as extend, _namespace_float32 as float32, _namespace_float64 as float64, InferType as infer, InferSubType as inferSubType, _namespace_int16 as int16, _namespace_int32 as int32, _namespace_int64 as int64, _namespace_int8 as int8, _namespace_nullable as nullable, _namespace_number as number, _namespace_object as object, _namespace_omit as omit, _namespace_optional as optional, _namespace_parse as parse, _namespace_partial as partial, _namespace_pick as pick, _namespace_record as record, _namespace_recursive as recursive, _namespace_safeCoerce as safeCoerce, _namespace_safeParse as safeParse, _namespace_serialize as serialize, _namespace_string as string, _namespace_stringEnum as stringEnum, _namespace_timestamp as timestamp, _namespace_uint16 as uint16, _namespace_uint32 as uint32, _namespace_uint64 as uint64, _namespace_uint8 as uint8, _namespace_validate as validate };
339
339
  }
340
340
 
341
- declare const int8Min = -128;
342
- declare const int8Max = 127;
343
- declare const uint8Min = 0;
344
- declare const uint8Max = 255;
345
- declare const int16Min = -32768;
346
- declare const int16Max = 32767;
347
- declare const uint16Min = 0;
348
- declare const uint16Max = 65535;
349
- declare const int32Min = -2147483648;
350
- declare const int32Max = 2147483647;
351
- declare const uint32Min = 0;
352
- declare const uint32Max = 4294967295;
353
- declare const int64Min: bigint;
354
- declare const int64Max: bigint;
355
- declare const uint64Min: bigint;
356
- declare const uint64Max: bigint;
357
-
358
341
  interface AAdaptedSchemaValidator<T> extends SchemaValidator<T> {
359
342
  _isAdaptedSchema: true;
360
343
  }
@@ -376,4 +359,21 @@ interface AAdaptedDiscriminatorSchema<T> extends ADiscriminatorSchema<T> {
376
359
  declare function isAAdaptedSchema<T = any>(input: unknown): input is AAdaptedSchema<T>;
377
360
  type ValidationAdapter = <T>(input: any) => AAdaptedSchema<T>;
378
361
 
362
+ declare const int8Min = -128;
363
+ declare const int8Max = 127;
364
+ declare const uint8Min = 0;
365
+ declare const uint8Max = 255;
366
+ declare const int16Min = -32768;
367
+ declare const int16Max = 32767;
368
+ declare const uint16Min = 0;
369
+ declare const uint16Max = 65535;
370
+ declare const int32Min = -2147483648;
371
+ declare const int32Max = 2147483647;
372
+ declare const uint32Min = 0;
373
+ declare const uint32Max = 4294967295;
374
+ declare const int64Min: bigint;
375
+ declare const int64Max: bigint;
376
+ declare const uint64Min: bigint;
377
+ declare const uint64Max: bigint;
378
+
379
379
  export { type AAdaptedDiscriminatorSchema, type AAdaptedObjectSchema, type AAdaptedRecordSchema, type AAdaptedSchema, type AAdaptedSchemaMetadata, type AAdaptedSchemaValidator, AArraySchema, ADiscriminatorSchema, AObjectSchema, AObjectSchemaOptions, ARecordSchema, ARefSchema, AScalarSchema, ASchema, ASchemaOptions, AStringEnumSchema, type CompiledValidator, InferObjectOutput, InferSubType, InferType, ResolveObject, SCHEMA_METADATA, SafeResult, SchemaMetadata, SchemaValidator, type ValidationAdapter, ValidationData, _namespace as a, any, array, boolean, clone, coerce, compile, discriminator, enumerator, errors, extend, float32, float64, getCompiledParser, getCompiledSerializer, createParsingTemplate as getSchemaParsingCode, createSerializationV2Template as getSchemaSerializationCode, createValidationTemplate as getSchemaValidationCode, int16, int16Max, int16Min, int32, int32Max, int32Min, int64, int64Max, int64Min, int8, int8Max, int8Min, isAAdaptedSchema, nullable, number, object, omit, optional, parse, parseObjectSchema, partial, pick, record, recursive, safeCoerce, safeParse, serialize, serializeObject, serializeSmallString, string, stringEnum, timestamp, uint16, uint16Max, uint16Min, uint32, uint32Max, uint32Min, uint64, uint64Max, uint64Min, uint8, uint8Max, uint8Min, validate, validateObjectSchema };
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { u as uint8Max, a as uint8Min, b as uint16Max, c as uint16Min, d as uint32Max, e as uint32Min, i as int8Max, f as int8Min, g as int16Max, h as int16Min, j as int32Max, k as int32Min, l as isAScalarSchema, m as isAObjectSchema, n as isAStringEnumSchema, o as isAAraySchema, p as isARecordSchema, q as isADiscriminatorSchema, r as isARefSchema, s as errors, V as ValidationError, t as any, v as array, w as boolean, x as clone, y as coerce, z as discriminator, A as enumerator, B as extend, C as float32, D as float64, E as int16, F as int32, G as int64, H as int8, I as nullable, J as number, K as object, L as omit, M as optional, N as parse, O as partial, P as pick, Q as record, R as recursive, S as safeCoerce, T as safeParse, U as serialize, W as string, X as stringEnum, Y as timestamp, Z as uint16, _ as uint32, $ as uint64, a0 as uint8, a1 as validate, a2 as isASchema, a3 as SCHEMA_METADATA } from './shared/schema.66772201.mjs';
2
- export { ae as NumberTypeValues, a5 as int64Max, a4 as int64Min, af as isObject, ad as isValidationError, a8 as parseObjectSchema, ac as sanitizeJson, aa as serializeObject, ab as serializeSmallString, a7 as uint64Max, a6 as uint64Min, a9 as validateObjectSchema } from './shared/schema.66772201.mjs';
3
1
  import { isSchemaFormProperties, isSchemaFormValues, isSchemaFormElements, isSchemaFormDiscriminator, isSchemaFormEmpty, isSchemaFormType, isSchemaFormEnum, isSchemaFormRef } from 'jtd-utils';
4
2
  import { camelCase } from 'scule';
3
+ import { u as uint8Max, a as uint8Min, b as uint16Max, c as uint16Min, d as uint32Max, e as uint32Min, i as int8Max, f as int8Min, g as int16Max, h as int16Min, j as int32Max, k as int32Min, l as isAScalarSchema, m as isAObjectSchema, n as isAStringEnumSchema, o as isAAraySchema, p as isARecordSchema, q as isADiscriminatorSchema, r as isARefSchema, s as errors, V as ValidationError, t as any, v as array, w as boolean, x as clone, y as coerce, z as discriminator, A as enumerator, B as extend, C as float32, D as float64, E as int16, F as int32, G as int64, H as int8, I as nullable, J as number, K as object, L as omit, M as optional, N as parse, O as partial, P as pick, Q as record, R as recursive, S as safeCoerce, T as safeParse, U as serialize, W as string, X as stringEnum, Y as timestamp, Z as uint16, _ as uint32, $ as uint64, a0 as uint8, a1 as validate, a2 as isASchema, a3 as SCHEMA_METADATA } from './shared/schema.79ea38f8.mjs';
4
+ export { ae as NumberTypeValues, a5 as int64Max, a4 as int64Min, af as isObject, ad as isValidationError, a8 as parseObjectSchema, ac as sanitizeJson, aa as serializeObject, ab as serializeSmallString, a7 as uint64Max, a6 as uint64Min, a9 as validateObjectSchema } from './shared/schema.79ea38f8.mjs';
5
5
 
6
6
  function createParsingTemplate(input, schema) {
7
7
  const fallbackTemplate = `
@@ -2,6 +2,23 @@
2
2
 
3
3
  const jtdUtils = require('jtd-utils');
4
4
 
5
+ const int8Min = -128;
6
+ const int8Max = 127;
7
+ const uint8Min = 0;
8
+ const uint8Max = 255;
9
+ const int16Min = -32768;
10
+ const int16Max = 32767;
11
+ const uint16Min = 0;
12
+ const uint16Max = 65535;
13
+ const int32Min = -2147483648;
14
+ const int32Max = 2147483647;
15
+ const uint32Min = 0;
16
+ const uint32Max = 4294967295;
17
+ const int64Min = BigInt("-9223372036854775808");
18
+ const int64Max = BigInt("9223372036854775807");
19
+ const uint64Min = BigInt("0");
20
+ const uint64Max = BigInt("18446744073709551615");
21
+
5
22
  const SCHEMA_METADATA = Symbol.for("arri.schema_metadata");
6
23
  function isASchema(input) {
7
24
  if (typeof input !== "object") {
@@ -522,20 +539,20 @@ function discriminatorMappingError(discriminatorVal, data) {
522
539
 
523
540
  const stringEnum = enumerator;
524
541
  function enumerator(paramA, paramB) {
542
+ const isIdShorthand = typeof paramA === "string";
543
+ const enumVal = isIdShorthand ? paramB : paramA;
544
+ const meta = isIdShorthand ? { id: paramA } : paramB;
525
545
  const isType = (input) => {
526
546
  if (typeof input !== "string") {
527
547
  return false;
528
548
  }
529
- for (const val of paramA) {
549
+ for (const val of enumVal) {
530
550
  if (val === input) {
531
551
  return true;
532
552
  }
533
553
  }
534
554
  return false;
535
555
  };
536
- const isIdShorthand = typeof paramA === "string";
537
- const enumVal = isIdShorthand ? paramB : paramA;
538
- const meta = isIdShorthand ? { id: paramA } : paramB;
539
556
  return {
540
557
  enum: enumVal,
541
558
  metadata: {
@@ -691,23 +708,6 @@ function clone(input, opts = {}) {
691
708
  return schema;
692
709
  }
693
710
 
694
- const int8Min = -128;
695
- const int8Max = 127;
696
- const uint8Min = 0;
697
- const uint8Max = 255;
698
- const int16Min = -32768;
699
- const int16Max = 32767;
700
- const uint16Min = 0;
701
- const uint16Max = 65535;
702
- const int32Min = -2147483648;
703
- const int32Max = 2147483647;
704
- const uint32Min = 0;
705
- const uint32Max = 4294967295;
706
- const int64Min = BigInt("-9223372036854775808");
707
- const int64Max = BigInt("9223372036854775807");
708
- const uint64Min = BigInt("0");
709
- const uint64Max = BigInt("18446744073709551615");
710
-
711
711
  function number(opts = {}) {
712
712
  return float64(opts);
713
713
  }
@@ -727,14 +727,14 @@ function coerceNumber(input, options) {
727
727
  return parseNumber(input, options);
728
728
  }
729
729
  function float32(opts = {}) {
730
- return numberScalarType("float32", opts, (input) => {
730
+ return numberScalarType("float32", opts, () => {
731
731
  return {
732
732
  success: true
733
733
  };
734
734
  });
735
735
  }
736
736
  function float64(opts = {}) {
737
- return numberScalarType("float64", opts, (input) => {
737
+ return numberScalarType("float64", opts, () => {
738
738
  return {
739
739
  success: true
740
740
  };
@@ -942,7 +942,7 @@ function validateNumber(input) {
942
942
  function validateInt(input, minVal, maxValue) {
943
943
  return Number.isInteger(input) && input >= minVal && input <= maxValue;
944
944
  }
945
- function serializeNumber(input, data) {
945
+ function serializeNumber(input, _data) {
946
946
  return input.toString();
947
947
  }
948
948
  function parseNumber(input, options) {
@@ -164,4 +164,4 @@ interface ARefSchema<T> extends ASchema<T> {
164
164
  }
165
165
  declare function isARefSchema(input: unknown): input is ARefSchema<any>;
166
166
 
167
- export { type ASchemaOptions as A, type Resolve as B, isAScalarSchema as C, type NumberType as D, isAAraySchema as E, isAStringEnumSchema as F, isADiscriminatorSchema as G, isARecordSchema as H, type InferType as I, isAObjectSchema as J, type InferObjectRawType as K, isObject as L, type MaybeNullable as M, NumberTypeValues as N, isARefSchema as O, type PartialBy as P, type ResolveObject as R, type SafeResult as S, type ValidationData as V, type ASchema as a, type AArraySchema as b, type AScalarSchema as c, type AObjectSchema as d, type ADiscriminatorSchema as e, type AStringEnumSchema as f, type AObjectSchemaOptions as g, type InferObjectOutput as h, type ARecordSchema as i, type ARefSchema as j, coerce as k, errors as l, type InferSubType as m, safeParse as n, serialize as o, parse as p, type SchemaValidator as q, type SchemaMetadata as r, safeCoerce as s, SCHEMA_METADATA as t, sanitizeJson as u, validate as v, type ValueError as w, ValidationError as x, isValidationError as y, isASchema as z };
167
+ export { type ASchema as A, type Resolve as B, isAScalarSchema as C, type NumberType as D, isAAraySchema as E, isAStringEnumSchema as F, isADiscriminatorSchema as G, isARecordSchema as H, type InferType as I, isAObjectSchema as J, type InferObjectRawType as K, isObject as L, type MaybeNullable as M, NumberTypeValues as N, isARefSchema as O, type PartialBy as P, type ResolveObject as R, type SafeResult as S, type ValidationData as V, type ASchemaOptions as a, type AArraySchema as b, type AScalarSchema as c, type AObjectSchema as d, type ADiscriminatorSchema as e, type AStringEnumSchema as f, type AObjectSchemaOptions as g, type InferObjectOutput as h, type ARecordSchema as i, type ARefSchema as j, coerce as k, errors as l, type InferSubType as m, safeParse as n, serialize as o, parse as p, type SchemaValidator as q, type SchemaMetadata as r, safeCoerce as s, SCHEMA_METADATA as t, sanitizeJson as u, validate as v, type ValueError as w, ValidationError as x, isValidationError as y, isASchema as z };
@@ -164,4 +164,4 @@ interface ARefSchema<T> extends ASchema<T> {
164
164
  }
165
165
  declare function isARefSchema(input: unknown): input is ARefSchema<any>;
166
166
 
167
- export { type ASchemaOptions as A, type Resolve as B, isAScalarSchema as C, type NumberType as D, isAAraySchema as E, isAStringEnumSchema as F, isADiscriminatorSchema as G, isARecordSchema as H, type InferType as I, isAObjectSchema as J, type InferObjectRawType as K, isObject as L, type MaybeNullable as M, NumberTypeValues as N, isARefSchema as O, type PartialBy as P, type ResolveObject as R, type SafeResult as S, type ValidationData as V, type ASchema as a, type AArraySchema as b, type AScalarSchema as c, type AObjectSchema as d, type ADiscriminatorSchema as e, type AStringEnumSchema as f, type AObjectSchemaOptions as g, type InferObjectOutput as h, type ARecordSchema as i, type ARefSchema as j, coerce as k, errors as l, type InferSubType as m, safeParse as n, serialize as o, parse as p, type SchemaValidator as q, type SchemaMetadata as r, safeCoerce as s, SCHEMA_METADATA as t, sanitizeJson as u, validate as v, type ValueError as w, ValidationError as x, isValidationError as y, isASchema as z };
167
+ export { type ASchema as A, type Resolve as B, isAScalarSchema as C, type NumberType as D, isAAraySchema as E, isAStringEnumSchema as F, isADiscriminatorSchema as G, isARecordSchema as H, type InferType as I, isAObjectSchema as J, type InferObjectRawType as K, isObject as L, type MaybeNullable as M, NumberTypeValues as N, isARefSchema as O, type PartialBy as P, type ResolveObject as R, type SafeResult as S, type ValidationData as V, type ASchemaOptions as a, type AArraySchema as b, type AScalarSchema as c, type AObjectSchema as d, type ADiscriminatorSchema as e, type AStringEnumSchema as f, type AObjectSchemaOptions as g, type InferObjectOutput as h, type ARecordSchema as i, type ARefSchema as j, coerce as k, errors as l, type InferSubType as m, safeParse as n, serialize as o, parse as p, type SchemaValidator as q, type SchemaMetadata as r, safeCoerce as s, SCHEMA_METADATA as t, sanitizeJson as u, validate as v, type ValueError as w, ValidationError as x, isValidationError as y, isASchema as z };
@@ -164,4 +164,4 @@ interface ARefSchema<T> extends ASchema<T> {
164
164
  }
165
165
  declare function isARefSchema(input: unknown): input is ARefSchema<any>;
166
166
 
167
- export { type ASchemaOptions as A, type Resolve as B, isAScalarSchema as C, type NumberType as D, isAAraySchema as E, isAStringEnumSchema as F, isADiscriminatorSchema as G, isARecordSchema as H, type InferType as I, isAObjectSchema as J, type InferObjectRawType as K, isObject as L, type MaybeNullable as M, NumberTypeValues as N, isARefSchema as O, type PartialBy as P, type ResolveObject as R, type SafeResult as S, type ValidationData as V, type ASchema as a, type AArraySchema as b, type AScalarSchema as c, type AObjectSchema as d, type ADiscriminatorSchema as e, type AStringEnumSchema as f, type AObjectSchemaOptions as g, type InferObjectOutput as h, type ARecordSchema as i, type ARefSchema as j, coerce as k, errors as l, type InferSubType as m, safeParse as n, serialize as o, parse as p, type SchemaValidator as q, type SchemaMetadata as r, safeCoerce as s, SCHEMA_METADATA as t, sanitizeJson as u, validate as v, type ValueError as w, ValidationError as x, isValidationError as y, isASchema as z };
167
+ export { type ASchema as A, type Resolve as B, isAScalarSchema as C, type NumberType as D, isAAraySchema as E, isAStringEnumSchema as F, isADiscriminatorSchema as G, isARecordSchema as H, type InferType as I, isAObjectSchema as J, type InferObjectRawType as K, isObject as L, type MaybeNullable as M, NumberTypeValues as N, isARefSchema as O, type PartialBy as P, type ResolveObject as R, type SafeResult as S, type ValidationData as V, type ASchemaOptions as a, type AArraySchema as b, type AScalarSchema as c, type AObjectSchema as d, type ADiscriminatorSchema as e, type AStringEnumSchema as f, type AObjectSchemaOptions as g, type InferObjectOutput as h, type ARecordSchema as i, type ARefSchema as j, coerce as k, errors as l, type InferSubType as m, safeParse as n, serialize as o, parse as p, type SchemaValidator as q, type SchemaMetadata as r, safeCoerce as s, SCHEMA_METADATA as t, sanitizeJson as u, validate as v, type ValueError as w, ValidationError as x, isValidationError as y, isASchema as z };
@@ -1,5 +1,22 @@
1
1
  import { TypeValues, isSchemaFormElements, isSchemaFormEnum, isSchemaFormDiscriminator, isSchemaFormValues, isSchemaFormProperties, isSchemaFormRef } from 'jtd-utils';
2
2
 
3
+ const int8Min = -128;
4
+ const int8Max = 127;
5
+ const uint8Min = 0;
6
+ const uint8Max = 255;
7
+ const int16Min = -32768;
8
+ const int16Max = 32767;
9
+ const uint16Min = 0;
10
+ const uint16Max = 65535;
11
+ const int32Min = -2147483648;
12
+ const int32Max = 2147483647;
13
+ const uint32Min = 0;
14
+ const uint32Max = 4294967295;
15
+ const int64Min = BigInt("-9223372036854775808");
16
+ const int64Max = BigInt("9223372036854775807");
17
+ const uint64Min = BigInt("0");
18
+ const uint64Max = BigInt("18446744073709551615");
19
+
3
20
  const SCHEMA_METADATA = Symbol.for("arri.schema_metadata");
4
21
  function isASchema(input) {
5
22
  if (typeof input !== "object") {
@@ -520,20 +537,20 @@ function discriminatorMappingError(discriminatorVal, data) {
520
537
 
521
538
  const stringEnum = enumerator;
522
539
  function enumerator(paramA, paramB) {
540
+ const isIdShorthand = typeof paramA === "string";
541
+ const enumVal = isIdShorthand ? paramB : paramA;
542
+ const meta = isIdShorthand ? { id: paramA } : paramB;
523
543
  const isType = (input) => {
524
544
  if (typeof input !== "string") {
525
545
  return false;
526
546
  }
527
- for (const val of paramA) {
547
+ for (const val of enumVal) {
528
548
  if (val === input) {
529
549
  return true;
530
550
  }
531
551
  }
532
552
  return false;
533
553
  };
534
- const isIdShorthand = typeof paramA === "string";
535
- const enumVal = isIdShorthand ? paramB : paramA;
536
- const meta = isIdShorthand ? { id: paramA } : paramB;
537
554
  return {
538
555
  enum: enumVal,
539
556
  metadata: {
@@ -689,23 +706,6 @@ function clone(input, opts = {}) {
689
706
  return schema;
690
707
  }
691
708
 
692
- const int8Min = -128;
693
- const int8Max = 127;
694
- const uint8Min = 0;
695
- const uint8Max = 255;
696
- const int16Min = -32768;
697
- const int16Max = 32767;
698
- const uint16Min = 0;
699
- const uint16Max = 65535;
700
- const int32Min = -2147483648;
701
- const int32Max = 2147483647;
702
- const uint32Min = 0;
703
- const uint32Max = 4294967295;
704
- const int64Min = BigInt("-9223372036854775808");
705
- const int64Max = BigInt("9223372036854775807");
706
- const uint64Min = BigInt("0");
707
- const uint64Max = BigInt("18446744073709551615");
708
-
709
709
  function number(opts = {}) {
710
710
  return float64(opts);
711
711
  }
@@ -725,14 +725,14 @@ function coerceNumber(input, options) {
725
725
  return parseNumber(input, options);
726
726
  }
727
727
  function float32(opts = {}) {
728
- return numberScalarType("float32", opts, (input) => {
728
+ return numberScalarType("float32", opts, () => {
729
729
  return {
730
730
  success: true
731
731
  };
732
732
  });
733
733
  }
734
734
  function float64(opts = {}) {
735
- return numberScalarType("float64", opts, (input) => {
735
+ return numberScalarType("float64", opts, () => {
736
736
  return {
737
737
  success: true
738
738
  };
@@ -940,7 +940,7 @@ function validateNumber(input) {
940
940
  function validateInt(input, minVal, maxValue) {
941
941
  return Number.isInteger(input) && input >= minVal && input <= maxValue;
942
942
  }
943
- function serializeNumber(input, data) {
943
+ function serializeNumber(input, _data) {
944
944
  return input.toString();
945
945
  }
946
946
  function parseNumber(input, options) {
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- const timestamp = require('./shared/schema.34cb5fb7.cjs');
4
3
  require('jtd-utils');
5
4
  require('scule');
5
+ const timestamp = require('./shared/schema.4c9064ee.cjs');
6
6
 
7
7
  const User = timestamp.object({
8
8
  id: timestamp.string(),
@@ -1,4 +1,4 @@
1
- import { d as AObjectSchema, e as ADiscriminatorSchema, a as ASchema } from './shared/schema.b7c77149.cjs';
1
+ import { d as AObjectSchema, e as ADiscriminatorSchema, A as ASchema } from './shared/schema.7414d46a.cjs';
2
2
  import 'jtd-utils';
3
3
 
4
4
  type RecursiveUnion = {
@@ -1,4 +1,4 @@
1
- import { d as AObjectSchema, e as ADiscriminatorSchema, a as ASchema } from './shared/schema.b7c77149.mjs';
1
+ import { d as AObjectSchema, e as ADiscriminatorSchema, A as ASchema } from './shared/schema.7414d46a.mjs';
2
2
  import 'jtd-utils';
3
3
 
4
4
  type RecursiveUnion = {
@@ -1,4 +1,4 @@
1
- import { d as AObjectSchema, e as ADiscriminatorSchema, a as ASchema } from './shared/schema.b7c77149.js';
1
+ import { d as AObjectSchema, e as ADiscriminatorSchema, A as ASchema } from './shared/schema.7414d46a.js';
2
2
  import 'jtd-utils';
3
3
 
4
4
  type RecursiveUnion = {
@@ -1,6 +1,6 @@
1
- import { K as object, W as string, M as optional, I as nullable, F as int32, z as discriminator, w as boolean, X as stringEnum, v as array, Y as timestamp, _ as uint32, t as any, J as number, Q as record, R as recursive, D as float64, C as float32, G as int64, E as int16, Z as uint16, H as int8, a0 as uint8, O as partial, $ as uint64, P as pick, A as enumerator } from './shared/schema.66772201.mjs';
2
1
  import 'jtd-utils';
3
2
  import 'scule';
3
+ import { K as object, W as string, M as optional, I as nullable, F as int32, z as discriminator, w as boolean, X as stringEnum, v as array, Y as timestamp, _ as uint32, t as any, J as number, Q as record, R as recursive, D as float64, C as float32, G as int64, E as int16, Z as uint16, H as int8, a0 as uint8, O as partial, $ as uint64, P as pick, A as enumerator } from './shared/schema.79ea38f8.mjs';
4
4
 
5
5
  const User = object({
6
6
  id: string(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arrirpc/schema",
3
- "version": "0.45.4",
3
+ "version": "0.45.6",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -24,11 +24,11 @@
24
24
  "dependencies": {
25
25
  "scule": "^1.3.0",
26
26
  "uncrypto": "^0.1.3",
27
- "jtd-utils": "0.45.4"
27
+ "jtd-utils": "0.45.6"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@faker-js/faker": "^8.4.1",
31
- "ajv": "^8.13.0",
31
+ "ajv": "^8.14.0",
32
32
  "benny": "^3.7.1"
33
33
  }
34
34
  }