@arrirpc/schema 0.58.0 → 0.59.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/dist/index.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  const jtdUtils = require('jtd-utils');
4
4
  const scule = require('scule');
5
- const timestamp = require('./shared/schema.05b481fe.cjs');
5
+ const timestamp = require('./shared/schema.78a649a7.cjs');
6
6
 
7
7
  function createParsingTemplate(input, schema) {
8
8
  const fallbackTemplate = `
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { isSchemaFormProperties, isSchemaFormValues, isSchemaFormElements, isSchemaFormDiscriminator, isSchemaFormEmpty, isSchemaFormType, isSchemaFormEnum, isSchemaFormRef } from 'jtd-utils';
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 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 SCHEMA_METADATA } from './shared/schema.c92354cc.mjs';
4
- export { ae as NumberTypeValues, a4 as int64Max, a3 as int64Min, ad as isASchema, af as isObject, ac as isValidationError, a7 as parseObjectSchema, ab as sanitizeJson, a9 as serializeObject, aa as serializeSmallString, a6 as uint64Max, a5 as uint64Min, a8 as validateObjectSchema } from './shared/schema.c92354cc.mjs';
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 SCHEMA_METADATA } from './shared/schema.31273dd5.mjs';
4
+ export { ae as NumberTypeValues, a4 as int64Max, a3 as int64Min, ad as isASchema, af as isObject, ac as isValidationError, a7 as parseObjectSchema, ab as sanitizeJson, a9 as serializeObject, aa as serializeSmallString, a6 as uint64Max, a5 as uint64Min, a8 as validateObjectSchema } from './shared/schema.31273dd5.mjs';
5
5
 
6
6
  function createParsingTemplate(input, schema) {
7
7
  const fallbackTemplate = `
@@ -1041,9 +1041,11 @@ function object(propA, propB) {
1041
1041
  const input = isIdShorthand ? propB : propA;
1042
1042
  const options = isIdShorthand ? { id: propA } : propB ?? {};
1043
1043
  const schema = {
1044
- properties: {},
1045
- strict: options.strict
1044
+ properties: {}
1046
1045
  };
1046
+ if (typeof options.strict === "boolean") {
1047
+ schema.strict = options.strict;
1048
+ }
1047
1049
  for (const key of Object.keys(input)) {
1048
1050
  const prop = input[key];
1049
1051
  if (prop.metadata[SCHEMA_METADATA].optional) {
@@ -1205,9 +1207,11 @@ function validateObjectSchema(schema, input) {
1205
1207
  function pick(inputSchema, keys, options = {}) {
1206
1208
  const schema = {
1207
1209
  properties: {},
1208
- nullable: inputSchema.nullable,
1209
- strict: options.strict
1210
+ nullable: inputSchema.nullable
1210
1211
  };
1212
+ if (typeof options.strict === "boolean") {
1213
+ schema.strict = options.strict;
1214
+ }
1211
1215
  Object.keys(inputSchema.properties).forEach((key) => {
1212
1216
  if (!schema.properties) {
1213
1217
  return;
@@ -1266,9 +1270,11 @@ function omit(inputSchema, keys, options = {}) {
1266
1270
  properties: {
1267
1271
  ...inputSchema.properties
1268
1272
  },
1269
- nullable: inputSchema.nullable,
1270
- strict: options.strict
1273
+ nullable: inputSchema.nullable
1271
1274
  };
1275
+ if (typeof options.strict === "boolean") {
1276
+ schema.strict = options.strict;
1277
+ }
1272
1278
  Object.keys(inputSchema.properties).forEach((key) => {
1273
1279
  if (keys.includes(key)) {
1274
1280
  delete schema.properties[key];
@@ -1362,9 +1368,11 @@ function extend(baseSchema, inputSchema, options = {}) {
1362
1368
  optionalProperties: {
1363
1369
  ...baseSchema.optionalProperties,
1364
1370
  ...inputSchema.optionalProperties
1365
- },
1366
- strict: options.strict
1371
+ }
1367
1372
  };
1373
+ if (typeof options.strict === "boolean") {
1374
+ schema.strict = options.strict;
1375
+ }
1368
1376
  const isType = (input) => validateObjectSchema(schema, input);
1369
1377
  const meta = {
1370
1378
  id: options.id,
@@ -1390,9 +1398,11 @@ function partial(schema, options = {}) {
1390
1398
  const newSchema = {
1391
1399
  properties: {},
1392
1400
  optionalProperties: {},
1393
- strict: options.strict,
1394
1401
  nullable: schema.nullable
1395
1402
  };
1403
+ if (typeof options.strict === "boolean") {
1404
+ schema.strict = options.strict;
1405
+ }
1396
1406
  for (const key of Object.keys(schema.properties)) {
1397
1407
  const prop = schema.properties[key];
1398
1408
  newSchema.optionalProperties[key] = optional(prop);
@@ -1043,9 +1043,11 @@ function object(propA, propB) {
1043
1043
  const input = isIdShorthand ? propB : propA;
1044
1044
  const options = isIdShorthand ? { id: propA } : propB ?? {};
1045
1045
  const schema = {
1046
- properties: {},
1047
- strict: options.strict
1046
+ properties: {}
1048
1047
  };
1048
+ if (typeof options.strict === "boolean") {
1049
+ schema.strict = options.strict;
1050
+ }
1049
1051
  for (const key of Object.keys(input)) {
1050
1052
  const prop = input[key];
1051
1053
  if (prop.metadata[SCHEMA_METADATA].optional) {
@@ -1207,9 +1209,11 @@ function validateObjectSchema(schema, input) {
1207
1209
  function pick(inputSchema, keys, options = {}) {
1208
1210
  const schema = {
1209
1211
  properties: {},
1210
- nullable: inputSchema.nullable,
1211
- strict: options.strict
1212
+ nullable: inputSchema.nullable
1212
1213
  };
1214
+ if (typeof options.strict === "boolean") {
1215
+ schema.strict = options.strict;
1216
+ }
1213
1217
  Object.keys(inputSchema.properties).forEach((key) => {
1214
1218
  if (!schema.properties) {
1215
1219
  return;
@@ -1268,9 +1272,11 @@ function omit(inputSchema, keys, options = {}) {
1268
1272
  properties: {
1269
1273
  ...inputSchema.properties
1270
1274
  },
1271
- nullable: inputSchema.nullable,
1272
- strict: options.strict
1275
+ nullable: inputSchema.nullable
1273
1276
  };
1277
+ if (typeof options.strict === "boolean") {
1278
+ schema.strict = options.strict;
1279
+ }
1274
1280
  Object.keys(inputSchema.properties).forEach((key) => {
1275
1281
  if (keys.includes(key)) {
1276
1282
  delete schema.properties[key];
@@ -1364,9 +1370,11 @@ function extend(baseSchema, inputSchema, options = {}) {
1364
1370
  optionalProperties: {
1365
1371
  ...baseSchema.optionalProperties,
1366
1372
  ...inputSchema.optionalProperties
1367
- },
1368
- strict: options.strict
1373
+ }
1369
1374
  };
1375
+ if (typeof options.strict === "boolean") {
1376
+ schema.strict = options.strict;
1377
+ }
1370
1378
  const isType = (input) => validateObjectSchema(schema, input);
1371
1379
  const meta = {
1372
1380
  id: options.id,
@@ -1392,9 +1400,11 @@ function partial(schema, options = {}) {
1392
1400
  const newSchema = {
1393
1401
  properties: {},
1394
1402
  optionalProperties: {},
1395
- strict: options.strict,
1396
1403
  nullable: schema.nullable
1397
1404
  };
1405
+ if (typeof options.strict === "boolean") {
1406
+ schema.strict = options.strict;
1407
+ }
1398
1408
  for (const key of Object.keys(schema.properties)) {
1399
1409
  const prop = schema.properties[key];
1400
1410
  newSchema.optionalProperties[key] = optional(prop);
@@ -2,7 +2,7 @@
2
2
 
3
3
  require('jtd-utils');
4
4
  require('scule');
5
- const timestamp = require('./shared/schema.05b481fe.cjs');
5
+ const timestamp = require('./shared/schema.78a649a7.cjs');
6
6
 
7
7
  const User = timestamp.object({
8
8
  id: timestamp.string(),
@@ -1,6 +1,6 @@
1
1
  import 'jtd-utils';
2
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.c92354cc.mjs';
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.31273dd5.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.58.0",
3
+ "version": "0.59.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -24,7 +24,7 @@
24
24
  "dependencies": {
25
25
  "scule": "^1.3.0",
26
26
  "uncrypto": "^0.1.3",
27
- "jtd-utils": "0.58.0"
27
+ "jtd-utils": "0.59.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@faker-js/faker": "^8.4.1",