@sanity/client 8.1.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 +171 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +408 -61
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +650 -2
- package/dist/index.node.js +379 -19
- package/dist/index.node.js.map +1 -1
- package/dist/media-library.d.ts +1 -1
- package/dist/{types-BODIEY7F.d.ts → types-nJhm5Nyq.d.ts} +651 -3
- package/package.json +1 -1
- package/src/SanityClient.ts +20 -0
- package/src/collaboration/CollaborationCommentsClient.ts +387 -0
- package/src/collaboration/comments.ts +313 -0
- package/src/collaboration/types.ts +252 -0
- package/src/data/dataMethods.ts +7 -1
- package/src/data/listen.ts +20 -5
- package/src/types.ts +234 -0
package/dist/index.js
CHANGED
|
@@ -338,41 +338,41 @@ var BasePatch = class {
|
|
|
338
338
|
_set(op, props) {
|
|
339
339
|
return this._assign(op, props, !1);
|
|
340
340
|
}
|
|
341
|
-
}, _client$
|
|
341
|
+
}, _client$11 = /* @__PURE__ */ new WeakMap(), ObservablePatch = class ObservablePatch extends BasePatch {
|
|
342
342
|
constructor(selection, operations, client) {
|
|
343
|
-
super(selection, operations), _classPrivateFieldInitSpec(this, _client$
|
|
343
|
+
super(selection, operations), _classPrivateFieldInitSpec(this, _client$11, void 0), _classPrivateFieldSet2(_client$11, this, client);
|
|
344
344
|
}
|
|
345
345
|
/**
|
|
346
346
|
* Clones the patch
|
|
347
347
|
*/
|
|
348
348
|
clone() {
|
|
349
|
-
return new ObservablePatch(this.selection, { ...this.operations }, _classPrivateFieldGet2(_client$
|
|
349
|
+
return new ObservablePatch(this.selection, { ...this.operations }, _classPrivateFieldGet2(_client$11, this));
|
|
350
350
|
}
|
|
351
351
|
commit(options) {
|
|
352
|
-
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");
|
|
353
353
|
let returnFirst = typeof this.selection == "string", opts = Object.assign({
|
|
354
354
|
returnFirst,
|
|
355
355
|
returnDocuments: !0
|
|
356
356
|
}, options);
|
|
357
|
-
return _classPrivateFieldGet2(_client$
|
|
357
|
+
return _classPrivateFieldGet2(_client$11, this).mutate({ patch: this.serialize() }, opts);
|
|
358
358
|
}
|
|
359
|
-
}, _client2$
|
|
359
|
+
}, _client2$10 = /* @__PURE__ */ new WeakMap(), Patch = class Patch extends BasePatch {
|
|
360
360
|
constructor(selection, operations, client) {
|
|
361
|
-
super(selection, operations), _classPrivateFieldInitSpec(this, _client2$
|
|
361
|
+
super(selection, operations), _classPrivateFieldInitSpec(this, _client2$10, void 0), _classPrivateFieldSet2(_client2$10, this, client);
|
|
362
362
|
}
|
|
363
363
|
/**
|
|
364
364
|
* Clones the patch
|
|
365
365
|
*/
|
|
366
366
|
clone() {
|
|
367
|
-
return new Patch(this.selection, { ...this.operations }, _classPrivateFieldGet2(_client2$
|
|
367
|
+
return new Patch(this.selection, { ...this.operations }, _classPrivateFieldGet2(_client2$10, this));
|
|
368
368
|
}
|
|
369
369
|
commit(options) {
|
|
370
|
-
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");
|
|
371
371
|
let returnFirst = typeof this.selection == "string", opts = Object.assign({
|
|
372
372
|
returnFirst,
|
|
373
373
|
returnDocuments: !0
|
|
374
374
|
}, options);
|
|
375
|
-
return _classPrivateFieldGet2(_client2$
|
|
375
|
+
return _classPrivateFieldGet2(_client2$10, this).mutate({ patch: this.serialize() }, opts);
|
|
376
376
|
}
|
|
377
377
|
};
|
|
378
378
|
const defaultMutateOptions = { returnDocuments: !1 };
|
|
@@ -443,30 +443,30 @@ var BaseTransaction = class {
|
|
|
443
443
|
_add(mut) {
|
|
444
444
|
return this.operations.push(mut), this;
|
|
445
445
|
}
|
|
446
|
-
}, _client$
|
|
446
|
+
}, _client$10 = /* @__PURE__ */ new WeakMap(), Transaction = class Transaction extends BaseTransaction {
|
|
447
447
|
constructor(operations, client, transactionId) {
|
|
448
|
-
super(operations, transactionId), _classPrivateFieldInitSpec(this, _client$
|
|
448
|
+
super(operations, transactionId), _classPrivateFieldInitSpec(this, _client$10, void 0), _classPrivateFieldSet2(_client$10, this, client);
|
|
449
449
|
}
|
|
450
450
|
/**
|
|
451
451
|
* Clones the transaction
|
|
452
452
|
*/
|
|
453
453
|
clone() {
|
|
454
|
-
return new Transaction([...this.operations], _classPrivateFieldGet2(_client$
|
|
454
|
+
return new Transaction([...this.operations], _classPrivateFieldGet2(_client$10, this), this.trxId);
|
|
455
455
|
}
|
|
456
456
|
commit(options) {
|
|
457
|
-
if (!_classPrivateFieldGet2(_client$
|
|
458
|
-
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 || {}));
|
|
459
459
|
}
|
|
460
460
|
patch(patchOrDocumentId, patchOps) {
|
|
461
461
|
let isBuilder = typeof patchOps == "function", isPatch = typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof Patch, isMutationSelection = typeof patchOrDocumentId == "object" && ("query" in patchOrDocumentId || "id" in patchOrDocumentId);
|
|
462
462
|
if (isPatch) return this._add({ patch: patchOrDocumentId.serialize() });
|
|
463
463
|
if (isBuilder) {
|
|
464
|
-
let patch = patchOps(new Patch(patchOrDocumentId, {}, _classPrivateFieldGet2(_client$
|
|
464
|
+
let patch = patchOps(new Patch(patchOrDocumentId, {}, _classPrivateFieldGet2(_client$10, this)));
|
|
465
465
|
if (!(patch instanceof Patch)) throw Error("function passed to `patch()` must return the patch");
|
|
466
466
|
return this._add({ patch: patch.serialize() });
|
|
467
467
|
}
|
|
468
468
|
if (isMutationSelection) {
|
|
469
|
-
let patch = new Patch(patchOrDocumentId, patchOps || {}, _classPrivateFieldGet2(_client$
|
|
469
|
+
let patch = new Patch(patchOrDocumentId, patchOps || {}, _classPrivateFieldGet2(_client$10, this));
|
|
470
470
|
return this._add({ patch: patch.serialize() });
|
|
471
471
|
}
|
|
472
472
|
return this._add({ patch: {
|
|
@@ -474,25 +474,25 @@ var BaseTransaction = class {
|
|
|
474
474
|
...patchOps
|
|
475
475
|
} });
|
|
476
476
|
}
|
|
477
|
-
}, _client2$
|
|
477
|
+
}, _client2$9 = /* @__PURE__ */ new WeakMap(), ObservableTransaction = class ObservableTransaction extends BaseTransaction {
|
|
478
478
|
constructor(operations, client, transactionId) {
|
|
479
|
-
super(operations, transactionId), _classPrivateFieldInitSpec(this, _client2$
|
|
479
|
+
super(operations, transactionId), _classPrivateFieldInitSpec(this, _client2$9, void 0), _classPrivateFieldSet2(_client2$9, this, client);
|
|
480
480
|
}
|
|
481
481
|
/**
|
|
482
482
|
* Clones the transaction
|
|
483
483
|
*/
|
|
484
484
|
clone() {
|
|
485
|
-
return new ObservableTransaction([...this.operations], _classPrivateFieldGet2(_client2$
|
|
485
|
+
return new ObservableTransaction([...this.operations], _classPrivateFieldGet2(_client2$9, this), this.trxId);
|
|
486
486
|
}
|
|
487
487
|
commit(options) {
|
|
488
|
-
if (!_classPrivateFieldGet2(_client2$
|
|
489
|
-
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 || {}));
|
|
490
490
|
}
|
|
491
491
|
patch(patchOrDocumentId, patchOps) {
|
|
492
492
|
let isBuilder = typeof patchOps == "function";
|
|
493
493
|
if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof ObservablePatch) return this._add({ patch: patchOrDocumentId.serialize() });
|
|
494
494
|
if (isBuilder) {
|
|
495
|
-
let patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, _classPrivateFieldGet2(_client2$
|
|
495
|
+
let patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, _classPrivateFieldGet2(_client2$9, this)));
|
|
496
496
|
if (!(patch instanceof ObservablePatch)) throw Error("function passed to `patch()` must return the patch");
|
|
497
497
|
return this._add({ patch: patch.serialize() });
|
|
498
498
|
}
|
|
@@ -604,7 +604,7 @@ function _fetchRequest(_stega, _params, options) {
|
|
|
604
604
|
}
|
|
605
605
|
/** @internal */
|
|
606
606
|
function _fetchObservable(client, httpRequest, _stega, query, _params = {}, options = {}) {
|
|
607
|
-
return _observe(options.signal, (signal) => _fetch(client, httpRequest, _stega, query, _params, {
|
|
607
|
+
return _observe(options.signal, (signal) => _fetch$1(client, httpRequest, _stega, query, _params, {
|
|
608
608
|
...options,
|
|
609
609
|
signal
|
|
610
610
|
}));
|
|
@@ -614,7 +614,7 @@ function _fetchObservable(client, httpRequest, _stega, query, _params = {}, opti
|
|
|
614
614
|
*
|
|
615
615
|
* @internal
|
|
616
616
|
*/
|
|
617
|
-
function _fetch(client, httpRequest, _stega, query, _params = {}, options = {}) {
|
|
617
|
+
function _fetch$1(client, httpRequest, _stega, query, _params = {}, options = {}) {
|
|
618
618
|
let { stega, params, mapResponse, reqOpts } = _fetchRequest(_stega, _params, options), request = _dataRequest(client, httpRequest, "query", {
|
|
619
619
|
query,
|
|
620
620
|
params
|
|
@@ -767,7 +767,7 @@ function _createVersionFromBaseObservable(client, httpRequest, publishedId, base
|
|
|
767
767
|
}
|
|
768
768
|
/** @internal */
|
|
769
769
|
function _deleteObservable(client, httpRequest, selection, options) {
|
|
770
|
-
return _observe(options?.signal, (signal) => _delete(client, httpRequest, selection, {
|
|
770
|
+
return _observe(options?.signal, (signal) => _delete$1(client, httpRequest, selection, {
|
|
771
771
|
...options,
|
|
772
772
|
signal
|
|
773
773
|
}));
|
|
@@ -872,7 +872,7 @@ function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
|
|
|
872
872
|
* @internal
|
|
873
873
|
*/
|
|
874
874
|
function _createObservable(client, httpRequest, doc, op, options = {}) {
|
|
875
|
-
return _observe(options.signal, (signal) => _create(client, httpRequest, doc, op, {
|
|
875
|
+
return _observe(options.signal, (signal) => _create$1(client, httpRequest, doc, op, {
|
|
876
876
|
...options,
|
|
877
877
|
signal
|
|
878
878
|
}));
|
|
@@ -882,7 +882,7 @@ function _createObservable(client, httpRequest, doc, op, options = {}) {
|
|
|
882
882
|
*
|
|
883
883
|
* @internal
|
|
884
884
|
*/
|
|
885
|
-
function _create(client, httpRequest, doc, op, options = {}) {
|
|
885
|
+
function _create$1(client, httpRequest, doc, op, options = {}) {
|
|
886
886
|
let mutation = { [op]: doc }, opts = Object.assign({
|
|
887
887
|
returnFirst: !0,
|
|
888
888
|
returnDocuments: !0
|
|
@@ -919,7 +919,7 @@ function _mutate(client, httpRequest, mutations, options) {
|
|
|
919
919
|
*
|
|
920
920
|
* @internal
|
|
921
921
|
*/
|
|
922
|
-
function _delete(client, httpRequest, selection, options) {
|
|
922
|
+
function _delete$1(client, httpRequest, selection, options) {
|
|
923
923
|
return _dataRequest(client, httpRequest, "mutate", { mutations: [{ delete: getSelection(selection) }] }, options);
|
|
924
924
|
}
|
|
925
925
|
/**
|
|
@@ -928,7 +928,7 @@ function _delete(client, httpRequest, selection, options) {
|
|
|
928
928
|
* @internal
|
|
929
929
|
*/
|
|
930
930
|
function _createIfNotExists(client, httpRequest, doc, options) {
|
|
931
|
-
return requireDocumentId("createIfNotExists", doc), _create(client, httpRequest, doc, "createIfNotExists", options);
|
|
931
|
+
return requireDocumentId("createIfNotExists", doc), _create$1(client, httpRequest, doc, "createIfNotExists", options);
|
|
932
932
|
}
|
|
933
933
|
/**
|
|
934
934
|
* Promise-based sibling of {@link _createOrReplaceObservable}.
|
|
@@ -936,7 +936,7 @@ function _createIfNotExists(client, httpRequest, doc, options) {
|
|
|
936
936
|
* @internal
|
|
937
937
|
*/
|
|
938
938
|
function _createOrReplace(client, httpRequest, doc, options) {
|
|
939
|
-
return requireDocumentId("createOrReplace", doc), _create(client, httpRequest, doc, "createOrReplace", options);
|
|
939
|
+
return requireDocumentId("createOrReplace", doc), _create$1(client, httpRequest, doc, "createOrReplace", options);
|
|
940
940
|
}
|
|
941
941
|
/**
|
|
942
942
|
* Promise-based sibling of {@link _createVersionObservable}.
|
|
@@ -1240,62 +1240,62 @@ function _translate(client, httpRequest, request) {
|
|
|
1240
1240
|
body: request
|
|
1241
1241
|
});
|
|
1242
1242
|
}
|
|
1243
|
-
var _client$
|
|
1243
|
+
var _client$9 = /* @__PURE__ */ new WeakMap(), _httpRequest$8 = /* @__PURE__ */ new WeakMap(), ObservableAgentsActionClient = class {
|
|
1244
1244
|
constructor(client, httpRequest) {
|
|
1245
|
-
_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);
|
|
1246
1246
|
}
|
|
1247
1247
|
/**
|
|
1248
1248
|
* Run an instruction to generate content in a target document.
|
|
1249
1249
|
* @param request - instruction request
|
|
1250
1250
|
*/
|
|
1251
1251
|
generate(request) {
|
|
1252
|
-
return _generateObservable(_classPrivateFieldGet2(_client$
|
|
1252
|
+
return _generateObservable(_classPrivateFieldGet2(_client$9, this), _classPrivateFieldGet2(_httpRequest$8, this), request);
|
|
1253
1253
|
}
|
|
1254
1254
|
/**
|
|
1255
1255
|
* Transform a target document based on a source.
|
|
1256
1256
|
* @param request - translation request
|
|
1257
1257
|
*/
|
|
1258
1258
|
transform(request) {
|
|
1259
|
-
return _transformObservable(_classPrivateFieldGet2(_client$
|
|
1259
|
+
return _transformObservable(_classPrivateFieldGet2(_client$9, this), _classPrivateFieldGet2(_httpRequest$8, this), request);
|
|
1260
1260
|
}
|
|
1261
1261
|
/**
|
|
1262
1262
|
* Translate a target document based on a source.
|
|
1263
1263
|
* @param request - translation request
|
|
1264
1264
|
*/
|
|
1265
1265
|
translate(request) {
|
|
1266
|
-
return _translateObservable(_classPrivateFieldGet2(_client$
|
|
1266
|
+
return _translateObservable(_classPrivateFieldGet2(_client$9, this), _classPrivateFieldGet2(_httpRequest$8, this), request);
|
|
1267
1267
|
}
|
|
1268
|
-
}, _client2$
|
|
1268
|
+
}, _client2$8 = /* @__PURE__ */ new WeakMap(), _httpRequest2$9 = /* @__PURE__ */ new WeakMap(), AgentActionsClient = class {
|
|
1269
1269
|
constructor(client, httpRequest) {
|
|
1270
|
-
_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);
|
|
1271
1271
|
}
|
|
1272
1272
|
/**
|
|
1273
1273
|
* Run an instruction to generate content in a target document.
|
|
1274
1274
|
* @param request - instruction request
|
|
1275
1275
|
*/
|
|
1276
1276
|
generate(request) {
|
|
1277
|
-
return _generate(_classPrivateFieldGet2(_client2$
|
|
1277
|
+
return _generate(_classPrivateFieldGet2(_client2$8, this), _classPrivateFieldGet2(_httpRequest2$9, this), request);
|
|
1278
1278
|
}
|
|
1279
1279
|
/**
|
|
1280
1280
|
* Transform a target document based on a source.
|
|
1281
1281
|
* @param request - translation request
|
|
1282
1282
|
*/
|
|
1283
1283
|
transform(request) {
|
|
1284
|
-
return _transform(_classPrivateFieldGet2(_client2$
|
|
1284
|
+
return _transform(_classPrivateFieldGet2(_client2$8, this), _classPrivateFieldGet2(_httpRequest2$9, this), request);
|
|
1285
1285
|
}
|
|
1286
1286
|
/**
|
|
1287
1287
|
* Translate a target document based on a source.
|
|
1288
1288
|
* @param request - translation request
|
|
1289
1289
|
*/
|
|
1290
1290
|
translate(request) {
|
|
1291
|
-
return _translate(_classPrivateFieldGet2(_client2$
|
|
1291
|
+
return _translate(_classPrivateFieldGet2(_client2$8, this), _classPrivateFieldGet2(_httpRequest2$9, this), request);
|
|
1292
1292
|
}
|
|
1293
1293
|
/**
|
|
1294
1294
|
* Run a raw instruction and return the result either as text or json
|
|
1295
1295
|
* @param request - prompt request
|
|
1296
1296
|
*/
|
|
1297
1297
|
prompt(request) {
|
|
1298
|
-
return _prompt(_classPrivateFieldGet2(_client2$
|
|
1298
|
+
return _prompt(_classPrivateFieldGet2(_client2$8, this), _classPrivateFieldGet2(_httpRequest2$9, this), request);
|
|
1299
1299
|
}
|
|
1300
1300
|
/**
|
|
1301
1301
|
* Patch a document using a schema aware API.
|
|
@@ -1303,21 +1303,21 @@ var _client$8 = /* @__PURE__ */ new WeakMap(), _httpRequest$7 = /* @__PURE__ */
|
|
|
1303
1303
|
* @param request - instruction request
|
|
1304
1304
|
*/
|
|
1305
1305
|
patch(request) {
|
|
1306
|
-
return _patch(_classPrivateFieldGet2(_client2$
|
|
1306
|
+
return _patch(_classPrivateFieldGet2(_client2$8, this), _classPrivateFieldGet2(_httpRequest2$9, this), request);
|
|
1307
1307
|
}
|
|
1308
|
-
}, _client$
|
|
1308
|
+
}, _client$8 = /* @__PURE__ */ new WeakMap(), _httpRequest2$8 = /* @__PURE__ */ new WeakMap(), ObservableAssetsClient = class {
|
|
1309
1309
|
constructor(client, httpRequest) {
|
|
1310
|
-
_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);
|
|
1311
1311
|
}
|
|
1312
1312
|
upload(assetType, body, options) {
|
|
1313
|
-
return _upload(_classPrivateFieldGet2(_client$
|
|
1313
|
+
return _upload(_classPrivateFieldGet2(_client$8, this), _classPrivateFieldGet2(_httpRequest2$8, this), assetType, body, options);
|
|
1314
1314
|
}
|
|
1315
|
-
}, _client2$
|
|
1315
|
+
}, _client2$7 = /* @__PURE__ */ new WeakMap(), _httpRequest3 = /* @__PURE__ */ new WeakMap(), AssetsClient = class {
|
|
1316
1316
|
constructor(client, httpRequest) {
|
|
1317
|
-
_classPrivateFieldInitSpec(this, _client2$
|
|
1317
|
+
_classPrivateFieldInitSpec(this, _client2$7, void 0), _classPrivateFieldInitSpec(this, _httpRequest3, void 0), _classPrivateFieldSet2(_client2$7, this, client), _classPrivateFieldSet2(_httpRequest3, this, httpRequest);
|
|
1318
1318
|
}
|
|
1319
1319
|
upload(assetType, body, options) {
|
|
1320
|
-
let observable = _upload(_classPrivateFieldGet2(_client2$
|
|
1320
|
+
let observable = _upload(_classPrivateFieldGet2(_client2$7, this), _classPrivateFieldGet2(_httpRequest3, this), assetType, body, options);
|
|
1321
1321
|
return lastValueFrom(observable.pipe(filter((event) => event.type === "response"), map$1((event) => pluckUploadedAsset(event.body))));
|
|
1322
1322
|
}
|
|
1323
1323
|
};
|
|
@@ -1458,6 +1458,7 @@ function resolveEventSourceFetch(config, options = {}) {
|
|
|
1458
1458
|
function pickBaseFetch(config) {
|
|
1459
1459
|
return config.resolveFetch ? config.resolveFetch(typeof config.proxy == "string" ? config.proxy : void 0) : globalThis.fetch.bind(globalThis);
|
|
1460
1460
|
}
|
|
1461
|
+
/** @internal */
|
|
1461
1462
|
const possibleOptions = [
|
|
1462
1463
|
"includePreviousRevision",
|
|
1463
1464
|
"includeResult",
|
|
@@ -1469,8 +1470,8 @@ const possibleOptions = [
|
|
|
1469
1470
|
"tag"
|
|
1470
1471
|
], defaultOptions = { includeResult: !0 };
|
|
1471
1472
|
/** @public */
|
|
1472
|
-
function _listen(query, params, opts = {}) {
|
|
1473
|
-
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 = {
|
|
1474
1475
|
...defaults_default(opts, defaultOptions),
|
|
1475
1476
|
tag
|
|
1476
1477
|
}, listenOpts = pick(options, possibleOptions), qs = encodeQueryString({
|
|
@@ -1482,7 +1483,12 @@ function _listen(query, params, opts = {}) {
|
|
|
1482
1483
|
}
|
|
1483
1484
|
}), uri = `${url}${_getDataUrl(this, "listen", qs)}`;
|
|
1484
1485
|
if (uri.length > 14800) return throwError(() => /* @__PURE__ */ Error("Query too large for listener"));
|
|
1485
|
-
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 = {};
|
|
1486
1492
|
token && (headers.Authorization = `Bearer ${token}`), configHeaders && Object.assign(headers, configHeaders);
|
|
1487
1493
|
let initEventSource = () => new EventSource(uri, { fetch: resolveEventSourceFetch(config, {
|
|
1488
1494
|
headers: Object.keys(headers).length ? headers : void 0,
|
|
@@ -1493,6 +1499,347 @@ function _listen(query, params, opts = {}) {
|
|
|
1493
1499
|
..."data" in event ? event.data : {}
|
|
1494
1500
|
})));
|
|
1495
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
|
+
};
|
|
1496
1843
|
/**
|
|
1497
1844
|
* A variant of share that takes a predicate function to determine which value to replay to new subscribers
|
|
1498
1845
|
* @param configOrPredicate - Predicate function to determine which value to replay
|
|
@@ -2520,14 +2867,14 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
|
|
|
2520
2867
|
}
|
|
2521
2868
|
}, _clientConfig = /* @__PURE__ */ new WeakMap(), _httpRequest = /* @__PURE__ */ new WeakMap(), ObservableSanityClient = class ObservableSanityClient {
|
|
2522
2869
|
constructor(httpRequest, config = defaultConfig) {
|
|
2523
|
-
_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, "functions", 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(
|
|
2524
2871
|
this,
|
|
2525
2872
|
/**
|
|
2526
2873
|
* Instance properties
|
|
2527
2874
|
*/
|
|
2528
2875
|
"listen",
|
|
2529
|
-
_listen
|
|
2530
|
-
), 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.functions = new ObservableFunctionsClient(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));
|
|
2531
2878
|
}
|
|
2532
2879
|
/**
|
|
2533
2880
|
* Clone the client - returns a new instance
|
|
@@ -2744,7 +3091,7 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
|
|
|
2744
3091
|
}
|
|
2745
3092
|
}, _clientConfig2 = /* @__PURE__ */ new WeakMap(), _httpRequest2 = /* @__PURE__ */ new WeakMap(), SanityClient = class SanityClient {
|
|
2746
3093
|
constructor(httpRequest, config = defaultConfig) {
|
|
2747
|
-
_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, "functions", 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(
|
|
2748
3095
|
this,
|
|
2749
3096
|
/**
|
|
2750
3097
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
@@ -2757,8 +3104,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
|
|
|
2757
3104
|
* Instance properties
|
|
2758
3105
|
*/
|
|
2759
3106
|
"listen",
|
|
2760
|
-
_listen
|
|
2761
|
-
), 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.functions = new FunctionsClient(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);
|
|
2762
3109
|
}
|
|
2763
3110
|
/**
|
|
2764
3111
|
* Clone the client - returns a new instance
|
|
@@ -2788,7 +3135,7 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
|
|
|
2788
3135
|
});
|
|
2789
3136
|
}
|
|
2790
3137
|
fetch(query, params, options) {
|
|
2791
|
-
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);
|
|
2792
3139
|
}
|
|
2793
3140
|
getDocument(id, options) {
|
|
2794
3141
|
if (options?.includeAllVersions === !0) return _getDocument(this, _classPrivateFieldGet2(_httpRequest2, this), id, {
|
|
@@ -2826,7 +3173,7 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
|
|
|
2826
3173
|
return _documentsExists(this, _classPrivateFieldGet2(_httpRequest2, this), ids, options);
|
|
2827
3174
|
}
|
|
2828
3175
|
create(document, options) {
|
|
2829
|
-
return _create(this, _classPrivateFieldGet2(_httpRequest2, this), document, "create", options);
|
|
3176
|
+
return _create$1(this, _classPrivateFieldGet2(_httpRequest2, this), document, "create", options);
|
|
2830
3177
|
}
|
|
2831
3178
|
createIfNotExists(document, options) {
|
|
2832
3179
|
return _createIfNotExists(this, _classPrivateFieldGet2(_httpRequest2, this), document, options);
|
|
@@ -2847,7 +3194,7 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
|
|
|
2847
3194
|
return _createVersion(this, _classPrivateFieldGet2(_httpRequest2, this), documentVersion, versionPublishedId, options);
|
|
2848
3195
|
}
|
|
2849
3196
|
delete(selection, options) {
|
|
2850
|
-
return _delete(this, _classPrivateFieldGet2(_httpRequest2, this), selection, options);
|
|
3197
|
+
return _delete$1(this, _classPrivateFieldGet2(_httpRequest2, this), selection, options);
|
|
2851
3198
|
}
|
|
2852
3199
|
/**
|
|
2853
3200
|
* @public
|