@sanity/client 6.7.1 → 6.8.0-pink-lizard.1

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.
Files changed (65) hide show
  1. package/README.md +79 -2
  2. package/dist/_chunks/browserMiddleware-Oa7zKwEN.js +1862 -0
  3. package/dist/_chunks/browserMiddleware-Oa7zKwEN.js.map +1 -0
  4. package/dist/_chunks/browserMiddleware-zle5A-pb.cjs +1877 -0
  5. package/dist/_chunks/browserMiddleware-zle5A-pb.cjs.map +1 -0
  6. package/dist/_chunks/createEditLink-FiifjNgi.cjs +222 -0
  7. package/dist/_chunks/createEditLink-FiifjNgi.cjs.map +1 -0
  8. package/dist/_chunks/createEditLink-f3l2nngi.js +212 -0
  9. package/dist/_chunks/createEditLink-f3l2nngi.js.map +1 -0
  10. package/dist/_chunks/nodeMiddleware-S6QZVGmT.cjs +1897 -0
  11. package/dist/_chunks/nodeMiddleware-S6QZVGmT.cjs.map +1 -0
  12. package/dist/_chunks/nodeMiddleware-XodpBhbR.js +1882 -0
  13. package/dist/_chunks/nodeMiddleware-XodpBhbR.js.map +1 -0
  14. package/dist/csm.cjs +71 -0
  15. package/dist/csm.cjs.map +1 -0
  16. package/dist/csm.d.ts +248 -0
  17. package/dist/csm.js +58 -0
  18. package/dist/csm.js.map +1 -0
  19. package/dist/index.browser.cjs +13 -1868
  20. package/dist/index.browser.cjs.map +1 -1
  21. package/dist/index.browser.js +3 -1858
  22. package/dist/index.browser.js.map +1 -1
  23. package/dist/index.cjs +13 -1888
  24. package/dist/index.cjs.js +2 -2
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.js +3 -1878
  27. package/dist/index.js.map +1 -1
  28. package/dist/stega.browser.cjs +629 -0
  29. package/dist/stega.browser.cjs.map +1 -0
  30. package/dist/stega.browser.js +598 -0
  31. package/dist/stega.browser.js.map +1 -0
  32. package/dist/stega.cjs +424 -0
  33. package/dist/stega.cjs.js +21 -0
  34. package/dist/stega.cjs.map +1 -0
  35. package/dist/stega.d.ts +2872 -0
  36. package/dist/stega.js +393 -0
  37. package/dist/stega.js.map +1 -0
  38. package/package.json +42 -2
  39. package/src/config.ts +6 -0
  40. package/src/csm/applySourceDocuments.test.ts +820 -0
  41. package/src/csm/applySourceDocuments.ts +87 -0
  42. package/src/csm/createEditLink.ts +75 -0
  43. package/src/csm/getPublishedId.ts +12 -0
  44. package/src/csm/index.ts +9 -0
  45. package/src/csm/isArray.ts +3 -0
  46. package/src/csm/isRecord.ts +3 -0
  47. package/src/csm/jsonpath.test.ts +33 -0
  48. package/src/csm/jsonpath.ts +93 -0
  49. package/src/csm/resolveMapping.ts +41 -0
  50. package/src/csm/resolvedKeyedSourcePath.ts +23 -0
  51. package/src/csm/simplifyPath.ts +20 -0
  52. package/src/csm/types.ts +72 -0
  53. package/src/csm/walkMap.ts +30 -0
  54. package/src/stega/SanityStegaClient.ts +244 -0
  55. package/src/stega/config.ts +56 -0
  56. package/src/stega/encodeIntoResult.test.ts +268 -0
  57. package/src/stega/encodeIntoResult.ts +59 -0
  58. package/src/stega/filterDefault.ts +49 -0
  59. package/src/stega/index.browser.ts +19 -0
  60. package/src/stega/index.ts +19 -0
  61. package/src/stega/shared.ts +4 -0
  62. package/src/stega/stegaEncodeSourceMap.ts +128 -0
  63. package/src/stega/types.ts +139 -0
  64. package/umd/sanityClient.js +5 -1
  65. package/umd/sanityClient.min.js +1 -1
package/dist/stega.js ADDED
@@ -0,0 +1,393 @@
1
+ import { ObservableSanityClient, defaultConfig, SanityClient, defineCreateClientExports, middleware } from './_chunks/nodeMiddleware-XodpBhbR.js';
2
+ export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableTransaction, Patch, ServerError, Transaction } from './_chunks/nodeMiddleware-XodpBhbR.js';
3
+ import { map } from 'rxjs/operators';
4
+ import { vercelStegaCombine } from '@vercel/stega';
5
+ import { walkMap, resolveMapping, parseJsonPath, createEditLink } from './_chunks/createEditLink-f3l2nngi.js';
6
+ export { adapter as unstable__adapter, environment as unstable__environment } from 'get-it';
7
+ const defaultStegaConfig = {
8
+ enabled: false,
9
+ filter: props => props.filterDefault(props),
10
+ vercelStegaCombineSkip: "auto"
11
+ };
12
+ function splitConfig(config) {
13
+ const {
14
+ stega = {},
15
+ ...clientConfig
16
+ } = config;
17
+ return {
18
+ clientConfig,
19
+ stegaConfig: stega
20
+ };
21
+ }
22
+ const initStegaConfig = (config, prevConfig) => {
23
+ const specifiedConfig = Object.assign({}, prevConfig, config);
24
+ const newConfig = Object.assign({}, defaultStegaConfig, specifiedConfig);
25
+ if ("encodeSourceMap" in newConfig) {
26
+ throw new Error("It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMap' is not supported in '@sanity/client/stega'. Did you mean 'enabled'?");
27
+ }
28
+ if ("encodeSourceMapAtPath" in newConfig) {
29
+ throw new Error("It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMapAtPath' is not supported in '@sanity/client/stega'. Did you mean 'filter'?");
30
+ }
31
+ if (typeof newConfig.enabled !== "boolean") {
32
+ throw new Error("config.enabled must be a boolean, received ".concat(newConfig.enabled));
33
+ }
34
+ if (newConfig.enabled && newConfig.studioUrl === void 0) {
35
+ throw new Error("config.studioUrl must be defined when config.enabled is true");
36
+ }
37
+ if (newConfig.enabled && typeof newConfig.studioUrl !== "string" && typeof newConfig.studioUrl !== "function") {
38
+ throw new Error("config.studioUrl must be a string or a function, received ".concat(newConfig.studioUrl));
39
+ }
40
+ return newConfig;
41
+ };
42
+ function encodeIntoResult(result, csm, encoder, options) {
43
+ return walkMap(result, (value, path) => {
44
+ if (typeof value !== "string") {
45
+ return value;
46
+ }
47
+ const resolveMappingResult = resolveMapping(path, csm);
48
+ if (!resolveMappingResult) {
49
+ return value;
50
+ }
51
+ const {
52
+ mapping,
53
+ matchedPath,
54
+ pathSuffix
55
+ } = resolveMappingResult;
56
+ if (mapping.type !== "value") {
57
+ return value;
58
+ }
59
+ if (mapping.source.type !== "documentValue") {
60
+ return value;
61
+ }
62
+ const sourceDocument = csm.documents[mapping.source.document];
63
+ const sourcePath = csm.paths[mapping.source.path];
64
+ if (options == null ? void 0 : options.keyArraySelectors) {
65
+ const matchPathSegments = parseJsonPath(matchedPath);
66
+ const sourcePathSegments = parseJsonPath(sourcePath);
67
+ const fullSourceSegments = sourcePathSegments.concat(path.slice(matchPathSegments.length));
68
+ return encoder({
69
+ sourcePath: fullSourceSegments,
70
+ sourceDocument,
71
+ resultPath: path,
72
+ value
73
+ });
74
+ }
75
+ return encoder({
76
+ sourcePath: parseJsonPath(sourcePath + pathSuffix),
77
+ sourceDocument,
78
+ resultPath: path,
79
+ value
80
+ });
81
+ });
82
+ }
83
+ const filterDefault = _ref => {
84
+ let {
85
+ sourcePath
86
+ } = _ref;
87
+ const endPath = sourcePath.at(-1);
88
+ if (sourcePath.at(-2) === "slug" && endPath === "current") {
89
+ return false;
90
+ }
91
+ if (typeof endPath === "string" && endPath.startsWith("_")) {
92
+ return false;
93
+ }
94
+ if (typeof endPath === "number" && sourcePath.at(-2) === "marks" && typeof sourcePath.at(-3) === "number" && sourcePath.at(-4) === "children" && typeof sourcePath.at(-5) === "number") {
95
+ return false;
96
+ }
97
+ if (endPath === "href" && typeof sourcePath.at(-2) === "number" && sourcePath.at(-3) === "markDefs" && typeof sourcePath.at(-4) === "number") {
98
+ return false;
99
+ }
100
+ if (typeof endPath === "string" && typeof sourcePath.at(-2) === "number") {
101
+ if (endPath === "style" || endPath === "listItem") {
102
+ return false;
103
+ }
104
+ }
105
+ return true;
106
+ };
107
+ const TRUNCATE_LENGTH = 20;
108
+ function stegaEncodeSourceMap(result, resultSourceMap, config) {
109
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
110
+ const {
111
+ filter,
112
+ vercelStegaCombineSkip,
113
+ logger,
114
+ studioUrl,
115
+ enabled
116
+ } = config;
117
+ if (!enabled) {
118
+ const msg = "config.enabled must be true, don't call this function otherwise";
119
+ (_a = logger == null ? void 0 : logger.error) == null ? void 0 : _a.call(logger, "[@sanity/client/stega]: ".concat(msg), {
120
+ result,
121
+ resultSourceMap,
122
+ config
123
+ });
124
+ throw new TypeError(msg);
125
+ }
126
+ if (!resultSourceMap) {
127
+ (_b = logger == null ? void 0 : logger.error) == null ? void 0 : _b.call(logger, "[@sanity/client/stega]: Missing Content Source Map from response body", {
128
+ result,
129
+ resultSourceMap,
130
+ config
131
+ });
132
+ return result;
133
+ }
134
+ if (!studioUrl) {
135
+ const msg = "config.studioUrl must be defined";
136
+ (_c = logger == null ? void 0 : logger.error) == null ? void 0 : _c.call(logger, "[@sanity/client/stega]: ".concat(msg), {
137
+ result,
138
+ resultSourceMap,
139
+ config
140
+ });
141
+ throw new TypeError(msg);
142
+ }
143
+ const report = {
144
+ encoded: [],
145
+ skipped: []
146
+ };
147
+ const resultWithStega = encodeIntoResult(result, resultSourceMap, _ref2 => {
148
+ let {
149
+ sourcePath,
150
+ sourceDocument,
151
+ resultPath,
152
+ value
153
+ } = _ref2;
154
+ if ((typeof filter === "function" ? filter({
155
+ sourcePath,
156
+ resultPath,
157
+ filterDefault,
158
+ sourceDocument,
159
+ value
160
+ }) : filterDefault({
161
+ sourcePath,
162
+ resultPath,
163
+ filterDefault,
164
+ sourceDocument,
165
+ value
166
+ })) === false) {
167
+ if (logger) {
168
+ report.skipped.push({
169
+ path: prettyPathForLogging(sourcePath),
170
+ value: "".concat(value.slice(0, TRUNCATE_LENGTH)).concat(value.length > TRUNCATE_LENGTH ? "..." : ""),
171
+ length: value.length
172
+ });
173
+ }
174
+ return value;
175
+ }
176
+ if (logger) {
177
+ report.encoded.push({
178
+ path: prettyPathForLogging(sourcePath),
179
+ value: "".concat(value.slice(0, TRUNCATE_LENGTH)).concat(value.length > TRUNCATE_LENGTH ? "..." : ""),
180
+ length: value.length
181
+ });
182
+ }
183
+ return vercelStegaCombine(value, {
184
+ origin: "sanity.io",
185
+ href: createEditLink({
186
+ studioUrl,
187
+ resultSourceMap,
188
+ resultPath
189
+ })
190
+ }, vercelStegaCombineSkip);
191
+ }, {
192
+ keyArraySelectors: true
193
+ });
194
+ if (logger) {
195
+ const isSkipping = report.skipped.length;
196
+ const isEncoding = report.encoded.length;
197
+ if (isSkipping || isEncoding) {
198
+ (_d = (logger == null ? void 0 : logger.groupCollapsed) || logger.log) == null ? void 0 : _d("[@sanity/client/stega]: Encoding source map into result");
199
+ (_e = logger.log) == null ? void 0 : _e.call(logger, "[@sanity/client/stega]: Paths encoded: ".concat(report.encoded.length, ", skipped: ").concat(report.skipped.length));
200
+ }
201
+ if (report.encoded.length > 0) {
202
+ (_f = logger == null ? void 0 : logger.log) == null ? void 0 : _f.call(logger, "[@sanity/client/stega]: Table of encoded paths");
203
+ (_g = (logger == null ? void 0 : logger.table) || logger.log) == null ? void 0 : _g(report.encoded);
204
+ }
205
+ if (report.skipped.length > 0) {
206
+ const skipped = /* @__PURE__ */new Set();
207
+ for (const {
208
+ path
209
+ } of report.skipped) {
210
+ skipped.add(path.replace(/\[\d+\]/g, "[]"));
211
+ }
212
+ (_h = logger == null ? void 0 : logger.log) == null ? void 0 : _h.call(logger, "[@sanity/client/stega]: List of skipped paths", [...skipped.values()]);
213
+ }
214
+ if (isSkipping || isEncoding) {
215
+ (_i = logger == null ? void 0 : logger.groupEnd) == null ? void 0 : _i.call(logger);
216
+ }
217
+ }
218
+ return resultWithStega;
219
+ }
220
+ function prettyPathForLogging(path) {
221
+ return path.map((segment, index) => typeof segment === "number" ? "[".concat(segment, "]") : index > 0 ? ".".concat(segment) : segment).join("");
222
+ }
223
+ var __accessCheck = (obj, member, msg) => {
224
+ if (!member.has(obj)) throw TypeError("Cannot " + msg);
225
+ };
226
+ var __privateGet = (obj, member, getter) => {
227
+ __accessCheck(obj, member, "read from private field");
228
+ return getter ? getter.call(obj) : member.get(obj);
229
+ };
230
+ var __privateAdd = (obj, member, value) => {
231
+ if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
232
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
233
+ };
234
+ var __privateSet = (obj, member, value, setter) => {
235
+ __accessCheck(obj, member, "write to private field");
236
+ setter ? setter.call(obj, value) : member.set(obj, value);
237
+ return value;
238
+ };
239
+ var _httpRequest, _httpRequest2;
240
+ const _ObservableSanityStegaClient = class _ObservableSanityStegaClient extends ObservableSanityClient {
241
+ constructor(httpRequest) {
242
+ let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
243
+ const {
244
+ clientConfig,
245
+ stegaConfig
246
+ } = splitConfig(config);
247
+ super(httpRequest, clientConfig);
248
+ /**
249
+ * Private properties
250
+ */
251
+ __privateAdd(this, _httpRequest, void 0);
252
+ __privateSet(this, _httpRequest, httpRequest);
253
+ this.stegaConfig = initStegaConfig(stegaConfig, defaultStegaConfig);
254
+ }
255
+ /**
256
+ * Clone the client - returns a new instance
257
+ */
258
+ clone() {
259
+ return new _ObservableSanityStegaClient(__privateGet(this, _httpRequest), this.config());
260
+ }
261
+ config(newConfig) {
262
+ if (newConfig === void 0) {
263
+ return {
264
+ ...super.config(),
265
+ stega: {
266
+ ...this.stegaConfig
267
+ }
268
+ };
269
+ }
270
+ super.config(newConfig);
271
+ const {
272
+ stegaConfig
273
+ } = splitConfig(newConfig);
274
+ this.stegaConfig = initStegaConfig(stegaConfig, this.stegaConfig || {});
275
+ return this;
276
+ }
277
+ /**
278
+ * Clone the client with a new (partial) configuration.
279
+ *
280
+ * @param newConfig - New client configuration properties, shallowly merged with existing configuration
281
+ */
282
+ withConfig(newConfig) {
283
+ return new _ObservableSanityStegaClient(__privateGet(this, _httpRequest), {
284
+ ...this.config(),
285
+ ...newConfig
286
+ });
287
+ }
288
+ fetch(query, params) {
289
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
290
+ const {
291
+ filterResponse: originalFilterResponse = true
292
+ } = options;
293
+ return super.fetch(query, params, Object.assign({}, options, {
294
+ filterResponse: false
295
+ })).pipe(map(res => {
296
+ const {
297
+ result: _result,
298
+ resultSourceMap
299
+ } = res;
300
+ let result = _result;
301
+ if (this.stegaConfig.enabled) {
302
+ result = stegaEncodeSourceMap(_result, resultSourceMap, this.stegaConfig);
303
+ }
304
+ return originalFilterResponse ? result : {
305
+ ...res,
306
+ result
307
+ };
308
+ }));
309
+ }
310
+ };
311
+ _httpRequest = new WeakMap();
312
+ let ObservableSanityStegaClient = _ObservableSanityStegaClient;
313
+ const _SanityStegaClient = class _SanityStegaClient extends SanityClient {
314
+ constructor(httpRequest) {
315
+ let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
316
+ const {
317
+ clientConfig,
318
+ stegaConfig
319
+ } = splitConfig(config);
320
+ super(httpRequest, clientConfig);
321
+ /**
322
+ * Private properties
323
+ */
324
+ __privateAdd(this, _httpRequest2, void 0);
325
+ __privateSet(this, _httpRequest2, httpRequest);
326
+ this.stegaConfig = initStegaConfig(stegaConfig, defaultStegaConfig);
327
+ this.observable = new ObservableSanityStegaClient(httpRequest, config);
328
+ }
329
+ /**
330
+ * Clone the client - returns a new instance
331
+ */
332
+ clone() {
333
+ return new _SanityStegaClient(__privateGet(this, _httpRequest2), this.config());
334
+ }
335
+ config(newConfig) {
336
+ if (newConfig === void 0) {
337
+ return {
338
+ ...super.config(),
339
+ stega: {
340
+ ...this.stegaConfig
341
+ }
342
+ };
343
+ }
344
+ super.config(newConfig);
345
+ const {
346
+ stegaConfig
347
+ } = splitConfig(newConfig);
348
+ this.stegaConfig = initStegaConfig(stegaConfig, {
349
+ ...(this.stegaConfig || {})
350
+ });
351
+ return this;
352
+ }
353
+ /**
354
+ * Clone the client with a new (partial) configuration.
355
+ *
356
+ * @param newConfig - New client configuration properties, shallowly merged with existing configuration
357
+ */
358
+ withConfig(newConfig) {
359
+ return new _SanityStegaClient(__privateGet(this, _httpRequest2), {
360
+ ...this.config(),
361
+ ...newConfig
362
+ });
363
+ }
364
+ fetch(query, params) {
365
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
366
+ const {
367
+ filterResponse: originalFilterResponse = true
368
+ } = options;
369
+ return super.fetch(query, params, Object.assign({}, options, {
370
+ filterResponse: false
371
+ })).then(res => {
372
+ const {
373
+ result: _result,
374
+ resultSourceMap
375
+ } = res;
376
+ let result = _result;
377
+ if (this.stegaConfig.enabled) {
378
+ result = stegaEncodeSourceMap(_result, resultSourceMap, this.stegaConfig);
379
+ }
380
+ return originalFilterResponse ? result : {
381
+ ...res,
382
+ result
383
+ };
384
+ });
385
+ }
386
+ };
387
+ _httpRequest2 = new WeakMap();
388
+ let SanityStegaClient = _SanityStegaClient;
389
+ const exp = defineCreateClientExports(middleware, SanityStegaClient);
390
+ const requester = exp.requester;
391
+ const createClient = exp.createClient;
392
+ export { ObservableSanityClient, ObservableSanityStegaClient, SanityClient, SanityStegaClient, createClient, encodeIntoResult, requester, stegaEncodeSourceMap };
393
+ //# sourceMappingURL=stega.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stega.js","sources":["../src/stega/config.ts","../src/stega/encodeIntoResult.ts","../src/stega/filterDefault.ts","../src/stega/stegaEncodeSourceMap.ts","../src/stega/SanityStegaClient.ts","../src/stega/index.ts"],"sourcesContent":["import type {ClientConfig} from '../types'\nimport type {ClientStegaConfig, InitializedStegaConfig, StegaConfig} from './types'\n\nexport const defaultStegaConfig: StegaConfig = {\n enabled: false,\n filter: (props) => props.filterDefault(props),\n vercelStegaCombineSkip: 'auto',\n}\n\nexport function splitConfig(config: ClientStegaConfig): {\n clientConfig: ClientConfig\n stegaConfig: StegaConfig\n} {\n const {stega = {}, ...clientConfig} = config\n return {clientConfig, stegaConfig: stega}\n}\n\nexport const initStegaConfig = (\n config: Partial<StegaConfig>,\n prevConfig: Partial<StegaConfig>,\n): InitializedStegaConfig => {\n const specifiedConfig = Object.assign({} as StegaConfig, prevConfig, config)\n const newConfig = Object.assign({} as InitializedStegaConfig, defaultStegaConfig, specifiedConfig)\n\n if ('encodeSourceMap' in newConfig) {\n throw new Error(\n `It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMap' is not supported in '@sanity/client/stega'. Did you mean 'enabled'?`,\n )\n }\n\n if ('encodeSourceMapAtPath' in newConfig) {\n throw new Error(\n `It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMapAtPath' is not supported in '@sanity/client/stega'. Did you mean 'filter'?`,\n )\n }\n\n if (typeof newConfig.enabled !== 'boolean') {\n throw new Error(`config.enabled must be a boolean, received ${newConfig.enabled}`)\n }\n\n if (newConfig.enabled && newConfig.studioUrl === undefined) {\n throw new Error(`config.studioUrl must be defined when config.enabled is true`)\n }\n\n if (\n newConfig.enabled &&\n typeof newConfig.studioUrl !== 'string' &&\n typeof newConfig.studioUrl !== 'function'\n ) {\n throw new Error(\n `config.studioUrl must be a string or a function, received ${newConfig.studioUrl}`,\n )\n }\n\n return newConfig\n}\n","import {parseJsonPath} from '../csm/jsonpath'\nimport {resolveMapping} from '../csm/resolveMapping'\nimport type {ContentSourceMap} from '../csm/types'\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 options?: {keyArraySelectors: boolean},\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, pathSuffix} = 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 if (options?.keyArraySelectors) {\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 }\n\n return encoder({\n sourcePath: parseJsonPath(sourcePath + pathSuffix),\n sourceDocument,\n resultPath: path,\n value,\n })\n }) as Result\n}\n","import type {FilterDefault} from './types'\n\nexport const filterDefault: FilterDefault = ({sourcePath}) => {\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, needs better heuristics but it works for now\n if (typeof endPath === 'string' && endPath.startsWith('_')) {\n return false\n }\n\n /**\n * Best effort infer Portable Text paths that should not be encoded.\n * 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.\n * 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.\n */\n // If the path ends in [number].children[number].marks[number] it's likely a PortableTextSpan: https://github.com/portabletext/types/blob/e54eb24f136d8efd51a46c6a190e7c46e79b5380/src/portableText.ts#LL154C16-L154C16\n if (\n typeof endPath === 'number' &&\n sourcePath.at(-2) === 'marks' &&\n typeof sourcePath.at(-3) === 'number' &&\n sourcePath.at(-4) === 'children' &&\n typeof sourcePath.at(-5) === 'number'\n ) {\n return false\n }\n // Or if it's [number].markDefs[number].href it's likely a PortableTextLink: https://github.com/portabletext/types/blob/e54eb24f136d8efd51a46c6a190e7c46e79b5380/src/portableText.ts#L163\n if (\n endPath === 'href' &&\n typeof sourcePath.at(-2) === 'number' &&\n sourcePath.at(-3) === 'markDefs' &&\n typeof sourcePath.at(-4) === 'number'\n ) {\n return false\n }\n // 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.\n // 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.\n if (typeof endPath === 'string' && typeof sourcePath.at(-2) === 'number') {\n // https://github.com/portabletext/types/blob/e54eb24f136d8efd51a46c6a190e7c46e79b5380/src/portableText.ts#L48-L58\n if (endPath === 'style' || endPath === 'listItem') {\n return false\n }\n }\n\n return true\n}\n","import {vercelStegaCombine} from '@vercel/stega'\n\nimport type {PathSegment} from '../csm'\nimport {createEditLink} from '../csm/createEditLink'\nimport {encodeIntoResult} from './encodeIntoResult'\nimport {filterDefault} from './filterDefault'\nimport {ContentSourceMap, InitializedStegaConfig} 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, vercelStegaCombineSkip, logger, studioUrl, enabled} = config\n if (!enabled) {\n const msg = \"config.enabled must be true, don't call this function otherwise\"\n logger?.error?.(`[@sanity/client/stega]: ${msg}`, {result, resultSourceMap, config})\n throw new TypeError(msg)\n }\n\n if (!resultSourceMap) {\n logger?.error?.('[@sanity/client/stega]: Missing Content Source Map from response body', {\n result,\n resultSourceMap,\n config,\n })\n return result\n }\n\n if (!studioUrl) {\n const msg = 'config.studioUrl must be defined'\n logger?.error?.(`[@sanity/client/stega]: ${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 return vercelStegaCombine(\n value,\n {\n origin: 'sanity.io',\n href: createEditLink({studioUrl, resultSourceMap, resultPath}),\n },\n vercelStegaCombineSkip,\n )\n },\n {keyArraySelectors: true},\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)?.(\n '[@sanity/client/stega]: Encoding source map into result',\n )\n logger.log?.(\n `[@sanity/client/stega]: Paths encoded: ${report.encoded.length}, skipped: ${report.skipped.length}`,\n )\n }\n if (report.encoded.length > 0) {\n logger?.log?.(`[@sanity/client/stega]: 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(/\\[\\d+\\]/g, '[]'))\n }\n logger?.log?.(`[@sanity/client/stega]: 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: PathSegment[]): string {\n return path\n .map((segment, index) =>\n typeof segment === 'number' ? `[${segment}]` : index > 0 ? `.${segment}` : segment,\n )\n .join('')\n}\n","import {Observable} from 'rxjs'\nimport {map} from 'rxjs/operators'\n\nimport {defaultConfig} from '../config'\nimport {ObservableSanityClient, SanityClient} from '../SanityClient'\nimport type {\n Any,\n ClientConfig,\n FilteredResponseQueryOptions,\n HttpRequest,\n QueryParams,\n RawQueryResponse,\n UnfilteredResponseQueryOptions,\n} from '../types'\nimport {defaultStegaConfig, initStegaConfig, splitConfig} from './config'\nimport {stegaEncodeSourceMap} from './stegaEncodeSourceMap'\nimport {ClientStegaConfig, InitializedClientStegaConfig, InitializedStegaConfig} from './types'\n\n/** @public */\nexport class ObservableSanityStegaClient extends ObservableSanityClient {\n /**\n * Private properties\n */\n #httpRequest: HttpRequest\n private stegaConfig: InitializedStegaConfig\n\n constructor(httpRequest: HttpRequest, config: ClientStegaConfig = defaultConfig) {\n const {clientConfig, stegaConfig} = splitConfig(config)\n super(httpRequest, clientConfig)\n\n this.#httpRequest = httpRequest\n this.stegaConfig = initStegaConfig(stegaConfig, defaultStegaConfig)\n }\n\n /**\n * Clone the client - returns a new instance\n */\n clone(): ObservableSanityStegaClient {\n return new ObservableSanityStegaClient(this.#httpRequest, this.config())\n }\n\n /**\n * Returns the current client configuration\n */\n config(): InitializedClientStegaConfig\n /**\n * Reconfigure the client. Note that this _mutates_ the current client.\n */\n config(newConfig?: Partial<ClientStegaConfig>): this\n config(newConfig?: Partial<ClientStegaConfig>): ClientStegaConfig | this {\n if (newConfig === undefined) {\n return {...super.config(), stega: {...this.stegaConfig}}\n }\n\n super.config(newConfig)\n\n const {stegaConfig} = splitConfig(newConfig)\n\n this.stegaConfig = initStegaConfig(stegaConfig, this.stegaConfig || {})\n return this\n }\n\n /**\n * Clone the client with a new (partial) configuration.\n *\n * @param newConfig - New client configuration properties, shallowly merged with existing configuration\n */\n withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityStegaClient {\n return new ObservableSanityStegaClient(this.#httpRequest, {...this.config(), ...newConfig})\n }\n\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n */\n fetch<R = Any>(query: string): Observable<R>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Query parameters\n */\n fetch<R = Any, Q = QueryParams>(query: string, params: Q): Observable<R>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Query parameters\n * @param options - Request options\n */\n fetch<R = Any, Q = QueryParams>(\n query: string,\n params: Q | undefined,\n options: FilteredResponseQueryOptions,\n ): Observable<R>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Query parameters\n * @param options - Request options\n */\n fetch<R = Any, Q = QueryParams>(\n query: string,\n params: Q | undefined,\n options: UnfilteredResponseQueryOptions,\n ): Observable<RawQueryResponse<R>>\n fetch<R, Q extends QueryParams>(\n query: string,\n params?: Q,\n options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {},\n ): Observable<RawQueryResponse<R> | R> {\n const {filterResponse: originalFilterResponse = true} = options\n return super\n .fetch<R, Q>(query, params, Object.assign({}, options as Any, {filterResponse: false}))\n .pipe(\n map((res: Any) => {\n const {result: _result, resultSourceMap} = res as RawQueryResponse<R>\n let result = _result\n if (this.stegaConfig.enabled) {\n result = stegaEncodeSourceMap(_result, resultSourceMap, this.stegaConfig)\n }\n return originalFilterResponse ? result : {...res, result}\n }),\n )\n }\n}\n\n/** @public */\nexport class SanityStegaClient extends SanityClient {\n /**\n * Observable version of the Sanity client, with the same configuration as the promise-based one\n */\n observable: ObservableSanityStegaClient\n\n /**\n * Private properties\n */\n #httpRequest: HttpRequest\n private stegaConfig: InitializedStegaConfig\n\n constructor(httpRequest: HttpRequest, config: ClientStegaConfig = defaultConfig) {\n const {clientConfig, stegaConfig} = splitConfig(config)\n super(httpRequest, clientConfig)\n\n this.#httpRequest = httpRequest\n this.stegaConfig = initStegaConfig(stegaConfig, defaultStegaConfig)\n\n this.observable = new ObservableSanityStegaClient(httpRequest, config)\n }\n\n /**\n * Clone the client - returns a new instance\n */\n clone(): SanityStegaClient {\n return new SanityStegaClient(this.#httpRequest, this.config())\n }\n\n /**\n * Returns the current client configuration\n */\n config(): InitializedClientStegaConfig\n /**\n * Reconfigure the client. Note that this _mutates_ the current client.\n */\n config(newConfig?: Partial<ClientStegaConfig>): this\n config(newConfig?: Partial<ClientStegaConfig>): ClientStegaConfig | this {\n if (newConfig === undefined) {\n return {...super.config(), stega: {...this.stegaConfig}}\n }\n\n super.config(newConfig)\n\n const {stegaConfig} = splitConfig(newConfig)\n\n this.stegaConfig = initStegaConfig(stegaConfig, {...(this.stegaConfig || {})})\n return this\n }\n\n /**\n * Clone the client with a new (partial) configuration.\n *\n * @param newConfig - New client configuration properties, shallowly merged with existing configuration\n */\n withConfig(newConfig?: Partial<ClientStegaConfig>): SanityStegaClient {\n return new SanityStegaClient(this.#httpRequest, {...this.config(), ...newConfig})\n }\n\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n */\n fetch<R = Any>(query: string): Promise<R>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Optional query parameters\n */\n fetch<R = Any, Q = QueryParams>(query: string, params: Q): Promise<R>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Optional query parameters\n * @param options - Request options\n */\n fetch<R = Any, Q = QueryParams>(\n query: string,\n params: Q | undefined,\n options: FilteredResponseQueryOptions,\n ): Promise<R>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Optional query parameters\n * @param options - Request options\n */\n fetch<R = Any, Q = QueryParams>(\n query: string,\n params: Q | undefined,\n options: UnfilteredResponseQueryOptions,\n ): Promise<RawQueryResponse<R>>\n fetch<R, Q extends QueryParams>(\n query: string,\n params?: Q,\n options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {},\n ): Promise<RawQueryResponse<R> | R> {\n const {filterResponse: originalFilterResponse = true} = options\n return super\n .fetch<R, Q>(query, params, Object.assign({}, options as Any, {filterResponse: false}))\n .then((res: Any) => {\n const {result: _result, resultSourceMap} = res as RawQueryResponse<R>\n let result = _result\n if (this.stegaConfig.enabled) {\n result = stegaEncodeSourceMap(_result, resultSourceMap, this.stegaConfig)\n }\n return originalFilterResponse ? result : {...res, result}\n })\n }\n}\n","export * from '../defineCreateClient'\n\nimport defineCreateClientExports from '../defineCreateClient'\nimport envMiddleware from '../http/nodeMiddleware'\nimport {SanityStegaClient} from './SanityStegaClient'\nimport type {ClientStegaConfig} from './types'\n\nconst exp = defineCreateClientExports<SanityStegaClient, ClientStegaConfig>(\n envMiddleware,\n SanityStegaClient,\n)\n\nexport * from './shared'\n\n/** @public */\nexport const requester = exp.requester\n\n/** @public */\nexport const createClient = exp.createClient\n"],"names":["defaultStegaConfig","enabled","filter","props","filterDefault","vercelStegaCombineSkip","splitConfig","config","stega","clientConfig","stegaConfig","initStegaConfig","prevConfig","specifiedConfig","Object","assign","newConfig","Error","concat","studioUrl","encodeIntoResult","result","csm","encoder","options","walkMap","value","path","resolveMappingResult","resolveMapping","mapping","matchedPath","pathSuffix","type","source","sourceDocument","documents","document","sourcePath","paths","keyArraySelectors","matchPathSegments","parseJsonPath","sourcePathSegments","fullSourceSegments","slice","length","resultPath","_ref","endPath","at","startsWith","TRUNCATE_LENGTH","stegaEncodeSourceMap","resultSourceMap","_a","_b","_c","_d","_e","_f","_g","_h","_i","logger","msg","error","call","TypeError","report","encoded","skipped","resultWithStega","_ref2","push","prettyPathForLogging","vercelStegaCombine","origin","href","createEditLink","isSkipping","isEncoding","groupCollapsed","log","table","Set","add","replace","values","groupEnd","map","segment","index","join","_httpRequest","_ObservableSanityStegaClient","ObservableSanityClient","constructor","httpRequest","arguments","undefined","defaultConfig","__privateAdd","__privateSet","clone","__privateGet","withConfig","fetch","query","params","filterResponse","originalFilterResponse","pipe","res","_result","WeakMap","ObservableSanityStegaClient","_SanityStegaClient","SanityClient","observable","then","SanityStegaClient","exp","defineCreateClientExports","envMiddleware","requester","createClient"],"mappings":";;;;;;AAGO,MAAMA,kBAAkC,GAAA;EAC7CC,OAAS,EAAA,KAAA;EACTC,MAAQ,EAACC,KAAU,IAAAA,KAAA,CAAMC,cAAcD,KAAK,CAAA;EAC5CE,sBAAwB,EAAA;AAC1B,CAAA;AAEO,SAASC,YAAYC,MAG1B,EAAA;EACA,MAAM;IAACC,KAAQ,GAAA,CAAA,CAAI;IAAA,GAAGC;GAAgB,GAAAF,MAAA;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,MAAA,EAAQ6F,OAAS;QAAA5D;MAAA,CAAmB,GAAA2D,GAAA;MAC3C,IAAI5F,MAAS,GAAA6F,OAAA;MACT,IAAA,IAAA,CAAKxG,YAAYT,OAAS,EAAA;QAC5BoB,MAAA,GAASgC,oBAAqB,CAAA6D,OAAA,EAAS5D,eAAiB,EAAA,IAAA,CAAK5C,WAAW,CAAA;MAC1E;MACA,OAAOqG,sBAAyB,GAAA1F,MAAA,GAAS;QAAC,GAAG4F;QAAK5F;MAAM,CAAA;IAAA,CACzD,CAAA;EACL;AACF,CAAA;AAxGEyE,aAAA,GAAA,IAAAqB,OAAA,CAAA,CAAA;AATK,IAAMM,iBAAN,GAAAJ,kBAAA;AC3HP,MAAMK,GAAM,GAAAC,yBAAA,CACVC,UAAA,EACAH,iBACF,CAAA;AAKO,MAAMI,YAAYH,GAAI,CAAAG,SAAA;AAGtB,MAAMC,eAAeJ,GAAI,CAAAI,YAAA;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/client",
3
- "version": "6.7.1",
3
+ "version": "6.8.0-pink-lizard.1",
4
4
  "description": "Client for retrieving, creating and patching data from Sanity.io",
5
5
  "keywords": [
6
6
  "sanity",
@@ -44,6 +44,33 @@
44
44
  },
45
45
  "default": "./dist/index.js"
46
46
  },
47
+ "./csm": {
48
+ "types": "./dist/csm.d.ts",
49
+ "source": "./src/csm/index.ts",
50
+ "import": "./dist/csm.js",
51
+ "require": "./dist/csm.cjs",
52
+ "default": "./dist/csm.js"
53
+ },
54
+ "./stega": {
55
+ "types": "./dist/stega.d.ts",
56
+ "browser": {
57
+ "source": "./src/stega/index.browser.ts",
58
+ "import": "./dist/stega.browser.js",
59
+ "require": "./dist/stega.browser.cjs"
60
+ },
61
+ "react-server": "./dist/stega.browser.js",
62
+ "deno": "./dist/stega.browser.js",
63
+ "edge": "./dist/stega.browser.js",
64
+ "edge-light": "./dist/stega.browser.js",
65
+ "worker": "./dist/stega.browser.js",
66
+ "source": "./src/stega/index.ts",
67
+ "require": "./dist/stega.cjs",
68
+ "node": {
69
+ "import": "./dist/stega.cjs.js"
70
+ },
71
+ "import": "./dist/stega.js",
72
+ "default": "./dist/stega.js"
73
+ },
47
74
  "./package.json": "./package.json"
48
75
  },
49
76
  "main": "./dist/index.cjs",
@@ -52,9 +79,21 @@
52
79
  "source": "./src/index.ts",
53
80
  "browser": {
54
81
  "./dist/index.cjs": "./dist/index.browser.cjs",
55
- "./dist/index.js": "./dist/index.browser.js"
82
+ "./dist/index.js": "./dist/index.browser.js",
83
+ "./dist/stega.cjs": "./dist/stega.browser.cjs",
84
+ "./dist/stega.js": "./dist/stega.browser.js"
56
85
  },
57
86
  "types": "./dist/index.d.ts",
87
+ "typesVersions": {
88
+ "*": {
89
+ "csm": [
90
+ "./dist/csm.d.ts"
91
+ ],
92
+ "stega": [
93
+ "./dist/stega.d.ts"
94
+ ]
95
+ }
96
+ },
58
97
  "files": [
59
98
  "dist",
60
99
  "src",
@@ -91,6 +130,7 @@
91
130
  },
92
131
  "dependencies": {
93
132
  "@sanity/eventsource": "^5.0.0",
133
+ "@vercel/stega": "0.1.0",
94
134
  "get-it": "^8.4.4",
95
135
  "rxjs": "^7.0.0"
96
136
  },
package/src/config.ts CHANGED
@@ -76,6 +76,12 @@ export const initConfig = (
76
76
  )
77
77
  }
78
78
 
79
+ if ('stega' in newConfig && newConfig['stega'] !== undefined) {
80
+ throw new Error(
81
+ `It looks like you're using options meant for '@sanity/client/stega'. Make sure you're using the right import. Or set 'stega' in 'createClient' to 'undefined'.`,
82
+ )
83
+ }
84
+
79
85
  const isBrowser = typeof window !== 'undefined' && window.location && window.location.hostname
80
86
  const isLocalhost = isBrowser && isLocal(window.location.hostname)
81
87