@sanity/client 6.11.3 → 6.11.4-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/_chunks/{browserMiddleware-1MULg59S.cjs → browserMiddleware-EnEpy_gt.cjs} +247 -299
- package/dist/_chunks/browserMiddleware-EnEpy_gt.cjs.map +1 -0
- package/dist/_chunks/{browserMiddleware-heyg-fDk.js → browserMiddleware-nSeu_Rmf.js} +246 -299
- package/dist/_chunks/browserMiddleware-nSeu_Rmf.js.map +1 -0
- package/dist/_chunks/{nodeMiddleware-CHxg1-zH.cjs → nodeMiddleware-_hIIS1d7.cjs} +248 -300
- package/dist/_chunks/nodeMiddleware-_hIIS1d7.cjs.map +1 -0
- package/dist/_chunks/{nodeMiddleware-u_fUUnxa.js → nodeMiddleware-hZIb_1T_.js} +247 -300
- package/dist/_chunks/nodeMiddleware-hZIb_1T_.js.map +1 -0
- package/dist/_chunks/stegaEncodeSourceMap-4w5UCEGT.cjs +479 -0
- package/dist/_chunks/stegaEncodeSourceMap-4w5UCEGT.cjs.map +1 -0
- package/dist/_chunks/stegaEncodeSourceMap-SOgem38i.js +475 -0
- package/dist/_chunks/stegaEncodeSourceMap-SOgem38i.js.map +1 -0
- package/dist/_chunks/stegaEncodeSourceMap-Tuf6zjiN.cjs +230 -0
- package/dist/_chunks/stegaEncodeSourceMap-Tuf6zjiN.cjs.map +1 -0
- package/dist/_chunks/stegaEncodeSourceMap-zvyGxB_C.js +226 -0
- package/dist/_chunks/stegaEncodeSourceMap-zvyGxB_C.js.map +1 -0
- package/dist/index.browser.cjs +1 -1
- package/dist/index.browser.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +319 -49
- package/dist/index.js +2 -2
- package/dist/stega.browser.cjs +12 -695
- package/dist/stega.browser.cjs.map +1 -1
- package/dist/stega.browser.js +7 -690
- package/dist/stega.browser.js.map +1 -1
- package/dist/stega.cjs +12 -446
- package/dist/stega.cjs.js +3 -3
- package/dist/stega.cjs.map +1 -1
- package/dist/stega.d.ts +1418 -1422
- package/dist/stega.js +7 -441
- package/dist/stega.js.map +1 -1
- package/package.json +11 -9
- package/src/SanityClient.ts +152 -75
- package/src/assets/AssetsClient.ts +19 -10
- package/src/config.ts +34 -12
- package/src/data/dataMethods.ts +40 -14
- package/src/data/patch.ts +12 -10
- package/src/data/transaction.ts +13 -12
- package/src/datasets/DatasetsClient.ts +36 -16
- package/src/projects/ProjectsClient.ts +21 -12
- package/src/stega/index.browser.ts +3 -7
- package/src/stega/index.ts +3 -7
- package/src/stega/shared.ts +7 -5
- package/src/stega/types.ts +11 -18
- package/src/types.ts +107 -5
- package/src/users/UsersClient.ts +20 -13
- package/umd/sanityClient.js +3148 -2235
- package/umd/sanityClient.min.js +4 -3
- package/dist/_chunks/browserMiddleware-1MULg59S.cjs.map +0 -1
- package/dist/_chunks/browserMiddleware-heyg-fDk.js.map +0 -1
- package/dist/_chunks/nodeMiddleware-CHxg1-zH.cjs.map +0 -1
- package/dist/_chunks/nodeMiddleware-u_fUUnxa.js.map +0 -1
- package/src/stega/SanityStegaClient.ts +0 -298
- package/src/stega/config.ts +0 -76
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Observable, from, lastValueFrom } from 'rxjs';
|
|
2
|
+
import { combineLatestWith, map, filter } from 'rxjs/operators';
|
|
1
3
|
import { getIt } from 'get-it';
|
|
2
4
|
import { retry, jsonRequest, jsonResponse, progress, observable, debug, headers, agent } from 'get-it/middleware';
|
|
3
|
-
import { Observable, lastValueFrom } from 'rxjs';
|
|
4
|
-
import { map, filter } from 'rxjs/operators';
|
|
5
5
|
|
|
6
6
|
const MAX_ITEMS_IN_ERROR_MESSAGE = 5;
|
|
7
7
|
class ClientError extends Error {
|
|
@@ -203,25 +203,7 @@ const requestTag = (tag) => {
|
|
|
203
203
|
return tag;
|
|
204
204
|
};
|
|
205
205
|
|
|
206
|
-
|
|
207
|
-
if (!member.has(obj))
|
|
208
|
-
throw TypeError("Cannot " + msg);
|
|
209
|
-
};
|
|
210
|
-
var __privateGet$6 = (obj, member, getter) => {
|
|
211
|
-
__accessCheck$6(obj, member, "read from private field");
|
|
212
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
213
|
-
};
|
|
214
|
-
var __privateAdd$6 = (obj, member, value) => {
|
|
215
|
-
if (member.has(obj))
|
|
216
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
217
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
218
|
-
};
|
|
219
|
-
var __privateSet$6 = (obj, member, value, setter) => {
|
|
220
|
-
__accessCheck$6(obj, member, "write to private field");
|
|
221
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
222
|
-
return value;
|
|
223
|
-
};
|
|
224
|
-
var _client$5, _client2$5;
|
|
206
|
+
const clientSymbol$5 = Symbol("#client");
|
|
225
207
|
class BasePatch {
|
|
226
208
|
constructor(selection, operations = {}) {
|
|
227
209
|
this.selection = selection;
|
|
@@ -371,74 +353,52 @@ class BasePatch {
|
|
|
371
353
|
const _ObservablePatch = class _ObservablePatch extends BasePatch {
|
|
372
354
|
constructor(selection, operations, client) {
|
|
373
355
|
super(selection, operations);
|
|
374
|
-
|
|
375
|
-
__privateSet$6(this, _client$5, client);
|
|
356
|
+
this[clientSymbol$5] = client;
|
|
376
357
|
}
|
|
377
358
|
/**
|
|
378
359
|
* Clones the patch
|
|
379
360
|
*/
|
|
380
361
|
clone() {
|
|
381
|
-
return new _ObservablePatch(this.selection, { ...this.operations },
|
|
362
|
+
return new _ObservablePatch(this.selection, { ...this.operations }, this[clientSymbol$5]);
|
|
382
363
|
}
|
|
383
364
|
commit(options) {
|
|
384
|
-
if (!
|
|
365
|
+
if (!this[clientSymbol$5]) {
|
|
385
366
|
throw new Error(
|
|
386
367
|
"No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
|
|
387
368
|
);
|
|
388
369
|
}
|
|
389
370
|
const returnFirst = typeof this.selection === "string";
|
|
390
371
|
const opts = Object.assign({ returnFirst, returnDocuments: true }, options);
|
|
391
|
-
return
|
|
372
|
+
return this[clientSymbol$5].mutate({ patch: this.serialize() }, opts);
|
|
392
373
|
}
|
|
393
374
|
};
|
|
394
|
-
_client$5 = new WeakMap();
|
|
395
375
|
let ObservablePatch = _ObservablePatch;
|
|
396
376
|
const _Patch = class _Patch extends BasePatch {
|
|
397
377
|
constructor(selection, operations, client) {
|
|
398
378
|
super(selection, operations);
|
|
399
|
-
|
|
400
|
-
__privateSet$6(this, _client2$5, client);
|
|
379
|
+
this[clientSymbol$5] = client;
|
|
401
380
|
}
|
|
402
381
|
/**
|
|
403
382
|
* Clones the patch
|
|
404
383
|
*/
|
|
405
384
|
clone() {
|
|
406
|
-
return new _Patch(this.selection, { ...this.operations },
|
|
385
|
+
return new _Patch(this.selection, { ...this.operations }, this[clientSymbol$5]);
|
|
407
386
|
}
|
|
408
387
|
commit(options) {
|
|
409
|
-
if (!
|
|
388
|
+
if (!this[clientSymbol$5]) {
|
|
410
389
|
throw new Error(
|
|
411
390
|
"No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
|
|
412
391
|
);
|
|
413
392
|
}
|
|
414
393
|
const returnFirst = typeof this.selection === "string";
|
|
415
394
|
const opts = Object.assign({ returnFirst, returnDocuments: true }, options);
|
|
416
|
-
return
|
|
395
|
+
return this[clientSymbol$5].mutate({ patch: this.serialize() }, opts);
|
|
417
396
|
}
|
|
418
397
|
};
|
|
419
|
-
_client2$5 = new WeakMap();
|
|
420
398
|
let Patch = _Patch;
|
|
421
399
|
|
|
422
|
-
var __accessCheck$5 = (obj, member, msg) => {
|
|
423
|
-
if (!member.has(obj))
|
|
424
|
-
throw TypeError("Cannot " + msg);
|
|
425
|
-
};
|
|
426
|
-
var __privateGet$5 = (obj, member, getter) => {
|
|
427
|
-
__accessCheck$5(obj, member, "read from private field");
|
|
428
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
429
|
-
};
|
|
430
|
-
var __privateAdd$5 = (obj, member, value) => {
|
|
431
|
-
if (member.has(obj))
|
|
432
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
433
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
434
|
-
};
|
|
435
|
-
var __privateSet$5 = (obj, member, value, setter) => {
|
|
436
|
-
__accessCheck$5(obj, member, "write to private field");
|
|
437
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
438
|
-
return value;
|
|
439
|
-
};
|
|
440
|
-
var _client$4, _client2$4;
|
|
441
400
|
const defaultMutateOptions = { returnDocuments: false };
|
|
401
|
+
const clientSymbol$4 = Symbol("#client");
|
|
442
402
|
class BaseTransaction {
|
|
443
403
|
constructor(operations = [], transactionId) {
|
|
444
404
|
this.operations = operations;
|
|
@@ -522,22 +482,21 @@ class BaseTransaction {
|
|
|
522
482
|
const _Transaction = class _Transaction extends BaseTransaction {
|
|
523
483
|
constructor(operations, client, transactionId) {
|
|
524
484
|
super(operations, transactionId);
|
|
525
|
-
|
|
526
|
-
__privateSet$5(this, _client$4, client);
|
|
485
|
+
this[clientSymbol$4] = client;
|
|
527
486
|
}
|
|
528
487
|
/**
|
|
529
488
|
* Clones the transaction
|
|
530
489
|
*/
|
|
531
490
|
clone() {
|
|
532
|
-
return new _Transaction([...this.operations],
|
|
491
|
+
return new _Transaction([...this.operations], this[clientSymbol$4], this.trxId);
|
|
533
492
|
}
|
|
534
493
|
commit(options) {
|
|
535
|
-
if (!
|
|
494
|
+
if (!this[clientSymbol$4]) {
|
|
536
495
|
throw new Error(
|
|
537
496
|
"No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
|
|
538
497
|
);
|
|
539
498
|
}
|
|
540
|
-
return
|
|
499
|
+
return this[clientSymbol$4].mutate(
|
|
541
500
|
this.serialize(),
|
|
542
501
|
Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
|
|
543
502
|
);
|
|
@@ -549,7 +508,7 @@ const _Transaction = class _Transaction extends BaseTransaction {
|
|
|
549
508
|
return this._add({ patch: patchOrDocumentId.serialize() });
|
|
550
509
|
}
|
|
551
510
|
if (isBuilder) {
|
|
552
|
-
const patch = patchOps(new Patch(patchOrDocumentId, {},
|
|
511
|
+
const patch = patchOps(new Patch(patchOrDocumentId, {}, this[clientSymbol$4]));
|
|
553
512
|
if (!(patch instanceof Patch)) {
|
|
554
513
|
throw new Error("function passed to `patch()` must return the patch");
|
|
555
514
|
}
|
|
@@ -558,27 +517,25 @@ const _Transaction = class _Transaction extends BaseTransaction {
|
|
|
558
517
|
return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
|
|
559
518
|
}
|
|
560
519
|
};
|
|
561
|
-
_client$4 = new WeakMap();
|
|
562
520
|
let Transaction = _Transaction;
|
|
563
521
|
const _ObservableTransaction = class _ObservableTransaction extends BaseTransaction {
|
|
564
522
|
constructor(operations, client, transactionId) {
|
|
565
523
|
super(operations, transactionId);
|
|
566
|
-
|
|
567
|
-
__privateSet$5(this, _client2$4, client);
|
|
524
|
+
this[clientSymbol$4] = client;
|
|
568
525
|
}
|
|
569
526
|
/**
|
|
570
527
|
* Clones the transaction
|
|
571
528
|
*/
|
|
572
529
|
clone() {
|
|
573
|
-
return new _ObservableTransaction([...this.operations],
|
|
530
|
+
return new _ObservableTransaction([...this.operations], this[clientSymbol$4], this.trxId);
|
|
574
531
|
}
|
|
575
532
|
commit(options) {
|
|
576
|
-
if (!
|
|
533
|
+
if (!this[clientSymbol$4]) {
|
|
577
534
|
throw new Error(
|
|
578
535
|
"No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
|
|
579
536
|
);
|
|
580
537
|
}
|
|
581
|
-
return
|
|
538
|
+
return this[clientSymbol$4].mutate(
|
|
582
539
|
this.serialize(),
|
|
583
540
|
Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
|
|
584
541
|
);
|
|
@@ -590,7 +547,7 @@ const _ObservableTransaction = class _ObservableTransaction extends BaseTransact
|
|
|
590
547
|
return this._add({ patch: patchOrDocumentId.serialize() });
|
|
591
548
|
}
|
|
592
549
|
if (isBuilder) {
|
|
593
|
-
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {},
|
|
550
|
+
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, this[clientSymbol$4]));
|
|
594
551
|
if (!(patch instanceof ObservablePatch)) {
|
|
595
552
|
throw new Error("function passed to `patch()` must return the patch");
|
|
596
553
|
}
|
|
@@ -599,7 +556,6 @@ const _ObservableTransaction = class _ObservableTransaction extends BaseTransact
|
|
|
599
556
|
return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
|
|
600
557
|
}
|
|
601
558
|
};
|
|
602
|
-
_client2$4 = new WeakMap();
|
|
603
559
|
let ObservableTransaction = _ObservableTransaction;
|
|
604
560
|
|
|
605
561
|
const BASE_URL = "https://www.sanity.io/help/";
|
|
@@ -651,7 +607,8 @@ const defaultCdnHost = "apicdn.sanity.io";
|
|
|
651
607
|
const defaultConfig = {
|
|
652
608
|
apiHost: "https://api.sanity.io",
|
|
653
609
|
apiVersion: "1",
|
|
654
|
-
useProjectHostname: true
|
|
610
|
+
useProjectHostname: true,
|
|
611
|
+
stega: { enabled: false }
|
|
655
612
|
};
|
|
656
613
|
const LOCALHOSTS = ["localhost", "127.0.0.1", "0.0.0.0"];
|
|
657
614
|
const isLocal = (host) => LOCALHOSTS.indexOf(host) !== -1;
|
|
@@ -678,11 +635,21 @@ const validateApiPerspective = function validateApiPerspective2(perspective) {
|
|
|
678
635
|
}
|
|
679
636
|
};
|
|
680
637
|
const initConfig = (config, prevConfig) => {
|
|
681
|
-
const specifiedConfig =
|
|
638
|
+
const specifiedConfig = {
|
|
639
|
+
...prevConfig,
|
|
640
|
+
...config,
|
|
641
|
+
stega: {
|
|
642
|
+
...typeof prevConfig.stega === "boolean" ? { enabled: prevConfig.stega } : prevConfig.stega || defaultConfig.stega,
|
|
643
|
+
...typeof config.stega === "boolean" ? { enabled: config.stega } : config.stega || {}
|
|
644
|
+
}
|
|
645
|
+
};
|
|
682
646
|
if (!specifiedConfig.apiVersion) {
|
|
683
647
|
printNoApiVersionSpecifiedWarning();
|
|
684
648
|
}
|
|
685
|
-
const newConfig =
|
|
649
|
+
const newConfig = {
|
|
650
|
+
...defaultConfig,
|
|
651
|
+
...specifiedConfig
|
|
652
|
+
};
|
|
686
653
|
const projectBased = newConfig.useProjectHostname;
|
|
687
654
|
if (typeof Promise === "undefined") {
|
|
688
655
|
const helpUrl = generateHelpUrl("js-client-promise-polyfill");
|
|
@@ -694,14 +661,25 @@ const initConfig = (config, prevConfig) => {
|
|
|
694
661
|
if (typeof newConfig.perspective === "string") {
|
|
695
662
|
validateApiPerspective(newConfig.perspective);
|
|
696
663
|
}
|
|
697
|
-
if ("
|
|
664
|
+
if ("encodeSourceMap" in newConfig) {
|
|
698
665
|
throw new Error(
|
|
699
|
-
"It looks like you're using options meant for '@sanity/preview-kit/client'
|
|
666
|
+
"It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMap' is not supported in '@sanity/client'. Did you mean 'stega.enabled'?"
|
|
700
667
|
);
|
|
701
668
|
}
|
|
702
|
-
if ("
|
|
669
|
+
if ("encodeSourceMapAtPath" in newConfig) {
|
|
703
670
|
throw new Error(
|
|
704
|
-
"It looks like you're using options meant for '@sanity/client
|
|
671
|
+
"It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMapAtPath' is not supported in '@sanity/client'. Did you mean 'stega.filter'?"
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
if (typeof newConfig.stega.enabled !== "boolean") {
|
|
675
|
+
throw new Error("stega.enabled must be a boolean, received ".concat(newConfig.stega.enabled));
|
|
676
|
+
}
|
|
677
|
+
if (newConfig.stega.enabled && newConfig.stega.studioUrl === void 0) {
|
|
678
|
+
throw new Error("stega.studioUrl must be defined when stega.enabled is true");
|
|
679
|
+
}
|
|
680
|
+
if (newConfig.stega.enabled && typeof newConfig.stega.studioUrl !== "string" && typeof newConfig.stega.studioUrl !== "function") {
|
|
681
|
+
throw new Error(
|
|
682
|
+
"stega.studioUrl must be a string or a function, received ".concat(newConfig.stega.studioUrl)
|
|
705
683
|
);
|
|
706
684
|
}
|
|
707
685
|
const isBrowser = typeof window !== "undefined" && window.location && window.location.hostname;
|
|
@@ -762,6 +740,22 @@ function requestOptions(config, overrides = {}) {
|
|
|
762
740
|
});
|
|
763
741
|
}
|
|
764
742
|
|
|
743
|
+
var s={0:8203,1:8204,2:8205,3:8290,4:8291,5:8288,6:65279,7:8289,8:119155,9:119156,a:119157,b:119158,c:119159,d:119160,e:119161,f:119162},c={0:8203,1:8204,2:8205,3:65279},d=new Array(4).fill(String.fromCodePoint(c[0])).join("");function E(t){let e=JSON.stringify(t);return `${d}${Array.from(e).map(r=>{let n=r.charCodeAt(0);if(n>255)throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${e} on character ${r} (${n})`);return Array.from(n.toString(4).padStart(4,"0")).map(o=>String.fromCodePoint(c[o])).join("")}).join("")}`}function I(t){return Number.isNaN(Number(t))?Boolean(Date.parse(t)):!1}function x(t){try{new URL(t,t.startsWith("/")?"https://acme.com":void 0);}catch{return !1}return !0}function b(t,e,r="auto"){return r===!0||r==="auto"&&(I(t)||x(t))?t:`${t}${E(e)}`}Object.fromEntries(Object.entries(c).map(t=>t.reverse()));Object.fromEntries(Object.entries(s).map(t=>t.reverse()));var S=`${Object.values(s).map(t=>`\\u{${t.toString(16)}}`).join("")}`,f=new RegExp(`[${S}]{4,}`,"gu");function X(t){var e;return {cleaned:t.replace(f,""),encoded:((e=t.match(f))==null?void 0:e[0])||""}}
|
|
744
|
+
|
|
745
|
+
function vercelStegaCleanAll(result) {
|
|
746
|
+
try {
|
|
747
|
+
return JSON.parse(
|
|
748
|
+
JSON.stringify(result, (key, value) => {
|
|
749
|
+
if (typeof value !== "string")
|
|
750
|
+
return value;
|
|
751
|
+
return X(value).cleaned;
|
|
752
|
+
})
|
|
753
|
+
);
|
|
754
|
+
} catch {
|
|
755
|
+
return result;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
765
759
|
const encodeQueryString = ({
|
|
766
760
|
query,
|
|
767
761
|
params = {},
|
|
@@ -803,21 +797,38 @@ const indexBy = (docs, attr) => docs.reduce((indexed, doc) => {
|
|
|
803
797
|
return indexed;
|
|
804
798
|
}, /* @__PURE__ */ Object.create(null));
|
|
805
799
|
const getQuerySizeLimit = 11264;
|
|
806
|
-
function _fetch(client, httpRequest, query,
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
800
|
+
function _fetch(client, httpRequest, _stega, query, _params = {}, options = {}) {
|
|
801
|
+
const stega = "stega" in options ? {
|
|
802
|
+
..._stega || {},
|
|
803
|
+
...typeof options.stega === "boolean" ? { enabled: options.stega } : options.stega || {}
|
|
804
|
+
} : _stega;
|
|
805
|
+
const params = stega.enabled ? vercelStegaCleanAll(_params) : _params;
|
|
812
806
|
const mapResponse = options.filterResponse === false ? (res) => res : (res) => res.result;
|
|
813
807
|
const { cache, next, ...opts } = {
|
|
814
808
|
// Opt out of setting a `signal` on an internal `fetch` if one isn't provided.
|
|
815
809
|
// This is necessary in React Server Components to avoid opting out of Request Memoization.
|
|
816
810
|
useAbortSignal: typeof options.signal !== "undefined",
|
|
811
|
+
// Set `resultSourceMap' when stega is enabled, as it's required for encoding.
|
|
812
|
+
resultSourceMap: stega.enabled ? "withKeyArraySelector" : options.resultSourceMap,
|
|
817
813
|
...options
|
|
818
814
|
};
|
|
819
815
|
const reqOpts = typeof cache !== "undefined" || typeof next !== "undefined" ? { ...opts, fetch: { cache, next } } : opts;
|
|
820
|
-
|
|
816
|
+
const $request = _dataRequest(client, httpRequest, "query", { query, params }, reqOpts);
|
|
817
|
+
return stega.enabled ? $request.pipe(
|
|
818
|
+
combineLatestWith(
|
|
819
|
+
from(
|
|
820
|
+
import('./stegaEncodeSourceMap-zvyGxB_C.js').then(function (n) { return n.stegaEncodeSourceMap$1; }).then(
|
|
821
|
+
({ stegaEncodeSourceMap }) => stegaEncodeSourceMap
|
|
822
|
+
)
|
|
823
|
+
)
|
|
824
|
+
),
|
|
825
|
+
map(
|
|
826
|
+
([res, stegaEncodeSourceMap]) => {
|
|
827
|
+
const result = stegaEncodeSourceMap(res.result, res.resultSourceMap, stega);
|
|
828
|
+
return mapResponse({ ...res, result });
|
|
829
|
+
}
|
|
830
|
+
)
|
|
831
|
+
) : $request.pipe(map(mapResponse));
|
|
821
832
|
}
|
|
822
833
|
function _getDocument(client, httpRequest, id, opts = {}) {
|
|
823
834
|
const options = { uri: _getDataUrl(client, "doc", id), json: true, tag: opts.tag };
|
|
@@ -1002,47 +1013,30 @@ function _createAbortError(signal) {
|
|
|
1002
1013
|
return error;
|
|
1003
1014
|
}
|
|
1004
1015
|
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
throw TypeError("Cannot " + msg);
|
|
1008
|
-
};
|
|
1009
|
-
var __privateGet$4 = (obj, member, getter) => {
|
|
1010
|
-
__accessCheck$4(obj, member, "read from private field");
|
|
1011
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
1012
|
-
};
|
|
1013
|
-
var __privateAdd$4 = (obj, member, value) => {
|
|
1014
|
-
if (member.has(obj))
|
|
1015
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
1016
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1017
|
-
};
|
|
1018
|
-
var __privateSet$4 = (obj, member, value, setter) => {
|
|
1019
|
-
__accessCheck$4(obj, member, "write to private field");
|
|
1020
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
1021
|
-
return value;
|
|
1022
|
-
};
|
|
1023
|
-
var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
|
|
1016
|
+
const clientSymbol$3 = Symbol("#client");
|
|
1017
|
+
const httpRequestSymbol$4 = Symbol("#httpRequest");
|
|
1024
1018
|
class ObservableAssetsClient {
|
|
1025
1019
|
constructor(client, httpRequest) {
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
__privateSet$4(this, _client$3, client);
|
|
1029
|
-
__privateSet$4(this, _httpRequest$4, httpRequest);
|
|
1020
|
+
this[clientSymbol$3] = client;
|
|
1021
|
+
this[httpRequestSymbol$4] = httpRequest;
|
|
1030
1022
|
}
|
|
1031
1023
|
upload(assetType, body, options) {
|
|
1032
|
-
return _upload(
|
|
1024
|
+
return _upload(this[clientSymbol$3], this[httpRequestSymbol$4], assetType, body, options);
|
|
1033
1025
|
}
|
|
1034
1026
|
}
|
|
1035
|
-
_client$3 = new WeakMap();
|
|
1036
|
-
_httpRequest$4 = new WeakMap();
|
|
1037
1027
|
class AssetsClient {
|
|
1038
1028
|
constructor(client, httpRequest) {
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
__privateSet$4(this, _client2$3, client);
|
|
1042
|
-
__privateSet$4(this, _httpRequest2$4, httpRequest);
|
|
1029
|
+
this[clientSymbol$3] = client;
|
|
1030
|
+
this[httpRequestSymbol$4] = httpRequest;
|
|
1043
1031
|
}
|
|
1044
1032
|
upload(assetType, body, options) {
|
|
1045
|
-
const observable = _upload(
|
|
1033
|
+
const observable = _upload(
|
|
1034
|
+
this[clientSymbol$3],
|
|
1035
|
+
this[httpRequestSymbol$4],
|
|
1036
|
+
assetType,
|
|
1037
|
+
body,
|
|
1038
|
+
options
|
|
1039
|
+
);
|
|
1046
1040
|
return lastValueFrom(
|
|
1047
1041
|
observable.pipe(
|
|
1048
1042
|
filter((event) => event.type === "response"),
|
|
@@ -1053,8 +1047,6 @@ class AssetsClient {
|
|
|
1053
1047
|
);
|
|
1054
1048
|
}
|
|
1055
1049
|
}
|
|
1056
|
-
_client2$3 = new WeakMap();
|
|
1057
|
-
_httpRequest2$4 = new WeakMap();
|
|
1058
1050
|
function _upload(client, httpRequest, assetType, body, opts = {}) {
|
|
1059
1051
|
validateAssetType(assetType);
|
|
1060
1052
|
let meta = opts.extract || void 0;
|
|
@@ -1245,31 +1237,12 @@ function extractErrorMessage(err) {
|
|
|
1245
1237
|
return typeof err.error === "string" ? err.error : JSON.stringify(err.error, null, 2);
|
|
1246
1238
|
}
|
|
1247
1239
|
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
throw TypeError("Cannot " + msg);
|
|
1251
|
-
};
|
|
1252
|
-
var __privateGet$3 = (obj, member, getter) => {
|
|
1253
|
-
__accessCheck$3(obj, member, "read from private field");
|
|
1254
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
1255
|
-
};
|
|
1256
|
-
var __privateAdd$3 = (obj, member, value) => {
|
|
1257
|
-
if (member.has(obj))
|
|
1258
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
1259
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1260
|
-
};
|
|
1261
|
-
var __privateSet$3 = (obj, member, value, setter) => {
|
|
1262
|
-
__accessCheck$3(obj, member, "write to private field");
|
|
1263
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
1264
|
-
return value;
|
|
1265
|
-
};
|
|
1266
|
-
var _client$2, _httpRequest$3, _client2$2, _httpRequest2$3;
|
|
1240
|
+
const clientSymbol$2 = Symbol("#client");
|
|
1241
|
+
const httpRequestSymbol$3 = Symbol("#httpRequest");
|
|
1267
1242
|
class ObservableDatasetsClient {
|
|
1268
1243
|
constructor(client, httpRequest) {
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
__privateSet$3(this, _client$2, client);
|
|
1272
|
-
__privateSet$3(this, _httpRequest$3, httpRequest);
|
|
1244
|
+
this[clientSymbol$2] = client;
|
|
1245
|
+
this[httpRequestSymbol$3] = httpRequest;
|
|
1273
1246
|
}
|
|
1274
1247
|
/**
|
|
1275
1248
|
* Create a new dataset with the given name
|
|
@@ -1278,7 +1251,13 @@ class ObservableDatasetsClient {
|
|
|
1278
1251
|
* @param options - Options for the dataset
|
|
1279
1252
|
*/
|
|
1280
1253
|
create(name, options) {
|
|
1281
|
-
return _modify(
|
|
1254
|
+
return _modify(
|
|
1255
|
+
this[clientSymbol$2],
|
|
1256
|
+
this[httpRequestSymbol$3],
|
|
1257
|
+
"PUT",
|
|
1258
|
+
name,
|
|
1259
|
+
options
|
|
1260
|
+
);
|
|
1282
1261
|
}
|
|
1283
1262
|
/**
|
|
1284
1263
|
* Edit a dataset with the given name
|
|
@@ -1287,7 +1266,13 @@ class ObservableDatasetsClient {
|
|
|
1287
1266
|
* @param options - New options for the dataset
|
|
1288
1267
|
*/
|
|
1289
1268
|
edit(name, options) {
|
|
1290
|
-
return _modify(
|
|
1269
|
+
return _modify(
|
|
1270
|
+
this[clientSymbol$2],
|
|
1271
|
+
this[httpRequestSymbol$3],
|
|
1272
|
+
"PATCH",
|
|
1273
|
+
name,
|
|
1274
|
+
options
|
|
1275
|
+
);
|
|
1291
1276
|
}
|
|
1292
1277
|
/**
|
|
1293
1278
|
* Delete a dataset with the given name
|
|
@@ -1295,26 +1280,22 @@ class ObservableDatasetsClient {
|
|
|
1295
1280
|
* @param name - Name of the dataset to delete
|
|
1296
1281
|
*/
|
|
1297
1282
|
delete(name) {
|
|
1298
|
-
return _modify(
|
|
1283
|
+
return _modify(this[clientSymbol$2], this[httpRequestSymbol$3], "DELETE", name);
|
|
1299
1284
|
}
|
|
1300
1285
|
/**
|
|
1301
1286
|
* Fetch a list of datasets for the configured project
|
|
1302
1287
|
*/
|
|
1303
1288
|
list() {
|
|
1304
|
-
return _request(
|
|
1289
|
+
return _request(this[clientSymbol$2], this[httpRequestSymbol$3], {
|
|
1305
1290
|
uri: "/datasets",
|
|
1306
1291
|
tag: null
|
|
1307
1292
|
});
|
|
1308
1293
|
}
|
|
1309
1294
|
}
|
|
1310
|
-
_client$2 = new WeakMap();
|
|
1311
|
-
_httpRequest$3 = new WeakMap();
|
|
1312
1295
|
class DatasetsClient {
|
|
1313
1296
|
constructor(client, httpRequest) {
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
__privateSet$3(this, _client2$2, client);
|
|
1317
|
-
__privateSet$3(this, _httpRequest2$3, httpRequest);
|
|
1297
|
+
this[clientSymbol$2] = client;
|
|
1298
|
+
this[httpRequestSymbol$3] = httpRequest;
|
|
1318
1299
|
}
|
|
1319
1300
|
/**
|
|
1320
1301
|
* Create a new dataset with the given name
|
|
@@ -1324,7 +1305,7 @@ class DatasetsClient {
|
|
|
1324
1305
|
*/
|
|
1325
1306
|
create(name, options) {
|
|
1326
1307
|
return lastValueFrom(
|
|
1327
|
-
_modify(
|
|
1308
|
+
_modify(this[clientSymbol$2], this[httpRequestSymbol$3], "PUT", name, options)
|
|
1328
1309
|
);
|
|
1329
1310
|
}
|
|
1330
1311
|
/**
|
|
@@ -1335,7 +1316,7 @@ class DatasetsClient {
|
|
|
1335
1316
|
*/
|
|
1336
1317
|
edit(name, options) {
|
|
1337
1318
|
return lastValueFrom(
|
|
1338
|
-
_modify(
|
|
1319
|
+
_modify(this[clientSymbol$2], this[httpRequestSymbol$3], "PATCH", name, options)
|
|
1339
1320
|
);
|
|
1340
1321
|
}
|
|
1341
1322
|
/**
|
|
@@ -1344,19 +1325,22 @@ class DatasetsClient {
|
|
|
1344
1325
|
* @param name - Name of the dataset to delete
|
|
1345
1326
|
*/
|
|
1346
1327
|
delete(name) {
|
|
1347
|
-
return lastValueFrom(
|
|
1328
|
+
return lastValueFrom(
|
|
1329
|
+
_modify(this[clientSymbol$2], this[httpRequestSymbol$3], "DELETE", name)
|
|
1330
|
+
);
|
|
1348
1331
|
}
|
|
1349
1332
|
/**
|
|
1350
1333
|
* Fetch a list of datasets for the configured project
|
|
1351
1334
|
*/
|
|
1352
1335
|
list() {
|
|
1353
1336
|
return lastValueFrom(
|
|
1354
|
-
_request(
|
|
1337
|
+
_request(this[clientSymbol$2], this[httpRequestSymbol$3], {
|
|
1338
|
+
uri: "/datasets",
|
|
1339
|
+
tag: null
|
|
1340
|
+
})
|
|
1355
1341
|
);
|
|
1356
1342
|
}
|
|
1357
1343
|
}
|
|
1358
|
-
_client2$2 = new WeakMap();
|
|
1359
|
-
_httpRequest2$3 = new WeakMap();
|
|
1360
1344
|
function _modify(client, httpRequest, method, name, options) {
|
|
1361
1345
|
dataset(name);
|
|
1362
1346
|
return _request(client, httpRequest, {
|
|
@@ -1367,35 +1351,16 @@ function _modify(client, httpRequest, method, name, options) {
|
|
|
1367
1351
|
});
|
|
1368
1352
|
}
|
|
1369
1353
|
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
throw TypeError("Cannot " + msg);
|
|
1373
|
-
};
|
|
1374
|
-
var __privateGet$2 = (obj, member, getter) => {
|
|
1375
|
-
__accessCheck$2(obj, member, "read from private field");
|
|
1376
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
1377
|
-
};
|
|
1378
|
-
var __privateAdd$2 = (obj, member, value) => {
|
|
1379
|
-
if (member.has(obj))
|
|
1380
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
1381
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1382
|
-
};
|
|
1383
|
-
var __privateSet$2 = (obj, member, value, setter) => {
|
|
1384
|
-
__accessCheck$2(obj, member, "write to private field");
|
|
1385
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
1386
|
-
return value;
|
|
1387
|
-
};
|
|
1388
|
-
var _client$1, _httpRequest$2, _client2$1, _httpRequest2$2;
|
|
1354
|
+
const clientSymbol$1 = Symbol("#client");
|
|
1355
|
+
const httpRequestSymbol$2 = Symbol("#httpRequest");
|
|
1389
1356
|
class ObservableProjectsClient {
|
|
1390
1357
|
constructor(client, httpRequest) {
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
__privateSet$2(this, _client$1, client);
|
|
1394
|
-
__privateSet$2(this, _httpRequest$2, httpRequest);
|
|
1358
|
+
this[clientSymbol$1] = client;
|
|
1359
|
+
this[httpRequestSymbol$2] = httpRequest;
|
|
1395
1360
|
}
|
|
1396
1361
|
list(options) {
|
|
1397
1362
|
const uri = (options == null ? void 0 : options.includeMembers) === false ? "/projects?includeMembers=false" : "/projects";
|
|
1398
|
-
return _request(
|
|
1363
|
+
return _request(this[clientSymbol$1], this[httpRequestSymbol$2], { uri });
|
|
1399
1364
|
}
|
|
1400
1365
|
/**
|
|
1401
1366
|
* Fetch a project by project ID
|
|
@@ -1403,21 +1368,21 @@ class ObservableProjectsClient {
|
|
|
1403
1368
|
* @param projectId - ID of the project to fetch
|
|
1404
1369
|
*/
|
|
1405
1370
|
getById(projectId) {
|
|
1406
|
-
return _request(
|
|
1371
|
+
return _request(this[clientSymbol$1], this[httpRequestSymbol$2], {
|
|
1372
|
+
uri: "/projects/".concat(projectId)
|
|
1373
|
+
});
|
|
1407
1374
|
}
|
|
1408
1375
|
}
|
|
1409
|
-
_client$1 = new WeakMap();
|
|
1410
|
-
_httpRequest$2 = new WeakMap();
|
|
1411
1376
|
class ProjectsClient {
|
|
1412
1377
|
constructor(client, httpRequest) {
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
__privateSet$2(this, _client2$1, client);
|
|
1416
|
-
__privateSet$2(this, _httpRequest2$2, httpRequest);
|
|
1378
|
+
this[clientSymbol$1] = client;
|
|
1379
|
+
this[httpRequestSymbol$2] = httpRequest;
|
|
1417
1380
|
}
|
|
1418
1381
|
list(options) {
|
|
1419
1382
|
const uri = (options == null ? void 0 : options.includeMembers) === false ? "/projects?includeMembers=false" : "/projects";
|
|
1420
|
-
return lastValueFrom(
|
|
1383
|
+
return lastValueFrom(
|
|
1384
|
+
_request(this[clientSymbol$1], this[httpRequestSymbol$2], { uri })
|
|
1385
|
+
);
|
|
1421
1386
|
}
|
|
1422
1387
|
/**
|
|
1423
1388
|
* Fetch a project by project ID
|
|
@@ -1426,38 +1391,19 @@ class ProjectsClient {
|
|
|
1426
1391
|
*/
|
|
1427
1392
|
getById(projectId) {
|
|
1428
1393
|
return lastValueFrom(
|
|
1429
|
-
_request(
|
|
1394
|
+
_request(this[clientSymbol$1], this[httpRequestSymbol$2], {
|
|
1395
|
+
uri: "/projects/".concat(projectId)
|
|
1396
|
+
})
|
|
1430
1397
|
);
|
|
1431
1398
|
}
|
|
1432
1399
|
}
|
|
1433
|
-
_client2$1 = new WeakMap();
|
|
1434
|
-
_httpRequest2$2 = new WeakMap();
|
|
1435
1400
|
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
throw TypeError("Cannot " + msg);
|
|
1439
|
-
};
|
|
1440
|
-
var __privateGet$1 = (obj, member, getter) => {
|
|
1441
|
-
__accessCheck$1(obj, member, "read from private field");
|
|
1442
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
1443
|
-
};
|
|
1444
|
-
var __privateAdd$1 = (obj, member, value) => {
|
|
1445
|
-
if (member.has(obj))
|
|
1446
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
1447
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1448
|
-
};
|
|
1449
|
-
var __privateSet$1 = (obj, member, value, setter) => {
|
|
1450
|
-
__accessCheck$1(obj, member, "write to private field");
|
|
1451
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
1452
|
-
return value;
|
|
1453
|
-
};
|
|
1454
|
-
var _client, _httpRequest$1, _client2, _httpRequest2$1;
|
|
1401
|
+
const clientSymbol = Symbol("#client");
|
|
1402
|
+
const httpRequestSymbol$1 = Symbol("#httpRequest");
|
|
1455
1403
|
class ObservableUsersClient {
|
|
1456
1404
|
constructor(client, httpRequest) {
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
__privateSet$1(this, _client, client);
|
|
1460
|
-
__privateSet$1(this, _httpRequest$1, httpRequest);
|
|
1405
|
+
this[clientSymbol] = client;
|
|
1406
|
+
this[httpRequestSymbol$1] = httpRequest;
|
|
1461
1407
|
}
|
|
1462
1408
|
/**
|
|
1463
1409
|
* Fetch a user by user ID
|
|
@@ -1466,20 +1412,16 @@ class ObservableUsersClient {
|
|
|
1466
1412
|
*/
|
|
1467
1413
|
getById(id) {
|
|
1468
1414
|
return _request(
|
|
1469
|
-
|
|
1470
|
-
|
|
1415
|
+
this[clientSymbol],
|
|
1416
|
+
this[httpRequestSymbol$1],
|
|
1471
1417
|
{ uri: "/users/".concat(id) }
|
|
1472
1418
|
);
|
|
1473
1419
|
}
|
|
1474
1420
|
}
|
|
1475
|
-
_client = new WeakMap();
|
|
1476
|
-
_httpRequest$1 = new WeakMap();
|
|
1477
1421
|
class UsersClient {
|
|
1478
1422
|
constructor(client, httpRequest) {
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
__privateSet$1(this, _client2, client);
|
|
1482
|
-
__privateSet$1(this, _httpRequest2$1, httpRequest);
|
|
1423
|
+
this[clientSymbol] = client;
|
|
1424
|
+
this[httpRequestSymbol$1] = httpRequest;
|
|
1483
1425
|
}
|
|
1484
1426
|
/**
|
|
1485
1427
|
* Fetch a user by user ID
|
|
@@ -1488,68 +1430,48 @@ class UsersClient {
|
|
|
1488
1430
|
*/
|
|
1489
1431
|
getById(id) {
|
|
1490
1432
|
return lastValueFrom(
|
|
1491
|
-
_request(
|
|
1492
|
-
|
|
1493
|
-
|
|
1433
|
+
_request(
|
|
1434
|
+
this[clientSymbol],
|
|
1435
|
+
this[httpRequestSymbol$1],
|
|
1436
|
+
{
|
|
1437
|
+
uri: "/users/".concat(id)
|
|
1438
|
+
}
|
|
1439
|
+
)
|
|
1494
1440
|
);
|
|
1495
1441
|
}
|
|
1496
1442
|
}
|
|
1497
|
-
_client2 = new WeakMap();
|
|
1498
|
-
_httpRequest2$1 = new WeakMap();
|
|
1499
1443
|
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
throw TypeError("Cannot " + msg);
|
|
1503
|
-
};
|
|
1504
|
-
var __privateGet = (obj, member, getter) => {
|
|
1505
|
-
__accessCheck(obj, member, "read from private field");
|
|
1506
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
1507
|
-
};
|
|
1508
|
-
var __privateAdd = (obj, member, value) => {
|
|
1509
|
-
if (member.has(obj))
|
|
1510
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
1511
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1512
|
-
};
|
|
1513
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
1514
|
-
__accessCheck(obj, member, "write to private field");
|
|
1515
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
1516
|
-
return value;
|
|
1517
|
-
};
|
|
1518
|
-
var _clientConfig, _httpRequest, _clientConfig2, _httpRequest2;
|
|
1444
|
+
const clientConfigSymbol = Symbol("#clientConfig");
|
|
1445
|
+
const httpRequestSymbol = Symbol("#httpRequest");
|
|
1519
1446
|
const _ObservableSanityClient = class _ObservableSanityClient {
|
|
1520
1447
|
constructor(httpRequest, config = defaultConfig) {
|
|
1521
|
-
/**
|
|
1522
|
-
* Private properties
|
|
1523
|
-
*/
|
|
1524
|
-
__privateAdd(this, _clientConfig, void 0);
|
|
1525
|
-
__privateAdd(this, _httpRequest, void 0);
|
|
1526
1448
|
/**
|
|
1527
1449
|
* Instance properties
|
|
1528
1450
|
*/
|
|
1529
1451
|
this.listen = _listen;
|
|
1530
1452
|
this.config(config);
|
|
1531
|
-
|
|
1532
|
-
this.assets = new ObservableAssetsClient(this,
|
|
1533
|
-
this.datasets = new ObservableDatasetsClient(this,
|
|
1534
|
-
this.projects = new ObservableProjectsClient(this,
|
|
1535
|
-
this.users = new ObservableUsersClient(this,
|
|
1453
|
+
this[httpRequestSymbol] = httpRequest;
|
|
1454
|
+
this.assets = new ObservableAssetsClient(this, this[httpRequestSymbol]);
|
|
1455
|
+
this.datasets = new ObservableDatasetsClient(this, this[httpRequestSymbol]);
|
|
1456
|
+
this.projects = new ObservableProjectsClient(this, this[httpRequestSymbol]);
|
|
1457
|
+
this.users = new ObservableUsersClient(this, this[httpRequestSymbol]);
|
|
1536
1458
|
}
|
|
1537
1459
|
/**
|
|
1538
1460
|
* Clone the client - returns a new instance
|
|
1539
1461
|
*/
|
|
1540
1462
|
clone() {
|
|
1541
|
-
return new _ObservableSanityClient(
|
|
1463
|
+
return new _ObservableSanityClient(this[httpRequestSymbol], this.config());
|
|
1542
1464
|
}
|
|
1543
1465
|
config(newConfig) {
|
|
1544
1466
|
if (newConfig === void 0) {
|
|
1545
|
-
return { ...
|
|
1467
|
+
return { ...this[clientConfigSymbol] };
|
|
1546
1468
|
}
|
|
1547
|
-
if (
|
|
1469
|
+
if (this[clientConfigSymbol] && this[clientConfigSymbol].allowReconfigure === false) {
|
|
1548
1470
|
throw new Error(
|
|
1549
1471
|
"Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
|
|
1550
1472
|
);
|
|
1551
1473
|
}
|
|
1552
|
-
|
|
1474
|
+
this[clientConfigSymbol] = initConfig(newConfig, this[clientConfigSymbol] || {});
|
|
1553
1475
|
return this;
|
|
1554
1476
|
}
|
|
1555
1477
|
/**
|
|
@@ -1558,10 +1480,25 @@ const _ObservableSanityClient = class _ObservableSanityClient {
|
|
|
1558
1480
|
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
1559
1481
|
*/
|
|
1560
1482
|
withConfig(newConfig) {
|
|
1561
|
-
|
|
1483
|
+
const thisConfig = this.config();
|
|
1484
|
+
return new _ObservableSanityClient(this[httpRequestSymbol], {
|
|
1485
|
+
...thisConfig,
|
|
1486
|
+
...newConfig,
|
|
1487
|
+
stega: {
|
|
1488
|
+
...thisConfig.stega || {},
|
|
1489
|
+
...typeof (newConfig == null ? void 0 : newConfig.stega) === "boolean" ? { enabled: newConfig.stega } : (newConfig == null ? void 0 : newConfig.stega) || {}
|
|
1490
|
+
}
|
|
1491
|
+
});
|
|
1562
1492
|
}
|
|
1563
|
-
fetch(query, params, options
|
|
1564
|
-
return _fetch(
|
|
1493
|
+
fetch(query, params, options) {
|
|
1494
|
+
return _fetch(
|
|
1495
|
+
this,
|
|
1496
|
+
this[httpRequestSymbol],
|
|
1497
|
+
this[clientConfigSymbol].stega,
|
|
1498
|
+
query,
|
|
1499
|
+
params,
|
|
1500
|
+
options
|
|
1501
|
+
);
|
|
1565
1502
|
}
|
|
1566
1503
|
/**
|
|
1567
1504
|
* Fetch a single document with the given ID.
|
|
@@ -1570,7 +1507,7 @@ const _ObservableSanityClient = class _ObservableSanityClient {
|
|
|
1570
1507
|
* @param options - Request options
|
|
1571
1508
|
*/
|
|
1572
1509
|
getDocument(id, options) {
|
|
1573
|
-
return _getDocument(this,
|
|
1510
|
+
return _getDocument(this, this[httpRequestSymbol], id, options);
|
|
1574
1511
|
}
|
|
1575
1512
|
/**
|
|
1576
1513
|
* Fetch multiple documents in one request.
|
|
@@ -1582,22 +1519,22 @@ const _ObservableSanityClient = class _ObservableSanityClient {
|
|
|
1582
1519
|
* @param options - Request options
|
|
1583
1520
|
*/
|
|
1584
1521
|
getDocuments(ids, options) {
|
|
1585
|
-
return _getDocuments(this,
|
|
1522
|
+
return _getDocuments(this, this[httpRequestSymbol], ids, options);
|
|
1586
1523
|
}
|
|
1587
1524
|
create(document, options) {
|
|
1588
|
-
return _create(this,
|
|
1525
|
+
return _create(this, this[httpRequestSymbol], document, "create", options);
|
|
1589
1526
|
}
|
|
1590
1527
|
createIfNotExists(document, options) {
|
|
1591
|
-
return _createIfNotExists(this,
|
|
1528
|
+
return _createIfNotExists(this, this[httpRequestSymbol], document, options);
|
|
1592
1529
|
}
|
|
1593
1530
|
createOrReplace(document, options) {
|
|
1594
|
-
return _createOrReplace(this,
|
|
1531
|
+
return _createOrReplace(this, this[httpRequestSymbol], document, options);
|
|
1595
1532
|
}
|
|
1596
1533
|
delete(selection, options) {
|
|
1597
|
-
return _delete(this,
|
|
1534
|
+
return _delete(this, this[httpRequestSymbol], selection, options);
|
|
1598
1535
|
}
|
|
1599
1536
|
mutate(operations, options) {
|
|
1600
|
-
return _mutate(this,
|
|
1537
|
+
return _mutate(this, this[httpRequestSymbol], operations, options);
|
|
1601
1538
|
}
|
|
1602
1539
|
/**
|
|
1603
1540
|
* Create a new buildable patch of operations to perform
|
|
@@ -1623,7 +1560,7 @@ const _ObservableSanityClient = class _ObservableSanityClient {
|
|
|
1623
1560
|
* @param options - Request options
|
|
1624
1561
|
*/
|
|
1625
1562
|
request(options) {
|
|
1626
|
-
return _request(this,
|
|
1563
|
+
return _request(this, this[httpRequestSymbol], options);
|
|
1627
1564
|
}
|
|
1628
1565
|
/**
|
|
1629
1566
|
* Get a Sanity API URL for the URI provided
|
|
@@ -1644,39 +1581,32 @@ const _ObservableSanityClient = class _ObservableSanityClient {
|
|
|
1644
1581
|
return _getDataUrl(this, operation, path);
|
|
1645
1582
|
}
|
|
1646
1583
|
};
|
|
1647
|
-
_clientConfig = new WeakMap();
|
|
1648
|
-
_httpRequest = new WeakMap();
|
|
1649
1584
|
let ObservableSanityClient = _ObservableSanityClient;
|
|
1650
1585
|
const _SanityClient = class _SanityClient {
|
|
1651
1586
|
constructor(httpRequest, config = defaultConfig) {
|
|
1652
|
-
/**
|
|
1653
|
-
* Private properties
|
|
1654
|
-
*/
|
|
1655
|
-
__privateAdd(this, _clientConfig2, void 0);
|
|
1656
|
-
__privateAdd(this, _httpRequest2, void 0);
|
|
1657
1587
|
/**
|
|
1658
1588
|
* Instance properties
|
|
1659
1589
|
*/
|
|
1660
1590
|
this.listen = _listen;
|
|
1661
1591
|
this.config(config);
|
|
1662
|
-
|
|
1663
|
-
this.assets = new AssetsClient(this,
|
|
1664
|
-
this.datasets = new DatasetsClient(this,
|
|
1665
|
-
this.projects = new ProjectsClient(this,
|
|
1666
|
-
this.users = new UsersClient(this,
|
|
1592
|
+
this[httpRequestSymbol] = httpRequest;
|
|
1593
|
+
this.assets = new AssetsClient(this, this[httpRequestSymbol]);
|
|
1594
|
+
this.datasets = new DatasetsClient(this, this[httpRequestSymbol]);
|
|
1595
|
+
this.projects = new ProjectsClient(this, this[httpRequestSymbol]);
|
|
1596
|
+
this.users = new UsersClient(this, this[httpRequestSymbol]);
|
|
1667
1597
|
this.observable = new ObservableSanityClient(httpRequest, config);
|
|
1668
1598
|
}
|
|
1669
1599
|
/**
|
|
1670
1600
|
* Clone the client - returns a new instance
|
|
1671
1601
|
*/
|
|
1672
1602
|
clone() {
|
|
1673
|
-
return new _SanityClient(
|
|
1603
|
+
return new _SanityClient(this[httpRequestSymbol], this.config());
|
|
1674
1604
|
}
|
|
1675
1605
|
config(newConfig) {
|
|
1676
1606
|
if (newConfig === void 0) {
|
|
1677
|
-
return { ...
|
|
1607
|
+
return { ...this[clientConfigSymbol] };
|
|
1678
1608
|
}
|
|
1679
|
-
if (
|
|
1609
|
+
if (this[clientConfigSymbol] && this[clientConfigSymbol].allowReconfigure === false) {
|
|
1680
1610
|
throw new Error(
|
|
1681
1611
|
"Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
|
|
1682
1612
|
);
|
|
@@ -1684,7 +1614,7 @@ const _SanityClient = class _SanityClient {
|
|
|
1684
1614
|
if (this.observable) {
|
|
1685
1615
|
this.observable.config(newConfig);
|
|
1686
1616
|
}
|
|
1687
|
-
|
|
1617
|
+
this[clientConfigSymbol] = initConfig(newConfig, this[clientConfigSymbol] || {});
|
|
1688
1618
|
return this;
|
|
1689
1619
|
}
|
|
1690
1620
|
/**
|
|
@@ -1693,10 +1623,27 @@ const _SanityClient = class _SanityClient {
|
|
|
1693
1623
|
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
1694
1624
|
*/
|
|
1695
1625
|
withConfig(newConfig) {
|
|
1696
|
-
|
|
1626
|
+
const thisConfig = this.config();
|
|
1627
|
+
return new _SanityClient(this[httpRequestSymbol], {
|
|
1628
|
+
...thisConfig,
|
|
1629
|
+
...newConfig,
|
|
1630
|
+
stega: {
|
|
1631
|
+
...thisConfig.stega || {},
|
|
1632
|
+
...typeof (newConfig == null ? void 0 : newConfig.stega) === "boolean" ? { enabled: newConfig.stega } : (newConfig == null ? void 0 : newConfig.stega) || {}
|
|
1633
|
+
}
|
|
1634
|
+
});
|
|
1697
1635
|
}
|
|
1698
|
-
fetch(query, params, options
|
|
1699
|
-
return lastValueFrom(
|
|
1636
|
+
fetch(query, params, options) {
|
|
1637
|
+
return lastValueFrom(
|
|
1638
|
+
_fetch(
|
|
1639
|
+
this,
|
|
1640
|
+
this[httpRequestSymbol],
|
|
1641
|
+
this[clientConfigSymbol].stega,
|
|
1642
|
+
query,
|
|
1643
|
+
params,
|
|
1644
|
+
options
|
|
1645
|
+
)
|
|
1646
|
+
);
|
|
1700
1647
|
}
|
|
1701
1648
|
/**
|
|
1702
1649
|
* Fetch a single document with the given ID.
|
|
@@ -1705,7 +1652,7 @@ const _SanityClient = class _SanityClient {
|
|
|
1705
1652
|
* @param options - Request options
|
|
1706
1653
|
*/
|
|
1707
1654
|
getDocument(id, options) {
|
|
1708
|
-
return lastValueFrom(_getDocument(this,
|
|
1655
|
+
return lastValueFrom(_getDocument(this, this[httpRequestSymbol], id, options));
|
|
1709
1656
|
}
|
|
1710
1657
|
/**
|
|
1711
1658
|
* Fetch multiple documents in one request.
|
|
@@ -1717,28 +1664,28 @@ const _SanityClient = class _SanityClient {
|
|
|
1717
1664
|
* @param options - Request options
|
|
1718
1665
|
*/
|
|
1719
1666
|
getDocuments(ids, options) {
|
|
1720
|
-
return lastValueFrom(_getDocuments(this,
|
|
1667
|
+
return lastValueFrom(_getDocuments(this, this[httpRequestSymbol], ids, options));
|
|
1721
1668
|
}
|
|
1722
1669
|
create(document, options) {
|
|
1723
1670
|
return lastValueFrom(
|
|
1724
|
-
_create(this,
|
|
1671
|
+
_create(this, this[httpRequestSymbol], document, "create", options)
|
|
1725
1672
|
);
|
|
1726
1673
|
}
|
|
1727
1674
|
createIfNotExists(document, options) {
|
|
1728
1675
|
return lastValueFrom(
|
|
1729
|
-
_createIfNotExists(this,
|
|
1676
|
+
_createIfNotExists(this, this[httpRequestSymbol], document, options)
|
|
1730
1677
|
);
|
|
1731
1678
|
}
|
|
1732
1679
|
createOrReplace(document, options) {
|
|
1733
1680
|
return lastValueFrom(
|
|
1734
|
-
_createOrReplace(this,
|
|
1681
|
+
_createOrReplace(this, this[httpRequestSymbol], document, options)
|
|
1735
1682
|
);
|
|
1736
1683
|
}
|
|
1737
1684
|
delete(selection, options) {
|
|
1738
|
-
return lastValueFrom(_delete(this,
|
|
1685
|
+
return lastValueFrom(_delete(this, this[httpRequestSymbol], selection, options));
|
|
1739
1686
|
}
|
|
1740
1687
|
mutate(operations, options) {
|
|
1741
|
-
return lastValueFrom(_mutate(this,
|
|
1688
|
+
return lastValueFrom(_mutate(this, this[httpRequestSymbol], operations, options));
|
|
1742
1689
|
}
|
|
1743
1690
|
/**
|
|
1744
1691
|
* Create a new buildable patch of operations to perform
|
|
@@ -1766,7 +1713,7 @@ const _SanityClient = class _SanityClient {
|
|
|
1766
1713
|
* @returns Promise resolving to the response body
|
|
1767
1714
|
*/
|
|
1768
1715
|
request(options) {
|
|
1769
|
-
return lastValueFrom(_request(this,
|
|
1716
|
+
return lastValueFrom(_request(this, this[httpRequestSymbol], options));
|
|
1770
1717
|
}
|
|
1771
1718
|
/**
|
|
1772
1719
|
* Perform an HTTP request a `/data` sub-endpoint
|
|
@@ -1779,7 +1726,9 @@ const _SanityClient = class _SanityClient {
|
|
|
1779
1726
|
* @internal
|
|
1780
1727
|
*/
|
|
1781
1728
|
dataRequest(endpoint, body, options) {
|
|
1782
|
-
return lastValueFrom(
|
|
1729
|
+
return lastValueFrom(
|
|
1730
|
+
_dataRequest(this, this[httpRequestSymbol], endpoint, body, options)
|
|
1731
|
+
);
|
|
1783
1732
|
}
|
|
1784
1733
|
/**
|
|
1785
1734
|
* Get a Sanity API URL for the URI provided
|
|
@@ -1800,8 +1749,6 @@ const _SanityClient = class _SanityClient {
|
|
|
1800
1749
|
return _getDataUrl(this, operation, path);
|
|
1801
1750
|
}
|
|
1802
1751
|
};
|
|
1803
|
-
_clientConfig2 = new WeakMap();
|
|
1804
|
-
_httpRequest2 = new WeakMap();
|
|
1805
1752
|
let SanityClient = _SanityClient;
|
|
1806
1753
|
|
|
1807
1754
|
function defineCreateClientExports(envMiddleware, ClassConstructor) {
|
|
@@ -1818,7 +1765,7 @@ function defineCreateClientExports(envMiddleware, ClassConstructor) {
|
|
|
1818
1765
|
}
|
|
1819
1766
|
|
|
1820
1767
|
var name = "@sanity/client";
|
|
1821
|
-
var version = "6.11.
|
|
1768
|
+
var version = "6.11.4-canary.1";
|
|
1822
1769
|
|
|
1823
1770
|
const middleware = [
|
|
1824
1771
|
debug({ verbose: true, namespace: "sanity:client" }),
|
|
@@ -1838,5 +1785,5 @@ const middleware = [
|
|
|
1838
1785
|
})
|
|
1839
1786
|
];
|
|
1840
1787
|
|
|
1841
|
-
export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, SanityClient, ServerError, Transaction,
|
|
1842
|
-
//# sourceMappingURL=nodeMiddleware-
|
|
1788
|
+
export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, SanityClient, ServerError, Transaction, b, defineCreateClientExports, middleware, printNoDefaultExport, vercelStegaCleanAll };
|
|
1789
|
+
//# sourceMappingURL=nodeMiddleware-hZIb_1T_.js.map
|