@arrirpc/schema 0.70.1 → 0.71.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 +41 -39
- package/dist/index.cjs +35 -28
- package/dist/index.d.cts +17 -10
- package/dist/index.d.mts +17 -10
- package/dist/index.d.ts +17 -10
- package/dist/index.mjs +35 -30
- package/dist/shared/{schema.TlNJgMz1.cjs → schema.BcsXcrqv.cjs} +380 -256
- package/dist/shared/{schema.C-0ZU_OQ.d.cts → schema.DLX0nTwB.d.cts} +4 -3
- package/dist/shared/{schema.C-0ZU_OQ.d.mts → schema.DLX0nTwB.d.mts} +4 -3
- package/dist/shared/{schema.C-0ZU_OQ.d.ts → schema.DLX0nTwB.d.ts} +4 -3
- package/dist/shared/{schema.lowJcmic.mjs → schema.O5uzRO_D.mjs} +379 -257
- package/dist/testSuites.cjs +10 -10
- package/dist/testSuites.d.cts +6 -5
- package/dist/testSuites.d.mts +6 -5
- package/dist/testSuites.d.ts +6 -5
- package/dist/testSuites.mjs +10 -10
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isSchemaFormProperties, isSchemaFormValues, isSchemaFormElements, isSchemaFormDiscriminator, isSchemaFormEmpty, isSchemaFormType, isSchemaFormEnum, isSchemaFormRef } from '@arrirpc/type-defs';
|
|
2
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
|
|
4
|
-
export {
|
|
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 createStandardSchemaProperty, v as any, w as array, x as boolean, y as clone, z as coerce, A as discriminator, B as enumerator, C as extend, D as float32, E as float64, F as int16, G as int32, H as int64, I as int8, J as nullable, K as number, L as object, M as omit, N as optional, O as parse, P as partial, Q as pick, R as record, S as recursive, T as safeCoerce, U as safeParse, W as serialize, X as string, Y as stringEnum, Z as timestamp, _ as uint16, $ as uint32, a0 as uint64, a1 as uint8, a2 as validate, a3 as SCHEMA_METADATA } from './shared/schema.O5uzRO_D.mjs';
|
|
4
|
+
export { ah as NumberTypeValues, ac as STR_ESCAPE, aj as hideInvalidProperties, a5 as int64Max, a4 as int64Min, ag as isASchema, ai as isObject, af as isValidationError, a8 as parseObjectSchema, ae as sanitizeJson, aa as serializeObject, ad as serializeSmallString, ab as serializeString, a7 as uint64Max, a6 as uint64Min, a9 as validateObjectSchema } from './shared/schema.O5uzRO_D.mjs';
|
|
5
5
|
|
|
6
6
|
function createParsingTemplate(input, schema) {
|
|
7
7
|
const fallbackTemplate = `
|
|
@@ -1366,33 +1366,31 @@ function compile(schema) {
|
|
|
1366
1366
|
const parseFn = parser.fn;
|
|
1367
1367
|
const serializer = getCompiledSerializer(schema);
|
|
1368
1368
|
const serializeFn = serializer.fn;
|
|
1369
|
-
const validate = new Function(
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
} catch (err) {
|
|
1379
|
-
const errors$1 = errors(schema, input);
|
|
1380
|
-
let errorMessage = err instanceof Error ? err.message : "";
|
|
1381
|
-
if (errors$1.length) {
|
|
1382
|
-
errorMessage = errors$1[0].message ?? `Parsing error at ${errors$1[0].instancePath}`;
|
|
1383
|
-
}
|
|
1384
|
-
throw new ValidationError({
|
|
1385
|
-
message: errorMessage,
|
|
1386
|
-
errors: errors$1
|
|
1387
|
-
});
|
|
1369
|
+
const validate = new Function("input", validateCode);
|
|
1370
|
+
const parse = (input) => {
|
|
1371
|
+
try {
|
|
1372
|
+
return parseFn(input);
|
|
1373
|
+
} catch (err) {
|
|
1374
|
+
const errors$1 = errors(schema, input);
|
|
1375
|
+
let errorMessage = err instanceof Error ? err.message : "";
|
|
1376
|
+
if (errors$1.length) {
|
|
1377
|
+
errorMessage = errors$1[0].message ?? `Parsing error at ${errors$1[0].instancePath}`;
|
|
1388
1378
|
}
|
|
1389
|
-
|
|
1379
|
+
throw new ValidationError({
|
|
1380
|
+
message: errorMessage,
|
|
1381
|
+
errors: errors$1
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
};
|
|
1385
|
+
const result = {
|
|
1386
|
+
validate,
|
|
1387
|
+
parse,
|
|
1390
1388
|
safeParse(input) {
|
|
1391
1389
|
try {
|
|
1392
|
-
const
|
|
1390
|
+
const result2 = parseFn(input);
|
|
1393
1391
|
return {
|
|
1394
1392
|
success: true,
|
|
1395
|
-
value:
|
|
1393
|
+
value: result2
|
|
1396
1394
|
};
|
|
1397
1395
|
} catch (err) {
|
|
1398
1396
|
const errors$1 = errors(schema, input);
|
|
@@ -1425,8 +1423,10 @@ function compile(schema) {
|
|
|
1425
1423
|
validate: validateCode,
|
|
1426
1424
|
parse: parser.code,
|
|
1427
1425
|
serialize: serializer.code
|
|
1428
|
-
}
|
|
1426
|
+
},
|
|
1427
|
+
"~standard": createStandardSchemaProperty(validate, parse)
|
|
1429
1428
|
};
|
|
1429
|
+
return result;
|
|
1430
1430
|
}
|
|
1431
1431
|
function getCompiledParser(input, schema) {
|
|
1432
1432
|
const code = createParsingTemplate(input, schema);
|
|
@@ -2133,7 +2133,7 @@ function isAdaptedSchema(input) {
|
|
|
2133
2133
|
return input.metadata[SCHEMA_METADATA]._isAdapted === true;
|
|
2134
2134
|
}
|
|
2135
2135
|
function validatorFromAdaptedSchema(schema) {
|
|
2136
|
-
|
|
2136
|
+
const result = {
|
|
2137
2137
|
compiledCode: {
|
|
2138
2138
|
parse: "",
|
|
2139
2139
|
serialize: "",
|
|
@@ -2155,13 +2155,13 @@ function validatorFromAdaptedSchema(schema) {
|
|
|
2155
2155
|
errors: []
|
|
2156
2156
|
};
|
|
2157
2157
|
try {
|
|
2158
|
-
const
|
|
2158
|
+
const result2 = schema.metadata[SCHEMA_METADATA].parse(
|
|
2159
2159
|
input,
|
|
2160
2160
|
context
|
|
2161
2161
|
);
|
|
2162
2162
|
return {
|
|
2163
2163
|
success: true,
|
|
2164
|
-
value:
|
|
2164
|
+
value: result2
|
|
2165
2165
|
};
|
|
2166
2166
|
} catch (err) {
|
|
2167
2167
|
if (err instanceof ValidationError) {
|
|
@@ -2186,8 +2186,13 @@ function validatorFromAdaptedSchema(schema) {
|
|
|
2186
2186
|
errors: []
|
|
2187
2187
|
};
|
|
2188
2188
|
return schema.metadata[SCHEMA_METADATA].serialize(input, context);
|
|
2189
|
-
}
|
|
2189
|
+
},
|
|
2190
|
+
"~standard": createStandardSchemaProperty(
|
|
2191
|
+
schema.metadata[SCHEMA_METADATA].validate,
|
|
2192
|
+
schema.metadata[SCHEMA_METADATA].parse
|
|
2193
|
+
)
|
|
2190
2194
|
};
|
|
2195
|
+
return result;
|
|
2191
2196
|
}
|
|
2192
2197
|
|
|
2193
|
-
export { SCHEMA_METADATA, ValidationError, _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, int8, int8Max, int8Min, isAAraySchema, isADiscriminatorSchema, isAObjectSchema, isARecordSchema, isARefSchema, isAScalarSchema, isAStringEnumSchema, isAdaptedSchema, nullable, number, object, omit, optional, parse, partial, pick, record, recursive, safeCoerce, safeParse, serialize, string, stringEnum, timestamp, uint16, uint16Max, uint16Min, uint32, uint32Max, uint32Min, uint64, uint8, uint8Max, uint8Min, validate, validatorFromAdaptedSchema };
|
|
2198
|
+
export { SCHEMA_METADATA, ValidationError, _namespace as a, any, array, boolean, clone, coerce, compile, createStandardSchemaProperty, discriminator, enumerator, errors, extend, float32, float64, getCompiledParser, getCompiledSerializer, createParsingTemplate as getSchemaParsingCode, createSerializationV2Template as getSchemaSerializationCode, createValidationTemplate as getSchemaValidationCode, int16, int16Max, int16Min, int32, int32Max, int32Min, int64, int8, int8Max, int8Min, isAAraySchema, isADiscriminatorSchema, isAObjectSchema, isARecordSchema, isARefSchema, isAScalarSchema, isAStringEnumSchema, isAdaptedSchema, nullable, number, object, omit, optional, parse, partial, pick, record, recursive, safeCoerce, safeParse, serialize, string, stringEnum, timestamp, uint16, uint16Max, uint16Min, uint32, uint32Max, uint32Min, uint64, uint8, uint8Max, uint8Min, validate, validatorFromAdaptedSchema };
|