@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.cjs
CHANGED
|
@@ -19,25 +19,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
19
19
|
mod
|
|
20
20
|
));
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
22
|
-
var getIt = require("get-it"), middleware$1 = require("get-it/middleware"), rxjs = require("rxjs"), stegaClean = require("./_chunks-cjs/stegaClean.cjs"),
|
|
22
|
+
var getIt = require("get-it"), middleware$1 = require("get-it/middleware"), rxjs = require("rxjs"), operators = require("rxjs/operators"), stegaClean = require("./_chunks-cjs/stegaClean.cjs"), __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);
|
|
23
23
|
class ClientError extends Error {
|
|
24
|
-
response;
|
|
25
|
-
statusCode = 400;
|
|
26
|
-
responseBody;
|
|
27
|
-
details;
|
|
28
24
|
constructor(res) {
|
|
29
25
|
const props = extractErrorProps(res);
|
|
30
|
-
super(props.message), Object.assign(this, props);
|
|
26
|
+
super(props.message), __publicField$3(this, "response"), __publicField$3(this, "statusCode", 400), __publicField$3(this, "responseBody"), __publicField$3(this, "details"), Object.assign(this, props);
|
|
31
27
|
}
|
|
32
28
|
}
|
|
33
29
|
class ServerError extends Error {
|
|
34
|
-
response;
|
|
35
|
-
statusCode = 500;
|
|
36
|
-
responseBody;
|
|
37
|
-
details;
|
|
38
30
|
constructor(res) {
|
|
39
31
|
const props = extractErrorProps(res);
|
|
40
|
-
super(props.message), Object.assign(this, props);
|
|
32
|
+
super(props.message), __publicField$3(this, "response"), __publicField$3(this, "statusCode", 500), __publicField$3(this, "responseBody"), __publicField$3(this, "details"), Object.assign(this, props);
|
|
41
33
|
}
|
|
42
34
|
}
|
|
43
35
|
function extractErrorProps(res) {
|
|
@@ -51,7 +43,10 @@ function extractErrorProps(res) {
|
|
|
51
43
|
if (body.error && body.message)
|
|
52
44
|
return props.message = `${body.error} - ${body.message}`, props;
|
|
53
45
|
if (isMutationError(body) || isActionError(body)) {
|
|
54
|
-
const allItems = body.error.items || [], items = allItems.slice(0, 5).map((item) =>
|
|
46
|
+
const allItems = body.error.items || [], items = allItems.slice(0, 5).map((item) => {
|
|
47
|
+
var _a;
|
|
48
|
+
return (_a = item.error) == null ? void 0 : _a.description;
|
|
49
|
+
}).filter(Boolean);
|
|
55
50
|
let itemsStr = items.length ? `:
|
|
56
51
|
- ${items.join(`
|
|
57
52
|
- `)}` : "";
|
|
@@ -167,11 +162,17 @@ const VALID_ASSET_TYPES = ["image", "file"], VALID_INSERT_LOCATIONS = ["before",
|
|
|
167
162
|
);
|
|
168
163
|
return tag;
|
|
169
164
|
};
|
|
165
|
+
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) => {
|
|
166
|
+
if (!member.has(obj))
|
|
167
|
+
throw TypeError("Cannot " + msg);
|
|
168
|
+
}, __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) => {
|
|
169
|
+
if (member.has(obj))
|
|
170
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
171
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
172
|
+
}, __privateSet$7 = (obj, member, value, setter) => (__accessCheck$7(obj, member, "write to private field"), member.set(obj, value), value);
|
|
170
173
|
class BasePatch {
|
|
171
|
-
selection;
|
|
172
|
-
operations;
|
|
173
174
|
constructor(selection, operations = {}) {
|
|
174
|
-
this.selection = selection, this.operations = operations;
|
|
175
|
+
__publicField$2(this, "selection"), __publicField$2(this, "operations"), this.selection = selection, this.operations = operations;
|
|
175
176
|
}
|
|
176
177
|
/**
|
|
177
178
|
* Sets the given attributes to the document. Does NOT merge objects.
|
|
@@ -302,52 +303,62 @@ class BasePatch {
|
|
|
302
303
|
return this._assign(op, props, !1);
|
|
303
304
|
}
|
|
304
305
|
}
|
|
305
|
-
|
|
306
|
-
|
|
306
|
+
var _client$6;
|
|
307
|
+
const _ObservablePatch = class _ObservablePatch2 extends BasePatch {
|
|
307
308
|
constructor(selection, operations, client) {
|
|
308
|
-
super(selection, operations), this
|
|
309
|
+
super(selection, operations), __privateAdd$7(this, _client$6, void 0), __privateSet$7(this, _client$6, client);
|
|
309
310
|
}
|
|
310
311
|
/**
|
|
311
312
|
* Clones the patch
|
|
312
313
|
*/
|
|
313
314
|
clone() {
|
|
314
|
-
return new
|
|
315
|
+
return new _ObservablePatch2(this.selection, { ...this.operations }, __privateGet$7(this, _client$6));
|
|
315
316
|
}
|
|
316
317
|
commit(options) {
|
|
317
|
-
if (!this
|
|
318
|
+
if (!__privateGet$7(this, _client$6))
|
|
318
319
|
throw new Error(
|
|
319
320
|
"No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
|
|
320
321
|
);
|
|
321
322
|
const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
|
|
322
|
-
return this
|
|
323
|
+
return __privateGet$7(this, _client$6).mutate({ patch: this.serialize() }, opts);
|
|
323
324
|
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
|
|
325
|
+
};
|
|
326
|
+
_client$6 = /* @__PURE__ */ new WeakMap();
|
|
327
|
+
let ObservablePatch = _ObservablePatch;
|
|
328
|
+
var _client2$5;
|
|
329
|
+
const _Patch = class _Patch2 extends BasePatch {
|
|
327
330
|
constructor(selection, operations, client) {
|
|
328
|
-
super(selection, operations), this
|
|
331
|
+
super(selection, operations), __privateAdd$7(this, _client2$5, void 0), __privateSet$7(this, _client2$5, client);
|
|
329
332
|
}
|
|
330
333
|
/**
|
|
331
334
|
* Clones the patch
|
|
332
335
|
*/
|
|
333
336
|
clone() {
|
|
334
|
-
return new
|
|
337
|
+
return new _Patch2(this.selection, { ...this.operations }, __privateGet$7(this, _client2$5));
|
|
335
338
|
}
|
|
336
339
|
commit(options) {
|
|
337
|
-
if (!this
|
|
340
|
+
if (!__privateGet$7(this, _client2$5))
|
|
338
341
|
throw new Error(
|
|
339
342
|
"No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
|
|
340
343
|
);
|
|
341
344
|
const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
|
|
342
|
-
return this
|
|
345
|
+
return __privateGet$7(this, _client2$5).mutate({ patch: this.serialize() }, opts);
|
|
343
346
|
}
|
|
344
|
-
}
|
|
347
|
+
};
|
|
348
|
+
_client2$5 = /* @__PURE__ */ new WeakMap();
|
|
349
|
+
let Patch = _Patch;
|
|
350
|
+
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) => {
|
|
351
|
+
if (!member.has(obj))
|
|
352
|
+
throw TypeError("Cannot " + msg);
|
|
353
|
+
}, __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) => {
|
|
354
|
+
if (member.has(obj))
|
|
355
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
356
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
357
|
+
}, __privateSet$6 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), member.set(obj, value), value);
|
|
345
358
|
const defaultMutateOptions = { returnDocuments: !1 };
|
|
346
359
|
class BaseTransaction {
|
|
347
|
-
operations;
|
|
348
|
-
trxId;
|
|
349
360
|
constructor(operations = [], transactionId) {
|
|
350
|
-
this.operations = operations, this.trxId = transactionId;
|
|
361
|
+
__publicField$1(this, "operations"), __publicField$1(this, "trxId"), this.operations = operations, this.trxId = transactionId;
|
|
351
362
|
}
|
|
352
363
|
/**
|
|
353
364
|
* 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.
|
|
@@ -412,23 +423,23 @@ class BaseTransaction {
|
|
|
412
423
|
return this.operations.push(mut), this;
|
|
413
424
|
}
|
|
414
425
|
}
|
|
415
|
-
|
|
416
|
-
|
|
426
|
+
var _client$5;
|
|
427
|
+
const _Transaction = class _Transaction2 extends BaseTransaction {
|
|
417
428
|
constructor(operations, client, transactionId) {
|
|
418
|
-
super(operations, transactionId), this
|
|
429
|
+
super(operations, transactionId), __privateAdd$6(this, _client$5, void 0), __privateSet$6(this, _client$5, client);
|
|
419
430
|
}
|
|
420
431
|
/**
|
|
421
432
|
* Clones the transaction
|
|
422
433
|
*/
|
|
423
434
|
clone() {
|
|
424
|
-
return new
|
|
435
|
+
return new _Transaction2([...this.operations], __privateGet$6(this, _client$5), this.trxId);
|
|
425
436
|
}
|
|
426
437
|
commit(options) {
|
|
427
|
-
if (!this
|
|
438
|
+
if (!__privateGet$6(this, _client$5))
|
|
428
439
|
throw new Error(
|
|
429
440
|
"No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
|
|
430
441
|
);
|
|
431
|
-
return this
|
|
442
|
+
return __privateGet$6(this, _client$5).mutate(
|
|
432
443
|
this.serialize(),
|
|
433
444
|
Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
|
|
434
445
|
);
|
|
@@ -438,31 +449,33 @@ class Transaction extends BaseTransaction {
|
|
|
438
449
|
if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof Patch)
|
|
439
450
|
return this._add({ patch: patchOrDocumentId.serialize() });
|
|
440
451
|
if (isBuilder) {
|
|
441
|
-
const patch = patchOps(new Patch(patchOrDocumentId, {}, this
|
|
452
|
+
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$6(this, _client$5)));
|
|
442
453
|
if (!(patch instanceof Patch))
|
|
443
454
|
throw new Error("function passed to `patch()` must return the patch");
|
|
444
455
|
return this._add({ patch: patch.serialize() });
|
|
445
456
|
}
|
|
446
457
|
return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
|
|
447
458
|
}
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
|
|
459
|
+
};
|
|
460
|
+
_client$5 = /* @__PURE__ */ new WeakMap();
|
|
461
|
+
let Transaction = _Transaction;
|
|
462
|
+
var _client2$4;
|
|
463
|
+
const _ObservableTransaction = class _ObservableTransaction2 extends BaseTransaction {
|
|
451
464
|
constructor(operations, client, transactionId) {
|
|
452
|
-
super(operations, transactionId), this
|
|
465
|
+
super(operations, transactionId), __privateAdd$6(this, _client2$4, void 0), __privateSet$6(this, _client2$4, client);
|
|
453
466
|
}
|
|
454
467
|
/**
|
|
455
468
|
* Clones the transaction
|
|
456
469
|
*/
|
|
457
470
|
clone() {
|
|
458
|
-
return new
|
|
471
|
+
return new _ObservableTransaction2([...this.operations], __privateGet$6(this, _client2$4), this.trxId);
|
|
459
472
|
}
|
|
460
473
|
commit(options) {
|
|
461
|
-
if (!this
|
|
474
|
+
if (!__privateGet$6(this, _client2$4))
|
|
462
475
|
throw new Error(
|
|
463
476
|
"No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
|
|
464
477
|
);
|
|
465
|
-
return this
|
|
478
|
+
return __privateGet$6(this, _client2$4).mutate(
|
|
466
479
|
this.serialize(),
|
|
467
480
|
Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
|
|
468
481
|
);
|
|
@@ -472,14 +485,16 @@ class ObservableTransaction extends BaseTransaction {
|
|
|
472
485
|
if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof ObservablePatch)
|
|
473
486
|
return this._add({ patch: patchOrDocumentId.serialize() });
|
|
474
487
|
if (isBuilder) {
|
|
475
|
-
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, this
|
|
488
|
+
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$6(this, _client2$4)));
|
|
476
489
|
if (!(patch instanceof ObservablePatch))
|
|
477
490
|
throw new Error("function passed to `patch()` must return the patch");
|
|
478
491
|
return this._add({ patch: patch.serialize() });
|
|
479
492
|
}
|
|
480
493
|
return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
|
|
481
494
|
}
|
|
482
|
-
}
|
|
495
|
+
};
|
|
496
|
+
_client2$4 = /* @__PURE__ */ new WeakMap();
|
|
497
|
+
let ObservableTransaction = _ObservableTransaction;
|
|
483
498
|
const BASE_URL = "https://www.sanity.io/help/";
|
|
484
499
|
function generateHelpUrl(slug) {
|
|
485
500
|
return BASE_URL + slug;
|
|
@@ -645,14 +660,24 @@ function _fetch(client, httpRequest, _stega, query, _params = {}, options = {})
|
|
|
645
660
|
) : $request.pipe(operators.map(mapResponse));
|
|
646
661
|
}
|
|
647
662
|
function _getDocument(client, httpRequest, id, opts = {}) {
|
|
648
|
-
const options = {
|
|
663
|
+
const options = {
|
|
664
|
+
uri: _getDataUrl(client, "doc", id),
|
|
665
|
+
json: !0,
|
|
666
|
+
tag: opts.tag,
|
|
667
|
+
signal: opts.signal
|
|
668
|
+
};
|
|
649
669
|
return _requestObservable(client, httpRequest, options).pipe(
|
|
650
670
|
operators.filter(isResponse),
|
|
651
671
|
operators.map((event) => event.body.documents && event.body.documents[0])
|
|
652
672
|
);
|
|
653
673
|
}
|
|
654
674
|
function _getDocuments(client, httpRequest, ids, opts = {}) {
|
|
655
|
-
const options = {
|
|
675
|
+
const options = {
|
|
676
|
+
uri: _getDataUrl(client, "doc", ids.join(",")),
|
|
677
|
+
json: !0,
|
|
678
|
+
tag: opts.tag,
|
|
679
|
+
signal: opts.signal
|
|
680
|
+
};
|
|
656
681
|
return _requestObservable(client, httpRequest, options).pipe(
|
|
657
682
|
operators.filter(isResponse),
|
|
658
683
|
operators.map((event) => {
|
|
@@ -736,11 +761,12 @@ function _create(client, httpRequest, doc, op, options = {}) {
|
|
|
736
761
|
return _dataRequest(client, httpRequest, "mutate", { mutations: [mutation] }, opts);
|
|
737
762
|
}
|
|
738
763
|
function _requestObservable(client, httpRequest, options) {
|
|
764
|
+
var _a, _b;
|
|
739
765
|
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;
|
|
740
|
-
let useCdn = (options.useCdn
|
|
766
|
+
let useCdn = ((_a = options.useCdn) != null ? _a : config.useCdn) && canUseCdn;
|
|
741
767
|
const tag = options.tag && config.requestTagPrefix ? [config.requestTagPrefix, options.tag].join(".") : options.tag || config.requestTagPrefix;
|
|
742
768
|
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) {
|
|
743
|
-
const resultSourceMap = options.resultSourceMap
|
|
769
|
+
const resultSourceMap = (_b = options.resultSourceMap) != null ? _b : config.resultSourceMap;
|
|
744
770
|
resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
|
|
745
771
|
const perspective = options.perspective || config.perspective;
|
|
746
772
|
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 });
|
|
@@ -784,29 +810,36 @@ function _withAbortSignal(signal) {
|
|
|
784
810
|
}
|
|
785
811
|
const isDomExceptionSupported = !!globalThis.DOMException;
|
|
786
812
|
function _createAbortError(signal) {
|
|
813
|
+
var _a, _b;
|
|
787
814
|
if (isDomExceptionSupported)
|
|
788
|
-
return new DOMException(signal
|
|
789
|
-
const error = new Error(signal
|
|
815
|
+
return new DOMException((_a = signal == null ? void 0 : signal.reason) != null ? _a : "The operation was aborted.", "AbortError");
|
|
816
|
+
const error = new Error((_b = signal == null ? void 0 : signal.reason) != null ? _b : "The operation was aborted.");
|
|
790
817
|
return error.name = "AbortError", error;
|
|
791
818
|
}
|
|
819
|
+
var __accessCheck$5 = (obj, member, msg) => {
|
|
820
|
+
if (!member.has(obj))
|
|
821
|
+
throw TypeError("Cannot " + msg);
|
|
822
|
+
}, __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) => {
|
|
823
|
+
if (member.has(obj))
|
|
824
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
825
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
826
|
+
}, __privateSet$5 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value), _client$4, _httpRequest$4;
|
|
792
827
|
class ObservableAssetsClient {
|
|
793
|
-
#client;
|
|
794
|
-
#httpRequest;
|
|
795
828
|
constructor(client, httpRequest) {
|
|
796
|
-
this
|
|
829
|
+
__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);
|
|
797
830
|
}
|
|
798
831
|
upload(assetType, body, options) {
|
|
799
|
-
return _upload(this
|
|
832
|
+
return _upload(__privateGet$5(this, _client$4), __privateGet$5(this, _httpRequest$4), assetType, body, options);
|
|
800
833
|
}
|
|
801
834
|
}
|
|
835
|
+
_client$4 = /* @__PURE__ */ new WeakMap(), _httpRequest$4 = /* @__PURE__ */ new WeakMap();
|
|
836
|
+
var _client2$3, _httpRequest2$4;
|
|
802
837
|
class AssetsClient {
|
|
803
|
-
#client;
|
|
804
|
-
#httpRequest;
|
|
805
838
|
constructor(client, httpRequest) {
|
|
806
|
-
this
|
|
839
|
+
__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);
|
|
807
840
|
}
|
|
808
841
|
upload(assetType, body, options) {
|
|
809
|
-
const observable = _upload(this
|
|
842
|
+
const observable = _upload(__privateGet$5(this, _client2$3), __privateGet$5(this, _httpRequest2$4), assetType, body, options);
|
|
810
843
|
return rxjs.lastValueFrom(
|
|
811
844
|
observable.pipe(
|
|
812
845
|
operators.filter((event) => event.type === "response"),
|
|
@@ -817,6 +850,7 @@ class AssetsClient {
|
|
|
817
850
|
);
|
|
818
851
|
}
|
|
819
852
|
}
|
|
853
|
+
_client2$3 = /* @__PURE__ */ new WeakMap(), _httpRequest2$4 = /* @__PURE__ */ new WeakMap();
|
|
820
854
|
function _upload(client, httpRequest, assetType, body, opts = {}) {
|
|
821
855
|
validateAssetType(assetType);
|
|
822
856
|
let meta = opts.extract || void 0;
|
|
@@ -925,22 +959,30 @@ function cooerceError(err) {
|
|
|
925
959
|
function extractErrorMessage(err) {
|
|
926
960
|
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";
|
|
927
961
|
}
|
|
962
|
+
var __accessCheck$4 = (obj, member, msg) => {
|
|
963
|
+
if (!member.has(obj))
|
|
964
|
+
throw TypeError("Cannot " + msg);
|
|
965
|
+
}, __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) => {
|
|
966
|
+
if (member.has(obj))
|
|
967
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
968
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
969
|
+
}, __privateSet$4 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
|
|
928
970
|
const requiredApiVersion = "2021-03-26";
|
|
971
|
+
var _client$3;
|
|
929
972
|
class LiveClient {
|
|
930
|
-
#client;
|
|
931
973
|
constructor(client) {
|
|
932
|
-
this
|
|
974
|
+
__privateAdd$4(this, _client$3, void 0), __privateSet$4(this, _client$3, client);
|
|
933
975
|
}
|
|
934
976
|
/**
|
|
935
977
|
* Requires `apiVersion` to be `2021-03-26` or later.
|
|
936
978
|
*/
|
|
937
979
|
events() {
|
|
938
|
-
const apiVersion = this
|
|
980
|
+
const apiVersion = __privateGet$4(this, _client$3).config().apiVersion.replace(/^v/, "");
|
|
939
981
|
if (apiVersion !== "X" && apiVersion < requiredApiVersion)
|
|
940
982
|
throw new Error(
|
|
941
983
|
`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.`
|
|
942
984
|
);
|
|
943
|
-
const path = _getDataUrl(this
|
|
985
|
+
const path = _getDataUrl(__privateGet$4(this, _client$3), "live/events"), url = new URL(__privateGet$4(this, _client$3).getUrl(path, !1)), listenFor = ["restart", "message"];
|
|
944
986
|
return new rxjs.Observable((observer) => {
|
|
945
987
|
let es, reconnectTimer, stopped = !1, unsubscribed = !1;
|
|
946
988
|
open();
|
|
@@ -989,6 +1031,7 @@ class LiveClient {
|
|
|
989
1031
|
});
|
|
990
1032
|
}
|
|
991
1033
|
}
|
|
1034
|
+
_client$3 = /* @__PURE__ */ new WeakMap();
|
|
992
1035
|
function parseEvent(event) {
|
|
993
1036
|
try {
|
|
994
1037
|
const data = event.data && JSON.parse(event.data) || {};
|
|
@@ -997,11 +1040,17 @@ function parseEvent(event) {
|
|
|
997
1040
|
return err;
|
|
998
1041
|
}
|
|
999
1042
|
}
|
|
1043
|
+
var __accessCheck$3 = (obj, member, msg) => {
|
|
1044
|
+
if (!member.has(obj))
|
|
1045
|
+
throw TypeError("Cannot " + msg);
|
|
1046
|
+
}, __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) => {
|
|
1047
|
+
if (member.has(obj))
|
|
1048
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
1049
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1050
|
+
}, __privateSet$3 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value), _client$2, _httpRequest$3;
|
|
1000
1051
|
class ObservableDatasetsClient {
|
|
1001
|
-
#client;
|
|
1002
|
-
#httpRequest;
|
|
1003
1052
|
constructor(client, httpRequest) {
|
|
1004
|
-
this
|
|
1053
|
+
__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);
|
|
1005
1054
|
}
|
|
1006
1055
|
/**
|
|
1007
1056
|
* Create a new dataset with the given name
|
|
@@ -1010,7 +1059,7 @@ class ObservableDatasetsClient {
|
|
|
1010
1059
|
* @param options - Options for the dataset
|
|
1011
1060
|
*/
|
|
1012
1061
|
create(name2, options) {
|
|
1013
|
-
return _modify(this
|
|
1062
|
+
return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "PUT", name2, options);
|
|
1014
1063
|
}
|
|
1015
1064
|
/**
|
|
1016
1065
|
* Edit a dataset with the given name
|
|
@@ -1019,7 +1068,7 @@ class ObservableDatasetsClient {
|
|
|
1019
1068
|
* @param options - New options for the dataset
|
|
1020
1069
|
*/
|
|
1021
1070
|
edit(name2, options) {
|
|
1022
|
-
return _modify(this
|
|
1071
|
+
return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "PATCH", name2, options);
|
|
1023
1072
|
}
|
|
1024
1073
|
/**
|
|
1025
1074
|
* Delete a dataset with the given name
|
|
@@ -1027,23 +1076,23 @@ class ObservableDatasetsClient {
|
|
|
1027
1076
|
* @param name - Name of the dataset to delete
|
|
1028
1077
|
*/
|
|
1029
1078
|
delete(name2) {
|
|
1030
|
-
return _modify(this
|
|
1079
|
+
return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "DELETE", name2);
|
|
1031
1080
|
}
|
|
1032
1081
|
/**
|
|
1033
1082
|
* Fetch a list of datasets for the configured project
|
|
1034
1083
|
*/
|
|
1035
1084
|
list() {
|
|
1036
|
-
return _request(this
|
|
1085
|
+
return _request(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), {
|
|
1037
1086
|
uri: "/datasets",
|
|
1038
1087
|
tag: null
|
|
1039
1088
|
});
|
|
1040
1089
|
}
|
|
1041
1090
|
}
|
|
1091
|
+
_client$2 = /* @__PURE__ */ new WeakMap(), _httpRequest$3 = /* @__PURE__ */ new WeakMap();
|
|
1092
|
+
var _client2$2, _httpRequest2$3;
|
|
1042
1093
|
class DatasetsClient {
|
|
1043
|
-
#client;
|
|
1044
|
-
#httpRequest;
|
|
1045
1094
|
constructor(client, httpRequest) {
|
|
1046
|
-
this
|
|
1095
|
+
__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);
|
|
1047
1096
|
}
|
|
1048
1097
|
/**
|
|
1049
1098
|
* Create a new dataset with the given name
|
|
@@ -1053,7 +1102,7 @@ class DatasetsClient {
|
|
|
1053
1102
|
*/
|
|
1054
1103
|
create(name2, options) {
|
|
1055
1104
|
return rxjs.lastValueFrom(
|
|
1056
|
-
_modify(this
|
|
1105
|
+
_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PUT", name2, options)
|
|
1057
1106
|
);
|
|
1058
1107
|
}
|
|
1059
1108
|
/**
|
|
@@ -1064,7 +1113,7 @@ class DatasetsClient {
|
|
|
1064
1113
|
*/
|
|
1065
1114
|
edit(name2, options) {
|
|
1066
1115
|
return rxjs.lastValueFrom(
|
|
1067
|
-
_modify(this
|
|
1116
|
+
_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PATCH", name2, options)
|
|
1068
1117
|
);
|
|
1069
1118
|
}
|
|
1070
1119
|
/**
|
|
@@ -1073,17 +1122,18 @@ class DatasetsClient {
|
|
|
1073
1122
|
* @param name - Name of the dataset to delete
|
|
1074
1123
|
*/
|
|
1075
1124
|
delete(name2) {
|
|
1076
|
-
return rxjs.lastValueFrom(_modify(this
|
|
1125
|
+
return rxjs.lastValueFrom(_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "DELETE", name2));
|
|
1077
1126
|
}
|
|
1078
1127
|
/**
|
|
1079
1128
|
* Fetch a list of datasets for the configured project
|
|
1080
1129
|
*/
|
|
1081
1130
|
list() {
|
|
1082
1131
|
return rxjs.lastValueFrom(
|
|
1083
|
-
_request(this
|
|
1132
|
+
_request(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), { uri: "/datasets", tag: null })
|
|
1084
1133
|
);
|
|
1085
1134
|
}
|
|
1086
1135
|
}
|
|
1136
|
+
_client2$2 = /* @__PURE__ */ new WeakMap(), _httpRequest2$3 = /* @__PURE__ */ new WeakMap();
|
|
1087
1137
|
function _modify(client, httpRequest, method, name2, options) {
|
|
1088
1138
|
return dataset(name2), _request(client, httpRequest, {
|
|
1089
1139
|
method,
|
|
@@ -1092,15 +1142,21 @@ function _modify(client, httpRequest, method, name2, options) {
|
|
|
1092
1142
|
tag: null
|
|
1093
1143
|
});
|
|
1094
1144
|
}
|
|
1145
|
+
var __accessCheck$2 = (obj, member, msg) => {
|
|
1146
|
+
if (!member.has(obj))
|
|
1147
|
+
throw TypeError("Cannot " + msg);
|
|
1148
|
+
}, __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) => {
|
|
1149
|
+
if (member.has(obj))
|
|
1150
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
1151
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1152
|
+
}, __privateSet$2 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), member.set(obj, value), value), _client$1, _httpRequest$2;
|
|
1095
1153
|
class ObservableProjectsClient {
|
|
1096
|
-
#client;
|
|
1097
|
-
#httpRequest;
|
|
1098
1154
|
constructor(client, httpRequest) {
|
|
1099
|
-
this
|
|
1155
|
+
__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);
|
|
1100
1156
|
}
|
|
1101
1157
|
list(options) {
|
|
1102
|
-
const uri = options
|
|
1103
|
-
return _request(this
|
|
1158
|
+
const uri = (options == null ? void 0 : options.includeMembers) === !1 ? "/projects?includeMembers=false" : "/projects";
|
|
1159
|
+
return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), { uri });
|
|
1104
1160
|
}
|
|
1105
1161
|
/**
|
|
1106
1162
|
* Fetch a project by project ID
|
|
@@ -1108,18 +1164,18 @@ class ObservableProjectsClient {
|
|
|
1108
1164
|
* @param projectId - ID of the project to fetch
|
|
1109
1165
|
*/
|
|
1110
1166
|
getById(projectId2) {
|
|
1111
|
-
return _request(this
|
|
1167
|
+
return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), { uri: `/projects/${projectId2}` });
|
|
1112
1168
|
}
|
|
1113
1169
|
}
|
|
1170
|
+
_client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */ new WeakMap();
|
|
1171
|
+
var _client2$1, _httpRequest2$2;
|
|
1114
1172
|
class ProjectsClient {
|
|
1115
|
-
#client;
|
|
1116
|
-
#httpRequest;
|
|
1117
1173
|
constructor(client, httpRequest) {
|
|
1118
|
-
this
|
|
1174
|
+
__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);
|
|
1119
1175
|
}
|
|
1120
1176
|
list(options) {
|
|
1121
|
-
const uri = options
|
|
1122
|
-
return rxjs.lastValueFrom(_request(this
|
|
1177
|
+
const uri = (options == null ? void 0 : options.includeMembers) === !1 ? "/projects?includeMembers=false" : "/projects";
|
|
1178
|
+
return rxjs.lastValueFrom(_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), { uri }));
|
|
1123
1179
|
}
|
|
1124
1180
|
/**
|
|
1125
1181
|
* Fetch a project by project ID
|
|
@@ -1128,15 +1184,22 @@ class ProjectsClient {
|
|
|
1128
1184
|
*/
|
|
1129
1185
|
getById(projectId2) {
|
|
1130
1186
|
return rxjs.lastValueFrom(
|
|
1131
|
-
_request(this
|
|
1187
|
+
_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), { uri: `/projects/${projectId2}` })
|
|
1132
1188
|
);
|
|
1133
1189
|
}
|
|
1134
1190
|
}
|
|
1191
|
+
_client2$1 = /* @__PURE__ */ new WeakMap(), _httpRequest2$2 = /* @__PURE__ */ new WeakMap();
|
|
1192
|
+
var __accessCheck$1 = (obj, member, msg) => {
|
|
1193
|
+
if (!member.has(obj))
|
|
1194
|
+
throw TypeError("Cannot " + msg);
|
|
1195
|
+
}, __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) => {
|
|
1196
|
+
if (member.has(obj))
|
|
1197
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
1198
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1199
|
+
}, __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value), _client, _httpRequest$1;
|
|
1135
1200
|
class ObservableUsersClient {
|
|
1136
|
-
#client;
|
|
1137
|
-
#httpRequest;
|
|
1138
1201
|
constructor(client, httpRequest) {
|
|
1139
|
-
this
|
|
1202
|
+
__privateAdd$1(this, _client, void 0), __privateAdd$1(this, _httpRequest$1, void 0), __privateSet$1(this, _client, client), __privateSet$1(this, _httpRequest$1, httpRequest);
|
|
1140
1203
|
}
|
|
1141
1204
|
/**
|
|
1142
1205
|
* Fetch a user by user ID
|
|
@@ -1145,17 +1208,17 @@ class ObservableUsersClient {
|
|
|
1145
1208
|
*/
|
|
1146
1209
|
getById(id) {
|
|
1147
1210
|
return _request(
|
|
1148
|
-
this
|
|
1149
|
-
this
|
|
1211
|
+
__privateGet$1(this, _client),
|
|
1212
|
+
__privateGet$1(this, _httpRequest$1),
|
|
1150
1213
|
{ uri: `/users/${id}` }
|
|
1151
1214
|
);
|
|
1152
1215
|
}
|
|
1153
1216
|
}
|
|
1217
|
+
_client = /* @__PURE__ */ new WeakMap(), _httpRequest$1 = /* @__PURE__ */ new WeakMap();
|
|
1218
|
+
var _client2, _httpRequest2$1;
|
|
1154
1219
|
class UsersClient {
|
|
1155
|
-
#client;
|
|
1156
|
-
#httpRequest;
|
|
1157
1220
|
constructor(client, httpRequest) {
|
|
1158
|
-
this
|
|
1221
|
+
__privateAdd$1(this, _client2, void 0), __privateAdd$1(this, _httpRequest2$1, void 0), __privateSet$1(this, _client2, client), __privateSet$1(this, _httpRequest2$1, httpRequest);
|
|
1159
1222
|
}
|
|
1160
1223
|
/**
|
|
1161
1224
|
* Fetch a user by user ID
|
|
@@ -1164,44 +1227,39 @@ class UsersClient {
|
|
|
1164
1227
|
*/
|
|
1165
1228
|
getById(id) {
|
|
1166
1229
|
return rxjs.lastValueFrom(
|
|
1167
|
-
_request(this
|
|
1230
|
+
_request(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), {
|
|
1168
1231
|
uri: `/users/${id}`
|
|
1169
1232
|
})
|
|
1170
1233
|
);
|
|
1171
1234
|
}
|
|
1172
1235
|
}
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
#httpRequest;
|
|
1184
|
-
/**
|
|
1185
|
-
* Instance properties
|
|
1186
|
-
*/
|
|
1187
|
-
listen = _listen;
|
|
1236
|
+
_client2 = /* @__PURE__ */ new WeakMap(), _httpRequest2$1 = /* @__PURE__ */ new WeakMap();
|
|
1237
|
+
var __defProp2 = Object.defineProperty, __defNormalProp = (obj, key, value) => key in obj ? __defProp2(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) => {
|
|
1238
|
+
if (!member.has(obj))
|
|
1239
|
+
throw TypeError("Cannot " + msg);
|
|
1240
|
+
}, __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd = (obj, member, value) => {
|
|
1241
|
+
if (member.has(obj))
|
|
1242
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
1243
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1244
|
+
}, __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value), _clientConfig, _httpRequest;
|
|
1245
|
+
const _ObservableSanityClient = class _ObservableSanityClient2 {
|
|
1188
1246
|
constructor(httpRequest, config = defaultConfig) {
|
|
1189
|
-
this.config(config), this
|
|
1247
|
+
__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));
|
|
1190
1248
|
}
|
|
1191
1249
|
/**
|
|
1192
1250
|
* Clone the client - returns a new instance
|
|
1193
1251
|
*/
|
|
1194
1252
|
clone() {
|
|
1195
|
-
return new
|
|
1253
|
+
return new _ObservableSanityClient2(__privateGet(this, _httpRequest), this.config());
|
|
1196
1254
|
}
|
|
1197
1255
|
config(newConfig) {
|
|
1198
1256
|
if (newConfig === void 0)
|
|
1199
|
-
return { ...this
|
|
1200
|
-
if (this
|
|
1257
|
+
return { ...__privateGet(this, _clientConfig) };
|
|
1258
|
+
if (__privateGet(this, _clientConfig) && __privateGet(this, _clientConfig).allowReconfigure === !1)
|
|
1201
1259
|
throw new Error(
|
|
1202
1260
|
"Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
|
|
1203
1261
|
);
|
|
1204
|
-
return this
|
|
1262
|
+
return __privateSet(this, _clientConfig, initConfig(newConfig, __privateGet(this, _clientConfig) || {})), this;
|
|
1205
1263
|
}
|
|
1206
1264
|
/**
|
|
1207
1265
|
* Clone the client with a new (partial) configuration.
|
|
@@ -1210,20 +1268,20 @@ class ObservableSanityClient {
|
|
|
1210
1268
|
*/
|
|
1211
1269
|
withConfig(newConfig) {
|
|
1212
1270
|
const thisConfig = this.config();
|
|
1213
|
-
return new
|
|
1271
|
+
return new _ObservableSanityClient2(__privateGet(this, _httpRequest), {
|
|
1214
1272
|
...thisConfig,
|
|
1215
1273
|
...newConfig,
|
|
1216
1274
|
stega: {
|
|
1217
1275
|
...thisConfig.stega || {},
|
|
1218
|
-
...typeof newConfig
|
|
1276
|
+
...typeof (newConfig == null ? void 0 : newConfig.stega) == "boolean" ? { enabled: newConfig.stega } : (newConfig == null ? void 0 : newConfig.stega) || {}
|
|
1219
1277
|
}
|
|
1220
1278
|
});
|
|
1221
1279
|
}
|
|
1222
1280
|
fetch(query, params, options) {
|
|
1223
1281
|
return _fetch(
|
|
1224
1282
|
this,
|
|
1225
|
-
this
|
|
1226
|
-
this
|
|
1283
|
+
__privateGet(this, _httpRequest),
|
|
1284
|
+
__privateGet(this, _clientConfig).stega,
|
|
1227
1285
|
query,
|
|
1228
1286
|
params,
|
|
1229
1287
|
options
|
|
@@ -1236,7 +1294,7 @@ class ObservableSanityClient {
|
|
|
1236
1294
|
* @param options - Request options
|
|
1237
1295
|
*/
|
|
1238
1296
|
getDocument(id, options) {
|
|
1239
|
-
return _getDocument(this, this
|
|
1297
|
+
return _getDocument(this, __privateGet(this, _httpRequest), id, options);
|
|
1240
1298
|
}
|
|
1241
1299
|
/**
|
|
1242
1300
|
* Fetch multiple documents in one request.
|
|
@@ -1248,22 +1306,22 @@ class ObservableSanityClient {
|
|
|
1248
1306
|
* @param options - Request options
|
|
1249
1307
|
*/
|
|
1250
1308
|
getDocuments(ids, options) {
|
|
1251
|
-
return _getDocuments(this, this
|
|
1309
|
+
return _getDocuments(this, __privateGet(this, _httpRequest), ids, options);
|
|
1252
1310
|
}
|
|
1253
1311
|
create(document, options) {
|
|
1254
|
-
return _create(this, this
|
|
1312
|
+
return _create(this, __privateGet(this, _httpRequest), document, "create", options);
|
|
1255
1313
|
}
|
|
1256
1314
|
createIfNotExists(document, options) {
|
|
1257
|
-
return _createIfNotExists(this, this
|
|
1315
|
+
return _createIfNotExists(this, __privateGet(this, _httpRequest), document, options);
|
|
1258
1316
|
}
|
|
1259
1317
|
createOrReplace(document, options) {
|
|
1260
|
-
return _createOrReplace(this, this
|
|
1318
|
+
return _createOrReplace(this, __privateGet(this, _httpRequest), document, options);
|
|
1261
1319
|
}
|
|
1262
1320
|
delete(selection, options) {
|
|
1263
|
-
return _delete(this, this
|
|
1321
|
+
return _delete(this, __privateGet(this, _httpRequest), selection, options);
|
|
1264
1322
|
}
|
|
1265
1323
|
mutate(operations, options) {
|
|
1266
|
-
return _mutate(this, this
|
|
1324
|
+
return _mutate(this, __privateGet(this, _httpRequest), operations, options);
|
|
1267
1325
|
}
|
|
1268
1326
|
/**
|
|
1269
1327
|
* Create a new buildable patch of operations to perform
|
|
@@ -1290,7 +1348,7 @@ class ObservableSanityClient {
|
|
|
1290
1348
|
* @param options - Action options
|
|
1291
1349
|
*/
|
|
1292
1350
|
action(operations, options) {
|
|
1293
|
-
return _action(this, this
|
|
1351
|
+
return _action(this, __privateGet(this, _httpRequest), operations, options);
|
|
1294
1352
|
}
|
|
1295
1353
|
/**
|
|
1296
1354
|
* Perform an HTTP request against the Sanity API
|
|
@@ -1298,7 +1356,7 @@ class ObservableSanityClient {
|
|
|
1298
1356
|
* @param options - Request options
|
|
1299
1357
|
*/
|
|
1300
1358
|
request(options) {
|
|
1301
|
-
return _request(this, this
|
|
1359
|
+
return _request(this, __privateGet(this, _httpRequest), options);
|
|
1302
1360
|
}
|
|
1303
1361
|
/**
|
|
1304
1362
|
* Get a Sanity API URL for the URI provided
|
|
@@ -1318,43 +1376,28 @@ class ObservableSanityClient {
|
|
|
1318
1376
|
getDataUrl(operation, path) {
|
|
1319
1377
|
return _getDataUrl(this, operation, path);
|
|
1320
1378
|
}
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
projects;
|
|
1327
|
-
users;
|
|
1328
|
-
/**
|
|
1329
|
-
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
1330
|
-
*/
|
|
1331
|
-
observable;
|
|
1332
|
-
/**
|
|
1333
|
-
* Private properties
|
|
1334
|
-
*/
|
|
1335
|
-
#clientConfig;
|
|
1336
|
-
#httpRequest;
|
|
1337
|
-
/**
|
|
1338
|
-
* Instance properties
|
|
1339
|
-
*/
|
|
1340
|
-
listen = _listen;
|
|
1379
|
+
};
|
|
1380
|
+
_clientConfig = /* @__PURE__ */ new WeakMap(), _httpRequest = /* @__PURE__ */ new WeakMap();
|
|
1381
|
+
let ObservableSanityClient = _ObservableSanityClient;
|
|
1382
|
+
var _clientConfig2, _httpRequest2;
|
|
1383
|
+
const _SanityClient = class _SanityClient2 {
|
|
1341
1384
|
constructor(httpRequest, config = defaultConfig) {
|
|
1342
|
-
this.config(config), this
|
|
1385
|
+
__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);
|
|
1343
1386
|
}
|
|
1344
1387
|
/**
|
|
1345
1388
|
* Clone the client - returns a new instance
|
|
1346
1389
|
*/
|
|
1347
1390
|
clone() {
|
|
1348
|
-
return new
|
|
1391
|
+
return new _SanityClient2(__privateGet(this, _httpRequest2), this.config());
|
|
1349
1392
|
}
|
|
1350
1393
|
config(newConfig) {
|
|
1351
1394
|
if (newConfig === void 0)
|
|
1352
|
-
return { ...this
|
|
1353
|
-
if (this
|
|
1395
|
+
return { ...__privateGet(this, _clientConfig2) };
|
|
1396
|
+
if (__privateGet(this, _clientConfig2) && __privateGet(this, _clientConfig2).allowReconfigure === !1)
|
|
1354
1397
|
throw new Error(
|
|
1355
1398
|
"Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
|
|
1356
1399
|
);
|
|
1357
|
-
return this.observable && this.observable.config(newConfig), this
|
|
1400
|
+
return this.observable && this.observable.config(newConfig), __privateSet(this, _clientConfig2, initConfig(newConfig, __privateGet(this, _clientConfig2) || {})), this;
|
|
1358
1401
|
}
|
|
1359
1402
|
/**
|
|
1360
1403
|
* Clone the client with a new (partial) configuration.
|
|
@@ -1363,12 +1406,12 @@ class SanityClient {
|
|
|
1363
1406
|
*/
|
|
1364
1407
|
withConfig(newConfig) {
|
|
1365
1408
|
const thisConfig = this.config();
|
|
1366
|
-
return new
|
|
1409
|
+
return new _SanityClient2(__privateGet(this, _httpRequest2), {
|
|
1367
1410
|
...thisConfig,
|
|
1368
1411
|
...newConfig,
|
|
1369
1412
|
stega: {
|
|
1370
1413
|
...thisConfig.stega || {},
|
|
1371
|
-
...typeof newConfig
|
|
1414
|
+
...typeof (newConfig == null ? void 0 : newConfig.stega) == "boolean" ? { enabled: newConfig.stega } : (newConfig == null ? void 0 : newConfig.stega) || {}
|
|
1372
1415
|
}
|
|
1373
1416
|
});
|
|
1374
1417
|
}
|
|
@@ -1376,8 +1419,8 @@ class SanityClient {
|
|
|
1376
1419
|
return rxjs.lastValueFrom(
|
|
1377
1420
|
_fetch(
|
|
1378
1421
|
this,
|
|
1379
|
-
this
|
|
1380
|
-
this
|
|
1422
|
+
__privateGet(this, _httpRequest2),
|
|
1423
|
+
__privateGet(this, _clientConfig2).stega,
|
|
1381
1424
|
query,
|
|
1382
1425
|
params,
|
|
1383
1426
|
options
|
|
@@ -1391,7 +1434,7 @@ class SanityClient {
|
|
|
1391
1434
|
* @param options - Request options
|
|
1392
1435
|
*/
|
|
1393
1436
|
getDocument(id, options) {
|
|
1394
|
-
return rxjs.lastValueFrom(_getDocument(this, this
|
|
1437
|
+
return rxjs.lastValueFrom(_getDocument(this, __privateGet(this, _httpRequest2), id, options));
|
|
1395
1438
|
}
|
|
1396
1439
|
/**
|
|
1397
1440
|
* Fetch multiple documents in one request.
|
|
@@ -1403,28 +1446,28 @@ class SanityClient {
|
|
|
1403
1446
|
* @param options - Request options
|
|
1404
1447
|
*/
|
|
1405
1448
|
getDocuments(ids, options) {
|
|
1406
|
-
return rxjs.lastValueFrom(_getDocuments(this, this
|
|
1449
|
+
return rxjs.lastValueFrom(_getDocuments(this, __privateGet(this, _httpRequest2), ids, options));
|
|
1407
1450
|
}
|
|
1408
1451
|
create(document, options) {
|
|
1409
1452
|
return rxjs.lastValueFrom(
|
|
1410
|
-
_create(this, this
|
|
1453
|
+
_create(this, __privateGet(this, _httpRequest2), document, "create", options)
|
|
1411
1454
|
);
|
|
1412
1455
|
}
|
|
1413
1456
|
createIfNotExists(document, options) {
|
|
1414
1457
|
return rxjs.lastValueFrom(
|
|
1415
|
-
_createIfNotExists(this, this
|
|
1458
|
+
_createIfNotExists(this, __privateGet(this, _httpRequest2), document, options)
|
|
1416
1459
|
);
|
|
1417
1460
|
}
|
|
1418
1461
|
createOrReplace(document, options) {
|
|
1419
1462
|
return rxjs.lastValueFrom(
|
|
1420
|
-
_createOrReplace(this, this
|
|
1463
|
+
_createOrReplace(this, __privateGet(this, _httpRequest2), document, options)
|
|
1421
1464
|
);
|
|
1422
1465
|
}
|
|
1423
1466
|
delete(selection, options) {
|
|
1424
|
-
return rxjs.lastValueFrom(_delete(this, this
|
|
1467
|
+
return rxjs.lastValueFrom(_delete(this, __privateGet(this, _httpRequest2), selection, options));
|
|
1425
1468
|
}
|
|
1426
1469
|
mutate(operations, options) {
|
|
1427
|
-
return rxjs.lastValueFrom(_mutate(this, this
|
|
1470
|
+
return rxjs.lastValueFrom(_mutate(this, __privateGet(this, _httpRequest2), operations, options));
|
|
1428
1471
|
}
|
|
1429
1472
|
/**
|
|
1430
1473
|
* Create a new buildable patch of operations to perform
|
|
@@ -1452,7 +1495,7 @@ class SanityClient {
|
|
|
1452
1495
|
* @param options - Action options
|
|
1453
1496
|
*/
|
|
1454
1497
|
action(operations, options) {
|
|
1455
|
-
return rxjs.lastValueFrom(_action(this, this
|
|
1498
|
+
return rxjs.lastValueFrom(_action(this, __privateGet(this, _httpRequest2), operations, options));
|
|
1456
1499
|
}
|
|
1457
1500
|
/**
|
|
1458
1501
|
* Perform a request against the Sanity API
|
|
@@ -1462,7 +1505,7 @@ class SanityClient {
|
|
|
1462
1505
|
* @returns Promise resolving to the response body
|
|
1463
1506
|
*/
|
|
1464
1507
|
request(options) {
|
|
1465
|
-
return rxjs.lastValueFrom(_request(this, this
|
|
1508
|
+
return rxjs.lastValueFrom(_request(this, __privateGet(this, _httpRequest2), options));
|
|
1466
1509
|
}
|
|
1467
1510
|
/**
|
|
1468
1511
|
* Perform an HTTP request a `/data` sub-endpoint
|
|
@@ -1475,7 +1518,7 @@ class SanityClient {
|
|
|
1475
1518
|
* @internal
|
|
1476
1519
|
*/
|
|
1477
1520
|
dataRequest(endpoint, body, options) {
|
|
1478
|
-
return rxjs.lastValueFrom(_dataRequest(this, this
|
|
1521
|
+
return rxjs.lastValueFrom(_dataRequest(this, __privateGet(this, _httpRequest2), endpoint, body, options));
|
|
1479
1522
|
}
|
|
1480
1523
|
/**
|
|
1481
1524
|
* Get a Sanity API URL for the URI provided
|
|
@@ -1495,7 +1538,9 @@ class SanityClient {
|
|
|
1495
1538
|
getDataUrl(operation, path) {
|
|
1496
1539
|
return _getDataUrl(this, operation, path);
|
|
1497
1540
|
}
|
|
1498
|
-
}
|
|
1541
|
+
};
|
|
1542
|
+
_clientConfig2 = /* @__PURE__ */ new WeakMap(), _httpRequest2 = /* @__PURE__ */ new WeakMap();
|
|
1543
|
+
let SanityClient = _SanityClient;
|
|
1499
1544
|
function defineCreateClientExports(envMiddleware, ClassConstructor) {
|
|
1500
1545
|
const defaultRequester = defineHttpRequest(envMiddleware);
|
|
1501
1546
|
return { requester: defaultRequester, createClient: (config) => new ClassConstructor(
|
|
@@ -1513,7 +1558,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
1513
1558
|
return printNoDefaultExport(), createClient2(config);
|
|
1514
1559
|
};
|
|
1515
1560
|
}
|
|
1516
|
-
var name = "@sanity/client", version = "6.21.
|
|
1561
|
+
var name = "@sanity/client", version = "6.21.3-canary.0";
|
|
1517
1562
|
const middleware = [
|
|
1518
1563
|
middleware$1.debug({ verbose: !0, namespace: "sanity:client" }),
|
|
1519
1564
|
middleware$1.headers({ "User-Agent": `${name} ${version}` }),
|