New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@sanity/client

Package Overview
Dependencies
Maintainers
63
Versions
1027
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/client - npm Package Compare versions

Comparing version 6.22.5-stega.0 to 6.22.5

48

dist/_chunks-es/resolveEditInfo.js

@@ -173,18 +173,13 @@ const rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, reKeySegment = /_key\s*==\s*['"](.*)['"]/, reIndexTuple = /^\d*:\d*$/;

return;
const resultMappingPath = jsonPath(jsonPathToMappingPath(resultPath)), directMapping = csm.mappings[resultMappingPath];
if (directMapping !== void 0)
const resultMappingPath = jsonPath(jsonPathToMappingPath(resultPath));
if (csm.mappings[resultMappingPath] !== void 0)
return {
mapping: directMapping,
mapping: csm.mappings[resultMappingPath],
matchedPath: resultMappingPath,
pathSuffix: ""
};
const mappingEntries = Object.entries(csm.mappings), entriesLength = mappingEntries.length;
let bestMatch = null, bestLength = -1;
for (let i = 0; i < entriesLength; i++) {
const entry = mappingEntries[i], key = entry[0];
resultMappingPath.startsWith(key) && key.length > bestLength && (bestMatch = entry, bestLength = key.length);
}
if (!bestMatch)
const mappings = Object.entries(csm.mappings).filter(([key]) => resultMappingPath.startsWith(key)).sort(([key1], [key2]) => key2.length - key1.length);
if (mappings.length == 0)
return;
const [matchedPath, mapping] = bestMatch, pathSuffix = resultMappingPath.substring(matchedPath.length);
const [matchedPath, mapping] = mappings[0], pathSuffix = resultMappingPath.substring(matchedPath.length);
return { mapping, matchedPath, pathSuffix };

@@ -199,26 +194,19 @@ }

function walkMap(value, mappingFn, path = []) {
if (!value || typeof value != "object")
return mappingFn(value, path);
if (isArray(value)) {
const result = new Array(value.length);
for (let idx = 0; idx < value.length; idx++) {
const v = value[idx];
if (isArray(value))
return value.map((v, idx) => {
if (isRecord(v)) {
const _key = v._key;
if (typeof _key == "string") {
result[idx] = walkMap(v, mappingFn, path.concat({ _key, _index: idx }));
continue;
}
if (typeof _key == "string")
return walkMap(v, mappingFn, path.concat({ _key, _index: idx }));
}
result[idx] = walkMap(v, mappingFn, path.concat(idx));
}
return result;
}
return walkMap(v, mappingFn, path.concat(idx));
});
if (isRecord(value)) {
const keys = Object.keys(value), result = {};
for (let i = 0; i < keys.length; i++) {
const k = keys[i];
result[k] = walkMap(value[k], mappingFn, path.concat(k));
if (value._type === "block" || value._type === "span") {
const result = { ...value };
return value._type === "block" ? result.children = walkMap(value.children, mappingFn, path.concat("children")) : value._type === "span" && (result.text = walkMap(value.text, mappingFn, path.concat("text"))), result;
}
return result;
return Object.fromEntries(
Object.entries(value).map(([k, v]) => [k, walkMap(v, mappingFn, path.concat(k))])
);
}

@@ -225,0 +213,0 @@ return mappingFn(value, path);

@@ -90,18 +90,13 @@ import { C } from "./stegaClean.js";

return;
const resultMappingPath = jsonPath(jsonPathToMappingPath(resultPath)), directMapping = csm.mappings[resultMappingPath];
if (directMapping !== void 0)
const resultMappingPath = jsonPath(jsonPathToMappingPath(resultPath));
if (csm.mappings[resultMappingPath] !== void 0)
return {
mapping: directMapping,
mapping: csm.mappings[resultMappingPath],
matchedPath: resultMappingPath,
pathSuffix: ""
};
const mappingEntries = Object.entries(csm.mappings), entriesLength = mappingEntries.length;
let bestMatch = null, bestLength = -1;
for (let i = 0; i < entriesLength; i++) {
const entry = mappingEntries[i], key = entry[0];
resultMappingPath.startsWith(key) && key.length > bestLength && (bestMatch = entry, bestLength = key.length);
}
if (!bestMatch)
const mappings = Object.entries(csm.mappings).filter(([key]) => resultMappingPath.startsWith(key)).sort(([key1], [key2]) => key2.length - key1.length);
if (mappings.length == 0)
return;
const [matchedPath, mapping] = bestMatch, pathSuffix = resultMappingPath.substring(matchedPath.length);
const [matchedPath, mapping] = mappings[0], pathSuffix = resultMappingPath.substring(matchedPath.length);
return { mapping, matchedPath, pathSuffix };

@@ -116,26 +111,19 @@ }

function walkMap(value, mappingFn, path = []) {
if (!value || typeof value != "object")
return mappingFn(value, path);
if (isArray(value)) {
const result = new Array(value.length);
for (let idx = 0; idx < value.length; idx++) {
const v = value[idx];
if (isArray(value))
return value.map((v, idx) => {
if (isRecord(v)) {
const _key = v._key;
if (typeof _key == "string") {
result[idx] = walkMap(v, mappingFn, path.concat({ _key, _index: idx }));
continue;
}
if (typeof _key == "string")
return walkMap(v, mappingFn, path.concat({ _key, _index: idx }));
}
result[idx] = walkMap(v, mappingFn, path.concat(idx));
}
return result;
}
return walkMap(v, mappingFn, path.concat(idx));
});
if (isRecord(value)) {
const keys = Object.keys(value), result = {};
for (let i = 0; i < keys.length; i++) {
const k = keys[i];
result[k] = walkMap(value[k], mappingFn, path.concat(k));
if (value._type === "block" || value._type === "span") {
const result = { ...value };
return value._type === "block" ? result.children = walkMap(value.children, mappingFn, path.concat("children")) : value._type === "span" && (result.text = walkMap(value.text, mappingFn, path.concat("text"))), result;
}
return result;
return Object.fromEntries(
Object.entries(value).map(([k, v]) => [k, walkMap(v, mappingFn, path.concat(k))])
);
}

@@ -211,3 +199,3 @@ return mappingFn(value, path);

const endPath = sourcePath.at(-1);
return !(sourcePath.at(-2) === "slug" && endPath === "current" || typeof endPath == "string" && (endPath.startsWith("_") || endPath.endsWith("Id")) || typeof endPath == "number" && sourcePath.at(-2) === "marks" || endPath === "href" && typeof sourcePath.at(-2) == "number" && sourcePath.at(-3) === "markDefs" || endPath === "style" || endPath === "listItem" || sourcePath.some(
return !(sourcePath.at(-2) === "slug" && endPath === "current" || typeof endPath == "string" && (endPath.startsWith("_") || endPath.endsWith("Id")) || sourcePath.some(
(path) => path === "meta" || path === "metadata" || path === "openGraph" || path === "seo"

@@ -214,0 +202,0 @@ ) || hasTypeLike(sourcePath) || hasTypeLike(resultPath) || typeof endPath == "string" && denylist.has(endPath));

{
"name": "@sanity/client",
"version": "6.22.5-stega.0",
"version": "6.22.5",
"description": "Client for retrieving, creating and patching data from Sanity.io",

@@ -92,2 +92,3 @@ "keywords": [

"scripts": {
"benchmark": "npm test -- bench",
"prebuild": "npm run clean",

@@ -126,13 +127,14 @@ "build": "pkg build --strict && pkg --strict && npm run rollup && npm run minify",

"devDependencies": {
"@edge-runtime/types": "^3.0.2",
"@edge-runtime/vm": "^4.0.3",
"@edge-runtime/types": "^3.0.3",
"@edge-runtime/vm": "^4.0.4",
"@rollup/plugin-commonjs": "^28.0.1",
"@rollup/plugin-node-resolve": "^15.3.0",
"@sanity/pkg-utils": "^6.11.8",
"@sanity/client-latest": "npm:@sanity/client@latest",
"@sanity/pkg-utils": "^6.11.11",
"@types/json-diff": "^1.0.3",
"@types/node": "^22.9.0",
"@typescript-eslint/eslint-plugin": "^8.13.0",
"@typescript-eslint/parser": "^8.13.0",
"@typescript-eslint/eslint-plugin": "^8.15.0",
"@typescript-eslint/parser": "^8.15.0",
"@vercel/stega": "0.1.2",
"@vitest/coverage-v8": "2.1.4",
"@vitest/coverage-v8": "2.1.5",
"eslint": "^8.57.1",

@@ -146,13 +148,13 @@ "eslint-config-prettier": "^9.1.0",

"ls-engines": "^0.9.3",
"msw": "^2.6.0",
"next": "^15.0.2",
"nock": "^13.5.5",
"msw": "^2.6.5",
"next": "^15.0.3",
"nock": "^13.5.6",
"prettier": "^3.3.3",
"prettier-plugin-packagejson": "^2.5.3",
"rimraf": "^5.0.7",
"rollup": "^4.24.4",
"rollup": "^4.27.3",
"sse-channel": "^4.0.0",
"terser": "^5.36.0",
"typescript": "5.6.3",
"vitest": "2.1.4",
"vitest": "2.1.5",
"vitest-github-actions-reporter": "0.11.1"

@@ -159,0 +161,0 @@ },

@@ -22,6 +22,5 @@ import {jsonPath, jsonPathToMappingPath} from './jsonPath'

const directMapping = csm.mappings[resultMappingPath]
if (directMapping !== undefined) {
if (csm.mappings[resultMappingPath] !== undefined) {
return {
mapping: directMapping,
mapping: csm.mappings[resultMappingPath],
matchedPath: resultMappingPath,

@@ -32,25 +31,13 @@ pathSuffix: '',

const mappingEntries = Object.entries(csm.mappings)
const entriesLength = mappingEntries.length
const mappings = Object.entries(csm.mappings)
.filter(([key]) => resultMappingPath.startsWith(key))
.sort(([key1], [key2]) => key2.length - key1.length)
let bestMatch: [string, ContentSourceMapMapping] | null = null
let bestLength = -1
for (let i = 0; i < entriesLength; i++) {
const entry = mappingEntries[i]
const key = entry[0]
if (resultMappingPath.startsWith(key) && key.length > bestLength) {
bestMatch = entry
bestLength = key.length
}
}
if (!bestMatch) {
if (mappings.length == 0) {
return undefined
}
const [matchedPath, mapping] = bestMatch
const [matchedPath, mapping] = mappings[0]
const pathSuffix = resultMappingPath.substring(matchedPath.length)
return {mapping, matchedPath, pathSuffix}
}

@@ -14,33 +14,30 @@ import {isArray} from './isArray'

): unknown {
// Early return for primitive values
if (!value || typeof value !== 'object') {
return mappingFn(value, path)
}
if (isArray(value)) {
// Pre-allocate array length for better memory management
const result = new Array(value.length)
for (let idx = 0; idx < value.length; idx++) {
const v = value[idx]
return value.map((v, idx) => {
if (isRecord(v)) {
const _key = v['_key']
if (typeof _key === 'string') {
result[idx] = walkMap(v, mappingFn, path.concat({_key, _index: idx}))
continue
return walkMap(v, mappingFn, path.concat({_key, _index: idx}))
}
}
result[idx] = walkMap(v, mappingFn, path.concat(idx))
}
return result
return walkMap(v, mappingFn, path.concat(idx))
})
}
if (isRecord(value)) {
// Use Object.keys instead of Object.entries to avoid creating unnecessary arrays
const keys = Object.keys(value)
const result: Record<string, unknown> = {}
for (let i = 0; i < keys.length; i++) {
const k = keys[i]
result[k] = walkMap(value[k], mappingFn, path.concat(k))
// Handle Portable Text in a faster way
if (value._type === 'block' || value._type === 'span') {
const result = {...value}
if (value._type === 'block') {
result.children = walkMap(value.children, mappingFn, path.concat('children'))
} else if (value._type === 'span') {
result.text = walkMap(value.text, mappingFn, path.concat('text'))
}
return result
}
return result
return Object.fromEntries(
Object.entries(value).map(([k, v]) => [k, walkMap(v, mappingFn, path.concat(k))]),
)
}

@@ -47,0 +44,0 @@

@@ -20,26 +20,2 @@ import type {ContentSourceMapParsedPath, FilterDefault} from './types'

/**
* Best effort infer Portable Text paths that should not be encoded.
* Nothing is for certain, and the below implementation may cause paths that aren't Portable Text and otherwise be safe to encode to be skipped.
* However, that's ok as userland can always opt-in with the `encodeSourceMapAtPath` option and mark known safe paths as such, which will override this heuristic.
*/
// If the path ends in marks[number] it's likely a PortableTextSpan: https://github.com/portabletext/types/blob/e54eb24f136d8efd51a46c6a190e7c46e79b5380/src/portableText.ts#LL154C16-L154C16
if (typeof endPath === 'number' && sourcePath.at(-2) === 'marks') {
return false
}
// Or if it's [number].markDefs[number].href it's likely a PortableTextLink: https://github.com/portabletext/types/blob/e54eb24f136d8efd51a46c6a190e7c46e79b5380/src/portableText.ts#L163
if (
endPath === 'href' &&
typeof sourcePath.at(-2) === 'number' &&
sourcePath.at(-3) === 'markDefs'
) {
return false
}
// Otherwise we have to deal with special properties of PortableTextBlock, and we can't confidently know if it's actually a `_type: 'block'` array item or not.
// All we know is that if it is indeed a block, and we encode the strings on these keys it'll for sure break the PortableText rendering and thus we skip encoding.
// https://github.com/portabletext/types/blob/e54eb24f136d8efd51a46c6a190e7c46e79b5380/src/portableText.ts#L48-L58
if (endPath === 'style' || endPath === 'listItem') {
return false
}
// Don't encode into anything that is suggested it'll render for SEO in meta tags

@@ -46,0 +22,0 @@ if (

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 too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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