fastapi-rtk 2.9.1 → 2.9.2

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.
Files changed (57) hide show
  1. package/dist/.bundled/jsonforms/cjs/_virtual/index10.cjs +2 -2
  2. package/dist/.bundled/jsonforms/cjs/_virtual/index6.cjs +2 -2
  3. package/dist/.bundled/jsonforms/cjs/_virtual/index7.cjs +2 -2
  4. package/dist/.bundled/jsonforms/cjs/_virtual/index8.cjs +2 -2
  5. package/dist/.bundled/jsonforms/cjs/_virtual/index9.cjs +2 -2
  6. package/dist/.bundled/jsonforms/esm/_virtual/index10.mjs +2 -2
  7. package/dist/.bundled/jsonforms/esm/_virtual/index6.mjs +2 -2
  8. package/dist/.bundled/jsonforms/esm/_virtual/index7.mjs +2 -2
  9. package/dist/.bundled/jsonforms/esm/_virtual/index8.mjs +2 -2
  10. package/dist/.bundled/jsonforms/esm/_virtual/index9.mjs +2 -2
  11. package/dist/.external/cjs/ajv@8.17.1/ajv/dist/compile/index.cjs +1 -1
  12. package/dist/.external/cjs/ajv@8.17.1/ajv/dist/vocabularies/applicator/index.cjs +1 -1
  13. package/dist/.external/cjs/ajv@8.17.1/ajv/dist/vocabularies/core/index.cjs +1 -1
  14. package/dist/.external/cjs/ajv@8.17.1/ajv/dist/vocabularies/format/index.cjs +1 -1
  15. package/dist/.external/cjs/ajv@8.17.1/ajv/dist/vocabularies/validation/index.cjs +1 -1
  16. package/dist/.external/cjs/html-parse-stringify@3.0.1/html-parse-stringify/dist/html-parse-stringify.module.cjs +1 -1
  17. package/dist/.external/cjs/toposort@2.0.2/toposort/index.cjs +1 -1
  18. package/dist/.external/cjs/yup@1.7.1/yup/index.esm.cjs +788 -1
  19. package/dist/.external/esm/ajv@8.17.1/ajv/dist/compile/index.mjs +1 -1
  20. package/dist/.external/esm/ajv@8.17.1/ajv/dist/vocabularies/applicator/index.mjs +1 -1
  21. package/dist/.external/esm/ajv@8.17.1/ajv/dist/vocabularies/core/index.mjs +1 -1
  22. package/dist/.external/esm/ajv@8.17.1/ajv/dist/vocabularies/format/index.mjs +1 -1
  23. package/dist/.external/esm/ajv@8.17.1/ajv/dist/vocabularies/validation/index.mjs +1 -1
  24. package/dist/.external/esm/html-parse-stringify@3.0.1/html-parse-stringify/dist/html-parse-stringify.module.mjs +1 -1
  25. package/dist/.external/esm/toposort@2.0.2/toposort/index.mjs +1 -1
  26. package/dist/.external/esm/yup@1.7.1/yup/index.esm.mjs +789 -2
  27. package/dist/api/cjs/ApiProvider/utils/getValidationSchema.cjs +3 -3
  28. package/dist/api/cjs/_virtual/_commonjsHelpers.cjs +6 -0
  29. package/dist/api/cjs/_virtual/index.cjs +5 -0
  30. package/dist/api/esm/ApiProvider/utils/getValidationSchema.mjs +4 -3
  31. package/dist/api/esm/_virtual/_commonjsHelpers.mjs +6 -0
  32. package/dist/api/esm/_virtual/index.mjs +5 -0
  33. package/dist/api/lib/ApiProvider/utils/getValidationSchema.d.ts +1 -1
  34. package/dist/contexts/cjs/_virtual/index.cjs +5 -4
  35. package/dist/contexts/cjs/index.cjs +0 -2
  36. package/dist/contexts/esm/_virtual/index.mjs +5 -3
  37. package/dist/contexts/esm/index.mjs +1 -3
  38. package/dist/contexts/lib/index.d.ts +0 -1
  39. package/dist/core/cjs/Tables/DataGrid/Toolbar/Filter/FilterMenu.cjs +9 -8
  40. package/dist/core/cjs/_virtual/_commonjsHelpers.cjs +6 -0
  41. package/dist/core/cjs/_virtual/index6.cjs +4 -2
  42. package/dist/core/cjs/_virtual/index7.cjs +5 -3
  43. package/dist/core/cjs/_virtual/index8.cjs +4 -0
  44. package/dist/core/esm/Tables/DataGrid/Toolbar/Filter/FilterMenu.mjs +9 -8
  45. package/dist/core/esm/_virtual/_commonjsHelpers.mjs +6 -0
  46. package/dist/core/esm/_virtual/index6.mjs +5 -2
  47. package/dist/core/esm/_virtual/index7.mjs +5 -2
  48. package/dist/core/esm/_virtual/index8.mjs +4 -0
  49. package/package.json +1 -1
  50. package/dist/contexts/cjs/_virtual/index5.cjs +0 -6
  51. package/dist/contexts/esm/_virtual/index5.mjs +0 -7
  52. /package/dist/{contexts → api}/cjs/_virtual/index2.cjs +0 -0
  53. /package/dist/{contexts → api}/cjs/_virtual/index3.cjs +0 -0
  54. /package/dist/{contexts → api}/cjs/_virtual/index4.cjs +0 -0
  55. /package/dist/{contexts → api}/esm/_virtual/index2.mjs +0 -0
  56. /package/dist/{contexts → api}/esm/_virtual/index3.mjs +0 -0
  57. /package/dist/{contexts → api}/esm/_virtual/index4.mjs +0 -0
@@ -1,5 +1,6 @@
1
1
  import { p as propertyExprExports } from "../../../../core/esm/_virtual/index5.mjs";
2
- import "../../../../core/esm/_virtual/index6.mjs";
2
+ import { t as tinyCaseExports } from "../../../../core/esm/_virtual/index6.mjs";
3
+ import toposort from "../../../../core/esm/_virtual/index7.mjs";
3
4
  const toString = Object.prototype.toString;
4
5
  const errorToString = Error.prototype.toString;
5
6
  const regExpToString = RegExp.prototype.toString;
@@ -1136,6 +1137,22 @@ for (const method of ["validate", "validateSync"]) Schema.prototype[`${method}At
1136
1137
  };
1137
1138
  for (const alias of ["equals", "is"]) Schema.prototype[alias] = Schema.prototype.oneOf;
1138
1139
  for (const alias of ["not", "nope"]) Schema.prototype[alias] = Schema.prototype.notOneOf;
1140
+ const returnsTrue = () => true;
1141
+ function create$8(spec) {
1142
+ return new MixedSchema(spec);
1143
+ }
1144
+ class MixedSchema extends Schema {
1145
+ constructor(spec) {
1146
+ super(typeof spec === "function" ? {
1147
+ type: "mixed",
1148
+ check: spec
1149
+ } : Object.assign({
1150
+ type: "mixed",
1151
+ check: returnsTrue
1152
+ }, spec));
1153
+ }
1154
+ }
1155
+ create$8.prototype = MixedSchema.prototype;
1139
1156
  const isoReg = /^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;
1140
1157
  function parseIsoDate(date2) {
1141
1158
  const struct = parseDateStruct(date2);
@@ -1175,6 +1192,223 @@ function parseDateStruct(date2) {
1175
1192
  function toNumber(str, defaultValue = 0) {
1176
1193
  return Number(str) || defaultValue;
1177
1194
  }
1195
+ let rEmail = (
1196
+ // eslint-disable-next-line
1197
+ /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
1198
+ );
1199
+ let rUrl = (
1200
+ // eslint-disable-next-line
1201
+ /^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i
1202
+ );
1203
+ let rUUID = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
1204
+ let yearMonthDay = "^\\d{4}-\\d{2}-\\d{2}";
1205
+ let hourMinuteSecond = "\\d{2}:\\d{2}:\\d{2}";
1206
+ let zOrOffset = "(([+-]\\d{2}(:?\\d{2})?)|Z)";
1207
+ let rIsoDateTime = new RegExp(`${yearMonthDay}T${hourMinuteSecond}(\\.\\d+)?${zOrOffset}$`);
1208
+ let isTrimmed = (value) => isAbsent(value) || value === value.trim();
1209
+ let objStringTag = {}.toString();
1210
+ function create$6() {
1211
+ return new StringSchema();
1212
+ }
1213
+ class StringSchema extends Schema {
1214
+ constructor() {
1215
+ super({
1216
+ type: "string",
1217
+ check(value) {
1218
+ if (value instanceof String) value = value.valueOf();
1219
+ return typeof value === "string";
1220
+ }
1221
+ });
1222
+ this.withMutation(() => {
1223
+ this.transform((value, _raw) => {
1224
+ if (!this.spec.coerce || this.isType(value)) return value;
1225
+ if (Array.isArray(value)) return value;
1226
+ const strValue = value != null && value.toString ? value.toString() : value;
1227
+ if (strValue === objStringTag) return value;
1228
+ return strValue;
1229
+ });
1230
+ });
1231
+ }
1232
+ required(message) {
1233
+ return super.required(message).withMutation((schema) => schema.test({
1234
+ message: message || mixed.required,
1235
+ name: "required",
1236
+ skipAbsent: true,
1237
+ test: (value) => !!value.length
1238
+ }));
1239
+ }
1240
+ notRequired() {
1241
+ return super.notRequired().withMutation((schema) => {
1242
+ schema.tests = schema.tests.filter((t) => t.OPTIONS.name !== "required");
1243
+ return schema;
1244
+ });
1245
+ }
1246
+ length(length, message = string.length) {
1247
+ return this.test({
1248
+ message,
1249
+ name: "length",
1250
+ exclusive: true,
1251
+ params: {
1252
+ length
1253
+ },
1254
+ skipAbsent: true,
1255
+ test(value) {
1256
+ return value.length === this.resolve(length);
1257
+ }
1258
+ });
1259
+ }
1260
+ min(min, message = string.min) {
1261
+ return this.test({
1262
+ message,
1263
+ name: "min",
1264
+ exclusive: true,
1265
+ params: {
1266
+ min
1267
+ },
1268
+ skipAbsent: true,
1269
+ test(value) {
1270
+ return value.length >= this.resolve(min);
1271
+ }
1272
+ });
1273
+ }
1274
+ max(max, message = string.max) {
1275
+ return this.test({
1276
+ name: "max",
1277
+ exclusive: true,
1278
+ message,
1279
+ params: {
1280
+ max
1281
+ },
1282
+ skipAbsent: true,
1283
+ test(value) {
1284
+ return value.length <= this.resolve(max);
1285
+ }
1286
+ });
1287
+ }
1288
+ matches(regex, options) {
1289
+ let excludeEmptyString = false;
1290
+ let message;
1291
+ let name;
1292
+ if (options) {
1293
+ if (typeof options === "object") {
1294
+ ({
1295
+ excludeEmptyString = false,
1296
+ message,
1297
+ name
1298
+ } = options);
1299
+ } else {
1300
+ message = options;
1301
+ }
1302
+ }
1303
+ return this.test({
1304
+ name: name || "matches",
1305
+ message: message || string.matches,
1306
+ params: {
1307
+ regex
1308
+ },
1309
+ skipAbsent: true,
1310
+ test: (value) => value === "" && excludeEmptyString || value.search(regex) !== -1
1311
+ });
1312
+ }
1313
+ email(message = string.email) {
1314
+ return this.matches(rEmail, {
1315
+ name: "email",
1316
+ message,
1317
+ excludeEmptyString: true
1318
+ });
1319
+ }
1320
+ url(message = string.url) {
1321
+ return this.matches(rUrl, {
1322
+ name: "url",
1323
+ message,
1324
+ excludeEmptyString: true
1325
+ });
1326
+ }
1327
+ uuid(message = string.uuid) {
1328
+ return this.matches(rUUID, {
1329
+ name: "uuid",
1330
+ message,
1331
+ excludeEmptyString: false
1332
+ });
1333
+ }
1334
+ datetime(options) {
1335
+ let message = "";
1336
+ let allowOffset;
1337
+ let precision;
1338
+ if (options) {
1339
+ if (typeof options === "object") {
1340
+ ({
1341
+ message = "",
1342
+ allowOffset = false,
1343
+ precision = void 0
1344
+ } = options);
1345
+ } else {
1346
+ message = options;
1347
+ }
1348
+ }
1349
+ return this.matches(rIsoDateTime, {
1350
+ name: "datetime",
1351
+ message: message || string.datetime,
1352
+ excludeEmptyString: true
1353
+ }).test({
1354
+ name: "datetime_offset",
1355
+ message: message || string.datetime_offset,
1356
+ params: {
1357
+ allowOffset
1358
+ },
1359
+ skipAbsent: true,
1360
+ test: (value) => {
1361
+ if (!value || allowOffset) return true;
1362
+ const struct = parseDateStruct(value);
1363
+ if (!struct) return false;
1364
+ return !!struct.z;
1365
+ }
1366
+ }).test({
1367
+ name: "datetime_precision",
1368
+ message: message || string.datetime_precision,
1369
+ params: {
1370
+ precision
1371
+ },
1372
+ skipAbsent: true,
1373
+ test: (value) => {
1374
+ if (!value || precision == void 0) return true;
1375
+ const struct = parseDateStruct(value);
1376
+ if (!struct) return false;
1377
+ return struct.precision === precision;
1378
+ }
1379
+ });
1380
+ }
1381
+ //-- transforms --
1382
+ ensure() {
1383
+ return this.default("").transform((val) => val === null ? "" : val);
1384
+ }
1385
+ trim(message = string.trim) {
1386
+ return this.transform((val) => val != null ? val.trim() : val).test({
1387
+ message,
1388
+ name: "trim",
1389
+ test: isTrimmed
1390
+ });
1391
+ }
1392
+ lowercase(message = string.lowercase) {
1393
+ return this.transform((value) => !isAbsent(value) ? value.toLowerCase() : value).test({
1394
+ message,
1395
+ name: "string_case",
1396
+ exclusive: true,
1397
+ skipAbsent: true,
1398
+ test: (value) => isAbsent(value) || value === value.toLowerCase()
1399
+ });
1400
+ }
1401
+ uppercase(message = string.uppercase) {
1402
+ return this.transform((value) => !isAbsent(value) ? value.toUpperCase() : value).test({
1403
+ message,
1404
+ name: "string_case",
1405
+ exclusive: true,
1406
+ skipAbsent: true,
1407
+ test: (value) => isAbsent(value) || value === value.toUpperCase()
1408
+ });
1409
+ }
1410
+ }
1411
+ create$6.prototype = StringSchema.prototype;
1178
1412
  let invalidDate = /* @__PURE__ */ new Date("");
1179
1413
  let isDate = (obj) => Object.prototype.toString.call(obj) === "[object Date]";
1180
1414
  class DateSchema extends Schema {
@@ -1236,11 +1470,564 @@ class DateSchema extends Schema {
1236
1470
  }
1237
1471
  }
1238
1472
  DateSchema.INVALID_DATE = invalidDate;
1473
+ function sortFields(fields, excludedEdges = []) {
1474
+ let edges = [];
1475
+ let nodes = /* @__PURE__ */ new Set();
1476
+ let excludes = new Set(excludedEdges.map(([a, b]) => `${a}-${b}`));
1477
+ function addNode(depPath, key) {
1478
+ let node = propertyExprExports.split(depPath)[0];
1479
+ nodes.add(node);
1480
+ if (!excludes.has(`${key}-${node}`)) edges.push([key, node]);
1481
+ }
1482
+ for (const key of Object.keys(fields)) {
1483
+ let value = fields[key];
1484
+ nodes.add(key);
1485
+ if (Reference.isRef(value) && value.isSibling) addNode(value.path, key);
1486
+ else if (isSchema(value) && "deps" in value) value.deps.forEach((path) => addNode(path, key));
1487
+ }
1488
+ return toposort.array(Array.from(nodes), edges).reverse();
1489
+ }
1490
+ function findIndex(arr, err) {
1491
+ let idx = Infinity;
1492
+ arr.some((key, ii) => {
1493
+ var _err$path;
1494
+ if ((_err$path = err.path) != null && _err$path.includes(key)) {
1495
+ idx = ii;
1496
+ return true;
1497
+ }
1498
+ });
1499
+ return idx;
1500
+ }
1501
+ function sortByKeyOrder(keys) {
1502
+ return (a, b) => {
1503
+ return findIndex(keys, a) - findIndex(keys, b);
1504
+ };
1505
+ }
1506
+ const parseJson = (value, _, schema) => {
1507
+ if (typeof value !== "string") {
1508
+ return value;
1509
+ }
1510
+ let parsed = value;
1511
+ try {
1512
+ parsed = JSON.parse(value);
1513
+ } catch (err) {
1514
+ }
1515
+ return schema.isType(parsed) ? parsed : value;
1516
+ };
1517
+ function deepPartial(schema) {
1518
+ if ("fields" in schema) {
1519
+ const partial = {};
1520
+ for (const [key, fieldSchema] of Object.entries(schema.fields)) {
1521
+ partial[key] = deepPartial(fieldSchema);
1522
+ }
1523
+ return schema.setFields(partial);
1524
+ }
1525
+ if (schema.type === "array") {
1526
+ const nextArray = schema.optional();
1527
+ if (nextArray.innerType) nextArray.innerType = deepPartial(nextArray.innerType);
1528
+ return nextArray;
1529
+ }
1530
+ if (schema.type === "tuple") {
1531
+ return schema.optional().clone({
1532
+ types: schema.spec.types.map(deepPartial)
1533
+ });
1534
+ }
1535
+ if ("optional" in schema) {
1536
+ return schema.optional();
1537
+ }
1538
+ return schema;
1539
+ }
1540
+ const deepHas = (obj, p) => {
1541
+ const path = [...propertyExprExports.normalizePath(p)];
1542
+ if (path.length === 1) return path[0] in obj;
1543
+ let last = path.pop();
1544
+ let parent = propertyExprExports.getter(propertyExprExports.join(path), true)(obj);
1545
+ return !!(parent && last in parent);
1546
+ };
1547
+ let isObject = (obj) => Object.prototype.toString.call(obj) === "[object Object]";
1548
+ function unknown(ctx, value) {
1549
+ let known = Object.keys(ctx.fields);
1550
+ return Object.keys(value).filter((key) => known.indexOf(key) === -1);
1551
+ }
1552
+ const defaultSort = sortByKeyOrder([]);
1553
+ function create$3(spec) {
1554
+ return new ObjectSchema(spec);
1555
+ }
1556
+ class ObjectSchema extends Schema {
1557
+ constructor(spec) {
1558
+ super({
1559
+ type: "object",
1560
+ check(value) {
1561
+ return isObject(value) || typeof value === "function";
1562
+ }
1563
+ });
1564
+ this.fields = /* @__PURE__ */ Object.create(null);
1565
+ this._sortErrors = defaultSort;
1566
+ this._nodes = [];
1567
+ this._excludedEdges = [];
1568
+ this.withMutation(() => {
1569
+ if (spec) {
1570
+ this.shape(spec);
1571
+ }
1572
+ });
1573
+ }
1574
+ _cast(_value, options = {}) {
1575
+ var _options$stripUnknown;
1576
+ let value = super._cast(_value, options);
1577
+ if (value === void 0) return this.getDefault(options);
1578
+ if (!this._typeCheck(value)) return value;
1579
+ let fields = this.fields;
1580
+ let strip = (_options$stripUnknown = options.stripUnknown) != null ? _options$stripUnknown : this.spec.noUnknown;
1581
+ let props = [].concat(this._nodes, Object.keys(value).filter((v) => !this._nodes.includes(v)));
1582
+ let intermediateValue = {};
1583
+ let innerOptions = Object.assign({}, options, {
1584
+ parent: intermediateValue,
1585
+ __validating: options.__validating || false
1586
+ });
1587
+ let isChanged = false;
1588
+ for (const prop of props) {
1589
+ let field = fields[prop];
1590
+ let exists = prop in value;
1591
+ let inputValue = value[prop];
1592
+ if (field) {
1593
+ let fieldValue;
1594
+ innerOptions.path = (options.path ? `${options.path}.` : "") + prop;
1595
+ field = field.resolve({
1596
+ value: inputValue,
1597
+ context: options.context,
1598
+ parent: intermediateValue
1599
+ });
1600
+ let fieldSpec = field instanceof Schema ? field.spec : void 0;
1601
+ let strict = fieldSpec == null ? void 0 : fieldSpec.strict;
1602
+ if (fieldSpec != null && fieldSpec.strip) {
1603
+ isChanged = isChanged || prop in value;
1604
+ continue;
1605
+ }
1606
+ fieldValue = !options.__validating || !strict ? field.cast(inputValue, innerOptions) : inputValue;
1607
+ if (fieldValue !== void 0) {
1608
+ intermediateValue[prop] = fieldValue;
1609
+ }
1610
+ } else if (exists && !strip) {
1611
+ intermediateValue[prop] = inputValue;
1612
+ }
1613
+ if (exists !== prop in intermediateValue || intermediateValue[prop] !== inputValue) {
1614
+ isChanged = true;
1615
+ }
1616
+ }
1617
+ return isChanged ? intermediateValue : value;
1618
+ }
1619
+ _validate(_value, options = {}, panic, next) {
1620
+ let {
1621
+ from = [],
1622
+ originalValue = _value,
1623
+ recursive = this.spec.recursive
1624
+ } = options;
1625
+ options.from = [{
1626
+ schema: this,
1627
+ value: originalValue
1628
+ }, ...from];
1629
+ options.__validating = true;
1630
+ options.originalValue = originalValue;
1631
+ super._validate(_value, options, panic, (objectErrors, value) => {
1632
+ if (!recursive || !isObject(value)) {
1633
+ next(objectErrors, value);
1634
+ return;
1635
+ }
1636
+ originalValue = originalValue || value;
1637
+ let tests = [];
1638
+ for (let key of this._nodes) {
1639
+ let field = this.fields[key];
1640
+ if (!field || Reference.isRef(field)) {
1641
+ continue;
1642
+ }
1643
+ tests.push(field.asNestedTest({
1644
+ options,
1645
+ key,
1646
+ parent: value,
1647
+ parentPath: options.path,
1648
+ originalParent: originalValue
1649
+ }));
1650
+ }
1651
+ this.runTests({
1652
+ tests,
1653
+ value,
1654
+ originalValue,
1655
+ options
1656
+ }, panic, (fieldErrors) => {
1657
+ next(fieldErrors.sort(this._sortErrors).concat(objectErrors), value);
1658
+ });
1659
+ });
1660
+ }
1661
+ clone(spec) {
1662
+ const next = super.clone(spec);
1663
+ next.fields = Object.assign({}, this.fields);
1664
+ next._nodes = this._nodes;
1665
+ next._excludedEdges = this._excludedEdges;
1666
+ next._sortErrors = this._sortErrors;
1667
+ return next;
1668
+ }
1669
+ concat(schema) {
1670
+ let next = super.concat(schema);
1671
+ let nextFields = next.fields;
1672
+ for (let [field, schemaOrRef] of Object.entries(this.fields)) {
1673
+ const target = nextFields[field];
1674
+ nextFields[field] = target === void 0 ? schemaOrRef : target;
1675
+ }
1676
+ return next.withMutation((s) => (
1677
+ // XXX: excludes here is wrong
1678
+ s.setFields(nextFields, [...this._excludedEdges, ...schema._excludedEdges])
1679
+ ));
1680
+ }
1681
+ _getDefault(options) {
1682
+ if ("default" in this.spec) {
1683
+ return super._getDefault(options);
1684
+ }
1685
+ if (!this._nodes.length) {
1686
+ return void 0;
1687
+ }
1688
+ let dft = {};
1689
+ this._nodes.forEach((key) => {
1690
+ var _innerOptions;
1691
+ const field = this.fields[key];
1692
+ let innerOptions = options;
1693
+ if ((_innerOptions = innerOptions) != null && _innerOptions.value) {
1694
+ innerOptions = Object.assign({}, innerOptions, {
1695
+ parent: innerOptions.value,
1696
+ value: innerOptions.value[key]
1697
+ });
1698
+ }
1699
+ dft[key] = field && "getDefault" in field ? field.getDefault(innerOptions) : void 0;
1700
+ });
1701
+ return dft;
1702
+ }
1703
+ setFields(shape, excludedEdges) {
1704
+ let next = this.clone();
1705
+ next.fields = shape;
1706
+ next._nodes = sortFields(shape, excludedEdges);
1707
+ next._sortErrors = sortByKeyOrder(Object.keys(shape));
1708
+ if (excludedEdges) next._excludedEdges = excludedEdges;
1709
+ return next;
1710
+ }
1711
+ shape(additions, excludes = []) {
1712
+ return this.clone().withMutation((next) => {
1713
+ let edges = next._excludedEdges;
1714
+ if (excludes.length) {
1715
+ if (!Array.isArray(excludes[0])) excludes = [excludes];
1716
+ edges = [...next._excludedEdges, ...excludes];
1717
+ }
1718
+ return next.setFields(Object.assign(next.fields, additions), edges);
1719
+ });
1720
+ }
1721
+ partial() {
1722
+ const partial = {};
1723
+ for (const [key, schema] of Object.entries(this.fields)) {
1724
+ partial[key] = "optional" in schema && schema.optional instanceof Function ? schema.optional() : schema;
1725
+ }
1726
+ return this.setFields(partial);
1727
+ }
1728
+ deepPartial() {
1729
+ const next = deepPartial(this);
1730
+ return next;
1731
+ }
1732
+ pick(keys) {
1733
+ const picked = {};
1734
+ for (const key of keys) {
1735
+ if (this.fields[key]) picked[key] = this.fields[key];
1736
+ }
1737
+ return this.setFields(picked, this._excludedEdges.filter(([a, b]) => keys.includes(a) && keys.includes(b)));
1738
+ }
1739
+ omit(keys) {
1740
+ const remaining = [];
1741
+ for (const key of Object.keys(this.fields)) {
1742
+ if (keys.includes(key)) continue;
1743
+ remaining.push(key);
1744
+ }
1745
+ return this.pick(remaining);
1746
+ }
1747
+ from(from, to, alias) {
1748
+ let fromGetter = propertyExprExports.getter(from, true);
1749
+ return this.transform((obj) => {
1750
+ if (!obj) return obj;
1751
+ let newObj = obj;
1752
+ if (deepHas(obj, from)) {
1753
+ newObj = Object.assign({}, obj);
1754
+ if (!alias) delete newObj[from];
1755
+ newObj[to] = fromGetter(obj);
1756
+ }
1757
+ return newObj;
1758
+ });
1759
+ }
1760
+ /** Parse an input JSON string to an object */
1761
+ json() {
1762
+ return this.transform(parseJson);
1763
+ }
1764
+ /**
1765
+ * Similar to `noUnknown` but only validates that an object is the right shape without stripping the unknown keys
1766
+ */
1767
+ exact(message) {
1768
+ return this.test({
1769
+ name: "exact",
1770
+ exclusive: true,
1771
+ message: message || object.exact,
1772
+ test(value) {
1773
+ if (value == null) return true;
1774
+ const unknownKeys = unknown(this.schema, value);
1775
+ return unknownKeys.length === 0 || this.createError({
1776
+ params: {
1777
+ properties: unknownKeys.join(", ")
1778
+ }
1779
+ });
1780
+ }
1781
+ });
1782
+ }
1783
+ stripUnknown() {
1784
+ return this.clone({
1785
+ noUnknown: true
1786
+ });
1787
+ }
1788
+ noUnknown(noAllow = true, message = object.noUnknown) {
1789
+ if (typeof noAllow !== "boolean") {
1790
+ message = noAllow;
1791
+ noAllow = true;
1792
+ }
1793
+ let next = this.test({
1794
+ name: "noUnknown",
1795
+ exclusive: true,
1796
+ message,
1797
+ test(value) {
1798
+ if (value == null) return true;
1799
+ const unknownKeys = unknown(this.schema, value);
1800
+ return !noAllow || unknownKeys.length === 0 || this.createError({
1801
+ params: {
1802
+ unknown: unknownKeys.join(", ")
1803
+ }
1804
+ });
1805
+ }
1806
+ });
1807
+ next.spec.noUnknown = noAllow;
1808
+ return next;
1809
+ }
1810
+ unknown(allow = true, message = object.noUnknown) {
1811
+ return this.noUnknown(!allow, message);
1812
+ }
1813
+ transformKeys(fn) {
1814
+ return this.transform((obj) => {
1815
+ if (!obj) return obj;
1816
+ const result = {};
1817
+ for (const key of Object.keys(obj)) result[fn(key)] = obj[key];
1818
+ return result;
1819
+ });
1820
+ }
1821
+ camelCase() {
1822
+ return this.transformKeys(tinyCaseExports.camelCase);
1823
+ }
1824
+ snakeCase() {
1825
+ return this.transformKeys(tinyCaseExports.snakeCase);
1826
+ }
1827
+ constantCase() {
1828
+ return this.transformKeys((key) => tinyCaseExports.snakeCase(key).toUpperCase());
1829
+ }
1830
+ describe(options) {
1831
+ const next = (options ? this.resolve(options) : this).clone();
1832
+ const base = super.describe(options);
1833
+ base.fields = {};
1834
+ for (const [key, value] of Object.entries(next.fields)) {
1835
+ var _innerOptions2;
1836
+ let innerOptions = options;
1837
+ if ((_innerOptions2 = innerOptions) != null && _innerOptions2.value) {
1838
+ innerOptions = Object.assign({}, innerOptions, {
1839
+ parent: innerOptions.value,
1840
+ value: innerOptions.value[key]
1841
+ });
1842
+ }
1843
+ base.fields[key] = value.describe(innerOptions);
1844
+ }
1845
+ return base;
1846
+ }
1847
+ }
1848
+ create$3.prototype = ObjectSchema.prototype;
1849
+ function create$2(type) {
1850
+ return new ArraySchema(type);
1851
+ }
1852
+ class ArraySchema extends Schema {
1853
+ constructor(type) {
1854
+ super({
1855
+ type: "array",
1856
+ spec: {
1857
+ types: type
1858
+ },
1859
+ check(v) {
1860
+ return Array.isArray(v);
1861
+ }
1862
+ });
1863
+ this.innerType = void 0;
1864
+ this.innerType = type;
1865
+ }
1866
+ _cast(_value, _opts) {
1867
+ const value = super._cast(_value, _opts);
1868
+ if (!this._typeCheck(value) || !this.innerType) {
1869
+ return value;
1870
+ }
1871
+ let isChanged = false;
1872
+ const castArray = value.map((v, idx) => {
1873
+ const castElement = this.innerType.cast(v, Object.assign({}, _opts, {
1874
+ path: `${_opts.path || ""}[${idx}]`,
1875
+ parent: value,
1876
+ originalValue: v,
1877
+ value: v,
1878
+ index: idx
1879
+ }));
1880
+ if (castElement !== v) {
1881
+ isChanged = true;
1882
+ }
1883
+ return castElement;
1884
+ });
1885
+ return isChanged ? castArray : value;
1886
+ }
1887
+ _validate(_value, options = {}, panic, next) {
1888
+ var _options$recursive;
1889
+ let innerType = this.innerType;
1890
+ let recursive = (_options$recursive = options.recursive) != null ? _options$recursive : this.spec.recursive;
1891
+ options.originalValue != null ? options.originalValue : _value;
1892
+ super._validate(_value, options, panic, (arrayErrors, value) => {
1893
+ var _options$originalValu2;
1894
+ if (!recursive || !innerType || !this._typeCheck(value)) {
1895
+ next(arrayErrors, value);
1896
+ return;
1897
+ }
1898
+ let tests = new Array(value.length);
1899
+ for (let index = 0; index < value.length; index++) {
1900
+ var _options$originalValu;
1901
+ tests[index] = innerType.asNestedTest({
1902
+ options,
1903
+ index,
1904
+ parent: value,
1905
+ parentPath: options.path,
1906
+ originalParent: (_options$originalValu = options.originalValue) != null ? _options$originalValu : _value
1907
+ });
1908
+ }
1909
+ this.runTests({
1910
+ value,
1911
+ tests,
1912
+ originalValue: (_options$originalValu2 = options.originalValue) != null ? _options$originalValu2 : _value,
1913
+ options
1914
+ }, panic, (innerTypeErrors) => next(innerTypeErrors.concat(arrayErrors), value));
1915
+ });
1916
+ }
1917
+ clone(spec) {
1918
+ const next = super.clone(spec);
1919
+ next.innerType = this.innerType;
1920
+ return next;
1921
+ }
1922
+ /** Parse an input JSON string to an object */
1923
+ json() {
1924
+ return this.transform(parseJson);
1925
+ }
1926
+ concat(schema) {
1927
+ let next = super.concat(schema);
1928
+ next.innerType = this.innerType;
1929
+ if (schema.innerType)
1930
+ next.innerType = next.innerType ? (
1931
+ // @ts-expect-error Lazy doesn't have concat and will break
1932
+ next.innerType.concat(schema.innerType)
1933
+ ) : schema.innerType;
1934
+ return next;
1935
+ }
1936
+ of(schema) {
1937
+ let next = this.clone();
1938
+ if (!isSchema(schema)) throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: " + printValue(schema));
1939
+ next.innerType = schema;
1940
+ next.spec = Object.assign({}, next.spec, {
1941
+ types: schema
1942
+ });
1943
+ return next;
1944
+ }
1945
+ length(length, message = array.length) {
1946
+ return this.test({
1947
+ message,
1948
+ name: "length",
1949
+ exclusive: true,
1950
+ params: {
1951
+ length
1952
+ },
1953
+ skipAbsent: true,
1954
+ test(value) {
1955
+ return value.length === this.resolve(length);
1956
+ }
1957
+ });
1958
+ }
1959
+ min(min, message) {
1960
+ message = message || array.min;
1961
+ return this.test({
1962
+ message,
1963
+ name: "min",
1964
+ exclusive: true,
1965
+ params: {
1966
+ min
1967
+ },
1968
+ skipAbsent: true,
1969
+ // FIXME(ts): Array<typeof T>
1970
+ test(value) {
1971
+ return value.length >= this.resolve(min);
1972
+ }
1973
+ });
1974
+ }
1975
+ max(max, message) {
1976
+ message = message || array.max;
1977
+ return this.test({
1978
+ message,
1979
+ name: "max",
1980
+ exclusive: true,
1981
+ params: {
1982
+ max
1983
+ },
1984
+ skipAbsent: true,
1985
+ test(value) {
1986
+ return value.length <= this.resolve(max);
1987
+ }
1988
+ });
1989
+ }
1990
+ ensure() {
1991
+ return this.default(() => []).transform((val, original) => {
1992
+ if (this._typeCheck(val)) return val;
1993
+ return original == null ? [] : [].concat(original);
1994
+ });
1995
+ }
1996
+ compact(rejector) {
1997
+ let reject = !rejector ? (v) => !!v : (v, i, a) => !rejector(v, i, a);
1998
+ return this.transform((values) => values != null ? values.filter(reject) : values);
1999
+ }
2000
+ describe(options) {
2001
+ const next = (options ? this.resolve(options) : this).clone();
2002
+ const base = super.describe(options);
2003
+ if (next.innerType) {
2004
+ var _innerOptions;
2005
+ let innerOptions = options;
2006
+ if ((_innerOptions = innerOptions) != null && _innerOptions.value) {
2007
+ innerOptions = Object.assign({}, innerOptions, {
2008
+ parent: innerOptions.value,
2009
+ value: innerOptions.value[0]
2010
+ });
2011
+ }
2012
+ base.innerType = next.innerType.describe(innerOptions);
2013
+ }
2014
+ return base;
2015
+ }
2016
+ }
2017
+ create$2.prototype = ArraySchema.prototype;
1239
2018
  export {
2019
+ ArraySchema,
1240
2020
  DateSchema,
2021
+ MixedSchema,
2022
+ ObjectSchema,
1241
2023
  Schema,
2024
+ StringSchema,
1242
2025
  ValidationError,
2026
+ create$2 as array,
1243
2027
  getIn,
1244
2028
  isSchema,
1245
- printValue
2029
+ create$8 as mixed,
2030
+ create$3 as object,
2031
+ printValue,
2032
+ create$6 as string
1246
2033
  };