Socket
Socket
Sign inDemoInstall

@sanity/schema

Package Overview
Dependencies
Maintainers
55
Versions
1338
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/schema - npm Package Compare versions

Comparing version 3.53.1-styled-fork.4 to 3.54.0

10

lib/_internal.esm.js

@@ -58,3 +58,3 @@ import difference from "lodash/difference.js";

function extractSchema(schemaDef, extractOptions = {}) {
const inlineFields = /* @__PURE__ */ new Set(), schema = [];
const inlineFields = /* @__PURE__ */ new Set(), documentTypes = /* @__PURE__ */ new Map(), schema = [];
sortByDependencies(schemaDef).forEach((typeName) => {

@@ -65,3 +65,3 @@ const schemaType = schemaDef.get(typeName);

const base = convertBaseType(schemaType);
base !== null && (base.type === "type" && inlineFields.add(schemaType), schema.push(base));
base !== null && (base.type === "type" && inlineFields.add(schemaType), base.type === "document" && documentTypes.set(typeName, base), schema.push(base));
});

@@ -105,4 +105,2 @@ function convertBaseType(schemaType) {

function convertSchemaType(schemaType) {
if (lastType(schemaType)?.name === "document")
return createReferenceTypeNode(schemaType.name);
if (inlineFields.has(schemaType.type))

@@ -126,2 +124,6 @@ return { type: "inline", name: schemaType.type.name };

return createObject(schemaType);
if (lastType(schemaType)?.name === "document") {
const doc = documentTypes.get(schemaType.name);
return doc === void 0 ? { type: "unknown" } : { type: "object", attributes: doc?.attributes };
}
throw new Error(`Type "${schemaType.name}" not found`);

@@ -128,0 +130,0 @@ }

@@ -53,3 +53,3 @@ "use strict";

function extractSchema(schemaDef, extractOptions = {}) {
const inlineFields = /* @__PURE__ */ new Set(), schema = [];
const inlineFields = /* @__PURE__ */ new Set(), documentTypes = /* @__PURE__ */ new Map(), schema = [];
sortByDependencies(schemaDef).forEach((typeName) => {

@@ -60,3 +60,3 @@ const schemaType = schemaDef.get(typeName);

const base = convertBaseType(schemaType);
base !== null && (base.type === "type" && inlineFields.add(schemaType), schema.push(base));
base !== null && (base.type === "type" && inlineFields.add(schemaType), base.type === "document" && documentTypes.set(typeName, base), schema.push(base));
});

@@ -100,4 +100,2 @@ function convertBaseType(schemaType) {

function convertSchemaType(schemaType) {
if (lastType(schemaType)?.name === "document")
return groqJs.createReferenceTypeNode(schemaType.name);
if (inlineFields.has(schemaType.type))

@@ -121,2 +119,6 @@ return { type: "inline", name: schemaType.type.name };

return createObject(schemaType);
if (lastType(schemaType)?.name === "document") {
const doc = documentTypes.get(schemaType.name);
return doc === void 0 ? { type: "unknown" } : { type: "object", attributes: doc?.attributes };
}
throw new Error(`Type "${schemaType.name}" not found`);

@@ -123,0 +125,0 @@ }

8

package.json
{
"name": "@sanity/schema",
"version": "3.53.1-styled-fork.4+a93ef546cf",
"version": "3.54.0",
"description": "",

@@ -67,3 +67,3 @@ "keywords": [

"@sanity/generate-help-url": "^3.0.0",
"@sanity/types": "3.53.1-styled-fork.4+a93ef546cf",
"@sanity/types": "3.54.0",
"arrify": "^1.0.1",

@@ -78,3 +78,3 @@ "groq-js": "^1.12.0",

"@jest/globals": "^29.7.0",
"@repo/package.config": "3.53.0",
"@repo/package.config": "3.54.0",
"@sanity/icons": "^3.3.1",

@@ -86,3 +86,3 @@ "@types/arrify": "^1.0.4",

},
"gitHead": "a93ef546cf6eada681da73245cfccc934022c51f"
"gitHead": "7531cda80b5a9af691a2b3ccf4b96ed04e64f60e"
}

@@ -70,2 +70,3 @@ import {

const inlineFields = new Set<SanitySchemaType>()
const documentTypes = new Map<string, DocumentSchemaType>()
const schema: SchemaType = []

@@ -87,2 +88,5 @@

}
if (base.type === 'document') {
documentTypes.set(typeName, base)
}

@@ -152,6 +156,2 @@ schema.push(base)

function convertSchemaType(schemaType: SanitySchemaType): TypeNode {
if (lastType(schemaType)?.name === 'document') {
return createReferenceTypeNode(schemaType.name)
}
// if we have already seen the base type, we can just reference it

@@ -198,2 +198,10 @@ if (inlineFields.has(schemaType.type!)) {

if (lastType(schemaType)?.name === 'document') {
const doc = documentTypes.get(schemaType.name)
if (doc === undefined) {
return {type: 'unknown'} satisfies UnknownTypeNode
}
return {type: 'object', attributes: doc?.attributes} satisfies ObjectTypeNode
}
throw new Error(`Type "${schemaType.name}" not found`)

@@ -200,0 +208,0 @@ }

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc