@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/dist/index.browser.js
CHANGED
|
@@ -2,26 +2,19 @@ import { getIt } from "get-it";
|
|
|
2
2
|
import { adapter, environment } from "get-it";
|
|
3
3
|
import { retry, jsonRequest, jsonResponse, progress, observable } from "get-it/middleware";
|
|
4
4
|
import { Observable, from, lastValueFrom } from "rxjs";
|
|
5
|
-
import { stegaClean } from "./_chunks-es/stegaClean.js";
|
|
6
5
|
import { combineLatestWith, map, filter } from "rxjs/operators";
|
|
6
|
+
import { stegaClean } from "./_chunks-es/stegaClean.js";
|
|
7
|
+
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);
|
|
7
8
|
class ClientError extends Error {
|
|
8
|
-
response;
|
|
9
|
-
statusCode = 400;
|
|
10
|
-
responseBody;
|
|
11
|
-
details;
|
|
12
9
|
constructor(res) {
|
|
13
10
|
const props = extractErrorProps(res);
|
|
14
|
-
super(props.message), Object.assign(this, props);
|
|
11
|
+
super(props.message), __publicField$3(this, "response"), __publicField$3(this, "statusCode", 400), __publicField$3(this, "responseBody"), __publicField$3(this, "details"), Object.assign(this, props);
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
14
|
class ServerError extends Error {
|
|
18
|
-
response;
|
|
19
|
-
statusCode = 500;
|
|
20
|
-
responseBody;
|
|
21
|
-
details;
|
|
22
15
|
constructor(res) {
|
|
23
16
|
const props = extractErrorProps(res);
|
|
24
|
-
super(props.message), Object.assign(this, props);
|
|
17
|
+
super(props.message), __publicField$3(this, "response"), __publicField$3(this, "statusCode", 500), __publicField$3(this, "responseBody"), __publicField$3(this, "details"), Object.assign(this, props);
|
|
25
18
|
}
|
|
26
19
|
}
|
|
27
20
|
function extractErrorProps(res) {
|
|
@@ -35,7 +28,10 @@ function extractErrorProps(res) {
|
|
|
35
28
|
if (body.error && body.message)
|
|
36
29
|
return props.message = `${body.error} - ${body.message}`, props;
|
|
37
30
|
if (isMutationError(body) || isActionError(body)) {
|
|
38
|
-
const allItems = body.error.items || [], items = allItems.slice(0, 5).map((item) =>
|
|
31
|
+
const allItems = body.error.items || [], items = allItems.slice(0, 5).map((item) => {
|
|
32
|
+
var _a;
|
|
33
|
+
return (_a = item.error) == null ? void 0 : _a.description;
|
|
34
|
+
}).filter(Boolean);
|
|
39
35
|
let itemsStr = items.length ? `:
|
|
40
36
|
- ${items.join(`
|
|
41
37
|
- `)}` : "";
|
|
@@ -151,11 +147,17 @@ const VALID_ASSET_TYPES = ["image", "file"], VALID_INSERT_LOCATIONS = ["before",
|
|
|
151
147
|
);
|
|
152
148
|
return tag;
|
|
153
149
|
};
|
|
150
|
+
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) => {
|
|
151
|
+
if (!member.has(obj))
|
|
152
|
+
throw TypeError("Cannot " + msg);
|
|
153
|
+
}, __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) => {
|
|
154
|
+
if (member.has(obj))
|
|
155
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
156
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
157
|
+
}, __privateSet$7 = (obj, member, value, setter) => (__accessCheck$7(obj, member, "write to private field"), member.set(obj, value), value);
|
|
154
158
|
class BasePatch {
|
|
155
|
-
selection;
|
|
156
|
-
operations;
|
|
157
159
|
constructor(selection, operations = {}) {
|
|
158
|
-
this.selection = selection, this.operations = operations;
|
|
160
|
+
__publicField$2(this, "selection"), __publicField$2(this, "operations"), this.selection = selection, this.operations = operations;
|
|
159
161
|
}
|
|
160
162
|
/**
|
|
161
163
|
* Sets the given attributes to the document. Does NOT merge objects.
|
|
@@ -286,52 +288,62 @@ class BasePatch {
|
|
|
286
288
|
return this._assign(op, props, !1);
|
|
287
289
|
}
|
|
288
290
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
+
var _client$6;
|
|
292
|
+
const _ObservablePatch = class _ObservablePatch2 extends BasePatch {
|
|
291
293
|
constructor(selection, operations, client) {
|
|
292
|
-
super(selection, operations), this
|
|
294
|
+
super(selection, operations), __privateAdd$7(this, _client$6, void 0), __privateSet$7(this, _client$6, client);
|
|
293
295
|
}
|
|
294
296
|
/**
|
|
295
297
|
* Clones the patch
|
|
296
298
|
*/
|
|
297
299
|
clone() {
|
|
298
|
-
return new
|
|
300
|
+
return new _ObservablePatch2(this.selection, { ...this.operations }, __privateGet$7(this, _client$6));
|
|
299
301
|
}
|
|
300
302
|
commit(options) {
|
|
301
|
-
if (!this
|
|
303
|
+
if (!__privateGet$7(this, _client$6))
|
|
302
304
|
throw new Error(
|
|
303
305
|
"No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
|
|
304
306
|
);
|
|
305
307
|
const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
|
|
306
|
-
return this
|
|
308
|
+
return __privateGet$7(this, _client$6).mutate({ patch: this.serialize() }, opts);
|
|
307
309
|
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
|
|
310
|
+
};
|
|
311
|
+
_client$6 = /* @__PURE__ */ new WeakMap();
|
|
312
|
+
let ObservablePatch = _ObservablePatch;
|
|
313
|
+
var _client2$5;
|
|
314
|
+
const _Patch = class _Patch2 extends BasePatch {
|
|
311
315
|
constructor(selection, operations, client) {
|
|
312
|
-
super(selection, operations), this
|
|
316
|
+
super(selection, operations), __privateAdd$7(this, _client2$5, void 0), __privateSet$7(this, _client2$5, client);
|
|
313
317
|
}
|
|
314
318
|
/**
|
|
315
319
|
* Clones the patch
|
|
316
320
|
*/
|
|
317
321
|
clone() {
|
|
318
|
-
return new
|
|
322
|
+
return new _Patch2(this.selection, { ...this.operations }, __privateGet$7(this, _client2$5));
|
|
319
323
|
}
|
|
320
324
|
commit(options) {
|
|
321
|
-
if (!this
|
|
325
|
+
if (!__privateGet$7(this, _client2$5))
|
|
322
326
|
throw new Error(
|
|
323
327
|
"No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
|
|
324
328
|
);
|
|
325
329
|
const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
|
|
326
|
-
return this
|
|
330
|
+
return __privateGet$7(this, _client2$5).mutate({ patch: this.serialize() }, opts);
|
|
327
331
|
}
|
|
328
|
-
}
|
|
332
|
+
};
|
|
333
|
+
_client2$5 = /* @__PURE__ */ new WeakMap();
|
|
334
|
+
let Patch = _Patch;
|
|
335
|
+
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) => {
|
|
336
|
+
if (!member.has(obj))
|
|
337
|
+
throw TypeError("Cannot " + msg);
|
|
338
|
+
}, __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) => {
|
|
339
|
+
if (member.has(obj))
|
|
340
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
341
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
342
|
+
}, __privateSet$6 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), member.set(obj, value), value);
|
|
329
343
|
const defaultMutateOptions = { returnDocuments: !1 };
|
|
330
344
|
class BaseTransaction {
|
|
331
|
-
operations;
|
|
332
|
-
trxId;
|
|
333
345
|
constructor(operations = [], transactionId) {
|
|
334
|
-
this.operations = operations, this.trxId = transactionId;
|
|
346
|
+
__publicField$1(this, "operations"), __publicField$1(this, "trxId"), this.operations = operations, this.trxId = transactionId;
|
|
335
347
|
}
|
|
336
348
|
/**
|
|
337
349
|
* 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.
|
|
@@ -396,23 +408,23 @@ class BaseTransaction {
|
|
|
396
408
|
return this.operations.push(mut), this;
|
|
397
409
|
}
|
|
398
410
|
}
|
|
399
|
-
|
|
400
|
-
|
|
411
|
+
var _client$5;
|
|
412
|
+
const _Transaction = class _Transaction2 extends BaseTransaction {
|
|
401
413
|
constructor(operations, client, transactionId) {
|
|
402
|
-
super(operations, transactionId), this
|
|
414
|
+
super(operations, transactionId), __privateAdd$6(this, _client$5, void 0), __privateSet$6(this, _client$5, client);
|
|
403
415
|
}
|
|
404
416
|
/**
|
|
405
417
|
* Clones the transaction
|
|
406
418
|
*/
|
|
407
419
|
clone() {
|
|
408
|
-
return new
|
|
420
|
+
return new _Transaction2([...this.operations], __privateGet$6(this, _client$5), this.trxId);
|
|
409
421
|
}
|
|
410
422
|
commit(options) {
|
|
411
|
-
if (!this
|
|
423
|
+
if (!__privateGet$6(this, _client$5))
|
|
412
424
|
throw new Error(
|
|
413
425
|
"No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
|
|
414
426
|
);
|
|
415
|
-
return this
|
|
427
|
+
return __privateGet$6(this, _client$5).mutate(
|
|
416
428
|
this.serialize(),
|
|
417
429
|
Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
|
|
418
430
|
);
|
|
@@ -422,31 +434,33 @@ class Transaction extends BaseTransaction {
|
|
|
422
434
|
if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof Patch)
|
|
423
435
|
return this._add({ patch: patchOrDocumentId.serialize() });
|
|
424
436
|
if (isBuilder) {
|
|
425
|
-
const patch = patchOps(new Patch(patchOrDocumentId, {}, this
|
|
437
|
+
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$6(this, _client$5)));
|
|
426
438
|
if (!(patch instanceof Patch))
|
|
427
439
|
throw new Error("function passed to `patch()` must return the patch");
|
|
428
440
|
return this._add({ patch: patch.serialize() });
|
|
429
441
|
}
|
|
430
442
|
return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
|
|
431
443
|
}
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
|
|
444
|
+
};
|
|
445
|
+
_client$5 = /* @__PURE__ */ new WeakMap();
|
|
446
|
+
let Transaction = _Transaction;
|
|
447
|
+
var _client2$4;
|
|
448
|
+
const _ObservableTransaction = class _ObservableTransaction2 extends BaseTransaction {
|
|
435
449
|
constructor(operations, client, transactionId) {
|
|
436
|
-
super(operations, transactionId), this
|
|
450
|
+
super(operations, transactionId), __privateAdd$6(this, _client2$4, void 0), __privateSet$6(this, _client2$4, client);
|
|
437
451
|
}
|
|
438
452
|
/**
|
|
439
453
|
* Clones the transaction
|
|
440
454
|
*/
|
|
441
455
|
clone() {
|
|
442
|
-
return new
|
|
456
|
+
return new _ObservableTransaction2([...this.operations], __privateGet$6(this, _client2$4), this.trxId);
|
|
443
457
|
}
|
|
444
458
|
commit(options) {
|
|
445
|
-
if (!this
|
|
459
|
+
if (!__privateGet$6(this, _client2$4))
|
|
446
460
|
throw new Error(
|
|
447
461
|
"No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
|
|
448
462
|
);
|
|
449
|
-
return this
|
|
463
|
+
return __privateGet$6(this, _client2$4).mutate(
|
|
450
464
|
this.serialize(),
|
|
451
465
|
Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
|
|
452
466
|
);
|
|
@@ -456,14 +470,16 @@ class ObservableTransaction extends BaseTransaction {
|
|
|
456
470
|
if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof ObservablePatch)
|
|
457
471
|
return this._add({ patch: patchOrDocumentId.serialize() });
|
|
458
472
|
if (isBuilder) {
|
|
459
|
-
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, this
|
|
473
|
+
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$6(this, _client2$4)));
|
|
460
474
|
if (!(patch instanceof ObservablePatch))
|
|
461
475
|
throw new Error("function passed to `patch()` must return the patch");
|
|
462
476
|
return this._add({ patch: patch.serialize() });
|
|
463
477
|
}
|
|
464
478
|
return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
|
|
465
479
|
}
|
|
466
|
-
}
|
|
480
|
+
};
|
|
481
|
+
_client2$4 = /* @__PURE__ */ new WeakMap();
|
|
482
|
+
let ObservableTransaction = _ObservableTransaction;
|
|
467
483
|
const BASE_URL = "https://www.sanity.io/help/";
|
|
468
484
|
function generateHelpUrl(slug) {
|
|
469
485
|
return BASE_URL + slug;
|
|
@@ -627,14 +643,24 @@ function _fetch(client, httpRequest, _stega, query, _params = {}, options = {})
|
|
|
627
643
|
) : $request.pipe(map(mapResponse));
|
|
628
644
|
}
|
|
629
645
|
function _getDocument(client, httpRequest, id, opts = {}) {
|
|
630
|
-
const options = {
|
|
646
|
+
const options = {
|
|
647
|
+
uri: _getDataUrl(client, "doc", id),
|
|
648
|
+
json: !0,
|
|
649
|
+
tag: opts.tag,
|
|
650
|
+
signal: opts.signal
|
|
651
|
+
};
|
|
631
652
|
return _requestObservable(client, httpRequest, options).pipe(
|
|
632
653
|
filter(isResponse),
|
|
633
654
|
map((event) => event.body.documents && event.body.documents[0])
|
|
634
655
|
);
|
|
635
656
|
}
|
|
636
657
|
function _getDocuments(client, httpRequest, ids, opts = {}) {
|
|
637
|
-
const options = {
|
|
658
|
+
const options = {
|
|
659
|
+
uri: _getDataUrl(client, "doc", ids.join(",")),
|
|
660
|
+
json: !0,
|
|
661
|
+
tag: opts.tag,
|
|
662
|
+
signal: opts.signal
|
|
663
|
+
};
|
|
638
664
|
return _requestObservable(client, httpRequest, options).pipe(
|
|
639
665
|
filter(isResponse),
|
|
640
666
|
map((event) => {
|
|
@@ -718,11 +744,12 @@ function _create(client, httpRequest, doc, op, options = {}) {
|
|
|
718
744
|
return _dataRequest(client, httpRequest, "mutate", { mutations: [mutation] }, opts);
|
|
719
745
|
}
|
|
720
746
|
function _requestObservable(client, httpRequest, options) {
|
|
747
|
+
var _a, _b;
|
|
721
748
|
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;
|
|
722
|
-
let useCdn = (options.useCdn
|
|
749
|
+
let useCdn = ((_a = options.useCdn) != null ? _a : config.useCdn) && canUseCdn;
|
|
723
750
|
const tag = options.tag && config.requestTagPrefix ? [config.requestTagPrefix, options.tag].join(".") : options.tag || config.requestTagPrefix;
|
|
724
751
|
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) {
|
|
725
|
-
const resultSourceMap = options.resultSourceMap
|
|
752
|
+
const resultSourceMap = (_b = options.resultSourceMap) != null ? _b : config.resultSourceMap;
|
|
726
753
|
resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
|
|
727
754
|
const perspective = options.perspective || config.perspective;
|
|
728
755
|
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 });
|
|
@@ -766,29 +793,36 @@ function _withAbortSignal(signal) {
|
|
|
766
793
|
}
|
|
767
794
|
const isDomExceptionSupported = !!globalThis.DOMException;
|
|
768
795
|
function _createAbortError(signal) {
|
|
796
|
+
var _a, _b;
|
|
769
797
|
if (isDomExceptionSupported)
|
|
770
|
-
return new DOMException(signal
|
|
771
|
-
const error = new Error(signal
|
|
798
|
+
return new DOMException((_a = signal == null ? void 0 : signal.reason) != null ? _a : "The operation was aborted.", "AbortError");
|
|
799
|
+
const error = new Error((_b = signal == null ? void 0 : signal.reason) != null ? _b : "The operation was aborted.");
|
|
772
800
|
return error.name = "AbortError", error;
|
|
773
801
|
}
|
|
802
|
+
var __accessCheck$5 = (obj, member, msg) => {
|
|
803
|
+
if (!member.has(obj))
|
|
804
|
+
throw TypeError("Cannot " + msg);
|
|
805
|
+
}, __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) => {
|
|
806
|
+
if (member.has(obj))
|
|
807
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
808
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
809
|
+
}, __privateSet$5 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value), _client$4, _httpRequest$4;
|
|
774
810
|
class ObservableAssetsClient {
|
|
775
|
-
#client;
|
|
776
|
-
#httpRequest;
|
|
777
811
|
constructor(client, httpRequest) {
|
|
778
|
-
this
|
|
812
|
+
__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);
|
|
779
813
|
}
|
|
780
814
|
upload(assetType, body, options) {
|
|
781
|
-
return _upload(this
|
|
815
|
+
return _upload(__privateGet$5(this, _client$4), __privateGet$5(this, _httpRequest$4), assetType, body, options);
|
|
782
816
|
}
|
|
783
817
|
}
|
|
818
|
+
_client$4 = /* @__PURE__ */ new WeakMap(), _httpRequest$4 = /* @__PURE__ */ new WeakMap();
|
|
819
|
+
var _client2$3, _httpRequest2$4;
|
|
784
820
|
class AssetsClient {
|
|
785
|
-
#client;
|
|
786
|
-
#httpRequest;
|
|
787
821
|
constructor(client, httpRequest) {
|
|
788
|
-
this
|
|
822
|
+
__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);
|
|
789
823
|
}
|
|
790
824
|
upload(assetType, body, options) {
|
|
791
|
-
const observable2 = _upload(this
|
|
825
|
+
const observable2 = _upload(__privateGet$5(this, _client2$3), __privateGet$5(this, _httpRequest2$4), assetType, body, options);
|
|
792
826
|
return lastValueFrom(
|
|
793
827
|
observable2.pipe(
|
|
794
828
|
filter((event) => event.type === "response"),
|
|
@@ -799,6 +833,7 @@ class AssetsClient {
|
|
|
799
833
|
);
|
|
800
834
|
}
|
|
801
835
|
}
|
|
836
|
+
_client2$3 = /* @__PURE__ */ new WeakMap(), _httpRequest2$4 = /* @__PURE__ */ new WeakMap();
|
|
802
837
|
function _upload(client, httpRequest, assetType, body, opts = {}) {
|
|
803
838
|
validateAssetType(assetType);
|
|
804
839
|
let meta = opts.extract || void 0;
|
|
@@ -907,22 +942,30 @@ function cooerceError(err) {
|
|
|
907
942
|
function extractErrorMessage(err) {
|
|
908
943
|
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";
|
|
909
944
|
}
|
|
945
|
+
var __accessCheck$4 = (obj, member, msg) => {
|
|
946
|
+
if (!member.has(obj))
|
|
947
|
+
throw TypeError("Cannot " + msg);
|
|
948
|
+
}, __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) => {
|
|
949
|
+
if (member.has(obj))
|
|
950
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
951
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
952
|
+
}, __privateSet$4 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
|
|
910
953
|
const requiredApiVersion = "2021-03-26";
|
|
954
|
+
var _client$3;
|
|
911
955
|
class LiveClient {
|
|
912
|
-
#client;
|
|
913
956
|
constructor(client) {
|
|
914
|
-
this
|
|
957
|
+
__privateAdd$4(this, _client$3, void 0), __privateSet$4(this, _client$3, client);
|
|
915
958
|
}
|
|
916
959
|
/**
|
|
917
960
|
* Requires `apiVersion` to be `2021-03-26` or later.
|
|
918
961
|
*/
|
|
919
962
|
events() {
|
|
920
|
-
const apiVersion = this
|
|
963
|
+
const apiVersion = __privateGet$4(this, _client$3).config().apiVersion.replace(/^v/, "");
|
|
921
964
|
if (apiVersion !== "X" && apiVersion < requiredApiVersion)
|
|
922
965
|
throw new Error(
|
|
923
966
|
`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.`
|
|
924
967
|
);
|
|
925
|
-
const path = _getDataUrl(this
|
|
968
|
+
const path = _getDataUrl(__privateGet$4(this, _client$3), "live/events"), url = new URL(__privateGet$4(this, _client$3).getUrl(path, !1)), listenFor = ["restart", "message"];
|
|
926
969
|
return new Observable((observer) => {
|
|
927
970
|
let es, reconnectTimer, stopped = !1, unsubscribed = !1;
|
|
928
971
|
open();
|
|
@@ -971,6 +1014,7 @@ class LiveClient {
|
|
|
971
1014
|
});
|
|
972
1015
|
}
|
|
973
1016
|
}
|
|
1017
|
+
_client$3 = /* @__PURE__ */ new WeakMap();
|
|
974
1018
|
function parseEvent(event) {
|
|
975
1019
|
try {
|
|
976
1020
|
const data = event.data && JSON.parse(event.data) || {};
|
|
@@ -979,11 +1023,17 @@ function parseEvent(event) {
|
|
|
979
1023
|
return err;
|
|
980
1024
|
}
|
|
981
1025
|
}
|
|
1026
|
+
var __accessCheck$3 = (obj, member, msg) => {
|
|
1027
|
+
if (!member.has(obj))
|
|
1028
|
+
throw TypeError("Cannot " + msg);
|
|
1029
|
+
}, __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) => {
|
|
1030
|
+
if (member.has(obj))
|
|
1031
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
1032
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1033
|
+
}, __privateSet$3 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value), _client$2, _httpRequest$3;
|
|
982
1034
|
class ObservableDatasetsClient {
|
|
983
|
-
#client;
|
|
984
|
-
#httpRequest;
|
|
985
1035
|
constructor(client, httpRequest) {
|
|
986
|
-
this
|
|
1036
|
+
__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);
|
|
987
1037
|
}
|
|
988
1038
|
/**
|
|
989
1039
|
* Create a new dataset with the given name
|
|
@@ -992,7 +1042,7 @@ class ObservableDatasetsClient {
|
|
|
992
1042
|
* @param options - Options for the dataset
|
|
993
1043
|
*/
|
|
994
1044
|
create(name, options) {
|
|
995
|
-
return _modify(this
|
|
1045
|
+
return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "PUT", name, options);
|
|
996
1046
|
}
|
|
997
1047
|
/**
|
|
998
1048
|
* Edit a dataset with the given name
|
|
@@ -1001,7 +1051,7 @@ class ObservableDatasetsClient {
|
|
|
1001
1051
|
* @param options - New options for the dataset
|
|
1002
1052
|
*/
|
|
1003
1053
|
edit(name, options) {
|
|
1004
|
-
return _modify(this
|
|
1054
|
+
return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "PATCH", name, options);
|
|
1005
1055
|
}
|
|
1006
1056
|
/**
|
|
1007
1057
|
* Delete a dataset with the given name
|
|
@@ -1009,23 +1059,23 @@ class ObservableDatasetsClient {
|
|
|
1009
1059
|
* @param name - Name of the dataset to delete
|
|
1010
1060
|
*/
|
|
1011
1061
|
delete(name) {
|
|
1012
|
-
return _modify(this
|
|
1062
|
+
return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "DELETE", name);
|
|
1013
1063
|
}
|
|
1014
1064
|
/**
|
|
1015
1065
|
* Fetch a list of datasets for the configured project
|
|
1016
1066
|
*/
|
|
1017
1067
|
list() {
|
|
1018
|
-
return _request(this
|
|
1068
|
+
return _request(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), {
|
|
1019
1069
|
uri: "/datasets",
|
|
1020
1070
|
tag: null
|
|
1021
1071
|
});
|
|
1022
1072
|
}
|
|
1023
1073
|
}
|
|
1074
|
+
_client$2 = /* @__PURE__ */ new WeakMap(), _httpRequest$3 = /* @__PURE__ */ new WeakMap();
|
|
1075
|
+
var _client2$2, _httpRequest2$3;
|
|
1024
1076
|
class DatasetsClient {
|
|
1025
|
-
#client;
|
|
1026
|
-
#httpRequest;
|
|
1027
1077
|
constructor(client, httpRequest) {
|
|
1028
|
-
this
|
|
1078
|
+
__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);
|
|
1029
1079
|
}
|
|
1030
1080
|
/**
|
|
1031
1081
|
* Create a new dataset with the given name
|
|
@@ -1035,7 +1085,7 @@ class DatasetsClient {
|
|
|
1035
1085
|
*/
|
|
1036
1086
|
create(name, options) {
|
|
1037
1087
|
return lastValueFrom(
|
|
1038
|
-
_modify(this
|
|
1088
|
+
_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PUT", name, options)
|
|
1039
1089
|
);
|
|
1040
1090
|
}
|
|
1041
1091
|
/**
|
|
@@ -1046,7 +1096,7 @@ class DatasetsClient {
|
|
|
1046
1096
|
*/
|
|
1047
1097
|
edit(name, options) {
|
|
1048
1098
|
return lastValueFrom(
|
|
1049
|
-
_modify(this
|
|
1099
|
+
_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PATCH", name, options)
|
|
1050
1100
|
);
|
|
1051
1101
|
}
|
|
1052
1102
|
/**
|
|
@@ -1055,17 +1105,18 @@ class DatasetsClient {
|
|
|
1055
1105
|
* @param name - Name of the dataset to delete
|
|
1056
1106
|
*/
|
|
1057
1107
|
delete(name) {
|
|
1058
|
-
return lastValueFrom(_modify(this
|
|
1108
|
+
return lastValueFrom(_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "DELETE", name));
|
|
1059
1109
|
}
|
|
1060
1110
|
/**
|
|
1061
1111
|
* Fetch a list of datasets for the configured project
|
|
1062
1112
|
*/
|
|
1063
1113
|
list() {
|
|
1064
1114
|
return lastValueFrom(
|
|
1065
|
-
_request(this
|
|
1115
|
+
_request(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), { uri: "/datasets", tag: null })
|
|
1066
1116
|
);
|
|
1067
1117
|
}
|
|
1068
1118
|
}
|
|
1119
|
+
_client2$2 = /* @__PURE__ */ new WeakMap(), _httpRequest2$3 = /* @__PURE__ */ new WeakMap();
|
|
1069
1120
|
function _modify(client, httpRequest, method, name, options) {
|
|
1070
1121
|
return dataset(name), _request(client, httpRequest, {
|
|
1071
1122
|
method,
|
|
@@ -1074,15 +1125,21 @@ function _modify(client, httpRequest, method, name, options) {
|
|
|
1074
1125
|
tag: null
|
|
1075
1126
|
});
|
|
1076
1127
|
}
|
|
1128
|
+
var __accessCheck$2 = (obj, member, msg) => {
|
|
1129
|
+
if (!member.has(obj))
|
|
1130
|
+
throw TypeError("Cannot " + msg);
|
|
1131
|
+
}, __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) => {
|
|
1132
|
+
if (member.has(obj))
|
|
1133
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
1134
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1135
|
+
}, __privateSet$2 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), member.set(obj, value), value), _client$1, _httpRequest$2;
|
|
1077
1136
|
class ObservableProjectsClient {
|
|
1078
|
-
#client;
|
|
1079
|
-
#httpRequest;
|
|
1080
1137
|
constructor(client, httpRequest) {
|
|
1081
|
-
this
|
|
1138
|
+
__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);
|
|
1082
1139
|
}
|
|
1083
1140
|
list(options) {
|
|
1084
|
-
const uri = options
|
|
1085
|
-
return _request(this
|
|
1141
|
+
const uri = (options == null ? void 0 : options.includeMembers) === !1 ? "/projects?includeMembers=false" : "/projects";
|
|
1142
|
+
return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), { uri });
|
|
1086
1143
|
}
|
|
1087
1144
|
/**
|
|
1088
1145
|
* Fetch a project by project ID
|
|
@@ -1090,18 +1147,18 @@ class ObservableProjectsClient {
|
|
|
1090
1147
|
* @param projectId - ID of the project to fetch
|
|
1091
1148
|
*/
|
|
1092
1149
|
getById(projectId2) {
|
|
1093
|
-
return _request(this
|
|
1150
|
+
return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), { uri: `/projects/${projectId2}` });
|
|
1094
1151
|
}
|
|
1095
1152
|
}
|
|
1153
|
+
_client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */ new WeakMap();
|
|
1154
|
+
var _client2$1, _httpRequest2$2;
|
|
1096
1155
|
class ProjectsClient {
|
|
1097
|
-
#client;
|
|
1098
|
-
#httpRequest;
|
|
1099
1156
|
constructor(client, httpRequest) {
|
|
1100
|
-
this
|
|
1157
|
+
__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);
|
|
1101
1158
|
}
|
|
1102
1159
|
list(options) {
|
|
1103
|
-
const uri = options
|
|
1104
|
-
return lastValueFrom(_request(this
|
|
1160
|
+
const uri = (options == null ? void 0 : options.includeMembers) === !1 ? "/projects?includeMembers=false" : "/projects";
|
|
1161
|
+
return lastValueFrom(_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), { uri }));
|
|
1105
1162
|
}
|
|
1106
1163
|
/**
|
|
1107
1164
|
* Fetch a project by project ID
|
|
@@ -1110,15 +1167,22 @@ class ProjectsClient {
|
|
|
1110
1167
|
*/
|
|
1111
1168
|
getById(projectId2) {
|
|
1112
1169
|
return lastValueFrom(
|
|
1113
|
-
_request(this
|
|
1170
|
+
_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), { uri: `/projects/${projectId2}` })
|
|
1114
1171
|
);
|
|
1115
1172
|
}
|
|
1116
1173
|
}
|
|
1174
|
+
_client2$1 = /* @__PURE__ */ new WeakMap(), _httpRequest2$2 = /* @__PURE__ */ new WeakMap();
|
|
1175
|
+
var __accessCheck$1 = (obj, member, msg) => {
|
|
1176
|
+
if (!member.has(obj))
|
|
1177
|
+
throw TypeError("Cannot " + msg);
|
|
1178
|
+
}, __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) => {
|
|
1179
|
+
if (member.has(obj))
|
|
1180
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
1181
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1182
|
+
}, __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value), _client, _httpRequest$1;
|
|
1117
1183
|
class ObservableUsersClient {
|
|
1118
|
-
#client;
|
|
1119
|
-
#httpRequest;
|
|
1120
1184
|
constructor(client, httpRequest) {
|
|
1121
|
-
this
|
|
1185
|
+
__privateAdd$1(this, _client, void 0), __privateAdd$1(this, _httpRequest$1, void 0), __privateSet$1(this, _client, client), __privateSet$1(this, _httpRequest$1, httpRequest);
|
|
1122
1186
|
}
|
|
1123
1187
|
/**
|
|
1124
1188
|
* Fetch a user by user ID
|
|
@@ -1127,17 +1191,17 @@ class ObservableUsersClient {
|
|
|
1127
1191
|
*/
|
|
1128
1192
|
getById(id) {
|
|
1129
1193
|
return _request(
|
|
1130
|
-
this
|
|
1131
|
-
this
|
|
1194
|
+
__privateGet$1(this, _client),
|
|
1195
|
+
__privateGet$1(this, _httpRequest$1),
|
|
1132
1196
|
{ uri: `/users/${id}` }
|
|
1133
1197
|
);
|
|
1134
1198
|
}
|
|
1135
1199
|
}
|
|
1200
|
+
_client = /* @__PURE__ */ new WeakMap(), _httpRequest$1 = /* @__PURE__ */ new WeakMap();
|
|
1201
|
+
var _client2, _httpRequest2$1;
|
|
1136
1202
|
class UsersClient {
|
|
1137
|
-
#client;
|
|
1138
|
-
#httpRequest;
|
|
1139
1203
|
constructor(client, httpRequest) {
|
|
1140
|
-
this
|
|
1204
|
+
__privateAdd$1(this, _client2, void 0), __privateAdd$1(this, _httpRequest2$1, void 0), __privateSet$1(this, _client2, client), __privateSet$1(this, _httpRequest2$1, httpRequest);
|
|
1141
1205
|
}
|
|
1142
1206
|
/**
|
|
1143
1207
|
* Fetch a user by user ID
|
|
@@ -1146,44 +1210,39 @@ class UsersClient {
|
|
|
1146
1210
|
*/
|
|
1147
1211
|
getById(id) {
|
|
1148
1212
|
return lastValueFrom(
|
|
1149
|
-
_request(this
|
|
1213
|
+
_request(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), {
|
|
1150
1214
|
uri: `/users/${id}`
|
|
1151
1215
|
})
|
|
1152
1216
|
);
|
|
1153
1217
|
}
|
|
1154
1218
|
}
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
#httpRequest;
|
|
1166
|
-
/**
|
|
1167
|
-
* Instance properties
|
|
1168
|
-
*/
|
|
1169
|
-
listen = _listen;
|
|
1219
|
+
_client2 = /* @__PURE__ */ new WeakMap(), _httpRequest2$1 = /* @__PURE__ */ new WeakMap();
|
|
1220
|
+
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) => {
|
|
1221
|
+
if (!member.has(obj))
|
|
1222
|
+
throw TypeError("Cannot " + msg);
|
|
1223
|
+
}, __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd = (obj, member, value) => {
|
|
1224
|
+
if (member.has(obj))
|
|
1225
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
1226
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1227
|
+
}, __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value), _clientConfig, _httpRequest;
|
|
1228
|
+
const _ObservableSanityClient = class _ObservableSanityClient2 {
|
|
1170
1229
|
constructor(httpRequest, config = defaultConfig) {
|
|
1171
|
-
this.config(config), this
|
|
1230
|
+
__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));
|
|
1172
1231
|
}
|
|
1173
1232
|
/**
|
|
1174
1233
|
* Clone the client - returns a new instance
|
|
1175
1234
|
*/
|
|
1176
1235
|
clone() {
|
|
1177
|
-
return new
|
|
1236
|
+
return new _ObservableSanityClient2(__privateGet(this, _httpRequest), this.config());
|
|
1178
1237
|
}
|
|
1179
1238
|
config(newConfig) {
|
|
1180
1239
|
if (newConfig === void 0)
|
|
1181
|
-
return { ...this
|
|
1182
|
-
if (this
|
|
1240
|
+
return { ...__privateGet(this, _clientConfig) };
|
|
1241
|
+
if (__privateGet(this, _clientConfig) && __privateGet(this, _clientConfig).allowReconfigure === !1)
|
|
1183
1242
|
throw new Error(
|
|
1184
1243
|
"Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
|
|
1185
1244
|
);
|
|
1186
|
-
return this
|
|
1245
|
+
return __privateSet(this, _clientConfig, initConfig(newConfig, __privateGet(this, _clientConfig) || {})), this;
|
|
1187
1246
|
}
|
|
1188
1247
|
/**
|
|
1189
1248
|
* Clone the client with a new (partial) configuration.
|
|
@@ -1192,20 +1251,20 @@ class ObservableSanityClient {
|
|
|
1192
1251
|
*/
|
|
1193
1252
|
withConfig(newConfig) {
|
|
1194
1253
|
const thisConfig = this.config();
|
|
1195
|
-
return new
|
|
1254
|
+
return new _ObservableSanityClient2(__privateGet(this, _httpRequest), {
|
|
1196
1255
|
...thisConfig,
|
|
1197
1256
|
...newConfig,
|
|
1198
1257
|
stega: {
|
|
1199
1258
|
...thisConfig.stega || {},
|
|
1200
|
-
...typeof newConfig
|
|
1259
|
+
...typeof (newConfig == null ? void 0 : newConfig.stega) == "boolean" ? { enabled: newConfig.stega } : (newConfig == null ? void 0 : newConfig.stega) || {}
|
|
1201
1260
|
}
|
|
1202
1261
|
});
|
|
1203
1262
|
}
|
|
1204
1263
|
fetch(query, params, options) {
|
|
1205
1264
|
return _fetch(
|
|
1206
1265
|
this,
|
|
1207
|
-
this
|
|
1208
|
-
this
|
|
1266
|
+
__privateGet(this, _httpRequest),
|
|
1267
|
+
__privateGet(this, _clientConfig).stega,
|
|
1209
1268
|
query,
|
|
1210
1269
|
params,
|
|
1211
1270
|
options
|
|
@@ -1218,7 +1277,7 @@ class ObservableSanityClient {
|
|
|
1218
1277
|
* @param options - Request options
|
|
1219
1278
|
*/
|
|
1220
1279
|
getDocument(id, options) {
|
|
1221
|
-
return _getDocument(this, this
|
|
1280
|
+
return _getDocument(this, __privateGet(this, _httpRequest), id, options);
|
|
1222
1281
|
}
|
|
1223
1282
|
/**
|
|
1224
1283
|
* Fetch multiple documents in one request.
|
|
@@ -1230,22 +1289,22 @@ class ObservableSanityClient {
|
|
|
1230
1289
|
* @param options - Request options
|
|
1231
1290
|
*/
|
|
1232
1291
|
getDocuments(ids, options) {
|
|
1233
|
-
return _getDocuments(this, this
|
|
1292
|
+
return _getDocuments(this, __privateGet(this, _httpRequest), ids, options);
|
|
1234
1293
|
}
|
|
1235
1294
|
create(document, options) {
|
|
1236
|
-
return _create(this, this
|
|
1295
|
+
return _create(this, __privateGet(this, _httpRequest), document, "create", options);
|
|
1237
1296
|
}
|
|
1238
1297
|
createIfNotExists(document, options) {
|
|
1239
|
-
return _createIfNotExists(this, this
|
|
1298
|
+
return _createIfNotExists(this, __privateGet(this, _httpRequest), document, options);
|
|
1240
1299
|
}
|
|
1241
1300
|
createOrReplace(document, options) {
|
|
1242
|
-
return _createOrReplace(this, this
|
|
1301
|
+
return _createOrReplace(this, __privateGet(this, _httpRequest), document, options);
|
|
1243
1302
|
}
|
|
1244
1303
|
delete(selection, options) {
|
|
1245
|
-
return _delete(this, this
|
|
1304
|
+
return _delete(this, __privateGet(this, _httpRequest), selection, options);
|
|
1246
1305
|
}
|
|
1247
1306
|
mutate(operations, options) {
|
|
1248
|
-
return _mutate(this, this
|
|
1307
|
+
return _mutate(this, __privateGet(this, _httpRequest), operations, options);
|
|
1249
1308
|
}
|
|
1250
1309
|
/**
|
|
1251
1310
|
* Create a new buildable patch of operations to perform
|
|
@@ -1272,7 +1331,7 @@ class ObservableSanityClient {
|
|
|
1272
1331
|
* @param options - Action options
|
|
1273
1332
|
*/
|
|
1274
1333
|
action(operations, options) {
|
|
1275
|
-
return _action(this, this
|
|
1334
|
+
return _action(this, __privateGet(this, _httpRequest), operations, options);
|
|
1276
1335
|
}
|
|
1277
1336
|
/**
|
|
1278
1337
|
* Perform an HTTP request against the Sanity API
|
|
@@ -1280,7 +1339,7 @@ class ObservableSanityClient {
|
|
|
1280
1339
|
* @param options - Request options
|
|
1281
1340
|
*/
|
|
1282
1341
|
request(options) {
|
|
1283
|
-
return _request(this, this
|
|
1342
|
+
return _request(this, __privateGet(this, _httpRequest), options);
|
|
1284
1343
|
}
|
|
1285
1344
|
/**
|
|
1286
1345
|
* Get a Sanity API URL for the URI provided
|
|
@@ -1300,43 +1359,28 @@ class ObservableSanityClient {
|
|
|
1300
1359
|
getDataUrl(operation, path) {
|
|
1301
1360
|
return _getDataUrl(this, operation, path);
|
|
1302
1361
|
}
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
projects;
|
|
1309
|
-
users;
|
|
1310
|
-
/**
|
|
1311
|
-
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
1312
|
-
*/
|
|
1313
|
-
observable;
|
|
1314
|
-
/**
|
|
1315
|
-
* Private properties
|
|
1316
|
-
*/
|
|
1317
|
-
#clientConfig;
|
|
1318
|
-
#httpRequest;
|
|
1319
|
-
/**
|
|
1320
|
-
* Instance properties
|
|
1321
|
-
*/
|
|
1322
|
-
listen = _listen;
|
|
1362
|
+
};
|
|
1363
|
+
_clientConfig = /* @__PURE__ */ new WeakMap(), _httpRequest = /* @__PURE__ */ new WeakMap();
|
|
1364
|
+
let ObservableSanityClient = _ObservableSanityClient;
|
|
1365
|
+
var _clientConfig2, _httpRequest2;
|
|
1366
|
+
const _SanityClient = class _SanityClient2 {
|
|
1323
1367
|
constructor(httpRequest, config = defaultConfig) {
|
|
1324
|
-
this.config(config), this
|
|
1368
|
+
__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);
|
|
1325
1369
|
}
|
|
1326
1370
|
/**
|
|
1327
1371
|
* Clone the client - returns a new instance
|
|
1328
1372
|
*/
|
|
1329
1373
|
clone() {
|
|
1330
|
-
return new
|
|
1374
|
+
return new _SanityClient2(__privateGet(this, _httpRequest2), this.config());
|
|
1331
1375
|
}
|
|
1332
1376
|
config(newConfig) {
|
|
1333
1377
|
if (newConfig === void 0)
|
|
1334
|
-
return { ...this
|
|
1335
|
-
if (this
|
|
1378
|
+
return { ...__privateGet(this, _clientConfig2) };
|
|
1379
|
+
if (__privateGet(this, _clientConfig2) && __privateGet(this, _clientConfig2).allowReconfigure === !1)
|
|
1336
1380
|
throw new Error(
|
|
1337
1381
|
"Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
|
|
1338
1382
|
);
|
|
1339
|
-
return this.observable && this.observable.config(newConfig), this
|
|
1383
|
+
return this.observable && this.observable.config(newConfig), __privateSet(this, _clientConfig2, initConfig(newConfig, __privateGet(this, _clientConfig2) || {})), this;
|
|
1340
1384
|
}
|
|
1341
1385
|
/**
|
|
1342
1386
|
* Clone the client with a new (partial) configuration.
|
|
@@ -1345,12 +1389,12 @@ class SanityClient {
|
|
|
1345
1389
|
*/
|
|
1346
1390
|
withConfig(newConfig) {
|
|
1347
1391
|
const thisConfig = this.config();
|
|
1348
|
-
return new
|
|
1392
|
+
return new _SanityClient2(__privateGet(this, _httpRequest2), {
|
|
1349
1393
|
...thisConfig,
|
|
1350
1394
|
...newConfig,
|
|
1351
1395
|
stega: {
|
|
1352
1396
|
...thisConfig.stega || {},
|
|
1353
|
-
...typeof newConfig
|
|
1397
|
+
...typeof (newConfig == null ? void 0 : newConfig.stega) == "boolean" ? { enabled: newConfig.stega } : (newConfig == null ? void 0 : newConfig.stega) || {}
|
|
1354
1398
|
}
|
|
1355
1399
|
});
|
|
1356
1400
|
}
|
|
@@ -1358,8 +1402,8 @@ class SanityClient {
|
|
|
1358
1402
|
return lastValueFrom(
|
|
1359
1403
|
_fetch(
|
|
1360
1404
|
this,
|
|
1361
|
-
this
|
|
1362
|
-
this
|
|
1405
|
+
__privateGet(this, _httpRequest2),
|
|
1406
|
+
__privateGet(this, _clientConfig2).stega,
|
|
1363
1407
|
query,
|
|
1364
1408
|
params,
|
|
1365
1409
|
options
|
|
@@ -1373,7 +1417,7 @@ class SanityClient {
|
|
|
1373
1417
|
* @param options - Request options
|
|
1374
1418
|
*/
|
|
1375
1419
|
getDocument(id, options) {
|
|
1376
|
-
return lastValueFrom(_getDocument(this, this
|
|
1420
|
+
return lastValueFrom(_getDocument(this, __privateGet(this, _httpRequest2), id, options));
|
|
1377
1421
|
}
|
|
1378
1422
|
/**
|
|
1379
1423
|
* Fetch multiple documents in one request.
|
|
@@ -1385,28 +1429,28 @@ class SanityClient {
|
|
|
1385
1429
|
* @param options - Request options
|
|
1386
1430
|
*/
|
|
1387
1431
|
getDocuments(ids, options) {
|
|
1388
|
-
return lastValueFrom(_getDocuments(this, this
|
|
1432
|
+
return lastValueFrom(_getDocuments(this, __privateGet(this, _httpRequest2), ids, options));
|
|
1389
1433
|
}
|
|
1390
1434
|
create(document, options) {
|
|
1391
1435
|
return lastValueFrom(
|
|
1392
|
-
_create(this, this
|
|
1436
|
+
_create(this, __privateGet(this, _httpRequest2), document, "create", options)
|
|
1393
1437
|
);
|
|
1394
1438
|
}
|
|
1395
1439
|
createIfNotExists(document, options) {
|
|
1396
1440
|
return lastValueFrom(
|
|
1397
|
-
_createIfNotExists(this, this
|
|
1441
|
+
_createIfNotExists(this, __privateGet(this, _httpRequest2), document, options)
|
|
1398
1442
|
);
|
|
1399
1443
|
}
|
|
1400
1444
|
createOrReplace(document, options) {
|
|
1401
1445
|
return lastValueFrom(
|
|
1402
|
-
_createOrReplace(this, this
|
|
1446
|
+
_createOrReplace(this, __privateGet(this, _httpRequest2), document, options)
|
|
1403
1447
|
);
|
|
1404
1448
|
}
|
|
1405
1449
|
delete(selection, options) {
|
|
1406
|
-
return lastValueFrom(_delete(this, this
|
|
1450
|
+
return lastValueFrom(_delete(this, __privateGet(this, _httpRequest2), selection, options));
|
|
1407
1451
|
}
|
|
1408
1452
|
mutate(operations, options) {
|
|
1409
|
-
return lastValueFrom(_mutate(this, this
|
|
1453
|
+
return lastValueFrom(_mutate(this, __privateGet(this, _httpRequest2), operations, options));
|
|
1410
1454
|
}
|
|
1411
1455
|
/**
|
|
1412
1456
|
* Create a new buildable patch of operations to perform
|
|
@@ -1434,7 +1478,7 @@ class SanityClient {
|
|
|
1434
1478
|
* @param options - Action options
|
|
1435
1479
|
*/
|
|
1436
1480
|
action(operations, options) {
|
|
1437
|
-
return lastValueFrom(_action(this, this
|
|
1481
|
+
return lastValueFrom(_action(this, __privateGet(this, _httpRequest2), operations, options));
|
|
1438
1482
|
}
|
|
1439
1483
|
/**
|
|
1440
1484
|
* Perform a request against the Sanity API
|
|
@@ -1444,7 +1488,7 @@ class SanityClient {
|
|
|
1444
1488
|
* @returns Promise resolving to the response body
|
|
1445
1489
|
*/
|
|
1446
1490
|
request(options) {
|
|
1447
|
-
return lastValueFrom(_request(this, this
|
|
1491
|
+
return lastValueFrom(_request(this, __privateGet(this, _httpRequest2), options));
|
|
1448
1492
|
}
|
|
1449
1493
|
/**
|
|
1450
1494
|
* Perform an HTTP request a `/data` sub-endpoint
|
|
@@ -1457,7 +1501,7 @@ class SanityClient {
|
|
|
1457
1501
|
* @internal
|
|
1458
1502
|
*/
|
|
1459
1503
|
dataRequest(endpoint, body, options) {
|
|
1460
|
-
return lastValueFrom(_dataRequest(this, this
|
|
1504
|
+
return lastValueFrom(_dataRequest(this, __privateGet(this, _httpRequest2), endpoint, body, options));
|
|
1461
1505
|
}
|
|
1462
1506
|
/**
|
|
1463
1507
|
* Get a Sanity API URL for the URI provided
|
|
@@ -1477,7 +1521,9 @@ class SanityClient {
|
|
|
1477
1521
|
getDataUrl(operation, path) {
|
|
1478
1522
|
return _getDataUrl(this, operation, path);
|
|
1479
1523
|
}
|
|
1480
|
-
}
|
|
1524
|
+
};
|
|
1525
|
+
_clientConfig2 = /* @__PURE__ */ new WeakMap(), _httpRequest2 = /* @__PURE__ */ new WeakMap();
|
|
1526
|
+
let SanityClient = _SanityClient;
|
|
1481
1527
|
function defineCreateClientExports(envMiddleware2, ClassConstructor) {
|
|
1482
1528
|
const defaultRequester = defineHttpRequest(envMiddleware2);
|
|
1483
1529
|
return { requester: defaultRequester, createClient: (config) => new ClassConstructor(
|