@sanity/client 8.0.0 → 8.2.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/README.md +265 -0
- package/dist/{browserUpload-CQgx9YYo.js → browserUpload-2tz6Sdqp.js} +4 -3
- package/dist/browserUpload-2tz6Sdqp.js.map +1 -0
- package/dist/{browserUpload-icWlVP15.js → browserUpload-CwpNx7Vl.js} +4 -3
- package/dist/browserUpload-CwpNx7Vl.js.map +1 -0
- package/dist/{config-a8VajuEY.js → config-3wiPP-sZ.js} +2 -2
- package/dist/config-3wiPP-sZ.js.map +1 -0
- package/dist/csm.js +2 -2
- package/dist/csm.js.map +1 -1
- package/dist/index.d.ts +17 -11
- package/dist/index.js +610 -136
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +918 -26
- package/dist/index.node.js +559 -66
- package/dist/index.node.js.map +1 -1
- package/dist/media-library.d.ts +1 -1
- package/dist/{request-CJxcN16k.js → request-BhMuKj0D.js} +10 -9
- package/dist/request-BhMuKj0D.js.map +1 -0
- package/dist/{request-k7VS_NnC.js → request-SnMg7nUX.js} +10 -9
- package/dist/request-SnMg7nUX.js.map +1 -0
- package/dist/{resolveEditInfo-sq7yF78q.js → resolveEditInfo-Cz-smq3a.js} +17 -3
- package/dist/resolveEditInfo-Cz-smq3a.js.map +1 -0
- package/dist/stega.js +1 -1
- package/dist/{stegaEncodeSourceMap-DkoIlutY.js → stegaEncodeSourceMap-DbM2fTN4.js} +8 -2
- package/dist/stegaEncodeSourceMap-DbM2fTN4.js.map +1 -0
- package/dist/{stegaEncodeSourceMap-B2fGArSf.js → stegaEncodeSourceMap-YR3NQ3iz.js} +2 -2
- package/dist/{stegaEncodeSourceMap-B2fGArSf.js.map → stegaEncodeSourceMap-YR3NQ3iz.js.map} +1 -1
- package/dist/{types-CUxZSgB2.d.ts → types-nJhm5Nyq.d.ts} +910 -24
- package/package.json +26 -11
- package/src/SanityClient.ts +39 -20
- package/src/assets/AssetsClient.ts +54 -5
- package/src/collaboration/CollaborationCommentsClient.ts +387 -0
- package/src/collaboration/comments.ts +313 -0
- package/src/collaboration/types.ts +252 -0
- package/src/csm/applySourceDocuments.ts +2 -4
- package/src/csm/draftUtils.ts +23 -4
- package/src/data/dataMethods.ts +9 -20
- package/src/data/eventsource.ts +71 -41
- package/src/data/listen.ts +20 -5
- package/src/data/live.ts +17 -9
- package/src/data/resolveEventSourceFetch.ts +9 -1
- package/src/defineCreateClient.ts +5 -1
- package/src/functions/FunctionsClient.ts +66 -0
- package/src/functions/invoke.ts +176 -0
- package/src/http/browserUpload.ts +1 -0
- package/src/http/errors.ts +2 -1
- package/src/http/request.ts +8 -14
- package/src/mediaLibrary/MediaLibraryVideoClient.ts +1 -1
- package/src/types.ts +420 -4
- package/src/validators.ts +1 -1
- package/src/warnings.ts +7 -1
- package/dist/browserUpload-CQgx9YYo.js.map +0 -1
- package/dist/browserUpload-icWlVP15.js.map +0 -1
- package/dist/config-a8VajuEY.js.map +0 -1
- package/dist/request-CJxcN16k.js.map +0 -1
- package/dist/request-k7VS_NnC.js.map +0 -1
- package/dist/resolveEditInfo-sq7yF78q.js.map +0 -1
- package/dist/stegaEncodeSourceMap-DkoIlutY.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { a as ServerError, c as isHttpError, i as CorsOriginError, l as isQueryParseError, o as formatQueryParseError, r as ClientError, t as defineRequester, u as _defineProperty } from "./request-
|
|
2
|
-
import {
|
|
1
|
+
import { a as ServerError, c as isHttpError, i as CorsOriginError, l as isQueryParseError, o as formatQueryParseError, r as ClientError, t as defineRequester, u as _defineProperty } from "./request-BhMuKj0D.js";
|
|
2
|
+
import { t as isRecord } from "./isRecord-Kfmt-nk-.js";
|
|
3
|
+
import { _ as validateDocumentId, a as printCreateVersionWithBaseIdWarning, b as validateVersionIdMatch, c as printPreviewDraftsDeprecationWarning, d as requestTag, f as requireDocumentId, g as validateAssetType, h as resourceGuard, i as printCdnPreviewDraftsWarning, l as dataset, m as resourceConfig, n as initConfig, o as printDeprecatedUriOptionWarning, p as requireDocumentType, r as validateApiPerspective, s as printNoDefaultExport, t as defaultConfig, u as hasDataset, v as validateInsert, y as validateObject } from "./config-3wiPP-sZ.js";
|
|
3
4
|
import { t as stegaClean } from "./stegaClean-C18wLWau.js";
|
|
5
|
+
import { isTimeoutError } from "get-it";
|
|
4
6
|
import { Observable, catchError, concat, defer, finalize, isObservable, lastValueFrom, map, merge, mergeMap, of, share, tap, throwError, timer } from "rxjs";
|
|
5
7
|
import { getDraftId, getPublishedId, getVersionFromId, getVersionId, isDraftId, isVersionId } from "@sanity/client/csm";
|
|
6
8
|
import { filter, finalize as finalize$1, map as map$1, mergeAll } from "rxjs/operators";
|
|
@@ -26,11 +28,12 @@ import { customAlphabet } from "nanoid";
|
|
|
26
28
|
*/
|
|
27
29
|
const EXPERIMENTAL_API_WARNING = "This is an experimental API version";
|
|
28
30
|
/**
|
|
29
|
-
* @public
|
|
30
31
|
* Thrown when the EventSource connection could not be established, or was rejected by the server.
|
|
31
32
|
* Transient failures (network drops, 5xx, 408, 429) are reconnected internally and emitted as
|
|
32
33
|
* `reconnect` events; a permanent rejection (any other 4xx, eg an expired token) errors the
|
|
33
34
|
* stream with this class so consumers can react — check `status` for the rejection code.
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
34
37
|
*/
|
|
35
38
|
var ConnectionFailedError = class extends Error {
|
|
36
39
|
constructor(message, options = {}) {
|
|
@@ -89,26 +92,30 @@ function connectEventSource(initEventSource, events) {
|
|
|
89
92
|
*/
|
|
90
93
|
function connectWithESInstance(es, events) {
|
|
91
94
|
return new Observable((observer) => {
|
|
92
|
-
let
|
|
95
|
+
let requestedEvents = new Set(events), isRequestedEvent = (type) => requestedEvents.has(type), emitOpen = isRequestedEvent("open");
|
|
93
96
|
function onError(evt) {
|
|
94
97
|
if ("data" in evt) {
|
|
95
98
|
let [parseError, event] = parseEvent(evt);
|
|
96
|
-
observer.error(parseError ? new MessageParseError("Unable to parse EventSource error message", { cause: parseError }) : new MessageError(event.data.message, event));
|
|
99
|
+
observer.error(parseError || !event ? new MessageParseError("Unable to parse EventSource error message", { cause: parseError }) : new MessageError(isRecord(event.data) && typeof event.data.message == "string" ? event.data.message : "", event));
|
|
97
100
|
return;
|
|
98
101
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
observer.error(new ConnectionFailedError("EventSource connection failed", { status }));
|
|
102
|
+
if (evt.code !== void 0) {
|
|
103
|
+
observer.error(new ConnectionFailedError("EventSource connection failed", { status: evt.code }));
|
|
102
104
|
return;
|
|
103
105
|
}
|
|
104
|
-
es.readyState === es.CLOSED
|
|
106
|
+
if (es.readyState === es.CLOSED) observer.error(new ConnectionFailedError("EventSource connection failed"));
|
|
107
|
+
else {
|
|
108
|
+
let type = "reconnect";
|
|
109
|
+
isRequestedEvent(type) && observer.next({ type });
|
|
110
|
+
}
|
|
105
111
|
}
|
|
106
112
|
function onOpen() {
|
|
107
|
-
|
|
113
|
+
let type = "open";
|
|
114
|
+
isRequestedEvent(type) && observer.next({ type });
|
|
108
115
|
}
|
|
109
116
|
function onMessage(message) {
|
|
110
117
|
let [parseError, event] = parseEvent(message);
|
|
111
|
-
if (parseError) {
|
|
118
|
+
if (parseError || !event) {
|
|
112
119
|
observer.error(new MessageParseError("Unable to parse EventSource message", { cause: parseError }));
|
|
113
120
|
return;
|
|
114
121
|
}
|
|
@@ -118,10 +125,10 @@ function connectWithESInstance(es, events) {
|
|
|
118
125
|
return;
|
|
119
126
|
}
|
|
120
127
|
if (message.type === "disconnect") {
|
|
121
|
-
observer.error(new DisconnectError(`Server disconnected client: ${event.data
|
|
128
|
+
observer.error(new DisconnectError(`Server disconnected client: ${isRecord(event.data) && typeof event.data.reason == "string" && event.data.reason || "unknown error"}`));
|
|
122
129
|
return;
|
|
123
130
|
}
|
|
124
|
-
observer.next({
|
|
131
|
+
isRequestedEvent(message.type) && observer.next({
|
|
125
132
|
type: message.type,
|
|
126
133
|
id: message.lastEventId,
|
|
127
134
|
...event.data ? { data: event.data } : {}
|
|
@@ -147,8 +154,16 @@ function parseEvent(message) {
|
|
|
147
154
|
}
|
|
148
155
|
}
|
|
149
156
|
function extractErrorMessage(err, tag) {
|
|
150
|
-
let error = err.error;
|
|
151
|
-
|
|
157
|
+
let error = isRecord(err) ? err.error : void 0;
|
|
158
|
+
if (!error) {
|
|
159
|
+
let message = isRecord(err) ? err.message : void 0;
|
|
160
|
+
return typeof message == "string" && message || "Unknown listener error";
|
|
161
|
+
}
|
|
162
|
+
if (isRecord(error)) {
|
|
163
|
+
if (isQueryParseError(error)) return formatQueryParseError(error, tag);
|
|
164
|
+
if (typeof error.description == "string") return error.description;
|
|
165
|
+
}
|
|
166
|
+
return typeof error == "string" ? error : JSON.stringify(error, null, 2);
|
|
152
167
|
}
|
|
153
168
|
function isEmptyObject(data) {
|
|
154
169
|
for (let _ in data) return !1;
|
|
@@ -323,41 +338,41 @@ var BasePatch = class {
|
|
|
323
338
|
_set(op, props) {
|
|
324
339
|
return this._assign(op, props, !1);
|
|
325
340
|
}
|
|
326
|
-
}, _client$
|
|
341
|
+
}, _client$11 = /* @__PURE__ */ new WeakMap(), ObservablePatch = class ObservablePatch extends BasePatch {
|
|
327
342
|
constructor(selection, operations, client) {
|
|
328
|
-
super(selection, operations), _classPrivateFieldInitSpec(this, _client$
|
|
343
|
+
super(selection, operations), _classPrivateFieldInitSpec(this, _client$11, void 0), _classPrivateFieldSet2(_client$11, this, client);
|
|
329
344
|
}
|
|
330
345
|
/**
|
|
331
346
|
* Clones the patch
|
|
332
347
|
*/
|
|
333
348
|
clone() {
|
|
334
|
-
return new ObservablePatch(this.selection, { ...this.operations }, _classPrivateFieldGet2(_client$
|
|
349
|
+
return new ObservablePatch(this.selection, { ...this.operations }, _classPrivateFieldGet2(_client$11, this));
|
|
335
350
|
}
|
|
336
351
|
commit(options) {
|
|
337
|
-
if (!_classPrivateFieldGet2(_client$
|
|
352
|
+
if (!_classPrivateFieldGet2(_client$11, this)) throw Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
338
353
|
let returnFirst = typeof this.selection == "string", opts = Object.assign({
|
|
339
354
|
returnFirst,
|
|
340
355
|
returnDocuments: !0
|
|
341
356
|
}, options);
|
|
342
|
-
return _classPrivateFieldGet2(_client$
|
|
357
|
+
return _classPrivateFieldGet2(_client$11, this).mutate({ patch: this.serialize() }, opts);
|
|
343
358
|
}
|
|
344
|
-
}, _client2$
|
|
359
|
+
}, _client2$10 = /* @__PURE__ */ new WeakMap(), Patch = class Patch extends BasePatch {
|
|
345
360
|
constructor(selection, operations, client) {
|
|
346
|
-
super(selection, operations), _classPrivateFieldInitSpec(this, _client2$
|
|
361
|
+
super(selection, operations), _classPrivateFieldInitSpec(this, _client2$10, void 0), _classPrivateFieldSet2(_client2$10, this, client);
|
|
347
362
|
}
|
|
348
363
|
/**
|
|
349
364
|
* Clones the patch
|
|
350
365
|
*/
|
|
351
366
|
clone() {
|
|
352
|
-
return new Patch(this.selection, { ...this.operations }, _classPrivateFieldGet2(_client2$
|
|
367
|
+
return new Patch(this.selection, { ...this.operations }, _classPrivateFieldGet2(_client2$10, this));
|
|
353
368
|
}
|
|
354
369
|
commit(options) {
|
|
355
|
-
if (!_classPrivateFieldGet2(_client2$
|
|
370
|
+
if (!_classPrivateFieldGet2(_client2$10, this)) throw Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
356
371
|
let returnFirst = typeof this.selection == "string", opts = Object.assign({
|
|
357
372
|
returnFirst,
|
|
358
373
|
returnDocuments: !0
|
|
359
374
|
}, options);
|
|
360
|
-
return _classPrivateFieldGet2(_client2$
|
|
375
|
+
return _classPrivateFieldGet2(_client2$10, this).mutate({ patch: this.serialize() }, opts);
|
|
361
376
|
}
|
|
362
377
|
};
|
|
363
378
|
const defaultMutateOptions = { returnDocuments: !1 };
|
|
@@ -428,30 +443,30 @@ var BaseTransaction = class {
|
|
|
428
443
|
_add(mut) {
|
|
429
444
|
return this.operations.push(mut), this;
|
|
430
445
|
}
|
|
431
|
-
}, _client$
|
|
446
|
+
}, _client$10 = /* @__PURE__ */ new WeakMap(), Transaction = class Transaction extends BaseTransaction {
|
|
432
447
|
constructor(operations, client, transactionId) {
|
|
433
|
-
super(operations, transactionId), _classPrivateFieldInitSpec(this, _client$
|
|
448
|
+
super(operations, transactionId), _classPrivateFieldInitSpec(this, _client$10, void 0), _classPrivateFieldSet2(_client$10, this, client);
|
|
434
449
|
}
|
|
435
450
|
/**
|
|
436
451
|
* Clones the transaction
|
|
437
452
|
*/
|
|
438
453
|
clone() {
|
|
439
|
-
return new Transaction([...this.operations], _classPrivateFieldGet2(_client$
|
|
454
|
+
return new Transaction([...this.operations], _classPrivateFieldGet2(_client$10, this), this.trxId);
|
|
440
455
|
}
|
|
441
456
|
commit(options) {
|
|
442
|
-
if (!_classPrivateFieldGet2(_client$
|
|
443
|
-
return _classPrivateFieldGet2(_client$
|
|
457
|
+
if (!_classPrivateFieldGet2(_client$10, this)) throw Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
458
|
+
return _classPrivateFieldGet2(_client$10, this).mutate(this.serialize(), Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {}));
|
|
444
459
|
}
|
|
445
460
|
patch(patchOrDocumentId, patchOps) {
|
|
446
461
|
let isBuilder = typeof patchOps == "function", isPatch = typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof Patch, isMutationSelection = typeof patchOrDocumentId == "object" && ("query" in patchOrDocumentId || "id" in patchOrDocumentId);
|
|
447
462
|
if (isPatch) return this._add({ patch: patchOrDocumentId.serialize() });
|
|
448
463
|
if (isBuilder) {
|
|
449
|
-
let patch = patchOps(new Patch(patchOrDocumentId, {}, _classPrivateFieldGet2(_client$
|
|
464
|
+
let patch = patchOps(new Patch(patchOrDocumentId, {}, _classPrivateFieldGet2(_client$10, this)));
|
|
450
465
|
if (!(patch instanceof Patch)) throw Error("function passed to `patch()` must return the patch");
|
|
451
466
|
return this._add({ patch: patch.serialize() });
|
|
452
467
|
}
|
|
453
468
|
if (isMutationSelection) {
|
|
454
|
-
let patch = new Patch(patchOrDocumentId, patchOps || {}, _classPrivateFieldGet2(_client$
|
|
469
|
+
let patch = new Patch(patchOrDocumentId, patchOps || {}, _classPrivateFieldGet2(_client$10, this));
|
|
455
470
|
return this._add({ patch: patch.serialize() });
|
|
456
471
|
}
|
|
457
472
|
return this._add({ patch: {
|
|
@@ -459,25 +474,25 @@ var BaseTransaction = class {
|
|
|
459
474
|
...patchOps
|
|
460
475
|
} });
|
|
461
476
|
}
|
|
462
|
-
}, _client2$
|
|
477
|
+
}, _client2$9 = /* @__PURE__ */ new WeakMap(), ObservableTransaction = class ObservableTransaction extends BaseTransaction {
|
|
463
478
|
constructor(operations, client, transactionId) {
|
|
464
|
-
super(operations, transactionId), _classPrivateFieldInitSpec(this, _client2$
|
|
479
|
+
super(operations, transactionId), _classPrivateFieldInitSpec(this, _client2$9, void 0), _classPrivateFieldSet2(_client2$9, this, client);
|
|
465
480
|
}
|
|
466
481
|
/**
|
|
467
482
|
* Clones the transaction
|
|
468
483
|
*/
|
|
469
484
|
clone() {
|
|
470
|
-
return new ObservableTransaction([...this.operations], _classPrivateFieldGet2(_client2$
|
|
485
|
+
return new ObservableTransaction([...this.operations], _classPrivateFieldGet2(_client2$9, this), this.trxId);
|
|
471
486
|
}
|
|
472
487
|
commit(options) {
|
|
473
|
-
if (!_classPrivateFieldGet2(_client2$
|
|
474
|
-
return _classPrivateFieldGet2(_client2$
|
|
488
|
+
if (!_classPrivateFieldGet2(_client2$9, this)) throw Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
489
|
+
return _classPrivateFieldGet2(_client2$9, this).mutate(this.serialize(), Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {}));
|
|
475
490
|
}
|
|
476
491
|
patch(patchOrDocumentId, patchOps) {
|
|
477
492
|
let isBuilder = typeof patchOps == "function";
|
|
478
493
|
if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof ObservablePatch) return this._add({ patch: patchOrDocumentId.serialize() });
|
|
479
494
|
if (isBuilder) {
|
|
480
|
-
let patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, _classPrivateFieldGet2(_client2$
|
|
495
|
+
let patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, _classPrivateFieldGet2(_client2$9, this)));
|
|
481
496
|
if (!(patch instanceof ObservablePatch)) throw Error("function passed to `patch()` must return the patch");
|
|
482
497
|
return this._add({ patch: patch.serialize() });
|
|
483
498
|
}
|
|
@@ -589,7 +604,7 @@ function _fetchRequest(_stega, _params, options) {
|
|
|
589
604
|
}
|
|
590
605
|
/** @internal */
|
|
591
606
|
function _fetchObservable(client, httpRequest, _stega, query, _params = {}, options = {}) {
|
|
592
|
-
return _observe(options.signal, (signal) => _fetch(client, httpRequest, _stega, query, _params, {
|
|
607
|
+
return _observe(options.signal, (signal) => _fetch$1(client, httpRequest, _stega, query, _params, {
|
|
593
608
|
...options,
|
|
594
609
|
signal
|
|
595
610
|
}));
|
|
@@ -599,12 +614,12 @@ function _fetchObservable(client, httpRequest, _stega, query, _params = {}, opti
|
|
|
599
614
|
*
|
|
600
615
|
* @internal
|
|
601
616
|
*/
|
|
602
|
-
function _fetch(client, httpRequest, _stega, query, _params = {}, options = {}) {
|
|
617
|
+
function _fetch$1(client, httpRequest, _stega, query, _params = {}, options = {}) {
|
|
603
618
|
let { stega, params, mapResponse, reqOpts } = _fetchRequest(_stega, _params, options), request = _dataRequest(client, httpRequest, "query", {
|
|
604
619
|
query,
|
|
605
620
|
params
|
|
606
621
|
}, reqOpts);
|
|
607
|
-
return stega.enabled ? Promise.all([request, import("./stegaEncodeSourceMap-
|
|
622
|
+
return stega.enabled ? Promise.all([request, import("./stegaEncodeSourceMap-YR3NQ3iz.js").then((n) => n.n)]).then(([res, { stegaEncodeSourceMap }]) => {
|
|
608
623
|
let result = stegaEncodeSourceMap(res.result, res.resultSourceMap, stega);
|
|
609
624
|
return mapResponse({
|
|
610
625
|
...res,
|
|
@@ -752,7 +767,7 @@ function _createVersionFromBaseObservable(client, httpRequest, publishedId, base
|
|
|
752
767
|
}
|
|
753
768
|
/** @internal */
|
|
754
769
|
function _deleteObservable(client, httpRequest, selection, options) {
|
|
755
|
-
return _observe(options?.signal, (signal) => _delete(client, httpRequest, selection, {
|
|
770
|
+
return _observe(options?.signal, (signal) => _delete$1(client, httpRequest, selection, {
|
|
756
771
|
...options,
|
|
757
772
|
signal
|
|
758
773
|
}));
|
|
@@ -847,8 +862,6 @@ function _mapDataResponse(res, isMutation, returnFirst, returnDocuments) {
|
|
|
847
862
|
};
|
|
848
863
|
}
|
|
849
864
|
/**
|
|
850
|
-
* Promise-based sibling of {@link _dataRequestObservable}.
|
|
851
|
-
*
|
|
852
865
|
* @internal
|
|
853
866
|
*/
|
|
854
867
|
function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
|
|
@@ -859,7 +872,7 @@ function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
|
|
|
859
872
|
* @internal
|
|
860
873
|
*/
|
|
861
874
|
function _createObservable(client, httpRequest, doc, op, options = {}) {
|
|
862
|
-
return _observe(options.signal, (signal) => _create(client, httpRequest, doc, op, {
|
|
875
|
+
return _observe(options.signal, (signal) => _create$1(client, httpRequest, doc, op, {
|
|
863
876
|
...options,
|
|
864
877
|
signal
|
|
865
878
|
}));
|
|
@@ -869,7 +882,7 @@ function _createObservable(client, httpRequest, doc, op, options = {}) {
|
|
|
869
882
|
*
|
|
870
883
|
* @internal
|
|
871
884
|
*/
|
|
872
|
-
function _create(client, httpRequest, doc, op, options = {}) {
|
|
885
|
+
function _create$1(client, httpRequest, doc, op, options = {}) {
|
|
873
886
|
let mutation = { [op]: doc }, opts = Object.assign({
|
|
874
887
|
returnFirst: !0,
|
|
875
888
|
returnDocuments: !0
|
|
@@ -906,7 +919,7 @@ function _mutate(client, httpRequest, mutations, options) {
|
|
|
906
919
|
*
|
|
907
920
|
* @internal
|
|
908
921
|
*/
|
|
909
|
-
function _delete(client, httpRequest, selection, options) {
|
|
922
|
+
function _delete$1(client, httpRequest, selection, options) {
|
|
910
923
|
return _dataRequest(client, httpRequest, "mutate", { mutations: [{ delete: getSelection(selection) }] }, options);
|
|
911
924
|
}
|
|
912
925
|
/**
|
|
@@ -915,7 +928,7 @@ function _delete(client, httpRequest, selection, options) {
|
|
|
915
928
|
* @internal
|
|
916
929
|
*/
|
|
917
930
|
function _createIfNotExists(client, httpRequest, doc, options) {
|
|
918
|
-
return requireDocumentId("createIfNotExists", doc), _create(client, httpRequest, doc, "createIfNotExists", options);
|
|
931
|
+
return requireDocumentId("createIfNotExists", doc), _create$1(client, httpRequest, doc, "createIfNotExists", options);
|
|
919
932
|
}
|
|
920
933
|
/**
|
|
921
934
|
* Promise-based sibling of {@link _createOrReplaceObservable}.
|
|
@@ -923,7 +936,7 @@ function _createIfNotExists(client, httpRequest, doc, options) {
|
|
|
923
936
|
* @internal
|
|
924
937
|
*/
|
|
925
938
|
function _createOrReplace(client, httpRequest, doc, options) {
|
|
926
|
-
return requireDocumentId("createOrReplace", doc), _create(client, httpRequest, doc, "createOrReplace", options);
|
|
939
|
+
return requireDocumentId("createOrReplace", doc), _create$1(client, httpRequest, doc, "createOrReplace", options);
|
|
927
940
|
}
|
|
928
941
|
/**
|
|
929
942
|
* Promise-based sibling of {@link _createVersionObservable}.
|
|
@@ -1073,7 +1086,7 @@ function _observe(userSignal, run) {
|
|
|
1073
1086
|
* @internal
|
|
1074
1087
|
*/
|
|
1075
1088
|
function _request(client, httpRequest, options) {
|
|
1076
|
-
return httpRequest(_prepareRequest(client, options)).then((body) => body);
|
|
1089
|
+
return httpRequest(_prepareRequest(client, options), client.config().requestHandler).then((body) => body);
|
|
1077
1090
|
}
|
|
1078
1091
|
/**
|
|
1079
1092
|
* Execute an HTTP request through the regular pipeline and resolve to the
|
|
@@ -1227,62 +1240,62 @@ function _translate(client, httpRequest, request) {
|
|
|
1227
1240
|
body: request
|
|
1228
1241
|
});
|
|
1229
1242
|
}
|
|
1230
|
-
var _client$
|
|
1243
|
+
var _client$9 = /* @__PURE__ */ new WeakMap(), _httpRequest$8 = /* @__PURE__ */ new WeakMap(), ObservableAgentsActionClient = class {
|
|
1231
1244
|
constructor(client, httpRequest) {
|
|
1232
|
-
_classPrivateFieldInitSpec(this, _client$
|
|
1245
|
+
_classPrivateFieldInitSpec(this, _client$9, void 0), _classPrivateFieldInitSpec(this, _httpRequest$8, void 0), _classPrivateFieldSet2(_client$9, this, client), _classPrivateFieldSet2(_httpRequest$8, this, httpRequest);
|
|
1233
1246
|
}
|
|
1234
1247
|
/**
|
|
1235
1248
|
* Run an instruction to generate content in a target document.
|
|
1236
1249
|
* @param request - instruction request
|
|
1237
1250
|
*/
|
|
1238
1251
|
generate(request) {
|
|
1239
|
-
return _generateObservable(_classPrivateFieldGet2(_client$
|
|
1252
|
+
return _generateObservable(_classPrivateFieldGet2(_client$9, this), _classPrivateFieldGet2(_httpRequest$8, this), request);
|
|
1240
1253
|
}
|
|
1241
1254
|
/**
|
|
1242
1255
|
* Transform a target document based on a source.
|
|
1243
1256
|
* @param request - translation request
|
|
1244
1257
|
*/
|
|
1245
1258
|
transform(request) {
|
|
1246
|
-
return _transformObservable(_classPrivateFieldGet2(_client$
|
|
1259
|
+
return _transformObservable(_classPrivateFieldGet2(_client$9, this), _classPrivateFieldGet2(_httpRequest$8, this), request);
|
|
1247
1260
|
}
|
|
1248
1261
|
/**
|
|
1249
1262
|
* Translate a target document based on a source.
|
|
1250
1263
|
* @param request - translation request
|
|
1251
1264
|
*/
|
|
1252
1265
|
translate(request) {
|
|
1253
|
-
return _translateObservable(_classPrivateFieldGet2(_client$
|
|
1266
|
+
return _translateObservable(_classPrivateFieldGet2(_client$9, this), _classPrivateFieldGet2(_httpRequest$8, this), request);
|
|
1254
1267
|
}
|
|
1255
|
-
}, _client2$
|
|
1268
|
+
}, _client2$8 = /* @__PURE__ */ new WeakMap(), _httpRequest2$9 = /* @__PURE__ */ new WeakMap(), AgentActionsClient = class {
|
|
1256
1269
|
constructor(client, httpRequest) {
|
|
1257
|
-
_classPrivateFieldInitSpec(this, _client2$
|
|
1270
|
+
_classPrivateFieldInitSpec(this, _client2$8, void 0), _classPrivateFieldInitSpec(this, _httpRequest2$9, void 0), _classPrivateFieldSet2(_client2$8, this, client), _classPrivateFieldSet2(_httpRequest2$9, this, httpRequest);
|
|
1258
1271
|
}
|
|
1259
1272
|
/**
|
|
1260
1273
|
* Run an instruction to generate content in a target document.
|
|
1261
1274
|
* @param request - instruction request
|
|
1262
1275
|
*/
|
|
1263
1276
|
generate(request) {
|
|
1264
|
-
return _generate(_classPrivateFieldGet2(_client2$
|
|
1277
|
+
return _generate(_classPrivateFieldGet2(_client2$8, this), _classPrivateFieldGet2(_httpRequest2$9, this), request);
|
|
1265
1278
|
}
|
|
1266
1279
|
/**
|
|
1267
1280
|
* Transform a target document based on a source.
|
|
1268
1281
|
* @param request - translation request
|
|
1269
1282
|
*/
|
|
1270
1283
|
transform(request) {
|
|
1271
|
-
return _transform(_classPrivateFieldGet2(_client2$
|
|
1284
|
+
return _transform(_classPrivateFieldGet2(_client2$8, this), _classPrivateFieldGet2(_httpRequest2$9, this), request);
|
|
1272
1285
|
}
|
|
1273
1286
|
/**
|
|
1274
1287
|
* Translate a target document based on a source.
|
|
1275
1288
|
* @param request - translation request
|
|
1276
1289
|
*/
|
|
1277
1290
|
translate(request) {
|
|
1278
|
-
return _translate(_classPrivateFieldGet2(_client2$
|
|
1291
|
+
return _translate(_classPrivateFieldGet2(_client2$8, this), _classPrivateFieldGet2(_httpRequest2$9, this), request);
|
|
1279
1292
|
}
|
|
1280
1293
|
/**
|
|
1281
1294
|
* Run a raw instruction and return the result either as text or json
|
|
1282
1295
|
* @param request - prompt request
|
|
1283
1296
|
*/
|
|
1284
1297
|
prompt(request) {
|
|
1285
|
-
return _prompt(_classPrivateFieldGet2(_client2$
|
|
1298
|
+
return _prompt(_classPrivateFieldGet2(_client2$8, this), _classPrivateFieldGet2(_httpRequest2$9, this), request);
|
|
1286
1299
|
}
|
|
1287
1300
|
/**
|
|
1288
1301
|
* Patch a document using a schema aware API.
|
|
@@ -1290,24 +1303,37 @@ var _client$7 = /* @__PURE__ */ new WeakMap(), _httpRequest$6 = /* @__PURE__ */
|
|
|
1290
1303
|
* @param request - instruction request
|
|
1291
1304
|
*/
|
|
1292
1305
|
patch(request) {
|
|
1293
|
-
return _patch(_classPrivateFieldGet2(_client2$
|
|
1306
|
+
return _patch(_classPrivateFieldGet2(_client2$8, this), _classPrivateFieldGet2(_httpRequest2$9, this), request);
|
|
1294
1307
|
}
|
|
1295
|
-
}, _client$
|
|
1308
|
+
}, _client$8 = /* @__PURE__ */ new WeakMap(), _httpRequest2$8 = /* @__PURE__ */ new WeakMap(), ObservableAssetsClient = class {
|
|
1296
1309
|
constructor(client, httpRequest) {
|
|
1297
|
-
_classPrivateFieldInitSpec(this, _client$
|
|
1310
|
+
_classPrivateFieldInitSpec(this, _client$8, void 0), _classPrivateFieldInitSpec(this, _httpRequest2$8, void 0), _classPrivateFieldSet2(_client$8, this, client), _classPrivateFieldSet2(_httpRequest2$8, this, httpRequest);
|
|
1298
1311
|
}
|
|
1299
1312
|
upload(assetType, body, options) {
|
|
1300
|
-
return _upload(_classPrivateFieldGet2(_client$
|
|
1313
|
+
return _upload(_classPrivateFieldGet2(_client$8, this), _classPrivateFieldGet2(_httpRequest2$8, this), assetType, body, options);
|
|
1301
1314
|
}
|
|
1302
|
-
}, _client2$
|
|
1315
|
+
}, _client2$7 = /* @__PURE__ */ new WeakMap(), _httpRequest3 = /* @__PURE__ */ new WeakMap(), AssetsClient = class {
|
|
1303
1316
|
constructor(client, httpRequest) {
|
|
1304
|
-
_classPrivateFieldInitSpec(this, _client2$
|
|
1317
|
+
_classPrivateFieldInitSpec(this, _client2$7, void 0), _classPrivateFieldInitSpec(this, _httpRequest3, void 0), _classPrivateFieldSet2(_client2$7, this, client), _classPrivateFieldSet2(_httpRequest3, this, httpRequest);
|
|
1305
1318
|
}
|
|
1306
1319
|
upload(assetType, body, options) {
|
|
1307
|
-
let observable = _upload(_classPrivateFieldGet2(_client2$
|
|
1308
|
-
return lastValueFrom(observable.pipe(filter((event) => event.type === "response"), map$1((event) => event.body
|
|
1320
|
+
let observable = _upload(_classPrivateFieldGet2(_client2$7, this), _classPrivateFieldGet2(_httpRequest3, this), assetType, body, options);
|
|
1321
|
+
return lastValueFrom(observable.pipe(filter((event) => event.type === "response"), map$1((event) => pluckUploadedAsset(event.body))));
|
|
1309
1322
|
}
|
|
1310
1323
|
};
|
|
1324
|
+
/**
|
|
1325
|
+
* Content Lake's upload endpoint responds with `{document: ...}`; the Media
|
|
1326
|
+
* Library upload endpoint responds with `{asset: ...}` instead (a
|
|
1327
|
+
* `sanity.asset` document, not a Content Lake asset document). Narrowing on
|
|
1328
|
+
* the response body itself - rather than on the client's `resource` config -
|
|
1329
|
+
* keeps this correct regardless of how the two are ever wired together.
|
|
1330
|
+
*/
|
|
1331
|
+
function isMediaLibraryUploadBody(body) {
|
|
1332
|
+
return "asset" in body;
|
|
1333
|
+
}
|
|
1334
|
+
function pluckUploadedAsset(body) {
|
|
1335
|
+
return isMediaLibraryUploadBody(body) ? body.asset : body.document;
|
|
1336
|
+
}
|
|
1311
1337
|
function _upload(client, _httpRequest, assetType, body, opts = {}) {
|
|
1312
1338
|
validateAssetType(assetType);
|
|
1313
1339
|
let meta = opts.extract || void 0;
|
|
@@ -1334,7 +1360,7 @@ function _upload(client, _httpRequest, assetType, body, opts = {}) {
|
|
|
1334
1360
|
body
|
|
1335
1361
|
};
|
|
1336
1362
|
return typeof XMLHttpRequest < "u" ? defer(async () => {
|
|
1337
|
-
let { uploadWithProgress } = await import("./browserUpload-
|
|
1363
|
+
let { uploadWithProgress } = await import("./browserUpload-CwpNx7Vl.js"), req = _prepareRequest(client, { ...baseRequest });
|
|
1338
1364
|
return uploadWithProgress({
|
|
1339
1365
|
url: appendQuery(req.url, req.query),
|
|
1340
1366
|
method: req.method ?? "POST",
|
|
@@ -1421,9 +1447,18 @@ function resolveEventSourceFetch(config, options = {}) {
|
|
|
1421
1447
|
return credentials !== void 0 && (mergedInit.credentials = credentials), baseFetch(typeof url == "string" ? url : url.href, mergedInit);
|
|
1422
1448
|
};
|
|
1423
1449
|
}
|
|
1450
|
+
/**
|
|
1451
|
+
* The fetch the client's own transport resolves for this config: the
|
|
1452
|
+
* configured `resolveFetch` (honouring an explicit `proxy`) if present,
|
|
1453
|
+
* otherwise the global fetch. Shared by the EventSource connection and the
|
|
1454
|
+
* `/check/cors` probe so both resolve identically.
|
|
1455
|
+
*
|
|
1456
|
+
* @internal
|
|
1457
|
+
*/
|
|
1424
1458
|
function pickBaseFetch(config) {
|
|
1425
1459
|
return config.resolveFetch ? config.resolveFetch(typeof config.proxy == "string" ? config.proxy : void 0) : globalThis.fetch.bind(globalThis);
|
|
1426
1460
|
}
|
|
1461
|
+
/** @internal */
|
|
1427
1462
|
const possibleOptions = [
|
|
1428
1463
|
"includePreviousRevision",
|
|
1429
1464
|
"includeResult",
|
|
@@ -1435,8 +1470,8 @@ const possibleOptions = [
|
|
|
1435
1470
|
"tag"
|
|
1436
1471
|
], defaultOptions = { includeResult: !0 };
|
|
1437
1472
|
/** @public */
|
|
1438
|
-
function _listen(query, params, opts = {}) {
|
|
1439
|
-
let
|
|
1473
|
+
function _listen$1(query, params, opts = {}) {
|
|
1474
|
+
let { url, requestTagPrefix } = this.config(), tag = opts.tag && requestTagPrefix ? [requestTagPrefix, opts.tag].join(".") : opts.tag, options = {
|
|
1440
1475
|
...defaults_default(opts, defaultOptions),
|
|
1441
1476
|
tag
|
|
1442
1477
|
}, listenOpts = pick(options, possibleOptions), qs = encodeQueryString({
|
|
@@ -1448,7 +1483,12 @@ function _listen(query, params, opts = {}) {
|
|
|
1448
1483
|
}
|
|
1449
1484
|
}), uri = `${url}${_getDataUrl(this, "listen", qs)}`;
|
|
1450
1485
|
if (uri.length > 14800) return throwError(() => /* @__PURE__ */ Error("Query too large for listener"));
|
|
1451
|
-
let listenFor = options.events ? options.events : ["mutation"]
|
|
1486
|
+
let listenFor = options.events ? options.events : ["mutation"];
|
|
1487
|
+
return _connectListenEventSource(this, uri, listenFor);
|
|
1488
|
+
}
|
|
1489
|
+
/** @internal */
|
|
1490
|
+
function _connectListenEventSource(client, uri, listenFor) {
|
|
1491
|
+
let config = client.config(), { token, withCredentials, headers: configHeaders } = config, headers = {};
|
|
1452
1492
|
token && (headers.Authorization = `Bearer ${token}`), configHeaders && Object.assign(headers, configHeaders);
|
|
1453
1493
|
let initEventSource = () => new EventSource(uri, { fetch: resolveEventSourceFetch(config, {
|
|
1454
1494
|
headers: Object.keys(headers).length ? headers : void 0,
|
|
@@ -1459,6 +1499,347 @@ function _listen(query, params, opts = {}) {
|
|
|
1459
1499
|
..."data" in event ? event.data : {}
|
|
1460
1500
|
})));
|
|
1461
1501
|
}
|
|
1502
|
+
/** @internal */
|
|
1503
|
+
const possibleRequestOptions = [
|
|
1504
|
+
"headers",
|
|
1505
|
+
"signal",
|
|
1506
|
+
"tag",
|
|
1507
|
+
"timeout",
|
|
1508
|
+
"token"
|
|
1509
|
+
];
|
|
1510
|
+
function commentUrl(id) {
|
|
1511
|
+
if (!id) throw Error("Comment ID must be provided");
|
|
1512
|
+
return `/collaboration/comments/${encodeURIComponent(id)}`;
|
|
1513
|
+
}
|
|
1514
|
+
function resolveCommentResource(client) {
|
|
1515
|
+
let { resource, projectId, dataset } = client.config();
|
|
1516
|
+
if (resource) return resource;
|
|
1517
|
+
if (projectId && dataset) return {
|
|
1518
|
+
type: "dataset",
|
|
1519
|
+
id: `${projectId}.${dataset}`
|
|
1520
|
+
};
|
|
1521
|
+
throw Error("`resource` or `projectId` and `dataset` must be configured to use collaboration comments");
|
|
1522
|
+
}
|
|
1523
|
+
function resourceQuery(client) {
|
|
1524
|
+
let { collaboration } = client.config(), organizationId = collaboration?.organizationId;
|
|
1525
|
+
if (!organizationId) throw Error("`collaboration.organizationId` must be configured to use collaboration comments");
|
|
1526
|
+
let resource = resolveCommentResource(client);
|
|
1527
|
+
return {
|
|
1528
|
+
organizationId,
|
|
1529
|
+
resourceId: resource.id,
|
|
1530
|
+
resourceType: resource.type
|
|
1531
|
+
};
|
|
1532
|
+
}
|
|
1533
|
+
/** @internal */
|
|
1534
|
+
function _getTargetDocumentRef(client, documentId) {
|
|
1535
|
+
if (!documentId) throw Error("Document ID must be provided");
|
|
1536
|
+
let resource = resolveCommentResource(client);
|
|
1537
|
+
return `${resource.type}:${resource.id}:${getPublishedId(documentId)}`;
|
|
1538
|
+
}
|
|
1539
|
+
function write(client, httpRequest, method, url, body, options = {}) {
|
|
1540
|
+
return _requestObservable(client, httpRequest, {
|
|
1541
|
+
method,
|
|
1542
|
+
url,
|
|
1543
|
+
body,
|
|
1544
|
+
query: {
|
|
1545
|
+
...resourceQuery(client),
|
|
1546
|
+
...options.transactionId ? { transactionId: options.transactionId } : {}
|
|
1547
|
+
},
|
|
1548
|
+
...pick(options, possibleRequestOptions)
|
|
1549
|
+
});
|
|
1550
|
+
}
|
|
1551
|
+
/**
|
|
1552
|
+
* `commentId` picks the written comment out of the results: a status update
|
|
1553
|
+
* cascades to the comment's replies, and the API leaves the results unordered.
|
|
1554
|
+
* Creates pass the requested `_id`, which is undefined when the API assigns
|
|
1555
|
+
* one, and always come back with a single result.
|
|
1556
|
+
*/
|
|
1557
|
+
function writeDocument(commentId, ...args) {
|
|
1558
|
+
return write(...args).pipe(map$1(({ results }) => {
|
|
1559
|
+
let result = commentId ? results.find(({ id }) => id === commentId) : results[0];
|
|
1560
|
+
if (!result?.document) throw Error("Comment write did not return a comment document");
|
|
1561
|
+
return result.document;
|
|
1562
|
+
}));
|
|
1563
|
+
}
|
|
1564
|
+
function writeMutationResult(...args) {
|
|
1565
|
+
return write(...args).pipe(map$1(({ transactionId, results }) => ({
|
|
1566
|
+
transactionId,
|
|
1567
|
+
documentIds: results.map((result) => result.id),
|
|
1568
|
+
results
|
|
1569
|
+
})));
|
|
1570
|
+
}
|
|
1571
|
+
/** @internal */
|
|
1572
|
+
function _create(client, httpRequest, body, options) {
|
|
1573
|
+
return writeDocument(body._id, client, httpRequest, "POST", "/collaboration/comments", body, options);
|
|
1574
|
+
}
|
|
1575
|
+
/** @internal */
|
|
1576
|
+
function _update(client, httpRequest, id, body, options) {
|
|
1577
|
+
return writeDocument(id, client, httpRequest, "PATCH", commentUrl(id), body, options);
|
|
1578
|
+
}
|
|
1579
|
+
/** @internal */
|
|
1580
|
+
function _delete(client, httpRequest, id, options) {
|
|
1581
|
+
return writeMutationResult(client, httpRequest, "DELETE", commentUrl(id), void 0, options);
|
|
1582
|
+
}
|
|
1583
|
+
/** @internal */
|
|
1584
|
+
function _addReaction(client, httpRequest, id, shortName, options) {
|
|
1585
|
+
return writeDocument(id, client, httpRequest, "POST", `${commentUrl(id)}/reactions`, { shortName }, options);
|
|
1586
|
+
}
|
|
1587
|
+
/** @internal */
|
|
1588
|
+
function _removeReaction(client, httpRequest, id, shortName, options) {
|
|
1589
|
+
return writeDocument(id, client, httpRequest, "DELETE", `${commentUrl(id)}/reactions/${encodeURIComponent(shortName)}`, void 0, options);
|
|
1590
|
+
}
|
|
1591
|
+
/** @internal */
|
|
1592
|
+
function _fetch(client, httpRequest, query, params, options) {
|
|
1593
|
+
let search = resourceQuery(client);
|
|
1594
|
+
return _requestObservable(client, httpRequest, {
|
|
1595
|
+
...encodeQueryString({
|
|
1596
|
+
query,
|
|
1597
|
+
params
|
|
1598
|
+
}).length < 11264 ? {
|
|
1599
|
+
method: "GET",
|
|
1600
|
+
url: `/collaboration/comments/query${encodeQueryString({
|
|
1601
|
+
query,
|
|
1602
|
+
params,
|
|
1603
|
+
options: search
|
|
1604
|
+
})}`
|
|
1605
|
+
} : {
|
|
1606
|
+
method: "POST",
|
|
1607
|
+
url: "/collaboration/comments/query",
|
|
1608
|
+
query: search,
|
|
1609
|
+
body: {
|
|
1610
|
+
query,
|
|
1611
|
+
params: params ?? {}
|
|
1612
|
+
}
|
|
1613
|
+
},
|
|
1614
|
+
...pick(options || {}, possibleRequestOptions)
|
|
1615
|
+
}).pipe(map$1((response) => response.result));
|
|
1616
|
+
}
|
|
1617
|
+
/** @internal */
|
|
1618
|
+
function _listen(client, query, params, options) {
|
|
1619
|
+
let opts = options ?? {}, { requestTagPrefix } = client.config(), tag = opts.tag && requestTagPrefix ? [requestTagPrefix, opts.tag].join(".") : opts.tag, listenOpts = pick({
|
|
1620
|
+
...defaults_default(opts, defaultOptions),
|
|
1621
|
+
tag
|
|
1622
|
+
}, possibleOptions), qs = encodeQueryString({
|
|
1623
|
+
query,
|
|
1624
|
+
params,
|
|
1625
|
+
options: {
|
|
1626
|
+
...listenOpts,
|
|
1627
|
+
...resourceQuery(client)
|
|
1628
|
+
}
|
|
1629
|
+
}), uri = `${client.getUrl("/collaboration/comments/listen")}${qs}`;
|
|
1630
|
+
return uri.length > 14800 ? throwError(() => /* @__PURE__ */ Error("Query too large for listener")) : _connectListenEventSource(client, uri, opts.events ? opts.events : ["mutation"]);
|
|
1631
|
+
}
|
|
1632
|
+
var _client$7 = /* @__PURE__ */ new WeakMap(), _httpRequest$7 = /* @__PURE__ */ new WeakMap(), ObservableCollaborationCommentsClient = class {
|
|
1633
|
+
constructor(client, httpRequest) {
|
|
1634
|
+
_classPrivateFieldInitSpec(this, _client$7, void 0), _classPrivateFieldInitSpec(this, _httpRequest$7, void 0), _classPrivateFieldSet2(_client$7, this, client), _classPrivateFieldSet2(_httpRequest$7, this, httpRequest);
|
|
1635
|
+
}
|
|
1636
|
+
/**
|
|
1637
|
+
* Create a comment or reply on the configured resource.
|
|
1638
|
+
*
|
|
1639
|
+
* A top-level comment requires `target`; a reply requires `parentCommentId` (never both).
|
|
1640
|
+
* Replies inherit `target`, `status`, and `threadId` from the parent comment.
|
|
1641
|
+
*
|
|
1642
|
+
* @param body - Comment to create
|
|
1643
|
+
* @param options - Optional request options
|
|
1644
|
+
* @returns The created comment
|
|
1645
|
+
*/
|
|
1646
|
+
create(body, options) {
|
|
1647
|
+
return _create(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), body, options);
|
|
1648
|
+
}
|
|
1649
|
+
/**
|
|
1650
|
+
* Update an existing comment.
|
|
1651
|
+
*
|
|
1652
|
+
* Updating `status` cascades to the comment's replies.
|
|
1653
|
+
*
|
|
1654
|
+
* @param id - Comment document ID
|
|
1655
|
+
* @param body - Fields to update
|
|
1656
|
+
* @param options - Optional request options
|
|
1657
|
+
* @returns The updated comment
|
|
1658
|
+
*/
|
|
1659
|
+
update(id, body, options) {
|
|
1660
|
+
return _update(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), id, body, options);
|
|
1661
|
+
}
|
|
1662
|
+
/**
|
|
1663
|
+
* Delete a comment and its replies.
|
|
1664
|
+
*
|
|
1665
|
+
* @param id - Comment document ID
|
|
1666
|
+
* @param options - Optional request options
|
|
1667
|
+
* @returns Mutation result, where `documentIds` covers the comment and every deleted reply
|
|
1668
|
+
*/
|
|
1669
|
+
delete(id, options) {
|
|
1670
|
+
return _delete(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), id, options);
|
|
1671
|
+
}
|
|
1672
|
+
/**
|
|
1673
|
+
* Add the current user's reaction to a comment.
|
|
1674
|
+
*
|
|
1675
|
+
* @param id - Comment document ID
|
|
1676
|
+
* @param shortName - Emoji short name, for example `:+1:`
|
|
1677
|
+
* @param options - Optional request options
|
|
1678
|
+
* @returns The comment, with the reaction applied
|
|
1679
|
+
*/
|
|
1680
|
+
addReaction(id, shortName, options) {
|
|
1681
|
+
return _addReaction(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), id, shortName, options);
|
|
1682
|
+
}
|
|
1683
|
+
/**
|
|
1684
|
+
* Remove the current user's reaction from a comment.
|
|
1685
|
+
*
|
|
1686
|
+
* @param id - Comment document ID
|
|
1687
|
+
* @param shortName - Emoji short name, for example `:+1:`
|
|
1688
|
+
* @param options - Optional request options
|
|
1689
|
+
* @returns The comment, with the reaction removed
|
|
1690
|
+
*/
|
|
1691
|
+
removeReaction(id, shortName, options) {
|
|
1692
|
+
return _removeReaction(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), id, shortName, options);
|
|
1693
|
+
}
|
|
1694
|
+
/**
|
|
1695
|
+
* Build the global document reference used by `target.document._ref`, for use in
|
|
1696
|
+
* queries and listeners.
|
|
1697
|
+
*
|
|
1698
|
+
* The reference is built from the configured `resource` and the published ID of
|
|
1699
|
+
* the given document ID, since comment references always use published IDs.
|
|
1700
|
+
*
|
|
1701
|
+
* @example
|
|
1702
|
+
* ```ts
|
|
1703
|
+
* client.collaboration.comments.listen(
|
|
1704
|
+
* '*[_type == "sanity.comment" && target.document._ref == $ref]',
|
|
1705
|
+
* {ref: client.collaboration.comments.getTargetDocumentRef('doc-1')},
|
|
1706
|
+
* )
|
|
1707
|
+
* ```
|
|
1708
|
+
*
|
|
1709
|
+
* @param documentId - Document ID, in published, draft or version form
|
|
1710
|
+
* @returns Global document reference, of the form `resourceType:resourceId:documentId`
|
|
1711
|
+
*/
|
|
1712
|
+
getTargetDocumentRef(documentId) {
|
|
1713
|
+
return _getTargetDocumentRef(_classPrivateFieldGet2(_client$7, this), documentId);
|
|
1714
|
+
}
|
|
1715
|
+
/**
|
|
1716
|
+
* Fetch comments on the configured resource.
|
|
1717
|
+
*
|
|
1718
|
+
* Takes the same `query` and `params` as `client.fetch`, and switches from a
|
|
1719
|
+
* GET to a POST for queries too large for the request URL in the same way,
|
|
1720
|
+
* but queries the comments endpoint, which accepts none of the query options
|
|
1721
|
+
* `client.fetch` does (`perspective`, `useCdn`, `filterResponse`,
|
|
1722
|
+
* `resultSourceMap`, stega).
|
|
1723
|
+
*
|
|
1724
|
+
* The query runs against the organization store, which is not scoped to
|
|
1725
|
+
* comments, so filter on `_type == "sanity.comment"`.
|
|
1726
|
+
*
|
|
1727
|
+
* @param query - GROQ-query to perform
|
|
1728
|
+
* @param params - Optional query parameters
|
|
1729
|
+
* @param options - Optional request options
|
|
1730
|
+
*/
|
|
1731
|
+
fetch(query, params, options) {
|
|
1732
|
+
return _fetch(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), query, params, options);
|
|
1733
|
+
}
|
|
1734
|
+
listen(query, params, options) {
|
|
1735
|
+
return _listen(_classPrivateFieldGet2(_client$7, this), query, params, options);
|
|
1736
|
+
}
|
|
1737
|
+
}, _client2$6 = /* @__PURE__ */ new WeakMap(), _httpRequest2$7 = /* @__PURE__ */ new WeakMap(), CollaborationCommentsClient = class {
|
|
1738
|
+
constructor(client, httpRequest) {
|
|
1739
|
+
_classPrivateFieldInitSpec(this, _client2$6, void 0), _classPrivateFieldInitSpec(this, _httpRequest2$7, void 0), _classPrivateFieldSet2(_client2$6, this, client), _classPrivateFieldSet2(_httpRequest2$7, this, httpRequest);
|
|
1740
|
+
}
|
|
1741
|
+
/**
|
|
1742
|
+
* Create a comment or reply on the configured resource.
|
|
1743
|
+
*
|
|
1744
|
+
* A top-level comment requires `target`; a reply requires `parentCommentId` (never both).
|
|
1745
|
+
* Replies inherit `target`, `status`, and `threadId` from the parent comment.
|
|
1746
|
+
*
|
|
1747
|
+
* @param body - Comment to create
|
|
1748
|
+
* @param options - Optional request options
|
|
1749
|
+
* @returns The created comment
|
|
1750
|
+
*/
|
|
1751
|
+
create(body, options) {
|
|
1752
|
+
return lastValueFrom(_create(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), body, options));
|
|
1753
|
+
}
|
|
1754
|
+
/**
|
|
1755
|
+
* Update an existing comment.
|
|
1756
|
+
*
|
|
1757
|
+
* Updating `status` cascades to the comment's replies.
|
|
1758
|
+
*
|
|
1759
|
+
* @param id - Comment document ID
|
|
1760
|
+
* @param body - Fields to update
|
|
1761
|
+
* @param options - Optional request options
|
|
1762
|
+
* @returns The updated comment
|
|
1763
|
+
*/
|
|
1764
|
+
update(id, body, options) {
|
|
1765
|
+
return lastValueFrom(_update(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), id, body, options));
|
|
1766
|
+
}
|
|
1767
|
+
/**
|
|
1768
|
+
* Delete a comment and its replies.
|
|
1769
|
+
*
|
|
1770
|
+
* @param id - Comment document ID
|
|
1771
|
+
* @param options - Optional request options
|
|
1772
|
+
* @returns Mutation result, where `documentIds` covers the comment and every deleted reply
|
|
1773
|
+
*/
|
|
1774
|
+
delete(id, options) {
|
|
1775
|
+
return lastValueFrom(_delete(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), id, options));
|
|
1776
|
+
}
|
|
1777
|
+
/**
|
|
1778
|
+
* Add the current user's reaction to a comment.
|
|
1779
|
+
*
|
|
1780
|
+
* @param id - Comment document ID
|
|
1781
|
+
* @param shortName - Emoji short name, for example `:+1:`
|
|
1782
|
+
* @param options - Optional request options
|
|
1783
|
+
* @returns The comment, with the reaction applied
|
|
1784
|
+
*/
|
|
1785
|
+
addReaction(id, shortName, options) {
|
|
1786
|
+
return lastValueFrom(_addReaction(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), id, shortName, options));
|
|
1787
|
+
}
|
|
1788
|
+
/**
|
|
1789
|
+
* Remove the current user's reaction from a comment.
|
|
1790
|
+
*
|
|
1791
|
+
* @param id - Comment document ID
|
|
1792
|
+
* @param shortName - Emoji short name, for example `:+1:`
|
|
1793
|
+
* @param options - Optional request options
|
|
1794
|
+
* @returns The comment, with the reaction removed
|
|
1795
|
+
*/
|
|
1796
|
+
removeReaction(id, shortName, options) {
|
|
1797
|
+
return lastValueFrom(_removeReaction(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), id, shortName, options));
|
|
1798
|
+
}
|
|
1799
|
+
/**
|
|
1800
|
+
* Build the global document reference used by `target.document._ref`, for use in
|
|
1801
|
+
* queries and listeners.
|
|
1802
|
+
*
|
|
1803
|
+
* The reference is built from the configured `resource` and the published ID of
|
|
1804
|
+
* the given document ID, since comment references always use published IDs.
|
|
1805
|
+
*
|
|
1806
|
+
* @example
|
|
1807
|
+
* ```ts
|
|
1808
|
+
* const comments = await client.collaboration.comments.fetch(
|
|
1809
|
+
* '*[_type == "sanity.comment" && target.document._ref == $ref]',
|
|
1810
|
+
* {ref: client.collaboration.comments.getTargetDocumentRef('doc-1')},
|
|
1811
|
+
* )
|
|
1812
|
+
* ```
|
|
1813
|
+
*
|
|
1814
|
+
* @param documentId - Document ID, in published, draft or version form
|
|
1815
|
+
* @returns Global document reference, of the form `resourceType:resourceId:documentId`
|
|
1816
|
+
*/
|
|
1817
|
+
getTargetDocumentRef(documentId) {
|
|
1818
|
+
return _getTargetDocumentRef(_classPrivateFieldGet2(_client2$6, this), documentId);
|
|
1819
|
+
}
|
|
1820
|
+
/**
|
|
1821
|
+
* Fetch comments on the configured resource.
|
|
1822
|
+
*
|
|
1823
|
+
* Takes the same `query` and `params` as `client.fetch`, and switches from a
|
|
1824
|
+
* GET to a POST for queries too large for the request URL in the same way,
|
|
1825
|
+
* but queries the comments endpoint, which accepts none of the query options
|
|
1826
|
+
* `client.fetch` does (`perspective`, `useCdn`, `filterResponse`,
|
|
1827
|
+
* `resultSourceMap`, stega).
|
|
1828
|
+
*
|
|
1829
|
+
* The query runs against the organization store, which is not scoped to
|
|
1830
|
+
* comments, so filter on `_type == "sanity.comment"`.
|
|
1831
|
+
*
|
|
1832
|
+
* @param query - GROQ-query to perform
|
|
1833
|
+
* @param params - Optional query parameters
|
|
1834
|
+
* @param options - Optional request options
|
|
1835
|
+
*/
|
|
1836
|
+
fetch(query, params, options) {
|
|
1837
|
+
return lastValueFrom(_fetch(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), query, params, options));
|
|
1838
|
+
}
|
|
1839
|
+
listen(query, params, options) {
|
|
1840
|
+
return _listen(_classPrivateFieldGet2(_client2$6, this), query, params, options);
|
|
1841
|
+
}
|
|
1842
|
+
};
|
|
1462
1843
|
/**
|
|
1463
1844
|
* A variant of share that takes a predicate function to determine which value to replay to new subscribers
|
|
1464
1845
|
* @param configOrPredicate - Predicate function to determine which value to replay
|
|
@@ -1483,18 +1864,18 @@ function _shareReplayLatest(config) {
|
|
|
1483
1864
|
};
|
|
1484
1865
|
}
|
|
1485
1866
|
const requiredApiVersion = "2021-03-25";
|
|
1486
|
-
var _client$
|
|
1867
|
+
var _client$6 = /* @__PURE__ */ new WeakMap(), LiveClient = class {
|
|
1487
1868
|
constructor(client) {
|
|
1488
|
-
_classPrivateFieldInitSpec(this, _client$
|
|
1869
|
+
_classPrivateFieldInitSpec(this, _client$6, void 0), _classPrivateFieldSet2(_client$6, this, client);
|
|
1489
1870
|
}
|
|
1490
1871
|
/**
|
|
1491
1872
|
* Requires `apiVersion` to be `2021-03-25` or later.
|
|
1492
1873
|
*/
|
|
1493
1874
|
events({ includeDrafts = !1, tag: _tag, waitFor } = {}) {
|
|
1494
|
-
let config = _classPrivateFieldGet2(_client$
|
|
1875
|
+
let config = _classPrivateFieldGet2(_client$6, this).config(), { projectId, apiVersion: _apiVersion, token, withCredentials, requestTagPrefix, headers: configHeaders } = config, apiVersion = _apiVersion.replace(/^v/, "");
|
|
1495
1876
|
if (apiVersion !== "X" && apiVersion < requiredApiVersion) throw Error(`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.`);
|
|
1496
1877
|
if (includeDrafts && !token && !withCredentials) throw Error("The live events API requires a token or withCredentials when 'includeDrafts: true'. Please update your client configuration. The token should have the lowest possible access role.");
|
|
1497
|
-
let path = _getDataUrl(_classPrivateFieldGet2(_client$
|
|
1878
|
+
let path = _getDataUrl(_classPrivateFieldGet2(_client$6, this), "live/events"), url = new URL(_classPrivateFieldGet2(_client$6, this).getUrl(path, !1)), tag = _tag && requestTagPrefix ? [requestTagPrefix, _tag].join(".") : _tag;
|
|
1498
1879
|
tag && url.searchParams.set("tag", tag), includeDrafts && url.searchParams.set("includeDrafts", "true"), waitFor && url.searchParams.set("waitFor", waitFor);
|
|
1499
1880
|
let eventSourceHeaders = {};
|
|
1500
1881
|
includeDrafts && token && (eventSourceHeaders.Authorization = `Bearer ${token}`), configHeaders && Object.assign(eventSourceHeaders, configHeaders);
|
|
@@ -1516,7 +1897,7 @@ var _client$5 = /* @__PURE__ */ new WeakMap(), LiveClient = class {
|
|
|
1516
1897
|
"welcome",
|
|
1517
1898
|
"reconnect",
|
|
1518
1899
|
"goaway"
|
|
1519
|
-
]), checkCors = checkCorsObservable(new URL(_classPrivateFieldGet2(_client$
|
|
1900
|
+
]), checkCors = checkCorsObservable(new URL(_classPrivateFieldGet2(_client$6, this).getUrl("/check/cors", !1)), projectId, eventSourceWithCredentials, pickBaseFetch(config)), observable = events.pipe(reconnectOnConnectionFailure(), mergeMap((event) => event.type === "reconnect" ? checkCors.pipe(mergeMap(() => of(event))) : of(event)), catchError((err) => err instanceof CorsOriginError ? throwError(() => err) : checkCors.pipe(mergeMap(() => {
|
|
1520
1901
|
throw err;
|
|
1521
1902
|
}))), map$1((event) => {
|
|
1522
1903
|
if (event.type === "message") {
|
|
@@ -1569,34 +1950,33 @@ var _client$5 = /* @__PURE__ */ new WeakMap(), LiveClient = class {
|
|
|
1569
1950
|
* In all of those cases the caller's original underlying error from the
|
|
1570
1951
|
* EventSource is allowed to propagate unchanged.
|
|
1571
1952
|
*/
|
|
1572
|
-
function checkCorsObservable(url, projectId, requireCredentials) {
|
|
1953
|
+
function checkCorsObservable(url, projectId, requireCredentials, fetcher) {
|
|
1573
1954
|
return new Observable((observer) => {
|
|
1574
1955
|
let controller = new AbortController(), { signal } = controller;
|
|
1575
|
-
return
|
|
1956
|
+
return fetcher(url.href, {
|
|
1576
1957
|
method: "GET",
|
|
1577
|
-
mode: "cors",
|
|
1578
1958
|
credentials: "omit",
|
|
1579
1959
|
signal
|
|
1580
1960
|
}).then((response) => {
|
|
1581
|
-
if (!(signal.aborted || !response.ok)) return response.
|
|
1582
|
-
}).then((
|
|
1583
|
-
if (
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
if (body?.result?.allowed === !1) {
|
|
1592
|
-
observer.error(new CorsOriginError({
|
|
1593
|
-
projectId,
|
|
1594
|
-
credentials: requireCredentials
|
|
1595
|
-
}));
|
|
1596
|
-
return;
|
|
1597
|
-
}
|
|
1598
|
-
observer.next(), observer.complete();
|
|
1961
|
+
if (!(signal.aborted || !response.ok)) return response.text();
|
|
1962
|
+
}).then((text) => {
|
|
1963
|
+
if (signal.aborted) return;
|
|
1964
|
+
let parsed = text === void 0 ? void 0 : JSON.parse(text), result = isRecord(parsed) ? parsed.result : void 0;
|
|
1965
|
+
if (requireCredentials && isRecord(result) && result.withCredentials === !1) {
|
|
1966
|
+
observer.error(new CorsOriginError({
|
|
1967
|
+
projectId,
|
|
1968
|
+
credentials: !0
|
|
1969
|
+
}));
|
|
1970
|
+
return;
|
|
1599
1971
|
}
|
|
1972
|
+
if (isRecord(result) && result.allowed === !1) {
|
|
1973
|
+
observer.error(new CorsOriginError({
|
|
1974
|
+
projectId,
|
|
1975
|
+
credentials: requireCredentials
|
|
1976
|
+
}));
|
|
1977
|
+
return;
|
|
1978
|
+
}
|
|
1979
|
+
observer.next(), observer.complete();
|
|
1600
1980
|
}).catch(() => {
|
|
1601
1981
|
signal.aborted || observer.closed || (observer.next(), observer.complete());
|
|
1602
1982
|
}), () => controller.abort();
|
|
@@ -1608,9 +1988,9 @@ function checkCorsObservable(url, projectId, requireCredentials) {
|
|
|
1608
1988
|
* resolver — `undefined` covers the `globalThis.fetch` fallback.
|
|
1609
1989
|
*/
|
|
1610
1990
|
const eventsCache = /* @__PURE__ */ new Map();
|
|
1611
|
-
var _client$
|
|
1991
|
+
var _client$5 = /* @__PURE__ */ new WeakMap(), _httpRequest$6 = /* @__PURE__ */ new WeakMap(), ObservableDatasetsClient = class {
|
|
1612
1992
|
constructor(client, httpRequest) {
|
|
1613
|
-
_classPrivateFieldInitSpec(this, _client$
|
|
1993
|
+
_classPrivateFieldInitSpec(this, _client$5, void 0), _classPrivateFieldInitSpec(this, _httpRequest$6, void 0), _classPrivateFieldSet2(_client$5, this, client), _classPrivateFieldSet2(_httpRequest$6, this, httpRequest);
|
|
1614
1994
|
}
|
|
1615
1995
|
/**
|
|
1616
1996
|
* Create a new dataset with the given name
|
|
@@ -1619,7 +1999,7 @@ var _client$4 = /* @__PURE__ */ new WeakMap(), _httpRequest$5 = /* @__PURE__ */
|
|
|
1619
1999
|
* @param options - Options for the dataset, including optional embeddings configuration
|
|
1620
2000
|
*/
|
|
1621
2001
|
create(name, options) {
|
|
1622
|
-
return _modifyObservable(_classPrivateFieldGet2(_client$
|
|
2002
|
+
return _modifyObservable(_classPrivateFieldGet2(_client$5, this), _classPrivateFieldGet2(_httpRequest$6, this), "PUT", name, options);
|
|
1623
2003
|
}
|
|
1624
2004
|
/**
|
|
1625
2005
|
* Edit a dataset with the given name
|
|
@@ -1628,7 +2008,7 @@ var _client$4 = /* @__PURE__ */ new WeakMap(), _httpRequest$5 = /* @__PURE__ */
|
|
|
1628
2008
|
* @param options - New options for the dataset
|
|
1629
2009
|
*/
|
|
1630
2010
|
edit(name, options) {
|
|
1631
|
-
return _modifyObservable(_classPrivateFieldGet2(_client$
|
|
2011
|
+
return _modifyObservable(_classPrivateFieldGet2(_client$5, this), _classPrivateFieldGet2(_httpRequest$6, this), "PATCH", name, options);
|
|
1632
2012
|
}
|
|
1633
2013
|
/**
|
|
1634
2014
|
* Delete a dataset with the given name
|
|
@@ -1636,15 +2016,15 @@ var _client$4 = /* @__PURE__ */ new WeakMap(), _httpRequest$5 = /* @__PURE__ */
|
|
|
1636
2016
|
* @param name - Name of the dataset to delete
|
|
1637
2017
|
*/
|
|
1638
2018
|
delete(name) {
|
|
1639
|
-
return _modifyObservable(_classPrivateFieldGet2(_client$
|
|
2019
|
+
return _modifyObservable(_classPrivateFieldGet2(_client$5, this), _classPrivateFieldGet2(_httpRequest$6, this), "DELETE", name);
|
|
1640
2020
|
}
|
|
1641
2021
|
/**
|
|
1642
2022
|
* Fetch a list of datasets for the configured project
|
|
1643
2023
|
*/
|
|
1644
2024
|
list() {
|
|
1645
|
-
resourceGuard("dataset", _classPrivateFieldGet2(_client$
|
|
1646
|
-
let config = _classPrivateFieldGet2(_client$
|
|
1647
|
-
return config.useProjectHostname === !1 && (url = `/projects/${projectId}/datasets`), _requestObservable(_classPrivateFieldGet2(_client$
|
|
2025
|
+
resourceGuard("dataset", _classPrivateFieldGet2(_client$5, this).config());
|
|
2026
|
+
let config = _classPrivateFieldGet2(_client$5, this).config(), projectId = config.projectId, url = "/datasets";
|
|
2027
|
+
return config.useProjectHostname === !1 && (url = `/projects/${projectId}/datasets`), _requestObservable(_classPrivateFieldGet2(_client$5, this), _classPrivateFieldGet2(_httpRequest$6, this), {
|
|
1648
2028
|
url,
|
|
1649
2029
|
tag: null
|
|
1650
2030
|
});
|
|
@@ -1655,8 +2035,8 @@ var _client$4 = /* @__PURE__ */ new WeakMap(), _httpRequest$5 = /* @__PURE__ */
|
|
|
1655
2035
|
* @param name - Name of the dataset
|
|
1656
2036
|
*/
|
|
1657
2037
|
getEmbeddingsSettings(name) {
|
|
1658
|
-
return resourceGuard("dataset", _classPrivateFieldGet2(_client$
|
|
1659
|
-
url: _embeddingsSettingsUri(_classPrivateFieldGet2(_client$
|
|
2038
|
+
return resourceGuard("dataset", _classPrivateFieldGet2(_client$5, this).config()), dataset(name), _requestObservable(_classPrivateFieldGet2(_client$5, this), _classPrivateFieldGet2(_httpRequest$6, this), {
|
|
2039
|
+
url: _embeddingsSettingsUri(_classPrivateFieldGet2(_client$5, this), name),
|
|
1660
2040
|
tag: null
|
|
1661
2041
|
});
|
|
1662
2042
|
}
|
|
@@ -1667,16 +2047,16 @@ var _client$4 = /* @__PURE__ */ new WeakMap(), _httpRequest$5 = /* @__PURE__ */
|
|
|
1667
2047
|
* @param settings - Embeddings settings to apply
|
|
1668
2048
|
*/
|
|
1669
2049
|
editEmbeddingsSettings(name, settings) {
|
|
1670
|
-
return resourceGuard("dataset", _classPrivateFieldGet2(_client$
|
|
2050
|
+
return resourceGuard("dataset", _classPrivateFieldGet2(_client$5, this).config()), dataset(name), _requestObservable(_classPrivateFieldGet2(_client$5, this), _classPrivateFieldGet2(_httpRequest$6, this), {
|
|
1671
2051
|
method: "PUT",
|
|
1672
|
-
url: _embeddingsSettingsUri(_classPrivateFieldGet2(_client$
|
|
2052
|
+
url: _embeddingsSettingsUri(_classPrivateFieldGet2(_client$5, this), name),
|
|
1673
2053
|
body: settings,
|
|
1674
2054
|
tag: null
|
|
1675
2055
|
});
|
|
1676
2056
|
}
|
|
1677
|
-
}, _client2$
|
|
2057
|
+
}, _client2$5 = /* @__PURE__ */ new WeakMap(), _httpRequest2$6 = /* @__PURE__ */ new WeakMap(), DatasetsClient = class {
|
|
1678
2058
|
constructor(client, httpRequest) {
|
|
1679
|
-
_classPrivateFieldInitSpec(this, _client2$
|
|
2059
|
+
_classPrivateFieldInitSpec(this, _client2$5, void 0), _classPrivateFieldInitSpec(this, _httpRequest2$6, void 0), _classPrivateFieldSet2(_client2$5, this, client), _classPrivateFieldSet2(_httpRequest2$6, this, httpRequest);
|
|
1680
2060
|
}
|
|
1681
2061
|
/**
|
|
1682
2062
|
* Create a new dataset with the given name
|
|
@@ -1685,7 +2065,7 @@ var _client$4 = /* @__PURE__ */ new WeakMap(), _httpRequest$5 = /* @__PURE__ */
|
|
|
1685
2065
|
* @param options - Options for the dataset, including optional embeddings configuration
|
|
1686
2066
|
*/
|
|
1687
2067
|
create(name, options) {
|
|
1688
|
-
return resourceGuard("dataset", _classPrivateFieldGet2(_client2$
|
|
2068
|
+
return resourceGuard("dataset", _classPrivateFieldGet2(_client2$5, this).config()), _modify(_classPrivateFieldGet2(_client2$5, this), _classPrivateFieldGet2(_httpRequest2$6, this), "PUT", name, options);
|
|
1689
2069
|
}
|
|
1690
2070
|
/**
|
|
1691
2071
|
* Edit a dataset with the given name
|
|
@@ -1694,7 +2074,7 @@ var _client$4 = /* @__PURE__ */ new WeakMap(), _httpRequest$5 = /* @__PURE__ */
|
|
|
1694
2074
|
* @param options - New options for the dataset
|
|
1695
2075
|
*/
|
|
1696
2076
|
edit(name, options) {
|
|
1697
|
-
return resourceGuard("dataset", _classPrivateFieldGet2(_client2$
|
|
2077
|
+
return resourceGuard("dataset", _classPrivateFieldGet2(_client2$5, this).config()), _modify(_classPrivateFieldGet2(_client2$5, this), _classPrivateFieldGet2(_httpRequest2$6, this), "PATCH", name, options);
|
|
1698
2078
|
}
|
|
1699
2079
|
/**
|
|
1700
2080
|
* Delete a dataset with the given name
|
|
@@ -1702,15 +2082,15 @@ var _client$4 = /* @__PURE__ */ new WeakMap(), _httpRequest$5 = /* @__PURE__ */
|
|
|
1702
2082
|
* @param name - Name of the dataset to delete
|
|
1703
2083
|
*/
|
|
1704
2084
|
delete(name) {
|
|
1705
|
-
return resourceGuard("dataset", _classPrivateFieldGet2(_client2$
|
|
2085
|
+
return resourceGuard("dataset", _classPrivateFieldGet2(_client2$5, this).config()), _modify(_classPrivateFieldGet2(_client2$5, this), _classPrivateFieldGet2(_httpRequest2$6, this), "DELETE", name);
|
|
1706
2086
|
}
|
|
1707
2087
|
/**
|
|
1708
2088
|
* Fetch a list of datasets for the configured project
|
|
1709
2089
|
*/
|
|
1710
2090
|
list() {
|
|
1711
|
-
resourceGuard("dataset", _classPrivateFieldGet2(_client2$
|
|
1712
|
-
let config = _classPrivateFieldGet2(_client2$
|
|
1713
|
-
return config.useProjectHostname === !1 && (url = `/projects/${projectId}/datasets`), _request(_classPrivateFieldGet2(_client2$
|
|
2091
|
+
resourceGuard("dataset", _classPrivateFieldGet2(_client2$5, this).config());
|
|
2092
|
+
let config = _classPrivateFieldGet2(_client2$5, this).config(), projectId = config.projectId, url = "/datasets";
|
|
2093
|
+
return config.useProjectHostname === !1 && (url = `/projects/${projectId}/datasets`), _request(_classPrivateFieldGet2(_client2$5, this), _classPrivateFieldGet2(_httpRequest2$6, this), {
|
|
1714
2094
|
url,
|
|
1715
2095
|
tag: null
|
|
1716
2096
|
});
|
|
@@ -1721,8 +2101,8 @@ var _client$4 = /* @__PURE__ */ new WeakMap(), _httpRequest$5 = /* @__PURE__ */
|
|
|
1721
2101
|
* @param name - Name of the dataset
|
|
1722
2102
|
*/
|
|
1723
2103
|
getEmbeddingsSettings(name) {
|
|
1724
|
-
return resourceGuard("dataset", _classPrivateFieldGet2(_client2$
|
|
1725
|
-
url: _embeddingsSettingsUri(_classPrivateFieldGet2(_client2$
|
|
2104
|
+
return resourceGuard("dataset", _classPrivateFieldGet2(_client2$5, this).config()), dataset(name), _request(_classPrivateFieldGet2(_client2$5, this), _classPrivateFieldGet2(_httpRequest2$6, this), {
|
|
2105
|
+
url: _embeddingsSettingsUri(_classPrivateFieldGet2(_client2$5, this), name),
|
|
1726
2106
|
tag: null
|
|
1727
2107
|
});
|
|
1728
2108
|
}
|
|
@@ -1733,9 +2113,9 @@ var _client$4 = /* @__PURE__ */ new WeakMap(), _httpRequest$5 = /* @__PURE__ */
|
|
|
1733
2113
|
* @param settings - Embeddings settings to apply
|
|
1734
2114
|
*/
|
|
1735
2115
|
editEmbeddingsSettings(name, settings) {
|
|
1736
|
-
return resourceGuard("dataset", _classPrivateFieldGet2(_client2$
|
|
2116
|
+
return resourceGuard("dataset", _classPrivateFieldGet2(_client2$5, this).config()), dataset(name), _request(_classPrivateFieldGet2(_client2$5, this), _classPrivateFieldGet2(_httpRequest2$6, this), {
|
|
1737
2117
|
method: "PUT",
|
|
1738
|
-
url: _embeddingsSettingsUri(_classPrivateFieldGet2(_client2$
|
|
2118
|
+
url: _embeddingsSettingsUri(_classPrivateFieldGet2(_client2$5, this), name),
|
|
1739
2119
|
body: settings,
|
|
1740
2120
|
tag: null
|
|
1741
2121
|
});
|
|
@@ -1761,7 +2141,101 @@ function _modify(client, httpRequest, method, name, options) {
|
|
|
1761
2141
|
tag: null
|
|
1762
2142
|
});
|
|
1763
2143
|
}
|
|
1764
|
-
|
|
2144
|
+
/** Function resource types in a blueprint are namespaced under this prefix. */
|
|
2145
|
+
const scopeHeaders = (config, request) => {
|
|
2146
|
+
let organizationId = request?.organizationId || config.organizationId;
|
|
2147
|
+
if (organizationId) return {
|
|
2148
|
+
"X-Sanity-Scope-Type": "organization",
|
|
2149
|
+
"X-Sanity-Scope-Id": organizationId
|
|
2150
|
+
};
|
|
2151
|
+
let { projectId } = config;
|
|
2152
|
+
if (!projectId) throw Error("`functions.invoke()` requires a `projectId` to be set in the client config, or an `organizationId` for a stack deployed at organization scope");
|
|
2153
|
+
return {
|
|
2154
|
+
"X-Sanity-Scope-Type": "project",
|
|
2155
|
+
"X-Sanity-Scope-Id": projectId
|
|
2156
|
+
};
|
|
2157
|
+
}, resolveStackId = (config, request) => {
|
|
2158
|
+
let stackId = request?.stackId || config.stackId;
|
|
2159
|
+
if (!stackId) throw Error("`functions.invoke()` requires a `stackId`, either in the client config or on the request. Function names are only unique within a stack.");
|
|
2160
|
+
return stackId;
|
|
2161
|
+
};
|
|
2162
|
+
/**
|
|
2163
|
+
* The invoke route is keyed by function id, but callers know functions by the
|
|
2164
|
+
* name declared in the blueprint. Names are unique within a stack, so the stack
|
|
2165
|
+
* both makes the name resolvable and confines the call to its own functions.
|
|
2166
|
+
*
|
|
2167
|
+
* @internal
|
|
2168
|
+
*/
|
|
2169
|
+
function _resolveFunctionId(client, httpRequest, functionName, stackId, headers, request) {
|
|
2170
|
+
return _requestObservable(client, httpRequest, {
|
|
2171
|
+
method: "GET",
|
|
2172
|
+
url: `/blueprints/stacks/${stackId}`,
|
|
2173
|
+
headers,
|
|
2174
|
+
signal: request?.signal
|
|
2175
|
+
}).pipe(map((stack) => {
|
|
2176
|
+
let match = (stack?.resources || []).find((resource) => resource.type?.startsWith("sanity.function.") && resource.name === functionName);
|
|
2177
|
+
if (!match) throw Error(`Function "${functionName}" not found in stack "${stackId}"`);
|
|
2178
|
+
if (!match.externalId) throw Error(`Function "${functionName}" is declared in stack "${stackId}" but is not deployed`);
|
|
2179
|
+
if (match.type !== "sanity.function.pubsub") throw Error(`Function invocation is not supported for ${match.type}`);
|
|
2180
|
+
return match.externalId;
|
|
2181
|
+
}));
|
|
2182
|
+
}
|
|
2183
|
+
/** @internal */
|
|
2184
|
+
function _invoke(client, httpRequest, functionName, request) {
|
|
2185
|
+
return defer(() => {
|
|
2186
|
+
let config = client.config(), headers = scopeHeaders(config, request);
|
|
2187
|
+
return _resolveFunctionId(client, httpRequest, functionName, resolveStackId(config, request), headers, request).pipe(mergeMap((functionId) => _requestObservable(client, httpRequest, {
|
|
2188
|
+
method: "POST",
|
|
2189
|
+
url: `/functions/${functionId}/invoke`,
|
|
2190
|
+
headers,
|
|
2191
|
+
body: { event: { data: request?.event?.data ?? {} } },
|
|
2192
|
+
timeout: request?.timeout,
|
|
2193
|
+
signal: request?.signal
|
|
2194
|
+
})));
|
|
2195
|
+
});
|
|
2196
|
+
}
|
|
2197
|
+
var _client$4 = /* @__PURE__ */ new WeakMap(), _httpRequest$5 = /* @__PURE__ */ new WeakMap(), ObservableFunctionsClient = class {
|
|
2198
|
+
constructor(client, httpRequest) {
|
|
2199
|
+
_classPrivateFieldInitSpec(this, _client$4, void 0), _classPrivateFieldInitSpec(this, _httpRequest$5, void 0), _classPrivateFieldSet2(_client$4, this, client), _classPrivateFieldSet2(_httpRequest$5, this, httpRequest);
|
|
2200
|
+
}
|
|
2201
|
+
/**
|
|
2202
|
+
* Invoke a deployed function by its blueprint name.
|
|
2203
|
+
*
|
|
2204
|
+
* The name is resolved within the stack given by `stackId` on the request or
|
|
2205
|
+
* the client config. Passes the function's return value once it finishes.
|
|
2206
|
+
*
|
|
2207
|
+
* @param functionName - name of the function, as declared in the blueprint
|
|
2208
|
+
* @param request - payload and request options
|
|
2209
|
+
*/
|
|
2210
|
+
invoke(functionName, request) {
|
|
2211
|
+
return _invoke(_classPrivateFieldGet2(_client$4, this), _classPrivateFieldGet2(_httpRequest$5, this), functionName, request);
|
|
2212
|
+
}
|
|
2213
|
+
}, _client2$4 = /* @__PURE__ */ new WeakMap(), _httpRequest2$5 = /* @__PURE__ */ new WeakMap(), FunctionsClient = class {
|
|
2214
|
+
constructor(client, httpRequest) {
|
|
2215
|
+
_classPrivateFieldInitSpec(this, _client2$4, void 0), _classPrivateFieldInitSpec(this, _httpRequest2$5, void 0), _classPrivateFieldSet2(_client2$4, this, client), _classPrivateFieldSet2(_httpRequest2$5, this, httpRequest);
|
|
2216
|
+
}
|
|
2217
|
+
/**
|
|
2218
|
+
* Invoke a deployed function by its blueprint name.
|
|
2219
|
+
*
|
|
2220
|
+
* The name is resolved within the stack given by `stackId` on the request or
|
|
2221
|
+
* the client config, which costs one extra request per call. Rejects if the
|
|
2222
|
+
* stack has no function by that name, or if the name resolves to anything
|
|
2223
|
+
* other than a `sanity.function.pubsub` function.
|
|
2224
|
+
*
|
|
2225
|
+
* The lookup is scoped to `projectId`, or to `organizationId` when one is set
|
|
2226
|
+
* for a stack deployed at organization scope.
|
|
2227
|
+
*
|
|
2228
|
+
* The request stays open until the function finishes, and resolves with its
|
|
2229
|
+
* return value, or `undefined` if it returns nothing. Long-running functions
|
|
2230
|
+
* may need an explicit `timeout`.
|
|
2231
|
+
*
|
|
2232
|
+
* @param functionName - name of the function, as declared in the blueprint
|
|
2233
|
+
* @param request - payload and request options
|
|
2234
|
+
*/
|
|
2235
|
+
invoke(functionName, request) {
|
|
2236
|
+
return lastValueFrom(_invoke(_classPrivateFieldGet2(_client2$4, this), _classPrivateFieldGet2(_httpRequest2$5, this), functionName, request));
|
|
2237
|
+
}
|
|
2238
|
+
}, _client$3 = /* @__PURE__ */ new WeakMap(), _httpRequest$4 = /* @__PURE__ */ new WeakMap(), ObservableMediaLibraryVideoClient = class {
|
|
1765
2239
|
constructor(client, httpRequest) {
|
|
1766
2240
|
_classPrivateFieldInitSpec(this, _client$3, void 0), _classPrivateFieldInitSpec(this, _httpRequest$4, void 0), _classPrivateFieldSet2(_client$3, this, client), _classPrivateFieldSet2(_httpRequest$4, this, httpRequest);
|
|
1767
2241
|
}
|
|
@@ -2393,14 +2867,14 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
|
|
|
2393
2867
|
}
|
|
2394
2868
|
}, _clientConfig = /* @__PURE__ */ new WeakMap(), _httpRequest = /* @__PURE__ */ new WeakMap(), ObservableSanityClient = class ObservableSanityClient {
|
|
2395
2869
|
constructor(httpRequest, config = defaultConfig) {
|
|
2396
|
-
_defineProperty(this, "assets", void 0), _defineProperty(this, "datasets", void 0), _defineProperty(this, "live", void 0), _defineProperty(this, "mediaLibrary", void 0), _defineProperty(this, "projects", void 0), _defineProperty(this, "users", void 0), _defineProperty(this, "agent", void 0), _defineProperty(this, "releases", void 0), _classPrivateFieldInitSpec(this, _clientConfig, void 0), _classPrivateFieldInitSpec(this, _httpRequest, void 0), _defineProperty(
|
|
2870
|
+
_defineProperty(this, "assets", void 0), _defineProperty(this, "datasets", void 0), _defineProperty(this, "live", void 0), _defineProperty(this, "mediaLibrary", void 0), _defineProperty(this, "projects", void 0), _defineProperty(this, "users", void 0), _defineProperty(this, "agent", void 0), _defineProperty(this, "collaboration", void 0), _defineProperty(this, "functions", void 0), _defineProperty(this, "releases", void 0), _classPrivateFieldInitSpec(this, _clientConfig, void 0), _classPrivateFieldInitSpec(this, _httpRequest, void 0), _defineProperty(
|
|
2397
2871
|
this,
|
|
2398
2872
|
/**
|
|
2399
2873
|
* Instance properties
|
|
2400
2874
|
*/
|
|
2401
2875
|
"listen",
|
|
2402
|
-
_listen
|
|
2403
|
-
), this.config(config), _classPrivateFieldSet2(_httpRequest, this, httpRequest), this.assets = new ObservableAssetsClient(this, _classPrivateFieldGet2(_httpRequest, this)), this.datasets = new ObservableDatasetsClient(this, _classPrivateFieldGet2(_httpRequest, this)), this.live = new LiveClient(this), this.mediaLibrary = { video: new ObservableMediaLibraryVideoClient(this, _classPrivateFieldGet2(_httpRequest, this)) }, this.projects = new ObservableProjectsClient(this, _classPrivateFieldGet2(_httpRequest, this)), this.users = new ObservableUsersClient(this, _classPrivateFieldGet2(_httpRequest, this)), this.agent = { action: new ObservableAgentsActionClient(this, _classPrivateFieldGet2(_httpRequest, this)) }, this.releases = new ObservableReleasesClient(this, _classPrivateFieldGet2(_httpRequest, this));
|
|
2876
|
+
_listen$1
|
|
2877
|
+
), this.config(config), _classPrivateFieldSet2(_httpRequest, this, httpRequest), this.assets = new ObservableAssetsClient(this, _classPrivateFieldGet2(_httpRequest, this)), this.datasets = new ObservableDatasetsClient(this, _classPrivateFieldGet2(_httpRequest, this)), this.live = new LiveClient(this), this.mediaLibrary = { video: new ObservableMediaLibraryVideoClient(this, _classPrivateFieldGet2(_httpRequest, this)) }, this.projects = new ObservableProjectsClient(this, _classPrivateFieldGet2(_httpRequest, this)), this.users = new ObservableUsersClient(this, _classPrivateFieldGet2(_httpRequest, this)), this.agent = { action: new ObservableAgentsActionClient(this, _classPrivateFieldGet2(_httpRequest, this)) }, this.collaboration = { comments: new ObservableCollaborationCommentsClient(this, _classPrivateFieldGet2(_httpRequest, this)) }, this.functions = new ObservableFunctionsClient(this, _classPrivateFieldGet2(_httpRequest, this)), this.releases = new ObservableReleasesClient(this, _classPrivateFieldGet2(_httpRequest, this));
|
|
2404
2878
|
}
|
|
2405
2879
|
/**
|
|
2406
2880
|
* Clone the client - returns a new instance
|
|
@@ -2617,7 +3091,7 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
|
|
|
2617
3091
|
}
|
|
2618
3092
|
}, _clientConfig2 = /* @__PURE__ */ new WeakMap(), _httpRequest2 = /* @__PURE__ */ new WeakMap(), SanityClient = class SanityClient {
|
|
2619
3093
|
constructor(httpRequest, config = defaultConfig) {
|
|
2620
|
-
_defineProperty(this, "assets", void 0), _defineProperty(this, "datasets", void 0), _defineProperty(this, "live", void 0), _defineProperty(this, "mediaLibrary", void 0), _defineProperty(this, "projects", void 0), _defineProperty(this, "users", void 0), _defineProperty(this, "agent", void 0), _defineProperty(this, "releases", void 0), _defineProperty(
|
|
3094
|
+
_defineProperty(this, "assets", void 0), _defineProperty(this, "datasets", void 0), _defineProperty(this, "live", void 0), _defineProperty(this, "mediaLibrary", void 0), _defineProperty(this, "projects", void 0), _defineProperty(this, "users", void 0), _defineProperty(this, "agent", void 0), _defineProperty(this, "collaboration", void 0), _defineProperty(this, "functions", void 0), _defineProperty(this, "releases", void 0), _defineProperty(
|
|
2621
3095
|
this,
|
|
2622
3096
|
/**
|
|
2623
3097
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
@@ -2630,8 +3104,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
|
|
|
2630
3104
|
* Instance properties
|
|
2631
3105
|
*/
|
|
2632
3106
|
"listen",
|
|
2633
|
-
_listen
|
|
2634
|
-
), this.config(config), _classPrivateFieldSet2(_httpRequest2, this, httpRequest), this.assets = new AssetsClient(this, _classPrivateFieldGet2(_httpRequest2, this)), this.datasets = new DatasetsClient(this, _classPrivateFieldGet2(_httpRequest2, this)), this.live = new LiveClient(this), this.mediaLibrary = { video: new MediaLibraryVideoClient(this, _classPrivateFieldGet2(_httpRequest2, this)) }, this.projects = new ProjectsClient(this, _classPrivateFieldGet2(_httpRequest2, this)), this.users = new UsersClient(this, _classPrivateFieldGet2(_httpRequest2, this)), this.agent = { action: new AgentActionsClient(this, _classPrivateFieldGet2(_httpRequest2, this)) }, this.releases = new ReleasesClient(this, _classPrivateFieldGet2(_httpRequest2, this)), this.observable = new ObservableSanityClient(httpRequest, config);
|
|
3107
|
+
_listen$1
|
|
3108
|
+
), this.config(config), _classPrivateFieldSet2(_httpRequest2, this, httpRequest), this.assets = new AssetsClient(this, _classPrivateFieldGet2(_httpRequest2, this)), this.datasets = new DatasetsClient(this, _classPrivateFieldGet2(_httpRequest2, this)), this.live = new LiveClient(this), this.mediaLibrary = { video: new MediaLibraryVideoClient(this, _classPrivateFieldGet2(_httpRequest2, this)) }, this.projects = new ProjectsClient(this, _classPrivateFieldGet2(_httpRequest2, this)), this.users = new UsersClient(this, _classPrivateFieldGet2(_httpRequest2, this)), this.agent = { action: new AgentActionsClient(this, _classPrivateFieldGet2(_httpRequest2, this)) }, this.collaboration = { comments: new CollaborationCommentsClient(this, _classPrivateFieldGet2(_httpRequest2, this)) }, this.functions = new FunctionsClient(this, _classPrivateFieldGet2(_httpRequest2, this)), this.releases = new ReleasesClient(this, _classPrivateFieldGet2(_httpRequest2, this)), this.observable = new ObservableSanityClient(httpRequest, config);
|
|
2635
3109
|
}
|
|
2636
3110
|
/**
|
|
2637
3111
|
* Clone the client - returns a new instance
|
|
@@ -2661,7 +3135,7 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
|
|
|
2661
3135
|
});
|
|
2662
3136
|
}
|
|
2663
3137
|
fetch(query, params, options) {
|
|
2664
|
-
return _fetch(this, _classPrivateFieldGet2(_httpRequest2, this), _classPrivateFieldGet2(_clientConfig2, this).stega, query, params, options);
|
|
3138
|
+
return _fetch$1(this, _classPrivateFieldGet2(_httpRequest2, this), _classPrivateFieldGet2(_clientConfig2, this).stega, query, params, options);
|
|
2665
3139
|
}
|
|
2666
3140
|
getDocument(id, options) {
|
|
2667
3141
|
if (options?.includeAllVersions === !0) return _getDocument(this, _classPrivateFieldGet2(_httpRequest2, this), id, {
|
|
@@ -2699,7 +3173,7 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
|
|
|
2699
3173
|
return _documentsExists(this, _classPrivateFieldGet2(_httpRequest2, this), ids, options);
|
|
2700
3174
|
}
|
|
2701
3175
|
create(document, options) {
|
|
2702
|
-
return _create(this, _classPrivateFieldGet2(_httpRequest2, this), document, "create", options);
|
|
3176
|
+
return _create$1(this, _classPrivateFieldGet2(_httpRequest2, this), document, "create", options);
|
|
2703
3177
|
}
|
|
2704
3178
|
createIfNotExists(document, options) {
|
|
2705
3179
|
return _createIfNotExists(this, _classPrivateFieldGet2(_httpRequest2, this), document, options);
|
|
@@ -2720,7 +3194,7 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
|
|
|
2720
3194
|
return _createVersion(this, _classPrivateFieldGet2(_httpRequest2, this), documentVersion, versionPublishedId, options);
|
|
2721
3195
|
}
|
|
2722
3196
|
delete(selection, options) {
|
|
2723
|
-
return _delete(this, _classPrivateFieldGet2(_httpRequest2, this), selection, options);
|
|
3197
|
+
return _delete$1(this, _classPrivateFieldGet2(_httpRequest2, this), selection, options);
|
|
2724
3198
|
}
|
|
2725
3199
|
/**
|
|
2726
3200
|
* @public
|
|
@@ -2873,10 +3347,10 @@ function defineCreateClientExports(envOptions, ClassConstructor) {
|
|
|
2873
3347
|
ignoreWarnings: config.ignoreWarnings,
|
|
2874
3348
|
maxRetries: config.maxRetries,
|
|
2875
3349
|
retryDelay: config.retryDelay
|
|
2876
|
-
}),
|
|
3350
|
+
}), performRequest = async (options) => (await clientRequesterPromise({
|
|
2877
3351
|
redirect: "manual",
|
|
2878
3352
|
...options
|
|
2879
|
-
})).body;
|
|
3353
|
+
})).body, httpRequest = (options, requestHandler) => requestHandler ? requestHandler(options, performRequest) : performRequest(options);
|
|
2880
3354
|
return new ClassConstructor(httpRequest, {
|
|
2881
3355
|
...config,
|
|
2882
3356
|
requester: clientRequester,
|
|
@@ -2894,6 +3368,6 @@ function defineDeprecatedCreateClient(createClient) {
|
|
|
2894
3368
|
};
|
|
2895
3369
|
}
|
|
2896
3370
|
const exp = defineCreateClientExports({ middleware: [] }, SanityClient), requester = exp.requester, createClient = exp.createClient, deprecatedCreateClient = defineDeprecatedCreateClient(createClient);
|
|
2897
|
-
export { BasePatch, BaseTransaction, ChannelError, ClientError, ConnectionFailedError, CorsOriginError, DisconnectError, EXPERIMENTAL_API_WARNING, MessageError, MessageParseError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, SanityClient, ServerError, Transaction, connectEventSource, createClient, deprecatedCreateClient as default, formatQueryParseError, isHttpError, isQueryParseError, requester, validateApiPerspective };
|
|
3371
|
+
export { BasePatch, BaseTransaction, ChannelError, ClientError, ConnectionFailedError, CorsOriginError, DisconnectError, EXPERIMENTAL_API_WARNING, MessageError, MessageParseError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, SanityClient, ServerError, Transaction, connectEventSource, createClient, deprecatedCreateClient as default, formatQueryParseError, isHttpError, isQueryParseError, isTimeoutError, requester, validateApiPerspective };
|
|
2898
3372
|
|
|
2899
3373
|
//# sourceMappingURL=index.js.map
|