@sanity/client 6.21.1 → 6.21.2
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 +1 -1
- package/dist/_chunks-cjs/resolveEditInfo.cjs.map +1 -1
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs +8 -10
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +1 -1
- package/dist/_chunks-es/resolveEditInfo.js +1 -1
- package/dist/_chunks-es/resolveEditInfo.js.map +1 -1
- package/dist/_chunks-es/stegaEncodeSourceMap.js +8 -10
- package/dist/_chunks-es/stegaEncodeSourceMap.js.map +1 -1
- package/dist/index.browser.cjs +172 -207
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +0 -2
- package/dist/index.browser.d.ts +0 -2
- package/dist/index.browser.js +172 -208
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +173 -208
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +173 -209
- package/dist/index.js.map +1 -1
- package/package.json +18 -18
- package/umd/sanityClient.js +191 -963
- 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.
|
|
@@ -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,22 @@
|
|
|
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
1163
|
if (options.maxRetries === 0)
|
|
1894
1164
|
return !1;
|
|
1895
1165
|
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 :
|
|
1166
|
+
return (isSafe || isQuery) && isRetriableResponse ? !0 : _$1.shouldRetry(err, attempt, options);
|
|
1897
1167
|
}
|
|
1898
1168
|
function getSelection(sel) {
|
|
1899
1169
|
if (typeof sel == "string")
|
|
@@ -1954,17 +1224,11 @@ ${selectionOpts}`);
|
|
|
1954
1224
|
);
|
|
1955
1225
|
return tag;
|
|
1956
1226
|
};
|
|
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
1227
|
class BasePatch {
|
|
1228
|
+
selection;
|
|
1229
|
+
operations;
|
|
1966
1230
|
constructor(selection, operations = {}) {
|
|
1967
|
-
|
|
1231
|
+
this.selection = selection, this.operations = operations;
|
|
1968
1232
|
}
|
|
1969
1233
|
/**
|
|
1970
1234
|
* Sets the given attributes to the document. Does NOT merge objects.
|
|
@@ -2095,62 +1359,52 @@ ${selectionOpts}`);
|
|
|
2095
1359
|
return this._assign(op, props, !1);
|
|
2096
1360
|
}
|
|
2097
1361
|
}
|
|
2098
|
-
|
|
2099
|
-
|
|
1362
|
+
class ObservablePatch extends BasePatch {
|
|
1363
|
+
#client;
|
|
2100
1364
|
constructor(selection, operations, client) {
|
|
2101
|
-
super(selection, operations),
|
|
1365
|
+
super(selection, operations), this.#client = client;
|
|
2102
1366
|
}
|
|
2103
1367
|
/**
|
|
2104
1368
|
* Clones the patch
|
|
2105
1369
|
*/
|
|
2106
1370
|
clone() {
|
|
2107
|
-
return new
|
|
1371
|
+
return new ObservablePatch(this.selection, { ...this.operations }, this.#client);
|
|
2108
1372
|
}
|
|
2109
1373
|
commit(options) {
|
|
2110
|
-
if (!
|
|
1374
|
+
if (!this.#client)
|
|
2111
1375
|
throw new Error(
|
|
2112
1376
|
"No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
|
|
2113
1377
|
);
|
|
2114
1378
|
const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
|
|
2115
|
-
return
|
|
1379
|
+
return this.#client.mutate({ patch: this.serialize() }, opts);
|
|
2116
1380
|
}
|
|
2117
|
-
}
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
var _client2$5;
|
|
2121
|
-
const _Patch = class _Patch2 extends BasePatch {
|
|
1381
|
+
}
|
|
1382
|
+
class Patch extends BasePatch {
|
|
1383
|
+
#client;
|
|
2122
1384
|
constructor(selection, operations, client) {
|
|
2123
|
-
super(selection, operations),
|
|
1385
|
+
super(selection, operations), this.#client = client;
|
|
2124
1386
|
}
|
|
2125
1387
|
/**
|
|
2126
1388
|
* Clones the patch
|
|
2127
1389
|
*/
|
|
2128
1390
|
clone() {
|
|
2129
|
-
return new
|
|
1391
|
+
return new Patch(this.selection, { ...this.operations }, this.#client);
|
|
2130
1392
|
}
|
|
2131
1393
|
commit(options) {
|
|
2132
|
-
if (!
|
|
1394
|
+
if (!this.#client)
|
|
2133
1395
|
throw new Error(
|
|
2134
1396
|
"No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
|
|
2135
1397
|
);
|
|
2136
1398
|
const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
|
|
2137
|
-
return
|
|
1399
|
+
return this.#client.mutate({ patch: this.serialize() }, opts);
|
|
2138
1400
|
}
|
|
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);
|
|
1401
|
+
}
|
|
2150
1402
|
const defaultMutateOptions = { returnDocuments: !1 };
|
|
2151
1403
|
class BaseTransaction {
|
|
1404
|
+
operations;
|
|
1405
|
+
trxId;
|
|
2152
1406
|
constructor(operations = [], transactionId) {
|
|
2153
|
-
|
|
1407
|
+
this.operations = operations, this.trxId = transactionId;
|
|
2154
1408
|
}
|
|
2155
1409
|
/**
|
|
2156
1410
|
* 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 +1469,23 @@ ${selectionOpts}`);
|
|
|
2215
1469
|
return this.operations.push(mut), this;
|
|
2216
1470
|
}
|
|
2217
1471
|
}
|
|
2218
|
-
|
|
2219
|
-
|
|
1472
|
+
class Transaction extends BaseTransaction {
|
|
1473
|
+
#client;
|
|
2220
1474
|
constructor(operations, client, transactionId) {
|
|
2221
|
-
super(operations, transactionId),
|
|
1475
|
+
super(operations, transactionId), this.#client = client;
|
|
2222
1476
|
}
|
|
2223
1477
|
/**
|
|
2224
1478
|
* Clones the transaction
|
|
2225
1479
|
*/
|
|
2226
1480
|
clone() {
|
|
2227
|
-
return new
|
|
1481
|
+
return new Transaction([...this.operations], this.#client, this.trxId);
|
|
2228
1482
|
}
|
|
2229
1483
|
commit(options) {
|
|
2230
|
-
if (!
|
|
1484
|
+
if (!this.#client)
|
|
2231
1485
|
throw new Error(
|
|
2232
1486
|
"No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
|
|
2233
1487
|
);
|
|
2234
|
-
return
|
|
1488
|
+
return this.#client.mutate(
|
|
2235
1489
|
this.serialize(),
|
|
2236
1490
|
Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
|
|
2237
1491
|
);
|
|
@@ -2241,33 +1495,31 @@ ${selectionOpts}`);
|
|
|
2241
1495
|
if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof Patch)
|
|
2242
1496
|
return this._add({ patch: patchOrDocumentId.serialize() });
|
|
2243
1497
|
if (isBuilder) {
|
|
2244
|
-
const patch = patchOps(new Patch(patchOrDocumentId, {},
|
|
1498
|
+
const patch = patchOps(new Patch(patchOrDocumentId, {}, this.#client));
|
|
2245
1499
|
if (!(patch instanceof Patch))
|
|
2246
1500
|
throw new Error("function passed to `patch()` must return the patch");
|
|
2247
1501
|
return this._add({ patch: patch.serialize() });
|
|
2248
1502
|
}
|
|
2249
1503
|
return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
|
|
2250
1504
|
}
|
|
2251
|
-
}
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
var _client2$4;
|
|
2255
|
-
const _ObservableTransaction = class _ObservableTransaction2 extends BaseTransaction {
|
|
1505
|
+
}
|
|
1506
|
+
class ObservableTransaction extends BaseTransaction {
|
|
1507
|
+
#client;
|
|
2256
1508
|
constructor(operations, client, transactionId) {
|
|
2257
|
-
super(operations, transactionId),
|
|
1509
|
+
super(operations, transactionId), this.#client = client;
|
|
2258
1510
|
}
|
|
2259
1511
|
/**
|
|
2260
1512
|
* Clones the transaction
|
|
2261
1513
|
*/
|
|
2262
1514
|
clone() {
|
|
2263
|
-
return new
|
|
1515
|
+
return new ObservableTransaction([...this.operations], this.#client, this.trxId);
|
|
2264
1516
|
}
|
|
2265
1517
|
commit(options) {
|
|
2266
|
-
if (!
|
|
1518
|
+
if (!this.#client)
|
|
2267
1519
|
throw new Error(
|
|
2268
1520
|
"No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
|
|
2269
1521
|
);
|
|
2270
|
-
return
|
|
1522
|
+
return this.#client.mutate(
|
|
2271
1523
|
this.serialize(),
|
|
2272
1524
|
Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
|
|
2273
1525
|
);
|
|
@@ -2277,16 +1529,14 @@ ${selectionOpts}`);
|
|
|
2277
1529
|
if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof ObservablePatch)
|
|
2278
1530
|
return this._add({ patch: patchOrDocumentId.serialize() });
|
|
2279
1531
|
if (isBuilder) {
|
|
2280
|
-
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {},
|
|
1532
|
+
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, this.#client));
|
|
2281
1533
|
if (!(patch instanceof ObservablePatch))
|
|
2282
1534
|
throw new Error("function passed to `patch()` must return the patch");
|
|
2283
1535
|
return this._add({ patch: patch.serialize() });
|
|
2284
1536
|
}
|
|
2285
1537
|
return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
|
|
2286
1538
|
}
|
|
2287
|
-
}
|
|
2288
|
-
_client2$4 = /* @__PURE__ */ new WeakMap();
|
|
2289
|
-
let ObservableTransaction = _ObservableTransaction;
|
|
1539
|
+
}
|
|
2290
1540
|
const BASE_URL = "https://www.sanity.io/help/";
|
|
2291
1541
|
function generateHelpUrl(slug) {
|
|
2292
1542
|
return BASE_URL + slug;
|
|
@@ -2541,12 +1791,11 @@ ${selectionOpts}`);
|
|
|
2541
1791
|
return _dataRequest(client, httpRequest, "mutate", { mutations: [mutation] }, opts);
|
|
2542
1792
|
}
|
|
2543
1793
|
function _requestObservable(client, httpRequest, options) {
|
|
2544
|
-
var _a, _b;
|
|
2545
1794
|
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 = (
|
|
1795
|
+
let useCdn = (options.useCdn ?? config.useCdn) && canUseCdn;
|
|
2547
1796
|
const tag = options.tag && config.requestTagPrefix ? [config.requestTagPrefix, options.tag].join(".") : options.tag || config.requestTagPrefix;
|
|
2548
1797
|
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 =
|
|
1798
|
+
const resultSourceMap = options.resultSourceMap ?? config.resultSourceMap;
|
|
2550
1799
|
resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
|
|
2551
1800
|
const perspective = options.perspective || config.perspective;
|
|
2552
1801
|
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 });
|
|
@@ -2590,36 +1839,29 @@ ${selectionOpts}`);
|
|
|
2590
1839
|
}
|
|
2591
1840
|
const isDomExceptionSupported = !!globalThis.DOMException;
|
|
2592
1841
|
function _createAbortError(signal) {
|
|
2593
|
-
var _a, _b;
|
|
2594
1842
|
if (isDomExceptionSupported)
|
|
2595
|
-
return new DOMException(
|
|
2596
|
-
const error = new Error(
|
|
1843
|
+
return new DOMException(signal?.reason ?? "The operation was aborted.", "AbortError");
|
|
1844
|
+
const error = new Error(signal?.reason ?? "The operation was aborted.");
|
|
2597
1845
|
return error.name = "AbortError", error;
|
|
2598
1846
|
}
|
|
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
1847
|
class ObservableAssetsClient {
|
|
1848
|
+
#client;
|
|
1849
|
+
#httpRequest;
|
|
2608
1850
|
constructor(client, httpRequest) {
|
|
2609
|
-
|
|
1851
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
2610
1852
|
}
|
|
2611
1853
|
upload(assetType, body, options) {
|
|
2612
|
-
return _upload(
|
|
1854
|
+
return _upload(this.#client, this.#httpRequest, assetType, body, options);
|
|
2613
1855
|
}
|
|
2614
1856
|
}
|
|
2615
|
-
_client$4 = /* @__PURE__ */ new WeakMap(), _httpRequest$4 = /* @__PURE__ */ new WeakMap();
|
|
2616
|
-
var _client2$3, _httpRequest2$4;
|
|
2617
1857
|
class AssetsClient {
|
|
1858
|
+
#client;
|
|
1859
|
+
#httpRequest;
|
|
2618
1860
|
constructor(client, httpRequest) {
|
|
2619
|
-
|
|
1861
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
2620
1862
|
}
|
|
2621
1863
|
upload(assetType, body, options) {
|
|
2622
|
-
const observable2 = _upload(
|
|
1864
|
+
const observable2 = _upload(this.#client, this.#httpRequest, assetType, body, options);
|
|
2623
1865
|
return lastValueFrom(
|
|
2624
1866
|
observable2.pipe(
|
|
2625
1867
|
filter((event) => event.type === "response"),
|
|
@@ -2630,7 +1872,6 @@ ${selectionOpts}`);
|
|
|
2630
1872
|
);
|
|
2631
1873
|
}
|
|
2632
1874
|
}
|
|
2633
|
-
_client2$3 = /* @__PURE__ */ new WeakMap(), _httpRequest2$4 = /* @__PURE__ */ new WeakMap();
|
|
2634
1875
|
function _upload(client, httpRequest, assetType, body, opts = {}) {
|
|
2635
1876
|
validateAssetType(assetType);
|
|
2636
1877
|
let meta = opts.extract || void 0;
|
|
@@ -2739,30 +1980,22 @@ ${selectionOpts}`);
|
|
|
2739
1980
|
function extractErrorMessage(err) {
|
|
2740
1981
|
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
1982
|
}
|
|
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
1983
|
const requiredApiVersion = "2021-03-26";
|
|
2751
|
-
var _client$3;
|
|
2752
1984
|
class LiveClient {
|
|
1985
|
+
#client;
|
|
2753
1986
|
constructor(client) {
|
|
2754
|
-
|
|
1987
|
+
this.#client = client;
|
|
2755
1988
|
}
|
|
2756
1989
|
/**
|
|
2757
1990
|
* Requires `apiVersion` to be `2021-03-26` or later.
|
|
2758
1991
|
*/
|
|
2759
1992
|
events() {
|
|
2760
|
-
const apiVersion =
|
|
1993
|
+
const apiVersion = this.#client.config().apiVersion.replace(/^v/, "");
|
|
2761
1994
|
if (apiVersion !== "X" && apiVersion < requiredApiVersion)
|
|
2762
1995
|
throw new Error(
|
|
2763
1996
|
`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
1997
|
);
|
|
2765
|
-
const path = _getDataUrl(
|
|
1998
|
+
const path = _getDataUrl(this.#client, "live/events"), url = new URL(this.#client.getUrl(path, !1)), listenFor = ["restart", "message"];
|
|
2766
1999
|
return new Observable((observer) => {
|
|
2767
2000
|
let es, reconnectTimer, stopped = !1, unsubscribed = !1;
|
|
2768
2001
|
open();
|
|
@@ -2811,7 +2044,6 @@ ${selectionOpts}`);
|
|
|
2811
2044
|
});
|
|
2812
2045
|
}
|
|
2813
2046
|
}
|
|
2814
|
-
_client$3 = /* @__PURE__ */ new WeakMap();
|
|
2815
2047
|
function parseEvent(event) {
|
|
2816
2048
|
try {
|
|
2817
2049
|
const data = event.data && JSON.parse(event.data) || {};
|
|
@@ -2820,17 +2052,11 @@ ${selectionOpts}`);
|
|
|
2820
2052
|
return err;
|
|
2821
2053
|
}
|
|
2822
2054
|
}
|
|
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
2055
|
class ObservableDatasetsClient {
|
|
2056
|
+
#client;
|
|
2057
|
+
#httpRequest;
|
|
2832
2058
|
constructor(client, httpRequest) {
|
|
2833
|
-
|
|
2059
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
2834
2060
|
}
|
|
2835
2061
|
/**
|
|
2836
2062
|
* Create a new dataset with the given name
|
|
@@ -2839,7 +2065,7 @@ ${selectionOpts}`);
|
|
|
2839
2065
|
* @param options - Options for the dataset
|
|
2840
2066
|
*/
|
|
2841
2067
|
create(name, options) {
|
|
2842
|
-
return _modify(
|
|
2068
|
+
return _modify(this.#client, this.#httpRequest, "PUT", name, options);
|
|
2843
2069
|
}
|
|
2844
2070
|
/**
|
|
2845
2071
|
* Edit a dataset with the given name
|
|
@@ -2848,7 +2074,7 @@ ${selectionOpts}`);
|
|
|
2848
2074
|
* @param options - New options for the dataset
|
|
2849
2075
|
*/
|
|
2850
2076
|
edit(name, options) {
|
|
2851
|
-
return _modify(
|
|
2077
|
+
return _modify(this.#client, this.#httpRequest, "PATCH", name, options);
|
|
2852
2078
|
}
|
|
2853
2079
|
/**
|
|
2854
2080
|
* Delete a dataset with the given name
|
|
@@ -2856,23 +2082,23 @@ ${selectionOpts}`);
|
|
|
2856
2082
|
* @param name - Name of the dataset to delete
|
|
2857
2083
|
*/
|
|
2858
2084
|
delete(name) {
|
|
2859
|
-
return _modify(
|
|
2085
|
+
return _modify(this.#client, this.#httpRequest, "DELETE", name);
|
|
2860
2086
|
}
|
|
2861
2087
|
/**
|
|
2862
2088
|
* Fetch a list of datasets for the configured project
|
|
2863
2089
|
*/
|
|
2864
2090
|
list() {
|
|
2865
|
-
return _request(
|
|
2091
|
+
return _request(this.#client, this.#httpRequest, {
|
|
2866
2092
|
uri: "/datasets",
|
|
2867
2093
|
tag: null
|
|
2868
2094
|
});
|
|
2869
2095
|
}
|
|
2870
2096
|
}
|
|
2871
|
-
_client$2 = /* @__PURE__ */ new WeakMap(), _httpRequest$3 = /* @__PURE__ */ new WeakMap();
|
|
2872
|
-
var _client2$2, _httpRequest2$3;
|
|
2873
2097
|
class DatasetsClient {
|
|
2098
|
+
#client;
|
|
2099
|
+
#httpRequest;
|
|
2874
2100
|
constructor(client, httpRequest) {
|
|
2875
|
-
|
|
2101
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
2876
2102
|
}
|
|
2877
2103
|
/**
|
|
2878
2104
|
* Create a new dataset with the given name
|
|
@@ -2882,7 +2108,7 @@ ${selectionOpts}`);
|
|
|
2882
2108
|
*/
|
|
2883
2109
|
create(name, options) {
|
|
2884
2110
|
return lastValueFrom(
|
|
2885
|
-
_modify(
|
|
2111
|
+
_modify(this.#client, this.#httpRequest, "PUT", name, options)
|
|
2886
2112
|
);
|
|
2887
2113
|
}
|
|
2888
2114
|
/**
|
|
@@ -2893,7 +2119,7 @@ ${selectionOpts}`);
|
|
|
2893
2119
|
*/
|
|
2894
2120
|
edit(name, options) {
|
|
2895
2121
|
return lastValueFrom(
|
|
2896
|
-
_modify(
|
|
2122
|
+
_modify(this.#client, this.#httpRequest, "PATCH", name, options)
|
|
2897
2123
|
);
|
|
2898
2124
|
}
|
|
2899
2125
|
/**
|
|
@@ -2902,18 +2128,17 @@ ${selectionOpts}`);
|
|
|
2902
2128
|
* @param name - Name of the dataset to delete
|
|
2903
2129
|
*/
|
|
2904
2130
|
delete(name) {
|
|
2905
|
-
return lastValueFrom(_modify(
|
|
2131
|
+
return lastValueFrom(_modify(this.#client, this.#httpRequest, "DELETE", name));
|
|
2906
2132
|
}
|
|
2907
2133
|
/**
|
|
2908
2134
|
* Fetch a list of datasets for the configured project
|
|
2909
2135
|
*/
|
|
2910
2136
|
list() {
|
|
2911
2137
|
return lastValueFrom(
|
|
2912
|
-
_request(
|
|
2138
|
+
_request(this.#client, this.#httpRequest, { uri: "/datasets", tag: null })
|
|
2913
2139
|
);
|
|
2914
2140
|
}
|
|
2915
2141
|
}
|
|
2916
|
-
_client2$2 = /* @__PURE__ */ new WeakMap(), _httpRequest2$3 = /* @__PURE__ */ new WeakMap();
|
|
2917
2142
|
function _modify(client, httpRequest, method, name, options) {
|
|
2918
2143
|
return dataset(name), _request(client, httpRequest, {
|
|
2919
2144
|
method,
|
|
@@ -2922,21 +2147,15 @@ ${selectionOpts}`);
|
|
|
2922
2147
|
tag: null
|
|
2923
2148
|
});
|
|
2924
2149
|
}
|
|
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
2150
|
class ObservableProjectsClient {
|
|
2151
|
+
#client;
|
|
2152
|
+
#httpRequest;
|
|
2934
2153
|
constructor(client, httpRequest) {
|
|
2935
|
-
|
|
2154
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
2936
2155
|
}
|
|
2937
2156
|
list(options) {
|
|
2938
|
-
const uri =
|
|
2939
|
-
return _request(
|
|
2157
|
+
const uri = options?.includeMembers === !1 ? "/projects?includeMembers=false" : "/projects";
|
|
2158
|
+
return _request(this.#client, this.#httpRequest, { uri });
|
|
2940
2159
|
}
|
|
2941
2160
|
/**
|
|
2942
2161
|
* Fetch a project by project ID
|
|
@@ -2944,18 +2163,18 @@ ${selectionOpts}`);
|
|
|
2944
2163
|
* @param projectId - ID of the project to fetch
|
|
2945
2164
|
*/
|
|
2946
2165
|
getById(projectId2) {
|
|
2947
|
-
return _request(
|
|
2166
|
+
return _request(this.#client, this.#httpRequest, { uri: `/projects/${projectId2}` });
|
|
2948
2167
|
}
|
|
2949
2168
|
}
|
|
2950
|
-
_client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */ new WeakMap();
|
|
2951
|
-
var _client2$1, _httpRequest2$2;
|
|
2952
2169
|
class ProjectsClient {
|
|
2170
|
+
#client;
|
|
2171
|
+
#httpRequest;
|
|
2953
2172
|
constructor(client, httpRequest) {
|
|
2954
|
-
|
|
2173
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
2955
2174
|
}
|
|
2956
2175
|
list(options) {
|
|
2957
|
-
const uri =
|
|
2958
|
-
return lastValueFrom(_request(
|
|
2176
|
+
const uri = options?.includeMembers === !1 ? "/projects?includeMembers=false" : "/projects";
|
|
2177
|
+
return lastValueFrom(_request(this.#client, this.#httpRequest, { uri }));
|
|
2959
2178
|
}
|
|
2960
2179
|
/**
|
|
2961
2180
|
* Fetch a project by project ID
|
|
@@ -2964,22 +2183,15 @@ ${selectionOpts}`);
|
|
|
2964
2183
|
*/
|
|
2965
2184
|
getById(projectId2) {
|
|
2966
2185
|
return lastValueFrom(
|
|
2967
|
-
_request(
|
|
2186
|
+
_request(this.#client, this.#httpRequest, { uri: `/projects/${projectId2}` })
|
|
2968
2187
|
);
|
|
2969
2188
|
}
|
|
2970
2189
|
}
|
|
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
2190
|
class ObservableUsersClient {
|
|
2191
|
+
#client;
|
|
2192
|
+
#httpRequest;
|
|
2981
2193
|
constructor(client, httpRequest) {
|
|
2982
|
-
|
|
2194
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
2983
2195
|
}
|
|
2984
2196
|
/**
|
|
2985
2197
|
* Fetch a user by user ID
|
|
@@ -2988,17 +2200,17 @@ ${selectionOpts}`);
|
|
|
2988
2200
|
*/
|
|
2989
2201
|
getById(id) {
|
|
2990
2202
|
return _request(
|
|
2991
|
-
|
|
2992
|
-
|
|
2203
|
+
this.#client,
|
|
2204
|
+
this.#httpRequest,
|
|
2993
2205
|
{ uri: `/users/${id}` }
|
|
2994
2206
|
);
|
|
2995
2207
|
}
|
|
2996
2208
|
}
|
|
2997
|
-
_client = /* @__PURE__ */ new WeakMap(), _httpRequest$1 = /* @__PURE__ */ new WeakMap();
|
|
2998
|
-
var _client2, _httpRequest2$1;
|
|
2999
2209
|
class UsersClient {
|
|
2210
|
+
#client;
|
|
2211
|
+
#httpRequest;
|
|
3000
2212
|
constructor(client, httpRequest) {
|
|
3001
|
-
|
|
2213
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
3002
2214
|
}
|
|
3003
2215
|
/**
|
|
3004
2216
|
* Fetch a user by user ID
|
|
@@ -3007,39 +2219,44 @@ ${selectionOpts}`);
|
|
|
3007
2219
|
*/
|
|
3008
2220
|
getById(id) {
|
|
3009
2221
|
return lastValueFrom(
|
|
3010
|
-
_request(
|
|
2222
|
+
_request(this.#client, this.#httpRequest, {
|
|
3011
2223
|
uri: `/users/${id}`
|
|
3012
2224
|
})
|
|
3013
2225
|
);
|
|
3014
2226
|
}
|
|
3015
2227
|
}
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
2228
|
+
class ObservableSanityClient {
|
|
2229
|
+
assets;
|
|
2230
|
+
datasets;
|
|
2231
|
+
live;
|
|
2232
|
+
projects;
|
|
2233
|
+
users;
|
|
2234
|
+
/**
|
|
2235
|
+
* Private properties
|
|
2236
|
+
*/
|
|
2237
|
+
#clientConfig;
|
|
2238
|
+
#httpRequest;
|
|
2239
|
+
/**
|
|
2240
|
+
* Instance properties
|
|
2241
|
+
*/
|
|
2242
|
+
listen = _listen;
|
|
3026
2243
|
constructor(httpRequest, config = defaultConfig) {
|
|
3027
|
-
|
|
2244
|
+
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
2245
|
}
|
|
3029
2246
|
/**
|
|
3030
2247
|
* Clone the client - returns a new instance
|
|
3031
2248
|
*/
|
|
3032
2249
|
clone() {
|
|
3033
|
-
return new
|
|
2250
|
+
return new ObservableSanityClient(this.#httpRequest, this.config());
|
|
3034
2251
|
}
|
|
3035
2252
|
config(newConfig) {
|
|
3036
2253
|
if (newConfig === void 0)
|
|
3037
|
-
return { ...
|
|
3038
|
-
if (
|
|
2254
|
+
return { ...this.#clientConfig };
|
|
2255
|
+
if (this.#clientConfig && this.#clientConfig.allowReconfigure === !1)
|
|
3039
2256
|
throw new Error(
|
|
3040
2257
|
"Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
|
|
3041
2258
|
);
|
|
3042
|
-
return
|
|
2259
|
+
return this.#clientConfig = initConfig(newConfig, this.#clientConfig || {}), this;
|
|
3043
2260
|
}
|
|
3044
2261
|
/**
|
|
3045
2262
|
* Clone the client with a new (partial) configuration.
|
|
@@ -3048,20 +2265,20 @@ ${selectionOpts}`);
|
|
|
3048
2265
|
*/
|
|
3049
2266
|
withConfig(newConfig) {
|
|
3050
2267
|
const thisConfig = this.config();
|
|
3051
|
-
return new
|
|
2268
|
+
return new ObservableSanityClient(this.#httpRequest, {
|
|
3052
2269
|
...thisConfig,
|
|
3053
2270
|
...newConfig,
|
|
3054
2271
|
stega: {
|
|
3055
2272
|
...thisConfig.stega || {},
|
|
3056
|
-
...typeof
|
|
2273
|
+
...typeof newConfig?.stega == "boolean" ? { enabled: newConfig.stega } : newConfig?.stega || {}
|
|
3057
2274
|
}
|
|
3058
2275
|
});
|
|
3059
2276
|
}
|
|
3060
2277
|
fetch(query, params, options) {
|
|
3061
2278
|
return _fetch(
|
|
3062
2279
|
this,
|
|
3063
|
-
|
|
3064
|
-
|
|
2280
|
+
this.#httpRequest,
|
|
2281
|
+
this.#clientConfig.stega,
|
|
3065
2282
|
query,
|
|
3066
2283
|
params,
|
|
3067
2284
|
options
|
|
@@ -3074,7 +2291,7 @@ ${selectionOpts}`);
|
|
|
3074
2291
|
* @param options - Request options
|
|
3075
2292
|
*/
|
|
3076
2293
|
getDocument(id, options) {
|
|
3077
|
-
return _getDocument(this,
|
|
2294
|
+
return _getDocument(this, this.#httpRequest, id, options);
|
|
3078
2295
|
}
|
|
3079
2296
|
/**
|
|
3080
2297
|
* Fetch multiple documents in one request.
|
|
@@ -3086,22 +2303,22 @@ ${selectionOpts}`);
|
|
|
3086
2303
|
* @param options - Request options
|
|
3087
2304
|
*/
|
|
3088
2305
|
getDocuments(ids, options) {
|
|
3089
|
-
return _getDocuments(this,
|
|
2306
|
+
return _getDocuments(this, this.#httpRequest, ids, options);
|
|
3090
2307
|
}
|
|
3091
2308
|
create(document, options) {
|
|
3092
|
-
return _create(this,
|
|
2309
|
+
return _create(this, this.#httpRequest, document, "create", options);
|
|
3093
2310
|
}
|
|
3094
2311
|
createIfNotExists(document, options) {
|
|
3095
|
-
return _createIfNotExists(this,
|
|
2312
|
+
return _createIfNotExists(this, this.#httpRequest, document, options);
|
|
3096
2313
|
}
|
|
3097
2314
|
createOrReplace(document, options) {
|
|
3098
|
-
return _createOrReplace(this,
|
|
2315
|
+
return _createOrReplace(this, this.#httpRequest, document, options);
|
|
3099
2316
|
}
|
|
3100
2317
|
delete(selection, options) {
|
|
3101
|
-
return _delete(this,
|
|
2318
|
+
return _delete(this, this.#httpRequest, selection, options);
|
|
3102
2319
|
}
|
|
3103
2320
|
mutate(operations, options) {
|
|
3104
|
-
return _mutate(this,
|
|
2321
|
+
return _mutate(this, this.#httpRequest, operations, options);
|
|
3105
2322
|
}
|
|
3106
2323
|
/**
|
|
3107
2324
|
* Create a new buildable patch of operations to perform
|
|
@@ -3128,7 +2345,7 @@ ${selectionOpts}`);
|
|
|
3128
2345
|
* @param options - Action options
|
|
3129
2346
|
*/
|
|
3130
2347
|
action(operations, options) {
|
|
3131
|
-
return _action(this,
|
|
2348
|
+
return _action(this, this.#httpRequest, operations, options);
|
|
3132
2349
|
}
|
|
3133
2350
|
/**
|
|
3134
2351
|
* Perform an HTTP request against the Sanity API
|
|
@@ -3136,7 +2353,7 @@ ${selectionOpts}`);
|
|
|
3136
2353
|
* @param options - Request options
|
|
3137
2354
|
*/
|
|
3138
2355
|
request(options) {
|
|
3139
|
-
return _request(this,
|
|
2356
|
+
return _request(this, this.#httpRequest, options);
|
|
3140
2357
|
}
|
|
3141
2358
|
/**
|
|
3142
2359
|
* Get a Sanity API URL for the URI provided
|
|
@@ -3156,28 +2373,43 @@ ${selectionOpts}`);
|
|
|
3156
2373
|
getDataUrl(operation, path) {
|
|
3157
2374
|
return _getDataUrl(this, operation, path);
|
|
3158
2375
|
}
|
|
3159
|
-
}
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
2376
|
+
}
|
|
2377
|
+
class SanityClient {
|
|
2378
|
+
assets;
|
|
2379
|
+
datasets;
|
|
2380
|
+
live;
|
|
2381
|
+
projects;
|
|
2382
|
+
users;
|
|
2383
|
+
/**
|
|
2384
|
+
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
2385
|
+
*/
|
|
2386
|
+
observable;
|
|
2387
|
+
/**
|
|
2388
|
+
* Private properties
|
|
2389
|
+
*/
|
|
2390
|
+
#clientConfig;
|
|
2391
|
+
#httpRequest;
|
|
2392
|
+
/**
|
|
2393
|
+
* Instance properties
|
|
2394
|
+
*/
|
|
2395
|
+
listen = _listen;
|
|
3164
2396
|
constructor(httpRequest, config = defaultConfig) {
|
|
3165
|
-
|
|
2397
|
+
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
2398
|
}
|
|
3167
2399
|
/**
|
|
3168
2400
|
* Clone the client - returns a new instance
|
|
3169
2401
|
*/
|
|
3170
2402
|
clone() {
|
|
3171
|
-
return new
|
|
2403
|
+
return new SanityClient(this.#httpRequest, this.config());
|
|
3172
2404
|
}
|
|
3173
2405
|
config(newConfig) {
|
|
3174
2406
|
if (newConfig === void 0)
|
|
3175
|
-
return { ...
|
|
3176
|
-
if (
|
|
2407
|
+
return { ...this.#clientConfig };
|
|
2408
|
+
if (this.#clientConfig && this.#clientConfig.allowReconfigure === !1)
|
|
3177
2409
|
throw new Error(
|
|
3178
2410
|
"Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
|
|
3179
2411
|
);
|
|
3180
|
-
return this.observable && this.observable.config(newConfig),
|
|
2412
|
+
return this.observable && this.observable.config(newConfig), this.#clientConfig = initConfig(newConfig, this.#clientConfig || {}), this;
|
|
3181
2413
|
}
|
|
3182
2414
|
/**
|
|
3183
2415
|
* Clone the client with a new (partial) configuration.
|
|
@@ -3186,12 +2418,12 @@ ${selectionOpts}`);
|
|
|
3186
2418
|
*/
|
|
3187
2419
|
withConfig(newConfig) {
|
|
3188
2420
|
const thisConfig = this.config();
|
|
3189
|
-
return new
|
|
2421
|
+
return new SanityClient(this.#httpRequest, {
|
|
3190
2422
|
...thisConfig,
|
|
3191
2423
|
...newConfig,
|
|
3192
2424
|
stega: {
|
|
3193
2425
|
...thisConfig.stega || {},
|
|
3194
|
-
...typeof
|
|
2426
|
+
...typeof newConfig?.stega == "boolean" ? { enabled: newConfig.stega } : newConfig?.stega || {}
|
|
3195
2427
|
}
|
|
3196
2428
|
});
|
|
3197
2429
|
}
|
|
@@ -3199,8 +2431,8 @@ ${selectionOpts}`);
|
|
|
3199
2431
|
return lastValueFrom(
|
|
3200
2432
|
_fetch(
|
|
3201
2433
|
this,
|
|
3202
|
-
|
|
3203
|
-
|
|
2434
|
+
this.#httpRequest,
|
|
2435
|
+
this.#clientConfig.stega,
|
|
3204
2436
|
query,
|
|
3205
2437
|
params,
|
|
3206
2438
|
options
|
|
@@ -3214,7 +2446,7 @@ ${selectionOpts}`);
|
|
|
3214
2446
|
* @param options - Request options
|
|
3215
2447
|
*/
|
|
3216
2448
|
getDocument(id, options) {
|
|
3217
|
-
return lastValueFrom(_getDocument(this,
|
|
2449
|
+
return lastValueFrom(_getDocument(this, this.#httpRequest, id, options));
|
|
3218
2450
|
}
|
|
3219
2451
|
/**
|
|
3220
2452
|
* Fetch multiple documents in one request.
|
|
@@ -3226,28 +2458,28 @@ ${selectionOpts}`);
|
|
|
3226
2458
|
* @param options - Request options
|
|
3227
2459
|
*/
|
|
3228
2460
|
getDocuments(ids, options) {
|
|
3229
|
-
return lastValueFrom(_getDocuments(this,
|
|
2461
|
+
return lastValueFrom(_getDocuments(this, this.#httpRequest, ids, options));
|
|
3230
2462
|
}
|
|
3231
2463
|
create(document, options) {
|
|
3232
2464
|
return lastValueFrom(
|
|
3233
|
-
_create(this,
|
|
2465
|
+
_create(this, this.#httpRequest, document, "create", options)
|
|
3234
2466
|
);
|
|
3235
2467
|
}
|
|
3236
2468
|
createIfNotExists(document, options) {
|
|
3237
2469
|
return lastValueFrom(
|
|
3238
|
-
_createIfNotExists(this,
|
|
2470
|
+
_createIfNotExists(this, this.#httpRequest, document, options)
|
|
3239
2471
|
);
|
|
3240
2472
|
}
|
|
3241
2473
|
createOrReplace(document, options) {
|
|
3242
2474
|
return lastValueFrom(
|
|
3243
|
-
_createOrReplace(this,
|
|
2475
|
+
_createOrReplace(this, this.#httpRequest, document, options)
|
|
3244
2476
|
);
|
|
3245
2477
|
}
|
|
3246
2478
|
delete(selection, options) {
|
|
3247
|
-
return lastValueFrom(_delete(this,
|
|
2479
|
+
return lastValueFrom(_delete(this, this.#httpRequest, selection, options));
|
|
3248
2480
|
}
|
|
3249
2481
|
mutate(operations, options) {
|
|
3250
|
-
return lastValueFrom(_mutate(this,
|
|
2482
|
+
return lastValueFrom(_mutate(this, this.#httpRequest, operations, options));
|
|
3251
2483
|
}
|
|
3252
2484
|
/**
|
|
3253
2485
|
* Create a new buildable patch of operations to perform
|
|
@@ -3275,7 +2507,7 @@ ${selectionOpts}`);
|
|
|
3275
2507
|
* @param options - Action options
|
|
3276
2508
|
*/
|
|
3277
2509
|
action(operations, options) {
|
|
3278
|
-
return lastValueFrom(_action(this,
|
|
2510
|
+
return lastValueFrom(_action(this, this.#httpRequest, operations, options));
|
|
3279
2511
|
}
|
|
3280
2512
|
/**
|
|
3281
2513
|
* Perform a request against the Sanity API
|
|
@@ -3285,7 +2517,7 @@ ${selectionOpts}`);
|
|
|
3285
2517
|
* @returns Promise resolving to the response body
|
|
3286
2518
|
*/
|
|
3287
2519
|
request(options) {
|
|
3288
|
-
return lastValueFrom(_request(this,
|
|
2520
|
+
return lastValueFrom(_request(this, this.#httpRequest, options));
|
|
3289
2521
|
}
|
|
3290
2522
|
/**
|
|
3291
2523
|
* Perform an HTTP request a `/data` sub-endpoint
|
|
@@ -3298,7 +2530,7 @@ ${selectionOpts}`);
|
|
|
3298
2530
|
* @internal
|
|
3299
2531
|
*/
|
|
3300
2532
|
dataRequest(endpoint, body, options) {
|
|
3301
|
-
return lastValueFrom(_dataRequest(this,
|
|
2533
|
+
return lastValueFrom(_dataRequest(this, this.#httpRequest, endpoint, body, options));
|
|
3302
2534
|
}
|
|
3303
2535
|
/**
|
|
3304
2536
|
* Get a Sanity API URL for the URI provided
|
|
@@ -3318,9 +2550,7 @@ ${selectionOpts}`);
|
|
|
3318
2550
|
getDataUrl(operation, path) {
|
|
3319
2551
|
return _getDataUrl(this, operation, path);
|
|
3320
2552
|
}
|
|
3321
|
-
}
|
|
3322
|
-
_clientConfig2 = /* @__PURE__ */ new WeakMap(), _httpRequest2 = /* @__PURE__ */ new WeakMap();
|
|
3323
|
-
let SanityClient = _SanityClient;
|
|
2553
|
+
}
|
|
3324
2554
|
function defineCreateClientExports(envMiddleware2, ClassConstructor) {
|
|
3325
2555
|
const defaultRequester = defineHttpRequest(envMiddleware2);
|
|
3326
2556
|
return { requester: defaultRequester, createClient: (config) => new ClassConstructor(
|
|
@@ -3427,7 +2657,7 @@ ${selectionOpts}`);
|
|
|
3427
2657
|
});
|
|
3428
2658
|
}
|
|
3429
2659
|
function resolveMapping(resultPath, csm) {
|
|
3430
|
-
if (!
|
|
2660
|
+
if (!csm?.mappings)
|
|
3431
2661
|
return;
|
|
3432
2662
|
const resultMappingPath = jsonPath(jsonPathToMappingPath(resultPath));
|
|
3433
2663
|
if (csm.mappings[resultMappingPath] !== void 0)
|
|
@@ -3586,21 +2816,20 @@ ${selectionOpts}`);
|
|
|
3586
2816
|
}
|
|
3587
2817
|
const TRUNCATE_LENGTH = 20;
|
|
3588
2818
|
function stegaEncodeSourceMap(result, resultSourceMap, config) {
|
|
3589
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
3590
2819
|
const { filter, logger, enabled } = config;
|
|
3591
2820
|
if (!enabled) {
|
|
3592
2821
|
const msg = "config.enabled must be true, don't call this function otherwise";
|
|
3593
|
-
throw
|
|
2822
|
+
throw logger?.error?.(`[@sanity/client]: ${msg}`, { result, resultSourceMap, config }), new TypeError(msg);
|
|
3594
2823
|
}
|
|
3595
2824
|
if (!resultSourceMap)
|
|
3596
|
-
return
|
|
2825
|
+
return logger?.error?.("[@sanity/client]: Missing Content Source Map from response body", {
|
|
3597
2826
|
result,
|
|
3598
2827
|
resultSourceMap,
|
|
3599
2828
|
config
|
|
3600
2829
|
}), result;
|
|
3601
2830
|
if (!config.studioUrl) {
|
|
3602
2831
|
const msg = "config.studioUrl must be defined";
|
|
3603
|
-
throw
|
|
2832
|
+
throw logger?.error?.(`[@sanity/client]: ${msg}`, { result, resultSourceMap, config }), new TypeError(msg);
|
|
3604
2833
|
}
|
|
3605
2834
|
const report = {
|
|
3606
2835
|
encoded: [],
|
|
@@ -3647,16 +2876,15 @@ ${selectionOpts}`);
|
|
|
3647
2876
|
);
|
|
3648
2877
|
if (logger) {
|
|
3649
2878
|
const isSkipping = report.skipped.length, isEncoding = report.encoded.length;
|
|
3650
|
-
if ((isSkipping || isEncoding) && ((
|
|
3651
|
-
logger,
|
|
2879
|
+
if ((isSkipping || isEncoding) && ((logger?.groupCollapsed || logger.log)?.("[@sanity/client]: Encoding source map into result"), logger.log?.(
|
|
3652
2880
|
`[@sanity/client]: Paths encoded: ${report.encoded.length}, skipped: ${report.skipped.length}`
|
|
3653
|
-
)), report.encoded.length > 0 && (
|
|
2881
|
+
)), report.encoded.length > 0 && (logger?.log?.("[@sanity/client]: Table of encoded paths"), (logger?.table || logger.log)?.(report.encoded)), report.skipped.length > 0) {
|
|
3654
2882
|
const skipped = /* @__PURE__ */ new Set();
|
|
3655
2883
|
for (const { path } of report.skipped)
|
|
3656
2884
|
skipped.add(path.replace(reKeySegment, "0").replace(/\[\d+\]/g, "[]"));
|
|
3657
|
-
|
|
2885
|
+
logger?.log?.("[@sanity/client]: List of skipped paths", [...skipped.values()]);
|
|
3658
2886
|
}
|
|
3659
|
-
(isSkipping || isEncoding) &&
|
|
2887
|
+
(isSkipping || isEncoding) && logger?.groupEnd?.();
|
|
3660
2888
|
}
|
|
3661
2889
|
return resultWithStega;
|
|
3662
2890
|
}
|
|
@@ -4751,8 +3979,8 @@ ${selectionOpts}`);
|
|
|
4751
3979
|
exports.createClient = createClient;
|
|
4752
3980
|
exports.default = deprecatedCreateClient;
|
|
4753
3981
|
exports.requester = requester;
|
|
4754
|
-
exports.unstable__adapter =
|
|
4755
|
-
exports.unstable__environment =
|
|
3982
|
+
exports.unstable__adapter = l$1;
|
|
3983
|
+
exports.unstable__environment = p$1;
|
|
4756
3984
|
|
|
4757
3985
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4758
3986
|
|