@sanity/client 6.11.2 → 6.11.3

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 (35) hide show
  1. package/dist/_chunks/{browserMiddleware-hi8PGbSU.cjs → browserMiddleware-1MULg59S.cjs} +377 -420
  2. package/dist/_chunks/{browserMiddleware-hi8PGbSU.cjs.map → browserMiddleware-1MULg59S.cjs.map} +1 -1
  3. package/dist/_chunks/{browserMiddleware-eLzHI4Fk.js → browserMiddleware-heyg-fDk.js} +377 -420
  4. package/dist/_chunks/{browserMiddleware-eLzHI4Fk.js.map → browserMiddleware-heyg-fDk.js.map} +1 -1
  5. package/dist/_chunks/{nodeMiddleware-SFcV9llR.cjs → nodeMiddleware-CHxg1-zH.cjs} +396 -440
  6. package/dist/_chunks/{nodeMiddleware-SFcV9llR.cjs.map → nodeMiddleware-CHxg1-zH.cjs.map} +1 -1
  7. package/dist/_chunks/{nodeMiddleware-dn4ZacKV.js → nodeMiddleware-u_fUUnxa.js} +396 -440
  8. package/dist/_chunks/{nodeMiddleware-dn4ZacKV.js.map → nodeMiddleware-u_fUUnxa.js.map} +1 -1
  9. package/dist/_chunks/{resolveEditInfo-TYjTkHKU.cjs → resolveEditInfo-dELeeJBE.cjs} +47 -70
  10. package/dist/_chunks/{resolveEditInfo-TYjTkHKU.cjs.map → resolveEditInfo-dELeeJBE.cjs.map} +1 -1
  11. package/dist/_chunks/{resolveEditInfo-FaeuCV4M.js → resolveEditInfo-uXvm6eWd.js} +47 -70
  12. package/dist/_chunks/{resolveEditInfo-FaeuCV4M.js.map → resolveEditInfo-uXvm6eWd.js.map} +1 -1
  13. package/dist/csm.cjs +20 -30
  14. package/dist/csm.cjs.map +1 -1
  15. package/dist/csm.js +19 -28
  16. package/dist/csm.js.map +1 -1
  17. package/dist/index.browser.cjs +8 -10
  18. package/dist/index.browser.cjs.map +1 -1
  19. package/dist/index.browser.js +5 -2
  20. package/dist/index.browser.js.map +1 -1
  21. package/dist/index.cjs +8 -10
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.js +5 -2
  24. package/dist/index.js.map +1 -1
  25. package/dist/stega.browser.cjs +224 -257
  26. package/dist/stega.browser.cjs.map +1 -1
  27. package/dist/stega.browser.js +221 -249
  28. package/dist/stega.browser.js.map +1 -1
  29. package/dist/stega.cjs +193 -217
  30. package/dist/stega.cjs.map +1 -1
  31. package/dist/stega.js +190 -209
  32. package/dist/stega.js.map +1 -1
  33. package/package.json +3 -3
  34. package/umd/sanityClient.js +494 -528
  35. package/umd/sanityClient.min.js +3 -3
package/dist/stega.cjs CHANGED
@@ -1,37 +1,33 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- });
6
- var nodeMiddleware = require('./_chunks/nodeMiddleware-SFcV9llR.cjs');
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var nodeMiddleware = require('./_chunks/nodeMiddleware-CHxg1-zH.cjs');
7
6
  var operators = require('rxjs/operators');
8
7
  var stega = require('@vercel/stega');
9
- var resolveEditInfo = require('./_chunks/resolveEditInfo-TYjTkHKU.cjs');
8
+ var resolveEditInfo = require('./_chunks/resolveEditInfo-dELeeJBE.cjs');
10
9
  var getIt = require('get-it');
10
+
11
11
  const defaultStegaConfig = {
12
12
  enabled: false,
13
- filter: props => props.filterDefault(props)
13
+ filter: (props) => props.filterDefault(props)
14
14
  };
15
15
  function splitConfig(config) {
16
- const {
17
- stega = {},
18
- ...clientConfig
19
- } = config;
20
- return {
21
- clientConfig,
22
- stegaConfig: typeof stega === "boolean" ? {
23
- enabled: stega
24
- } : stega
25
- };
16
+ const { stega = {}, ...clientConfig } = config;
17
+ return { clientConfig, stegaConfig: typeof stega === "boolean" ? { enabled: stega } : stega };
26
18
  }
27
19
  const initStegaConfig = (config, prevConfig) => {
28
20
  const specifiedConfig = Object.assign({}, prevConfig, config);
29
21
  const newConfig = Object.assign({}, defaultStegaConfig, specifiedConfig);
30
22
  if ("encodeSourceMap" in newConfig) {
31
- 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'?");
23
+ throw new Error(
24
+ "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'?"
25
+ );
32
26
  }
33
27
  if ("encodeSourceMapAtPath" in newConfig) {
34
- 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'?");
28
+ throw new Error(
29
+ "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
+ );
35
31
  }
36
32
  if (typeof newConfig.enabled !== "boolean") {
37
33
  throw new Error("config.enabled must be a boolean, received ".concat(newConfig.enabled));
@@ -40,23 +36,21 @@ const initStegaConfig = (config, prevConfig) => {
40
36
  throw new Error("config.studioUrl must be defined when config.enabled is true");
41
37
  }
42
38
  if (newConfig.enabled && typeof newConfig.studioUrl !== "string" && typeof newConfig.studioUrl !== "function") {
43
- throw new Error("config.studioUrl must be a string or a function, received ".concat(newConfig.studioUrl));
39
+ throw new Error(
40
+ "config.studioUrl must be a string or a function, received ".concat(newConfig.studioUrl)
41
+ );
44
42
  }
45
43
  return newConfig;
46
44
  };
47
45
  function splitStegaConfigFromFetchOptions(options, initializedStegaConfig) {
48
- const {
49
- stega = {},
50
- ...fetchOptions
51
- } = options;
52
- const stegaConfig = initStegaConfig(typeof stega === "boolean" ? {
53
- enabled: stega
54
- } : stega, initializedStegaConfig);
55
- return {
56
- fetchOptions,
57
- stegaConfig
58
- };
46
+ const { stega = {}, ...fetchOptions } = options;
47
+ const stegaConfig = initStegaConfig(
48
+ typeof stega === "boolean" ? { enabled: stega } : stega,
49
+ initializedStegaConfig
50
+ );
51
+ return { fetchOptions, stegaConfig };
59
52
  }
53
+
60
54
  function encodeIntoResult(result, csm, encoder) {
61
55
  return resolveEditInfo.walkMap(result, (value, path) => {
62
56
  if (typeof value !== "string") {
@@ -66,10 +60,7 @@ function encodeIntoResult(result, csm, encoder) {
66
60
  if (!resolveMappingResult) {
67
61
  return value;
68
62
  }
69
- const {
70
- mapping,
71
- matchedPath
72
- } = resolveMappingResult;
63
+ const { mapping, matchedPath } = resolveMappingResult;
73
64
  if (mapping.type !== "value") {
74
65
  return value;
75
66
  }
@@ -89,11 +80,8 @@ function encodeIntoResult(result, csm, encoder) {
89
80
  });
90
81
  });
91
82
  }
92
- const filterDefault = _ref => {
93
- let {
94
- sourcePath,
95
- value
96
- } = _ref;
83
+
84
+ const filterDefault = ({ sourcePath, value }) => {
97
85
  if (isValidDate(value) || isValidURL(value)) {
98
86
  return false;
99
87
  }
@@ -113,7 +101,9 @@ const filterDefault = _ref => {
113
101
  if (endPath === "style" || endPath === "listItem") {
114
102
  return false;
115
103
  }
116
- if (sourcePath.some(path => path === "meta" || path === "metadata" || path === "openGraph" || path === "seo")) {
104
+ if (sourcePath.some(
105
+ (path) => path === "meta" || path === "metadata" || path === "openGraph" || path === "seo"
106
+ )) {
117
107
  return false;
118
108
  }
119
109
  if (typeof endPath === "string" && denylist.has(endPath)) {
@@ -121,7 +111,46 @@ const filterDefault = _ref => {
121
111
  }
122
112
  return true;
123
113
  };
124
- const denylist = /* @__PURE__ */new Set(["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", "unit", "url", "username", "variant", "website"]);
114
+ const denylist = /* @__PURE__ */ new Set([
115
+ "color",
116
+ "colour",
117
+ "currency",
118
+ "email",
119
+ "format",
120
+ "gid",
121
+ "hex",
122
+ "href",
123
+ "hsl",
124
+ "hsla",
125
+ "icon",
126
+ "id",
127
+ "index",
128
+ "key",
129
+ "language",
130
+ "layout",
131
+ "link",
132
+ "linkAction",
133
+ "locale",
134
+ "lqip",
135
+ "page",
136
+ "path",
137
+ "ref",
138
+ "rgb",
139
+ "rgba",
140
+ "route",
141
+ "secret",
142
+ "slug",
143
+ "status",
144
+ "tag",
145
+ "template",
146
+ "theme",
147
+ "type",
148
+ "unit",
149
+ "url",
150
+ "username",
151
+ "variant",
152
+ "website"
153
+ ]);
125
154
  function isValidDate(dateString) {
126
155
  return Number.isNaN(Number(dateString)) ? Boolean(Date.parse(dateString)) : false;
127
156
  }
@@ -133,21 +162,14 @@ function isValidURL(url) {
133
162
  }
134
163
  return true;
135
164
  }
165
+
136
166
  const TRUNCATE_LENGTH = 20;
137
167
  function stegaEncodeSourceMap(result, resultSourceMap, config) {
138
168
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
139
- const {
140
- filter,
141
- logger,
142
- enabled
143
- } = config;
169
+ const { filter, logger, enabled } = config;
144
170
  if (!enabled) {
145
171
  const msg = "config.enabled must be true, don't call this function otherwise";
146
- (_a = logger == null ? void 0 : logger.error) == null ? void 0 : _a.call(logger, "[@sanity/client/stega]: ".concat(msg), {
147
- result,
148
- resultSourceMap,
149
- config
150
- });
172
+ (_a = logger == null ? void 0 : logger.error) == null ? void 0 : _a.call(logger, "[@sanity/client/stega]: ".concat(msg), { result, resultSourceMap, config });
151
173
  throw new TypeError(msg);
152
174
  }
153
175
  if (!resultSourceMap) {
@@ -160,93 +182,77 @@ function stegaEncodeSourceMap(result, resultSourceMap, config) {
160
182
  }
161
183
  if (!config.studioUrl) {
162
184
  const msg = "config.studioUrl must be defined";
163
- (_c = logger == null ? void 0 : logger.error) == null ? void 0 : _c.call(logger, "[@sanity/client/stega]: ".concat(msg), {
164
- result,
165
- resultSourceMap,
166
- config
167
- });
185
+ (_c = logger == null ? void 0 : logger.error) == null ? void 0 : _c.call(logger, "[@sanity/client/stega]: ".concat(msg), { result, resultSourceMap, config });
168
186
  throw new TypeError(msg);
169
187
  }
170
188
  const report = {
171
189
  encoded: [],
172
190
  skipped: []
173
191
  };
174
- const resultWithStega = encodeIntoResult(result, resultSourceMap, _ref2 => {
175
- let {
176
- sourcePath,
177
- sourceDocument,
178
- resultPath,
179
- value
180
- } = _ref2;
181
- if ((typeof filter === "function" ? filter({
182
- sourcePath,
183
- resultPath,
184
- filterDefault,
185
- sourceDocument,
186
- value
187
- }) : filterDefault({
188
- sourcePath,
189
- resultPath,
190
- filterDefault,
191
- sourceDocument,
192
- value
193
- })) === false) {
192
+ const resultWithStega = encodeIntoResult(
193
+ result,
194
+ resultSourceMap,
195
+ ({ sourcePath, sourceDocument, resultPath, value }) => {
196
+ if ((typeof filter === "function" ? filter({ sourcePath, resultPath, filterDefault, sourceDocument, value }) : filterDefault({ sourcePath, resultPath, filterDefault, sourceDocument, value })) === false) {
197
+ if (logger) {
198
+ report.skipped.push({
199
+ path: prettyPathForLogging(sourcePath),
200
+ value: "".concat(value.slice(0, TRUNCATE_LENGTH)).concat(value.length > TRUNCATE_LENGTH ? "..." : ""),
201
+ length: value.length
202
+ });
203
+ }
204
+ return value;
205
+ }
194
206
  if (logger) {
195
- report.skipped.push({
207
+ report.encoded.push({
196
208
  path: prettyPathForLogging(sourcePath),
197
209
  value: "".concat(value.slice(0, TRUNCATE_LENGTH)).concat(value.length > TRUNCATE_LENGTH ? "..." : ""),
198
210
  length: value.length
199
211
  });
200
212
  }
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
- });
213
+ const { baseUrl, workspace, tool } = resolveEditInfo.resolveStudioBaseRoute(
214
+ typeof config.studioUrl === "function" ? config.studioUrl(sourceDocument) : config.studioUrl
215
+ );
216
+ if (!baseUrl)
217
+ return value;
218
+ const { _id: id, _type: type } = sourceDocument;
219
+ return stega.vercelStegaCombine(
220
+ value,
221
+ {
222
+ origin: "sanity.io",
223
+ href: resolveEditInfo.createEditUrl({
224
+ baseUrl,
225
+ workspace,
226
+ tool,
227
+ id,
228
+ type,
229
+ path: sourcePath
230
+ })
231
+ },
232
+ // We use custom logic to determine if we should skip encoding
233
+ false
234
+ );
209
235
  }
210
- const {
211
- baseUrl,
212
- workspace,
213
- tool
214
- } = resolveEditInfo.resolveStudioBaseRoute(typeof config.studioUrl === "function" ? config.studioUrl(sourceDocument) : config.studioUrl);
215
- if (!baseUrl) return value;
216
- const {
217
- _id: id,
218
- _type: type
219
- } = sourceDocument;
220
- return stega.vercelStegaCombine(value, {
221
- origin: "sanity.io",
222
- href: resolveEditInfo.createEditUrl({
223
- baseUrl,
224
- workspace,
225
- tool,
226
- id,
227
- type,
228
- path: sourcePath
229
- })
230
- },
231
- // We use custom logic to determine if we should skip encoding
232
- false);
233
- });
236
+ );
234
237
  if (logger) {
235
238
  const isSkipping = report.skipped.length;
236
239
  const isEncoding = report.encoded.length;
237
240
  if (isSkipping || isEncoding) {
238
- (_d = (logger == null ? void 0 : logger.groupCollapsed) || logger.log) == null ? void 0 : _d("[@sanity/client/stega]: Encoding source map into result");
239
- (_e = logger.log) == null ? void 0 : _e.call(logger, "[@sanity/client/stega]: Paths encoded: ".concat(report.encoded.length, ", skipped: ").concat(report.skipped.length));
241
+ (_d = (logger == null ? void 0 : logger.groupCollapsed) || logger.log) == null ? void 0 : _d(
242
+ "[@sanity/client/stega]: Encoding source map into result"
243
+ );
244
+ (_e = logger.log) == null ? void 0 : _e.call(
245
+ logger,
246
+ "[@sanity/client/stega]: Paths encoded: ".concat(report.encoded.length, ", skipped: ").concat(report.skipped.length)
247
+ );
240
248
  }
241
249
  if (report.encoded.length > 0) {
242
250
  (_f = logger == null ? void 0 : logger.log) == null ? void 0 : _f.call(logger, "[@sanity/client/stega]: Table of encoded paths");
243
251
  (_g = (logger == null ? void 0 : logger.table) || logger.log) == null ? void 0 : _g(report.encoded);
244
252
  }
245
253
  if (report.skipped.length > 0) {
246
- const skipped = /* @__PURE__ */new Set();
247
- for (const {
248
- path
249
- } of report.skipped) {
254
+ const skipped = /* @__PURE__ */ new Set();
255
+ for (const { path } of report.skipped) {
250
256
  skipped.add(path.replace(resolveEditInfo.reKeySegment, "0").replace(/\[\d+\]/g, "[]"));
251
257
  }
252
258
  (_h = logger == null ? void 0 : logger.log) == null ? void 0 : _h.call(logger, "[@sanity/client/stega]: List of skipped paths", [...skipped.values()]);
@@ -260,25 +266,32 @@ function stegaEncodeSourceMap(result, resultSourceMap, config) {
260
266
  function prettyPathForLogging(path) {
261
267
  return resolveEditInfo.toString(resolveEditInfo.jsonPathToStudioPath(path));
262
268
  }
269
+
263
270
  function vercelStegaCleanAll(result) {
264
271
  try {
265
- return JSON.parse(JSON.stringify(result, (key, value) => {
266
- if (typeof value !== "string") return value;
267
- return stega.vercelStegaSplit(value).cleaned;
268
- }));
272
+ return JSON.parse(
273
+ JSON.stringify(result, (key, value) => {
274
+ if (typeof value !== "string")
275
+ return value;
276
+ return stega.vercelStegaSplit(value).cleaned;
277
+ })
278
+ );
269
279
  } catch {
270
280
  return result;
271
281
  }
272
282
  }
283
+
273
284
  var __accessCheck = (obj, member, msg) => {
274
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
285
+ if (!member.has(obj))
286
+ throw TypeError("Cannot " + msg);
275
287
  };
276
288
  var __privateGet = (obj, member, getter) => {
277
289
  __accessCheck(obj, member, "read from private field");
278
290
  return getter ? getter.call(obj) : member.get(obj);
279
291
  };
280
292
  var __privateAdd = (obj, member, value) => {
281
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
293
+ if (member.has(obj))
294
+ throw TypeError("Cannot add the same private member more than once");
282
295
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
283
296
  };
284
297
  var __privateSet = (obj, member, value, setter) => {
@@ -288,12 +301,8 @@ var __privateSet = (obj, member, value, setter) => {
288
301
  };
289
302
  var _httpRequest, _httpRequest2;
290
303
  const _ObservableSanityStegaClient = class _ObservableSanityStegaClient extends nodeMiddleware.ObservableSanityClient {
291
- constructor(httpRequest) {
292
- let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : nodeMiddleware.defaultConfig;
293
- const {
294
- clientConfig,
295
- stegaConfig
296
- } = splitConfig(config);
304
+ constructor(httpRequest, config = nodeMiddleware.defaultConfig) {
305
+ const { clientConfig, stegaConfig } = splitConfig(config);
297
306
  super(httpRequest, clientConfig);
298
307
  /**
299
308
  * Private properties
@@ -310,17 +319,9 @@ const _ObservableSanityStegaClient = class _ObservableSanityStegaClient extends
310
319
  }
311
320
  config(newConfig) {
312
321
  if (newConfig === void 0) {
313
- return {
314
- ...super.config(),
315
- stega: {
316
- ...this.stegaConfig
317
- }
318
- };
322
+ return { ...super.config(), stega: { ...this.stegaConfig } };
319
323
  }
320
- const {
321
- clientConfig,
322
- stegaConfig
323
- } = splitConfig(newConfig);
324
+ const { clientConfig, stegaConfig } = splitConfig(newConfig);
324
325
  super.config(clientConfig);
325
326
  this.stegaConfig = initStegaConfig(stegaConfig, this.stegaConfig || {});
326
327
  return this;
@@ -332,56 +333,47 @@ const _ObservableSanityStegaClient = class _ObservableSanityStegaClient extends
332
333
  */
333
334
  withConfig(newConfig) {
334
335
  const thisConfig = this.config();
335
- const {
336
- stegaConfig
337
- } = splitConfig(newConfig || {});
336
+ const { stegaConfig } = splitConfig(newConfig || {});
338
337
  return new _ObservableSanityStegaClient(__privateGet(this, _httpRequest), {
339
338
  ...thisConfig,
340
339
  ...newConfig,
341
340
  stega: {
342
- ...(thisConfig.stega || {}),
343
- ...(stegaConfig || {})
341
+ ...thisConfig.stega || {},
342
+ ...stegaConfig || {}
344
343
  }
345
344
  });
346
345
  }
347
- fetch(query, _params) {
348
- let _options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
349
- const {
350
- stegaConfig,
351
- fetchOptions: options
352
- } = splitStegaConfigFromFetchOptions(_options, this.stegaConfig);
346
+ fetch(query, _params, _options = {}) {
347
+ const { stegaConfig, fetchOptions: options } = splitStegaConfigFromFetchOptions(
348
+ _options,
349
+ this.stegaConfig
350
+ );
353
351
  const params = _params ? vercelStegaCleanAll(_params) : _params;
354
352
  if (!stegaConfig.enabled) {
355
353
  return super.fetch(query, params, options);
356
354
  }
357
- const {
358
- filterResponse: originalFilterResponse = true
359
- } = options;
360
- return super.fetch(query, params, Object.assign({}, options, {
361
- filterResponse: false,
362
- resultSourceMap: "withKeyArraySelector"
363
- })).pipe(operators.map(res => {
364
- const {
365
- result: _result,
366
- resultSourceMap
367
- } = res;
368
- const result = stegaEncodeSourceMap(_result, resultSourceMap, stegaConfig);
369
- return originalFilterResponse ? result : {
370
- ...res,
371
- result
372
- };
373
- }));
355
+ const { filterResponse: originalFilterResponse = true } = options;
356
+ return super.fetch(
357
+ query,
358
+ params,
359
+ Object.assign({}, options, {
360
+ filterResponse: false,
361
+ resultSourceMap: "withKeyArraySelector"
362
+ })
363
+ ).pipe(
364
+ operators.map((res) => {
365
+ const { result: _result, resultSourceMap } = res;
366
+ const result = stegaEncodeSourceMap(_result, resultSourceMap, stegaConfig);
367
+ return originalFilterResponse ? result : { ...res, result };
368
+ })
369
+ );
374
370
  }
375
371
  };
376
372
  _httpRequest = new WeakMap();
377
373
  let ObservableSanityStegaClient = _ObservableSanityStegaClient;
378
374
  const _SanityStegaClient = class _SanityStegaClient extends nodeMiddleware.SanityClient {
379
- constructor(httpRequest) {
380
- let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : nodeMiddleware.defaultConfig;
381
- const {
382
- clientConfig,
383
- stegaConfig
384
- } = splitConfig(config);
375
+ constructor(httpRequest, config = nodeMiddleware.defaultConfig) {
376
+ const { clientConfig, stegaConfig } = splitConfig(config);
385
377
  super(httpRequest, clientConfig);
386
378
  /**
387
379
  * Private properties
@@ -399,21 +391,11 @@ const _SanityStegaClient = class _SanityStegaClient extends nodeMiddleware.Sanit
399
391
  }
400
392
  config(newConfig) {
401
393
  if (newConfig === void 0) {
402
- return {
403
- ...super.config(),
404
- stega: {
405
- ...this.stegaConfig
406
- }
407
- };
394
+ return { ...super.config(), stega: { ...this.stegaConfig } };
408
395
  }
409
- const {
410
- clientConfig,
411
- stegaConfig
412
- } = splitConfig(newConfig);
396
+ const { clientConfig, stegaConfig } = splitConfig(newConfig);
413
397
  super.config(clientConfig);
414
- this.stegaConfig = initStegaConfig(stegaConfig, {
415
- ...(this.stegaConfig || {})
416
- });
398
+ this.stegaConfig = initStegaConfig(stegaConfig, { ...this.stegaConfig || {} });
417
399
  return this;
418
400
  }
419
401
  /**
@@ -423,52 +405,50 @@ const _SanityStegaClient = class _SanityStegaClient extends nodeMiddleware.Sanit
423
405
  */
424
406
  withConfig(newConfig) {
425
407
  const thisConfig = this.config();
426
- const {
427
- stegaConfig
428
- } = splitConfig(newConfig || {});
408
+ const { stegaConfig } = splitConfig(newConfig || {});
429
409
  return new _SanityStegaClient(__privateGet(this, _httpRequest2), {
430
410
  ...thisConfig,
431
411
  ...newConfig,
432
412
  stega: {
433
- ...(thisConfig.stega || {}),
434
- ...(stegaConfig || {})
413
+ ...thisConfig.stega || {},
414
+ ...stegaConfig || {}
435
415
  }
436
416
  });
437
417
  }
438
- fetch(query, _params) {
439
- let _options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
440
- const {
441
- stegaConfig,
442
- fetchOptions: options
443
- } = splitStegaConfigFromFetchOptions(_options, this.stegaConfig);
418
+ fetch(query, _params, _options = {}) {
419
+ const { stegaConfig, fetchOptions: options } = splitStegaConfigFromFetchOptions(
420
+ _options,
421
+ this.stegaConfig
422
+ );
444
423
  const params = _params ? vercelStegaCleanAll(_params) : _params;
445
424
  if (!stegaConfig.enabled) {
446
425
  return super.fetch(query, params, options);
447
426
  }
448
- const {
449
- filterResponse: originalFilterResponse = true
450
- } = options;
451
- return super.fetch(query, params, Object.assign({}, options, {
452
- filterResponse: false,
453
- resultSourceMap: "withKeyArraySelector"
454
- })).then(res => {
455
- const {
456
- result: _result,
457
- resultSourceMap
458
- } = res;
427
+ const { filterResponse: originalFilterResponse = true } = options;
428
+ return super.fetch(
429
+ query,
430
+ params,
431
+ Object.assign({}, options, {
432
+ filterResponse: false,
433
+ resultSourceMap: "withKeyArraySelector"
434
+ })
435
+ ).then((res) => {
436
+ const { result: _result, resultSourceMap } = res;
459
437
  const result = stegaEncodeSourceMap(_result, resultSourceMap, stegaConfig);
460
- return originalFilterResponse ? result : {
461
- ...res,
462
- result
463
- };
438
+ return originalFilterResponse ? result : { ...res, result };
464
439
  });
465
440
  }
466
441
  };
467
442
  _httpRequest2 = new WeakMap();
468
443
  let SanityStegaClient = _SanityStegaClient;
469
- const exp = nodeMiddleware.defineCreateClientExports(nodeMiddleware.middleware, SanityStegaClient);
444
+
445
+ const exp = nodeMiddleware.defineCreateClientExports(
446
+ nodeMiddleware.middleware,
447
+ SanityStegaClient
448
+ );
470
449
  const requester = exp.requester;
471
450
  const createClient = exp.createClient;
451
+
472
452
  exports.BasePatch = nodeMiddleware.BasePatch;
473
453
  exports.BaseTransaction = nodeMiddleware.BaseTransaction;
474
454
  exports.ClientError = nodeMiddleware.ClientError;
@@ -481,15 +461,11 @@ exports.ServerError = nodeMiddleware.ServerError;
481
461
  exports.Transaction = nodeMiddleware.Transaction;
482
462
  Object.defineProperty(exports, "unstable__adapter", {
483
463
  enumerable: true,
484
- get: function () {
485
- return getIt.adapter;
486
- }
464
+ get: function () { return getIt.adapter; }
487
465
  });
488
466
  Object.defineProperty(exports, "unstable__environment", {
489
467
  enumerable: true,
490
- get: function () {
491
- return getIt.environment;
492
- }
468
+ get: function () { return getIt.environment; }
493
469
  });
494
470
  exports.ObservableSanityStegaClient = ObservableSanityStegaClient;
495
471
  exports.SanityStegaClient = SanityStegaClient;