@sanity/client 7.26.2 → 8.0.0
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/README.md +5 -377
- package/dist/browserUpload-CQgx9YYo.js +86 -0
- package/dist/browserUpload-CQgx9YYo.js.map +1 -0
- package/dist/browserUpload-icWlVP15.js +86 -0
- package/dist/browserUpload-icWlVP15.js.map +1 -0
- package/dist/config-a8VajuEY.js +126 -0
- package/dist/config-a8VajuEY.js.map +1 -0
- package/dist/csm.d.ts +122 -335
- package/dist/csm.js +79 -91
- package/dist/csm.js.map +1 -1
- package/dist/dist-C9ExSk2R.js +73 -0
- package/dist/dist-C9ExSk2R.js.map +1 -0
- package/dist/dist-Z8cIRxoB.js +69 -0
- package/dist/dist-Z8cIRxoB.js.map +1 -0
- package/dist/index.d.ts +107 -6723
- package/dist/index.js +2822 -2847
- package/dist/index.js.map +1 -1
- package/dist/{index.d.cts → index.node.d.ts} +4291 -5328
- package/dist/index.node.js +3131 -0
- package/dist/index.node.js.map +1 -0
- package/dist/isRecord-Kfmt-nk-.js +7 -0
- package/dist/isRecord-Kfmt-nk-.js.map +1 -0
- package/dist/media-library.d.ts +9 -100
- package/dist/media-library.js +36 -14
- package/dist/media-library.js.map +1 -1
- package/dist/request-CJxcN16k.js +372 -0
- package/dist/request-CJxcN16k.js.map +1 -0
- package/dist/request-k7VS_NnC.js +354 -0
- package/dist/request-k7VS_NnC.js.map +1 -0
- package/dist/resolveEditInfo-sq7yF78q.js +325 -0
- package/dist/resolveEditInfo-sq7yF78q.js.map +1 -0
- package/dist/rolldown-runtime-vyAXikos.js +9 -0
- package/dist/stega.d.ts +78 -7137
- package/dist/stega.js +27 -20
- package/dist/stega.js.map +1 -1
- package/dist/stegaClean-C18wLWau.js +21 -0
- package/dist/stegaClean-C18wLWau.js.map +1 -0
- package/dist/stegaEncodeSourceMap-B2fGArSf.js +163 -0
- package/dist/stegaEncodeSourceMap-B2fGArSf.js.map +1 -0
- package/dist/stegaEncodeSourceMap-DkoIlutY.js +367 -0
- package/dist/stegaEncodeSourceMap-DkoIlutY.js.map +1 -0
- package/dist/{index.browser.d.cts → types-CUxZSgB2.d.ts} +3956 -5256
- package/dist/types-CfGzbXrl.d.ts +108 -0
- package/package.json +64 -141
- package/src/SanityClient.ts +82 -117
- package/src/agent/actions/AgentActionsClient.ts +12 -12
- package/src/agent/actions/commonTypes.ts +2 -1
- package/src/agent/actions/generate.ts +26 -6
- package/src/agent/actions/patch.ts +27 -7
- package/src/agent/actions/prompt.ts +19 -5
- package/src/agent/actions/transform.ts +23 -5
- package/src/agent/actions/translate.ts +23 -5
- package/src/assets/AssetsClient.ts +71 -23
- package/src/csm/applySourceDocuments.ts +3 -1
- package/src/csm/createEditUrl.ts +1 -1
- package/src/csm/draftUtils.ts +0 -1
- package/src/csm/index.ts +2 -2
- package/src/csm/studioPath.ts +2 -1
- package/src/csm/types.ts +8 -2
- package/src/data/dataMethods.ts +801 -349
- package/src/data/eventsource.ts +13 -10
- package/src/data/listen.ts +18 -23
- package/src/data/live.ts +44 -27
- package/src/data/resolveEventSourceFetch.ts +96 -0
- package/src/datasets/DatasetsClient.ts +58 -41
- package/src/defineCreateClient.ts +35 -23
- package/src/http/browserMiddleware.ts +7 -1
- package/src/http/browserUpload.ts +162 -0
- package/src/http/errors.ts +60 -6
- package/src/http/nodeMiddleware.ts +94 -30
- package/src/http/request.ts +310 -87
- package/src/http/requestOptions.ts +131 -15
- package/src/{index.browser.ts → index.node.ts} +9 -4
- package/src/index.ts +4 -3
- package/src/mediaLibrary/MediaLibraryVideoClient.ts +26 -11
- package/src/projects/ProjectsClient.ts +18 -16
- package/src/releases/ReleasesClient.ts +38 -33
- package/src/stega/index.ts +1 -2
- package/src/stega/stegaEncodeSourceMap.ts +5 -0
- package/src/stega/types.ts +2 -2
- package/src/types.ts +148 -105
- package/src/users/UsersClient.ts +10 -14
- package/src/util/shareReplayLatest.ts +1 -1
- package/src/warnings.ts +6 -1
- package/dist/_chunks-cjs/config.cjs +0 -206
- package/dist/_chunks-cjs/config.cjs.map +0 -1
- package/dist/_chunks-cjs/isRecord.cjs +0 -6
- package/dist/_chunks-cjs/isRecord.cjs.map +0 -1
- package/dist/_chunks-cjs/resolveEditInfo.cjs +0 -334
- package/dist/_chunks-cjs/resolveEditInfo.cjs.map +0 -1
- package/dist/_chunks-cjs/stegaClean.cjs +0 -46
- package/dist/_chunks-cjs/stegaClean.cjs.map +0 -1
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs +0 -388
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +0 -1
- package/dist/_chunks-es/config.js +0 -207
- package/dist/_chunks-es/config.js.map +0 -1
- package/dist/_chunks-es/isRecord.js +0 -7
- package/dist/_chunks-es/isRecord.js.map +0 -1
- package/dist/_chunks-es/resolveEditInfo.js +0 -335
- package/dist/_chunks-es/resolveEditInfo.js.map +0 -1
- package/dist/_chunks-es/stegaClean.js +0 -47
- package/dist/_chunks-es/stegaClean.js.map +0 -1
- package/dist/_chunks-es/stegaEncodeSourceMap.js +0 -389
- package/dist/_chunks-es/stegaEncodeSourceMap.js.map +0 -1
- package/dist/csm.cjs +0 -99
- package/dist/csm.cjs.map +0 -1
- package/dist/csm.d.cts +0 -391
- package/dist/index.browser.cjs +0 -3106
- package/dist/index.browser.cjs.map +0 -1
- package/dist/index.browser.d.ts +0 -6802
- package/dist/index.browser.js +0 -3082
- package/dist/index.browser.js.map +0 -1
- package/dist/index.cjs +0 -2946
- package/dist/index.cjs.map +0 -1
- package/dist/media-library.cjs +0 -20
- package/dist/media-library.cjs.map +0 -1
- package/dist/media-library.d.cts +0 -117
- package/dist/stega.browser.cjs +0 -29
- package/dist/stega.browser.cjs.map +0 -1
- package/dist/stega.browser.d.cts +0 -7200
- package/dist/stega.browser.d.ts +0 -7200
- package/dist/stega.browser.js +0 -24
- package/dist/stega.browser.js.map +0 -1
- package/dist/stega.cjs +0 -29
- package/dist/stega.cjs.map +0 -1
- package/dist/stega.d.cts +0 -7200
- package/src/data/eventsourcePolyfill.ts +0 -7
- package/umd/.gitkeep +0 -1
- package/umd/sanityClient.js +0 -6543
- package/umd/sanityClient.min.js +0 -6
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
import { t as require_dist } from "./dist-C9ExSk2R.js";
|
|
2
|
+
import { t as isRecord } from "./isRecord-Kfmt-nk-.js";
|
|
3
|
+
var import_dist = require_dist();
|
|
4
|
+
/** @internal */
|
|
5
|
+
function isDraftId(id) {
|
|
6
|
+
return id.startsWith("drafts.");
|
|
7
|
+
}
|
|
8
|
+
/** @internal */
|
|
9
|
+
function isVersionId(id) {
|
|
10
|
+
return id.startsWith("versions.");
|
|
11
|
+
}
|
|
12
|
+
/** @internal */
|
|
13
|
+
function isPublishedId(id) {
|
|
14
|
+
return !isDraftId(id) && !isVersionId(id);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* @internal
|
|
18
|
+
* Given an id, returns the versionId if it exists.
|
|
19
|
+
* e.g. `versions.summer-drop.foo` = `summer-drop`
|
|
20
|
+
* e.g. `drafts.foo` = `undefined`
|
|
21
|
+
* e.g. `foo` = `undefined`
|
|
22
|
+
*/
|
|
23
|
+
function getVersionFromId(id) {
|
|
24
|
+
if (!isVersionId(id)) return;
|
|
25
|
+
let [_versionPrefix, versionId, ..._publishedId] = id.split(".");
|
|
26
|
+
return versionId;
|
|
27
|
+
}
|
|
28
|
+
/** @internal */
|
|
29
|
+
function getPublishedId(id) {
|
|
30
|
+
return isVersionId(id) ? id.split(".").slice(2).join(".") : isDraftId(id) ? id.slice(7) : id;
|
|
31
|
+
}
|
|
32
|
+
/** @internal */
|
|
33
|
+
const reKeySegment = /_key\s*==\s*['"](.*)['"]/;
|
|
34
|
+
/** @internal */
|
|
35
|
+
function isKeySegment(segment) {
|
|
36
|
+
return typeof segment == "string" ? reKeySegment.test(segment.trim()) : typeof segment == "object" && "_key" in segment;
|
|
37
|
+
}
|
|
38
|
+
/** @alpha */
|
|
39
|
+
function toString(path) {
|
|
40
|
+
if (!Array.isArray(path)) throw Error("Path is not an array");
|
|
41
|
+
return path.reduce((target, segment, i) => {
|
|
42
|
+
let segmentType = typeof segment;
|
|
43
|
+
if (segmentType === "number") return `${target}[${segment}]`;
|
|
44
|
+
if (segmentType === "string") return `${target}${i === 0 ? "" : "."}${segment}`;
|
|
45
|
+
if (isKeySegment(segment) && segment._key) return `${target}[_key=="${segment._key}"]`;
|
|
46
|
+
if (Array.isArray(segment)) {
|
|
47
|
+
let [from, to] = segment;
|
|
48
|
+
return `${target}[${from}:${to}]`;
|
|
49
|
+
}
|
|
50
|
+
throw Error(`Unsupported path segment \`${JSON.stringify(segment)}\``);
|
|
51
|
+
}, "");
|
|
52
|
+
}
|
|
53
|
+
const ESCAPE = {
|
|
54
|
+
"\f": "\\f",
|
|
55
|
+
"\n": "\\n",
|
|
56
|
+
"\r": "\\r",
|
|
57
|
+
" ": "\\t",
|
|
58
|
+
"'": "\\'",
|
|
59
|
+
"\\": "\\\\"
|
|
60
|
+
}, UNESCAPE = {
|
|
61
|
+
"\\f": "\f",
|
|
62
|
+
"\\n": "\n",
|
|
63
|
+
"\\r": "\r",
|
|
64
|
+
"\\t": " ",
|
|
65
|
+
"\\'": "'",
|
|
66
|
+
"\\\\": "\\"
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
function jsonPath(path) {
|
|
72
|
+
return `$${path.map((segment) => typeof segment == "string" ? `['${segment.replace(/[\f\n\r\t'\\]/g, (match) => ESCAPE[match])}']` : typeof segment == "number" ? `[${segment}]` : segment._key === "" ? `[${segment._index}]` : `[?(@._key=='${segment._key.replace(/['\\]/g, (match) => ESCAPE[match])}')]`).join("")}`;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
function jsonPathArray(path) {
|
|
78
|
+
return path.map((segment) => typeof segment == "string" ? `['${segment.replace(/[\f\n\r\t'\\]/g, (match) => ESCAPE[match])}']` : typeof segment == "number" ? `[${segment}]` : segment._key === "" ? `[${segment._index}]` : `[?(@._key=='${segment._key.replace(/['\\]/g, (match) => ESCAPE[match])}')]`);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
function parseJsonPath(path) {
|
|
84
|
+
let parsed = [], parseRe = /\['(.*?)'\]|\[(\d+)\]|\[\?\(@\._key=='(.*?)'\)\]/g, match;
|
|
85
|
+
for (; (match = parseRe.exec(path)) !== null;) {
|
|
86
|
+
if (match[1] !== void 0) {
|
|
87
|
+
let key = match[1].replace(/\\(\\|f|n|r|t|')/g, (m) => UNESCAPE[m]);
|
|
88
|
+
parsed.push(key);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (match[2] !== void 0) {
|
|
92
|
+
parsed.push(parseInt(match[2], 10));
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (match[3] !== void 0) {
|
|
96
|
+
let _key = match[3].replace(/\\(\\')/g, (m) => UNESCAPE[m]);
|
|
97
|
+
parsed.push({
|
|
98
|
+
_key,
|
|
99
|
+
_index: -1
|
|
100
|
+
});
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return parsed;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
function jsonPathToStudioPath(path) {
|
|
110
|
+
return path.map((segment) => {
|
|
111
|
+
if (typeof segment == "string" || typeof segment == "number") return segment;
|
|
112
|
+
if (segment._key !== "") return { _key: segment._key };
|
|
113
|
+
if (segment._index !== -1) return segment._index;
|
|
114
|
+
throw Error(`invalid segment:${JSON.stringify(segment)}`);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* @internal
|
|
119
|
+
*/
|
|
120
|
+
function jsonPathToMappingPath(path) {
|
|
121
|
+
return path.map((segment) => {
|
|
122
|
+
if (typeof segment == "string" || typeof segment == "number") return segment;
|
|
123
|
+
if (segment._index !== -1) return segment._index;
|
|
124
|
+
throw Error(`invalid segment:${JSON.stringify(segment)}`);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/** @internal */
|
|
128
|
+
function createEditUrl(options) {
|
|
129
|
+
let { baseUrl, workspace: _workspace = "default", tool: _tool = "default", id: _id, type, path, projectId, dataset } = options;
|
|
130
|
+
if (!baseUrl) throw Error("baseUrl is required");
|
|
131
|
+
if (!path) throw Error("path is required");
|
|
132
|
+
if (!_id) throw Error("id is required");
|
|
133
|
+
if (baseUrl !== "/" && baseUrl.endsWith("/")) throw Error("baseUrl must not end with a slash");
|
|
134
|
+
let workspace = _workspace === "default" ? void 0 : _workspace, tool = _tool === "default" ? void 0 : _tool, id = getPublishedId(_id), stringifiedPath = Array.isArray(path) ? toString(jsonPathToStudioPath(path)) : path, searchParams = new URLSearchParams({
|
|
135
|
+
baseUrl,
|
|
136
|
+
id,
|
|
137
|
+
type,
|
|
138
|
+
path: stringifiedPath
|
|
139
|
+
});
|
|
140
|
+
if (workspace && searchParams.set("workspace", workspace), tool && searchParams.set("tool", tool), projectId && searchParams.set("projectId", projectId), dataset && searchParams.set("dataset", dataset), isPublishedId(_id)) searchParams.set("perspective", "published");
|
|
141
|
+
else if (isVersionId(_id)) {
|
|
142
|
+
let versionId = getVersionFromId(_id);
|
|
143
|
+
searchParams.set("perspective", versionId);
|
|
144
|
+
}
|
|
145
|
+
let segments = [baseUrl === "/" ? "" : baseUrl];
|
|
146
|
+
workspace && segments.push(workspace);
|
|
147
|
+
let routerParams = [
|
|
148
|
+
"mode=presentation",
|
|
149
|
+
`id=${id}`,
|
|
150
|
+
`type=${type}`,
|
|
151
|
+
`path=${encodeURIComponent(stringifiedPath)}`
|
|
152
|
+
];
|
|
153
|
+
return tool && routerParams.push(`tool=${tool}`), segments.push("intent", "edit", `${routerParams.join(";")}?${searchParams}`), segments.join("/");
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* @internal
|
|
157
|
+
*/
|
|
158
|
+
function resolveMapping(resultPath, csm) {
|
|
159
|
+
if (!csm?.mappings) return;
|
|
160
|
+
let resultMappingPath = jsonPath(jsonPathToMappingPath(resultPath));
|
|
161
|
+
if (csm.mappings[resultMappingPath] !== void 0) return {
|
|
162
|
+
mapping: csm.mappings[resultMappingPath],
|
|
163
|
+
matchedPath: resultMappingPath,
|
|
164
|
+
pathSuffix: ""
|
|
165
|
+
};
|
|
166
|
+
let resultMappingPathArray = jsonPathArray(jsonPathToMappingPath(resultPath));
|
|
167
|
+
for (let i = resultMappingPathArray.length - 1; i >= 0; i--) {
|
|
168
|
+
let key = `$${resultMappingPathArray.slice(0, i).join("")}`, mappingFound = csm.mappings[key];
|
|
169
|
+
if (mappingFound) return {
|
|
170
|
+
mapping: mappingFound,
|
|
171
|
+
matchedPath: key,
|
|
172
|
+
pathSuffix: resultMappingPath.substring(key.length)
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/** @internal */
|
|
177
|
+
function resolveStudioBaseRoute(studioUrl) {
|
|
178
|
+
let baseUrl = typeof studioUrl == "string" ? studioUrl : studioUrl.baseUrl;
|
|
179
|
+
return baseUrl !== "/" && (baseUrl = baseUrl.replace(/\/$/, "")), typeof studioUrl == "string" ? { baseUrl } : {
|
|
180
|
+
...studioUrl,
|
|
181
|
+
baseUrl
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/** @internal */
|
|
185
|
+
function isArray(value) {
|
|
186
|
+
return value !== null && Array.isArray(value);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* generic way to walk a nested object or array and apply a mapping function to each value
|
|
190
|
+
* @internal
|
|
191
|
+
*/
|
|
192
|
+
function walkMap(value, mappingFn, path = []) {
|
|
193
|
+
if (isArray(value)) return value.map((v, idx) => {
|
|
194
|
+
if (isRecord(v)) {
|
|
195
|
+
let _key = v._key;
|
|
196
|
+
if (typeof _key == "string") return walkMap(v, mappingFn, path.concat({
|
|
197
|
+
_key,
|
|
198
|
+
_index: idx
|
|
199
|
+
}));
|
|
200
|
+
}
|
|
201
|
+
return walkMap(v, mappingFn, path.concat(idx));
|
|
202
|
+
});
|
|
203
|
+
if (isRecord(value)) {
|
|
204
|
+
if (value._type === "block" || value._type === "span") {
|
|
205
|
+
let result = { ...value };
|
|
206
|
+
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;
|
|
207
|
+
}
|
|
208
|
+
return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, walkMap(v, mappingFn, path.concat(k))]));
|
|
209
|
+
}
|
|
210
|
+
return mappingFn(value, path);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* @internal
|
|
214
|
+
*/
|
|
215
|
+
function encodeIntoResult(result, csm, encoder) {
|
|
216
|
+
return walkMap(result, (value, path) => {
|
|
217
|
+
if (typeof value != "string") return value;
|
|
218
|
+
let resolveMappingResult = resolveMapping(path, csm);
|
|
219
|
+
if (!resolveMappingResult) return value;
|
|
220
|
+
let { mapping, matchedPath } = resolveMappingResult;
|
|
221
|
+
if (mapping.type !== "value" || mapping.source.type !== "documentValue") return value;
|
|
222
|
+
let sourceDocument = csm.documents[mapping.source.document], sourcePath = csm.paths[mapping.source.path], matchPathSegments = parseJsonPath(matchedPath);
|
|
223
|
+
return encoder({
|
|
224
|
+
sourcePath: parseJsonPath(sourcePath).concat(path.slice(matchPathSegments.length)),
|
|
225
|
+
sourceDocument,
|
|
226
|
+
resultPath: path,
|
|
227
|
+
value
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
const filterDefault = ({ sourcePath, resultPath, value }) => {
|
|
232
|
+
if (isValidDate(value) || isValidURL(value)) return !1;
|
|
233
|
+
let endPath = sourcePath.at(-1);
|
|
234
|
+
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") || hasTypeLike(sourcePath) || hasTypeLike(resultPath) || typeof endPath == "string" && denylist.has(endPath));
|
|
235
|
+
}, denylist = /* @__PURE__ */ new Set(/* @__PURE__ */ "color.colour.currency.email.format.gid.hex.href.hsl.hsla.icon.id.index.key.language.layout.link.linkAction.locale.lqip.page.path.ref.rgb.rgba.route.secret.slug.status.tag.template.theme.type.textTheme.unit.url.username.variant.website".split("."));
|
|
236
|
+
function isValidDate(dateString) {
|
|
237
|
+
return /^\d{4}-\d{2}-\d{2}/.test(dateString) ? !!Date.parse(dateString) : !1;
|
|
238
|
+
}
|
|
239
|
+
const allowedProtocols = /* @__PURE__ */ new Set([
|
|
240
|
+
"app:",
|
|
241
|
+
"data:",
|
|
242
|
+
"discord:",
|
|
243
|
+
"file:",
|
|
244
|
+
"ftp:",
|
|
245
|
+
"ftps:",
|
|
246
|
+
"geo:",
|
|
247
|
+
"http:",
|
|
248
|
+
"https:",
|
|
249
|
+
"imap:",
|
|
250
|
+
"javascript:",
|
|
251
|
+
"magnet:",
|
|
252
|
+
"mailto:",
|
|
253
|
+
"maps:",
|
|
254
|
+
"ms-excel:",
|
|
255
|
+
"ms-powerpoint:",
|
|
256
|
+
"ms-word:",
|
|
257
|
+
"slack:",
|
|
258
|
+
"sms:",
|
|
259
|
+
"spotify:",
|
|
260
|
+
"steam:",
|
|
261
|
+
"teams:",
|
|
262
|
+
"tel:",
|
|
263
|
+
"vscode:",
|
|
264
|
+
"zoom:"
|
|
265
|
+
]);
|
|
266
|
+
function isValidURL(url) {
|
|
267
|
+
try {
|
|
268
|
+
let { protocol } = new URL(url, url.startsWith("/") ? "https://acme.com" : void 0);
|
|
269
|
+
return allowedProtocols.has(protocol) || protocol.startsWith("web+");
|
|
270
|
+
} catch {
|
|
271
|
+
return !1;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function hasTypeLike(path) {
|
|
275
|
+
return path.some((segment) => typeof segment == "string" && segment.match(/type/i) !== null);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Uses `@vercel/stega` to embed edit info JSON into strings in your query result.
|
|
279
|
+
* The JSON payloads are added using invisible characters so they don't show up visually.
|
|
280
|
+
* The edit info is generated from the Content Source Map (CSM) that is returned from Sanity for the query.
|
|
281
|
+
* @public
|
|
282
|
+
*/
|
|
283
|
+
function stegaEncodeSourceMap(result, resultSourceMap, config) {
|
|
284
|
+
let { filter, logger, enabled } = config;
|
|
285
|
+
if (!enabled) {
|
|
286
|
+
let msg = "config.enabled must be true, don't call this function otherwise";
|
|
287
|
+
throw logger?.error?.(`[@sanity/client]: ${msg}`, {
|
|
288
|
+
result,
|
|
289
|
+
resultSourceMap,
|
|
290
|
+
config
|
|
291
|
+
}), TypeError(msg);
|
|
292
|
+
}
|
|
293
|
+
if (!resultSourceMap) return logger?.error?.("[@sanity/client]: Missing Content Source Map from response body", {
|
|
294
|
+
result,
|
|
295
|
+
resultSourceMap,
|
|
296
|
+
config
|
|
297
|
+
}), result;
|
|
298
|
+
if (!config.studioUrl) {
|
|
299
|
+
let msg = "config.studioUrl must be defined";
|
|
300
|
+
throw logger?.error?.(`[@sanity/client]: ${msg}`, {
|
|
301
|
+
result,
|
|
302
|
+
resultSourceMap,
|
|
303
|
+
config
|
|
304
|
+
}), TypeError(msg);
|
|
305
|
+
}
|
|
306
|
+
let report = {
|
|
307
|
+
encoded: [],
|
|
308
|
+
skipped: []
|
|
309
|
+
}, resultWithStega = encodeIntoResult(result, resultSourceMap, ({ sourcePath, sourceDocument, resultPath, value }) => {
|
|
310
|
+
if ((typeof filter == "function" ? filter({
|
|
311
|
+
sourcePath,
|
|
312
|
+
resultPath,
|
|
313
|
+
filterDefault,
|
|
314
|
+
sourceDocument,
|
|
315
|
+
value
|
|
316
|
+
}) : filterDefault({
|
|
317
|
+
sourcePath,
|
|
318
|
+
resultPath,
|
|
319
|
+
filterDefault,
|
|
320
|
+
sourceDocument,
|
|
321
|
+
value
|
|
322
|
+
})) === !1) return logger && report.skipped.push({
|
|
323
|
+
path: prettyPathForLogging(sourcePath),
|
|
324
|
+
value: `${value.slice(0, 20)}${value.length > 20 ? "..." : ""}`,
|
|
325
|
+
length: value.length
|
|
326
|
+
}), value;
|
|
327
|
+
logger && report.encoded.push({
|
|
328
|
+
path: prettyPathForLogging(sourcePath),
|
|
329
|
+
value: `${value.slice(0, 20)}${value.length > 20 ? "..." : ""}`,
|
|
330
|
+
length: value.length
|
|
331
|
+
});
|
|
332
|
+
let { baseUrl, workspace, tool } = resolveStudioBaseRoute(typeof config.studioUrl == "function" ? config.studioUrl(sourceDocument) : config.studioUrl);
|
|
333
|
+
if (!baseUrl) return value;
|
|
334
|
+
let { _id: id, _type: type, _projectId: projectId, _dataset: dataset } = sourceDocument;
|
|
335
|
+
return (0, import_dist.vercelStegaCombine)(value, {
|
|
336
|
+
origin: "sanity.io",
|
|
337
|
+
href: createEditUrl({
|
|
338
|
+
baseUrl,
|
|
339
|
+
workspace,
|
|
340
|
+
tool,
|
|
341
|
+
id,
|
|
342
|
+
type,
|
|
343
|
+
path: sourcePath,
|
|
344
|
+
...!config.omitCrossDatasetReferenceData && {
|
|
345
|
+
dataset,
|
|
346
|
+
projectId
|
|
347
|
+
}
|
|
348
|
+
})
|
|
349
|
+
}, !1);
|
|
350
|
+
});
|
|
351
|
+
if (logger) {
|
|
352
|
+
let isSkipping = report.skipped.length, isEncoding = report.encoded.length;
|
|
353
|
+
if ((isSkipping || isEncoding) && ((logger?.groupCollapsed || logger.log)?.("[@sanity/client]: Encoding source map into result"), logger.log?.(`[@sanity/client]: Paths encoded: ${report.encoded.length}, skipped: ${report.skipped.length}`)), report.encoded.length > 0 && (logger?.log?.("[@sanity/client]: Table of encoded paths"), (logger?.table || logger.log)?.(report.encoded)), report.skipped.length > 0) {
|
|
354
|
+
let skipped = /* @__PURE__ */ new Set();
|
|
355
|
+
for (let { path } of report.skipped) skipped.add(path.replace(reKeySegment, "0").replace(/\[\d+\]/g, "[]"));
|
|
356
|
+
logger?.log?.("[@sanity/client]: List of skipped paths", [...skipped.values()]);
|
|
357
|
+
}
|
|
358
|
+
(isSkipping || isEncoding) && logger?.groupEnd?.();
|
|
359
|
+
}
|
|
360
|
+
return resultWithStega;
|
|
361
|
+
}
|
|
362
|
+
function prettyPathForLogging(path) {
|
|
363
|
+
return toString(jsonPathToStudioPath(path));
|
|
364
|
+
}
|
|
365
|
+
export { encodeIntoResult, stegaEncodeSourceMap };
|
|
366
|
+
|
|
367
|
+
//# sourceMappingURL=stegaEncodeSourceMap-DkoIlutY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stegaEncodeSourceMap-DkoIlutY.js","names":["studioPath.toString","vercelStegaCombine","studioPathToString"],"sources":["../src/csm/draftUtils.ts","../src/csm/studioPath.ts","../src/csm/jsonPath.ts","../src/csm/createEditUrl.ts","../src/csm/resolveMapping.ts","../src/csm/resolveEditInfo.ts","../src/csm/isArray.ts","../src/csm/walkMap.ts","../src/stega/encodeIntoResult.ts","../src/stega/filterDefault.ts","../src/stega/stegaEncodeSourceMap.ts"],"sourcesContent":["// nominal/opaque type hack\ntype Opaque<T, K> = T & {__opaqueId__: K}\n\n/** @internal */\nexport type DraftId = Opaque<string, 'draftId'>\n\n/** @internal */\nexport type PublishedId = Opaque<string, 'publishedId'>\n\n/** @internal */\nexport const DRAFTS_FOLDER = 'drafts'\n\n/** @internal */\nexport const VERSION_FOLDER = 'versions'\n\nconst PATH_SEPARATOR = '.'\nconst DRAFTS_PREFIX = `${DRAFTS_FOLDER}${PATH_SEPARATOR}`\nconst VERSION_PREFIX = `${VERSION_FOLDER}${PATH_SEPARATOR}`\n\n/** @internal */\nexport function isDraftId(id: string): id is DraftId {\n return id.startsWith(DRAFTS_PREFIX)\n}\n\n/** @internal */\nexport function isVersionId(id: string): boolean {\n return id.startsWith(VERSION_PREFIX)\n}\n\n/** @internal */\nexport function isPublishedId(id: string): id is PublishedId {\n return !isDraftId(id) && !isVersionId(id)\n}\n\n/** @internal */\nexport function getDraftId(id: string): DraftId {\n if (isVersionId(id)) {\n const publishedId = getPublishedId(id)\n return (DRAFTS_PREFIX + publishedId) as DraftId\n }\n\n return isDraftId(id) ? id : ((DRAFTS_PREFIX + id) as DraftId)\n}\n\n/** @internal */\nexport function getVersionId(id: string, version: string): string {\n if (version === 'drafts' || version === 'published') {\n throw new Error('Version can not be \"published\" or \"drafts\"')\n }\n\n return `${VERSION_PREFIX}${version}${PATH_SEPARATOR}${getPublishedId(id)}`\n}\n\n/**\n * @internal\n * Given an id, returns the versionId if it exists.\n * e.g. `versions.summer-drop.foo` = `summer-drop`\n * e.g. `drafts.foo` = `undefined`\n * e.g. `foo` = `undefined`\n */\nexport function getVersionFromId(id: string): string | undefined {\n if (!isVersionId(id)) return undefined\n const [_versionPrefix, versionId, ..._publishedId] = id.split(PATH_SEPARATOR)\n\n return versionId\n}\n\n/** @internal */\nexport function getPublishedId(id: string): PublishedId {\n if (isVersionId(id)) {\n // make sure to only remove the versions prefix and the bundle name\n return id.split(PATH_SEPARATOR).slice(2).join(PATH_SEPARATOR) as PublishedId as PublishedId\n }\n\n if (isDraftId(id)) {\n return id.slice(DRAFTS_PREFIX.length) as PublishedId\n }\n\n return id as PublishedId\n}\n","/** @alpha */\nexport type KeyedSegment = {_key: string}\n\n/** @alpha */\nexport type IndexTuple = [number | '', number | '']\n\n/** @alpha */\nexport type PathSegment = string | number | KeyedSegment | IndexTuple\n\n/** @alpha */\nexport type Path = PathSegment[]\n\nconst rePropName =\n /[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g\n/** @internal */\nexport const reKeySegment = /_key\\s*==\\s*['\"](.*)['\"]/\nconst reIndexTuple = /^\\d*:\\d*$/\n\n/** @internal */\nexport function isIndexSegment(segment: PathSegment): segment is number {\n return typeof segment === 'number' || (typeof segment === 'string' && /^\\[\\d+\\]$/.test(segment))\n}\n\n/** @internal */\nexport function isKeySegment(segment: PathSegment): segment is KeyedSegment {\n if (typeof segment === 'string') {\n return reKeySegment.test(segment.trim())\n }\n\n return typeof segment === 'object' && '_key' in segment\n}\n\n/** @internal */\nexport function isIndexTuple(segment: PathSegment): segment is IndexTuple {\n if (typeof segment === 'string' && reIndexTuple.test(segment)) {\n return true\n }\n\n if (!Array.isArray(segment) || segment.length !== 2) {\n return false\n }\n\n const [from, to] = segment\n return (typeof from === 'number' || from === '') && (typeof to === 'number' || to === '')\n}\n\n/** @internal */\n// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- caller-supplied return type; removing it breaks `get<Result>(...)` call sites\nexport function get<Result = unknown, Fallback = unknown>(\n obj: unknown,\n path: Path | string,\n defaultVal?: Fallback,\n): Result | typeof defaultVal {\n const select = typeof path === 'string' ? fromString(path) : path\n if (!Array.isArray(select)) {\n throw new Error('Path must be an array or a string')\n }\n\n let acc: unknown = obj\n for (let i = 0; i < select.length; i++) {\n const segment = select[i]\n if (isIndexSegment(segment)) {\n if (!Array.isArray(acc)) {\n return defaultVal\n }\n\n acc = acc[segment]\n }\n\n if (isKeySegment(segment)) {\n if (!Array.isArray(acc)) {\n return defaultVal\n }\n\n acc = acc.find((item) => item._key === segment._key)\n }\n\n if (typeof segment === 'string') {\n acc =\n typeof acc === 'object' && acc !== null\n ? ((acc as Record<string, unknown>)[segment] as Result)\n : undefined\n }\n\n if (typeof acc === 'undefined') {\n return defaultVal\n }\n }\n\n return acc as Result\n}\n\n/** @alpha */\nexport function toString(path: Path): string {\n if (!Array.isArray(path)) {\n throw new Error('Path is not an array')\n }\n\n return path.reduce<string>((target, segment, i) => {\n const segmentType = typeof segment\n if (segmentType === 'number') {\n return `${target}[${segment}]`\n }\n\n if (segmentType === 'string') {\n const separator = i === 0 ? '' : '.'\n return `${target}${separator}${segment}`\n }\n\n if (isKeySegment(segment) && segment._key) {\n return `${target}[_key==\"${segment._key}\"]`\n }\n\n if (Array.isArray(segment)) {\n const [from, to] = segment\n return `${target}[${from}:${to}]`\n }\n\n throw new Error(`Unsupported path segment \\`${JSON.stringify(segment)}\\``)\n }, '')\n}\n\n/** @alpha */\nexport function fromString(path: string): Path {\n if (typeof path !== 'string') {\n throw new Error('Path is not a string')\n }\n\n const segments = path.match(rePropName)\n if (!segments) {\n throw new Error('Invalid path string')\n }\n\n return segments.map(parsePathSegment)\n}\n\nfunction parsePathSegment(segment: string): PathSegment {\n if (isIndexSegment(segment)) {\n return parseIndexSegment(segment)\n }\n\n if (isKeySegment(segment)) {\n return parseKeySegment(segment)\n }\n\n if (isIndexTuple(segment)) {\n return parseIndexTupleSegment(segment)\n }\n\n return segment\n}\n\nfunction parseIndexSegment(segment: string): PathSegment {\n return Number(segment.replace(/[^\\d]/g, ''))\n}\n\nfunction parseKeySegment(segment: string): KeyedSegment {\n const segments = segment.match(reKeySegment)\n return {_key: segments![1]}\n}\n\nfunction parseIndexTupleSegment(segment: string): IndexTuple {\n const [from, to] = segment.split(':').map((seg) => (seg === '' ? seg : Number(seg)))\n return [from, to]\n}\n","import * as studioPath from './studioPath'\nimport type {\n ContentSourceMapParsedPath,\n ContentSourceMapParsedPathKeyedSegment,\n ContentSourceMapPaths,\n Path,\n} from './types'\n\nconst ESCAPE: Record<string, string> = {\n '\\f': '\\\\f',\n '\\n': '\\\\n',\n '\\r': '\\\\r',\n '\\t': '\\\\t',\n \"'\": \"\\\\'\",\n '\\\\': '\\\\\\\\',\n}\n\nconst UNESCAPE: Record<string, string> = {\n '\\\\f': '\\f',\n '\\\\n': '\\n',\n '\\\\r': '\\r',\n '\\\\t': '\\t',\n \"\\\\'\": \"'\",\n '\\\\\\\\': '\\\\',\n}\n\n/**\n * @internal\n */\nexport function jsonPath(path: ContentSourceMapParsedPath): ContentSourceMapPaths[number] {\n return `$${path\n .map((segment) => {\n if (typeof segment === 'string') {\n const escapedKey = segment.replace(/[\\f\\n\\r\\t'\\\\]/g, (match) => {\n return ESCAPE[match]\n })\n return `['${escapedKey}']`\n }\n\n if (typeof segment === 'number') {\n return `[${segment}]`\n }\n\n if (segment._key !== '') {\n const escapedKey = segment._key.replace(/['\\\\]/g, (match) => {\n return ESCAPE[match]\n })\n return `[?(@._key=='${escapedKey}')]`\n }\n\n return `[${segment._index}]`\n })\n .join('')}`\n}\n/**\n * @internal\n */\nexport function jsonPathArray(path: ContentSourceMapParsedPath): string[] {\n return path.map((segment) => {\n if (typeof segment === 'string') {\n const escapedKey = segment.replace(/[\\f\\n\\r\\t'\\\\]/g, (match) => {\n return ESCAPE[match]\n })\n return `['${escapedKey}']`\n }\n\n if (typeof segment === 'number') {\n return `[${segment}]`\n }\n\n if (segment._key !== '') {\n const escapedKey = segment._key.replace(/['\\\\]/g, (match) => {\n return ESCAPE[match]\n })\n return `[?(@._key=='${escapedKey}')]`\n }\n\n return `[${segment._index}]`\n })\n}\n\n/**\n * @internal\n */\nexport function parseJsonPath(path: ContentSourceMapPaths[number]): ContentSourceMapParsedPath {\n const parsed: ContentSourceMapParsedPath = []\n\n const parseRe = /\\['(.*?)'\\]|\\[(\\d+)\\]|\\[\\?\\(@\\._key=='(.*?)'\\)\\]/g\n let match: RegExpExecArray | null\n\n while ((match = parseRe.exec(path)) !== null) {\n if (match[1] !== undefined) {\n const key = match[1].replace(/\\\\(\\\\|f|n|r|t|')/g, (m) => {\n return UNESCAPE[m]\n })\n\n parsed.push(key)\n continue\n }\n\n if (match[2] !== undefined) {\n parsed.push(parseInt(match[2], 10))\n continue\n }\n\n if (match[3] !== undefined) {\n const _key = match[3].replace(/\\\\(\\\\')/g, (m) => {\n return UNESCAPE[m]\n })\n\n parsed.push({\n _key,\n _index: -1,\n })\n continue\n }\n }\n\n return parsed\n}\n\n/**\n * @internal\n */\nexport function jsonPathToStudioPath(path: ContentSourceMapParsedPath): Path {\n return path.map((segment) => {\n if (typeof segment === 'string') {\n return segment\n }\n\n if (typeof segment === 'number') {\n return segment\n }\n\n if (segment._key !== '') {\n return {_key: segment._key}\n }\n\n if (segment._index !== -1) {\n return segment._index\n }\n\n throw new Error(`invalid segment:${JSON.stringify(segment)}`)\n })\n}\n\n/**\n * @internal\n */\nexport function studioPathToJsonPath(path: Path | string): ContentSourceMapParsedPath {\n const parsedPath = typeof path === 'string' ? studioPath.fromString(path) : path\n\n return parsedPath.map((segment) => {\n if (typeof segment === 'string') {\n return segment\n }\n\n if (typeof segment === 'number') {\n return segment\n }\n\n if (Array.isArray(segment)) {\n throw new Error(`IndexTuple segments aren't supported:${JSON.stringify(segment)}`)\n }\n\n if (isContentSourceMapParsedPathKeyedSegment(segment)) {\n return segment\n }\n\n if (segment._key) {\n return {_key: segment._key, _index: -1}\n }\n\n throw new Error(`invalid segment:${JSON.stringify(segment)}`)\n })\n}\n\nfunction isContentSourceMapParsedPathKeyedSegment(\n segment: studioPath.PathSegment | ContentSourceMapParsedPath[number],\n): segment is ContentSourceMapParsedPathKeyedSegment {\n return typeof segment === 'object' && '_key' in segment && '_index' in segment\n}\n\n/**\n * @internal\n */\nexport function jsonPathToMappingPath(path: ContentSourceMapParsedPath): (string | number)[] {\n return path.map((segment) => {\n if (typeof segment === 'string') {\n return segment\n }\n\n if (typeof segment === 'number') {\n return segment\n }\n\n if (segment._index !== -1) {\n return segment._index\n }\n\n throw new Error(`invalid segment:${JSON.stringify(segment)}`)\n })\n}\n","import {getPublishedId, getVersionFromId, isPublishedId, isVersionId} from './draftUtils'\nimport {jsonPathToStudioPath} from './jsonPath'\nimport * as studioPath from './studioPath'\nimport type {CreateEditUrlOptions, EditIntentUrl, StudioBaseUrl} from './types'\n\n/** @internal */\nexport function createEditUrl(options: CreateEditUrlOptions): `${StudioBaseUrl}${EditIntentUrl}` {\n const {\n baseUrl,\n workspace: _workspace = 'default',\n tool: _tool = 'default',\n id: _id,\n type,\n path,\n projectId,\n dataset,\n } = options\n\n if (!baseUrl) {\n throw new Error('baseUrl is required')\n }\n if (!path) {\n throw new Error('path is required')\n }\n if (!_id) {\n throw new Error('id is required')\n }\n if (baseUrl !== '/' && baseUrl.endsWith('/')) {\n throw new Error('baseUrl must not end with a slash')\n }\n\n const workspace = _workspace === 'default' ? undefined : _workspace\n const tool = _tool === 'default' ? undefined : _tool\n const id = getPublishedId(_id)\n const stringifiedPath = Array.isArray(path)\n ? studioPath.toString(jsonPathToStudioPath(path))\n : path\n\n // oxlint-disable-next-line no-warning-comments\n // @TODO Using searchParams as a temporary workaround until `@sanity/overlays` can decode state from the path reliably\n const searchParams = new URLSearchParams({\n baseUrl,\n id,\n type,\n path: stringifiedPath,\n })\n if (workspace) {\n searchParams.set('workspace', workspace)\n }\n if (tool) {\n searchParams.set('tool', tool)\n }\n if (projectId) {\n searchParams.set('projectId', projectId)\n }\n if (dataset) {\n searchParams.set('dataset', dataset)\n }\n if (isPublishedId(_id)) {\n searchParams.set('perspective', 'published')\n } else if (isVersionId(_id)) {\n const versionId = getVersionFromId(_id)!\n searchParams.set('perspective', versionId)\n }\n\n const segments = [baseUrl === '/' ? '' : baseUrl]\n if (workspace) {\n segments.push(workspace)\n }\n const routerParams = [\n 'mode=presentation',\n `id=${id}`,\n `type=${type}`,\n `path=${encodeURIComponent(stringifiedPath)}`,\n ]\n if (tool) {\n routerParams.push(`tool=${tool}`)\n }\n segments.push('intent', 'edit', `${routerParams.join(';')}?${searchParams}`)\n return segments.join('/') as unknown as `${StudioBaseUrl}${EditIntentUrl}`\n}\n","import {jsonPath, jsonPathArray, jsonPathToMappingPath} from './jsonPath'\nimport type {ContentSourceMap, ContentSourceMapMapping, ContentSourceMapParsedPath} from './types'\n\n/**\n * @internal\n */\nexport function resolveMapping(\n resultPath: ContentSourceMapParsedPath,\n csm?: ContentSourceMap,\n):\n | {\n mapping: ContentSourceMapMapping\n matchedPath: string\n pathSuffix: string\n }\n | undefined {\n if (!csm?.mappings) {\n return undefined\n }\n const resultMappingPath = jsonPath(jsonPathToMappingPath(resultPath))\n\n if (csm.mappings[resultMappingPath] !== undefined) {\n return {\n mapping: csm.mappings[resultMappingPath],\n matchedPath: resultMappingPath,\n pathSuffix: '',\n }\n }\n\n const resultMappingPathArray = jsonPathArray(jsonPathToMappingPath(resultPath))\n for (let i = resultMappingPathArray.length - 1; i >= 0; i--) {\n const key = `$${resultMappingPathArray.slice(0, i).join('')}`\n const mappingFound = csm.mappings[key]\n if (mappingFound) {\n const pathSuffix = resultMappingPath.substring(key.length)\n return {mapping: mappingFound, matchedPath: key, pathSuffix}\n }\n }\n\n return undefined\n}\n","import {parseJsonPath} from './jsonPath'\nimport {resolveMapping} from './resolveMapping'\nimport type {\n CreateEditUrlOptions,\n ResolveEditInfoOptions,\n StudioBaseRoute,\n StudioBaseUrl,\n StudioUrl,\n} from './types'\n\n/** @internal */\nexport function resolveEditInfo(options: ResolveEditInfoOptions): CreateEditUrlOptions | undefined {\n const {resultSourceMap: csm, resultPath} = options\n const {mapping, pathSuffix} = resolveMapping(resultPath, csm) || {}\n\n if (!mapping) {\n // console.warn('no mapping for path', { path: resultPath, sourceMap: csm })\n return undefined\n }\n\n if (mapping.source.type === 'literal') {\n return undefined\n }\n\n if (mapping.source.type === 'unknown') {\n return undefined\n }\n\n const sourceDoc = csm.documents[mapping.source.document]\n const sourcePath = csm.paths[mapping.source.path]\n\n if (sourceDoc && sourcePath) {\n const {baseUrl, workspace, tool} = resolveStudioBaseRoute(\n typeof options.studioUrl === 'function' ? options.studioUrl(sourceDoc) : options.studioUrl,\n )\n if (!baseUrl) return undefined\n const {_id, _type, _projectId, _dataset} = sourceDoc\n return {\n baseUrl,\n workspace,\n tool,\n id: _id,\n type: _type,\n path: parseJsonPath(sourcePath + pathSuffix),\n projectId: _projectId,\n dataset: _dataset,\n } satisfies CreateEditUrlOptions\n }\n\n return undefined\n}\n\n/** @internal */\nexport function resolveStudioBaseRoute(studioUrl: StudioUrl): StudioBaseRoute {\n let baseUrl: StudioBaseUrl = typeof studioUrl === 'string' ? studioUrl : studioUrl.baseUrl\n if (baseUrl !== '/') {\n baseUrl = baseUrl.replace(/\\/$/, '')\n }\n if (typeof studioUrl === 'string') {\n return {baseUrl}\n }\n return {...studioUrl, baseUrl}\n}\n","/** @internal */\nexport function isArray(value: unknown): value is Array<unknown> {\n return value !== null && Array.isArray(value)\n}\n","import {isRecord} from '../util/isRecord'\nimport {isArray} from './isArray'\nimport type {ContentSourceMapParsedPath, WalkMapFn} from './types'\n\n/**\n * generic way to walk a nested object or array and apply a mapping function to each value\n * @internal\n */\nexport function walkMap(\n value: unknown,\n mappingFn: WalkMapFn,\n path: ContentSourceMapParsedPath = [],\n): unknown {\n if (isArray(value)) {\n return value.map((v, idx) => {\n if (isRecord(v)) {\n const _key = v['_key']\n if (typeof _key === 'string') {\n return walkMap(v, mappingFn, path.concat({_key, _index: idx}))\n }\n }\n\n return walkMap(v, mappingFn, path.concat(idx))\n })\n }\n\n if (isRecord(value)) {\n // Handle Portable Text in a faster way\n if (value._type === 'block' || value._type === 'span') {\n const result = {...value}\n if (value._type === 'block') {\n result.children = walkMap(value.children, mappingFn, path.concat('children'))\n } else if (value._type === 'span') {\n result.text = walkMap(value.text, mappingFn, path.concat('text'))\n }\n return result\n }\n\n return Object.fromEntries(\n Object.entries(value).map(([k, v]) => [k, walkMap(v, mappingFn, path.concat(k))]),\n )\n }\n\n return mappingFn(value, path)\n}\n","import type {ContentSourceMap} from '@sanity/client/csm'\n\nimport {parseJsonPath} from '../csm/jsonPath'\nimport {resolveMapping} from '../csm/resolveMapping'\nimport {walkMap} from '../csm/walkMap'\nimport type {Encoder} from './types'\n\n/**\n * @internal\n */\nexport function encodeIntoResult<Result>(\n result: Result,\n csm: ContentSourceMap,\n encoder: Encoder,\n): Result {\n return walkMap(result, (value, path) => {\n // Only map strings, we could extend this in the future to support other types like integers...\n if (typeof value !== 'string') {\n return value\n }\n\n const resolveMappingResult = resolveMapping(path, csm)\n if (!resolveMappingResult) {\n return value\n }\n\n const {mapping, matchedPath} = resolveMappingResult\n if (mapping.type !== 'value') {\n return value\n }\n\n if (mapping.source.type !== 'documentValue') {\n return value\n }\n\n const sourceDocument = csm.documents[mapping.source.document!]\n const sourcePath = csm.paths[mapping.source.path]\n\n const matchPathSegments = parseJsonPath(matchedPath)\n const sourcePathSegments = parseJsonPath(sourcePath)\n const fullSourceSegments = sourcePathSegments.concat(path.slice(matchPathSegments.length))\n\n return encoder({\n sourcePath: fullSourceSegments,\n sourceDocument,\n resultPath: path,\n value,\n })\n }) as Result\n}\n","import type {ContentSourceMapParsedPath, FilterDefault} from './types'\n\nexport const filterDefault: FilterDefault = ({sourcePath, resultPath, value}) => {\n // Skips encoding on URL or Date strings, similar to the `skip: 'auto'` parameter in vercelStegaCombine()\n if (isValidDate(value) || isValidURL(value)) {\n return false\n }\n\n const endPath = sourcePath.at(-1)\n // Never encode slugs\n if (sourcePath.at(-2) === 'slug' && endPath === 'current') {\n return false\n }\n\n // Skip underscored keys, and strings that end with `Id`, needs better heuristics but it works for now\n if (typeof endPath === 'string' && (endPath.startsWith('_') || endPath.endsWith('Id'))) {\n return false\n }\n\n // Don't encode into anything that is suggested it'll render for SEO in meta tags\n if (\n sourcePath.some(\n (path) => path === 'meta' || path === 'metadata' || path === 'openGraph' || path === 'seo',\n )\n ) {\n return false\n }\n\n // If the sourcePath or resultPath contains something that sounds like a type, like iconType, we skip encoding, as it's most\n // of the time used for logic that breaks if it contains stega characters\n if (hasTypeLike(sourcePath) || hasTypeLike(resultPath)) {\n return false\n }\n\n // Finally, we ignore a bunch of paths that are typically used for page building\n if (typeof endPath === 'string' && denylist.has(endPath)) {\n return false\n }\n\n return true\n}\n\nconst denylist = new Set([\n 'color',\n 'colour',\n 'currency',\n 'email',\n 'format',\n 'gid',\n 'hex',\n 'href',\n 'hsl',\n 'hsla',\n 'icon',\n 'id',\n 'index',\n 'key',\n 'language',\n 'layout',\n 'link',\n 'linkAction',\n 'locale',\n 'lqip',\n 'page',\n 'path',\n 'ref',\n 'rgb',\n 'rgba',\n 'route',\n 'secret',\n 'slug',\n 'status',\n 'tag',\n 'template',\n 'theme',\n 'type',\n 'textTheme',\n 'unit',\n 'url',\n 'username',\n 'variant',\n 'website',\n])\n\nfunction isValidDate(dateString: string) {\n return /^\\d{4}-\\d{2}-\\d{2}/.test(dateString) ? Boolean(Date.parse(dateString)) : false\n}\n\nconst allowedProtocols = new Set([\n 'app:',\n 'data:',\n 'discord:',\n 'file:',\n 'ftp:',\n 'ftps:',\n 'geo:',\n 'http:',\n 'https:',\n 'imap:',\n 'javascript:',\n 'magnet:',\n 'mailto:',\n 'maps:',\n 'ms-excel:',\n 'ms-powerpoint:',\n 'ms-word:',\n 'slack:',\n 'sms:',\n 'spotify:',\n 'steam:',\n 'teams:',\n 'tel:',\n 'vscode:',\n 'zoom:',\n])\n\nfunction isValidURL(url: string) {\n try {\n const {protocol} = new URL(url, url.startsWith('/') ? 'https://acme.com' : undefined)\n return allowedProtocols.has(protocol) || protocol.startsWith('web+')\n } catch {\n return false\n }\n}\n\nfunction hasTypeLike(path: ContentSourceMapParsedPath): boolean {\n return path.some((segment) => typeof segment === 'string' && segment.match(/type/i) !== null)\n}\n","import {vercelStegaCombine} from '@vercel/stega'\n\nimport {createEditUrl} from '../csm/createEditUrl'\nimport {jsonPathToStudioPath} from '../csm/jsonPath'\nimport {resolveStudioBaseRoute} from '../csm/resolveEditInfo'\nimport {reKeySegment, toString as studioPathToString} from '../csm/studioPath'\nimport {encodeIntoResult} from './encodeIntoResult'\n// Re-export so `encodeIntoResult` is a genuine export of this module - which\n// forms its own output chunk via the dynamic import in `dataMethods`. Without\n// this, rolldown absorbs `encodeIntoResult` into the chunk but omits it from\n// the chunk's exports, breaking `@sanity/client/stega`'s re-export of it.\nexport {encodeIntoResult} from './encodeIntoResult'\nimport {filterDefault} from './filterDefault'\nimport {\n type ContentSourceMap,\n type ContentSourceMapParsedPath,\n type InitializedStegaConfig,\n} from './types'\n\nconst TRUNCATE_LENGTH = 20\n\n/**\n * Uses `@vercel/stega` to embed edit info JSON into strings in your query result.\n * The JSON payloads are added using invisible characters so they don't show up visually.\n * The edit info is generated from the Content Source Map (CSM) that is returned from Sanity for the query.\n * @public\n */\nexport function stegaEncodeSourceMap<Result = unknown>(\n result: Result,\n resultSourceMap: ContentSourceMap | undefined,\n config: InitializedStegaConfig,\n): Result {\n const {filter, logger, enabled} = config\n if (!enabled) {\n const msg = \"config.enabled must be true, don't call this function otherwise\"\n logger?.error?.(`[@sanity/client]: ${msg}`, {result, resultSourceMap, config})\n throw new TypeError(msg)\n }\n\n if (!resultSourceMap) {\n logger?.error?.('[@sanity/client]: Missing Content Source Map from response body', {\n result,\n resultSourceMap,\n config,\n })\n return result\n }\n\n if (!config.studioUrl) {\n const msg = 'config.studioUrl must be defined'\n logger?.error?.(`[@sanity/client]: ${msg}`, {result, resultSourceMap, config})\n throw new TypeError(msg)\n }\n\n const report: Record<'encoded' | 'skipped', {path: string; length: number; value: string}[]> = {\n encoded: [],\n skipped: [],\n }\n\n const resultWithStega = encodeIntoResult(\n result,\n resultSourceMap,\n ({sourcePath, sourceDocument, resultPath, value}) => {\n // Allow userland to control when to opt-out of encoding\n if (\n (typeof filter === 'function'\n ? filter({sourcePath, resultPath, filterDefault, sourceDocument, value})\n : filterDefault({sourcePath, resultPath, filterDefault, sourceDocument, value})) === false\n ) {\n if (logger) {\n report.skipped.push({\n path: prettyPathForLogging(sourcePath),\n value: `${value.slice(0, TRUNCATE_LENGTH)}${\n value.length > TRUNCATE_LENGTH ? '...' : ''\n }`,\n length: value.length,\n })\n }\n return value\n }\n\n if (logger) {\n report.encoded.push({\n path: prettyPathForLogging(sourcePath),\n value: `${value.slice(0, TRUNCATE_LENGTH)}${value.length > TRUNCATE_LENGTH ? '...' : ''}`,\n length: value.length,\n })\n }\n\n const {baseUrl, workspace, tool} = resolveStudioBaseRoute(\n typeof config.studioUrl === 'function'\n ? config.studioUrl(sourceDocument)\n : config.studioUrl!,\n )\n if (!baseUrl) return value\n const {_id: id, _type: type, _projectId: projectId, _dataset: dataset} = sourceDocument\n\n return vercelStegaCombine(\n value,\n {\n origin: 'sanity.io',\n href: createEditUrl({\n baseUrl,\n workspace,\n tool,\n id,\n type,\n path: sourcePath,\n ...(!config.omitCrossDatasetReferenceData && {dataset, projectId}),\n }),\n },\n // We use custom logic to determine if we should skip encoding\n false,\n )\n },\n )\n\n if (logger) {\n const isSkipping = report.skipped.length\n const isEncoding = report.encoded.length\n if (isSkipping || isEncoding) {\n ;(logger?.groupCollapsed || logger.log)?.('[@sanity/client]: Encoding source map into result')\n logger.log?.(\n `[@sanity/client]: Paths encoded: ${report.encoded.length}, skipped: ${report.skipped.length}`,\n )\n }\n if (report.encoded.length > 0) {\n logger?.log?.(`[@sanity/client]: Table of encoded paths`)\n ;(logger?.table || logger.log)?.(report.encoded)\n }\n if (report.skipped.length > 0) {\n const skipped = new Set<string>()\n for (const {path} of report.skipped) {\n skipped.add(path.replace(reKeySegment, '0').replace(/\\[\\d+\\]/g, '[]'))\n }\n logger?.log?.(`[@sanity/client]: List of skipped paths`, [...skipped.values()])\n }\n\n if (isSkipping || isEncoding) {\n logger?.groupEnd?.()\n }\n }\n\n return resultWithStega\n}\n\nfunction prettyPathForLogging(path: ContentSourceMapParsedPath): string {\n return studioPathToString(jsonPathToStudioPath(path))\n}\n"],"mappings":";;;;AAoBA,SAAgB,UAAU,IAA2B;CACnD,OAAO,GAAG,WAAW,SAAa;AACpC;;AAGA,SAAgB,YAAY,IAAqB;CAC/C,OAAO,GAAG,WAAW,WAAc;AACrC;;AAGA,SAAgB,cAAc,IAA+B;CAC3D,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,YAAY,EAAE;AAC1C;;;;;;;;AA4BA,SAAgB,iBAAiB,IAAgC;CAC/D,IAAI,CAAC,YAAY,EAAE,GAAG;CACtB,IAAM,CAAC,gBAAgB,WAAW,GAAG,gBAAgB,GAAG,MAAM,GAAc;CAE5E,OAAO;A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