@sanity/schema 6.12.0 → 6.13.0-next.17
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 +6 -6
- package/lib/_internal.js +8 -6
- package/lib/_internal.js.map +1 -1
- package/package.json +3 -2
package/lib/_internal.d.ts
CHANGED
|
@@ -394,8 +394,8 @@ declare const builtinTypes: ({
|
|
|
394
394
|
name: string;
|
|
395
395
|
type: string;
|
|
396
396
|
title: string;
|
|
397
|
-
readOnly?: undefined;
|
|
398
397
|
fieldset?: undefined;
|
|
398
|
+
readOnly?: undefined;
|
|
399
399
|
validation?: undefined;
|
|
400
400
|
hidden?: undefined;
|
|
401
401
|
} | {
|
|
@@ -473,8 +473,8 @@ declare const builtinTypes: ({
|
|
|
473
473
|
name: string;
|
|
474
474
|
type: string;
|
|
475
475
|
title: string;
|
|
476
|
-
readOnly?: undefined;
|
|
477
476
|
fieldset?: undefined;
|
|
477
|
+
readOnly?: undefined;
|
|
478
478
|
validation?: undefined;
|
|
479
479
|
hidden?: undefined;
|
|
480
480
|
} | {
|
|
@@ -550,17 +550,17 @@ declare const builtinTypes: ({
|
|
|
550
550
|
};
|
|
551
551
|
}[];
|
|
552
552
|
fields: ({
|
|
553
|
-
title?: undefined;
|
|
554
|
-
readOnly?: undefined;
|
|
555
|
-
fieldset?: undefined;
|
|
556
553
|
name: string;
|
|
557
554
|
type: string;
|
|
558
|
-
|
|
555
|
+
fieldset?: undefined;
|
|
556
|
+
title?: undefined;
|
|
559
557
|
readOnly?: undefined;
|
|
558
|
+
} | {
|
|
560
559
|
name: string;
|
|
561
560
|
title: string;
|
|
562
561
|
type: string;
|
|
563
562
|
fieldset: string;
|
|
563
|
+
readOnly?: undefined;
|
|
564
564
|
} | {
|
|
565
565
|
fieldset?: undefined;
|
|
566
566
|
name: string;
|
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;
|