@sanity/client 6.21.1 → 6.21.3-bundle-perspective
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/_chunks-cjs/resolveEditInfo.cjs +2 -3
- package/dist/_chunks-cjs/resolveEditInfo.cjs.map +1 -1
- package/dist/_chunks-cjs/stegaClean.cjs +1 -2
- package/dist/_chunks-cjs/stegaClean.cjs.map +1 -1
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs +9 -12
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +1 -1
- package/dist/_chunks-es/resolveEditInfo.js +2 -3
- package/dist/_chunks-es/resolveEditInfo.js.map +1 -1
- package/dist/_chunks-es/stegaClean.js +1 -2
- package/dist/_chunks-es/stegaClean.js.map +1 -1
- package/dist/_chunks-es/stegaEncodeSourceMap.js +9 -12
- package/dist/_chunks-es/stegaEncodeSourceMap.js.map +1 -1
- package/dist/csm.cjs +1 -2
- package/dist/csm.cjs.map +1 -1
- package/dist/csm.js +1 -2
- package/dist/csm.js.map +1 -1
- package/dist/index.browser.cjs +188 -213
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +16 -3
- package/dist/index.browser.d.ts +16 -3
- package/dist/index.browser.js +188 -214
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +189 -214
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -3
- package/dist/index.d.ts +16 -3
- package/dist/index.js +189 -215
- package/dist/index.js.map +1 -1
- package/package.json +18 -18
- package/src/SanityClient.ts +2 -2
- package/src/data/dataMethods.ts +23 -4
- package/src/types.ts +14 -1
- package/umd/sanityClient.js +212 -975
- package/umd/sanityClient.min.js +2 -8
package/umd/sanityClient.js
CHANGED
|
@@ -4,745 +4,11 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.SanityClient = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
const options = {
|
|
9
|
-
...defaultOptions$1,
|
|
10
|
-
...typeof opts == "string" ? { url: opts } : opts
|
|
11
|
-
};
|
|
12
|
-
if (options.timeout = normalizeTimeout(options.timeout), options.query) {
|
|
13
|
-
const { url, searchParams } = splitUrl(options.url);
|
|
14
|
-
for (const [key, value] of Object.entries(options.query)) {
|
|
15
|
-
if (value !== void 0)
|
|
16
|
-
if (Array.isArray(value))
|
|
17
|
-
for (const v of value)
|
|
18
|
-
searchParams.append(key, v);
|
|
19
|
-
else
|
|
20
|
-
searchParams.append(key, value);
|
|
21
|
-
const search = searchParams.toString();
|
|
22
|
-
search && (options.url = `${url}?${search}`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return options.method = options.body && !options.method ? "POST" : (options.method || "GET").toUpperCase(), options;
|
|
26
|
-
};
|
|
27
|
-
function splitUrl(url) {
|
|
28
|
-
const qIndex = url.indexOf("?");
|
|
29
|
-
if (qIndex === -1)
|
|
30
|
-
return { url, searchParams: new URLSearchParams() };
|
|
31
|
-
const base = url.slice(0, qIndex), qs = url.slice(qIndex + 1);
|
|
32
|
-
if (!isReactNative)
|
|
33
|
-
return { url: base, searchParams: new URLSearchParams(qs) };
|
|
34
|
-
if (typeof decodeURIComponent != "function")
|
|
35
|
-
throw new Error(
|
|
36
|
-
"Broken `URLSearchParams` implementation, and `decodeURIComponent` is not defined"
|
|
37
|
-
);
|
|
38
|
-
const params = new URLSearchParams();
|
|
39
|
-
for (const pair of qs.split("&")) {
|
|
40
|
-
const [key, value] = pair.split("=");
|
|
41
|
-
key && params.append(decodeQueryParam(key), decodeQueryParam(value || ""));
|
|
42
|
-
}
|
|
43
|
-
return { url: base, searchParams: params };
|
|
44
|
-
}
|
|
45
|
-
function decodeQueryParam(value) {
|
|
46
|
-
return decodeURIComponent(value.replace(/\+/g, " "));
|
|
47
|
-
}
|
|
48
|
-
function normalizeTimeout(time) {
|
|
49
|
-
if (time === !1 || time === 0)
|
|
50
|
-
return !1;
|
|
51
|
-
if (time.connect || time.socket)
|
|
52
|
-
return time;
|
|
53
|
-
const delay = Number(time);
|
|
54
|
-
return isNaN(delay) ? normalizeTimeout(defaultOptions$1.timeout) : { connect: delay, socket: delay };
|
|
55
|
-
}
|
|
56
|
-
const validUrl = /^https?:\/\//i, validateOptions = function(options) {
|
|
57
|
-
if (!validUrl.test(options.url))
|
|
58
|
-
throw new Error(`"${options.url}" is not a valid URL`);
|
|
59
|
-
};
|
|
60
|
-
function getDefaultExportFromCjs$1(x) {
|
|
61
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x.default : x;
|
|
62
|
-
}
|
|
7
|
+
const e=!(typeof navigator>"u")&&"ReactNative"===navigator.product,t={timeout:e?6e4:12e4},r=function(r){const a={...t,..."string"==typeof r?{url:r}:r};if(a.timeout=n$1(a.timeout),a.query){const{url:t,searchParams:r}=function(t){const r=t.indexOf("?");if(-1===r)return {url:t,searchParams:new URLSearchParams};const n=t.slice(0,r),a=t.slice(r+1);if(!e)return {url:n,searchParams:new URLSearchParams(a)};if("function"!=typeof decodeURIComponent)throw new Error("Broken `URLSearchParams` implementation, and `decodeURIComponent` is not defined");const s=new URLSearchParams;for(const e of a.split("&")){const[t,r]=e.split("=");t&&s.append(o$1(t),o$1(r||""));}return {url:n,searchParams:s}}(a.url);for(const[e,o]of Object.entries(a.query)){if(void 0!==o)if(Array.isArray(o))for(const t of o)r.append(e,t);else r.append(e,o);const n=r.toString();n&&(a.url=`${t}?${n}`);}}return a.method=a.body&&!a.method?"POST":(a.method||"GET").toUpperCase(),a};function o$1(e){return decodeURIComponent(e.replace(/\+/g," "))}function n$1(e){if(!1===e||0===e)return !1;if(e.connect||e.socket)return e;const r=Number(e);return isNaN(r)?n$1(t.timeout):{connect:r,socket:r}}const a$2=/^https?:\/\//i,s$2=function(e){if(!a$2.test(e.url))throw new Error(`"${e.url}" is not a valid URL`)};function c$3(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}
|
|
63
8
|
|
|
64
|
-
const
|
|
65
|
-
const bailEarly = hook === "onError";
|
|
66
|
-
let value = defaultValue;
|
|
67
|
-
for (let i = 0; i < middleware[hook].length; i++) {
|
|
68
|
-
const handler = middleware[hook][i];
|
|
69
|
-
if (value = handler(value, ...args), bailEarly && !value)
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
return value;
|
|
73
|
-
};
|
|
74
|
-
function createPubSub() {
|
|
75
|
-
const subscribers = /* @__PURE__ */ Object.create(null);
|
|
76
|
-
let nextId = 0;
|
|
77
|
-
function subscribe(subscriber) {
|
|
78
|
-
const id = nextId++;
|
|
79
|
-
return subscribers[id] = subscriber, function() {
|
|
80
|
-
delete subscribers[id];
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
function publish(event) {
|
|
84
|
-
for (const id in subscribers)
|
|
85
|
-
subscribers[id](event);
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
publish,
|
|
89
|
-
subscribe
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
const channelNames = [
|
|
93
|
-
"request",
|
|
94
|
-
"response",
|
|
95
|
-
"progress",
|
|
96
|
-
"error",
|
|
97
|
-
"abort"
|
|
98
|
-
], middlehooks = [
|
|
99
|
-
"processOptions",
|
|
100
|
-
"validateOptions",
|
|
101
|
-
"interceptRequest",
|
|
102
|
-
"finalizeOptions",
|
|
103
|
-
"onRequest",
|
|
104
|
-
"onResponse",
|
|
105
|
-
"onError",
|
|
106
|
-
"onReturn",
|
|
107
|
-
"onHeaders"
|
|
108
|
-
];
|
|
109
|
-
function createRequester(initMiddleware, httpRequest) {
|
|
110
|
-
const loadedMiddleware = [], middleware = middlehooks.reduce(
|
|
111
|
-
(ware, name) => (ware[name] = ware[name] || [], ware),
|
|
112
|
-
{
|
|
113
|
-
processOptions: [processOptions],
|
|
114
|
-
validateOptions: [validateOptions]
|
|
115
|
-
}
|
|
116
|
-
);
|
|
117
|
-
function request(opts) {
|
|
118
|
-
const onResponse = (reqErr, res, ctx) => {
|
|
119
|
-
let error = reqErr, response = res;
|
|
120
|
-
if (!error)
|
|
121
|
-
try {
|
|
122
|
-
response = applyMiddleware("onResponse", res, ctx);
|
|
123
|
-
} catch (err) {
|
|
124
|
-
response = null, error = err;
|
|
125
|
-
}
|
|
126
|
-
error = error && applyMiddleware("onError", error, ctx), error ? channels.error.publish(error) : response && channels.response.publish(response);
|
|
127
|
-
}, channels = channelNames.reduce((target, name) => (target[name] = createPubSub(), target), {}), applyMiddleware = middlewareReducer(middleware), options = applyMiddleware("processOptions", opts);
|
|
128
|
-
applyMiddleware("validateOptions", options);
|
|
129
|
-
const context = { options, channels, applyMiddleware };
|
|
130
|
-
let ongoingRequest;
|
|
131
|
-
const unsubscribe = channels.request.subscribe((ctx) => {
|
|
132
|
-
ongoingRequest = httpRequest(ctx, (err, res) => onResponse(err, res, ctx));
|
|
133
|
-
});
|
|
134
|
-
channels.abort.subscribe(() => {
|
|
135
|
-
unsubscribe(), ongoingRequest && ongoingRequest.abort();
|
|
136
|
-
});
|
|
137
|
-
const returnValue = applyMiddleware("onReturn", channels, context);
|
|
138
|
-
return returnValue === channels && channels.request.publish(context), returnValue;
|
|
139
|
-
}
|
|
140
|
-
return request.use = function(newMiddleware) {
|
|
141
|
-
if (!newMiddleware)
|
|
142
|
-
throw new Error("Tried to add middleware that resolved to falsey value");
|
|
143
|
-
if (typeof newMiddleware == "function")
|
|
144
|
-
throw new Error(
|
|
145
|
-
"Tried to add middleware that was a function. It probably expects you to pass options to it."
|
|
146
|
-
);
|
|
147
|
-
if (newMiddleware.onReturn && middleware.onReturn.length > 0)
|
|
148
|
-
throw new Error(
|
|
149
|
-
"Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event"
|
|
150
|
-
);
|
|
151
|
-
return middlehooks.forEach((key) => {
|
|
152
|
-
newMiddleware[key] && middleware[key].push(newMiddleware[key]);
|
|
153
|
-
}), loadedMiddleware.push(newMiddleware), request;
|
|
154
|
-
}, request.clone = () => createRequester(loadedMiddleware, httpRequest), initMiddleware.forEach(request.use), request;
|
|
155
|
-
}
|
|
156
|
-
var trim = function(string) {
|
|
157
|
-
return string.replace(/^\s+|\s+$/g, "");
|
|
158
|
-
}, isArray$3 = function(arg) {
|
|
159
|
-
return Object.prototype.toString.call(arg) === "[object Array]";
|
|
160
|
-
}, parseHeaders = function(headers) {
|
|
161
|
-
if (!headers)
|
|
162
|
-
return {};
|
|
163
|
-
for (var result = {}, headersArr = trim(headers).split(`
|
|
164
|
-
`), i = 0; i < headersArr.length; i++) {
|
|
165
|
-
var row = headersArr[i], index = row.indexOf(":"), key = trim(row.slice(0, index)).toLowerCase(), value = trim(row.slice(index + 1));
|
|
166
|
-
typeof result[key] > "u" ? result[key] = value : isArray$3(result[key]) ? result[key].push(value) : result[key] = [result[key], value];
|
|
167
|
-
}
|
|
168
|
-
return result;
|
|
169
|
-
}, parseHeaders$1 = /* @__PURE__ */ getDefaultExportFromCjs$1(parseHeaders), __defProp$4 = Object.defineProperty, __typeError = (msg) => {
|
|
170
|
-
throw TypeError(msg);
|
|
171
|
-
}, __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key != "symbol" ? key + "" : key, value), __accessCheck$8 = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg), __privateGet$8 = (obj, member, getter) => (__accessCheck$8(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$8 = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value), __privateSet$8 = (obj, member, value, setter) => (__accessCheck$8(obj, member, "write to private field"), member.set(obj, value), value), _method, _url, _resHeaders, _headers, _controller, _init, _useAbortSignal;
|
|
172
|
-
class FetchXhr {
|
|
173
|
-
constructor() {
|
|
174
|
-
__publicField$4(this, "onabort"), __publicField$4(this, "onerror"), __publicField$4(this, "onreadystatechange"), __publicField$4(this, "ontimeout"), __publicField$4(this, "readyState", 0), __publicField$4(this, "response"), __publicField$4(this, "responseText", ""), __publicField$4(this, "responseType", ""), __publicField$4(this, "status"), __publicField$4(this, "statusText"), __publicField$4(this, "withCredentials"), __privateAdd$8(this, _method), __privateAdd$8(this, _url), __privateAdd$8(this, _resHeaders), __privateAdd$8(this, _headers, {}), __privateAdd$8(this, _controller), __privateAdd$8(this, _init, {}), __privateAdd$8(this, _useAbortSignal);
|
|
175
|
-
}
|
|
176
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- _async is only declared for typings compatibility
|
|
177
|
-
open(method, url, _async) {
|
|
178
|
-
var _a;
|
|
179
|
-
__privateSet$8(this, _method, method), __privateSet$8(this, _url, url), __privateSet$8(this, _resHeaders, ""), this.readyState = 1, (_a = this.onreadystatechange) == null || _a.call(this), __privateSet$8(this, _controller, void 0);
|
|
180
|
-
}
|
|
181
|
-
abort() {
|
|
182
|
-
__privateGet$8(this, _controller) && __privateGet$8(this, _controller).abort();
|
|
183
|
-
}
|
|
184
|
-
getAllResponseHeaders() {
|
|
185
|
-
return __privateGet$8(this, _resHeaders);
|
|
186
|
-
}
|
|
187
|
-
setRequestHeader(name, value) {
|
|
188
|
-
__privateGet$8(this, _headers)[name] = value;
|
|
189
|
-
}
|
|
190
|
-
// Allow setting extra fetch init options, needed for runtimes such as Vercel Edge to set `cache` and other options in React Server Components
|
|
191
|
-
setInit(init, useAbortSignal = !0) {
|
|
192
|
-
__privateSet$8(this, _init, init), __privateSet$8(this, _useAbortSignal, useAbortSignal);
|
|
193
|
-
}
|
|
194
|
-
send(body) {
|
|
195
|
-
const textBody = this.responseType !== "arraybuffer", options = {
|
|
196
|
-
...__privateGet$8(this, _init),
|
|
197
|
-
method: __privateGet$8(this, _method),
|
|
198
|
-
headers: __privateGet$8(this, _headers),
|
|
199
|
-
body
|
|
200
|
-
};
|
|
201
|
-
typeof AbortController == "function" && __privateGet$8(this, _useAbortSignal) && (__privateSet$8(this, _controller, new AbortController()), typeof EventTarget < "u" && __privateGet$8(this, _controller).signal instanceof EventTarget && (options.signal = __privateGet$8(this, _controller).signal)), typeof document < "u" && (options.credentials = this.withCredentials ? "include" : "omit"), fetch(__privateGet$8(this, _url), options).then((res) => {
|
|
202
|
-
var _a;
|
|
203
|
-
return res.headers.forEach((value, key) => {
|
|
204
|
-
__privateSet$8(this, _resHeaders, __privateGet$8(this, _resHeaders) + `${key}: ${value}\r
|
|
205
|
-
`);
|
|
206
|
-
}), this.status = res.status, this.statusText = res.statusText, this.readyState = 3, (_a = this.onreadystatechange) == null || _a.call(this), textBody ? res.text() : res.arrayBuffer();
|
|
207
|
-
}).then((resBody) => {
|
|
208
|
-
var _a;
|
|
209
|
-
typeof resBody == "string" ? this.responseText = resBody : this.response = resBody, this.readyState = 4, (_a = this.onreadystatechange) == null || _a.call(this);
|
|
210
|
-
}).catch((err) => {
|
|
211
|
-
var _a, _b;
|
|
212
|
-
if (err.name === "AbortError") {
|
|
213
|
-
(_a = this.onabort) == null || _a.call(this);
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
(_b = this.onerror) == null || _b.call(this, err);
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
_method = /* @__PURE__ */ new WeakMap(), _url = /* @__PURE__ */ new WeakMap(), _resHeaders = /* @__PURE__ */ new WeakMap(), _headers = /* @__PURE__ */ new WeakMap(), _controller = /* @__PURE__ */ new WeakMap(), _init = /* @__PURE__ */ new WeakMap(), _useAbortSignal = /* @__PURE__ */ new WeakMap();
|
|
221
|
-
const adapter = typeof XMLHttpRequest == "function" ? "xhr" : "fetch", XmlHttpRequest = adapter === "xhr" ? XMLHttpRequest : FetchXhr, httpRequester = (context, callback) => {
|
|
222
|
-
var _a;
|
|
223
|
-
const opts = context.options, options = context.applyMiddleware("finalizeOptions", opts), timers = {}, injectedResponse = context.applyMiddleware("interceptRequest", void 0, {
|
|
224
|
-
adapter,
|
|
225
|
-
context
|
|
226
|
-
});
|
|
227
|
-
if (injectedResponse) {
|
|
228
|
-
const cbTimer = setTimeout(callback, 0, null, injectedResponse);
|
|
229
|
-
return { abort: () => clearTimeout(cbTimer) };
|
|
230
|
-
}
|
|
231
|
-
let xhr = new XmlHttpRequest();
|
|
232
|
-
xhr instanceof FetchXhr && typeof options.fetch == "object" && xhr.setInit(options.fetch, (_a = options.useAbortSignal) != null ? _a : !0);
|
|
233
|
-
const headers = options.headers, delays = options.timeout;
|
|
234
|
-
let aborted = !1, loaded = !1, timedOut = !1;
|
|
235
|
-
if (xhr.onerror = (event) => {
|
|
236
|
-
xhr instanceof FetchXhr ? onError(
|
|
237
|
-
event instanceof Error ? event : new Error(`Request error while attempting to reach is ${options.url}`, { cause: event })
|
|
238
|
-
) : onError(
|
|
239
|
-
new Error(
|
|
240
|
-
`Request error while attempting to reach is ${options.url}${event.lengthComputable ? `(${event.loaded} of ${event.total} bytes transferred)` : ""}`
|
|
241
|
-
)
|
|
242
|
-
);
|
|
243
|
-
}, xhr.ontimeout = (event) => {
|
|
244
|
-
onError(
|
|
245
|
-
new Error(
|
|
246
|
-
`Request timeout while attempting to reach ${options.url}${event.lengthComputable ? `(${event.loaded} of ${event.total} bytes transferred)` : ""}`
|
|
247
|
-
)
|
|
248
|
-
);
|
|
249
|
-
}, xhr.onabort = () => {
|
|
250
|
-
stopTimers(!0), aborted = !0;
|
|
251
|
-
}, xhr.onreadystatechange = () => {
|
|
252
|
-
resetTimers(), !(aborted || xhr.readyState !== 4) && xhr.status !== 0 && onLoad();
|
|
253
|
-
}, xhr.open(
|
|
254
|
-
options.method,
|
|
255
|
-
options.url,
|
|
256
|
-
!0
|
|
257
|
-
// Always async
|
|
258
|
-
), xhr.withCredentials = !!options.withCredentials, headers && xhr.setRequestHeader)
|
|
259
|
-
for (const key in headers)
|
|
260
|
-
headers.hasOwnProperty(key) && xhr.setRequestHeader(key, headers[key]);
|
|
261
|
-
return options.rawBody && (xhr.responseType = "arraybuffer"), context.applyMiddleware("onRequest", { options, adapter, request: xhr, context }), xhr.send(options.body || null), delays && (timers.connect = setTimeout(() => timeoutRequest("ETIMEDOUT"), delays.connect)), { abort };
|
|
262
|
-
function abort() {
|
|
263
|
-
aborted = !0, xhr && xhr.abort();
|
|
264
|
-
}
|
|
265
|
-
function timeoutRequest(code) {
|
|
266
|
-
timedOut = !0, xhr.abort();
|
|
267
|
-
const error = new Error(
|
|
268
|
-
code === "ESOCKETTIMEDOUT" ? `Socket timed out on request to ${options.url}` : `Connection timed out on request to ${options.url}`
|
|
269
|
-
);
|
|
270
|
-
error.code = code, context.channels.error.publish(error);
|
|
271
|
-
}
|
|
272
|
-
function resetTimers() {
|
|
273
|
-
delays && (stopTimers(), timers.socket = setTimeout(() => timeoutRequest("ESOCKETTIMEDOUT"), delays.socket));
|
|
274
|
-
}
|
|
275
|
-
function stopTimers(force) {
|
|
276
|
-
(force || aborted || xhr.readyState >= 2 && timers.connect) && clearTimeout(timers.connect), timers.socket && clearTimeout(timers.socket);
|
|
277
|
-
}
|
|
278
|
-
function onError(error) {
|
|
279
|
-
if (loaded)
|
|
280
|
-
return;
|
|
281
|
-
stopTimers(!0), loaded = !0, xhr = null;
|
|
282
|
-
const err = error || new Error(`Network error while attempting to reach ${options.url}`);
|
|
283
|
-
err.isNetworkError = !0, err.request = options, callback(err);
|
|
284
|
-
}
|
|
285
|
-
function reduceResponse() {
|
|
286
|
-
return {
|
|
287
|
-
body: xhr.response || (xhr.responseType === "" || xhr.responseType === "text" ? xhr.responseText : ""),
|
|
288
|
-
url: options.url,
|
|
289
|
-
method: options.method,
|
|
290
|
-
headers: parseHeaders$1(xhr.getAllResponseHeaders()),
|
|
291
|
-
statusCode: xhr.status,
|
|
292
|
-
statusMessage: xhr.statusText
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
function onLoad() {
|
|
296
|
-
if (!(aborted || loaded || timedOut)) {
|
|
297
|
-
if (xhr.status === 0) {
|
|
298
|
-
onError(new Error("Unknown XHR error"));
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
stopTimers(), loaded = !0, callback(null, reduceResponse());
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}, getIt = (initMiddleware = [], httpRequest = httpRequester) => createRequester(initMiddleware, httpRequest), environment = "browser";
|
|
9
|
+
const o=["request","response","progress","error","abort"],s$1=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function n(r$1,a){const i=[],u=s$1.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[r],validateOptions:[s$2]});function l(e){const t=o.reduce(((e,t)=>(e[t]=function(){const e=Object.create(null);let t=0;return {publish:function(t){for(const r in e)e[r](t);},subscribe:function(r){const o=t++;return e[o]=r,function(){delete e[o];}}}}(),e)),{}),r=(e=>function(t,r,...o){const s="onError"===t;let n=r;for(let r=0;r<e[t].length&&(n=(0, e[t][r])(n,...o),!s||n);r++);return n})(u),s=r("processOptions",e);r("validateOptions",s);const n={options:s,channels:t,applyMiddleware:r};let i;const l=t.request.subscribe((e=>{i=a(e,((o,s)=>((e,o,s)=>{let n=e,a=o;if(!n)try{a=r("onResponse",o,s);}catch(e){a=null,n=e;}n=n&&r("onError",n,s),n?t.error.publish(n):a&&t.response.publish(a);})(o,s,e)));}));t.abort.subscribe((()=>{l(),i&&i.abort();}));const c=r("onReturn",t,n);return c===t&&t.request.publish(n),c}return l.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&u.onReturn.length>0)throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");return s$1.forEach((t=>{e[t]&&u[t].push(e[t]);})),i.push(e),l},l.clone=()=>n(i,a),r$1.forEach(l.use),l}var a$1=function(e){return e.replace(/^\s+|\s+$/g,"")},i=c$3((function(e){if(!e)return {};for(var t={},r=a$1(e).split("\n"),o=0;o<r.length;o++){var s=r[o],n=s.indexOf(":"),i=a$1(s.slice(0,n)).toLowerCase(),u=a$1(s.slice(n+1));typeof t[i]>"u"?t[i]=u:(l=t[i],"[object Array]"===Object.prototype.toString.call(l)?t[i].push(u):t[i]=[t[i],u]);}var l;return t}));let u$2 = class u{onabort;onerror;onreadystatechange;ontimeout;readyState=0;response;responseText="";responseType="";status;statusText;withCredentials;#e;#t;#r;#o={};#s;#n={};#a;open(e,t,r){this.#e=e,this.#t=t,this.#r="",this.readyState=1,this.onreadystatechange?.(),this.#s=void 0;}abort(){this.#s&&this.#s.abort();}getAllResponseHeaders(){return this.#r}setRequestHeader(e,t){this.#o[e]=t;}setInit(e,t=!0){this.#n=e,this.#a=t;}send(e){const t="arraybuffer"!==this.responseType,r={...this.#n,method:this.#e,headers:this.#o,body:e};"function"==typeof AbortController&&this.#a&&(this.#s=new AbortController,typeof EventTarget<"u"&&this.#s.signal instanceof EventTarget&&(r.signal=this.#s.signal)),typeof document<"u"&&(r.credentials=this.withCredentials?"include":"omit"),fetch(this.#t,r).then((e=>(e.headers.forEach(((e,t)=>{this.#r+=`${t}: ${e}\r\n`;})),this.status=e.status,this.statusText=e.statusText,this.readyState=3,this.onreadystatechange?.(),t?e.text():e.arrayBuffer()))).then((e=>{"string"==typeof e?this.responseText=e:this.response=e,this.readyState=4,this.onreadystatechange?.();})).catch((e=>{"AbortError"!==e.name?this.onerror?.(e):this.onabort?.();}));}};const l$1="function"==typeof XMLHttpRequest?"xhr":"fetch",c$2="xhr"===l$1?XMLHttpRequest:u$2,h=(e,t)=>{const r=e.options,o=e.applyMiddleware("finalizeOptions",r),s={},n=e.applyMiddleware("interceptRequest",void 0,{adapter:l$1,context:e});if(n){const e=setTimeout(t,0,null,n);return {abort:()=>clearTimeout(e)}}let a=new c$2;a instanceof u$2&&"object"==typeof o.fetch&&a.setInit(o.fetch,o.useAbortSignal??!0);const h=o.headers,d=o.timeout;let p=!1,f=!1,b=!1;if(a.onerror=e=>{m(a instanceof u$2?e instanceof Error?e:new Error(`Request error while attempting to reach is ${o.url}`,{cause:e}):new Error(`Request error while attempting to reach is ${o.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`));},a.ontimeout=e=>{m(new Error(`Request timeout while attempting to reach ${o.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`));},a.onabort=()=>{w(!0),p=!0;},a.onreadystatechange=()=>{d&&(w(),s.socket=setTimeout((()=>y("ESOCKETTIMEDOUT")),d.socket)),!p&&4===a.readyState&&0!==a.status&&function(){if(!(p||f||b)){if(0===a.status)return void m(new Error("Unknown XHR error"));w(),f=!0,t(null,{body:a.response||(""===a.responseType||"text"===a.responseType?a.responseText:""),url:o.url,method:o.method,headers:i(a.getAllResponseHeaders()),statusCode:a.status,statusMessage:a.statusText});}}();},a.open(o.method,o.url,!0),a.withCredentials=!!o.withCredentials,h&&a.setRequestHeader)for(const e in h)h.hasOwnProperty(e)&&a.setRequestHeader(e,h[e]);return o.rawBody&&(a.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:o,adapter:l$1,request:a,context:e}),a.send(o.body||null),d&&(s.connect=setTimeout((()=>y("ETIMEDOUT")),d.connect)),{abort:function(){p=!0,a&&a.abort();}};function y(t){b=!0,a.abort();const r=new Error("ESOCKETTIMEDOUT"===t?`Socket timed out on request to ${o.url}`:`Connection timed out on request to ${o.url}`);r.code=t,e.channels.error.publish(r);}function w(e){(e||p||a.readyState>=2&&s.connect)&&clearTimeout(s.connect),s.socket&&clearTimeout(s.socket);}function m(e){if(f)return;w(!0),f=!0,a=null;const r=e||new Error(`Network error while attempting to reach ${o.url}`);r.isNetworkError=!0,r.request=o,t(r);}},d=(e=[],t=h)=>n(e,t),p$1="browser";
|
|
305
10
|
|
|
306
|
-
var
|
|
307
|
-
function requireMs() {
|
|
308
|
-
if (hasRequiredMs) return ms;
|
|
309
|
-
hasRequiredMs = 1;
|
|
310
|
-
var s = 1e3, m = s * 60, h = m * 60, d = h * 24, w = d * 7, y = d * 365.25;
|
|
311
|
-
ms = function(val, options) {
|
|
312
|
-
options = options || {};
|
|
313
|
-
var type = typeof val;
|
|
314
|
-
if (type === "string" && val.length > 0)
|
|
315
|
-
return parse(val);
|
|
316
|
-
if (type === "number" && isFinite(val))
|
|
317
|
-
return options.long ? fmtLong(val) : fmtShort(val);
|
|
318
|
-
throw new Error(
|
|
319
|
-
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
320
|
-
);
|
|
321
|
-
};
|
|
322
|
-
function parse(str) {
|
|
323
|
-
if (str = String(str), !(str.length > 100)) {
|
|
324
|
-
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
325
|
-
str
|
|
326
|
-
);
|
|
327
|
-
if (match) {
|
|
328
|
-
var n = parseFloat(match[1]), type = (match[2] || "ms").toLowerCase();
|
|
329
|
-
switch (type) {
|
|
330
|
-
case "years":
|
|
331
|
-
case "year":
|
|
332
|
-
case "yrs":
|
|
333
|
-
case "yr":
|
|
334
|
-
case "y":
|
|
335
|
-
return n * y;
|
|
336
|
-
case "weeks":
|
|
337
|
-
case "week":
|
|
338
|
-
case "w":
|
|
339
|
-
return n * w;
|
|
340
|
-
case "days":
|
|
341
|
-
case "day":
|
|
342
|
-
case "d":
|
|
343
|
-
return n * d;
|
|
344
|
-
case "hours":
|
|
345
|
-
case "hour":
|
|
346
|
-
case "hrs":
|
|
347
|
-
case "hr":
|
|
348
|
-
case "h":
|
|
349
|
-
return n * h;
|
|
350
|
-
case "minutes":
|
|
351
|
-
case "minute":
|
|
352
|
-
case "mins":
|
|
353
|
-
case "min":
|
|
354
|
-
case "m":
|
|
355
|
-
return n * m;
|
|
356
|
-
case "seconds":
|
|
357
|
-
case "second":
|
|
358
|
-
case "secs":
|
|
359
|
-
case "sec":
|
|
360
|
-
case "s":
|
|
361
|
-
return n * s;
|
|
362
|
-
case "milliseconds":
|
|
363
|
-
case "millisecond":
|
|
364
|
-
case "msecs":
|
|
365
|
-
case "msec":
|
|
366
|
-
case "ms":
|
|
367
|
-
return n;
|
|
368
|
-
default:
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
function fmtShort(ms2) {
|
|
375
|
-
var msAbs = Math.abs(ms2);
|
|
376
|
-
return msAbs >= d ? Math.round(ms2 / d) + "d" : msAbs >= h ? Math.round(ms2 / h) + "h" : msAbs >= m ? Math.round(ms2 / m) + "m" : msAbs >= s ? Math.round(ms2 / s) + "s" : ms2 + "ms";
|
|
377
|
-
}
|
|
378
|
-
function fmtLong(ms2) {
|
|
379
|
-
var msAbs = Math.abs(ms2);
|
|
380
|
-
return msAbs >= d ? plural(ms2, msAbs, d, "day") : msAbs >= h ? plural(ms2, msAbs, h, "hour") : msAbs >= m ? plural(ms2, msAbs, m, "minute") : msAbs >= s ? plural(ms2, msAbs, s, "second") : ms2 + " ms";
|
|
381
|
-
}
|
|
382
|
-
function plural(ms2, msAbs, n, name) {
|
|
383
|
-
var isPlural = msAbs >= n * 1.5;
|
|
384
|
-
return Math.round(ms2 / n) + " " + name + (isPlural ? "s" : "");
|
|
385
|
-
}
|
|
386
|
-
return ms;
|
|
387
|
-
}
|
|
388
|
-
function setup(env) {
|
|
389
|
-
createDebug.debug = createDebug, createDebug.default = createDebug, createDebug.coerce = coerce, createDebug.disable = disable, createDebug.enable = enable, createDebug.enabled = enabled, createDebug.humanize = requireMs(), createDebug.destroy = destroy, Object.keys(env).forEach((key) => {
|
|
390
|
-
createDebug[key] = env[key];
|
|
391
|
-
}), createDebug.names = [], createDebug.skips = [], createDebug.formatters = {};
|
|
392
|
-
function selectColor(namespace) {
|
|
393
|
-
let hash = 0;
|
|
394
|
-
for (let i = 0; i < namespace.length; i++)
|
|
395
|
-
hash = (hash << 5) - hash + namespace.charCodeAt(i), hash |= 0;
|
|
396
|
-
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
397
|
-
}
|
|
398
|
-
createDebug.selectColor = selectColor;
|
|
399
|
-
function createDebug(namespace) {
|
|
400
|
-
let prevTime, enableOverride = null, namespacesCache, enabledCache;
|
|
401
|
-
function debug2(...args) {
|
|
402
|
-
if (!debug2.enabled)
|
|
403
|
-
return;
|
|
404
|
-
const self2 = debug2, curr = Number(/* @__PURE__ */ new Date()), ms2 = curr - (prevTime || curr);
|
|
405
|
-
self2.diff = ms2, self2.prev = prevTime, self2.curr = curr, prevTime = curr, args[0] = createDebug.coerce(args[0]), typeof args[0] != "string" && args.unshift("%O");
|
|
406
|
-
let index = 0;
|
|
407
|
-
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
408
|
-
if (match === "%%")
|
|
409
|
-
return "%";
|
|
410
|
-
index++;
|
|
411
|
-
const formatter = createDebug.formatters[format];
|
|
412
|
-
if (typeof formatter == "function") {
|
|
413
|
-
const val = args[index];
|
|
414
|
-
match = formatter.call(self2, val), args.splice(index, 1), index--;
|
|
415
|
-
}
|
|
416
|
-
return match;
|
|
417
|
-
}), createDebug.formatArgs.call(self2, args), (self2.log || createDebug.log).apply(self2, args);
|
|
418
|
-
}
|
|
419
|
-
return debug2.namespace = namespace, debug2.useColors = createDebug.useColors(), debug2.color = createDebug.selectColor(namespace), debug2.extend = extend, debug2.destroy = createDebug.destroy, Object.defineProperty(debug2, "enabled", {
|
|
420
|
-
enumerable: !0,
|
|
421
|
-
configurable: !1,
|
|
422
|
-
get: () => enableOverride !== null ? enableOverride : (namespacesCache !== createDebug.namespaces && (namespacesCache = createDebug.namespaces, enabledCache = createDebug.enabled(namespace)), enabledCache),
|
|
423
|
-
set: (v) => {
|
|
424
|
-
enableOverride = v;
|
|
425
|
-
}
|
|
426
|
-
}), typeof createDebug.init == "function" && createDebug.init(debug2), debug2;
|
|
427
|
-
}
|
|
428
|
-
function extend(namespace, delimiter) {
|
|
429
|
-
const newDebug = createDebug(this.namespace + (typeof delimiter > "u" ? ":" : delimiter) + namespace);
|
|
430
|
-
return newDebug.log = this.log, newDebug;
|
|
431
|
-
}
|
|
432
|
-
function enable(namespaces) {
|
|
433
|
-
createDebug.save(namespaces), createDebug.namespaces = namespaces, createDebug.names = [], createDebug.skips = [];
|
|
434
|
-
let i;
|
|
435
|
-
const split = (typeof namespaces == "string" ? namespaces : "").split(/[\s,]+/), len = split.length;
|
|
436
|
-
for (i = 0; i < len; i++)
|
|
437
|
-
split[i] && (namespaces = split[i].replace(/\*/g, ".*?"), namespaces[0] === "-" ? createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$")) : createDebug.names.push(new RegExp("^" + namespaces + "$")));
|
|
438
|
-
}
|
|
439
|
-
function disable() {
|
|
440
|
-
const namespaces = [
|
|
441
|
-
...createDebug.names.map(toNamespace),
|
|
442
|
-
...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace)
|
|
443
|
-
].join(",");
|
|
444
|
-
return createDebug.enable(""), namespaces;
|
|
445
|
-
}
|
|
446
|
-
function enabled(name) {
|
|
447
|
-
if (name[name.length - 1] === "*")
|
|
448
|
-
return !0;
|
|
449
|
-
let i, len;
|
|
450
|
-
for (i = 0, len = createDebug.skips.length; i < len; i++)
|
|
451
|
-
if (createDebug.skips[i].test(name))
|
|
452
|
-
return !1;
|
|
453
|
-
for (i = 0, len = createDebug.names.length; i < len; i++)
|
|
454
|
-
if (createDebug.names[i].test(name))
|
|
455
|
-
return !0;
|
|
456
|
-
return !1;
|
|
457
|
-
}
|
|
458
|
-
function toNamespace(regexp) {
|
|
459
|
-
return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
|
|
460
|
-
}
|
|
461
|
-
function coerce(val) {
|
|
462
|
-
return val instanceof Error ? val.stack || val.message : val;
|
|
463
|
-
}
|
|
464
|
-
function destroy() {
|
|
465
|
-
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
466
|
-
}
|
|
467
|
-
return createDebug.enable(createDebug.load()), createDebug;
|
|
468
|
-
}
|
|
469
|
-
var common = setup;
|
|
470
|
-
(function(module, exports) {
|
|
471
|
-
exports.formatArgs = formatArgs, exports.save = save, exports.load = load, exports.useColors = useColors, exports.storage = localstorage(), exports.destroy = /* @__PURE__ */ (() => {
|
|
472
|
-
let warned = !1;
|
|
473
|
-
return () => {
|
|
474
|
-
warned || (warned = !0, console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."));
|
|
475
|
-
};
|
|
476
|
-
})(), exports.colors = [
|
|
477
|
-
"#0000CC",
|
|
478
|
-
"#0000FF",
|
|
479
|
-
"#0033CC",
|
|
480
|
-
"#0033FF",
|
|
481
|
-
"#0066CC",
|
|
482
|
-
"#0066FF",
|
|
483
|
-
"#0099CC",
|
|
484
|
-
"#0099FF",
|
|
485
|
-
"#00CC00",
|
|
486
|
-
"#00CC33",
|
|
487
|
-
"#00CC66",
|
|
488
|
-
"#00CC99",
|
|
489
|
-
"#00CCCC",
|
|
490
|
-
"#00CCFF",
|
|
491
|
-
"#3300CC",
|
|
492
|
-
"#3300FF",
|
|
493
|
-
"#3333CC",
|
|
494
|
-
"#3333FF",
|
|
495
|
-
"#3366CC",
|
|
496
|
-
"#3366FF",
|
|
497
|
-
"#3399CC",
|
|
498
|
-
"#3399FF",
|
|
499
|
-
"#33CC00",
|
|
500
|
-
"#33CC33",
|
|
501
|
-
"#33CC66",
|
|
502
|
-
"#33CC99",
|
|
503
|
-
"#33CCCC",
|
|
504
|
-
"#33CCFF",
|
|
505
|
-
"#6600CC",
|
|
506
|
-
"#6600FF",
|
|
507
|
-
"#6633CC",
|
|
508
|
-
"#6633FF",
|
|
509
|
-
"#66CC00",
|
|
510
|
-
"#66CC33",
|
|
511
|
-
"#9900CC",
|
|
512
|
-
"#9900FF",
|
|
513
|
-
"#9933CC",
|
|
514
|
-
"#9933FF",
|
|
515
|
-
"#99CC00",
|
|
516
|
-
"#99CC33",
|
|
517
|
-
"#CC0000",
|
|
518
|
-
"#CC0033",
|
|
519
|
-
"#CC0066",
|
|
520
|
-
"#CC0099",
|
|
521
|
-
"#CC00CC",
|
|
522
|
-
"#CC00FF",
|
|
523
|
-
"#CC3300",
|
|
524
|
-
"#CC3333",
|
|
525
|
-
"#CC3366",
|
|
526
|
-
"#CC3399",
|
|
527
|
-
"#CC33CC",
|
|
528
|
-
"#CC33FF",
|
|
529
|
-
"#CC6600",
|
|
530
|
-
"#CC6633",
|
|
531
|
-
"#CC9900",
|
|
532
|
-
"#CC9933",
|
|
533
|
-
"#CCCC00",
|
|
534
|
-
"#CCCC33",
|
|
535
|
-
"#FF0000",
|
|
536
|
-
"#FF0033",
|
|
537
|
-
"#FF0066",
|
|
538
|
-
"#FF0099",
|
|
539
|
-
"#FF00CC",
|
|
540
|
-
"#FF00FF",
|
|
541
|
-
"#FF3300",
|
|
542
|
-
"#FF3333",
|
|
543
|
-
"#FF3366",
|
|
544
|
-
"#FF3399",
|
|
545
|
-
"#FF33CC",
|
|
546
|
-
"#FF33FF",
|
|
547
|
-
"#FF6600",
|
|
548
|
-
"#FF6633",
|
|
549
|
-
"#FF9900",
|
|
550
|
-
"#FF9933",
|
|
551
|
-
"#FFCC00",
|
|
552
|
-
"#FFCC33"
|
|
553
|
-
];
|
|
554
|
-
function useColors() {
|
|
555
|
-
return typeof window < "u" && window.process && (window.process.type === "renderer" || window.process.__nwjs) ? !0 : typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/) ? !1 : typeof document < "u" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
|
556
|
-
typeof window < "u" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
|
557
|
-
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
558
|
-
typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
|
559
|
-
typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
560
|
-
}
|
|
561
|
-
function formatArgs(args) {
|
|
562
|
-
if (args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff), !this.useColors)
|
|
563
|
-
return;
|
|
564
|
-
const c = "color: " + this.color;
|
|
565
|
-
args.splice(1, 0, c, "color: inherit");
|
|
566
|
-
let index = 0, lastC = 0;
|
|
567
|
-
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
568
|
-
match !== "%%" && (index++, match === "%c" && (lastC = index));
|
|
569
|
-
}), args.splice(lastC, 0, c);
|
|
570
|
-
}
|
|
571
|
-
exports.log = console.debug || console.log || (() => {
|
|
572
|
-
});
|
|
573
|
-
function save(namespaces) {
|
|
574
|
-
try {
|
|
575
|
-
namespaces ? exports.storage.setItem("debug", namespaces) : exports.storage.removeItem("debug");
|
|
576
|
-
} catch {
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
function load() {
|
|
580
|
-
let r;
|
|
581
|
-
try {
|
|
582
|
-
r = exports.storage.getItem("debug");
|
|
583
|
-
} catch {
|
|
584
|
-
}
|
|
585
|
-
return !r && typeof process < "u" && "env" in process && (r = process.env.DEBUG), r;
|
|
586
|
-
}
|
|
587
|
-
function localstorage() {
|
|
588
|
-
try {
|
|
589
|
-
return localStorage;
|
|
590
|
-
} catch {
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
module.exports = common(exports);
|
|
594
|
-
const { formatters } = module.exports;
|
|
595
|
-
formatters.j = function(v) {
|
|
596
|
-
try {
|
|
597
|
-
return JSON.stringify(v);
|
|
598
|
-
} catch (error) {
|
|
599
|
-
return "[UnexpectedJSONParseError]: " + error.message;
|
|
600
|
-
}
|
|
601
|
-
};
|
|
602
|
-
})(browser$3, browser$3.exports);
|
|
603
|
-
const isBuffer = typeof Buffer > "u" ? () => !1 : (obj) => Buffer.isBuffer(obj);
|
|
604
|
-
/*!
|
|
605
|
-
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
606
|
-
*
|
|
607
|
-
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
608
|
-
* Released under the MIT License.
|
|
609
|
-
*/
|
|
610
|
-
function isObject(o) {
|
|
611
|
-
return Object.prototype.toString.call(o) === "[object Object]";
|
|
612
|
-
}
|
|
613
|
-
function isPlainObject$1(o) {
|
|
614
|
-
if (isObject(o) === !1) return !1;
|
|
615
|
-
const ctor = o.constructor;
|
|
616
|
-
if (ctor === void 0) return !0;
|
|
617
|
-
const prot = ctor.prototype;
|
|
618
|
-
return !(isObject(prot) === !1 || // eslint-disable-next-line no-prototype-builtins
|
|
619
|
-
prot.hasOwnProperty("isPrototypeOf") === !1);
|
|
620
|
-
}
|
|
621
|
-
const serializeTypes = ["boolean", "string", "number"];
|
|
622
|
-
function jsonRequest() {
|
|
623
|
-
return {
|
|
624
|
-
processOptions: (options) => {
|
|
625
|
-
const body = options.body;
|
|
626
|
-
return !body || !(typeof body.pipe != "function" && !isBuffer(body) && (serializeTypes.indexOf(typeof body) !== -1 || Array.isArray(body) || isPlainObject$1(body))) ? options : Object.assign({}, options, {
|
|
627
|
-
body: JSON.stringify(options.body),
|
|
628
|
-
headers: Object.assign({}, options.headers, {
|
|
629
|
-
"Content-Type": "application/json"
|
|
630
|
-
})
|
|
631
|
-
});
|
|
632
|
-
}
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
function jsonResponse(opts) {
|
|
636
|
-
return {
|
|
637
|
-
onResponse: (response) => {
|
|
638
|
-
const contentType = response.headers["content-type"] || "", shouldDecode = contentType.indexOf("application/json") !== -1;
|
|
639
|
-
return !response.body || !contentType || !shouldDecode ? response : Object.assign({}, response, { body: tryParse(response.body) });
|
|
640
|
-
},
|
|
641
|
-
processOptions: (options) => Object.assign({}, options, {
|
|
642
|
-
headers: Object.assign({ Accept: "application/json" }, options.headers)
|
|
643
|
-
})
|
|
644
|
-
};
|
|
645
|
-
function tryParse(body) {
|
|
646
|
-
try {
|
|
647
|
-
return JSON.parse(body);
|
|
648
|
-
} catch (err) {
|
|
649
|
-
throw err.message = `Failed to parsed response body as JSON: ${err.message}`, err;
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
let actualGlobal = {};
|
|
654
|
-
typeof globalThis < "u" ? actualGlobal = globalThis : typeof window < "u" ? actualGlobal = window : typeof global < "u" ? actualGlobal = global : typeof self < "u" && (actualGlobal = self);
|
|
655
|
-
var global$1 = actualGlobal;
|
|
656
|
-
function observable$1(opts = {}) {
|
|
657
|
-
const Observable = (
|
|
658
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- @TODO consider dropping checking for a global Observable since it's not on a standards track
|
|
659
|
-
opts.implementation || global$1.Observable
|
|
660
|
-
);
|
|
661
|
-
if (!Observable)
|
|
662
|
-
throw new Error(
|
|
663
|
-
"`Observable` is not available in global scope, and no implementation was passed"
|
|
664
|
-
);
|
|
665
|
-
return {
|
|
666
|
-
onReturn: (channels, context) => new Observable((observer) => (channels.error.subscribe((err) => observer.error(err)), channels.progress.subscribe(
|
|
667
|
-
(event) => observer.next(Object.assign({ type: "progress" }, event))
|
|
668
|
-
), channels.response.subscribe((response) => {
|
|
669
|
-
observer.next(Object.assign({ type: "response" }, response)), observer.complete();
|
|
670
|
-
}), channels.request.publish(context), () => channels.abort.publish()))
|
|
671
|
-
};
|
|
672
|
-
}
|
|
673
|
-
function progress() {
|
|
674
|
-
return {
|
|
675
|
-
onRequest: (evt) => {
|
|
676
|
-
if (evt.adapter !== "xhr")
|
|
677
|
-
return;
|
|
678
|
-
const xhr = evt.request, context = evt.context;
|
|
679
|
-
"upload" in xhr && "onprogress" in xhr.upload && (xhr.upload.onprogress = handleProgress("upload")), "onprogress" in xhr && (xhr.onprogress = handleProgress("download"));
|
|
680
|
-
function handleProgress(stage) {
|
|
681
|
-
return (event) => {
|
|
682
|
-
const percent = event.lengthComputable ? event.loaded / event.total * 100 : -1;
|
|
683
|
-
context.channels.progress.publish({
|
|
684
|
-
stage,
|
|
685
|
-
percent,
|
|
686
|
-
total: event.total,
|
|
687
|
-
loaded: event.loaded,
|
|
688
|
-
lengthComputable: event.lengthComputable
|
|
689
|
-
});
|
|
690
|
-
};
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
};
|
|
694
|
-
}
|
|
695
|
-
var __defProp$1$1 = Object.defineProperty, __defNormalProp$1$1 = (obj, key, value) => key in obj ? __defProp$1$1(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField$1$1 = (obj, key, value) => __defNormalProp$1$1(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
696
|
-
class Cancel {
|
|
697
|
-
constructor(message) {
|
|
698
|
-
__publicField$1$1(this, "__CANCEL__", !0), __publicField$1$1(this, "message"), this.message = message;
|
|
699
|
-
}
|
|
700
|
-
toString() {
|
|
701
|
-
return `Cancel${this.message ? `: ${this.message}` : ""}`;
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
const _CancelToken = class {
|
|
705
|
-
constructor(executor) {
|
|
706
|
-
if (__publicField$1$1(this, "promise"), __publicField$1$1(this, "reason"), typeof executor != "function")
|
|
707
|
-
throw new TypeError("executor must be a function.");
|
|
708
|
-
let resolvePromise = null;
|
|
709
|
-
this.promise = new Promise((resolve) => {
|
|
710
|
-
resolvePromise = resolve;
|
|
711
|
-
}), executor((message) => {
|
|
712
|
-
this.reason || (this.reason = new Cancel(message), resolvePromise(this.reason));
|
|
713
|
-
});
|
|
714
|
-
}
|
|
715
|
-
};
|
|
716
|
-
__publicField$1$1(_CancelToken, "source", () => {
|
|
717
|
-
let cancel;
|
|
718
|
-
return {
|
|
719
|
-
token: new _CancelToken((can) => {
|
|
720
|
-
cancel = can;
|
|
721
|
-
}),
|
|
722
|
-
cancel
|
|
723
|
-
};
|
|
724
|
-
});
|
|
725
|
-
var defaultShouldRetry = (err, _attempt, options) => options.method !== "GET" && options.method !== "HEAD" ? !1 : err.isNetworkError || !1;
|
|
726
|
-
const isStream = (stream) => stream !== null && typeof stream == "object" && typeof stream.pipe == "function";
|
|
727
|
-
var sharedRetry = (opts) => {
|
|
728
|
-
const maxRetries = opts.maxRetries || 5, retryDelay = opts.retryDelay || getRetryDelay, allowRetry = opts.shouldRetry;
|
|
729
|
-
return {
|
|
730
|
-
onError: (err, context) => {
|
|
731
|
-
const options = context.options, max = options.maxRetries || maxRetries, delay = options.retryDelay || retryDelay, shouldRetry = options.shouldRetry || allowRetry, attemptNumber = options.attemptNumber || 0;
|
|
732
|
-
if (isStream(options.body) || !shouldRetry(err, attemptNumber, options) || attemptNumber >= max)
|
|
733
|
-
return err;
|
|
734
|
-
const newContext = Object.assign({}, context, {
|
|
735
|
-
options: Object.assign({}, options, { attemptNumber: attemptNumber + 1 })
|
|
736
|
-
});
|
|
737
|
-
return setTimeout(() => context.channels.request.publish(newContext), delay(attemptNumber)), null;
|
|
738
|
-
}
|
|
739
|
-
};
|
|
740
|
-
};
|
|
741
|
-
function getRetryDelay(attemptNum) {
|
|
742
|
-
return 100 * Math.pow(2, attemptNum) + Math.random() * 100;
|
|
743
|
-
}
|
|
744
|
-
const retry = (opts = {}) => sharedRetry({ shouldRetry: defaultShouldRetry, ...opts });
|
|
745
|
-
retry.shouldRetry = defaultShouldRetry;
|
|
11
|
+
var a,c$1,u$1={exports:{}};function l(){if(c$1)return a;c$1=1;var e=1e3,t=60*e,s=60*t,n=24*s,r=7*n,o=365.25*n;function i(e,t,s,n){var r=t>=1.5*s;return Math.round(e/s)+" "+n+(r?"s":"")}return a=function(a,c){c=c||{};var u,l,p=typeof a;if("string"===p&&a.length>0)return function(i){if(!((i=String(i)).length>100)){var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(a){var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*r;case"days":case"day":case"d":return c*n;case"hours":case"hour":case"hrs":case"hr":case"h":return c*s;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}}}(a);if("number"===p&&isFinite(a))return c.long?(u=a,(l=Math.abs(u))>=n?i(u,l,n,"day"):l>=s?i(u,l,s,"hour"):l>=t?i(u,l,t,"minute"):l>=e?i(u,l,e,"second"):u+" ms"):function(r){var o=Math.abs(r);return o>=n?Math.round(r/n)+"d":o>=s?Math.round(r/s)+"h":o>=t?Math.round(r/t)+"m":o>=e?Math.round(r/e)+"s":r+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}var p=function(e){function t(e){let n,r,o,i=null;function a(...e){if(!a.enabled)return;const s=a,r=Number(new Date),o=r-(n||r);s.diff=o,s.prev=n,s.curr=r,n=r,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,r)=>{if("%%"===n)return "%";i++;const o=t.formatters[r];if("function"==typeof o){const t=e[i];n=o.call(s,t),e.splice(i,1),i--;}return n})),t.formatArgs.call(s,e),(s.log||t.log).apply(s,e);}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=s,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(r!==t.namespaces&&(r=t.namespaces,o=t.enabled(e)),o),set:e=>{i=e;}}),"function"==typeof t.init&&t.init(a),a}function s(e,s){const n=t(this.namespace+(typeof s>"u"?":":s)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let s;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),r=n.length;for(s=0;s<r;s++)n[s]&&("-"===(e=n[s].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")));},t.enabled=function(e){if("*"===e[e.length-1])return !0;let s,n;for(s=0,n=t.skips.length;s<n;s++)if(t.skips[s].test(e))return !1;for(s=0,n=t.names.length;s<n;s++)if(t.names[s].test(e))return !0;return !1},t.humanize=l(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");},Object.keys(e).forEach((s=>{t[s]=e[s];})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let s=0;for(let t=0;t<e.length;t++)s=(s<<5)-s+e.charCodeAt(t),s|=0;return t.colors[Math.abs(s)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const s="color: "+this.color;t.splice(1,0,s,"color: inherit");let n=0,r=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(r=n));})),t.splice(r,0,s);},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug");}catch{}},t.load=function(){let e;try{e=t.storage.getItem("debug");}catch{}return !e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return !(!(typeof window<"u"&&window.process)||"renderer"!==window.process.type&&!window.process.__nwjs)||!(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&(typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch{}}(),t.destroy=(()=>{let e=!1;return ()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."));}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=p(t);const{formatters:s}=e.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return "[UnexpectedJSONParseError]: "+e.message}};}(u$1,u$1.exports);c$3(u$1.exports);const w=typeof Buffer>"u"?()=>!1:e=>Buffer.isBuffer(e);function F(e){return "[object Object]"===Object.prototype.toString.call(e)}function O$1(e){if(!1===F(e))return !1;const t=e.constructor;if(void 0===t)return !0;const s=t.prototype;return !(!1===F(s)||!1===s.hasOwnProperty("isPrototypeOf"))}const j=["boolean","string","number"];function v(){return {processOptions:e=>{const t=e.body;return !t||"function"==typeof t.pipe||w(t)||-1===j.indexOf(typeof t)&&!Array.isArray(t)&&!O$1(t)?e:Object.assign({},e,{body:JSON.stringify(e.body),headers:Object.assign({},e.headers,{"Content-Type":"application/json"})})}}}function x(e){return {onResponse:s=>{const n=s.headers["content-type"]||"",r=-1!==n.indexOf("application/json");return s.body&&n&&r?Object.assign({},s,{body:t(s.body)}):s},processOptions:e=>Object.assign({},e,{headers:Object.assign({Accept:"application/json"},e.headers)})};function t(e){try{return JSON.parse(e)}catch(e){throw e.message=`Failed to parsed response body as JSON: ${e.message}`,e}}}let R={};typeof globalThis<"u"?R=globalThis:typeof window<"u"?R=window:typeof global<"u"?R=global:typeof self<"u"&&(R=self);var k=R;function q(e={}){const t=e.implementation||k.Observable;if(!t)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return {onReturn:(e,s)=>new t((t=>(e.error.subscribe((e=>t.error(e))),e.progress.subscribe((e=>t.next(Object.assign({type:"progress"},e)))),e.response.subscribe((e=>{t.next(Object.assign({type:"response"},e)),t.complete();})),e.request.publish(s),()=>e.abort.publish())))}}function A(){return {onRequest:e=>{if("xhr"!==e.adapter)return;const t=e.request,s=e.context;function n(e){return t=>{const n=t.lengthComputable?t.loaded/t.total*100:-1;s.channels.progress.publish({stage:e,percent:n,total:t.total,loaded:t.loaded,lengthComputable:t.lengthComputable});}}"upload"in t&&"onprogress"in t.upload&&(t.upload.onprogress=n("upload")),"onprogress"in t&&(t.onprogress=n("download"));}}}var I$1=(e,t,s)=>("GET"===s.method||"HEAD"===s.method)&&(e.isNetworkError||!1);function M(e){return 100*Math.pow(2,e)+100*Math.random()}const _$1=(e={})=>(e=>{const t=e.maxRetries||5,s=e.retryDelay||M,n=e.shouldRetry;return {onError:(e,r)=>{const o=r.options,i=o.maxRetries||t,a=o.retryDelay||s,c=o.shouldRetry||n,u=o.attemptNumber||0;if(null!==(l=o.body)&&"object"==typeof l&&"function"==typeof l.pipe||!c(e,u,o)||u>=i)return e;var l;const p=Object.assign({},r,{options:Object.assign({},o,{attemptNumber:u+1})});return setTimeout((()=>r.channels.request.publish(p)),a(u)),null}}})({shouldRetry:I$1,...e});_$1.shouldRetry=I$1;
|
|
746
12
|
|
|
747
13
|
/******************************************************************************
|
|
748
14
|
Copyright (c) Microsoft Corporation.
|
|
@@ -859,8 +125,9 @@
|
|
|
859
125
|
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
860
126
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
861
127
|
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
862
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
863
|
-
function
|
|
128
|
+
return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
129
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
130
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
864
131
|
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
865
132
|
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
866
133
|
function fulfill(value) { resume("next", value); }
|
|
@@ -1778,8 +1045,7 @@
|
|
|
1778
1045
|
let e = JSON.stringify(t);
|
|
1779
1046
|
return `${u}${Array.from(e).map((r) => {
|
|
1780
1047
|
let n = r.charCodeAt(0);
|
|
1781
|
-
if (n > 255)
|
|
1782
|
-
throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${e} on character ${r} (${n})`);
|
|
1048
|
+
if (n > 255) throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${e} on character ${r} (${n})`);
|
|
1783
1049
|
return Array.from(n.toString(4).padStart(4, "0")).map((o) => String.fromCodePoint(c[o])).join("");
|
|
1784
1050
|
}).join("")}`;
|
|
1785
1051
|
}
|
|
@@ -1811,17 +1077,24 @@
|
|
|
1811
1077
|
return O(result);
|
|
1812
1078
|
}
|
|
1813
1079
|
|
|
1814
|
-
var __defProp$3 = Object.defineProperty, __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField$3 = (obj, key, value) => (__defNormalProp$3(obj, typeof key != "symbol" ? key + "" : key, value), value);
|
|
1815
1080
|
class ClientError extends Error {
|
|
1081
|
+
response;
|
|
1082
|
+
statusCode = 400;
|
|
1083
|
+
responseBody;
|
|
1084
|
+
details;
|
|
1816
1085
|
constructor(res) {
|
|
1817
1086
|
const props = extractErrorProps(res);
|
|
1818
|
-
super(props.message),
|
|
1087
|
+
super(props.message), Object.assign(this, props);
|
|
1819
1088
|
}
|
|
1820
1089
|
}
|
|
1821
1090
|
class ServerError extends Error {
|
|
1091
|
+
response;
|
|
1092
|
+
statusCode = 500;
|
|
1093
|
+
responseBody;
|
|
1094
|
+
details;
|
|
1822
1095
|
constructor(res) {
|
|
1823
1096
|
const props = extractErrorProps(res);
|
|
1824
|
-
super(props.message),
|
|
1097
|
+
super(props.message), Object.assign(this, props);
|
|
1825
1098
|
}
|
|
1826
1099
|
}
|
|
1827
1100
|
function extractErrorProps(res) {
|
|
@@ -1835,10 +1108,7 @@
|
|
|
1835
1108
|
if (body.error && body.message)
|
|
1836
1109
|
return props.message = `${body.error} - ${body.message}`, props;
|
|
1837
1110
|
if (isMutationError(body) || isActionError(body)) {
|
|
1838
|
-
const allItems = body.error.items || [], items = allItems.slice(0, 5).map((item) =>
|
|
1839
|
-
var _a;
|
|
1840
|
-
return (_a = item.error) == null ? void 0 : _a.description;
|
|
1841
|
-
}).filter(Boolean);
|
|
1111
|
+
const allItems = body.error.items || [], items = allItems.slice(0, 5).map((item) => item.error?.description).filter(Boolean);
|
|
1842
1112
|
let itemsStr = items.length ? `:
|
|
1843
1113
|
- ${items.join(`
|
|
1844
1114
|
- `)}` : "";
|
|
@@ -1878,22 +1148,21 @@
|
|
|
1878
1148
|
}
|
|
1879
1149
|
};
|
|
1880
1150
|
function defineHttpRequest(envMiddleware2) {
|
|
1881
|
-
return
|
|
1882
|
-
|
|
1151
|
+
return d([
|
|
1152
|
+
_$1({ shouldRetry }),
|
|
1883
1153
|
...envMiddleware2,
|
|
1884
1154
|
printWarnings,
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1155
|
+
v(),
|
|
1156
|
+
x(),
|
|
1157
|
+
A(),
|
|
1888
1158
|
httpError,
|
|
1889
|
-
|
|
1159
|
+
q({ implementation: Observable })
|
|
1890
1160
|
]);
|
|
1891
1161
|
}
|
|
1892
1162
|
function shouldRetry(err, attempt, options) {
|
|
1893
|
-
if (options.maxRetries === 0)
|
|
1894
|
-
return !1;
|
|
1163
|
+
if (options.maxRetries === 0) return !1;
|
|
1895
1164
|
const isSafe = options.method === "GET" || options.method === "HEAD", isQuery = (options.uri || options.url).startsWith("/data/query"), isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503);
|
|
1896
|
-
return (isSafe || isQuery) && isRetriableResponse ? !0 :
|
|
1165
|
+
return (isSafe || isQuery) && isRetriableResponse ? !0 : _$1.shouldRetry(err, attempt, options);
|
|
1897
1166
|
}
|
|
1898
1167
|
function getSelection(sel) {
|
|
1899
1168
|
if (typeof sel == "string")
|
|
@@ -1954,17 +1223,11 @@ ${selectionOpts}`);
|
|
|
1954
1223
|
);
|
|
1955
1224
|
return tag;
|
|
1956
1225
|
};
|
|
1957
|
-
var __defProp$2 = Object.defineProperty, __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField$2 = (obj, key, value) => (__defNormalProp$2(obj, typeof key != "symbol" ? key + "" : key, value), value), __accessCheck$7 = (obj, member, msg) => {
|
|
1958
|
-
if (!member.has(obj))
|
|
1959
|
-
throw TypeError("Cannot " + msg);
|
|
1960
|
-
}, __privateGet$7 = (obj, member, getter) => (__accessCheck$7(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$7 = (obj, member, value) => {
|
|
1961
|
-
if (member.has(obj))
|
|
1962
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
1963
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1964
|
-
}, __privateSet$7 = (obj, member, value, setter) => (__accessCheck$7(obj, member, "write to private field"), member.set(obj, value), value);
|
|
1965
1226
|
class BasePatch {
|
|
1227
|
+
selection;
|
|
1228
|
+
operations;
|
|
1966
1229
|
constructor(selection, operations = {}) {
|
|
1967
|
-
|
|
1230
|
+
this.selection = selection, this.operations = operations;
|
|
1968
1231
|
}
|
|
1969
1232
|
/**
|
|
1970
1233
|
* Sets the given attributes to the document. Does NOT merge objects.
|
|
@@ -2095,62 +1358,52 @@ ${selectionOpts}`);
|
|
|
2095
1358
|
return this._assign(op, props, !1);
|
|
2096
1359
|
}
|
|
2097
1360
|
}
|
|
2098
|
-
|
|
2099
|
-
|
|
1361
|
+
class ObservablePatch extends BasePatch {
|
|
1362
|
+
#client;
|
|
2100
1363
|
constructor(selection, operations, client) {
|
|
2101
|
-
super(selection, operations),
|
|
1364
|
+
super(selection, operations), this.#client = client;
|
|
2102
1365
|
}
|
|
2103
1366
|
/**
|
|
2104
1367
|
* Clones the patch
|
|
2105
1368
|
*/
|
|
2106
1369
|
clone() {
|
|
2107
|
-
return new
|
|
1370
|
+
return new ObservablePatch(this.selection, { ...this.operations }, this.#client);
|
|
2108
1371
|
}
|
|
2109
1372
|
commit(options) {
|
|
2110
|
-
if (!
|
|
1373
|
+
if (!this.#client)
|
|
2111
1374
|
throw new Error(
|
|
2112
1375
|
"No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
|
|
2113
1376
|
);
|
|
2114
1377
|
const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
|
|
2115
|
-
return
|
|
1378
|
+
return this.#client.mutate({ patch: this.serialize() }, opts);
|
|
2116
1379
|
}
|
|
2117
|
-
}
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
var _client2$5;
|
|
2121
|
-
const _Patch = class _Patch2 extends BasePatch {
|
|
1380
|
+
}
|
|
1381
|
+
class Patch extends BasePatch {
|
|
1382
|
+
#client;
|
|
2122
1383
|
constructor(selection, operations, client) {
|
|
2123
|
-
super(selection, operations),
|
|
1384
|
+
super(selection, operations), this.#client = client;
|
|
2124
1385
|
}
|
|
2125
1386
|
/**
|
|
2126
1387
|
* Clones the patch
|
|
2127
1388
|
*/
|
|
2128
1389
|
clone() {
|
|
2129
|
-
return new
|
|
1390
|
+
return new Patch(this.selection, { ...this.operations }, this.#client);
|
|
2130
1391
|
}
|
|
2131
1392
|
commit(options) {
|
|
2132
|
-
if (!
|
|
1393
|
+
if (!this.#client)
|
|
2133
1394
|
throw new Error(
|
|
2134
1395
|
"No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
|
|
2135
1396
|
);
|
|
2136
1397
|
const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
|
|
2137
|
-
return
|
|
1398
|
+
return this.#client.mutate({ patch: this.serialize() }, opts);
|
|
2138
1399
|
}
|
|
2139
|
-
}
|
|
2140
|
-
_client2$5 = /* @__PURE__ */ new WeakMap();
|
|
2141
|
-
let Patch = _Patch;
|
|
2142
|
-
var __defProp$1 = Object.defineProperty, __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField$1 = (obj, key, value) => (__defNormalProp$1(obj, typeof key != "symbol" ? key + "" : key, value), value), __accessCheck$6 = (obj, member, msg) => {
|
|
2143
|
-
if (!member.has(obj))
|
|
2144
|
-
throw TypeError("Cannot " + msg);
|
|
2145
|
-
}, __privateGet$6 = (obj, member, getter) => (__accessCheck$6(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$6 = (obj, member, value) => {
|
|
2146
|
-
if (member.has(obj))
|
|
2147
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
2148
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
2149
|
-
}, __privateSet$6 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), member.set(obj, value), value);
|
|
1400
|
+
}
|
|
2150
1401
|
const defaultMutateOptions = { returnDocuments: !1 };
|
|
2151
1402
|
class BaseTransaction {
|
|
1403
|
+
operations;
|
|
1404
|
+
trxId;
|
|
2152
1405
|
constructor(operations = [], transactionId) {
|
|
2153
|
-
|
|
1406
|
+
this.operations = operations, this.trxId = transactionId;
|
|
2154
1407
|
}
|
|
2155
1408
|
/**
|
|
2156
1409
|
* Creates a new Sanity document. If `_id` is provided and already exists, the mutation will fail. If no `_id` is given, one will automatically be generated by the database.
|
|
@@ -2215,23 +1468,23 @@ ${selectionOpts}`);
|
|
|
2215
1468
|
return this.operations.push(mut), this;
|
|
2216
1469
|
}
|
|
2217
1470
|
}
|
|
2218
|
-
|
|
2219
|
-
|
|
1471
|
+
class Transaction extends BaseTransaction {
|
|
1472
|
+
#client;
|
|
2220
1473
|
constructor(operations, client, transactionId) {
|
|
2221
|
-
super(operations, transactionId),
|
|
1474
|
+
super(operations, transactionId), this.#client = client;
|
|
2222
1475
|
}
|
|
2223
1476
|
/**
|
|
2224
1477
|
* Clones the transaction
|
|
2225
1478
|
*/
|
|
2226
1479
|
clone() {
|
|
2227
|
-
return new
|
|
1480
|
+
return new Transaction([...this.operations], this.#client, this.trxId);
|
|
2228
1481
|
}
|
|
2229
1482
|
commit(options) {
|
|
2230
|
-
if (!
|
|
1483
|
+
if (!this.#client)
|
|
2231
1484
|
throw new Error(
|
|
2232
1485
|
"No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
|
|
2233
1486
|
);
|
|
2234
|
-
return
|
|
1487
|
+
return this.#client.mutate(
|
|
2235
1488
|
this.serialize(),
|
|
2236
1489
|
Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
|
|
2237
1490
|
);
|
|
@@ -2241,33 +1494,31 @@ ${selectionOpts}`);
|
|
|
2241
1494
|
if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof Patch)
|
|
2242
1495
|
return this._add({ patch: patchOrDocumentId.serialize() });
|
|
2243
1496
|
if (isBuilder) {
|
|
2244
|
-
const patch = patchOps(new Patch(patchOrDocumentId, {},
|
|
1497
|
+
const patch = patchOps(new Patch(patchOrDocumentId, {}, this.#client));
|
|
2245
1498
|
if (!(patch instanceof Patch))
|
|
2246
1499
|
throw new Error("function passed to `patch()` must return the patch");
|
|
2247
1500
|
return this._add({ patch: patch.serialize() });
|
|
2248
1501
|
}
|
|
2249
1502
|
return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
|
|
2250
1503
|
}
|
|
2251
|
-
}
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
var _client2$4;
|
|
2255
|
-
const _ObservableTransaction = class _ObservableTransaction2 extends BaseTransaction {
|
|
1504
|
+
}
|
|
1505
|
+
class ObservableTransaction extends BaseTransaction {
|
|
1506
|
+
#client;
|
|
2256
1507
|
constructor(operations, client, transactionId) {
|
|
2257
|
-
super(operations, transactionId),
|
|
1508
|
+
super(operations, transactionId), this.#client = client;
|
|
2258
1509
|
}
|
|
2259
1510
|
/**
|
|
2260
1511
|
* Clones the transaction
|
|
2261
1512
|
*/
|
|
2262
1513
|
clone() {
|
|
2263
|
-
return new
|
|
1514
|
+
return new ObservableTransaction([...this.operations], this.#client, this.trxId);
|
|
2264
1515
|
}
|
|
2265
1516
|
commit(options) {
|
|
2266
|
-
if (!
|
|
1517
|
+
if (!this.#client)
|
|
2267
1518
|
throw new Error(
|
|
2268
1519
|
"No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
|
|
2269
1520
|
);
|
|
2270
|
-
return
|
|
1521
|
+
return this.#client.mutate(
|
|
2271
1522
|
this.serialize(),
|
|
2272
1523
|
Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
|
|
2273
1524
|
);
|
|
@@ -2277,16 +1528,14 @@ ${selectionOpts}`);
|
|
|
2277
1528
|
if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof ObservablePatch)
|
|
2278
1529
|
return this._add({ patch: patchOrDocumentId.serialize() });
|
|
2279
1530
|
if (isBuilder) {
|
|
2280
|
-
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {},
|
|
1531
|
+
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, this.#client));
|
|
2281
1532
|
if (!(patch instanceof ObservablePatch))
|
|
2282
1533
|
throw new Error("function passed to `patch()` must return the patch");
|
|
2283
1534
|
return this._add({ patch: patch.serialize() });
|
|
2284
1535
|
}
|
|
2285
1536
|
return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
|
|
2286
1537
|
}
|
|
2287
|
-
}
|
|
2288
|
-
_client2$4 = /* @__PURE__ */ new WeakMap();
|
|
2289
|
-
let ObservableTransaction = _ObservableTransaction;
|
|
1538
|
+
}
|
|
2290
1539
|
const BASE_URL = "https://www.sanity.io/help/";
|
|
2291
1540
|
function generateHelpUrl(slug) {
|
|
2292
1541
|
return BASE_URL + slug;
|
|
@@ -2450,14 +1699,24 @@ ${selectionOpts}`);
|
|
|
2450
1699
|
) : $request.pipe(map(mapResponse));
|
|
2451
1700
|
}
|
|
2452
1701
|
function _getDocument(client, httpRequest, id, opts = {}) {
|
|
2453
|
-
const options = {
|
|
1702
|
+
const options = {
|
|
1703
|
+
uri: _getDataUrl(client, "doc", id),
|
|
1704
|
+
json: !0,
|
|
1705
|
+
tag: opts.tag,
|
|
1706
|
+
signal: opts.signal
|
|
1707
|
+
};
|
|
2454
1708
|
return _requestObservable(client, httpRequest, options).pipe(
|
|
2455
1709
|
filter(isResponse),
|
|
2456
1710
|
map((event) => event.body.documents && event.body.documents[0])
|
|
2457
1711
|
);
|
|
2458
1712
|
}
|
|
2459
1713
|
function _getDocuments(client, httpRequest, ids, opts = {}) {
|
|
2460
|
-
const options = {
|
|
1714
|
+
const options = {
|
|
1715
|
+
uri: _getDataUrl(client, "doc", ids.join(",")),
|
|
1716
|
+
json: !0,
|
|
1717
|
+
tag: opts.tag,
|
|
1718
|
+
signal: opts.signal
|
|
1719
|
+
};
|
|
2461
1720
|
return _requestObservable(client, httpRequest, options).pipe(
|
|
2462
1721
|
filter(isResponse),
|
|
2463
1722
|
map((event) => {
|
|
@@ -2510,6 +1769,7 @@ ${selectionOpts}`);
|
|
|
2510
1769
|
tag,
|
|
2511
1770
|
returnQuery,
|
|
2512
1771
|
perspective: options.perspective,
|
|
1772
|
+
bundlePerspective: options.bundlePerspective,
|
|
2513
1773
|
resultSourceMap: options.resultSourceMap,
|
|
2514
1774
|
lastLiveEventId: Array.isArray(lastLiveEventId) ? lastLiveEventId[0] : lastLiveEventId,
|
|
2515
1775
|
canUseCdn: isQuery,
|
|
@@ -2541,15 +1801,14 @@ ${selectionOpts}`);
|
|
|
2541
1801
|
return _dataRequest(client, httpRequest, "mutate", { mutations: [mutation] }, opts);
|
|
2542
1802
|
}
|
|
2543
1803
|
function _requestObservable(client, httpRequest, options) {
|
|
2544
|
-
var _a, _b;
|
|
2545
1804
|
const uri = options.url || options.uri, config = client.config(), canUseCdn = typeof options.canUseCdn > "u" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/") === 0 : options.canUseCdn;
|
|
2546
|
-
let useCdn = (
|
|
1805
|
+
let useCdn = (options.useCdn ?? config.useCdn) && canUseCdn;
|
|
2547
1806
|
const tag = options.tag && config.requestTagPrefix ? [config.requestTagPrefix, options.tag].join(".") : options.tag || config.requestTagPrefix;
|
|
2548
1807
|
if (tag && options.tag !== null && (options.query = { tag: requestTag(tag), ...options.query }), ["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
|
|
2549
|
-
const resultSourceMap =
|
|
1808
|
+
const resultSourceMap = options.resultSourceMap ?? config.resultSourceMap;
|
|
2550
1809
|
resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
|
|
2551
|
-
const perspective = options.perspective || config.perspective;
|
|
2552
|
-
typeof perspective == "string" && perspective !== "raw" && (validateApiPerspective(perspective), options.query = { perspective, ...options.query }, perspective === "previewDrafts" && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning())), options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query });
|
|
1810
|
+
const perspective = options.perspective || config.perspective, bundlePerspective = options.bundlePerspective || config.bundlePerspective;
|
|
1811
|
+
typeof perspective == "string" && perspective !== "raw" && (validateApiPerspective(perspective), options.query = { perspective, ...options.query }, perspective === "previewDrafts" && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning())), typeof bundlePerspective == "string" && (options.query = { perspective: void 0, bundlePerspective, ...options.query }), options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query });
|
|
2553
1812
|
}
|
|
2554
1813
|
const reqOptions = requestOptions(
|
|
2555
1814
|
config,
|
|
@@ -2590,36 +1849,29 @@ ${selectionOpts}`);
|
|
|
2590
1849
|
}
|
|
2591
1850
|
const isDomExceptionSupported = !!globalThis.DOMException;
|
|
2592
1851
|
function _createAbortError(signal) {
|
|
2593
|
-
var _a, _b;
|
|
2594
1852
|
if (isDomExceptionSupported)
|
|
2595
|
-
return new DOMException(
|
|
2596
|
-
const error = new Error(
|
|
1853
|
+
return new DOMException(signal?.reason ?? "The operation was aborted.", "AbortError");
|
|
1854
|
+
const error = new Error(signal?.reason ?? "The operation was aborted.");
|
|
2597
1855
|
return error.name = "AbortError", error;
|
|
2598
1856
|
}
|
|
2599
|
-
var __accessCheck$5 = (obj, member, msg) => {
|
|
2600
|
-
if (!member.has(obj))
|
|
2601
|
-
throw TypeError("Cannot " + msg);
|
|
2602
|
-
}, __privateGet$5 = (obj, member, getter) => (__accessCheck$5(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$5 = (obj, member, value) => {
|
|
2603
|
-
if (member.has(obj))
|
|
2604
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
2605
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
2606
|
-
}, __privateSet$5 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value), _client$4, _httpRequest$4;
|
|
2607
1857
|
class ObservableAssetsClient {
|
|
1858
|
+
#client;
|
|
1859
|
+
#httpRequest;
|
|
2608
1860
|
constructor(client, httpRequest) {
|
|
2609
|
-
|
|
1861
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
2610
1862
|
}
|
|
2611
1863
|
upload(assetType, body, options) {
|
|
2612
|
-
return _upload(
|
|
1864
|
+
return _upload(this.#client, this.#httpRequest, assetType, body, options);
|
|
2613
1865
|
}
|
|
2614
1866
|
}
|
|
2615
|
-
_client$4 = /* @__PURE__ */ new WeakMap(), _httpRequest$4 = /* @__PURE__ */ new WeakMap();
|
|
2616
|
-
var _client2$3, _httpRequest2$4;
|
|
2617
1867
|
class AssetsClient {
|
|
1868
|
+
#client;
|
|
1869
|
+
#httpRequest;
|
|
2618
1870
|
constructor(client, httpRequest) {
|
|
2619
|
-
|
|
1871
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
2620
1872
|
}
|
|
2621
1873
|
upload(assetType, body, options) {
|
|
2622
|
-
const observable2 = _upload(
|
|
1874
|
+
const observable2 = _upload(this.#client, this.#httpRequest, assetType, body, options);
|
|
2623
1875
|
return lastValueFrom(
|
|
2624
1876
|
observable2.pipe(
|
|
2625
1877
|
filter((event) => event.type === "response"),
|
|
@@ -2630,7 +1882,6 @@ ${selectionOpts}`);
|
|
|
2630
1882
|
);
|
|
2631
1883
|
}
|
|
2632
1884
|
}
|
|
2633
|
-
_client2$3 = /* @__PURE__ */ new WeakMap(), _httpRequest2$4 = /* @__PURE__ */ new WeakMap();
|
|
2634
1885
|
function _upload(client, httpRequest, assetType, body, opts = {}) {
|
|
2635
1886
|
validateAssetType(assetType);
|
|
2636
1887
|
let meta = opts.extract || void 0;
|
|
@@ -2739,30 +1990,22 @@ ${selectionOpts}`);
|
|
|
2739
1990
|
function extractErrorMessage(err) {
|
|
2740
1991
|
return err.error ? err.error.description ? err.error.description : typeof err.error == "string" ? err.error : JSON.stringify(err.error, null, 2) : err.message || "Unknown listener error";
|
|
2741
1992
|
}
|
|
2742
|
-
var __accessCheck$4 = (obj, member, msg) => {
|
|
2743
|
-
if (!member.has(obj))
|
|
2744
|
-
throw TypeError("Cannot " + msg);
|
|
2745
|
-
}, __privateGet$4 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$4 = (obj, member, value) => {
|
|
2746
|
-
if (member.has(obj))
|
|
2747
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
2748
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
2749
|
-
}, __privateSet$4 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
|
|
2750
1993
|
const requiredApiVersion = "2021-03-26";
|
|
2751
|
-
var _client$3;
|
|
2752
1994
|
class LiveClient {
|
|
1995
|
+
#client;
|
|
2753
1996
|
constructor(client) {
|
|
2754
|
-
|
|
1997
|
+
this.#client = client;
|
|
2755
1998
|
}
|
|
2756
1999
|
/**
|
|
2757
2000
|
* Requires `apiVersion` to be `2021-03-26` or later.
|
|
2758
2001
|
*/
|
|
2759
2002
|
events() {
|
|
2760
|
-
const apiVersion =
|
|
2003
|
+
const apiVersion = this.#client.config().apiVersion.replace(/^v/, "");
|
|
2761
2004
|
if (apiVersion !== "X" && apiVersion < requiredApiVersion)
|
|
2762
2005
|
throw new Error(
|
|
2763
2006
|
`The live events API requires API version ${requiredApiVersion} or later. The current API version is ${apiVersion}. Please update your API version to use this feature.`
|
|
2764
2007
|
);
|
|
2765
|
-
const path = _getDataUrl(
|
|
2008
|
+
const path = _getDataUrl(this.#client, "live/events"), url = new URL(this.#client.getUrl(path, !1)), listenFor = ["restart", "message"];
|
|
2766
2009
|
return new Observable((observer) => {
|
|
2767
2010
|
let es, reconnectTimer, stopped = !1, unsubscribed = !1;
|
|
2768
2011
|
open();
|
|
@@ -2811,7 +2054,6 @@ ${selectionOpts}`);
|
|
|
2811
2054
|
});
|
|
2812
2055
|
}
|
|
2813
2056
|
}
|
|
2814
|
-
_client$3 = /* @__PURE__ */ new WeakMap();
|
|
2815
2057
|
function parseEvent(event) {
|
|
2816
2058
|
try {
|
|
2817
2059
|
const data = event.data && JSON.parse(event.data) || {};
|
|
@@ -2820,17 +2062,11 @@ ${selectionOpts}`);
|
|
|
2820
2062
|
return err;
|
|
2821
2063
|
}
|
|
2822
2064
|
}
|
|
2823
|
-
var __accessCheck$3 = (obj, member, msg) => {
|
|
2824
|
-
if (!member.has(obj))
|
|
2825
|
-
throw TypeError("Cannot " + msg);
|
|
2826
|
-
}, __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$3 = (obj, member, value) => {
|
|
2827
|
-
if (member.has(obj))
|
|
2828
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
2829
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
2830
|
-
}, __privateSet$3 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value), _client$2, _httpRequest$3;
|
|
2831
2065
|
class ObservableDatasetsClient {
|
|
2066
|
+
#client;
|
|
2067
|
+
#httpRequest;
|
|
2832
2068
|
constructor(client, httpRequest) {
|
|
2833
|
-
|
|
2069
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
2834
2070
|
}
|
|
2835
2071
|
/**
|
|
2836
2072
|
* Create a new dataset with the given name
|
|
@@ -2839,7 +2075,7 @@ ${selectionOpts}`);
|
|
|
2839
2075
|
* @param options - Options for the dataset
|
|
2840
2076
|
*/
|
|
2841
2077
|
create(name, options) {
|
|
2842
|
-
return _modify(
|
|
2078
|
+
return _modify(this.#client, this.#httpRequest, "PUT", name, options);
|
|
2843
2079
|
}
|
|
2844
2080
|
/**
|
|
2845
2081
|
* Edit a dataset with the given name
|
|
@@ -2848,7 +2084,7 @@ ${selectionOpts}`);
|
|
|
2848
2084
|
* @param options - New options for the dataset
|
|
2849
2085
|
*/
|
|
2850
2086
|
edit(name, options) {
|
|
2851
|
-
return _modify(
|
|
2087
|
+
return _modify(this.#client, this.#httpRequest, "PATCH", name, options);
|
|
2852
2088
|
}
|
|
2853
2089
|
/**
|
|
2854
2090
|
* Delete a dataset with the given name
|
|
@@ -2856,23 +2092,23 @@ ${selectionOpts}`);
|
|
|
2856
2092
|
* @param name - Name of the dataset to delete
|
|
2857
2093
|
*/
|
|
2858
2094
|
delete(name) {
|
|
2859
|
-
return _modify(
|
|
2095
|
+
return _modify(this.#client, this.#httpRequest, "DELETE", name);
|
|
2860
2096
|
}
|
|
2861
2097
|
/**
|
|
2862
2098
|
* Fetch a list of datasets for the configured project
|
|
2863
2099
|
*/
|
|
2864
2100
|
list() {
|
|
2865
|
-
return _request(
|
|
2101
|
+
return _request(this.#client, this.#httpRequest, {
|
|
2866
2102
|
uri: "/datasets",
|
|
2867
2103
|
tag: null
|
|
2868
2104
|
});
|
|
2869
2105
|
}
|
|
2870
2106
|
}
|
|
2871
|
-
_client$2 = /* @__PURE__ */ new WeakMap(), _httpRequest$3 = /* @__PURE__ */ new WeakMap();
|
|
2872
|
-
var _client2$2, _httpRequest2$3;
|
|
2873
2107
|
class DatasetsClient {
|
|
2108
|
+
#client;
|
|
2109
|
+
#httpRequest;
|
|
2874
2110
|
constructor(client, httpRequest) {
|
|
2875
|
-
|
|
2111
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
2876
2112
|
}
|
|
2877
2113
|
/**
|
|
2878
2114
|
* Create a new dataset with the given name
|
|
@@ -2882,7 +2118,7 @@ ${selectionOpts}`);
|
|
|
2882
2118
|
*/
|
|
2883
2119
|
create(name, options) {
|
|
2884
2120
|
return lastValueFrom(
|
|
2885
|
-
_modify(
|
|
2121
|
+
_modify(this.#client, this.#httpRequest, "PUT", name, options)
|
|
2886
2122
|
);
|
|
2887
2123
|
}
|
|
2888
2124
|
/**
|
|
@@ -2893,7 +2129,7 @@ ${selectionOpts}`);
|
|
|
2893
2129
|
*/
|
|
2894
2130
|
edit(name, options) {
|
|
2895
2131
|
return lastValueFrom(
|
|
2896
|
-
_modify(
|
|
2132
|
+
_modify(this.#client, this.#httpRequest, "PATCH", name, options)
|
|
2897
2133
|
);
|
|
2898
2134
|
}
|
|
2899
2135
|
/**
|
|
@@ -2902,18 +2138,17 @@ ${selectionOpts}`);
|
|
|
2902
2138
|
* @param name - Name of the dataset to delete
|
|
2903
2139
|
*/
|
|
2904
2140
|
delete(name) {
|
|
2905
|
-
return lastValueFrom(_modify(
|
|
2141
|
+
return lastValueFrom(_modify(this.#client, this.#httpRequest, "DELETE", name));
|
|
2906
2142
|
}
|
|
2907
2143
|
/**
|
|
2908
2144
|
* Fetch a list of datasets for the configured project
|
|
2909
2145
|
*/
|
|
2910
2146
|
list() {
|
|
2911
2147
|
return lastValueFrom(
|
|
2912
|
-
_request(
|
|
2148
|
+
_request(this.#client, this.#httpRequest, { uri: "/datasets", tag: null })
|
|
2913
2149
|
);
|
|
2914
2150
|
}
|
|
2915
2151
|
}
|
|
2916
|
-
_client2$2 = /* @__PURE__ */ new WeakMap(), _httpRequest2$3 = /* @__PURE__ */ new WeakMap();
|
|
2917
2152
|
function _modify(client, httpRequest, method, name, options) {
|
|
2918
2153
|
return dataset(name), _request(client, httpRequest, {
|
|
2919
2154
|
method,
|
|
@@ -2922,21 +2157,15 @@ ${selectionOpts}`);
|
|
|
2922
2157
|
tag: null
|
|
2923
2158
|
});
|
|
2924
2159
|
}
|
|
2925
|
-
var __accessCheck$2 = (obj, member, msg) => {
|
|
2926
|
-
if (!member.has(obj))
|
|
2927
|
-
throw TypeError("Cannot " + msg);
|
|
2928
|
-
}, __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$2 = (obj, member, value) => {
|
|
2929
|
-
if (member.has(obj))
|
|
2930
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
2931
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
2932
|
-
}, __privateSet$2 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), member.set(obj, value), value), _client$1, _httpRequest$2;
|
|
2933
2160
|
class ObservableProjectsClient {
|
|
2161
|
+
#client;
|
|
2162
|
+
#httpRequest;
|
|
2934
2163
|
constructor(client, httpRequest) {
|
|
2935
|
-
|
|
2164
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
2936
2165
|
}
|
|
2937
2166
|
list(options) {
|
|
2938
|
-
const uri =
|
|
2939
|
-
return _request(
|
|
2167
|
+
const uri = options?.includeMembers === !1 ? "/projects?includeMembers=false" : "/projects";
|
|
2168
|
+
return _request(this.#client, this.#httpRequest, { uri });
|
|
2940
2169
|
}
|
|
2941
2170
|
/**
|
|
2942
2171
|
* Fetch a project by project ID
|
|
@@ -2944,18 +2173,18 @@ ${selectionOpts}`);
|
|
|
2944
2173
|
* @param projectId - ID of the project to fetch
|
|
2945
2174
|
*/
|
|
2946
2175
|
getById(projectId2) {
|
|
2947
|
-
return _request(
|
|
2176
|
+
return _request(this.#client, this.#httpRequest, { uri: `/projects/${projectId2}` });
|
|
2948
2177
|
}
|
|
2949
2178
|
}
|
|
2950
|
-
_client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */ new WeakMap();
|
|
2951
|
-
var _client2$1, _httpRequest2$2;
|
|
2952
2179
|
class ProjectsClient {
|
|
2180
|
+
#client;
|
|
2181
|
+
#httpRequest;
|
|
2953
2182
|
constructor(client, httpRequest) {
|
|
2954
|
-
|
|
2183
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
2955
2184
|
}
|
|
2956
2185
|
list(options) {
|
|
2957
|
-
const uri =
|
|
2958
|
-
return lastValueFrom(_request(
|
|
2186
|
+
const uri = options?.includeMembers === !1 ? "/projects?includeMembers=false" : "/projects";
|
|
2187
|
+
return lastValueFrom(_request(this.#client, this.#httpRequest, { uri }));
|
|
2959
2188
|
}
|
|
2960
2189
|
/**
|
|
2961
2190
|
* Fetch a project by project ID
|
|
@@ -2964,22 +2193,15 @@ ${selectionOpts}`);
|
|
|
2964
2193
|
*/
|
|
2965
2194
|
getById(projectId2) {
|
|
2966
2195
|
return lastValueFrom(
|
|
2967
|
-
_request(
|
|
2196
|
+
_request(this.#client, this.#httpRequest, { uri: `/projects/${projectId2}` })
|
|
2968
2197
|
);
|
|
2969
2198
|
}
|
|
2970
2199
|
}
|
|
2971
|
-
_client2$1 = /* @__PURE__ */ new WeakMap(), _httpRequest2$2 = /* @__PURE__ */ new WeakMap();
|
|
2972
|
-
var __accessCheck$1 = (obj, member, msg) => {
|
|
2973
|
-
if (!member.has(obj))
|
|
2974
|
-
throw TypeError("Cannot " + msg);
|
|
2975
|
-
}, __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$1 = (obj, member, value) => {
|
|
2976
|
-
if (member.has(obj))
|
|
2977
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
2978
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
2979
|
-
}, __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value), _client, _httpRequest$1;
|
|
2980
2200
|
class ObservableUsersClient {
|
|
2201
|
+
#client;
|
|
2202
|
+
#httpRequest;
|
|
2981
2203
|
constructor(client, httpRequest) {
|
|
2982
|
-
|
|
2204
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
2983
2205
|
}
|
|
2984
2206
|
/**
|
|
2985
2207
|
* Fetch a user by user ID
|
|
@@ -2988,17 +2210,17 @@ ${selectionOpts}`);
|
|
|
2988
2210
|
*/
|
|
2989
2211
|
getById(id) {
|
|
2990
2212
|
return _request(
|
|
2991
|
-
|
|
2992
|
-
|
|
2213
|
+
this.#client,
|
|
2214
|
+
this.#httpRequest,
|
|
2993
2215
|
{ uri: `/users/${id}` }
|
|
2994
2216
|
);
|
|
2995
2217
|
}
|
|
2996
2218
|
}
|
|
2997
|
-
_client = /* @__PURE__ */ new WeakMap(), _httpRequest$1 = /* @__PURE__ */ new WeakMap();
|
|
2998
|
-
var _client2, _httpRequest2$1;
|
|
2999
2219
|
class UsersClient {
|
|
2220
|
+
#client;
|
|
2221
|
+
#httpRequest;
|
|
3000
2222
|
constructor(client, httpRequest) {
|
|
3001
|
-
|
|
2223
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
3002
2224
|
}
|
|
3003
2225
|
/**
|
|
3004
2226
|
* Fetch a user by user ID
|
|
@@ -3007,39 +2229,44 @@ ${selectionOpts}`);
|
|
|
3007
2229
|
*/
|
|
3008
2230
|
getById(id) {
|
|
3009
2231
|
return lastValueFrom(
|
|
3010
|
-
_request(
|
|
2232
|
+
_request(this.#client, this.#httpRequest, {
|
|
3011
2233
|
uri: `/users/${id}`
|
|
3012
2234
|
})
|
|
3013
2235
|
);
|
|
3014
2236
|
}
|
|
3015
2237
|
}
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
2238
|
+
class ObservableSanityClient {
|
|
2239
|
+
assets;
|
|
2240
|
+
datasets;
|
|
2241
|
+
live;
|
|
2242
|
+
projects;
|
|
2243
|
+
users;
|
|
2244
|
+
/**
|
|
2245
|
+
* Private properties
|
|
2246
|
+
*/
|
|
2247
|
+
#clientConfig;
|
|
2248
|
+
#httpRequest;
|
|
2249
|
+
/**
|
|
2250
|
+
* Instance properties
|
|
2251
|
+
*/
|
|
2252
|
+
listen = _listen;
|
|
3026
2253
|
constructor(httpRequest, config = defaultConfig) {
|
|
3027
|
-
|
|
2254
|
+
this.config(config), this.#httpRequest = httpRequest, this.assets = new ObservableAssetsClient(this, this.#httpRequest), this.datasets = new ObservableDatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ObservableProjectsClient(this, this.#httpRequest), this.users = new ObservableUsersClient(this, this.#httpRequest);
|
|
3028
2255
|
}
|
|
3029
2256
|
/**
|
|
3030
2257
|
* Clone the client - returns a new instance
|
|
3031
2258
|
*/
|
|
3032
2259
|
clone() {
|
|
3033
|
-
return new
|
|
2260
|
+
return new ObservableSanityClient(this.#httpRequest, this.config());
|
|
3034
2261
|
}
|
|
3035
2262
|
config(newConfig) {
|
|
3036
2263
|
if (newConfig === void 0)
|
|
3037
|
-
return { ...
|
|
3038
|
-
if (
|
|
2264
|
+
return { ...this.#clientConfig };
|
|
2265
|
+
if (this.#clientConfig && this.#clientConfig.allowReconfigure === !1)
|
|
3039
2266
|
throw new Error(
|
|
3040
2267
|
"Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
|
|
3041
2268
|
);
|
|
3042
|
-
return
|
|
2269
|
+
return this.#clientConfig = initConfig(newConfig, this.#clientConfig || {}), this;
|
|
3043
2270
|
}
|
|
3044
2271
|
/**
|
|
3045
2272
|
* Clone the client with a new (partial) configuration.
|
|
@@ -3048,20 +2275,20 @@ ${selectionOpts}`);
|
|
|
3048
2275
|
*/
|
|
3049
2276
|
withConfig(newConfig) {
|
|
3050
2277
|
const thisConfig = this.config();
|
|
3051
|
-
return new
|
|
2278
|
+
return new ObservableSanityClient(this.#httpRequest, {
|
|
3052
2279
|
...thisConfig,
|
|
3053
2280
|
...newConfig,
|
|
3054
2281
|
stega: {
|
|
3055
2282
|
...thisConfig.stega || {},
|
|
3056
|
-
...typeof
|
|
2283
|
+
...typeof newConfig?.stega == "boolean" ? { enabled: newConfig.stega } : newConfig?.stega || {}
|
|
3057
2284
|
}
|
|
3058
2285
|
});
|
|
3059
2286
|
}
|
|
3060
2287
|
fetch(query, params, options) {
|
|
3061
2288
|
return _fetch(
|
|
3062
2289
|
this,
|
|
3063
|
-
|
|
3064
|
-
|
|
2290
|
+
this.#httpRequest,
|
|
2291
|
+
this.#clientConfig.stega,
|
|
3065
2292
|
query,
|
|
3066
2293
|
params,
|
|
3067
2294
|
options
|
|
@@ -3074,7 +2301,7 @@ ${selectionOpts}`);
|
|
|
3074
2301
|
* @param options - Request options
|
|
3075
2302
|
*/
|
|
3076
2303
|
getDocument(id, options) {
|
|
3077
|
-
return _getDocument(this,
|
|
2304
|
+
return _getDocument(this, this.#httpRequest, id, options);
|
|
3078
2305
|
}
|
|
3079
2306
|
/**
|
|
3080
2307
|
* Fetch multiple documents in one request.
|
|
@@ -3086,22 +2313,22 @@ ${selectionOpts}`);
|
|
|
3086
2313
|
* @param options - Request options
|
|
3087
2314
|
*/
|
|
3088
2315
|
getDocuments(ids, options) {
|
|
3089
|
-
return _getDocuments(this,
|
|
2316
|
+
return _getDocuments(this, this.#httpRequest, ids, options);
|
|
3090
2317
|
}
|
|
3091
2318
|
create(document, options) {
|
|
3092
|
-
return _create(this,
|
|
2319
|
+
return _create(this, this.#httpRequest, document, "create", options);
|
|
3093
2320
|
}
|
|
3094
2321
|
createIfNotExists(document, options) {
|
|
3095
|
-
return _createIfNotExists(this,
|
|
2322
|
+
return _createIfNotExists(this, this.#httpRequest, document, options);
|
|
3096
2323
|
}
|
|
3097
2324
|
createOrReplace(document, options) {
|
|
3098
|
-
return _createOrReplace(this,
|
|
2325
|
+
return _createOrReplace(this, this.#httpRequest, document, options);
|
|
3099
2326
|
}
|
|
3100
2327
|
delete(selection, options) {
|
|
3101
|
-
return _delete(this,
|
|
2328
|
+
return _delete(this, this.#httpRequest, selection, options);
|
|
3102
2329
|
}
|
|
3103
2330
|
mutate(operations, options) {
|
|
3104
|
-
return _mutate(this,
|
|
2331
|
+
return _mutate(this, this.#httpRequest, operations, options);
|
|
3105
2332
|
}
|
|
3106
2333
|
/**
|
|
3107
2334
|
* Create a new buildable patch of operations to perform
|
|
@@ -3128,7 +2355,7 @@ ${selectionOpts}`);
|
|
|
3128
2355
|
* @param options - Action options
|
|
3129
2356
|
*/
|
|
3130
2357
|
action(operations, options) {
|
|
3131
|
-
return _action(this,
|
|
2358
|
+
return _action(this, this.#httpRequest, operations, options);
|
|
3132
2359
|
}
|
|
3133
2360
|
/**
|
|
3134
2361
|
* Perform an HTTP request against the Sanity API
|
|
@@ -3136,7 +2363,7 @@ ${selectionOpts}`);
|
|
|
3136
2363
|
* @param options - Request options
|
|
3137
2364
|
*/
|
|
3138
2365
|
request(options) {
|
|
3139
|
-
return _request(this,
|
|
2366
|
+
return _request(this, this.#httpRequest, options);
|
|
3140
2367
|
}
|
|
3141
2368
|
/**
|
|
3142
2369
|
* Get a Sanity API URL for the URI provided
|
|
@@ -3156,28 +2383,43 @@ ${selectionOpts}`);
|
|
|
3156
2383
|
getDataUrl(operation, path) {
|
|
3157
2384
|
return _getDataUrl(this, operation, path);
|
|
3158
2385
|
}
|
|
3159
|
-
}
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
2386
|
+
}
|
|
2387
|
+
class SanityClient {
|
|
2388
|
+
assets;
|
|
2389
|
+
datasets;
|
|
2390
|
+
live;
|
|
2391
|
+
projects;
|
|
2392
|
+
users;
|
|
2393
|
+
/**
|
|
2394
|
+
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
2395
|
+
*/
|
|
2396
|
+
observable;
|
|
2397
|
+
/**
|
|
2398
|
+
* Private properties
|
|
2399
|
+
*/
|
|
2400
|
+
#clientConfig;
|
|
2401
|
+
#httpRequest;
|
|
2402
|
+
/**
|
|
2403
|
+
* Instance properties
|
|
2404
|
+
*/
|
|
2405
|
+
listen = _listen;
|
|
3164
2406
|
constructor(httpRequest, config = defaultConfig) {
|
|
3165
|
-
|
|
2407
|
+
this.config(config), this.#httpRequest = httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.observable = new ObservableSanityClient(httpRequest, config);
|
|
3166
2408
|
}
|
|
3167
2409
|
/**
|
|
3168
2410
|
* Clone the client - returns a new instance
|
|
3169
2411
|
*/
|
|
3170
2412
|
clone() {
|
|
3171
|
-
return new
|
|
2413
|
+
return new SanityClient(this.#httpRequest, this.config());
|
|
3172
2414
|
}
|
|
3173
2415
|
config(newConfig) {
|
|
3174
2416
|
if (newConfig === void 0)
|
|
3175
|
-
return { ...
|
|
3176
|
-
if (
|
|
2417
|
+
return { ...this.#clientConfig };
|
|
2418
|
+
if (this.#clientConfig && this.#clientConfig.allowReconfigure === !1)
|
|
3177
2419
|
throw new Error(
|
|
3178
2420
|
"Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
|
|
3179
2421
|
);
|
|
3180
|
-
return this.observable && this.observable.config(newConfig),
|
|
2422
|
+
return this.observable && this.observable.config(newConfig), this.#clientConfig = initConfig(newConfig, this.#clientConfig || {}), this;
|
|
3181
2423
|
}
|
|
3182
2424
|
/**
|
|
3183
2425
|
* Clone the client with a new (partial) configuration.
|
|
@@ -3186,12 +2428,12 @@ ${selectionOpts}`);
|
|
|
3186
2428
|
*/
|
|
3187
2429
|
withConfig(newConfig) {
|
|
3188
2430
|
const thisConfig = this.config();
|
|
3189
|
-
return new
|
|
2431
|
+
return new SanityClient(this.#httpRequest, {
|
|
3190
2432
|
...thisConfig,
|
|
3191
2433
|
...newConfig,
|
|
3192
2434
|
stega: {
|
|
3193
2435
|
...thisConfig.stega || {},
|
|
3194
|
-
...typeof
|
|
2436
|
+
...typeof newConfig?.stega == "boolean" ? { enabled: newConfig.stega } : newConfig?.stega || {}
|
|
3195
2437
|
}
|
|
3196
2438
|
});
|
|
3197
2439
|
}
|
|
@@ -3199,8 +2441,8 @@ ${selectionOpts}`);
|
|
|
3199
2441
|
return lastValueFrom(
|
|
3200
2442
|
_fetch(
|
|
3201
2443
|
this,
|
|
3202
|
-
|
|
3203
|
-
|
|
2444
|
+
this.#httpRequest,
|
|
2445
|
+
this.#clientConfig.stega,
|
|
3204
2446
|
query,
|
|
3205
2447
|
params,
|
|
3206
2448
|
options
|
|
@@ -3214,7 +2456,7 @@ ${selectionOpts}`);
|
|
|
3214
2456
|
* @param options - Request options
|
|
3215
2457
|
*/
|
|
3216
2458
|
getDocument(id, options) {
|
|
3217
|
-
return lastValueFrom(_getDocument(this,
|
|
2459
|
+
return lastValueFrom(_getDocument(this, this.#httpRequest, id, options));
|
|
3218
2460
|
}
|
|
3219
2461
|
/**
|
|
3220
2462
|
* Fetch multiple documents in one request.
|
|
@@ -3226,28 +2468,28 @@ ${selectionOpts}`);
|
|
|
3226
2468
|
* @param options - Request options
|
|
3227
2469
|
*/
|
|
3228
2470
|
getDocuments(ids, options) {
|
|
3229
|
-
return lastValueFrom(_getDocuments(this,
|
|
2471
|
+
return lastValueFrom(_getDocuments(this, this.#httpRequest, ids, options));
|
|
3230
2472
|
}
|
|
3231
2473
|
create(document, options) {
|
|
3232
2474
|
return lastValueFrom(
|
|
3233
|
-
_create(this,
|
|
2475
|
+
_create(this, this.#httpRequest, document, "create", options)
|
|
3234
2476
|
);
|
|
3235
2477
|
}
|
|
3236
2478
|
createIfNotExists(document, options) {
|
|
3237
2479
|
return lastValueFrom(
|
|
3238
|
-
_createIfNotExists(this,
|
|
2480
|
+
_createIfNotExists(this, this.#httpRequest, document, options)
|
|
3239
2481
|
);
|
|
3240
2482
|
}
|
|
3241
2483
|
createOrReplace(document, options) {
|
|
3242
2484
|
return lastValueFrom(
|
|
3243
|
-
_createOrReplace(this,
|
|
2485
|
+
_createOrReplace(this, this.#httpRequest, document, options)
|
|
3244
2486
|
);
|
|
3245
2487
|
}
|
|
3246
2488
|
delete(selection, options) {
|
|
3247
|
-
return lastValueFrom(_delete(this,
|
|
2489
|
+
return lastValueFrom(_delete(this, this.#httpRequest, selection, options));
|
|
3248
2490
|
}
|
|
3249
2491
|
mutate(operations, options) {
|
|
3250
|
-
return lastValueFrom(_mutate(this,
|
|
2492
|
+
return lastValueFrom(_mutate(this, this.#httpRequest, operations, options));
|
|
3251
2493
|
}
|
|
3252
2494
|
/**
|
|
3253
2495
|
* Create a new buildable patch of operations to perform
|
|
@@ -3275,7 +2517,7 @@ ${selectionOpts}`);
|
|
|
3275
2517
|
* @param options - Action options
|
|
3276
2518
|
*/
|
|
3277
2519
|
action(operations, options) {
|
|
3278
|
-
return lastValueFrom(_action(this,
|
|
2520
|
+
return lastValueFrom(_action(this, this.#httpRequest, operations, options));
|
|
3279
2521
|
}
|
|
3280
2522
|
/**
|
|
3281
2523
|
* Perform a request against the Sanity API
|
|
@@ -3285,7 +2527,7 @@ ${selectionOpts}`);
|
|
|
3285
2527
|
* @returns Promise resolving to the response body
|
|
3286
2528
|
*/
|
|
3287
2529
|
request(options) {
|
|
3288
|
-
return lastValueFrom(_request(this,
|
|
2530
|
+
return lastValueFrom(_request(this, this.#httpRequest, options));
|
|
3289
2531
|
}
|
|
3290
2532
|
/**
|
|
3291
2533
|
* Perform an HTTP request a `/data` sub-endpoint
|
|
@@ -3298,7 +2540,7 @@ ${selectionOpts}`);
|
|
|
3298
2540
|
* @internal
|
|
3299
2541
|
*/
|
|
3300
2542
|
dataRequest(endpoint, body, options) {
|
|
3301
|
-
return lastValueFrom(_dataRequest(this,
|
|
2543
|
+
return lastValueFrom(_dataRequest(this, this.#httpRequest, endpoint, body, options));
|
|
3302
2544
|
}
|
|
3303
2545
|
/**
|
|
3304
2546
|
* Get a Sanity API URL for the URI provided
|
|
@@ -3318,9 +2560,7 @@ ${selectionOpts}`);
|
|
|
3318
2560
|
getDataUrl(operation, path) {
|
|
3319
2561
|
return _getDataUrl(this, operation, path);
|
|
3320
2562
|
}
|
|
3321
|
-
}
|
|
3322
|
-
_clientConfig2 = /* @__PURE__ */ new WeakMap(), _httpRequest2 = /* @__PURE__ */ new WeakMap();
|
|
3323
|
-
let SanityClient = _SanityClient;
|
|
2563
|
+
}
|
|
3324
2564
|
function defineCreateClientExports(envMiddleware2, ClassConstructor) {
|
|
3325
2565
|
const defaultRequester = defineHttpRequest(envMiddleware2);
|
|
3326
2566
|
return { requester: defaultRequester, createClient: (config) => new ClassConstructor(
|
|
@@ -3427,7 +2667,7 @@ ${selectionOpts}`);
|
|
|
3427
2667
|
});
|
|
3428
2668
|
}
|
|
3429
2669
|
function resolveMapping(resultPath, csm) {
|
|
3430
|
-
if (!
|
|
2670
|
+
if (!csm?.mappings)
|
|
3431
2671
|
return;
|
|
3432
2672
|
const resultMappingPath = jsonPath(jsonPathToMappingPath(resultPath));
|
|
3433
2673
|
if (csm.mappings[resultMappingPath] !== void 0)
|
|
@@ -3586,21 +2826,20 @@ ${selectionOpts}`);
|
|
|
3586
2826
|
}
|
|
3587
2827
|
const TRUNCATE_LENGTH = 20;
|
|
3588
2828
|
function stegaEncodeSourceMap(result, resultSourceMap, config) {
|
|
3589
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
3590
2829
|
const { filter, logger, enabled } = config;
|
|
3591
2830
|
if (!enabled) {
|
|
3592
2831
|
const msg = "config.enabled must be true, don't call this function otherwise";
|
|
3593
|
-
throw
|
|
2832
|
+
throw logger?.error?.(`[@sanity/client]: ${msg}`, { result, resultSourceMap, config }), new TypeError(msg);
|
|
3594
2833
|
}
|
|
3595
2834
|
if (!resultSourceMap)
|
|
3596
|
-
return
|
|
2835
|
+
return logger?.error?.("[@sanity/client]: Missing Content Source Map from response body", {
|
|
3597
2836
|
result,
|
|
3598
2837
|
resultSourceMap,
|
|
3599
2838
|
config
|
|
3600
2839
|
}), result;
|
|
3601
2840
|
if (!config.studioUrl) {
|
|
3602
2841
|
const msg = "config.studioUrl must be defined";
|
|
3603
|
-
throw
|
|
2842
|
+
throw logger?.error?.(`[@sanity/client]: ${msg}`, { result, resultSourceMap, config }), new TypeError(msg);
|
|
3604
2843
|
}
|
|
3605
2844
|
const report = {
|
|
3606
2845
|
encoded: [],
|
|
@@ -3623,8 +2862,7 @@ ${selectionOpts}`);
|
|
|
3623
2862
|
const { baseUrl, workspace, tool } = resolveStudioBaseRoute(
|
|
3624
2863
|
typeof config.studioUrl == "function" ? config.studioUrl(sourceDocument) : config.studioUrl
|
|
3625
2864
|
);
|
|
3626
|
-
if (!baseUrl)
|
|
3627
|
-
return value;
|
|
2865
|
+
if (!baseUrl) return value;
|
|
3628
2866
|
const { _id: id, _type: type, _projectId: projectId, _dataset: dataset } = sourceDocument;
|
|
3629
2867
|
return C(
|
|
3630
2868
|
value,
|
|
@@ -3647,16 +2885,15 @@ ${selectionOpts}`);
|
|
|
3647
2885
|
);
|
|
3648
2886
|
if (logger) {
|
|
3649
2887
|
const isSkipping = report.skipped.length, isEncoding = report.encoded.length;
|
|
3650
|
-
if ((isSkipping || isEncoding) && ((
|
|
3651
|
-
logger,
|
|
2888
|
+
if ((isSkipping || isEncoding) && ((logger?.groupCollapsed || logger.log)?.("[@sanity/client]: Encoding source map into result"), logger.log?.(
|
|
3652
2889
|
`[@sanity/client]: Paths encoded: ${report.encoded.length}, skipped: ${report.skipped.length}`
|
|
3653
|
-
)), report.encoded.length > 0 && (
|
|
2890
|
+
)), report.encoded.length > 0 && (logger?.log?.("[@sanity/client]: Table of encoded paths"), (logger?.table || logger.log)?.(report.encoded)), report.skipped.length > 0) {
|
|
3654
2891
|
const skipped = /* @__PURE__ */ new Set();
|
|
3655
2892
|
for (const { path } of report.skipped)
|
|
3656
2893
|
skipped.add(path.replace(reKeySegment, "0").replace(/\[\d+\]/g, "[]"));
|
|
3657
|
-
|
|
2894
|
+
logger?.log?.("[@sanity/client]: List of skipped paths", [...skipped.values()]);
|
|
3658
2895
|
}
|
|
3659
|
-
(isSkipping || isEncoding) &&
|
|
2896
|
+
(isSkipping || isEncoding) && logger?.groupEnd?.();
|
|
3660
2897
|
}
|
|
3661
2898
|
return resultWithStega;
|
|
3662
2899
|
}
|
|
@@ -4751,8 +3988,8 @@ ${selectionOpts}`);
|
|
|
4751
3988
|
exports.createClient = createClient;
|
|
4752
3989
|
exports.default = deprecatedCreateClient;
|
|
4753
3990
|
exports.requester = requester;
|
|
4754
|
-
exports.unstable__adapter =
|
|
4755
|
-
exports.unstable__environment =
|
|
3991
|
+
exports.unstable__adapter = l$1;
|
|
3992
|
+
exports.unstable__environment = p$1;
|
|
4756
3993
|
|
|
4757
3994
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4758
3995
|
|