@arrirpc/schema 0.69.2 → 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 +139 -137
- package/dist/index.cjs +59 -51
- package/dist/index.d.cts +20 -11
- package/dist/index.d.mts +20 -11
- package/dist/index.d.ts +20 -11
- package/dist/index.mjs +36 -32
- package/dist/shared/{schema.4e2863ed.cjs → schema.BcsXcrqv.cjs} +479 -349
- package/dist/shared/{schema.cdac4a20.d.ts → schema.DLX0nTwB.d.cts} +5 -4
- package/dist/shared/{schema.cdac4a20.d.cts → schema.DLX0nTwB.d.mts} +5 -4
- package/dist/shared/{schema.cdac4a20.d.mts → schema.DLX0nTwB.d.ts} +5 -4
- package/dist/shared/{schema.25b78dac.mjs → schema.O5uzRO_D.mjs} +470 -344
- package/dist/testSuites.cjs +11 -11
- package/dist/testSuites.d.cts +7 -6
- package/dist/testSuites.d.mts +7 -6
- package/dist/testSuites.d.ts +7 -6
- package/dist/testSuites.mjs +11 -11
- package/package.json +4 -3
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { isSchemaFormProperties, isSchemaFormValues, isSchemaFormElements, isSchemaFormDiscriminator, isSchemaFormEmpty, isSchemaFormType, isSchemaFormEnum, isSchemaFormRef } from '
|
|
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);
|
|
@@ -1409,7 +1407,6 @@ function compile(schema) {
|
|
|
1409
1407
|
};
|
|
1410
1408
|
}
|
|
1411
1409
|
},
|
|
1412
|
-
// eslint-disable-next-line no-eval
|
|
1413
1410
|
serialize(input) {
|
|
1414
1411
|
try {
|
|
1415
1412
|
return serializeFn(input);
|
|
@@ -1426,8 +1423,10 @@ function compile(schema) {
|
|
|
1426
1423
|
validate: validateCode,
|
|
1427
1424
|
parse: parser.code,
|
|
1428
1425
|
serialize: serializer.code
|
|
1429
|
-
}
|
|
1426
|
+
},
|
|
1427
|
+
"~standard": createStandardSchemaProperty(validate, parse)
|
|
1430
1428
|
};
|
|
1429
|
+
return result;
|
|
1431
1430
|
}
|
|
1432
1431
|
function getCompiledParser(input, schema) {
|
|
1433
1432
|
const code = createParsingTemplate(input, schema);
|
|
@@ -2134,7 +2133,7 @@ function isAdaptedSchema(input) {
|
|
|
2134
2133
|
return input.metadata[SCHEMA_METADATA]._isAdapted === true;
|
|
2135
2134
|
}
|
|
2136
2135
|
function validatorFromAdaptedSchema(schema) {
|
|
2137
|
-
|
|
2136
|
+
const result = {
|
|
2138
2137
|
compiledCode: {
|
|
2139
2138
|
parse: "",
|
|
2140
2139
|
serialize: "",
|
|
@@ -2156,13 +2155,13 @@ function validatorFromAdaptedSchema(schema) {
|
|
|
2156
2155
|
errors: []
|
|
2157
2156
|
};
|
|
2158
2157
|
try {
|
|
2159
|
-
const
|
|
2158
|
+
const result2 = schema.metadata[SCHEMA_METADATA].parse(
|
|
2160
2159
|
input,
|
|
2161
2160
|
context
|
|
2162
2161
|
);
|
|
2163
2162
|
return {
|
|
2164
2163
|
success: true,
|
|
2165
|
-
value:
|
|
2164
|
+
value: result2
|
|
2166
2165
|
};
|
|
2167
2166
|
} catch (err) {
|
|
2168
2167
|
if (err instanceof ValidationError) {
|
|
@@ -2187,8 +2186,13 @@ function validatorFromAdaptedSchema(schema) {
|
|
|
2187
2186
|
errors: []
|
|
2188
2187
|
};
|
|
2189
2188
|
return schema.metadata[SCHEMA_METADATA].serialize(input, context);
|
|
2190
|
-
}
|
|
2189
|
+
},
|
|
2190
|
+
"~standard": createStandardSchemaProperty(
|
|
2191
|
+
schema.metadata[SCHEMA_METADATA].validate,
|
|
2192
|
+
schema.metadata[SCHEMA_METADATA].parse
|
|
2193
|
+
)
|
|
2191
2194
|
};
|
|
2195
|
+
return result;
|
|
2192
2196
|
}
|
|
2193
2197
|
|
|
2194
|
-
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 };
|