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