@sanity/schema
Advanced tools
Comparing version 3.52.5-canary.18 to 3.52.5-canary.41
@@ -38,4 +38,3 @@ "use strict"; | ||
function deriveFromPreview(type, maxDepth) { | ||
var _a; | ||
const select = (_a = type == null ? void 0 : type.preview) == null ? void 0 : _a.select; | ||
const select = type?.preview?.select; | ||
if (!select) | ||
@@ -42,0 +41,0 @@ return []; |
@@ -103,8 +103,7 @@ import difference from "lodash/difference.js"; | ||
function convertSchemaType(schemaType) { | ||
var _a, _b, _c; | ||
if (((_a = lastType(schemaType)) == null ? void 0 : _a.name) === "document") | ||
if (lastType(schemaType)?.name === "document") | ||
return createReferenceTypeNode(schemaType.name); | ||
if (inlineFields.has(schemaType.type)) | ||
return { type: "inline", name: schemaType.type.name }; | ||
if (((_c = (_b = schemaType.type) == null ? void 0 : _b.type) == null ? void 0 : _c.name) === "object") | ||
if (schemaType.type?.type?.name === "object") | ||
return { type: "inline", name: schemaType.type.name }; | ||
@@ -128,3 +127,2 @@ if (isStringType(schemaType)) | ||
function createObject(schemaType) { | ||
var _a; | ||
const attributes = {}, fields = gatherFields(schemaType); | ||
@@ -143,3 +141,3 @@ for (const field of fields) { | ||
} | ||
return Object.keys(attributes).length === 0 ? { type: "unknown" } : (((_a = schemaType.type) == null ? void 0 : _a.name) !== "document" && schemaType.name !== "object" && (attributes._type = { | ||
return Object.keys(attributes).length === 0 ? { type: "unknown" } : (schemaType.type?.name !== "document" && schemaType.name !== "object" && (attributes._type = { | ||
type: "objectAttribute", | ||
@@ -245,4 +243,3 @@ value: { | ||
function createStringTypeNodeDefintion(stringSchemaType) { | ||
var _a; | ||
const listOptions = (_a = stringSchemaType.options) == null ? void 0 : _a.list; | ||
const listOptions = stringSchemaType.options?.list; | ||
return listOptions && Array.isArray(listOptions) ? { | ||
@@ -259,4 +256,3 @@ type: "union", | ||
function createNumberTypeNodeDefintion(numberSchemaType) { | ||
var _a; | ||
const listOptions = (_a = numberSchemaType.options) == null ? void 0 : _a.list; | ||
const listOptions = numberSchemaType.options?.list; | ||
return listOptions && Array.isArray(listOptions) ? { | ||
@@ -561,3 +557,2 @@ type: "union", | ||
var array = (typeDef, visitorContext) => { | ||
var _a, _b, _c; | ||
const ofIsArray = Array.isArray(typeDef.of); | ||
@@ -627,6 +622,3 @@ if (ofIsArray) { | ||
of, | ||
(ofType) => { | ||
var _a2; | ||
return isPrimitiveTypeName(ofType.type) || isPrimitiveTypeName((_a2 = visitorContext.getType(ofType.type)) == null ? void 0 : _a2.jsonType); | ||
} | ||
(ofType) => isPrimitiveTypeName(ofType.type) || isPrimitiveTypeName(visitorContext.getType(ofType.type)?.jsonType) | ||
), isMixedArray = primitiveTypes.length > 0 && objectTypes.length > 0; | ||
@@ -646,6 +638,5 @@ if (isMixedArray) { | ||
} | ||
const list = (_a = typeDef == null ? void 0 : typeDef.options) == null ? void 0 : _a.list; | ||
const list = typeDef?.options?.list; | ||
return !isMixedArray && Array.isArray(list) && (primitiveTypes.length > 0 ? list.forEach((option) => { | ||
var _a2; | ||
const value = (_a2 = option == null ? void 0 : option.value) != null ? _a2 : option; | ||
const value = option?.value ?? option; | ||
if (!primitiveTypes.some((primitiveType) => typeof value === visitorContext.getType(primitiveType.type).jsonType)) { | ||
@@ -680,3 +671,3 @@ const formattedTypeList = humanizeList( | ||
); | ||
})), (_b = typeDef == null ? void 0 : typeDef.options) != null && _b.list && ((_c = typeDef == null ? void 0 : typeDef.options) == null ? void 0 : _c.layout) === "tags" && problems.push( | ||
})), typeDef?.options?.list && typeDef?.options?.layout === "tags" && problems.push( | ||
warning( | ||
@@ -833,3 +824,2 @@ "Found array member declaration with both tags layout and a list of predefined values. If you want to display a list of predefined values, remove the tags layout from `options`." | ||
return annotations.map((annotation) => { | ||
var _a, _b; | ||
if (!isPlainObject(annotation)) | ||
@@ -850,3 +840,3 @@ return { | ||
) | ||
), annotation.icon = annotation.icon || annotation.blockEditor.icon, (_a = annotation.blockEditor) != null && _a.render && !((_b = annotation.components) != null && _b.annotation) && (annotation.components = annotation.components || {}, annotation.components.annotation = annotation.components.annotation || annotation.blockEditor.render)), { ...annotation, _problems }; | ||
), annotation.icon = annotation.icon || annotation.blockEditor.icon, annotation.blockEditor?.render && !annotation.components?.annotation && (annotation.components = annotation.components || {}, annotation.components.annotation = annotation.components.annotation || annotation.blockEditor.render)), { ...annotation, _problems }; | ||
}); | ||
@@ -919,13 +909,12 @@ } | ||
function validateDeprecatedProperties(type) { | ||
var _a, _b, _c; | ||
const warnings = []; | ||
return type != null && type.inputComponent && warnings.push( | ||
return type?.inputComponent && warnings.push( | ||
warning('The "inputComponent" property is deprecated. Use "components.input" instead.') | ||
), (_a = type == null ? void 0 : type.preview) != null && _a.component && warnings.push( | ||
), type?.preview?.component && warnings.push( | ||
warning('The "preview.component" property is deprecated. Use "components.preview" instead.') | ||
), type != null && type.diffComponent && warnings.push( | ||
), type?.diffComponent && warnings.push( | ||
warning('The "diffComponent" property is deprecated. Use "components.diff" instead.') | ||
), (_b = type == null ? void 0 : type.options) != null && _b.editModal && warnings.push( | ||
), type?.options?.editModal && warnings.push( | ||
warning('The "options.editModal" property is deprecated. Use "options.modal" instead.') | ||
), (_c = type == null ? void 0 : type.options) != null && _c.isHighlighted && warnings.push( | ||
), type?.options?.isHighlighted && warnings.push( | ||
warning( | ||
@@ -1027,3 +1016,3 @@ 'The "options.isHighlighted" property is deprecated. You can put fields behind a collapsed fieldset if you want to hide them from plain sight.' | ||
function isComponentLike(value) { | ||
return typeof value == "function" || typeof (value == null ? void 0 : value.$$typeof) == "symbol" && REACT_SYM_RE.test(String(value == null ? void 0 : value.$$typeof)); | ||
return typeof value == "function" || typeof value?.$$typeof == "symbol" && REACT_SYM_RE.test(String(value?.$$typeof)); | ||
} | ||
@@ -1180,3 +1169,3 @@ function validateComponent(typeDef) { | ||
fields && problems.push(...validateFields(fields, { allowEmpty: !0 })); | ||
const invalidFieldNames = Array.isArray(fields) ? fields == null ? void 0 : fields.filter((field) => field.name === "asset") : []; | ||
const invalidFieldNames = Array.isArray(fields) ? fields?.filter((field) => field.name === "asset") : []; | ||
return typeDef.options && typeof typeDef.options.metadata < "u" && !Array.isArray(typeDef.options.metadata) ? problems.push( | ||
@@ -1205,3 +1194,3 @@ error( | ||
let options = typeDef.options; | ||
const metadata = options == null ? void 0 : options.metadata, superfluousMeta = Array.isArray(metadata) ? metadata.filter((meta) => autoMeta.includes(meta)) : [], invalidFieldNames = ["asset", "hotspot", "crop"], fieldsWithInvalidName = Array.isArray(fields) ? fields == null ? void 0 : fields.filter((field) => invalidFieldNames.includes(field.name)) : []; | ||
const metadata = options?.metadata, superfluousMeta = Array.isArray(metadata) ? metadata.filter((meta) => autoMeta.includes(meta)) : [], invalidFieldNames = ["asset", "hotspot", "crop"], fieldsWithInvalidName = Array.isArray(fields) ? fields?.filter((field) => invalidFieldNames.includes(field.name)) : []; | ||
return typeof metadata < "u" && !Array.isArray(metadata) ? problems.push( | ||
@@ -1208,0 +1197,0 @@ error( |
@@ -98,8 +98,7 @@ "use strict"; | ||
function convertSchemaType(schemaType) { | ||
var _a, _b, _c; | ||
if (((_a = lastType(schemaType)) == null ? void 0 : _a.name) === "document") | ||
if (lastType(schemaType)?.name === "document") | ||
return groqJs.createReferenceTypeNode(schemaType.name); | ||
if (inlineFields.has(schemaType.type)) | ||
return { type: "inline", name: schemaType.type.name }; | ||
if (((_c = (_b = schemaType.type) == null ? void 0 : _b.type) == null ? void 0 : _c.name) === "object") | ||
if (schemaType.type?.type?.name === "object") | ||
return { type: "inline", name: schemaType.type.name }; | ||
@@ -123,3 +122,2 @@ if (isStringType(schemaType)) | ||
function createObject(schemaType) { | ||
var _a; | ||
const attributes = {}, fields = gatherFields(schemaType); | ||
@@ -138,3 +136,3 @@ for (const field of fields) { | ||
} | ||
return Object.keys(attributes).length === 0 ? { type: "unknown" } : (((_a = schemaType.type) == null ? void 0 : _a.name) !== "document" && schemaType.name !== "object" && (attributes._type = { | ||
return Object.keys(attributes).length === 0 ? { type: "unknown" } : (schemaType.type?.name !== "document" && schemaType.name !== "object" && (attributes._type = { | ||
type: "objectAttribute", | ||
@@ -240,4 +238,3 @@ value: { | ||
function createStringTypeNodeDefintion(stringSchemaType) { | ||
var _a; | ||
const listOptions = (_a = stringSchemaType.options) == null ? void 0 : _a.list; | ||
const listOptions = stringSchemaType.options?.list; | ||
return listOptions && Array.isArray(listOptions) ? { | ||
@@ -254,4 +251,3 @@ type: "union", | ||
function createNumberTypeNodeDefintion(numberSchemaType) { | ||
var _a; | ||
const listOptions = (_a = numberSchemaType.options) == null ? void 0 : _a.list; | ||
const listOptions = numberSchemaType.options?.list; | ||
return listOptions && Array.isArray(listOptions) ? { | ||
@@ -556,3 +552,2 @@ type: "union", | ||
var array = (typeDef, visitorContext) => { | ||
var _a, _b, _c; | ||
const ofIsArray = Array.isArray(typeDef.of); | ||
@@ -622,6 +617,3 @@ if (ofIsArray) { | ||
of, | ||
(ofType) => { | ||
var _a2; | ||
return isPrimitiveTypeName(ofType.type) || isPrimitiveTypeName((_a2 = visitorContext.getType(ofType.type)) == null ? void 0 : _a2.jsonType); | ||
} | ||
(ofType) => isPrimitiveTypeName(ofType.type) || isPrimitiveTypeName(visitorContext.getType(ofType.type)?.jsonType) | ||
), isMixedArray = primitiveTypes.length > 0 && objectTypes.length > 0; | ||
@@ -641,6 +633,5 @@ if (isMixedArray) { | ||
} | ||
const list = (_a = typeDef == null ? void 0 : typeDef.options) == null ? void 0 : _a.list; | ||
const list = typeDef?.options?.list; | ||
return !isMixedArray && Array.isArray(list) && (primitiveTypes.length > 0 ? list.forEach((option) => { | ||
var _a2; | ||
const value = (_a2 = option == null ? void 0 : option.value) != null ? _a2 : option; | ||
const value = option?.value ?? option; | ||
if (!primitiveTypes.some((primitiveType) => typeof value === visitorContext.getType(primitiveType.type).jsonType)) { | ||
@@ -675,3 +666,3 @@ const formattedTypeList = humanizeList__default.default( | ||
); | ||
})), (_b = typeDef == null ? void 0 : typeDef.options) != null && _b.list && ((_c = typeDef == null ? void 0 : typeDef.options) == null ? void 0 : _c.layout) === "tags" && problems.push( | ||
})), typeDef?.options?.list && typeDef?.options?.layout === "tags" && problems.push( | ||
warning( | ||
@@ -828,3 +819,2 @@ "Found array member declaration with both tags layout and a list of predefined values. If you want to display a list of predefined values, remove the tags layout from `options`." | ||
return annotations.map((annotation) => { | ||
var _a, _b; | ||
if (!isPlainObject__default.default(annotation)) | ||
@@ -845,3 +835,3 @@ return { | ||
) | ||
), annotation.icon = annotation.icon || annotation.blockEditor.icon, (_a = annotation.blockEditor) != null && _a.render && !((_b = annotation.components) != null && _b.annotation) && (annotation.components = annotation.components || {}, annotation.components.annotation = annotation.components.annotation || annotation.blockEditor.render)), { ...annotation, _problems }; | ||
), annotation.icon = annotation.icon || annotation.blockEditor.icon, annotation.blockEditor?.render && !annotation.components?.annotation && (annotation.components = annotation.components || {}, annotation.components.annotation = annotation.components.annotation || annotation.blockEditor.render)), { ...annotation, _problems }; | ||
}); | ||
@@ -914,13 +904,12 @@ } | ||
function validateDeprecatedProperties(type) { | ||
var _a, _b, _c; | ||
const warnings = []; | ||
return type != null && type.inputComponent && warnings.push( | ||
return type?.inputComponent && warnings.push( | ||
warning('The "inputComponent" property is deprecated. Use "components.input" instead.') | ||
), (_a = type == null ? void 0 : type.preview) != null && _a.component && warnings.push( | ||
), type?.preview?.component && warnings.push( | ||
warning('The "preview.component" property is deprecated. Use "components.preview" instead.') | ||
), type != null && type.diffComponent && warnings.push( | ||
), type?.diffComponent && warnings.push( | ||
warning('The "diffComponent" property is deprecated. Use "components.diff" instead.') | ||
), (_b = type == null ? void 0 : type.options) != null && _b.editModal && warnings.push( | ||
), type?.options?.editModal && warnings.push( | ||
warning('The "options.editModal" property is deprecated. Use "options.modal" instead.') | ||
), (_c = type == null ? void 0 : type.options) != null && _c.isHighlighted && warnings.push( | ||
), type?.options?.isHighlighted && warnings.push( | ||
warning( | ||
@@ -1022,3 +1011,3 @@ 'The "options.isHighlighted" property is deprecated. You can put fields behind a collapsed fieldset if you want to hide them from plain sight.' | ||
function isComponentLike(value) { | ||
return typeof value == "function" || typeof (value == null ? void 0 : value.$$typeof) == "symbol" && REACT_SYM_RE.test(String(value == null ? void 0 : value.$$typeof)); | ||
return typeof value == "function" || typeof value?.$$typeof == "symbol" && REACT_SYM_RE.test(String(value?.$$typeof)); | ||
} | ||
@@ -1175,3 +1164,3 @@ function validateComponent(typeDef) { | ||
fields && problems.push(...validateFields(fields, { allowEmpty: !0 })); | ||
const invalidFieldNames = Array.isArray(fields) ? fields == null ? void 0 : fields.filter((field) => field.name === "asset") : []; | ||
const invalidFieldNames = Array.isArray(fields) ? fields?.filter((field) => field.name === "asset") : []; | ||
return typeDef.options && typeof typeDef.options.metadata < "u" && !Array.isArray(typeDef.options.metadata) ? problems.push( | ||
@@ -1200,3 +1189,3 @@ error( | ||
let options = typeDef.options; | ||
const metadata = options == null ? void 0 : options.metadata, superfluousMeta = Array.isArray(metadata) ? metadata.filter((meta) => autoMeta.includes(meta)) : [], invalidFieldNames = ["asset", "hotspot", "crop"], fieldsWithInvalidName = Array.isArray(fields) ? fields == null ? void 0 : fields.filter((field) => invalidFieldNames.includes(field.name)) : []; | ||
const metadata = options?.metadata, superfluousMeta = Array.isArray(metadata) ? metadata.filter((meta) => autoMeta.includes(meta)) : [], invalidFieldNames = ["asset", "hotspot", "crop"], fieldsWithInvalidName = Array.isArray(fields) ? fields?.filter((field) => invalidFieldNames.includes(field.name)) : []; | ||
return typeof metadata < "u" && !Array.isArray(metadata) ? problems.push( | ||
@@ -1203,0 +1192,0 @@ error( |
@@ -34,4 +34,3 @@ import isFinite from "lodash/isFinite.js"; | ||
function deriveFromPreview(type, maxDepth) { | ||
var _a; | ||
const select = (_a = type == null ? void 0 : type.preview) == null ? void 0 : _a.select; | ||
const select = type?.preview?.select; | ||
if (!select) | ||
@@ -38,0 +37,0 @@ return []; |
@@ -362,3 +362,3 @@ import omit from "lodash/omit.js"; | ||
type: "array", | ||
of: (marks == null ? void 0 : marks.annotations) || DEFAULT_ANNOTATIONS | ||
of: marks?.annotations || DEFAULT_ANNOTATIONS | ||
}, fields = [childrenField, styleField, listItemField, markDefsField, { | ||
@@ -1151,3 +1151,3 @@ name: "level", | ||
url: UrlType | ||
}), __defProp = Object.defineProperty, __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value); | ||
}); | ||
function compileRegistry(schemaDef) { | ||
@@ -1175,8 +1175,10 @@ const registry = Object.assign(/* @__PURE__ */ Object.create(null), types), defsByName = schemaDef.types.reduce((acc, def) => { | ||
let Schema$1 = class Schema { | ||
constructor(schemaDef) { | ||
__publicField(this, "_original"), __publicField(this, "_registry"), this._original = schemaDef, this._registry = compileRegistry(schemaDef); | ||
} | ||
_original; | ||
_registry; | ||
static compile(schemaDef) { | ||
return new Schema(schemaDef); | ||
} | ||
constructor(schemaDef) { | ||
this._original = schemaDef, this._registry = compileRegistry(schemaDef); | ||
} | ||
get name() { | ||
@@ -1183,0 +1185,0 @@ return this._original.name; |
@@ -357,3 +357,3 @@ "use strict"; | ||
type: "array", | ||
of: (marks == null ? void 0 : marks.annotations) || DEFAULT_ANNOTATIONS | ||
of: marks?.annotations || DEFAULT_ANNOTATIONS | ||
}, fields = [childrenField, styleField, listItemField, markDefsField, { | ||
@@ -1146,3 +1146,3 @@ name: "level", | ||
url: UrlType | ||
}), __defProp = Object.defineProperty, __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value); | ||
}); | ||
function compileRegistry(schemaDef) { | ||
@@ -1170,8 +1170,10 @@ const registry = Object.assign(/* @__PURE__ */ Object.create(null), types), defsByName = schemaDef.types.reduce((acc, def) => { | ||
let Schema$1 = class Schema { | ||
constructor(schemaDef) { | ||
__publicField(this, "_original"), __publicField(this, "_registry"), this._original = schemaDef, this._registry = compileRegistry(schemaDef); | ||
} | ||
_original; | ||
_registry; | ||
static compile(schemaDef) { | ||
return new Schema(schemaDef); | ||
} | ||
constructor(schemaDef) { | ||
this._original = schemaDef, this._registry = compileRegistry(schemaDef); | ||
} | ||
get name() { | ||
@@ -1178,0 +1180,0 @@ return this._original.name; |
{ | ||
"name": "@sanity/schema", | ||
"version": "3.52.5-canary.18+3b2329cf64", | ||
"version": "3.52.5-canary.41+812e1e3930", | ||
"description": "", | ||
@@ -67,3 +67,3 @@ "keywords": [ | ||
"@sanity/generate-help-url": "^3.0.0", | ||
"@sanity/types": "3.52.5-canary.18+3b2329cf64", | ||
"@sanity/types": "3.52.5-canary.41+812e1e3930", | ||
"arrify": "^1.0.1", | ||
@@ -85,3 +85,3 @@ "groq-js": "^1.12.0", | ||
}, | ||
"gitHead": "3b2329cf640954f308676a4b02f3fda701c65587" | ||
"gitHead": "812e1e393037e12bad90533b992ab4043396b21a" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
1076743
12481