@sanity/client 6.21.2 → 6.21.3-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks-cjs/resolveEditInfo.cjs +1 -1
- package/dist/_chunks-cjs/resolveEditInfo.cjs.map +1 -1
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs +10 -8
- 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 +10 -8
- package/dist/_chunks-es/stegaEncodeSourceMap.js.map +1 -1
- package/dist/index.browser.cjs +219 -174
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +12 -0
- package/dist/index.browser.d.ts +12 -0
- package/dist/index.browser.js +220 -174
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +220 -175
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +221 -175
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/SanityClient.ts +2 -2
- package/src/data/dataMethods.ts +14 -4
- package/src/types.ts +8 -0
- package/umd/sanityClient.js +980 -193
- package/umd/sanityClient.min.js +8 -2
package/umd/sanityClient.js
CHANGED
|
@@ -4,11 +4,750 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.SanityClient = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const isReactNative = typeof navigator > "u" ? !1 : navigator.product === "ReactNative", defaultOptions$1 = { timeout: isReactNative ? 6e4 : 12e4 }, processOptions = function(opts) {
|
|
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
|
+
}
|
|
8
63
|
|
|
9
|
-
const
|
|
64
|
+
const middlewareReducer = (middleware) => function(hook, defaultValue, ...args) {
|
|
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, __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), value), __accessCheck$8 = (obj, member, msg) => {
|
|
170
|
+
if (!member.has(obj))
|
|
171
|
+
throw TypeError("Cannot " + msg);
|
|
172
|
+
}, __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) => {
|
|
173
|
+
if (member.has(obj))
|
|
174
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
175
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
176
|
+
}, __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;
|
|
177
|
+
class FetchXhr {
|
|
178
|
+
constructor() {
|
|
179
|
+
__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, void 0), __privateAdd$8(this, _url, void 0), __privateAdd$8(this, _resHeaders, void 0), __privateAdd$8(this, _headers, {}), __privateAdd$8(this, _controller, void 0), __privateAdd$8(this, _init, {}), __privateAdd$8(this, _useAbortSignal, void 0);
|
|
180
|
+
}
|
|
181
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- _async is only declared for typings compatibility
|
|
182
|
+
open(method, url, _async) {
|
|
183
|
+
var _a;
|
|
184
|
+
__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);
|
|
185
|
+
}
|
|
186
|
+
abort() {
|
|
187
|
+
__privateGet$8(this, _controller) && __privateGet$8(this, _controller).abort();
|
|
188
|
+
}
|
|
189
|
+
getAllResponseHeaders() {
|
|
190
|
+
return __privateGet$8(this, _resHeaders);
|
|
191
|
+
}
|
|
192
|
+
setRequestHeader(name, value) {
|
|
193
|
+
__privateGet$8(this, _headers)[name] = value;
|
|
194
|
+
}
|
|
195
|
+
// Allow setting extra fetch init options, needed for runtimes such as Vercel Edge to set `cache` and other options in React Server Components
|
|
196
|
+
setInit(init, useAbortSignal = !0) {
|
|
197
|
+
__privateSet$8(this, _init, init), __privateSet$8(this, _useAbortSignal, useAbortSignal);
|
|
198
|
+
}
|
|
199
|
+
send(body) {
|
|
200
|
+
const textBody = this.responseType !== "arraybuffer", options = {
|
|
201
|
+
...__privateGet$8(this, _init),
|
|
202
|
+
method: __privateGet$8(this, _method),
|
|
203
|
+
headers: __privateGet$8(this, _headers),
|
|
204
|
+
body
|
|
205
|
+
};
|
|
206
|
+
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) => (res.headers.forEach((value, key) => {
|
|
207
|
+
__privateSet$8(this, _resHeaders, __privateGet$8(this, _resHeaders) + `${key}: ${value}\r
|
|
208
|
+
`);
|
|
209
|
+
}), this.status = res.status, this.statusText = res.statusText, this.readyState = 3, textBody ? res.text() : res.arrayBuffer())).then((resBody) => {
|
|
210
|
+
var _a;
|
|
211
|
+
typeof resBody == "string" ? this.responseText = resBody : this.response = resBody, this.readyState = 4, (_a = this.onreadystatechange) == null || _a.call(this);
|
|
212
|
+
}).catch((err) => {
|
|
213
|
+
var _a, _b;
|
|
214
|
+
if (err.name === "AbortError") {
|
|
215
|
+
(_a = this.onabort) == null || _a.call(this);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
(_b = this.onerror) == null || _b.call(this, err);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
_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();
|
|
223
|
+
const adapter = typeof XMLHttpRequest == "function" ? "xhr" : "fetch", XmlHttpRequest = adapter === "xhr" ? XMLHttpRequest : FetchXhr, httpRequester = (context, callback) => {
|
|
224
|
+
var _a;
|
|
225
|
+
const opts = context.options, options = context.applyMiddleware("finalizeOptions", opts), timers = {}, injectedResponse = context.applyMiddleware("interceptRequest", void 0, {
|
|
226
|
+
adapter,
|
|
227
|
+
context
|
|
228
|
+
});
|
|
229
|
+
if (injectedResponse) {
|
|
230
|
+
const cbTimer = setTimeout(callback, 0, null, injectedResponse);
|
|
231
|
+
return { abort: () => clearTimeout(cbTimer) };
|
|
232
|
+
}
|
|
233
|
+
let xhr = new XmlHttpRequest();
|
|
234
|
+
xhr instanceof FetchXhr && typeof options.fetch == "object" && xhr.setInit(options.fetch, (_a = options.useAbortSignal) != null ? _a : !0);
|
|
235
|
+
const headers = options.headers, delays = options.timeout;
|
|
236
|
+
let aborted = !1, loaded = !1, timedOut = !1;
|
|
237
|
+
if (xhr.onerror = (event) => {
|
|
238
|
+
xhr instanceof FetchXhr ? onError(
|
|
239
|
+
event instanceof Error ? event : new Error(`Request error while attempting to reach is ${options.url}`, { cause: event })
|
|
240
|
+
) : onError(
|
|
241
|
+
new Error(
|
|
242
|
+
`Request error while attempting to reach is ${options.url}${event.lengthComputable ? `(${event.loaded} of ${event.total} bytes transferred)` : ""}`
|
|
243
|
+
)
|
|
244
|
+
);
|
|
245
|
+
}, xhr.ontimeout = (event) => {
|
|
246
|
+
onError(
|
|
247
|
+
new Error(
|
|
248
|
+
`Request timeout while attempting to reach ${options.url}${event.lengthComputable ? `(${event.loaded} of ${event.total} bytes transferred)` : ""}`
|
|
249
|
+
)
|
|
250
|
+
);
|
|
251
|
+
}, xhr.onabort = () => {
|
|
252
|
+
stopTimers(!0), aborted = !0;
|
|
253
|
+
}, xhr.onreadystatechange = () => {
|
|
254
|
+
resetTimers(), !(aborted || xhr.readyState !== 4) && xhr.status !== 0 && onLoad();
|
|
255
|
+
}, xhr.open(
|
|
256
|
+
options.method,
|
|
257
|
+
options.url,
|
|
258
|
+
!0
|
|
259
|
+
// Always async
|
|
260
|
+
), xhr.withCredentials = !!options.withCredentials, headers && xhr.setRequestHeader)
|
|
261
|
+
for (const key in headers)
|
|
262
|
+
headers.hasOwnProperty(key) && xhr.setRequestHeader(key, headers[key]);
|
|
263
|
+
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 };
|
|
264
|
+
function abort() {
|
|
265
|
+
aborted = !0, xhr && xhr.abort();
|
|
266
|
+
}
|
|
267
|
+
function timeoutRequest(code) {
|
|
268
|
+
timedOut = !0, xhr.abort();
|
|
269
|
+
const error = new Error(
|
|
270
|
+
code === "ESOCKETTIMEDOUT" ? `Socket timed out on request to ${options.url}` : `Connection timed out on request to ${options.url}`
|
|
271
|
+
);
|
|
272
|
+
error.code = code, context.channels.error.publish(error);
|
|
273
|
+
}
|
|
274
|
+
function resetTimers() {
|
|
275
|
+
delays && (stopTimers(), timers.socket = setTimeout(() => timeoutRequest("ESOCKETTIMEDOUT"), delays.socket));
|
|
276
|
+
}
|
|
277
|
+
function stopTimers(force) {
|
|
278
|
+
(force || aborted || xhr.readyState >= 2 && timers.connect) && clearTimeout(timers.connect), timers.socket && clearTimeout(timers.socket);
|
|
279
|
+
}
|
|
280
|
+
function onError(error) {
|
|
281
|
+
if (loaded)
|
|
282
|
+
return;
|
|
283
|
+
stopTimers(!0), loaded = !0, xhr = null;
|
|
284
|
+
const err = error || new Error(`Network error while attempting to reach ${options.url}`);
|
|
285
|
+
err.isNetworkError = !0, err.request = options, callback(err);
|
|
286
|
+
}
|
|
287
|
+
function reduceResponse() {
|
|
288
|
+
return {
|
|
289
|
+
body: xhr.response || (xhr.responseType === "" || xhr.responseType === "text" ? xhr.responseText : ""),
|
|
290
|
+
url: options.url,
|
|
291
|
+
method: options.method,
|
|
292
|
+
headers: parseHeaders$1(xhr.getAllResponseHeaders()),
|
|
293
|
+
statusCode: xhr.status,
|
|
294
|
+
statusMessage: xhr.statusText
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
function onLoad() {
|
|
298
|
+
if (!(aborted || loaded || timedOut)) {
|
|
299
|
+
if (xhr.status === 0) {
|
|
300
|
+
onError(new Error("Unknown XHR error"));
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
stopTimers(), loaded = !0, callback(null, reduceResponse());
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}, getIt = (initMiddleware = [], httpRequest = httpRequester) => createRequester(initMiddleware, httpRequest), environment = "browser";
|
|
10
307
|
|
|
11
|
-
var
|
|
308
|
+
var browser$3 = { exports: {} }, ms, hasRequiredMs;
|
|
309
|
+
function requireMs() {
|
|
310
|
+
if (hasRequiredMs)
|
|
311
|
+
return ms;
|
|
312
|
+
hasRequiredMs = 1;
|
|
313
|
+
var s = 1e3, m = s * 60, h = m * 60, d = h * 24, w = d * 7, y = d * 365.25;
|
|
314
|
+
ms = function(val, options) {
|
|
315
|
+
options = options || {};
|
|
316
|
+
var type = typeof val;
|
|
317
|
+
if (type === "string" && val.length > 0)
|
|
318
|
+
return parse(val);
|
|
319
|
+
if (type === "number" && isFinite(val))
|
|
320
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
|
321
|
+
throw new Error(
|
|
322
|
+
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
323
|
+
);
|
|
324
|
+
};
|
|
325
|
+
function parse(str) {
|
|
326
|
+
if (str = String(str), !(str.length > 100)) {
|
|
327
|
+
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(
|
|
328
|
+
str
|
|
329
|
+
);
|
|
330
|
+
if (match) {
|
|
331
|
+
var n = parseFloat(match[1]), type = (match[2] || "ms").toLowerCase();
|
|
332
|
+
switch (type) {
|
|
333
|
+
case "years":
|
|
334
|
+
case "year":
|
|
335
|
+
case "yrs":
|
|
336
|
+
case "yr":
|
|
337
|
+
case "y":
|
|
338
|
+
return n * y;
|
|
339
|
+
case "weeks":
|
|
340
|
+
case "week":
|
|
341
|
+
case "w":
|
|
342
|
+
return n * w;
|
|
343
|
+
case "days":
|
|
344
|
+
case "day":
|
|
345
|
+
case "d":
|
|
346
|
+
return n * d;
|
|
347
|
+
case "hours":
|
|
348
|
+
case "hour":
|
|
349
|
+
case "hrs":
|
|
350
|
+
case "hr":
|
|
351
|
+
case "h":
|
|
352
|
+
return n * h;
|
|
353
|
+
case "minutes":
|
|
354
|
+
case "minute":
|
|
355
|
+
case "mins":
|
|
356
|
+
case "min":
|
|
357
|
+
case "m":
|
|
358
|
+
return n * m;
|
|
359
|
+
case "seconds":
|
|
360
|
+
case "second":
|
|
361
|
+
case "secs":
|
|
362
|
+
case "sec":
|
|
363
|
+
case "s":
|
|
364
|
+
return n * s;
|
|
365
|
+
case "milliseconds":
|
|
366
|
+
case "millisecond":
|
|
367
|
+
case "msecs":
|
|
368
|
+
case "msec":
|
|
369
|
+
case "ms":
|
|
370
|
+
return n;
|
|
371
|
+
default:
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
function fmtShort(ms2) {
|
|
378
|
+
var msAbs = Math.abs(ms2);
|
|
379
|
+
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";
|
|
380
|
+
}
|
|
381
|
+
function fmtLong(ms2) {
|
|
382
|
+
var msAbs = Math.abs(ms2);
|
|
383
|
+
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";
|
|
384
|
+
}
|
|
385
|
+
function plural(ms2, msAbs, n, name) {
|
|
386
|
+
var isPlural = msAbs >= n * 1.5;
|
|
387
|
+
return Math.round(ms2 / n) + " " + name + (isPlural ? "s" : "");
|
|
388
|
+
}
|
|
389
|
+
return ms;
|
|
390
|
+
}
|
|
391
|
+
function setup(env) {
|
|
392
|
+
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) => {
|
|
393
|
+
createDebug[key] = env[key];
|
|
394
|
+
}), createDebug.names = [], createDebug.skips = [], createDebug.formatters = {};
|
|
395
|
+
function selectColor(namespace) {
|
|
396
|
+
let hash = 0;
|
|
397
|
+
for (let i = 0; i < namespace.length; i++)
|
|
398
|
+
hash = (hash << 5) - hash + namespace.charCodeAt(i), hash |= 0;
|
|
399
|
+
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
400
|
+
}
|
|
401
|
+
createDebug.selectColor = selectColor;
|
|
402
|
+
function createDebug(namespace) {
|
|
403
|
+
let prevTime, enableOverride = null, namespacesCache, enabledCache;
|
|
404
|
+
function debug2(...args) {
|
|
405
|
+
if (!debug2.enabled)
|
|
406
|
+
return;
|
|
407
|
+
const self2 = debug2, curr = Number(/* @__PURE__ */ new Date()), ms2 = curr - (prevTime || curr);
|
|
408
|
+
self2.diff = ms2, self2.prev = prevTime, self2.curr = curr, prevTime = curr, args[0] = createDebug.coerce(args[0]), typeof args[0] != "string" && args.unshift("%O");
|
|
409
|
+
let index = 0;
|
|
410
|
+
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
411
|
+
if (match === "%%")
|
|
412
|
+
return "%";
|
|
413
|
+
index++;
|
|
414
|
+
const formatter = createDebug.formatters[format];
|
|
415
|
+
if (typeof formatter == "function") {
|
|
416
|
+
const val = args[index];
|
|
417
|
+
match = formatter.call(self2, val), args.splice(index, 1), index--;
|
|
418
|
+
}
|
|
419
|
+
return match;
|
|
420
|
+
}), createDebug.formatArgs.call(self2, args), (self2.log || createDebug.log).apply(self2, args);
|
|
421
|
+
}
|
|
422
|
+
return debug2.namespace = namespace, debug2.useColors = createDebug.useColors(), debug2.color = createDebug.selectColor(namespace), debug2.extend = extend, debug2.destroy = createDebug.destroy, Object.defineProperty(debug2, "enabled", {
|
|
423
|
+
enumerable: !0,
|
|
424
|
+
configurable: !1,
|
|
425
|
+
get: () => enableOverride !== null ? enableOverride : (namespacesCache !== createDebug.namespaces && (namespacesCache = createDebug.namespaces, enabledCache = createDebug.enabled(namespace)), enabledCache),
|
|
426
|
+
set: (v) => {
|
|
427
|
+
enableOverride = v;
|
|
428
|
+
}
|
|
429
|
+
}), typeof createDebug.init == "function" && createDebug.init(debug2), debug2;
|
|
430
|
+
}
|
|
431
|
+
function extend(namespace, delimiter) {
|
|
432
|
+
const newDebug = createDebug(this.namespace + (typeof delimiter > "u" ? ":" : delimiter) + namespace);
|
|
433
|
+
return newDebug.log = this.log, newDebug;
|
|
434
|
+
}
|
|
435
|
+
function enable(namespaces) {
|
|
436
|
+
createDebug.save(namespaces), createDebug.namespaces = namespaces, createDebug.names = [], createDebug.skips = [];
|
|
437
|
+
let i;
|
|
438
|
+
const split = (typeof namespaces == "string" ? namespaces : "").split(/[\s,]+/), len = split.length;
|
|
439
|
+
for (i = 0; i < len; i++)
|
|
440
|
+
split[i] && (namespaces = split[i].replace(/\*/g, ".*?"), namespaces[0] === "-" ? createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$")) : createDebug.names.push(new RegExp("^" + namespaces + "$")));
|
|
441
|
+
}
|
|
442
|
+
function disable() {
|
|
443
|
+
const namespaces = [
|
|
444
|
+
...createDebug.names.map(toNamespace),
|
|
445
|
+
...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace)
|
|
446
|
+
].join(",");
|
|
447
|
+
return createDebug.enable(""), namespaces;
|
|
448
|
+
}
|
|
449
|
+
function enabled(name) {
|
|
450
|
+
if (name[name.length - 1] === "*")
|
|
451
|
+
return !0;
|
|
452
|
+
let i, len;
|
|
453
|
+
for (i = 0, len = createDebug.skips.length; i < len; i++)
|
|
454
|
+
if (createDebug.skips[i].test(name))
|
|
455
|
+
return !1;
|
|
456
|
+
for (i = 0, len = createDebug.names.length; i < len; i++)
|
|
457
|
+
if (createDebug.names[i].test(name))
|
|
458
|
+
return !0;
|
|
459
|
+
return !1;
|
|
460
|
+
}
|
|
461
|
+
function toNamespace(regexp) {
|
|
462
|
+
return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
|
|
463
|
+
}
|
|
464
|
+
function coerce(val) {
|
|
465
|
+
return val instanceof Error ? val.stack || val.message : val;
|
|
466
|
+
}
|
|
467
|
+
function destroy() {
|
|
468
|
+
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
469
|
+
}
|
|
470
|
+
return createDebug.enable(createDebug.load()), createDebug;
|
|
471
|
+
}
|
|
472
|
+
var common = setup;
|
|
473
|
+
(function(module, exports) {
|
|
474
|
+
exports.formatArgs = formatArgs, exports.save = save, exports.load = load, exports.useColors = useColors, exports.storage = localstorage(), exports.destroy = /* @__PURE__ */ (() => {
|
|
475
|
+
let warned = !1;
|
|
476
|
+
return () => {
|
|
477
|
+
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`."));
|
|
478
|
+
};
|
|
479
|
+
})(), exports.colors = [
|
|
480
|
+
"#0000CC",
|
|
481
|
+
"#0000FF",
|
|
482
|
+
"#0033CC",
|
|
483
|
+
"#0033FF",
|
|
484
|
+
"#0066CC",
|
|
485
|
+
"#0066FF",
|
|
486
|
+
"#0099CC",
|
|
487
|
+
"#0099FF",
|
|
488
|
+
"#00CC00",
|
|
489
|
+
"#00CC33",
|
|
490
|
+
"#00CC66",
|
|
491
|
+
"#00CC99",
|
|
492
|
+
"#00CCCC",
|
|
493
|
+
"#00CCFF",
|
|
494
|
+
"#3300CC",
|
|
495
|
+
"#3300FF",
|
|
496
|
+
"#3333CC",
|
|
497
|
+
"#3333FF",
|
|
498
|
+
"#3366CC",
|
|
499
|
+
"#3366FF",
|
|
500
|
+
"#3399CC",
|
|
501
|
+
"#3399FF",
|
|
502
|
+
"#33CC00",
|
|
503
|
+
"#33CC33",
|
|
504
|
+
"#33CC66",
|
|
505
|
+
"#33CC99",
|
|
506
|
+
"#33CCCC",
|
|
507
|
+
"#33CCFF",
|
|
508
|
+
"#6600CC",
|
|
509
|
+
"#6600FF",
|
|
510
|
+
"#6633CC",
|
|
511
|
+
"#6633FF",
|
|
512
|
+
"#66CC00",
|
|
513
|
+
"#66CC33",
|
|
514
|
+
"#9900CC",
|
|
515
|
+
"#9900FF",
|
|
516
|
+
"#9933CC",
|
|
517
|
+
"#9933FF",
|
|
518
|
+
"#99CC00",
|
|
519
|
+
"#99CC33",
|
|
520
|
+
"#CC0000",
|
|
521
|
+
"#CC0033",
|
|
522
|
+
"#CC0066",
|
|
523
|
+
"#CC0099",
|
|
524
|
+
"#CC00CC",
|
|
525
|
+
"#CC00FF",
|
|
526
|
+
"#CC3300",
|
|
527
|
+
"#CC3333",
|
|
528
|
+
"#CC3366",
|
|
529
|
+
"#CC3399",
|
|
530
|
+
"#CC33CC",
|
|
531
|
+
"#CC33FF",
|
|
532
|
+
"#CC6600",
|
|
533
|
+
"#CC6633",
|
|
534
|
+
"#CC9900",
|
|
535
|
+
"#CC9933",
|
|
536
|
+
"#CCCC00",
|
|
537
|
+
"#CCCC33",
|
|
538
|
+
"#FF0000",
|
|
539
|
+
"#FF0033",
|
|
540
|
+
"#FF0066",
|
|
541
|
+
"#FF0099",
|
|
542
|
+
"#FF00CC",
|
|
543
|
+
"#FF00FF",
|
|
544
|
+
"#FF3300",
|
|
545
|
+
"#FF3333",
|
|
546
|
+
"#FF3366",
|
|
547
|
+
"#FF3399",
|
|
548
|
+
"#FF33CC",
|
|
549
|
+
"#FF33FF",
|
|
550
|
+
"#FF6600",
|
|
551
|
+
"#FF6633",
|
|
552
|
+
"#FF9900",
|
|
553
|
+
"#FF9933",
|
|
554
|
+
"#FFCC00",
|
|
555
|
+
"#FFCC33"
|
|
556
|
+
];
|
|
557
|
+
function useColors() {
|
|
558
|
+
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
|
|
559
|
+
typeof window < "u" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
|
560
|
+
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
561
|
+
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
|
|
562
|
+
typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
563
|
+
}
|
|
564
|
+
function formatArgs(args) {
|
|
565
|
+
if (args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff), !this.useColors)
|
|
566
|
+
return;
|
|
567
|
+
const c = "color: " + this.color;
|
|
568
|
+
args.splice(1, 0, c, "color: inherit");
|
|
569
|
+
let index = 0, lastC = 0;
|
|
570
|
+
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
571
|
+
match !== "%%" && (index++, match === "%c" && (lastC = index));
|
|
572
|
+
}), args.splice(lastC, 0, c);
|
|
573
|
+
}
|
|
574
|
+
exports.log = console.debug || console.log || (() => {
|
|
575
|
+
});
|
|
576
|
+
function save(namespaces) {
|
|
577
|
+
try {
|
|
578
|
+
namespaces ? exports.storage.setItem("debug", namespaces) : exports.storage.removeItem("debug");
|
|
579
|
+
} catch {
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
function load() {
|
|
583
|
+
let r;
|
|
584
|
+
try {
|
|
585
|
+
r = exports.storage.getItem("debug");
|
|
586
|
+
} catch {
|
|
587
|
+
}
|
|
588
|
+
return !r && typeof process < "u" && "env" in process && (r = process.env.DEBUG), r;
|
|
589
|
+
}
|
|
590
|
+
function localstorage() {
|
|
591
|
+
try {
|
|
592
|
+
return localStorage;
|
|
593
|
+
} catch {
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
module.exports = common(exports);
|
|
597
|
+
const { formatters } = module.exports;
|
|
598
|
+
formatters.j = function(v) {
|
|
599
|
+
try {
|
|
600
|
+
return JSON.stringify(v);
|
|
601
|
+
} catch (error) {
|
|
602
|
+
return "[UnexpectedJSONParseError]: " + error.message;
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
})(browser$3, browser$3.exports);
|
|
606
|
+
const isBuffer = typeof Buffer > "u" ? () => !1 : (obj) => Buffer.isBuffer(obj);
|
|
607
|
+
/*!
|
|
608
|
+
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
609
|
+
*
|
|
610
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
611
|
+
* Released under the MIT License.
|
|
612
|
+
*/
|
|
613
|
+
function isObject(o) {
|
|
614
|
+
return Object.prototype.toString.call(o) === "[object Object]";
|
|
615
|
+
}
|
|
616
|
+
function isPlainObject$1(o) {
|
|
617
|
+
if (isObject(o) === !1)
|
|
618
|
+
return !1;
|
|
619
|
+
const ctor = o.constructor;
|
|
620
|
+
if (ctor === void 0)
|
|
621
|
+
return !0;
|
|
622
|
+
const prot = ctor.prototype;
|
|
623
|
+
return !(isObject(prot) === !1 || // eslint-disable-next-line no-prototype-builtins
|
|
624
|
+
prot.hasOwnProperty("isPrototypeOf") === !1);
|
|
625
|
+
}
|
|
626
|
+
const serializeTypes = ["boolean", "string", "number"];
|
|
627
|
+
function jsonRequest() {
|
|
628
|
+
return {
|
|
629
|
+
processOptions: (options) => {
|
|
630
|
+
const body = options.body;
|
|
631
|
+
return !body || !(typeof body.pipe != "function" && !isBuffer(body) && (serializeTypes.indexOf(typeof body) !== -1 || Array.isArray(body) || isPlainObject$1(body))) ? options : Object.assign({}, options, {
|
|
632
|
+
body: JSON.stringify(options.body),
|
|
633
|
+
headers: Object.assign({}, options.headers, {
|
|
634
|
+
"Content-Type": "application/json"
|
|
635
|
+
})
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
function jsonResponse(opts) {
|
|
641
|
+
return {
|
|
642
|
+
onResponse: (response) => {
|
|
643
|
+
const contentType = response.headers["content-type"] || "", shouldDecode = contentType.indexOf("application/json") !== -1;
|
|
644
|
+
return !response.body || !contentType || !shouldDecode ? response : Object.assign({}, response, { body: tryParse(response.body) });
|
|
645
|
+
},
|
|
646
|
+
processOptions: (options) => Object.assign({}, options, {
|
|
647
|
+
headers: Object.assign({ Accept: "application/json" }, options.headers)
|
|
648
|
+
})
|
|
649
|
+
};
|
|
650
|
+
function tryParse(body) {
|
|
651
|
+
try {
|
|
652
|
+
return JSON.parse(body);
|
|
653
|
+
} catch (err) {
|
|
654
|
+
throw err.message = `Failed to parsed response body as JSON: ${err.message}`, err;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
let actualGlobal = {};
|
|
659
|
+
typeof globalThis < "u" ? actualGlobal = globalThis : typeof window < "u" ? actualGlobal = window : typeof global < "u" ? actualGlobal = global : typeof self < "u" && (actualGlobal = self);
|
|
660
|
+
var global$1 = actualGlobal;
|
|
661
|
+
function observable$1(opts = {}) {
|
|
662
|
+
const Observable = (
|
|
663
|
+
// 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
|
|
664
|
+
opts.implementation || global$1.Observable
|
|
665
|
+
);
|
|
666
|
+
if (!Observable)
|
|
667
|
+
throw new Error(
|
|
668
|
+
"`Observable` is not available in global scope, and no implementation was passed"
|
|
669
|
+
);
|
|
670
|
+
return {
|
|
671
|
+
onReturn: (channels, context) => new Observable((observer) => (channels.error.subscribe((err) => observer.error(err)), channels.progress.subscribe(
|
|
672
|
+
(event) => observer.next(Object.assign({ type: "progress" }, event))
|
|
673
|
+
), channels.response.subscribe((response) => {
|
|
674
|
+
observer.next(Object.assign({ type: "response" }, response)), observer.complete();
|
|
675
|
+
}), channels.request.publish(context), () => channels.abort.publish()))
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
function progress() {
|
|
679
|
+
return {
|
|
680
|
+
onRequest: (evt) => {
|
|
681
|
+
if (evt.adapter !== "xhr")
|
|
682
|
+
return;
|
|
683
|
+
const xhr = evt.request, context = evt.context;
|
|
684
|
+
"upload" in xhr && "onprogress" in xhr.upload && (xhr.upload.onprogress = handleProgress("upload")), "onprogress" in xhr && (xhr.onprogress = handleProgress("download"));
|
|
685
|
+
function handleProgress(stage) {
|
|
686
|
+
return (event) => {
|
|
687
|
+
const percent = event.lengthComputable ? event.loaded / event.total * 100 : -1;
|
|
688
|
+
context.channels.progress.publish({
|
|
689
|
+
stage,
|
|
690
|
+
percent,
|
|
691
|
+
total: event.total,
|
|
692
|
+
loaded: event.loaded,
|
|
693
|
+
lengthComputable: event.lengthComputable
|
|
694
|
+
});
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
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), value);
|
|
701
|
+
class Cancel {
|
|
702
|
+
constructor(message) {
|
|
703
|
+
__publicField$1$1(this, "__CANCEL__", !0), __publicField$1$1(this, "message"), this.message = message;
|
|
704
|
+
}
|
|
705
|
+
toString() {
|
|
706
|
+
return `Cancel${this.message ? `: ${this.message}` : ""}`;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
const _CancelToken = class {
|
|
710
|
+
constructor(executor) {
|
|
711
|
+
if (__publicField$1$1(this, "promise"), __publicField$1$1(this, "reason"), typeof executor != "function")
|
|
712
|
+
throw new TypeError("executor must be a function.");
|
|
713
|
+
let resolvePromise = null;
|
|
714
|
+
this.promise = new Promise((resolve) => {
|
|
715
|
+
resolvePromise = resolve;
|
|
716
|
+
}), executor((message) => {
|
|
717
|
+
this.reason || (this.reason = new Cancel(message), resolvePromise(this.reason));
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
__publicField$1$1(_CancelToken, "source", () => {
|
|
722
|
+
let cancel;
|
|
723
|
+
return {
|
|
724
|
+
token: new _CancelToken((can) => {
|
|
725
|
+
cancel = can;
|
|
726
|
+
}),
|
|
727
|
+
cancel
|
|
728
|
+
};
|
|
729
|
+
});
|
|
730
|
+
var defaultShouldRetry = (err, _attempt, options) => options.method !== "GET" && options.method !== "HEAD" ? !1 : err.isNetworkError || !1;
|
|
731
|
+
const isStream = (stream) => stream !== null && typeof stream == "object" && typeof stream.pipe == "function";
|
|
732
|
+
var sharedRetry = (opts) => {
|
|
733
|
+
const maxRetries = opts.maxRetries || 5, retryDelay = opts.retryDelay || getRetryDelay, allowRetry = opts.shouldRetry;
|
|
734
|
+
return {
|
|
735
|
+
onError: (err, context) => {
|
|
736
|
+
const options = context.options, max = options.maxRetries || maxRetries, delay = options.retryDelay || retryDelay, shouldRetry = options.shouldRetry || allowRetry, attemptNumber = options.attemptNumber || 0;
|
|
737
|
+
if (isStream(options.body) || !shouldRetry(err, attemptNumber, options) || attemptNumber >= max)
|
|
738
|
+
return err;
|
|
739
|
+
const newContext = Object.assign({}, context, {
|
|
740
|
+
options: Object.assign({}, options, { attemptNumber: attemptNumber + 1 })
|
|
741
|
+
});
|
|
742
|
+
return setTimeout(() => context.channels.request.publish(newContext), delay(attemptNumber)), null;
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
};
|
|
746
|
+
function getRetryDelay(attemptNum) {
|
|
747
|
+
return 100 * Math.pow(2, attemptNum) + Math.random() * 100;
|
|
748
|
+
}
|
|
749
|
+
const retry = (opts = {}) => sharedRetry({ shouldRetry: defaultShouldRetry, ...opts });
|
|
750
|
+
retry.shouldRetry = defaultShouldRetry;
|
|
12
751
|
|
|
13
752
|
/******************************************************************************
|
|
14
753
|
Copyright (c) Microsoft Corporation.
|
|
@@ -1077,24 +1816,17 @@
|
|
|
1077
1816
|
return O(result);
|
|
1078
1817
|
}
|
|
1079
1818
|
|
|
1819
|
+
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);
|
|
1080
1820
|
class ClientError extends Error {
|
|
1081
|
-
response;
|
|
1082
|
-
statusCode = 400;
|
|
1083
|
-
responseBody;
|
|
1084
|
-
details;
|
|
1085
1821
|
constructor(res) {
|
|
1086
1822
|
const props = extractErrorProps(res);
|
|
1087
|
-
super(props.message), Object.assign(this, props);
|
|
1823
|
+
super(props.message), __publicField$3(this, "response"), __publicField$3(this, "statusCode", 400), __publicField$3(this, "responseBody"), __publicField$3(this, "details"), Object.assign(this, props);
|
|
1088
1824
|
}
|
|
1089
1825
|
}
|
|
1090
1826
|
class ServerError extends Error {
|
|
1091
|
-
response;
|
|
1092
|
-
statusCode = 500;
|
|
1093
|
-
responseBody;
|
|
1094
|
-
details;
|
|
1095
1827
|
constructor(res) {
|
|
1096
1828
|
const props = extractErrorProps(res);
|
|
1097
|
-
super(props.message), Object.assign(this, props);
|
|
1829
|
+
super(props.message), __publicField$3(this, "response"), __publicField$3(this, "statusCode", 500), __publicField$3(this, "responseBody"), __publicField$3(this, "details"), Object.assign(this, props);
|
|
1098
1830
|
}
|
|
1099
1831
|
}
|
|
1100
1832
|
function extractErrorProps(res) {
|
|
@@ -1108,7 +1840,10 @@
|
|
|
1108
1840
|
if (body.error && body.message)
|
|
1109
1841
|
return props.message = `${body.error} - ${body.message}`, props;
|
|
1110
1842
|
if (isMutationError(body) || isActionError(body)) {
|
|
1111
|
-
const allItems = body.error.items || [], items = allItems.slice(0, 5).map((item) =>
|
|
1843
|
+
const allItems = body.error.items || [], items = allItems.slice(0, 5).map((item) => {
|
|
1844
|
+
var _a;
|
|
1845
|
+
return (_a = item.error) == null ? void 0 : _a.description;
|
|
1846
|
+
}).filter(Boolean);
|
|
1112
1847
|
let itemsStr = items.length ? `:
|
|
1113
1848
|
- ${items.join(`
|
|
1114
1849
|
- `)}` : "";
|
|
@@ -1148,22 +1883,22 @@
|
|
|
1148
1883
|
}
|
|
1149
1884
|
};
|
|
1150
1885
|
function defineHttpRequest(envMiddleware2) {
|
|
1151
|
-
return
|
|
1152
|
-
|
|
1886
|
+
return getIt([
|
|
1887
|
+
retry({ shouldRetry }),
|
|
1153
1888
|
...envMiddleware2,
|
|
1154
1889
|
printWarnings,
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1890
|
+
jsonRequest(),
|
|
1891
|
+
jsonResponse(),
|
|
1892
|
+
progress(),
|
|
1158
1893
|
httpError,
|
|
1159
|
-
|
|
1894
|
+
observable$1({ implementation: Observable })
|
|
1160
1895
|
]);
|
|
1161
1896
|
}
|
|
1162
1897
|
function shouldRetry(err, attempt, options) {
|
|
1163
1898
|
if (options.maxRetries === 0)
|
|
1164
1899
|
return !1;
|
|
1165
1900
|
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);
|
|
1166
|
-
return (isSafe || isQuery) && isRetriableResponse ? !0 :
|
|
1901
|
+
return (isSafe || isQuery) && isRetriableResponse ? !0 : retry.shouldRetry(err, attempt, options);
|
|
1167
1902
|
}
|
|
1168
1903
|
function getSelection(sel) {
|
|
1169
1904
|
if (typeof sel == "string")
|
|
@@ -1224,11 +1959,17 @@ ${selectionOpts}`);
|
|
|
1224
1959
|
);
|
|
1225
1960
|
return tag;
|
|
1226
1961
|
};
|
|
1962
|
+
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) => {
|
|
1963
|
+
if (!member.has(obj))
|
|
1964
|
+
throw TypeError("Cannot " + msg);
|
|
1965
|
+
}, __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) => {
|
|
1966
|
+
if (member.has(obj))
|
|
1967
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
1968
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1969
|
+
}, __privateSet$7 = (obj, member, value, setter) => (__accessCheck$7(obj, member, "write to private field"), member.set(obj, value), value);
|
|
1227
1970
|
class BasePatch {
|
|
1228
|
-
selection;
|
|
1229
|
-
operations;
|
|
1230
1971
|
constructor(selection, operations = {}) {
|
|
1231
|
-
this.selection = selection, this.operations = operations;
|
|
1972
|
+
__publicField$2(this, "selection"), __publicField$2(this, "operations"), this.selection = selection, this.operations = operations;
|
|
1232
1973
|
}
|
|
1233
1974
|
/**
|
|
1234
1975
|
* Sets the given attributes to the document. Does NOT merge objects.
|
|
@@ -1359,52 +2100,62 @@ ${selectionOpts}`);
|
|
|
1359
2100
|
return this._assign(op, props, !1);
|
|
1360
2101
|
}
|
|
1361
2102
|
}
|
|
1362
|
-
|
|
1363
|
-
|
|
2103
|
+
var _client$6;
|
|
2104
|
+
const _ObservablePatch = class _ObservablePatch2 extends BasePatch {
|
|
1364
2105
|
constructor(selection, operations, client) {
|
|
1365
|
-
super(selection, operations), this
|
|
2106
|
+
super(selection, operations), __privateAdd$7(this, _client$6, void 0), __privateSet$7(this, _client$6, client);
|
|
1366
2107
|
}
|
|
1367
2108
|
/**
|
|
1368
2109
|
* Clones the patch
|
|
1369
2110
|
*/
|
|
1370
2111
|
clone() {
|
|
1371
|
-
return new
|
|
2112
|
+
return new _ObservablePatch2(this.selection, { ...this.operations }, __privateGet$7(this, _client$6));
|
|
1372
2113
|
}
|
|
1373
2114
|
commit(options) {
|
|
1374
|
-
if (!this
|
|
2115
|
+
if (!__privateGet$7(this, _client$6))
|
|
1375
2116
|
throw new Error(
|
|
1376
2117
|
"No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
|
|
1377
2118
|
);
|
|
1378
2119
|
const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
|
|
1379
|
-
return this
|
|
2120
|
+
return __privateGet$7(this, _client$6).mutate({ patch: this.serialize() }, opts);
|
|
1380
2121
|
}
|
|
1381
|
-
}
|
|
1382
|
-
|
|
1383
|
-
|
|
2122
|
+
};
|
|
2123
|
+
_client$6 = /* @__PURE__ */ new WeakMap();
|
|
2124
|
+
let ObservablePatch = _ObservablePatch;
|
|
2125
|
+
var _client2$5;
|
|
2126
|
+
const _Patch = class _Patch2 extends BasePatch {
|
|
1384
2127
|
constructor(selection, operations, client) {
|
|
1385
|
-
super(selection, operations), this
|
|
2128
|
+
super(selection, operations), __privateAdd$7(this, _client2$5, void 0), __privateSet$7(this, _client2$5, client);
|
|
1386
2129
|
}
|
|
1387
2130
|
/**
|
|
1388
2131
|
* Clones the patch
|
|
1389
2132
|
*/
|
|
1390
2133
|
clone() {
|
|
1391
|
-
return new
|
|
2134
|
+
return new _Patch2(this.selection, { ...this.operations }, __privateGet$7(this, _client2$5));
|
|
1392
2135
|
}
|
|
1393
2136
|
commit(options) {
|
|
1394
|
-
if (!this
|
|
2137
|
+
if (!__privateGet$7(this, _client2$5))
|
|
1395
2138
|
throw new Error(
|
|
1396
2139
|
"No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
|
|
1397
2140
|
);
|
|
1398
2141
|
const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
|
|
1399
|
-
return this
|
|
2142
|
+
return __privateGet$7(this, _client2$5).mutate({ patch: this.serialize() }, opts);
|
|
1400
2143
|
}
|
|
1401
|
-
}
|
|
2144
|
+
};
|
|
2145
|
+
_client2$5 = /* @__PURE__ */ new WeakMap();
|
|
2146
|
+
let Patch = _Patch;
|
|
2147
|
+
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) => {
|
|
2148
|
+
if (!member.has(obj))
|
|
2149
|
+
throw TypeError("Cannot " + msg);
|
|
2150
|
+
}, __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) => {
|
|
2151
|
+
if (member.has(obj))
|
|
2152
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
2153
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
2154
|
+
}, __privateSet$6 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), member.set(obj, value), value);
|
|
1402
2155
|
const defaultMutateOptions = { returnDocuments: !1 };
|
|
1403
2156
|
class BaseTransaction {
|
|
1404
|
-
operations;
|
|
1405
|
-
trxId;
|
|
1406
2157
|
constructor(operations = [], transactionId) {
|
|
1407
|
-
this.operations = operations, this.trxId = transactionId;
|
|
2158
|
+
__publicField$1(this, "operations"), __publicField$1(this, "trxId"), this.operations = operations, this.trxId = transactionId;
|
|
1408
2159
|
}
|
|
1409
2160
|
/**
|
|
1410
2161
|
* 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.
|
|
@@ -1469,23 +2220,23 @@ ${selectionOpts}`);
|
|
|
1469
2220
|
return this.operations.push(mut), this;
|
|
1470
2221
|
}
|
|
1471
2222
|
}
|
|
1472
|
-
|
|
1473
|
-
|
|
2223
|
+
var _client$5;
|
|
2224
|
+
const _Transaction = class _Transaction2 extends BaseTransaction {
|
|
1474
2225
|
constructor(operations, client, transactionId) {
|
|
1475
|
-
super(operations, transactionId), this
|
|
2226
|
+
super(operations, transactionId), __privateAdd$6(this, _client$5, void 0), __privateSet$6(this, _client$5, client);
|
|
1476
2227
|
}
|
|
1477
2228
|
/**
|
|
1478
2229
|
* Clones the transaction
|
|
1479
2230
|
*/
|
|
1480
2231
|
clone() {
|
|
1481
|
-
return new
|
|
2232
|
+
return new _Transaction2([...this.operations], __privateGet$6(this, _client$5), this.trxId);
|
|
1482
2233
|
}
|
|
1483
2234
|
commit(options) {
|
|
1484
|
-
if (!this
|
|
2235
|
+
if (!__privateGet$6(this, _client$5))
|
|
1485
2236
|
throw new Error(
|
|
1486
2237
|
"No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
|
|
1487
2238
|
);
|
|
1488
|
-
return this
|
|
2239
|
+
return __privateGet$6(this, _client$5).mutate(
|
|
1489
2240
|
this.serialize(),
|
|
1490
2241
|
Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
|
|
1491
2242
|
);
|
|
@@ -1495,31 +2246,33 @@ ${selectionOpts}`);
|
|
|
1495
2246
|
if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof Patch)
|
|
1496
2247
|
return this._add({ patch: patchOrDocumentId.serialize() });
|
|
1497
2248
|
if (isBuilder) {
|
|
1498
|
-
const patch = patchOps(new Patch(patchOrDocumentId, {}, this
|
|
2249
|
+
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$6(this, _client$5)));
|
|
1499
2250
|
if (!(patch instanceof Patch))
|
|
1500
2251
|
throw new Error("function passed to `patch()` must return the patch");
|
|
1501
2252
|
return this._add({ patch: patch.serialize() });
|
|
1502
2253
|
}
|
|
1503
2254
|
return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
|
|
1504
2255
|
}
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1507
|
-
|
|
2256
|
+
};
|
|
2257
|
+
_client$5 = /* @__PURE__ */ new WeakMap();
|
|
2258
|
+
let Transaction = _Transaction;
|
|
2259
|
+
var _client2$4;
|
|
2260
|
+
const _ObservableTransaction = class _ObservableTransaction2 extends BaseTransaction {
|
|
1508
2261
|
constructor(operations, client, transactionId) {
|
|
1509
|
-
super(operations, transactionId), this
|
|
2262
|
+
super(operations, transactionId), __privateAdd$6(this, _client2$4, void 0), __privateSet$6(this, _client2$4, client);
|
|
1510
2263
|
}
|
|
1511
2264
|
/**
|
|
1512
2265
|
* Clones the transaction
|
|
1513
2266
|
*/
|
|
1514
2267
|
clone() {
|
|
1515
|
-
return new
|
|
2268
|
+
return new _ObservableTransaction2([...this.operations], __privateGet$6(this, _client2$4), this.trxId);
|
|
1516
2269
|
}
|
|
1517
2270
|
commit(options) {
|
|
1518
|
-
if (!this
|
|
2271
|
+
if (!__privateGet$6(this, _client2$4))
|
|
1519
2272
|
throw new Error(
|
|
1520
2273
|
"No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
|
|
1521
2274
|
);
|
|
1522
|
-
return this
|
|
2275
|
+
return __privateGet$6(this, _client2$4).mutate(
|
|
1523
2276
|
this.serialize(),
|
|
1524
2277
|
Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
|
|
1525
2278
|
);
|
|
@@ -1529,14 +2282,16 @@ ${selectionOpts}`);
|
|
|
1529
2282
|
if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof ObservablePatch)
|
|
1530
2283
|
return this._add({ patch: patchOrDocumentId.serialize() });
|
|
1531
2284
|
if (isBuilder) {
|
|
1532
|
-
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, this
|
|
2285
|
+
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$6(this, _client2$4)));
|
|
1533
2286
|
if (!(patch instanceof ObservablePatch))
|
|
1534
2287
|
throw new Error("function passed to `patch()` must return the patch");
|
|
1535
2288
|
return this._add({ patch: patch.serialize() });
|
|
1536
2289
|
}
|
|
1537
2290
|
return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
|
|
1538
2291
|
}
|
|
1539
|
-
}
|
|
2292
|
+
};
|
|
2293
|
+
_client2$4 = /* @__PURE__ */ new WeakMap();
|
|
2294
|
+
let ObservableTransaction = _ObservableTransaction;
|
|
1540
2295
|
const BASE_URL = "https://www.sanity.io/help/";
|
|
1541
2296
|
function generateHelpUrl(slug) {
|
|
1542
2297
|
return BASE_URL + slug;
|
|
@@ -1700,14 +2455,24 @@ ${selectionOpts}`);
|
|
|
1700
2455
|
) : $request.pipe(map(mapResponse));
|
|
1701
2456
|
}
|
|
1702
2457
|
function _getDocument(client, httpRequest, id, opts = {}) {
|
|
1703
|
-
const options = {
|
|
2458
|
+
const options = {
|
|
2459
|
+
uri: _getDataUrl(client, "doc", id),
|
|
2460
|
+
json: !0,
|
|
2461
|
+
tag: opts.tag,
|
|
2462
|
+
signal: opts.signal
|
|
2463
|
+
};
|
|
1704
2464
|
return _requestObservable(client, httpRequest, options).pipe(
|
|
1705
2465
|
filter(isResponse),
|
|
1706
2466
|
map((event) => event.body.documents && event.body.documents[0])
|
|
1707
2467
|
);
|
|
1708
2468
|
}
|
|
1709
2469
|
function _getDocuments(client, httpRequest, ids, opts = {}) {
|
|
1710
|
-
const options = {
|
|
2470
|
+
const options = {
|
|
2471
|
+
uri: _getDataUrl(client, "doc", ids.join(",")),
|
|
2472
|
+
json: !0,
|
|
2473
|
+
tag: opts.tag,
|
|
2474
|
+
signal: opts.signal
|
|
2475
|
+
};
|
|
1711
2476
|
return _requestObservable(client, httpRequest, options).pipe(
|
|
1712
2477
|
filter(isResponse),
|
|
1713
2478
|
map((event) => {
|
|
@@ -1791,11 +2556,12 @@ ${selectionOpts}`);
|
|
|
1791
2556
|
return _dataRequest(client, httpRequest, "mutate", { mutations: [mutation] }, opts);
|
|
1792
2557
|
}
|
|
1793
2558
|
function _requestObservable(client, httpRequest, options) {
|
|
2559
|
+
var _a, _b;
|
|
1794
2560
|
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;
|
|
1795
|
-
let useCdn = (options.useCdn
|
|
2561
|
+
let useCdn = ((_a = options.useCdn) != null ? _a : config.useCdn) && canUseCdn;
|
|
1796
2562
|
const tag = options.tag && config.requestTagPrefix ? [config.requestTagPrefix, options.tag].join(".") : options.tag || config.requestTagPrefix;
|
|
1797
2563
|
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) {
|
|
1798
|
-
const resultSourceMap = options.resultSourceMap
|
|
2564
|
+
const resultSourceMap = (_b = options.resultSourceMap) != null ? _b : config.resultSourceMap;
|
|
1799
2565
|
resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
|
|
1800
2566
|
const perspective = options.perspective || config.perspective;
|
|
1801
2567
|
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 });
|
|
@@ -1839,29 +2605,36 @@ ${selectionOpts}`);
|
|
|
1839
2605
|
}
|
|
1840
2606
|
const isDomExceptionSupported = !!globalThis.DOMException;
|
|
1841
2607
|
function _createAbortError(signal) {
|
|
2608
|
+
var _a, _b;
|
|
1842
2609
|
if (isDomExceptionSupported)
|
|
1843
|
-
return new DOMException(signal
|
|
1844
|
-
const error = new Error(signal
|
|
2610
|
+
return new DOMException((_a = signal == null ? void 0 : signal.reason) != null ? _a : "The operation was aborted.", "AbortError");
|
|
2611
|
+
const error = new Error((_b = signal == null ? void 0 : signal.reason) != null ? _b : "The operation was aborted.");
|
|
1845
2612
|
return error.name = "AbortError", error;
|
|
1846
2613
|
}
|
|
2614
|
+
var __accessCheck$5 = (obj, member, msg) => {
|
|
2615
|
+
if (!member.has(obj))
|
|
2616
|
+
throw TypeError("Cannot " + msg);
|
|
2617
|
+
}, __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) => {
|
|
2618
|
+
if (member.has(obj))
|
|
2619
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
2620
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
2621
|
+
}, __privateSet$5 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value), _client$4, _httpRequest$4;
|
|
1847
2622
|
class ObservableAssetsClient {
|
|
1848
|
-
#client;
|
|
1849
|
-
#httpRequest;
|
|
1850
2623
|
constructor(client, httpRequest) {
|
|
1851
|
-
this
|
|
2624
|
+
__privateAdd$5(this, _client$4, void 0), __privateAdd$5(this, _httpRequest$4, void 0), __privateSet$5(this, _client$4, client), __privateSet$5(this, _httpRequest$4, httpRequest);
|
|
1852
2625
|
}
|
|
1853
2626
|
upload(assetType, body, options) {
|
|
1854
|
-
return _upload(this
|
|
2627
|
+
return _upload(__privateGet$5(this, _client$4), __privateGet$5(this, _httpRequest$4), assetType, body, options);
|
|
1855
2628
|
}
|
|
1856
2629
|
}
|
|
2630
|
+
_client$4 = /* @__PURE__ */ new WeakMap(), _httpRequest$4 = /* @__PURE__ */ new WeakMap();
|
|
2631
|
+
var _client2$3, _httpRequest2$4;
|
|
1857
2632
|
class AssetsClient {
|
|
1858
|
-
#client;
|
|
1859
|
-
#httpRequest;
|
|
1860
2633
|
constructor(client, httpRequest) {
|
|
1861
|
-
this
|
|
2634
|
+
__privateAdd$5(this, _client2$3, void 0), __privateAdd$5(this, _httpRequest2$4, void 0), __privateSet$5(this, _client2$3, client), __privateSet$5(this, _httpRequest2$4, httpRequest);
|
|
1862
2635
|
}
|
|
1863
2636
|
upload(assetType, body, options) {
|
|
1864
|
-
const observable2 = _upload(this
|
|
2637
|
+
const observable2 = _upload(__privateGet$5(this, _client2$3), __privateGet$5(this, _httpRequest2$4), assetType, body, options);
|
|
1865
2638
|
return lastValueFrom(
|
|
1866
2639
|
observable2.pipe(
|
|
1867
2640
|
filter((event) => event.type === "response"),
|
|
@@ -1872,6 +2645,7 @@ ${selectionOpts}`);
|
|
|
1872
2645
|
);
|
|
1873
2646
|
}
|
|
1874
2647
|
}
|
|
2648
|
+
_client2$3 = /* @__PURE__ */ new WeakMap(), _httpRequest2$4 = /* @__PURE__ */ new WeakMap();
|
|
1875
2649
|
function _upload(client, httpRequest, assetType, body, opts = {}) {
|
|
1876
2650
|
validateAssetType(assetType);
|
|
1877
2651
|
let meta = opts.extract || void 0;
|
|
@@ -1980,22 +2754,30 @@ ${selectionOpts}`);
|
|
|
1980
2754
|
function extractErrorMessage(err) {
|
|
1981
2755
|
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";
|
|
1982
2756
|
}
|
|
2757
|
+
var __accessCheck$4 = (obj, member, msg) => {
|
|
2758
|
+
if (!member.has(obj))
|
|
2759
|
+
throw TypeError("Cannot " + msg);
|
|
2760
|
+
}, __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) => {
|
|
2761
|
+
if (member.has(obj))
|
|
2762
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
2763
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
2764
|
+
}, __privateSet$4 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
|
|
1983
2765
|
const requiredApiVersion = "2021-03-26";
|
|
2766
|
+
var _client$3;
|
|
1984
2767
|
class LiveClient {
|
|
1985
|
-
#client;
|
|
1986
2768
|
constructor(client) {
|
|
1987
|
-
this
|
|
2769
|
+
__privateAdd$4(this, _client$3, void 0), __privateSet$4(this, _client$3, client);
|
|
1988
2770
|
}
|
|
1989
2771
|
/**
|
|
1990
2772
|
* Requires `apiVersion` to be `2021-03-26` or later.
|
|
1991
2773
|
*/
|
|
1992
2774
|
events() {
|
|
1993
|
-
const apiVersion = this
|
|
2775
|
+
const apiVersion = __privateGet$4(this, _client$3).config().apiVersion.replace(/^v/, "");
|
|
1994
2776
|
if (apiVersion !== "X" && apiVersion < requiredApiVersion)
|
|
1995
2777
|
throw new Error(
|
|
1996
2778
|
`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.`
|
|
1997
2779
|
);
|
|
1998
|
-
const path = _getDataUrl(this
|
|
2780
|
+
const path = _getDataUrl(__privateGet$4(this, _client$3), "live/events"), url = new URL(__privateGet$4(this, _client$3).getUrl(path, !1)), listenFor = ["restart", "message"];
|
|
1999
2781
|
return new Observable((observer) => {
|
|
2000
2782
|
let es, reconnectTimer, stopped = !1, unsubscribed = !1;
|
|
2001
2783
|
open();
|
|
@@ -2044,6 +2826,7 @@ ${selectionOpts}`);
|
|
|
2044
2826
|
});
|
|
2045
2827
|
}
|
|
2046
2828
|
}
|
|
2829
|
+
_client$3 = /* @__PURE__ */ new WeakMap();
|
|
2047
2830
|
function parseEvent(event) {
|
|
2048
2831
|
try {
|
|
2049
2832
|
const data = event.data && JSON.parse(event.data) || {};
|
|
@@ -2052,11 +2835,17 @@ ${selectionOpts}`);
|
|
|
2052
2835
|
return err;
|
|
2053
2836
|
}
|
|
2054
2837
|
}
|
|
2838
|
+
var __accessCheck$3 = (obj, member, msg) => {
|
|
2839
|
+
if (!member.has(obj))
|
|
2840
|
+
throw TypeError("Cannot " + msg);
|
|
2841
|
+
}, __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) => {
|
|
2842
|
+
if (member.has(obj))
|
|
2843
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
2844
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
2845
|
+
}, __privateSet$3 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value), _client$2, _httpRequest$3;
|
|
2055
2846
|
class ObservableDatasetsClient {
|
|
2056
|
-
#client;
|
|
2057
|
-
#httpRequest;
|
|
2058
2847
|
constructor(client, httpRequest) {
|
|
2059
|
-
this
|
|
2848
|
+
__privateAdd$3(this, _client$2, void 0), __privateAdd$3(this, _httpRequest$3, void 0), __privateSet$3(this, _client$2, client), __privateSet$3(this, _httpRequest$3, httpRequest);
|
|
2060
2849
|
}
|
|
2061
2850
|
/**
|
|
2062
2851
|
* Create a new dataset with the given name
|
|
@@ -2065,7 +2854,7 @@ ${selectionOpts}`);
|
|
|
2065
2854
|
* @param options - Options for the dataset
|
|
2066
2855
|
*/
|
|
2067
2856
|
create(name, options) {
|
|
2068
|
-
return _modify(this
|
|
2857
|
+
return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "PUT", name, options);
|
|
2069
2858
|
}
|
|
2070
2859
|
/**
|
|
2071
2860
|
* Edit a dataset with the given name
|
|
@@ -2074,7 +2863,7 @@ ${selectionOpts}`);
|
|
|
2074
2863
|
* @param options - New options for the dataset
|
|
2075
2864
|
*/
|
|
2076
2865
|
edit(name, options) {
|
|
2077
|
-
return _modify(this
|
|
2866
|
+
return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "PATCH", name, options);
|
|
2078
2867
|
}
|
|
2079
2868
|
/**
|
|
2080
2869
|
* Delete a dataset with the given name
|
|
@@ -2082,23 +2871,23 @@ ${selectionOpts}`);
|
|
|
2082
2871
|
* @param name - Name of the dataset to delete
|
|
2083
2872
|
*/
|
|
2084
2873
|
delete(name) {
|
|
2085
|
-
return _modify(this
|
|
2874
|
+
return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "DELETE", name);
|
|
2086
2875
|
}
|
|
2087
2876
|
/**
|
|
2088
2877
|
* Fetch a list of datasets for the configured project
|
|
2089
2878
|
*/
|
|
2090
2879
|
list() {
|
|
2091
|
-
return _request(this
|
|
2880
|
+
return _request(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), {
|
|
2092
2881
|
uri: "/datasets",
|
|
2093
2882
|
tag: null
|
|
2094
2883
|
});
|
|
2095
2884
|
}
|
|
2096
2885
|
}
|
|
2886
|
+
_client$2 = /* @__PURE__ */ new WeakMap(), _httpRequest$3 = /* @__PURE__ */ new WeakMap();
|
|
2887
|
+
var _client2$2, _httpRequest2$3;
|
|
2097
2888
|
class DatasetsClient {
|
|
2098
|
-
#client;
|
|
2099
|
-
#httpRequest;
|
|
2100
2889
|
constructor(client, httpRequest) {
|
|
2101
|
-
this
|
|
2890
|
+
__privateAdd$3(this, _client2$2, void 0), __privateAdd$3(this, _httpRequest2$3, void 0), __privateSet$3(this, _client2$2, client), __privateSet$3(this, _httpRequest2$3, httpRequest);
|
|
2102
2891
|
}
|
|
2103
2892
|
/**
|
|
2104
2893
|
* Create a new dataset with the given name
|
|
@@ -2108,7 +2897,7 @@ ${selectionOpts}`);
|
|
|
2108
2897
|
*/
|
|
2109
2898
|
create(name, options) {
|
|
2110
2899
|
return lastValueFrom(
|
|
2111
|
-
_modify(this
|
|
2900
|
+
_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PUT", name, options)
|
|
2112
2901
|
);
|
|
2113
2902
|
}
|
|
2114
2903
|
/**
|
|
@@ -2119,7 +2908,7 @@ ${selectionOpts}`);
|
|
|
2119
2908
|
*/
|
|
2120
2909
|
edit(name, options) {
|
|
2121
2910
|
return lastValueFrom(
|
|
2122
|
-
_modify(this
|
|
2911
|
+
_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PATCH", name, options)
|
|
2123
2912
|
);
|
|
2124
2913
|
}
|
|
2125
2914
|
/**
|
|
@@ -2128,17 +2917,18 @@ ${selectionOpts}`);
|
|
|
2128
2917
|
* @param name - Name of the dataset to delete
|
|
2129
2918
|
*/
|
|
2130
2919
|
delete(name) {
|
|
2131
|
-
return lastValueFrom(_modify(this
|
|
2920
|
+
return lastValueFrom(_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "DELETE", name));
|
|
2132
2921
|
}
|
|
2133
2922
|
/**
|
|
2134
2923
|
* Fetch a list of datasets for the configured project
|
|
2135
2924
|
*/
|
|
2136
2925
|
list() {
|
|
2137
2926
|
return lastValueFrom(
|
|
2138
|
-
_request(this
|
|
2927
|
+
_request(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), { uri: "/datasets", tag: null })
|
|
2139
2928
|
);
|
|
2140
2929
|
}
|
|
2141
2930
|
}
|
|
2931
|
+
_client2$2 = /* @__PURE__ */ new WeakMap(), _httpRequest2$3 = /* @__PURE__ */ new WeakMap();
|
|
2142
2932
|
function _modify(client, httpRequest, method, name, options) {
|
|
2143
2933
|
return dataset(name), _request(client, httpRequest, {
|
|
2144
2934
|
method,
|
|
@@ -2147,15 +2937,21 @@ ${selectionOpts}`);
|
|
|
2147
2937
|
tag: null
|
|
2148
2938
|
});
|
|
2149
2939
|
}
|
|
2940
|
+
var __accessCheck$2 = (obj, member, msg) => {
|
|
2941
|
+
if (!member.has(obj))
|
|
2942
|
+
throw TypeError("Cannot " + msg);
|
|
2943
|
+
}, __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) => {
|
|
2944
|
+
if (member.has(obj))
|
|
2945
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
2946
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
2947
|
+
}, __privateSet$2 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), member.set(obj, value), value), _client$1, _httpRequest$2;
|
|
2150
2948
|
class ObservableProjectsClient {
|
|
2151
|
-
#client;
|
|
2152
|
-
#httpRequest;
|
|
2153
2949
|
constructor(client, httpRequest) {
|
|
2154
|
-
this
|
|
2950
|
+
__privateAdd$2(this, _client$1, void 0), __privateAdd$2(this, _httpRequest$2, void 0), __privateSet$2(this, _client$1, client), __privateSet$2(this, _httpRequest$2, httpRequest);
|
|
2155
2951
|
}
|
|
2156
2952
|
list(options) {
|
|
2157
|
-
const uri = options
|
|
2158
|
-
return _request(this
|
|
2953
|
+
const uri = (options == null ? void 0 : options.includeMembers) === !1 ? "/projects?includeMembers=false" : "/projects";
|
|
2954
|
+
return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), { uri });
|
|
2159
2955
|
}
|
|
2160
2956
|
/**
|
|
2161
2957
|
* Fetch a project by project ID
|
|
@@ -2163,18 +2959,18 @@ ${selectionOpts}`);
|
|
|
2163
2959
|
* @param projectId - ID of the project to fetch
|
|
2164
2960
|
*/
|
|
2165
2961
|
getById(projectId2) {
|
|
2166
|
-
return _request(this
|
|
2962
|
+
return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), { uri: `/projects/${projectId2}` });
|
|
2167
2963
|
}
|
|
2168
2964
|
}
|
|
2965
|
+
_client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */ new WeakMap();
|
|
2966
|
+
var _client2$1, _httpRequest2$2;
|
|
2169
2967
|
class ProjectsClient {
|
|
2170
|
-
#client;
|
|
2171
|
-
#httpRequest;
|
|
2172
2968
|
constructor(client, httpRequest) {
|
|
2173
|
-
this
|
|
2969
|
+
__privateAdd$2(this, _client2$1, void 0), __privateAdd$2(this, _httpRequest2$2, void 0), __privateSet$2(this, _client2$1, client), __privateSet$2(this, _httpRequest2$2, httpRequest);
|
|
2174
2970
|
}
|
|
2175
2971
|
list(options) {
|
|
2176
|
-
const uri = options
|
|
2177
|
-
return lastValueFrom(_request(this
|
|
2972
|
+
const uri = (options == null ? void 0 : options.includeMembers) === !1 ? "/projects?includeMembers=false" : "/projects";
|
|
2973
|
+
return lastValueFrom(_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), { uri }));
|
|
2178
2974
|
}
|
|
2179
2975
|
/**
|
|
2180
2976
|
* Fetch a project by project ID
|
|
@@ -2183,15 +2979,22 @@ ${selectionOpts}`);
|
|
|
2183
2979
|
*/
|
|
2184
2980
|
getById(projectId2) {
|
|
2185
2981
|
return lastValueFrom(
|
|
2186
|
-
_request(this
|
|
2982
|
+
_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), { uri: `/projects/${projectId2}` })
|
|
2187
2983
|
);
|
|
2188
2984
|
}
|
|
2189
2985
|
}
|
|
2986
|
+
_client2$1 = /* @__PURE__ */ new WeakMap(), _httpRequest2$2 = /* @__PURE__ */ new WeakMap();
|
|
2987
|
+
var __accessCheck$1 = (obj, member, msg) => {
|
|
2988
|
+
if (!member.has(obj))
|
|
2989
|
+
throw TypeError("Cannot " + msg);
|
|
2990
|
+
}, __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) => {
|
|
2991
|
+
if (member.has(obj))
|
|
2992
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
2993
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
2994
|
+
}, __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value), _client, _httpRequest$1;
|
|
2190
2995
|
class ObservableUsersClient {
|
|
2191
|
-
#client;
|
|
2192
|
-
#httpRequest;
|
|
2193
2996
|
constructor(client, httpRequest) {
|
|
2194
|
-
this
|
|
2997
|
+
__privateAdd$1(this, _client, void 0), __privateAdd$1(this, _httpRequest$1, void 0), __privateSet$1(this, _client, client), __privateSet$1(this, _httpRequest$1, httpRequest);
|
|
2195
2998
|
}
|
|
2196
2999
|
/**
|
|
2197
3000
|
* Fetch a user by user ID
|
|
@@ -2200,17 +3003,17 @@ ${selectionOpts}`);
|
|
|
2200
3003
|
*/
|
|
2201
3004
|
getById(id) {
|
|
2202
3005
|
return _request(
|
|
2203
|
-
this
|
|
2204
|
-
this
|
|
3006
|
+
__privateGet$1(this, _client),
|
|
3007
|
+
__privateGet$1(this, _httpRequest$1),
|
|
2205
3008
|
{ uri: `/users/${id}` }
|
|
2206
3009
|
);
|
|
2207
3010
|
}
|
|
2208
3011
|
}
|
|
3012
|
+
_client = /* @__PURE__ */ new WeakMap(), _httpRequest$1 = /* @__PURE__ */ new WeakMap();
|
|
3013
|
+
var _client2, _httpRequest2$1;
|
|
2209
3014
|
class UsersClient {
|
|
2210
|
-
#client;
|
|
2211
|
-
#httpRequest;
|
|
2212
3015
|
constructor(client, httpRequest) {
|
|
2213
|
-
this
|
|
3016
|
+
__privateAdd$1(this, _client2, void 0), __privateAdd$1(this, _httpRequest2$1, void 0), __privateSet$1(this, _client2, client), __privateSet$1(this, _httpRequest2$1, httpRequest);
|
|
2214
3017
|
}
|
|
2215
3018
|
/**
|
|
2216
3019
|
* Fetch a user by user ID
|
|
@@ -2219,44 +3022,39 @@ ${selectionOpts}`);
|
|
|
2219
3022
|
*/
|
|
2220
3023
|
getById(id) {
|
|
2221
3024
|
return lastValueFrom(
|
|
2222
|
-
_request(this
|
|
3025
|
+
_request(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), {
|
|
2223
3026
|
uri: `/users/${id}`
|
|
2224
3027
|
})
|
|
2225
3028
|
);
|
|
2226
3029
|
}
|
|
2227
3030
|
}
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
#httpRequest;
|
|
2239
|
-
/**
|
|
2240
|
-
* Instance properties
|
|
2241
|
-
*/
|
|
2242
|
-
listen = _listen;
|
|
3031
|
+
_client2 = /* @__PURE__ */ new WeakMap(), _httpRequest2$1 = /* @__PURE__ */ new WeakMap();
|
|
3032
|
+
var __defProp = Object.defineProperty, __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField = (obj, key, value) => (__defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value), value), __accessCheck = (obj, member, msg) => {
|
|
3033
|
+
if (!member.has(obj))
|
|
3034
|
+
throw TypeError("Cannot " + msg);
|
|
3035
|
+
}, __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd = (obj, member, value) => {
|
|
3036
|
+
if (member.has(obj))
|
|
3037
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
3038
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
3039
|
+
}, __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value), _clientConfig, _httpRequest;
|
|
3040
|
+
const _ObservableSanityClient = class _ObservableSanityClient2 {
|
|
2243
3041
|
constructor(httpRequest, config = defaultConfig) {
|
|
2244
|
-
this.config(config), this
|
|
3042
|
+
__publicField(this, "assets"), __publicField(this, "datasets"), __publicField(this, "live"), __publicField(this, "projects"), __publicField(this, "users"), __privateAdd(this, _clientConfig, void 0), __privateAdd(this, _httpRequest, void 0), __publicField(this, "listen", _listen), this.config(config), __privateSet(this, _httpRequest, httpRequest), this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest)), this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest)), this.live = new LiveClient(this), this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest)), this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
|
|
2245
3043
|
}
|
|
2246
3044
|
/**
|
|
2247
3045
|
* Clone the client - returns a new instance
|
|
2248
3046
|
*/
|
|
2249
3047
|
clone() {
|
|
2250
|
-
return new
|
|
3048
|
+
return new _ObservableSanityClient2(__privateGet(this, _httpRequest), this.config());
|
|
2251
3049
|
}
|
|
2252
3050
|
config(newConfig) {
|
|
2253
3051
|
if (newConfig === void 0)
|
|
2254
|
-
return { ...this
|
|
2255
|
-
if (this
|
|
3052
|
+
return { ...__privateGet(this, _clientConfig) };
|
|
3053
|
+
if (__privateGet(this, _clientConfig) && __privateGet(this, _clientConfig).allowReconfigure === !1)
|
|
2256
3054
|
throw new Error(
|
|
2257
3055
|
"Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
|
|
2258
3056
|
);
|
|
2259
|
-
return this
|
|
3057
|
+
return __privateSet(this, _clientConfig, initConfig(newConfig, __privateGet(this, _clientConfig) || {})), this;
|
|
2260
3058
|
}
|
|
2261
3059
|
/**
|
|
2262
3060
|
* Clone the client with a new (partial) configuration.
|
|
@@ -2265,20 +3063,20 @@ ${selectionOpts}`);
|
|
|
2265
3063
|
*/
|
|
2266
3064
|
withConfig(newConfig) {
|
|
2267
3065
|
const thisConfig = this.config();
|
|
2268
|
-
return new
|
|
3066
|
+
return new _ObservableSanityClient2(__privateGet(this, _httpRequest), {
|
|
2269
3067
|
...thisConfig,
|
|
2270
3068
|
...newConfig,
|
|
2271
3069
|
stega: {
|
|
2272
3070
|
...thisConfig.stega || {},
|
|
2273
|
-
...typeof newConfig
|
|
3071
|
+
...typeof (newConfig == null ? void 0 : newConfig.stega) == "boolean" ? { enabled: newConfig.stega } : (newConfig == null ? void 0 : newConfig.stega) || {}
|
|
2274
3072
|
}
|
|
2275
3073
|
});
|
|
2276
3074
|
}
|
|
2277
3075
|
fetch(query, params, options) {
|
|
2278
3076
|
return _fetch(
|
|
2279
3077
|
this,
|
|
2280
|
-
this
|
|
2281
|
-
this
|
|
3078
|
+
__privateGet(this, _httpRequest),
|
|
3079
|
+
__privateGet(this, _clientConfig).stega,
|
|
2282
3080
|
query,
|
|
2283
3081
|
params,
|
|
2284
3082
|
options
|
|
@@ -2291,7 +3089,7 @@ ${selectionOpts}`);
|
|
|
2291
3089
|
* @param options - Request options
|
|
2292
3090
|
*/
|
|
2293
3091
|
getDocument(id, options) {
|
|
2294
|
-
return _getDocument(this, this
|
|
3092
|
+
return _getDocument(this, __privateGet(this, _httpRequest), id, options);
|
|
2295
3093
|
}
|
|
2296
3094
|
/**
|
|
2297
3095
|
* Fetch multiple documents in one request.
|
|
@@ -2303,22 +3101,22 @@ ${selectionOpts}`);
|
|
|
2303
3101
|
* @param options - Request options
|
|
2304
3102
|
*/
|
|
2305
3103
|
getDocuments(ids, options) {
|
|
2306
|
-
return _getDocuments(this, this
|
|
3104
|
+
return _getDocuments(this, __privateGet(this, _httpRequest), ids, options);
|
|
2307
3105
|
}
|
|
2308
3106
|
create(document, options) {
|
|
2309
|
-
return _create(this, this
|
|
3107
|
+
return _create(this, __privateGet(this, _httpRequest), document, "create", options);
|
|
2310
3108
|
}
|
|
2311
3109
|
createIfNotExists(document, options) {
|
|
2312
|
-
return _createIfNotExists(this, this
|
|
3110
|
+
return _createIfNotExists(this, __privateGet(this, _httpRequest), document, options);
|
|
2313
3111
|
}
|
|
2314
3112
|
createOrReplace(document, options) {
|
|
2315
|
-
return _createOrReplace(this, this
|
|
3113
|
+
return _createOrReplace(this, __privateGet(this, _httpRequest), document, options);
|
|
2316
3114
|
}
|
|
2317
3115
|
delete(selection, options) {
|
|
2318
|
-
return _delete(this, this
|
|
3116
|
+
return _delete(this, __privateGet(this, _httpRequest), selection, options);
|
|
2319
3117
|
}
|
|
2320
3118
|
mutate(operations, options) {
|
|
2321
|
-
return _mutate(this, this
|
|
3119
|
+
return _mutate(this, __privateGet(this, _httpRequest), operations, options);
|
|
2322
3120
|
}
|
|
2323
3121
|
/**
|
|
2324
3122
|
* Create a new buildable patch of operations to perform
|
|
@@ -2345,7 +3143,7 @@ ${selectionOpts}`);
|
|
|
2345
3143
|
* @param options - Action options
|
|
2346
3144
|
*/
|
|
2347
3145
|
action(operations, options) {
|
|
2348
|
-
return _action(this, this
|
|
3146
|
+
return _action(this, __privateGet(this, _httpRequest), operations, options);
|
|
2349
3147
|
}
|
|
2350
3148
|
/**
|
|
2351
3149
|
* Perform an HTTP request against the Sanity API
|
|
@@ -2353,7 +3151,7 @@ ${selectionOpts}`);
|
|
|
2353
3151
|
* @param options - Request options
|
|
2354
3152
|
*/
|
|
2355
3153
|
request(options) {
|
|
2356
|
-
return _request(this, this
|
|
3154
|
+
return _request(this, __privateGet(this, _httpRequest), options);
|
|
2357
3155
|
}
|
|
2358
3156
|
/**
|
|
2359
3157
|
* Get a Sanity API URL for the URI provided
|
|
@@ -2373,43 +3171,28 @@ ${selectionOpts}`);
|
|
|
2373
3171
|
getDataUrl(operation, path) {
|
|
2374
3172
|
return _getDataUrl(this, operation, path);
|
|
2375
3173
|
}
|
|
2376
|
-
}
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
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;
|
|
3174
|
+
};
|
|
3175
|
+
_clientConfig = /* @__PURE__ */ new WeakMap(), _httpRequest = /* @__PURE__ */ new WeakMap();
|
|
3176
|
+
let ObservableSanityClient = _ObservableSanityClient;
|
|
3177
|
+
var _clientConfig2, _httpRequest2;
|
|
3178
|
+
const _SanityClient = class _SanityClient2 {
|
|
2396
3179
|
constructor(httpRequest, config = defaultConfig) {
|
|
2397
|
-
this.config(config), this
|
|
3180
|
+
__publicField(this, "assets"), __publicField(this, "datasets"), __publicField(this, "live"), __publicField(this, "projects"), __publicField(this, "users"), __publicField(this, "observable"), __privateAdd(this, _clientConfig2, void 0), __privateAdd(this, _httpRequest2, void 0), __publicField(this, "listen", _listen), this.config(config), __privateSet(this, _httpRequest2, httpRequest), this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2)), this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2)), this.live = new LiveClient(this), this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2)), this.users = new UsersClient(this, __privateGet(this, _httpRequest2)), this.observable = new ObservableSanityClient(httpRequest, config);
|
|
2398
3181
|
}
|
|
2399
3182
|
/**
|
|
2400
3183
|
* Clone the client - returns a new instance
|
|
2401
3184
|
*/
|
|
2402
3185
|
clone() {
|
|
2403
|
-
return new
|
|
3186
|
+
return new _SanityClient2(__privateGet(this, _httpRequest2), this.config());
|
|
2404
3187
|
}
|
|
2405
3188
|
config(newConfig) {
|
|
2406
3189
|
if (newConfig === void 0)
|
|
2407
|
-
return { ...this
|
|
2408
|
-
if (this
|
|
3190
|
+
return { ...__privateGet(this, _clientConfig2) };
|
|
3191
|
+
if (__privateGet(this, _clientConfig2) && __privateGet(this, _clientConfig2).allowReconfigure === !1)
|
|
2409
3192
|
throw new Error(
|
|
2410
3193
|
"Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
|
|
2411
3194
|
);
|
|
2412
|
-
return this.observable && this.observable.config(newConfig), this
|
|
3195
|
+
return this.observable && this.observable.config(newConfig), __privateSet(this, _clientConfig2, initConfig(newConfig, __privateGet(this, _clientConfig2) || {})), this;
|
|
2413
3196
|
}
|
|
2414
3197
|
/**
|
|
2415
3198
|
* Clone the client with a new (partial) configuration.
|
|
@@ -2418,12 +3201,12 @@ ${selectionOpts}`);
|
|
|
2418
3201
|
*/
|
|
2419
3202
|
withConfig(newConfig) {
|
|
2420
3203
|
const thisConfig = this.config();
|
|
2421
|
-
return new
|
|
3204
|
+
return new _SanityClient2(__privateGet(this, _httpRequest2), {
|
|
2422
3205
|
...thisConfig,
|
|
2423
3206
|
...newConfig,
|
|
2424
3207
|
stega: {
|
|
2425
3208
|
...thisConfig.stega || {},
|
|
2426
|
-
...typeof newConfig
|
|
3209
|
+
...typeof (newConfig == null ? void 0 : newConfig.stega) == "boolean" ? { enabled: newConfig.stega } : (newConfig == null ? void 0 : newConfig.stega) || {}
|
|
2427
3210
|
}
|
|
2428
3211
|
});
|
|
2429
3212
|
}
|
|
@@ -2431,8 +3214,8 @@ ${selectionOpts}`);
|
|
|
2431
3214
|
return lastValueFrom(
|
|
2432
3215
|
_fetch(
|
|
2433
3216
|
this,
|
|
2434
|
-
this
|
|
2435
|
-
this
|
|
3217
|
+
__privateGet(this, _httpRequest2),
|
|
3218
|
+
__privateGet(this, _clientConfig2).stega,
|
|
2436
3219
|
query,
|
|
2437
3220
|
params,
|
|
2438
3221
|
options
|
|
@@ -2446,7 +3229,7 @@ ${selectionOpts}`);
|
|
|
2446
3229
|
* @param options - Request options
|
|
2447
3230
|
*/
|
|
2448
3231
|
getDocument(id, options) {
|
|
2449
|
-
return lastValueFrom(_getDocument(this, this
|
|
3232
|
+
return lastValueFrom(_getDocument(this, __privateGet(this, _httpRequest2), id, options));
|
|
2450
3233
|
}
|
|
2451
3234
|
/**
|
|
2452
3235
|
* Fetch multiple documents in one request.
|
|
@@ -2458,28 +3241,28 @@ ${selectionOpts}`);
|
|
|
2458
3241
|
* @param options - Request options
|
|
2459
3242
|
*/
|
|
2460
3243
|
getDocuments(ids, options) {
|
|
2461
|
-
return lastValueFrom(_getDocuments(this, this
|
|
3244
|
+
return lastValueFrom(_getDocuments(this, __privateGet(this, _httpRequest2), ids, options));
|
|
2462
3245
|
}
|
|
2463
3246
|
create(document, options) {
|
|
2464
3247
|
return lastValueFrom(
|
|
2465
|
-
_create(this, this
|
|
3248
|
+
_create(this, __privateGet(this, _httpRequest2), document, "create", options)
|
|
2466
3249
|
);
|
|
2467
3250
|
}
|
|
2468
3251
|
createIfNotExists(document, options) {
|
|
2469
3252
|
return lastValueFrom(
|
|
2470
|
-
_createIfNotExists(this, this
|
|
3253
|
+
_createIfNotExists(this, __privateGet(this, _httpRequest2), document, options)
|
|
2471
3254
|
);
|
|
2472
3255
|
}
|
|
2473
3256
|
createOrReplace(document, options) {
|
|
2474
3257
|
return lastValueFrom(
|
|
2475
|
-
_createOrReplace(this, this
|
|
3258
|
+
_createOrReplace(this, __privateGet(this, _httpRequest2), document, options)
|
|
2476
3259
|
);
|
|
2477
3260
|
}
|
|
2478
3261
|
delete(selection, options) {
|
|
2479
|
-
return lastValueFrom(_delete(this, this
|
|
3262
|
+
return lastValueFrom(_delete(this, __privateGet(this, _httpRequest2), selection, options));
|
|
2480
3263
|
}
|
|
2481
3264
|
mutate(operations, options) {
|
|
2482
|
-
return lastValueFrom(_mutate(this, this
|
|
3265
|
+
return lastValueFrom(_mutate(this, __privateGet(this, _httpRequest2), operations, options));
|
|
2483
3266
|
}
|
|
2484
3267
|
/**
|
|
2485
3268
|
* Create a new buildable patch of operations to perform
|
|
@@ -2507,7 +3290,7 @@ ${selectionOpts}`);
|
|
|
2507
3290
|
* @param options - Action options
|
|
2508
3291
|
*/
|
|
2509
3292
|
action(operations, options) {
|
|
2510
|
-
return lastValueFrom(_action(this, this
|
|
3293
|
+
return lastValueFrom(_action(this, __privateGet(this, _httpRequest2), operations, options));
|
|
2511
3294
|
}
|
|
2512
3295
|
/**
|
|
2513
3296
|
* Perform a request against the Sanity API
|
|
@@ -2517,7 +3300,7 @@ ${selectionOpts}`);
|
|
|
2517
3300
|
* @returns Promise resolving to the response body
|
|
2518
3301
|
*/
|
|
2519
3302
|
request(options) {
|
|
2520
|
-
return lastValueFrom(_request(this, this
|
|
3303
|
+
return lastValueFrom(_request(this, __privateGet(this, _httpRequest2), options));
|
|
2521
3304
|
}
|
|
2522
3305
|
/**
|
|
2523
3306
|
* Perform an HTTP request a `/data` sub-endpoint
|
|
@@ -2530,7 +3313,7 @@ ${selectionOpts}`);
|
|
|
2530
3313
|
* @internal
|
|
2531
3314
|
*/
|
|
2532
3315
|
dataRequest(endpoint, body, options) {
|
|
2533
|
-
return lastValueFrom(_dataRequest(this, this
|
|
3316
|
+
return lastValueFrom(_dataRequest(this, __privateGet(this, _httpRequest2), endpoint, body, options));
|
|
2534
3317
|
}
|
|
2535
3318
|
/**
|
|
2536
3319
|
* Get a Sanity API URL for the URI provided
|
|
@@ -2550,7 +3333,9 @@ ${selectionOpts}`);
|
|
|
2550
3333
|
getDataUrl(operation, path) {
|
|
2551
3334
|
return _getDataUrl(this, operation, path);
|
|
2552
3335
|
}
|
|
2553
|
-
}
|
|
3336
|
+
};
|
|
3337
|
+
_clientConfig2 = /* @__PURE__ */ new WeakMap(), _httpRequest2 = /* @__PURE__ */ new WeakMap();
|
|
3338
|
+
let SanityClient = _SanityClient;
|
|
2554
3339
|
function defineCreateClientExports(envMiddleware2, ClassConstructor) {
|
|
2555
3340
|
const defaultRequester = defineHttpRequest(envMiddleware2);
|
|
2556
3341
|
return { requester: defaultRequester, createClient: (config) => new ClassConstructor(
|
|
@@ -2657,7 +3442,7 @@ ${selectionOpts}`);
|
|
|
2657
3442
|
});
|
|
2658
3443
|
}
|
|
2659
3444
|
function resolveMapping(resultPath, csm) {
|
|
2660
|
-
if (!csm
|
|
3445
|
+
if (!(csm != null && csm.mappings))
|
|
2661
3446
|
return;
|
|
2662
3447
|
const resultMappingPath = jsonPath(jsonPathToMappingPath(resultPath));
|
|
2663
3448
|
if (csm.mappings[resultMappingPath] !== void 0)
|
|
@@ -2816,20 +3601,21 @@ ${selectionOpts}`);
|
|
|
2816
3601
|
}
|
|
2817
3602
|
const TRUNCATE_LENGTH = 20;
|
|
2818
3603
|
function stegaEncodeSourceMap(result, resultSourceMap, config) {
|
|
3604
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2819
3605
|
const { filter, logger, enabled } = config;
|
|
2820
3606
|
if (!enabled) {
|
|
2821
3607
|
const msg = "config.enabled must be true, don't call this function otherwise";
|
|
2822
|
-
throw logger
|
|
3608
|
+
throw (_a = logger == null ? void 0 : logger.error) == null || _a.call(logger, `[@sanity/client]: ${msg}`, { result, resultSourceMap, config }), new TypeError(msg);
|
|
2823
3609
|
}
|
|
2824
3610
|
if (!resultSourceMap)
|
|
2825
|
-
return logger
|
|
3611
|
+
return (_b = logger == null ? void 0 : logger.error) == null || _b.call(logger, "[@sanity/client]: Missing Content Source Map from response body", {
|
|
2826
3612
|
result,
|
|
2827
3613
|
resultSourceMap,
|
|
2828
3614
|
config
|
|
2829
3615
|
}), result;
|
|
2830
3616
|
if (!config.studioUrl) {
|
|
2831
3617
|
const msg = "config.studioUrl must be defined";
|
|
2832
|
-
throw logger
|
|
3618
|
+
throw (_c = logger == null ? void 0 : logger.error) == null || _c.call(logger, `[@sanity/client]: ${msg}`, { result, resultSourceMap, config }), new TypeError(msg);
|
|
2833
3619
|
}
|
|
2834
3620
|
const report = {
|
|
2835
3621
|
encoded: [],
|
|
@@ -2876,15 +3662,16 @@ ${selectionOpts}`);
|
|
|
2876
3662
|
);
|
|
2877
3663
|
if (logger) {
|
|
2878
3664
|
const isSkipping = report.skipped.length, isEncoding = report.encoded.length;
|
|
2879
|
-
if ((isSkipping || isEncoding) && ((logger
|
|
3665
|
+
if ((isSkipping || isEncoding) && ((_d = (logger == null ? void 0 : logger.groupCollapsed) || logger.log) == null || _d("[@sanity/client]: Encoding source map into result"), (_e = logger.log) == null || _e.call(
|
|
3666
|
+
logger,
|
|
2880
3667
|
`[@sanity/client]: Paths encoded: ${report.encoded.length}, skipped: ${report.skipped.length}`
|
|
2881
|
-
)), report.encoded.length > 0 && (logger
|
|
3668
|
+
)), report.encoded.length > 0 && ((_f = logger == null ? void 0 : logger.log) == null || _f.call(logger, "[@sanity/client]: Table of encoded paths"), (_g = (logger == null ? void 0 : logger.table) || logger.log) == null || _g(report.encoded)), report.skipped.length > 0) {
|
|
2882
3669
|
const skipped = /* @__PURE__ */ new Set();
|
|
2883
3670
|
for (const { path } of report.skipped)
|
|
2884
3671
|
skipped.add(path.replace(reKeySegment, "0").replace(/\[\d+\]/g, "[]"));
|
|
2885
|
-
logger
|
|
3672
|
+
(_h = logger == null ? void 0 : logger.log) == null || _h.call(logger, "[@sanity/client]: List of skipped paths", [...skipped.values()]);
|
|
2886
3673
|
}
|
|
2887
|
-
(isSkipping || isEncoding) && logger
|
|
3674
|
+
(isSkipping || isEncoding) && ((_i = logger == null ? void 0 : logger.groupEnd) == null || _i.call(logger));
|
|
2888
3675
|
}
|
|
2889
3676
|
return resultWithStega;
|
|
2890
3677
|
}
|
|
@@ -3979,8 +4766,8 @@ ${selectionOpts}`);
|
|
|
3979
4766
|
exports.createClient = createClient;
|
|
3980
4767
|
exports.default = deprecatedCreateClient;
|
|
3981
4768
|
exports.requester = requester;
|
|
3982
|
-
exports.unstable__adapter =
|
|
3983
|
-
exports.unstable__environment =
|
|
4769
|
+
exports.unstable__adapter = adapter;
|
|
4770
|
+
exports.unstable__environment = environment;
|
|
3984
4771
|
|
|
3985
4772
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3986
4773
|
|