@sanity/schema 6.12.1-next.1 → 6.13.0-next.37
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/lib/_internal.d.ts +10 -10
- package/lib/_internal.js +8 -6
- package/lib/_internal.js.map +1 -1
- package/package.json +3 -2
package/lib/_internal.d.ts
CHANGED
|
@@ -387,17 +387,17 @@ declare const builtinTypes: ({
|
|
|
387
387
|
type: string;
|
|
388
388
|
title: string;
|
|
389
389
|
readOnly: boolean;
|
|
390
|
+
fieldset?: undefined;
|
|
390
391
|
validation?: undefined;
|
|
391
392
|
hidden?: undefined;
|
|
392
|
-
fieldset?: undefined;
|
|
393
393
|
} | {
|
|
394
394
|
name: string;
|
|
395
395
|
type: string;
|
|
396
396
|
title: string;
|
|
397
|
-
validation?: undefined;
|
|
398
|
-
hidden?: undefined;
|
|
399
397
|
readOnly?: undefined;
|
|
400
398
|
fieldset?: undefined;
|
|
399
|
+
validation?: undefined;
|
|
400
|
+
hidden?: undefined;
|
|
401
401
|
} | {
|
|
402
402
|
name: string;
|
|
403
403
|
type: string;
|
|
@@ -412,8 +412,8 @@ declare const builtinTypes: ({
|
|
|
412
412
|
readOnly: boolean;
|
|
413
413
|
hidden: boolean;
|
|
414
414
|
fieldset: string;
|
|
415
|
-
validation?: undefined;
|
|
416
415
|
title?: undefined;
|
|
416
|
+
validation?: undefined;
|
|
417
417
|
} | {
|
|
418
418
|
name: string;
|
|
419
419
|
type: string;
|
|
@@ -466,17 +466,17 @@ declare const builtinTypes: ({
|
|
|
466
466
|
type: string;
|
|
467
467
|
title: string;
|
|
468
468
|
readOnly: boolean;
|
|
469
|
+
fieldset?: undefined;
|
|
469
470
|
validation?: undefined;
|
|
470
471
|
hidden?: undefined;
|
|
471
|
-
fieldset?: undefined;
|
|
472
472
|
} | {
|
|
473
473
|
name: string;
|
|
474
474
|
type: string;
|
|
475
475
|
title: string;
|
|
476
|
-
validation?: undefined;
|
|
477
|
-
hidden?: undefined;
|
|
478
476
|
readOnly?: undefined;
|
|
479
477
|
fieldset?: undefined;
|
|
478
|
+
validation?: undefined;
|
|
479
|
+
hidden?: undefined;
|
|
480
480
|
} | {
|
|
481
481
|
name: string;
|
|
482
482
|
type: string;
|
|
@@ -486,21 +486,21 @@ declare const builtinTypes: ({
|
|
|
486
486
|
validation: (Rule: import("@sanity/types").Rule) => import("@sanity/types").Rule;
|
|
487
487
|
hidden?: undefined;
|
|
488
488
|
} | {
|
|
489
|
-
validation?: undefined;
|
|
490
489
|
name: string;
|
|
491
490
|
type: string;
|
|
492
491
|
readOnly: boolean;
|
|
493
492
|
hidden: boolean;
|
|
494
493
|
fieldset: string;
|
|
495
494
|
title?: undefined;
|
|
496
|
-
} | {
|
|
497
495
|
validation?: undefined;
|
|
498
|
-
|
|
496
|
+
} | {
|
|
499
497
|
name: string;
|
|
500
498
|
type: string;
|
|
501
499
|
title: string;
|
|
502
500
|
readOnly: boolean;
|
|
503
501
|
fieldset: string;
|
|
502
|
+
validation?: undefined;
|
|
503
|
+
hidden?: undefined;
|
|
504
504
|
})[];
|
|
505
505
|
preview: {
|
|
506
506
|
select: {
|
package/lib/_internal.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as resolveSearchConfig, d as OWN_PROPS_NAME, f as Rule, l as resolveSearchConfigForBaseFieldPaths, n as Schema$1, s as DEFAULT_MAX_FIELD_DEPTH, u as ALL_FIELDS_GROUP_NAME } from "./Schema-ClAx8eCc.js";
|
|
2
2
|
import { SetBuilder, processSetSynchronization } from "@sanity/descriptors";
|
|
3
3
|
import { isSpanSchemaType } from "@sanity/types";
|
|
4
|
-
import
|
|
4
|
+
import { dequal } from "dequal/lite";
|
|
5
5
|
import isObject from "lodash-es/isObject.js";
|
|
6
6
|
import cloneDeep from "lodash-es/cloneDeep.js";
|
|
7
7
|
import { HttpError, createRequester } from "get-it";
|
|
@@ -400,7 +400,7 @@ function maybeValidations(obj) {
|
|
|
400
400
|
let validation = maybeValidation(rule);
|
|
401
401
|
if (validation === void 0) continue;
|
|
402
402
|
let rulesToAdd = impliedRules.filter((ir) => !validation.rules.some((r) => r.type === ir.type));
|
|
403
|
-
rulesToAdd.length > 0 && validation.rules.unshift(...rulesToAdd), !validations.some((v) =>
|
|
403
|
+
rulesToAdd.length > 0 && validation.rules.unshift(...rulesToAdd), !validations.some((v) => dequal(v, validation)) && validations.push(validation);
|
|
404
404
|
}
|
|
405
405
|
return validations.length > 0 ? validations : void 0;
|
|
406
406
|
}
|
|
@@ -429,7 +429,7 @@ function maybeValidation(val) {
|
|
|
429
429
|
let level = val._level || "error", message = maybeValidationMessage(val._message), rules = [];
|
|
430
430
|
for (let spec of val._rules || []) {
|
|
431
431
|
let convertedRule = convertRuleSpec(spec, val._required === "optional" || void 0);
|
|
432
|
-
convertedRule !== void 0 && (rules.some((r) =>
|
|
432
|
+
convertedRule !== void 0 && (rules.some((r) => dequal(r, convertedRule)) || rules.push(convertedRule));
|
|
433
433
|
}
|
|
434
434
|
return rules.length === 0 ? void 0 : {
|
|
435
435
|
level,
|
|
@@ -2108,7 +2108,9 @@ var ValidationError = class extends Error {
|
|
|
2108
2108
|
const builtinSchema = Schema$1.compile({
|
|
2109
2109
|
name: "studio",
|
|
2110
2110
|
types: builtinTypes
|
|
2111
|
-
})
|
|
2111
|
+
}), unavailableValidator = () => {
|
|
2112
|
+
throw Error("This validator is unavailable because it was reconstructed from a serialized schema manifest");
|
|
2113
|
+
};
|
|
2112
2114
|
function createSchemaFromManifestTypes(schemaDef) {
|
|
2113
2115
|
let problems = groupProblems(validateSchema(schemaDef.types).getTypes()).filter((group) => group.problems.some((problem) => problem.severity === "error"));
|
|
2114
2116
|
if (problems.length > 0) throw new ValidationError(problems);
|
|
@@ -2215,11 +2217,11 @@ function applyRuleSpec(rule, ruleSpec) {
|
|
|
2215
2217
|
case "all": return rule.all(coerceConstraintRule(constraint));
|
|
2216
2218
|
case "either": return rule.either(coerceConstraintRule(constraint));
|
|
2217
2219
|
case "custom":
|
|
2218
|
-
if (constraint === void 0) return rule.custom(
|
|
2220
|
+
if (constraint === void 0) return rule.custom(unavailableValidator);
|
|
2219
2221
|
if (typeof constraint == "function") return rule.custom(constraint);
|
|
2220
2222
|
break;
|
|
2221
2223
|
case "media":
|
|
2222
|
-
if (constraint === void 0) return rule.media(
|
|
2224
|
+
if (constraint === void 0) return rule.media(unavailableValidator);
|
|
2223
2225
|
if (typeof constraint == "function") return rule.media(constraint);
|
|
2224
2226
|
}
|
|
2225
2227
|
return rule;
|