@sanity/client 6.11.3 → 6.11.4-canary.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.
Files changed (49) hide show
  1. package/README.md +85 -4
  2. package/dist/_chunks/{browserMiddleware-1MULg59S.cjs → browserMiddleware-Pe3R-Bkh.cjs} +106 -20
  3. package/dist/_chunks/browserMiddleware-Pe3R-Bkh.cjs.map +1 -0
  4. package/dist/_chunks/{browserMiddleware-heyg-fDk.js → browserMiddleware-wklv-F5c.js} +108 -22
  5. package/dist/_chunks/browserMiddleware-wklv-F5c.js.map +1 -0
  6. package/dist/_chunks/{nodeMiddleware-CHxg1-zH.cjs → nodeMiddleware-7PkLkt-m.cjs} +107 -21
  7. package/dist/_chunks/nodeMiddleware-7PkLkt-m.cjs.map +1 -0
  8. package/dist/_chunks/{nodeMiddleware-u_fUUnxa.js → nodeMiddleware-LGORMZpx.js} +109 -23
  9. package/dist/_chunks/nodeMiddleware-LGORMZpx.js.map +1 -0
  10. package/dist/_chunks/stegaEncodeSourceMap-2y-qTNKB.cjs +230 -0
  11. package/dist/_chunks/stegaEncodeSourceMap-2y-qTNKB.cjs.map +1 -0
  12. package/dist/_chunks/stegaEncodeSourceMap-9L0STMBo.js +475 -0
  13. package/dist/_chunks/stegaEncodeSourceMap-9L0STMBo.js.map +1 -0
  14. package/dist/_chunks/stegaEncodeSourceMap-gXzb3LIV.js +226 -0
  15. package/dist/_chunks/stegaEncodeSourceMap-gXzb3LIV.js.map +1 -0
  16. package/dist/_chunks/stegaEncodeSourceMap-vNYIaMiu.cjs +479 -0
  17. package/dist/_chunks/stegaEncodeSourceMap-vNYIaMiu.cjs.map +1 -0
  18. package/dist/index.browser.cjs +1 -1
  19. package/dist/index.browser.js +2 -2
  20. package/dist/index.cjs +1 -1
  21. package/dist/index.d.ts +133 -0
  22. package/dist/index.js +2 -2
  23. package/dist/stega.browser.cjs +10 -700
  24. package/dist/stega.browser.cjs.map +1 -1
  25. package/dist/stega.browser.js +5 -693
  26. package/dist/stega.browser.js.map +1 -1
  27. package/dist/stega.cjs +10 -451
  28. package/dist/stega.cjs.js +3 -5
  29. package/dist/stega.cjs.map +1 -1
  30. package/dist/stega.d.ts +1302 -1455
  31. package/dist/stega.js +5 -444
  32. package/dist/stega.js.map +1 -1
  33. package/package.json +12 -7
  34. package/src/SanityClient.ts +40 -4
  35. package/src/config.ts +34 -12
  36. package/src/data/dataMethods.ts +37 -9
  37. package/src/stega/index.browser.ts +3 -6
  38. package/src/stega/index.ts +3 -6
  39. package/src/stega/shared.ts +1 -13
  40. package/src/stega/types.ts +11 -18
  41. package/src/types.ts +24 -0
  42. package/umd/sanityClient.js +1073 -20
  43. package/umd/sanityClient.min.js +4 -3
  44. package/dist/_chunks/browserMiddleware-1MULg59S.cjs.map +0 -1
  45. package/dist/_chunks/browserMiddleware-heyg-fDk.js.map +0 -1
  46. package/dist/_chunks/nodeMiddleware-CHxg1-zH.cjs.map +0 -1
  47. package/dist/_chunks/nodeMiddleware-u_fUUnxa.js.map +0 -1
  48. package/src/stega/SanityStegaClient.ts +0 -298
  49. package/src/stega/config.ts +0 -76
package/dist/stega.js CHANGED
@@ -1,450 +1,11 @@
1
- import { ObservableSanityClient, defaultConfig, SanityClient, defineCreateClientExports, middleware } from './_chunks/nodeMiddleware-u_fUUnxa.js';
2
- export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableTransaction, Patch, ServerError, Transaction } from './_chunks/nodeMiddleware-u_fUUnxa.js';
3
- import { map } from 'rxjs/operators';
4
- import { vercelStegaCombine, vercelStegaSplit } from '@vercel/stega';
5
- import { walkMap, resolveMapping, parseJsonPath, resolveStudioBaseRoute, createEditUrl, reKeySegment, toString, jsonPathToStudioPath } from './_chunks/resolveEditInfo-uXvm6eWd.js';
1
+ import { defineCreateClientExports, SanityClient, middleware } from './_chunks/nodeMiddleware-LGORMZpx.js';
2
+ export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, ServerError, Transaction, vercelStegaCleanAll } from './_chunks/nodeMiddleware-LGORMZpx.js';
3
+ export { encodeIntoResult, stegaEncodeSourceMap } from './_chunks/stegaEncodeSourceMap-gXzb3LIV.js';
6
4
  export { adapter as unstable__adapter, environment as unstable__environment } from 'get-it';
7
5
 
8
- const defaultStegaConfig = {
9
- enabled: false,
10
- filter: (props) => props.filterDefault(props)
11
- };
12
- function splitConfig(config) {
13
- const { stega = {}, ...clientConfig } = config;
14
- return { clientConfig, stegaConfig: typeof stega === "boolean" ? { enabled: stega } : stega };
15
- }
16
- const initStegaConfig = (config, prevConfig) => {
17
- const specifiedConfig = Object.assign({}, prevConfig, config);
18
- const newConfig = Object.assign({}, defaultStegaConfig, specifiedConfig);
19
- if ("encodeSourceMap" in newConfig) {
20
- throw new Error(
21
- "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'?"
22
- );
23
- }
24
- if ("encodeSourceMapAtPath" in newConfig) {
25
- throw new Error(
26
- "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'?"
27
- );
28
- }
29
- if (typeof newConfig.enabled !== "boolean") {
30
- throw new Error("config.enabled must be a boolean, received ".concat(newConfig.enabled));
31
- }
32
- if (newConfig.enabled && newConfig.studioUrl === void 0) {
33
- throw new Error("config.studioUrl must be defined when config.enabled is true");
34
- }
35
- if (newConfig.enabled && typeof newConfig.studioUrl !== "string" && typeof newConfig.studioUrl !== "function") {
36
- throw new Error(
37
- "config.studioUrl must be a string or a function, received ".concat(newConfig.studioUrl)
38
- );
39
- }
40
- return newConfig;
41
- };
42
- function splitStegaConfigFromFetchOptions(options, initializedStegaConfig) {
43
- const { stega = {}, ...fetchOptions } = options;
44
- const stegaConfig = initStegaConfig(
45
- typeof stega === "boolean" ? { enabled: stega } : stega,
46
- initializedStegaConfig
47
- );
48
- return { fetchOptions, stegaConfig };
49
- }
50
-
51
- function encodeIntoResult(result, csm, encoder) {
52
- return walkMap(result, (value, path) => {
53
- if (typeof value !== "string") {
54
- return value;
55
- }
56
- const resolveMappingResult = resolveMapping(path, csm);
57
- if (!resolveMappingResult) {
58
- return value;
59
- }
60
- const { mapping, matchedPath } = resolveMappingResult;
61
- if (mapping.type !== "value") {
62
- return value;
63
- }
64
- if (mapping.source.type !== "documentValue") {
65
- return value;
66
- }
67
- const sourceDocument = csm.documents[mapping.source.document];
68
- const sourcePath = csm.paths[mapping.source.path];
69
- const matchPathSegments = parseJsonPath(matchedPath);
70
- const sourcePathSegments = parseJsonPath(sourcePath);
71
- const fullSourceSegments = sourcePathSegments.concat(path.slice(matchPathSegments.length));
72
- return encoder({
73
- sourcePath: fullSourceSegments,
74
- sourceDocument,
75
- resultPath: path,
76
- value
77
- });
78
- });
79
- }
80
-
81
- const filterDefault = ({ sourcePath, value }) => {
82
- if (isValidDate(value) || isValidURL(value)) {
83
- return false;
84
- }
85
- const endPath = sourcePath.at(-1);
86
- if (sourcePath.at(-2) === "slug" && endPath === "current") {
87
- return false;
88
- }
89
- if (typeof endPath === "string" && endPath.startsWith("_")) {
90
- return false;
91
- }
92
- if (typeof endPath === "number" && sourcePath.at(-2) === "marks") {
93
- return false;
94
- }
95
- if (endPath === "href" && typeof sourcePath.at(-2) === "number" && sourcePath.at(-3) === "markDefs") {
96
- return false;
97
- }
98
- if (endPath === "style" || endPath === "listItem") {
99
- return false;
100
- }
101
- if (sourcePath.some(
102
- (path) => path === "meta" || path === "metadata" || path === "openGraph" || path === "seo"
103
- )) {
104
- return false;
105
- }
106
- if (typeof endPath === "string" && denylist.has(endPath)) {
107
- return false;
108
- }
109
- return true;
110
- };
111
- const denylist = /* @__PURE__ */ new Set([
112
- "color",
113
- "colour",
114
- "currency",
115
- "email",
116
- "format",
117
- "gid",
118
- "hex",
119
- "href",
120
- "hsl",
121
- "hsla",
122
- "icon",
123
- "id",
124
- "index",
125
- "key",
126
- "language",
127
- "layout",
128
- "link",
129
- "linkAction",
130
- "locale",
131
- "lqip",
132
- "page",
133
- "path",
134
- "ref",
135
- "rgb",
136
- "rgba",
137
- "route",
138
- "secret",
139
- "slug",
140
- "status",
141
- "tag",
142
- "template",
143
- "theme",
144
- "type",
145
- "unit",
146
- "url",
147
- "username",
148
- "variant",
149
- "website"
150
- ]);
151
- function isValidDate(dateString) {
152
- return Number.isNaN(Number(dateString)) ? Boolean(Date.parse(dateString)) : false;
153
- }
154
- function isValidURL(url) {
155
- try {
156
- new URL(url, url.startsWith("/") ? "https://acme.com" : void 0);
157
- } catch {
158
- return false;
159
- }
160
- return true;
161
- }
162
-
163
- const TRUNCATE_LENGTH = 20;
164
- function stegaEncodeSourceMap(result, resultSourceMap, config) {
165
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
166
- const { filter, logger, enabled } = config;
167
- if (!enabled) {
168
- const msg = "config.enabled must be true, don't call this function otherwise";
169
- (_a = logger == null ? void 0 : logger.error) == null ? void 0 : _a.call(logger, "[@sanity/client/stega]: ".concat(msg), { result, resultSourceMap, config });
170
- throw new TypeError(msg);
171
- }
172
- if (!resultSourceMap) {
173
- (_b = logger == null ? void 0 : logger.error) == null ? void 0 : _b.call(logger, "[@sanity/client/stega]: Missing Content Source Map from response body", {
174
- result,
175
- resultSourceMap,
176
- config
177
- });
178
- return result;
179
- }
180
- if (!config.studioUrl) {
181
- const msg = "config.studioUrl must be defined";
182
- (_c = logger == null ? void 0 : logger.error) == null ? void 0 : _c.call(logger, "[@sanity/client/stega]: ".concat(msg), { result, resultSourceMap, config });
183
- throw new TypeError(msg);
184
- }
185
- const report = {
186
- encoded: [],
187
- skipped: []
188
- };
189
- const resultWithStega = encodeIntoResult(
190
- result,
191
- resultSourceMap,
192
- ({ sourcePath, sourceDocument, resultPath, value }) => {
193
- if ((typeof filter === "function" ? filter({ sourcePath, resultPath, filterDefault, sourceDocument, value }) : filterDefault({ sourcePath, resultPath, filterDefault, sourceDocument, value })) === false) {
194
- if (logger) {
195
- report.skipped.push({
196
- path: prettyPathForLogging(sourcePath),
197
- value: "".concat(value.slice(0, TRUNCATE_LENGTH)).concat(value.length > TRUNCATE_LENGTH ? "..." : ""),
198
- length: value.length
199
- });
200
- }
201
- return value;
202
- }
203
- if (logger) {
204
- report.encoded.push({
205
- path: prettyPathForLogging(sourcePath),
206
- value: "".concat(value.slice(0, TRUNCATE_LENGTH)).concat(value.length > TRUNCATE_LENGTH ? "..." : ""),
207
- length: value.length
208
- });
209
- }
210
- const { baseUrl, workspace, tool } = resolveStudioBaseRoute(
211
- typeof config.studioUrl === "function" ? config.studioUrl(sourceDocument) : config.studioUrl
212
- );
213
- if (!baseUrl)
214
- return value;
215
- const { _id: id, _type: type } = sourceDocument;
216
- return vercelStegaCombine(
217
- value,
218
- {
219
- origin: "sanity.io",
220
- href: createEditUrl({
221
- baseUrl,
222
- workspace,
223
- tool,
224
- id,
225
- type,
226
- path: sourcePath
227
- })
228
- },
229
- // We use custom logic to determine if we should skip encoding
230
- false
231
- );
232
- }
233
- );
234
- if (logger) {
235
- const isSkipping = report.skipped.length;
236
- const isEncoding = report.encoded.length;
237
- if (isSkipping || isEncoding) {
238
- (_d = (logger == null ? void 0 : logger.groupCollapsed) || logger.log) == null ? void 0 : _d(
239
- "[@sanity/client/stega]: Encoding source map into result"
240
- );
241
- (_e = logger.log) == null ? void 0 : _e.call(
242
- logger,
243
- "[@sanity/client/stega]: Paths encoded: ".concat(report.encoded.length, ", skipped: ").concat(report.skipped.length)
244
- );
245
- }
246
- if (report.encoded.length > 0) {
247
- (_f = logger == null ? void 0 : logger.log) == null ? void 0 : _f.call(logger, "[@sanity/client/stega]: Table of encoded paths");
248
- (_g = (logger == null ? void 0 : logger.table) || logger.log) == null ? void 0 : _g(report.encoded);
249
- }
250
- if (report.skipped.length > 0) {
251
- const skipped = /* @__PURE__ */ new Set();
252
- for (const { path } of report.skipped) {
253
- skipped.add(path.replace(reKeySegment, "0").replace(/\[\d+\]/g, "[]"));
254
- }
255
- (_h = logger == null ? void 0 : logger.log) == null ? void 0 : _h.call(logger, "[@sanity/client/stega]: List of skipped paths", [...skipped.values()]);
256
- }
257
- if (isSkipping || isEncoding) {
258
- (_i = logger == null ? void 0 : logger.groupEnd) == null ? void 0 : _i.call(logger);
259
- }
260
- }
261
- return resultWithStega;
262
- }
263
- function prettyPathForLogging(path) {
264
- return toString(jsonPathToStudioPath(path));
265
- }
266
-
267
- function vercelStegaCleanAll(result) {
268
- try {
269
- return JSON.parse(
270
- JSON.stringify(result, (key, value) => {
271
- if (typeof value !== "string")
272
- return value;
273
- return vercelStegaSplit(value).cleaned;
274
- })
275
- );
276
- } catch {
277
- return result;
278
- }
279
- }
280
-
281
- var __accessCheck = (obj, member, msg) => {
282
- if (!member.has(obj))
283
- throw TypeError("Cannot " + msg);
284
- };
285
- var __privateGet = (obj, member, getter) => {
286
- __accessCheck(obj, member, "read from private field");
287
- return getter ? getter.call(obj) : member.get(obj);
288
- };
289
- var __privateAdd = (obj, member, value) => {
290
- if (member.has(obj))
291
- throw TypeError("Cannot add the same private member more than once");
292
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
293
- };
294
- var __privateSet = (obj, member, value, setter) => {
295
- __accessCheck(obj, member, "write to private field");
296
- setter ? setter.call(obj, value) : member.set(obj, value);
297
- return value;
298
- };
299
- var _httpRequest, _httpRequest2;
300
- const _ObservableSanityStegaClient = class _ObservableSanityStegaClient extends ObservableSanityClient {
301
- constructor(httpRequest, config = defaultConfig) {
302
- const { clientConfig, stegaConfig } = splitConfig(config);
303
- super(httpRequest, clientConfig);
304
- /**
305
- * Private properties
306
- */
307
- __privateAdd(this, _httpRequest, void 0);
308
- __privateSet(this, _httpRequest, httpRequest);
309
- this.stegaConfig = initStegaConfig(stegaConfig, defaultStegaConfig);
310
- }
311
- /**
312
- * Clone the client - returns a new instance
313
- */
314
- clone() {
315
- return new _ObservableSanityStegaClient(__privateGet(this, _httpRequest), this.config());
316
- }
317
- config(newConfig) {
318
- if (newConfig === void 0) {
319
- return { ...super.config(), stega: { ...this.stegaConfig } };
320
- }
321
- const { clientConfig, stegaConfig } = splitConfig(newConfig);
322
- super.config(clientConfig);
323
- this.stegaConfig = initStegaConfig(stegaConfig, this.stegaConfig || {});
324
- return this;
325
- }
326
- /**
327
- * Clone the client with a new (partial) configuration.
328
- *
329
- * @param newConfig - New client configuration properties, shallowly merged with existing configuration
330
- */
331
- withConfig(newConfig) {
332
- const thisConfig = this.config();
333
- const { stegaConfig } = splitConfig(newConfig || {});
334
- return new _ObservableSanityStegaClient(__privateGet(this, _httpRequest), {
335
- ...thisConfig,
336
- ...newConfig,
337
- stega: {
338
- ...thisConfig.stega || {},
339
- ...stegaConfig || {}
340
- }
341
- });
342
- }
343
- fetch(query, _params, _options = {}) {
344
- const { stegaConfig, fetchOptions: options } = splitStegaConfigFromFetchOptions(
345
- _options,
346
- this.stegaConfig
347
- );
348
- const params = _params ? vercelStegaCleanAll(_params) : _params;
349
- if (!stegaConfig.enabled) {
350
- return super.fetch(query, params, options);
351
- }
352
- const { filterResponse: originalFilterResponse = true } = options;
353
- return super.fetch(
354
- query,
355
- params,
356
- Object.assign({}, options, {
357
- filterResponse: false,
358
- resultSourceMap: "withKeyArraySelector"
359
- })
360
- ).pipe(
361
- map((res) => {
362
- const { result: _result, resultSourceMap } = res;
363
- const result = stegaEncodeSourceMap(_result, resultSourceMap, stegaConfig);
364
- return originalFilterResponse ? result : { ...res, result };
365
- })
366
- );
367
- }
368
- };
369
- _httpRequest = new WeakMap();
370
- let ObservableSanityStegaClient = _ObservableSanityStegaClient;
371
- const _SanityStegaClient = class _SanityStegaClient extends SanityClient {
372
- constructor(httpRequest, config = defaultConfig) {
373
- const { clientConfig, stegaConfig } = splitConfig(config);
374
- super(httpRequest, clientConfig);
375
- /**
376
- * Private properties
377
- */
378
- __privateAdd(this, _httpRequest2, void 0);
379
- __privateSet(this, _httpRequest2, httpRequest);
380
- this.stegaConfig = initStegaConfig(stegaConfig, defaultStegaConfig);
381
- this.observable = new ObservableSanityStegaClient(httpRequest, config);
382
- }
383
- /**
384
- * Clone the client - returns a new instance
385
- */
386
- clone() {
387
- return new _SanityStegaClient(__privateGet(this, _httpRequest2), this.config());
388
- }
389
- config(newConfig) {
390
- if (newConfig === void 0) {
391
- return { ...super.config(), stega: { ...this.stegaConfig } };
392
- }
393
- const { clientConfig, stegaConfig } = splitConfig(newConfig);
394
- super.config(clientConfig);
395
- this.stegaConfig = initStegaConfig(stegaConfig, { ...this.stegaConfig || {} });
396
- return this;
397
- }
398
- /**
399
- * Clone the client with a new (partial) configuration.
400
- *
401
- * @param newConfig - New client configuration properties, shallowly merged with existing configuration
402
- */
403
- withConfig(newConfig) {
404
- const thisConfig = this.config();
405
- const { stegaConfig } = splitConfig(newConfig || {});
406
- return new _SanityStegaClient(__privateGet(this, _httpRequest2), {
407
- ...thisConfig,
408
- ...newConfig,
409
- stega: {
410
- ...thisConfig.stega || {},
411
- ...stegaConfig || {}
412
- }
413
- });
414
- }
415
- fetch(query, _params, _options = {}) {
416
- const { stegaConfig, fetchOptions: options } = splitStegaConfigFromFetchOptions(
417
- _options,
418
- this.stegaConfig
419
- );
420
- const params = _params ? vercelStegaCleanAll(_params) : _params;
421
- if (!stegaConfig.enabled) {
422
- return super.fetch(query, params, options);
423
- }
424
- const { filterResponse: originalFilterResponse = true } = options;
425
- return super.fetch(
426
- query,
427
- params,
428
- Object.assign({}, options, {
429
- filterResponse: false,
430
- resultSourceMap: "withKeyArraySelector"
431
- })
432
- ).then((res) => {
433
- const { result: _result, resultSourceMap } = res;
434
- const result = stegaEncodeSourceMap(_result, resultSourceMap, stegaConfig);
435
- return originalFilterResponse ? result : { ...res, result };
436
- });
437
- }
438
- };
439
- _httpRequest2 = new WeakMap();
440
- let SanityStegaClient = _SanityStegaClient;
441
-
442
- const exp = defineCreateClientExports(
443
- middleware,
444
- SanityStegaClient
445
- );
6
+ const exp = defineCreateClientExports(middleware, SanityClient);
446
7
  const requester = exp.requester;
447
8
  const createClient = exp.createClient;
448
9
 
449
- export { ObservableSanityClient, ObservableSanityStegaClient, SanityClient, SanityStegaClient, createClient, encodeIntoResult, requester, stegaEncodeSourceMap, vercelStegaCleanAll };
10
+ export { SanityClient, createClient, requester };
450
11
  //# sourceMappingURL=stega.js.map
package/dist/stega.js.map CHANGED
@@ -1 +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/vercelStegaCleanAll.ts","../src/stega/SanityStegaClient.ts","../src/stega/index.ts"],"sourcesContent":["import type {\n ClientConfig,\n FilteredResponseQueryOptions,\n UnfilteredResponseQueryOptions,\n} from '../types'\nimport type {ClientStegaConfig, InitializedStegaConfig, StegaConfig} from './types'\n\nexport const defaultStegaConfig: StegaConfig = {\n enabled: false,\n filter: (props) => props.filterDefault(props),\n}\n\nexport function splitConfig(config: ClientStegaConfig): {\n clientConfig: ClientConfig\n stegaConfig: StegaConfig\n} {\n const {stega = {}, ...clientConfig} = config\n return {clientConfig, stegaConfig: typeof stega === 'boolean' ? {enabled: stega} : 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\nexport function splitStegaConfigFromFetchOptions(\n options: (FilteredResponseQueryOptions | UnfilteredResponseQueryOptions) & {\n stega?: boolean | StegaConfig\n },\n initializedStegaConfig: InitializedStegaConfig,\n): {\n fetchOptions: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions\n stegaConfig: InitializedStegaConfig\n} {\n const {stega = {}, ...fetchOptions} = options\n const stegaConfig = initStegaConfig(\n typeof stega === 'boolean' ? {enabled: stega} : stega,\n initializedStegaConfig,\n )\n return {fetchOptions, stegaConfig}\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): 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 {FilterDefault} from './types'\n\nexport const filterDefault: FilterDefault = ({sourcePath, 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, 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 marks[number] it's likely a PortableTextSpan: https://github.com/portabletext/types/blob/e54eb24f136d8efd51a46c6a190e7c46e79b5380/src/portableText.ts#LL154C16-L154C16\n if (typeof endPath === 'number' && sourcePath.at(-2) === 'marks') {\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 ) {\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 // https://github.com/portabletext/types/blob/e54eb24f136d8efd51a46c6a190e7c46e79b5380/src/portableText.ts#L48-L58\n if (endPath === 'style' || endPath === 'listItem') {\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 // 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 'unit',\n 'url',\n 'username',\n 'variant',\n 'website',\n])\n\nfunction isValidDate(dateString: string) {\n return Number.isNaN(Number(dateString)) ? Boolean(Date.parse(dateString)) : false\n}\n\nfunction isValidURL(url: string) {\n try {\n new URL(url, url.startsWith('/') ? 'https://acme.com' : undefined)\n } catch {\n return false\n }\n return true\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'\nimport {filterDefault} from './filterDefault'\nimport {ContentSourceMap, ContentSourceMapParsedPath, 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, 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/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 (!config.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 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} = 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 }),\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)?.(\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(reKeySegment, '0').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: ContentSourceMapParsedPath): string {\n return studioPathToString(jsonPathToStudioPath(path))\n}\n","import {vercelStegaSplit} from '@vercel/stega'\n\n/**\n * Can take a `result` JSON from a `const {result} = client.fetch(query, params, {filterResponse: false})`\n * and remove all stega-encoded data from it.\n * @alpha\n */\nexport function vercelStegaCleanAll<Result = unknown>(result: Result): Result {\n try {\n return JSON.parse(\n JSON.stringify(result, (key, value) => {\n if (typeof value !== 'string') return value\n return vercelStegaSplit(value).cleaned\n }),\n )\n } catch {\n return result\n }\n}\n","import {Observable} from 'rxjs'\nimport {map} from 'rxjs/operators'\n\nimport {defaultConfig} from '../config'\nimport {\n ObservableSanityClient as INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient,\n SanityClient as INTERNAL_DO_NOT_USE_DIRECTLY_SanityClient,\n} from '../SanityClient'\nimport type {\n Any,\n ClientConfig,\n FilteredResponseQueryOptions,\n HttpRequest,\n QueryParams,\n RawQueryResponse,\n UnfilteredResponseQueryOptions,\n} from '../types'\nimport {\n defaultStegaConfig,\n initStegaConfig,\n splitConfig,\n splitStegaConfigFromFetchOptions,\n} from './config'\nimport {stegaEncodeSourceMap} from './stegaEncodeSourceMap'\nimport {ClientStegaConfig, InitializedClientStegaConfig, InitializedStegaConfig} from './types'\nimport {vercelStegaCleanAll} from './vercelStegaCleanAll'\n\n/** @public */\nexport class ObservableSanityStegaClient extends INTERNAL_DO_NOT_USE_DIRECTLY_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 const {clientConfig, stegaConfig} = splitConfig(newConfig)\n super.config(clientConfig)\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 const thisConfig = this.config()\n const {stegaConfig} = splitConfig(newConfig || {})\n return new ObservableSanityStegaClient(this.#httpRequest, {\n ...thisConfig,\n ...newConfig,\n stega: {\n ...(thisConfig.stega || {}),\n ...(stegaConfig || {}),\n },\n })\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 {stegaConfig, fetchOptions: options} = splitStegaConfigFromFetchOptions(\n _options,\n this.stegaConfig,\n )\n const params = _params ? vercelStegaCleanAll(_params) : _params\n if (!stegaConfig.enabled) {\n return super.fetch<R, Q>(query, params, options as Any)\n }\n const {filterResponse: originalFilterResponse = true} = options\n return super\n .fetch<R, Q>(\n query,\n params,\n Object.assign({}, options as Any, {\n filterResponse: false,\n resultSourceMap: 'withKeyArraySelector',\n }),\n )\n .pipe(\n map((res: Any) => {\n const {result: _result, resultSourceMap} = res as RawQueryResponse<R>\n const result = stegaEncodeSourceMap(_result, resultSourceMap, stegaConfig)\n return originalFilterResponse ? result : {...res, result}\n }),\n )\n }\n}\n\n/** @public */\nexport class SanityStegaClient extends INTERNAL_DO_NOT_USE_DIRECTLY_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 const {clientConfig, stegaConfig} = splitConfig(newConfig)\n super.config(clientConfig)\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 const thisConfig = this.config()\n const {stegaConfig} = splitConfig(newConfig || {})\n return new SanityStegaClient(this.#httpRequest, {\n ...thisConfig,\n ...newConfig,\n stega: {\n ...(thisConfig.stega || {}),\n ...(stegaConfig || {}),\n },\n })\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 {stegaConfig, fetchOptions: options} = splitStegaConfigFromFetchOptions(\n _options,\n this.stegaConfig,\n )\n const params = _params ? vercelStegaCleanAll(_params) : _params\n if (!stegaConfig.enabled) {\n return super.fetch<R, Q>(query, params, options as Any)\n }\n const {filterResponse: originalFilterResponse = true} = options\n return super\n .fetch<R, Q>(\n query,\n params,\n Object.assign({}, options as Any, {\n filterResponse: false,\n resultSourceMap: 'withKeyArraySelector',\n }),\n )\n .then((res: Any) => {\n const {result: _result, resultSourceMap} = res as RawQueryResponse<R>\n const result = stegaEncodeSourceMap(_result, resultSourceMap, stegaConfig)\n return originalFilterResponse ? result : {...res, result}\n })\n }\n}\n\nexport type {\n INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient,\n INTERNAL_DO_NOT_USE_DIRECTLY_SanityClient,\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 type {ObservableSanityClient, SanityClient} from './shared'\nexport * from './shared'\n\n/** @public */\nexport const requester = exp.requester\n\n/** @public */\nexport const createClient = exp.createClient\n"],"names":["studioPathToString","_httpRequest","INTERNAL_DO_NOT_USE_DIRECTLY_ObservableSanityClient","INTERNAL_DO_NOT_USE_DIRECTLY_SanityClient","envMiddleware"],"mappings":";;;;;;;AAOO,MAAM,kBAAkC,GAAA;AAAA,EAC7C,OAAS,EAAA,KAAA;AAAA,EACT,MAAQ,EAAA,CAAC,KAAU,KAAA,KAAA,CAAM,cAAc,KAAK,CAAA;AAC9C,CAAA,CAAA;AAEO,SAAS,YAAY,MAG1B,EAAA;AACA,EAAA,MAAM,EAAC,KAAQ,GAAA,EAAI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AA,EAAgB,sBAAyB,GAAA,IAAA,EAAQ,GAAA,OAAA,CAAA;AACxD,IAAA,OAAO,KACJ,CAAA,KAAA;AAAA,MACC,KAAA;AAAA,MACA,MAAA;AAAA,MACA,MAAO,CAAA,MAAA,CAAO,EAAC,EAAG,OAAgB,EAAA;AAAA,QAChC,cAAgB,EAAA,KAAA;AAAA,QAChB,eAAiB,EAAA,sBAAA;AAAA,OAClB,CAAA;AAAA,KACH,CACC,IAAK,CAAA,CAAC,GAAa,KAAA;AAClB,MAAA,MAAM,EAAC,MAAA,EAAQ,OAAS,EAAA,eAAA,EAAmB,GAAA,GAAA,CAAA;AAC3C,MAAA,MAAM,MAAS,GAAA,oBAAA,CAAqB,OAAS,EAAA,eAAA,EAAiB,WAAW,CAAA,CAAA;AACzE,MAAA,OAAO,sBAAyB,GAAA,MAAA,GAAS,EAAC,GAAG,KAAK,MAAM,EAAA,CAAA;AAAA,KACzD,CAAA,CAAA;AAAA,GACL;AACF,CAAA,CAAA;AA5HEA,aAAA,GAAA,IAAA,OAAA,EAAA,CAAA;AATK,IAAM,iBAAN,GAAA;;ACxJP,MAAM,GAAM,GAAA,yBAAA;AAAA,EACVG,UAAA;AAAA,EACA,iBAAA;AACF,CAAA,CAAA;AAMO,MAAM,YAAY,GAAI,CAAA,UAAA;AAGtB,MAAM,eAAe,GAAI,CAAA;;;;"}
1
+ {"version":3,"file":"stega.js","sources":["../src/stega/index.ts"],"sourcesContent":["export * from '../defineCreateClient'\n\nimport defineCreateClientExports from '../defineCreateClient'\nimport envMiddleware from '../http/nodeMiddleware'\nimport {SanityClient} from '../SanityClient'\nimport type {ClientConfig} from './types'\n\nconst exp = defineCreateClientExports<SanityClient, ClientConfig>(envMiddleware, SanityClient)\n\nexport type {ObservableSanityClient, SanityClient} from './shared'\nexport * from './shared'\n\n/** @public */\nexport const requester = exp.requester\n\n/** @public */\nexport const createClient = exp.createClient\n"],"names":["envMiddleware"],"mappings":";;;;;AAOA,MAAM,GAAA,GAAM,yBAAsD,CAAAA,UAAA,EAAe,YAAY,CAAA,CAAA;AAMtF,MAAM,YAAY,GAAI,CAAA,UAAA;AAGtB,MAAM,eAAe,GAAI,CAAA;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/client",
3
- "version": "6.11.3",
3
+ "version": "6.11.4-canary.0",
4
4
  "description": "Client for retrieving, creating and patching data from Sanity.io",
5
5
  "keywords": [
6
6
  "sanity",
@@ -117,10 +117,7 @@
117
117
  "test:edge-runtime": "npm test -- --config vitest.edge.config.ts",
118
118
  "test:node-runtimes": "node --test runtimes/node | npx faucet"
119
119
  },
120
- "browserslist": [
121
- "> 0.2% and supports es6-module and supports es6-module-dynamic-import and not dead and not IE 11",
122
- "maintained node versions"
123
- ],
120
+ "browserslist": "extends @sanity/browserslist-config",
124
121
  "prettier": {
125
122
  "bracketSpacing": false,
126
123
  "printWidth": 100,
@@ -129,7 +126,6 @@
129
126
  },
130
127
  "dependencies": {
131
128
  "@sanity/eventsource": "^5.0.0",
132
- "@vercel/stega": "0.1.0",
133
129
  "get-it": "^8.4.6",
134
130
  "rxjs": "^7.0.0"
135
131
  },
@@ -138,11 +134,12 @@
138
134
  "@edge-runtime/vm": "^3.1.8",
139
135
  "@rollup/plugin-commonjs": "^25.0.7",
140
136
  "@rollup/plugin-node-resolve": "^15.2.3",
141
- "@sanity/pkg-utils": "^4.0.0",
137
+ "@sanity/pkg-utils": "^4.1.0",
142
138
  "@types/json-diff": "^1.0.3",
143
139
  "@types/node": "^20.8.8",
144
140
  "@typescript-eslint/eslint-plugin": "^6.19.1",
145
141
  "@typescript-eslint/parser": "^6.19.1",
142
+ "@vercel/stega": "0.1.0",
146
143
  "@vitest/coverage-v8": "1.2.1",
147
144
  "eslint": "^8.56.0",
148
145
  "eslint-config-prettier": "^9.1.0",
@@ -163,6 +160,14 @@
163
160
  "vitest": "1.2.1",
164
161
  "vitest-github-actions-reporter": "0.11.1"
165
162
  },
163
+ "peerDependencies": {
164
+ "@vercel/stega": "0.1.0"
165
+ },
166
+ "peerDependenciesMeta": {
167
+ "@vercel/stega": {
168
+ "optional": true
169
+ }
170
+ },
166
171
  "engines": {
167
172
  "node": ">=14.18"
168
173
  }
@@ -112,7 +112,17 @@ export class ObservableSanityClient {
112
112
  * @param newConfig - New client configuration properties, shallowly merged with existing configuration
113
113
  */
114
114
  withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityClient {
115
- return new ObservableSanityClient(this.#httpRequest, {...this.config(), ...newConfig})
115
+ const thisConfig = this.config()
116
+ return new ObservableSanityClient(this.#httpRequest, {
117
+ ...this.config(),
118
+ ...newConfig,
119
+ stega: {
120
+ ...(thisConfig.stega || {}),
121
+ ...(typeof newConfig?.stega === 'boolean'
122
+ ? {enabled: newConfig.stega}
123
+ : newConfig?.stega || {}),
124
+ },
125
+ })
116
126
  }
117
127
 
118
128
  /**
@@ -157,7 +167,14 @@ export class ObservableSanityClient {
157
167
  params?: Q,
158
168
  options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {},
159
169
  ): Observable<RawQueryResponse<R> | R> {
160
- return dataMethods._fetch<R, Q>(this, this.#httpRequest, query, params, options)
170
+ return dataMethods._fetch<R, Q>(
171
+ this,
172
+ this.#httpRequest,
173
+ this.#clientConfig.stega,
174
+ query,
175
+ params,
176
+ options,
177
+ )
161
178
  }
162
179
 
163
180
  /**
@@ -738,7 +755,17 @@ export class SanityClient {
738
755
  * @param newConfig - New client configuration properties, shallowly merged with existing configuration
739
756
  */
740
757
  withConfig(newConfig?: Partial<ClientConfig>): SanityClient {
741
- return new SanityClient(this.#httpRequest, {...this.config(), ...newConfig})
758
+ const thisConfig = this.config()
759
+ return new SanityClient(this.#httpRequest, {
760
+ ...thisConfig,
761
+ ...newConfig,
762
+ stega: {
763
+ ...(thisConfig.stega || {}),
764
+ ...(typeof newConfig?.stega === 'boolean'
765
+ ? {enabled: newConfig.stega}
766
+ : newConfig?.stega || {}),
767
+ },
768
+ })
742
769
  }
743
770
 
744
771
  /**
@@ -783,7 +810,16 @@ export class SanityClient {
783
810
  params?: Q,
784
811
  options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {},
785
812
  ): Promise<RawQueryResponse<R> | R> {
786
- return lastValueFrom(dataMethods._fetch<R, Q>(this, this.#httpRequest, query, params, options))
813
+ return lastValueFrom(
814
+ dataMethods._fetch<R, Q>(
815
+ this,
816
+ this.#httpRequest,
817
+ this.#clientConfig.stega,
818
+ query,
819
+ params,
820
+ options,
821
+ ),
822
+ )
787
823
  }
788
824
 
789
825
  /**