@sanity/client 8.3.0 → 8.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{browserUpload-2tz6Sdqp.js → browserUpload-C7PwCs-C.js} +6 -9
- package/dist/browserUpload-C7PwCs-C.js.map +1 -0
- package/dist/{browserUpload-CwpNx7Vl.js → browserUpload-D-2Rmfjo.js} +6 -9
- package/dist/browserUpload-D-2Rmfjo.js.map +1 -0
- package/dist/{config-3wiPP-sZ.js → config-CgJ16jET.js} +4 -2
- package/dist/config-CgJ16jET.js.map +1 -0
- package/dist/csm.js +1 -1
- package/dist/{dist-C9ExSk2R.js → dist-C5K_YcEU.js} +3 -2
- package/dist/{dist-C9ExSk2R.js.map → dist-C5K_YcEU.js.map} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +912 -75
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +3255 -2
- package/dist/index.node.js +835 -19
- package/dist/index.node.js.map +1 -1
- package/dist/media-library.d.ts +1 -1
- package/dist/rolldown-runtime-4YWMqDIC.js +9 -0
- package/dist/{stegaEncodeSourceMap-DbM2fTN4.js → stegaEncodeSourceMap-CO1HKnm2.js} +2 -2
- package/dist/{stegaEncodeSourceMap-DbM2fTN4.js.map → stegaEncodeSourceMap-CO1HKnm2.js.map} +1 -1
- package/dist/{types-0x2hPfhJ.d.ts → types-DiPF0ENT.d.ts} +3256 -3
- package/package.json +3 -2
- package/src/SanityClient.ts +7 -0
- package/src/assets/AssetsClient.ts +5 -0
- package/src/config.ts +1 -0
- package/src/context/ContextClient.ts +1006 -0
- package/src/context/openapi.json +5345 -0
- package/src/context/reads.ts +206 -0
- package/src/context/store.ts +100 -0
- package/src/context/types.gen.ts +2428 -0
- package/src/context/types.ts +228 -0
- package/src/data/dataMethods.ts +4 -1
- package/src/defineCreateClient.ts +1 -0
- package/src/http/browserUpload.ts +0 -12
- package/src/types.ts +23 -2
- package/src/validators.ts +1 -0
- package/dist/browserUpload-2tz6Sdqp.js.map +0 -1
- package/dist/browserUpload-CwpNx7Vl.js.map +0 -1
- package/dist/config-3wiPP-sZ.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-vyAXikos.js";
|
|
1
2
|
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
3
|
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-
|
|
4
|
+
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-CgJ16jET.js";
|
|
4
5
|
import { t as stegaClean } from "./stegaClean-C18wLWau.js";
|
|
5
6
|
import { isTimeoutError } from "get-it";
|
|
6
7
|
import { Observable, catchError, concat, defer, finalize, isObservable, lastValueFrom, map, merge, mergeMap, of, share, tap, throwError, timer } from "rxjs";
|
|
@@ -337,41 +338,41 @@ var BasePatch = class {
|
|
|
337
338
|
_set(op, props) {
|
|
338
339
|
return this._assign(op, props, !1);
|
|
339
340
|
}
|
|
340
|
-
}, _client$
|
|
341
|
+
}, _client$12 = /* @__PURE__ */ new WeakMap(), ObservablePatch = class ObservablePatch extends BasePatch {
|
|
341
342
|
constructor(selection, operations, client) {
|
|
342
|
-
super(selection, operations), _classPrivateFieldInitSpec(this, _client$
|
|
343
|
+
super(selection, operations), _classPrivateFieldInitSpec(this, _client$12, void 0), _classPrivateFieldSet2(_client$12, this, client);
|
|
343
344
|
}
|
|
344
345
|
/**
|
|
345
346
|
* Clones the patch
|
|
346
347
|
*/
|
|
347
348
|
clone() {
|
|
348
|
-
return new ObservablePatch(this.selection, { ...this.operations }, _classPrivateFieldGet2(_client$
|
|
349
|
+
return new ObservablePatch(this.selection, { ...this.operations }, _classPrivateFieldGet2(_client$12, this));
|
|
349
350
|
}
|
|
350
351
|
commit(options) {
|
|
351
|
-
if (!_classPrivateFieldGet2(_client$
|
|
352
|
+
if (!_classPrivateFieldGet2(_client$12, this)) throw Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
352
353
|
let returnFirst = typeof this.selection == "string", opts = Object.assign({
|
|
353
354
|
returnFirst,
|
|
354
355
|
returnDocuments: !0
|
|
355
356
|
}, options);
|
|
356
|
-
return _classPrivateFieldGet2(_client$
|
|
357
|
+
return _classPrivateFieldGet2(_client$12, this).mutate({ patch: this.serialize() }, opts);
|
|
357
358
|
}
|
|
358
|
-
}, _client2$
|
|
359
|
+
}, _client2$11 = /* @__PURE__ */ new WeakMap(), Patch = class Patch extends BasePatch {
|
|
359
360
|
constructor(selection, operations, client) {
|
|
360
|
-
super(selection, operations), _classPrivateFieldInitSpec(this, _client2$
|
|
361
|
+
super(selection, operations), _classPrivateFieldInitSpec(this, _client2$11, void 0), _classPrivateFieldSet2(_client2$11, this, client);
|
|
361
362
|
}
|
|
362
363
|
/**
|
|
363
364
|
* Clones the patch
|
|
364
365
|
*/
|
|
365
366
|
clone() {
|
|
366
|
-
return new Patch(this.selection, { ...this.operations }, _classPrivateFieldGet2(_client2$
|
|
367
|
+
return new Patch(this.selection, { ...this.operations }, _classPrivateFieldGet2(_client2$11, this));
|
|
367
368
|
}
|
|
368
369
|
commit(options) {
|
|
369
|
-
if (!_classPrivateFieldGet2(_client2$
|
|
370
|
+
if (!_classPrivateFieldGet2(_client2$11, this)) throw Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
370
371
|
let returnFirst = typeof this.selection == "string", opts = Object.assign({
|
|
371
372
|
returnFirst,
|
|
372
373
|
returnDocuments: !0
|
|
373
374
|
}, options);
|
|
374
|
-
return _classPrivateFieldGet2(_client2$
|
|
375
|
+
return _classPrivateFieldGet2(_client2$11, this).mutate({ patch: this.serialize() }, opts);
|
|
375
376
|
}
|
|
376
377
|
};
|
|
377
378
|
const defaultMutateOptions = { returnDocuments: !1 };
|
|
@@ -442,30 +443,30 @@ var BaseTransaction = class {
|
|
|
442
443
|
_add(mut) {
|
|
443
444
|
return this.operations.push(mut), this;
|
|
444
445
|
}
|
|
445
|
-
}, _client$
|
|
446
|
+
}, _client$11 = /* @__PURE__ */ new WeakMap(), Transaction = class Transaction extends BaseTransaction {
|
|
446
447
|
constructor(operations, client, transactionId) {
|
|
447
|
-
super(operations, transactionId), _classPrivateFieldInitSpec(this, _client$
|
|
448
|
+
super(operations, transactionId), _classPrivateFieldInitSpec(this, _client$11, void 0), _classPrivateFieldSet2(_client$11, this, client);
|
|
448
449
|
}
|
|
449
450
|
/**
|
|
450
451
|
* Clones the transaction
|
|
451
452
|
*/
|
|
452
453
|
clone() {
|
|
453
|
-
return new Transaction([...this.operations], _classPrivateFieldGet2(_client$
|
|
454
|
+
return new Transaction([...this.operations], _classPrivateFieldGet2(_client$11, this), this.trxId);
|
|
454
455
|
}
|
|
455
456
|
commit(options) {
|
|
456
|
-
if (!_classPrivateFieldGet2(_client$
|
|
457
|
-
return _classPrivateFieldGet2(_client$
|
|
457
|
+
if (!_classPrivateFieldGet2(_client$11, this)) throw Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
458
|
+
return _classPrivateFieldGet2(_client$11, this).mutate(this.serialize(), Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {}));
|
|
458
459
|
}
|
|
459
460
|
patch(patchOrDocumentId, patchOps) {
|
|
460
461
|
let isBuilder = typeof patchOps == "function", isPatch = typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof Patch, isMutationSelection = typeof patchOrDocumentId == "object" && ("query" in patchOrDocumentId || "id" in patchOrDocumentId);
|
|
461
462
|
if (isPatch) return this._add({ patch: patchOrDocumentId.serialize() });
|
|
462
463
|
if (isBuilder) {
|
|
463
|
-
let patch = patchOps(new Patch(patchOrDocumentId, {}, _classPrivateFieldGet2(_client$
|
|
464
|
+
let patch = patchOps(new Patch(patchOrDocumentId, {}, _classPrivateFieldGet2(_client$11, this)));
|
|
464
465
|
if (!(patch instanceof Patch)) throw Error("function passed to `patch()` must return the patch");
|
|
465
466
|
return this._add({ patch: patch.serialize() });
|
|
466
467
|
}
|
|
467
468
|
if (isMutationSelection) {
|
|
468
|
-
let patch = new Patch(patchOrDocumentId, patchOps || {}, _classPrivateFieldGet2(_client$
|
|
469
|
+
let patch = new Patch(patchOrDocumentId, patchOps || {}, _classPrivateFieldGet2(_client$11, this));
|
|
469
470
|
return this._add({ patch: patch.serialize() });
|
|
470
471
|
}
|
|
471
472
|
return this._add({ patch: {
|
|
@@ -473,25 +474,25 @@ var BaseTransaction = class {
|
|
|
473
474
|
...patchOps
|
|
474
475
|
} });
|
|
475
476
|
}
|
|
476
|
-
}, _client2$
|
|
477
|
+
}, _client2$10 = /* @__PURE__ */ new WeakMap(), ObservableTransaction = class ObservableTransaction extends BaseTransaction {
|
|
477
478
|
constructor(operations, client, transactionId) {
|
|
478
|
-
super(operations, transactionId), _classPrivateFieldInitSpec(this, _client2$
|
|
479
|
+
super(operations, transactionId), _classPrivateFieldInitSpec(this, _client2$10, void 0), _classPrivateFieldSet2(_client2$10, this, client);
|
|
479
480
|
}
|
|
480
481
|
/**
|
|
481
482
|
* Clones the transaction
|
|
482
483
|
*/
|
|
483
484
|
clone() {
|
|
484
|
-
return new ObservableTransaction([...this.operations], _classPrivateFieldGet2(_client2$
|
|
485
|
+
return new ObservableTransaction([...this.operations], _classPrivateFieldGet2(_client2$10, this), this.trxId);
|
|
485
486
|
}
|
|
486
487
|
commit(options) {
|
|
487
|
-
if (!_classPrivateFieldGet2(_client2$
|
|
488
|
-
return _classPrivateFieldGet2(_client2$
|
|
488
|
+
if (!_classPrivateFieldGet2(_client2$10, this)) throw Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
489
|
+
return _classPrivateFieldGet2(_client2$10, this).mutate(this.serialize(), Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {}));
|
|
489
490
|
}
|
|
490
491
|
patch(patchOrDocumentId, patchOps) {
|
|
491
492
|
let isBuilder = typeof patchOps == "function";
|
|
492
493
|
if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof ObservablePatch) return this._add({ patch: patchOrDocumentId.serialize() });
|
|
493
494
|
if (isBuilder) {
|
|
494
|
-
let patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, _classPrivateFieldGet2(_client2$
|
|
495
|
+
let patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, _classPrivateFieldGet2(_client2$10, this)));
|
|
495
496
|
if (!(patch instanceof ObservablePatch)) throw Error("function passed to `patch()` must return the patch");
|
|
496
497
|
return this._add({ patch: patch.serialize() });
|
|
497
498
|
}
|
|
@@ -500,7 +501,15 @@ var BaseTransaction = class {
|
|
|
500
501
|
...patchOps
|
|
501
502
|
} });
|
|
502
503
|
}
|
|
503
|
-
};
|
|
504
|
+
}, types_exports = /* @__PURE__ */ __exportAll({ possibleStoreRequestOptions: () => possibleStoreRequestOptions });
|
|
505
|
+
/** @internal */
|
|
506
|
+
const possibleStoreRequestOptions = [
|
|
507
|
+
"headers",
|
|
508
|
+
"signal",
|
|
509
|
+
"tag",
|
|
510
|
+
"timeout",
|
|
511
|
+
"token"
|
|
512
|
+
];
|
|
504
513
|
/**
|
|
505
514
|
* Project the public request options (`timeout: 0` to disable,
|
|
506
515
|
* `withCredentials`, `maxRedirects`, the function/object-form `fetch`, ...)
|
|
@@ -603,7 +612,7 @@ function _fetchRequest(_stega, _params, options) {
|
|
|
603
612
|
}
|
|
604
613
|
/** @internal */
|
|
605
614
|
function _fetchObservable(client, httpRequest, _stega, query, _params = {}, options = {}) {
|
|
606
|
-
return _observe(options.signal, (signal) => _fetch$
|
|
615
|
+
return _observe(options.signal, (signal) => _fetch$2(client, httpRequest, _stega, query, _params, {
|
|
607
616
|
...options,
|
|
608
617
|
signal
|
|
609
618
|
}));
|
|
@@ -613,7 +622,7 @@ function _fetchObservable(client, httpRequest, _stega, query, _params = {}, opti
|
|
|
613
622
|
*
|
|
614
623
|
* @internal
|
|
615
624
|
*/
|
|
616
|
-
function _fetch$
|
|
625
|
+
function _fetch$2(client, httpRequest, _stega, query, _params = {}, options = {}) {
|
|
617
626
|
let { stega, params, mapResponse, reqOpts } = _fetchRequest(_stega, _params, options), request = _dataRequest(client, httpRequest, "query", {
|
|
618
627
|
query,
|
|
619
628
|
params
|
|
@@ -1175,6 +1184,7 @@ const resourceDataBase = (config) => {
|
|
|
1175
1184
|
return `/projects/${segments[0]}/datasets/${segments[1]}`;
|
|
1176
1185
|
}
|
|
1177
1186
|
case "canvas": return `/canvases/${id}`;
|
|
1187
|
+
case "knowledge-base": return `/knowledge-bases/${id}`;
|
|
1178
1188
|
case "media-library": return `/media-libraries/${id}`;
|
|
1179
1189
|
case "dashboard": return `/dashboards/${id}`;
|
|
1180
1190
|
default: throw Error(`Unsupported resource type: ${type.toString()}`);
|
|
@@ -1239,62 +1249,62 @@ function _translate(client, httpRequest, request) {
|
|
|
1239
1249
|
body: request
|
|
1240
1250
|
});
|
|
1241
1251
|
}
|
|
1242
|
-
var _client$
|
|
1252
|
+
var _client$10 = /* @__PURE__ */ new WeakMap(), _httpRequest$9 = /* @__PURE__ */ new WeakMap(), ObservableAgentsActionClient = class {
|
|
1243
1253
|
constructor(client, httpRequest) {
|
|
1244
|
-
_classPrivateFieldInitSpec(this, _client$
|
|
1254
|
+
_classPrivateFieldInitSpec(this, _client$10, void 0), _classPrivateFieldInitSpec(this, _httpRequest$9, void 0), _classPrivateFieldSet2(_client$10, this, client), _classPrivateFieldSet2(_httpRequest$9, this, httpRequest);
|
|
1245
1255
|
}
|
|
1246
1256
|
/**
|
|
1247
1257
|
* Run an instruction to generate content in a target document.
|
|
1248
1258
|
* @param request - instruction request
|
|
1249
1259
|
*/
|
|
1250
1260
|
generate(request) {
|
|
1251
|
-
return _generateObservable(_classPrivateFieldGet2(_client$
|
|
1261
|
+
return _generateObservable(_classPrivateFieldGet2(_client$10, this), _classPrivateFieldGet2(_httpRequest$9, this), request);
|
|
1252
1262
|
}
|
|
1253
1263
|
/**
|
|
1254
1264
|
* Transform a target document based on a source.
|
|
1255
1265
|
* @param request - translation request
|
|
1256
1266
|
*/
|
|
1257
1267
|
transform(request) {
|
|
1258
|
-
return _transformObservable(_classPrivateFieldGet2(_client$
|
|
1268
|
+
return _transformObservable(_classPrivateFieldGet2(_client$10, this), _classPrivateFieldGet2(_httpRequest$9, this), request);
|
|
1259
1269
|
}
|
|
1260
1270
|
/**
|
|
1261
1271
|
* Translate a target document based on a source.
|
|
1262
1272
|
* @param request - translation request
|
|
1263
1273
|
*/
|
|
1264
1274
|
translate(request) {
|
|
1265
|
-
return _translateObservable(_classPrivateFieldGet2(_client$
|
|
1275
|
+
return _translateObservable(_classPrivateFieldGet2(_client$10, this), _classPrivateFieldGet2(_httpRequest$9, this), request);
|
|
1266
1276
|
}
|
|
1267
|
-
}, _client2$
|
|
1277
|
+
}, _client2$9 = /* @__PURE__ */ new WeakMap(), _httpRequest2$10 = /* @__PURE__ */ new WeakMap(), AgentActionsClient = class {
|
|
1268
1278
|
constructor(client, httpRequest) {
|
|
1269
|
-
_classPrivateFieldInitSpec(this, _client2$
|
|
1279
|
+
_classPrivateFieldInitSpec(this, _client2$9, void 0), _classPrivateFieldInitSpec(this, _httpRequest2$10, void 0), _classPrivateFieldSet2(_client2$9, this, client), _classPrivateFieldSet2(_httpRequest2$10, this, httpRequest);
|
|
1270
1280
|
}
|
|
1271
1281
|
/**
|
|
1272
1282
|
* Run an instruction to generate content in a target document.
|
|
1273
1283
|
* @param request - instruction request
|
|
1274
1284
|
*/
|
|
1275
1285
|
generate(request) {
|
|
1276
|
-
return _generate(_classPrivateFieldGet2(_client2$
|
|
1286
|
+
return _generate(_classPrivateFieldGet2(_client2$9, this), _classPrivateFieldGet2(_httpRequest2$10, this), request);
|
|
1277
1287
|
}
|
|
1278
1288
|
/**
|
|
1279
1289
|
* Transform a target document based on a source.
|
|
1280
1290
|
* @param request - translation request
|
|
1281
1291
|
*/
|
|
1282
1292
|
transform(request) {
|
|
1283
|
-
return _transform(_classPrivateFieldGet2(_client2$
|
|
1293
|
+
return _transform(_classPrivateFieldGet2(_client2$9, this), _classPrivateFieldGet2(_httpRequest2$10, this), request);
|
|
1284
1294
|
}
|
|
1285
1295
|
/**
|
|
1286
1296
|
* Translate a target document based on a source.
|
|
1287
1297
|
* @param request - translation request
|
|
1288
1298
|
*/
|
|
1289
1299
|
translate(request) {
|
|
1290
|
-
return _translate(_classPrivateFieldGet2(_client2$
|
|
1300
|
+
return _translate(_classPrivateFieldGet2(_client2$9, this), _classPrivateFieldGet2(_httpRequest2$10, this), request);
|
|
1291
1301
|
}
|
|
1292
1302
|
/**
|
|
1293
1303
|
* Run a raw instruction and return the result either as text or json
|
|
1294
1304
|
* @param request - prompt request
|
|
1295
1305
|
*/
|
|
1296
1306
|
prompt(request) {
|
|
1297
|
-
return _prompt(_classPrivateFieldGet2(_client2$
|
|
1307
|
+
return _prompt(_classPrivateFieldGet2(_client2$9, this), _classPrivateFieldGet2(_httpRequest2$10, this), request);
|
|
1298
1308
|
}
|
|
1299
1309
|
/**
|
|
1300
1310
|
* Patch a document using a schema aware API.
|
|
@@ -1302,21 +1312,21 @@ var _client$9 = /* @__PURE__ */ new WeakMap(), _httpRequest$8 = /* @__PURE__ */
|
|
|
1302
1312
|
* @param request - instruction request
|
|
1303
1313
|
*/
|
|
1304
1314
|
patch(request) {
|
|
1305
|
-
return _patch(_classPrivateFieldGet2(_client2$
|
|
1315
|
+
return _patch(_classPrivateFieldGet2(_client2$9, this), _classPrivateFieldGet2(_httpRequest2$10, this), request);
|
|
1306
1316
|
}
|
|
1307
|
-
}, _client$
|
|
1317
|
+
}, _client$9 = /* @__PURE__ */ new WeakMap(), _httpRequest2$9 = /* @__PURE__ */ new WeakMap(), ObservableAssetsClient = class {
|
|
1308
1318
|
constructor(client, httpRequest) {
|
|
1309
|
-
_classPrivateFieldInitSpec(this, _client$
|
|
1319
|
+
_classPrivateFieldInitSpec(this, _client$9, void 0), _classPrivateFieldInitSpec(this, _httpRequest2$9, void 0), _classPrivateFieldSet2(_client$9, this, client), _classPrivateFieldSet2(_httpRequest2$9, this, httpRequest);
|
|
1310
1320
|
}
|
|
1311
1321
|
upload(assetType, body, options) {
|
|
1312
|
-
return _upload(_classPrivateFieldGet2(_client$
|
|
1322
|
+
return _upload(_classPrivateFieldGet2(_client$9, this), _classPrivateFieldGet2(_httpRequest2$9, this), assetType, body, options);
|
|
1313
1323
|
}
|
|
1314
|
-
}, _client2$
|
|
1324
|
+
}, _client2$8 = /* @__PURE__ */ new WeakMap(), _httpRequest3 = /* @__PURE__ */ new WeakMap(), AssetsClient = class {
|
|
1315
1325
|
constructor(client, httpRequest) {
|
|
1316
|
-
_classPrivateFieldInitSpec(this, _client2$
|
|
1326
|
+
_classPrivateFieldInitSpec(this, _client2$8, void 0), _classPrivateFieldInitSpec(this, _httpRequest3, void 0), _classPrivateFieldSet2(_client2$8, this, client), _classPrivateFieldSet2(_httpRequest3, this, httpRequest);
|
|
1317
1327
|
}
|
|
1318
1328
|
upload(assetType, body, options) {
|
|
1319
|
-
let observable = _upload(_classPrivateFieldGet2(_client2$
|
|
1329
|
+
let observable = _upload(_classPrivateFieldGet2(_client2$8, this), _classPrivateFieldGet2(_httpRequest3, this), assetType, body, options);
|
|
1320
1330
|
return lastValueFrom(observable.pipe(filter((event) => event.type === "response"), map$1((event) => pluckUploadedAsset(event.body))));
|
|
1321
1331
|
}
|
|
1322
1332
|
};
|
|
@@ -1359,7 +1369,7 @@ function _upload(client, _httpRequest, assetType, body, opts = {}) {
|
|
|
1359
1369
|
body
|
|
1360
1370
|
};
|
|
1361
1371
|
return typeof XMLHttpRequest < "u" ? defer(async () => {
|
|
1362
|
-
let { uploadWithProgress } = await import("./browserUpload-
|
|
1372
|
+
let { uploadWithProgress } = await import("./browserUpload-D-2Rmfjo.js"), req = _prepareRequest(client, { ...baseRequest });
|
|
1363
1373
|
return uploadWithProgress({
|
|
1364
1374
|
url: appendQuery(req.url, req.query),
|
|
1365
1375
|
method: req.method ?? "POST",
|
|
@@ -1383,6 +1393,7 @@ function buildAssetUploadUrl(config, assetType) {
|
|
|
1383
1393
|
switch (type) {
|
|
1384
1394
|
case "dataset": throw Error("Assets are not supported for dataset resources, yet. Configure the client with `{projectId: <projectId>, dataset: <datasetId>}` instead.");
|
|
1385
1395
|
case "canvas": return `/canvases/${id}/assets/${assetTypeEndpoint}`;
|
|
1396
|
+
case "knowledge-base": throw Error("Assets are not supported for knowledge-base resources. Use `client.context.imports` to add content instead.");
|
|
1386
1397
|
case "media-library": return `/media-libraries/${id}/upload`;
|
|
1387
1398
|
case "dashboard": return `/dashboards/${id}/assets/${assetTypeEndpoint}`;
|
|
1388
1399
|
default: throw Error(`Unsupported resource type: ${type.toString()}`);
|
|
@@ -1469,7 +1480,7 @@ const possibleOptions = [
|
|
|
1469
1480
|
"tag"
|
|
1470
1481
|
], defaultOptions = { includeResult: !0 };
|
|
1471
1482
|
/** @public */
|
|
1472
|
-
function _listen$
|
|
1483
|
+
function _listen$2(query, params, opts = {}) {
|
|
1473
1484
|
let { url, requestTagPrefix } = this.config(), tag = opts.tag && requestTagPrefix ? [requestTagPrefix, opts.tag].join(".") : opts.tag, options = {
|
|
1474
1485
|
...defaults_default(opts, defaultOptions),
|
|
1475
1486
|
tag
|
|
@@ -1588,7 +1599,7 @@ function _removeReaction(client, httpRequest, id, shortName, options) {
|
|
|
1588
1599
|
return writeDocument(id, client, httpRequest, "DELETE", `${commentUrl(id)}/reactions/${encodeURIComponent(shortName)}`, void 0, options);
|
|
1589
1600
|
}
|
|
1590
1601
|
/** @internal */
|
|
1591
|
-
function _fetch(client, httpRequest, query, params, options) {
|
|
1602
|
+
function _fetch$1(client, httpRequest, query, params, options) {
|
|
1592
1603
|
let search = resourceQuery(client);
|
|
1593
1604
|
return _requestObservable(client, httpRequest, {
|
|
1594
1605
|
...encodeQueryString({
|
|
@@ -1614,7 +1625,7 @@ function _fetch(client, httpRequest, query, params, options) {
|
|
|
1614
1625
|
}).pipe(map$1((response) => response.result));
|
|
1615
1626
|
}
|
|
1616
1627
|
/** @internal */
|
|
1617
|
-
function _listen(client, query, params, options) {
|
|
1628
|
+
function _listen$1(client, query, params, options) {
|
|
1618
1629
|
let opts = options ?? {}, { requestTagPrefix } = client.config(), tag = opts.tag && requestTagPrefix ? [requestTagPrefix, opts.tag].join(".") : opts.tag, listenOpts = pick({
|
|
1619
1630
|
...defaults_default(opts, defaultOptions),
|
|
1620
1631
|
tag
|
|
@@ -1628,9 +1639,9 @@ function _listen(client, query, params, options) {
|
|
|
1628
1639
|
}), uri = `${client.getUrl("/collaboration/comments/listen")}${qs}`;
|
|
1629
1640
|
return uri.length > 14800 ? throwError(() => /* @__PURE__ */ Error("Query too large for listener")) : _connectListenEventSource(client, uri, opts.events ? opts.events : ["mutation"]);
|
|
1630
1641
|
}
|
|
1631
|
-
var _client$
|
|
1642
|
+
var _client$8 = /* @__PURE__ */ new WeakMap(), _httpRequest$8 = /* @__PURE__ */ new WeakMap(), ObservableCollaborationCommentsClient = class {
|
|
1632
1643
|
constructor(client, httpRequest) {
|
|
1633
|
-
_classPrivateFieldInitSpec(this, _client$
|
|
1644
|
+
_classPrivateFieldInitSpec(this, _client$8, void 0), _classPrivateFieldInitSpec(this, _httpRequest$8, void 0), _classPrivateFieldSet2(_client$8, this, client), _classPrivateFieldSet2(_httpRequest$8, this, httpRequest);
|
|
1634
1645
|
}
|
|
1635
1646
|
/**
|
|
1636
1647
|
* Create a comment or reply on the configured resource.
|
|
@@ -1643,7 +1654,7 @@ var _client$7 = /* @__PURE__ */ new WeakMap(), _httpRequest$7 = /* @__PURE__ */
|
|
|
1643
1654
|
* @returns The created comment
|
|
1644
1655
|
*/
|
|
1645
1656
|
create(body, options) {
|
|
1646
|
-
return _create(_classPrivateFieldGet2(_client$
|
|
1657
|
+
return _create(_classPrivateFieldGet2(_client$8, this), _classPrivateFieldGet2(_httpRequest$8, this), body, options);
|
|
1647
1658
|
}
|
|
1648
1659
|
/**
|
|
1649
1660
|
* Update an existing comment.
|
|
@@ -1656,7 +1667,7 @@ var _client$7 = /* @__PURE__ */ new WeakMap(), _httpRequest$7 = /* @__PURE__ */
|
|
|
1656
1667
|
* @returns The updated comment
|
|
1657
1668
|
*/
|
|
1658
1669
|
update(id, body, options) {
|
|
1659
|
-
return _update(_classPrivateFieldGet2(_client$
|
|
1670
|
+
return _update(_classPrivateFieldGet2(_client$8, this), _classPrivateFieldGet2(_httpRequest$8, this), id, body, options);
|
|
1660
1671
|
}
|
|
1661
1672
|
/**
|
|
1662
1673
|
* Delete a comment and its replies.
|
|
@@ -1666,7 +1677,7 @@ var _client$7 = /* @__PURE__ */ new WeakMap(), _httpRequest$7 = /* @__PURE__ */
|
|
|
1666
1677
|
* @returns Mutation result, where `documentIds` covers the comment and every deleted reply
|
|
1667
1678
|
*/
|
|
1668
1679
|
delete(id, options) {
|
|
1669
|
-
return _delete(_classPrivateFieldGet2(_client$
|
|
1680
|
+
return _delete(_classPrivateFieldGet2(_client$8, this), _classPrivateFieldGet2(_httpRequest$8, this), id, options);
|
|
1670
1681
|
}
|
|
1671
1682
|
/**
|
|
1672
1683
|
* Add the current user's reaction to a comment.
|
|
@@ -1677,7 +1688,7 @@ var _client$7 = /* @__PURE__ */ new WeakMap(), _httpRequest$7 = /* @__PURE__ */
|
|
|
1677
1688
|
* @returns The comment, with the reaction applied
|
|
1678
1689
|
*/
|
|
1679
1690
|
addReaction(id, shortName, options) {
|
|
1680
|
-
return _addReaction(_classPrivateFieldGet2(_client$
|
|
1691
|
+
return _addReaction(_classPrivateFieldGet2(_client$8, this), _classPrivateFieldGet2(_httpRequest$8, this), id, shortName, options);
|
|
1681
1692
|
}
|
|
1682
1693
|
/**
|
|
1683
1694
|
* Remove the current user's reaction from a comment.
|
|
@@ -1688,7 +1699,7 @@ var _client$7 = /* @__PURE__ */ new WeakMap(), _httpRequest$7 = /* @__PURE__ */
|
|
|
1688
1699
|
* @returns The comment, with the reaction removed
|
|
1689
1700
|
*/
|
|
1690
1701
|
removeReaction(id, shortName, options) {
|
|
1691
|
-
return _removeReaction(_classPrivateFieldGet2(_client$
|
|
1702
|
+
return _removeReaction(_classPrivateFieldGet2(_client$8, this), _classPrivateFieldGet2(_httpRequest$8, this), id, shortName, options);
|
|
1692
1703
|
}
|
|
1693
1704
|
/**
|
|
1694
1705
|
* Build the global document reference used by `target.document._ref`, for use in
|
|
@@ -1709,7 +1720,7 @@ var _client$7 = /* @__PURE__ */ new WeakMap(), _httpRequest$7 = /* @__PURE__ */
|
|
|
1709
1720
|
* @returns Global document reference, of the form `resourceType:resourceId:documentId`
|
|
1710
1721
|
*/
|
|
1711
1722
|
getTargetDocumentRef(documentId) {
|
|
1712
|
-
return _getTargetDocumentRef(_classPrivateFieldGet2(_client$
|
|
1723
|
+
return _getTargetDocumentRef(_classPrivateFieldGet2(_client$8, this), documentId);
|
|
1713
1724
|
}
|
|
1714
1725
|
/**
|
|
1715
1726
|
* Fetch comments on the configured resource.
|
|
@@ -1728,14 +1739,14 @@ var _client$7 = /* @__PURE__ */ new WeakMap(), _httpRequest$7 = /* @__PURE__ */
|
|
|
1728
1739
|
* @param options - Optional request options
|
|
1729
1740
|
*/
|
|
1730
1741
|
fetch(query, params, options) {
|
|
1731
|
-
return _fetch(_classPrivateFieldGet2(_client$
|
|
1742
|
+
return _fetch$1(_classPrivateFieldGet2(_client$8, this), _classPrivateFieldGet2(_httpRequest$8, this), query, params, options);
|
|
1732
1743
|
}
|
|
1733
1744
|
listen(query, params, options) {
|
|
1734
|
-
return _listen(_classPrivateFieldGet2(_client$
|
|
1745
|
+
return _listen$1(_classPrivateFieldGet2(_client$8, this), query, params, options);
|
|
1735
1746
|
}
|
|
1736
|
-
}, _client2$
|
|
1747
|
+
}, _client2$7 = /* @__PURE__ */ new WeakMap(), _httpRequest2$8 = /* @__PURE__ */ new WeakMap(), CollaborationCommentsClient = class {
|
|
1737
1748
|
constructor(client, httpRequest) {
|
|
1738
|
-
_classPrivateFieldInitSpec(this, _client2$
|
|
1749
|
+
_classPrivateFieldInitSpec(this, _client2$7, void 0), _classPrivateFieldInitSpec(this, _httpRequest2$8, void 0), _classPrivateFieldSet2(_client2$7, this, client), _classPrivateFieldSet2(_httpRequest2$8, this, httpRequest);
|
|
1739
1750
|
}
|
|
1740
1751
|
/**
|
|
1741
1752
|
* Create a comment or reply on the configured resource.
|
|
@@ -1748,7 +1759,7 @@ var _client$7 = /* @__PURE__ */ new WeakMap(), _httpRequest$7 = /* @__PURE__ */
|
|
|
1748
1759
|
* @returns The created comment
|
|
1749
1760
|
*/
|
|
1750
1761
|
create(body, options) {
|
|
1751
|
-
return lastValueFrom(_create(_classPrivateFieldGet2(_client2$
|
|
1762
|
+
return lastValueFrom(_create(_classPrivateFieldGet2(_client2$7, this), _classPrivateFieldGet2(_httpRequest2$8, this), body, options));
|
|
1752
1763
|
}
|
|
1753
1764
|
/**
|
|
1754
1765
|
* Update an existing comment.
|
|
@@ -1761,7 +1772,7 @@ var _client$7 = /* @__PURE__ */ new WeakMap(), _httpRequest$7 = /* @__PURE__ */
|
|
|
1761
1772
|
* @returns The updated comment
|
|
1762
1773
|
*/
|
|
1763
1774
|
update(id, body, options) {
|
|
1764
|
-
return lastValueFrom(_update(_classPrivateFieldGet2(_client2$
|
|
1775
|
+
return lastValueFrom(_update(_classPrivateFieldGet2(_client2$7, this), _classPrivateFieldGet2(_httpRequest2$8, this), id, body, options));
|
|
1765
1776
|
}
|
|
1766
1777
|
/**
|
|
1767
1778
|
* Delete a comment and its replies.
|
|
@@ -1771,7 +1782,7 @@ var _client$7 = /* @__PURE__ */ new WeakMap(), _httpRequest$7 = /* @__PURE__ */
|
|
|
1771
1782
|
* @returns Mutation result, where `documentIds` covers the comment and every deleted reply
|
|
1772
1783
|
*/
|
|
1773
1784
|
delete(id, options) {
|
|
1774
|
-
return lastValueFrom(_delete(_classPrivateFieldGet2(_client2$
|
|
1785
|
+
return lastValueFrom(_delete(_classPrivateFieldGet2(_client2$7, this), _classPrivateFieldGet2(_httpRequest2$8, this), id, options));
|
|
1775
1786
|
}
|
|
1776
1787
|
/**
|
|
1777
1788
|
* Add the current user's reaction to a comment.
|
|
@@ -1782,7 +1793,7 @@ var _client$7 = /* @__PURE__ */ new WeakMap(), _httpRequest$7 = /* @__PURE__ */
|
|
|
1782
1793
|
* @returns The comment, with the reaction applied
|
|
1783
1794
|
*/
|
|
1784
1795
|
addReaction(id, shortName, options) {
|
|
1785
|
-
return lastValueFrom(_addReaction(_classPrivateFieldGet2(_client2$
|
|
1796
|
+
return lastValueFrom(_addReaction(_classPrivateFieldGet2(_client2$7, this), _classPrivateFieldGet2(_httpRequest2$8, this), id, shortName, options));
|
|
1786
1797
|
}
|
|
1787
1798
|
/**
|
|
1788
1799
|
* Remove the current user's reaction from a comment.
|
|
@@ -1793,7 +1804,7 @@ var _client$7 = /* @__PURE__ */ new WeakMap(), _httpRequest$7 = /* @__PURE__ */
|
|
|
1793
1804
|
* @returns The comment, with the reaction removed
|
|
1794
1805
|
*/
|
|
1795
1806
|
removeReaction(id, shortName, options) {
|
|
1796
|
-
return lastValueFrom(_removeReaction(_classPrivateFieldGet2(_client2$
|
|
1807
|
+
return lastValueFrom(_removeReaction(_classPrivateFieldGet2(_client2$7, this), _classPrivateFieldGet2(_httpRequest2$8, this), id, shortName, options));
|
|
1797
1808
|
}
|
|
1798
1809
|
/**
|
|
1799
1810
|
* Build the global document reference used by `target.document._ref`, for use in
|
|
@@ -1814,7 +1825,7 @@ var _client$7 = /* @__PURE__ */ new WeakMap(), _httpRequest$7 = /* @__PURE__ */
|
|
|
1814
1825
|
* @returns Global document reference, of the form `resourceType:resourceId:documentId`
|
|
1815
1826
|
*/
|
|
1816
1827
|
getTargetDocumentRef(documentId) {
|
|
1817
|
-
return _getTargetDocumentRef(_classPrivateFieldGet2(_client2$
|
|
1828
|
+
return _getTargetDocumentRef(_classPrivateFieldGet2(_client2$7, this), documentId);
|
|
1818
1829
|
}
|
|
1819
1830
|
/**
|
|
1820
1831
|
* Fetch comments on the configured resource.
|
|
@@ -1833,8 +1844,824 @@ var _client$7 = /* @__PURE__ */ new WeakMap(), _httpRequest$7 = /* @__PURE__ */
|
|
|
1833
1844
|
* @param options - Optional request options
|
|
1834
1845
|
*/
|
|
1835
1846
|
fetch(query, params, options) {
|
|
1836
|
-
return lastValueFrom(_fetch(_classPrivateFieldGet2(_client2$
|
|
1847
|
+
return lastValueFrom(_fetch$1(_classPrivateFieldGet2(_client2$7, this), _classPrivateFieldGet2(_httpRequest2$8, this), query, params, options));
|
|
1848
|
+
}
|
|
1849
|
+
listen(query, params, options) {
|
|
1850
|
+
return _listen$1(_classPrivateFieldGet2(_client2$7, this), query, params, options);
|
|
1851
|
+
}
|
|
1852
|
+
};
|
|
1853
|
+
/** @internal */
|
|
1854
|
+
function _organizationId(client) {
|
|
1855
|
+
let organizationId = client.config().context?.organizationId;
|
|
1856
|
+
if (!organizationId) throw Error("`context.organizationId` must be configured to query Context documents");
|
|
1857
|
+
return organizationId;
|
|
1858
|
+
}
|
|
1859
|
+
function storeUrl(client, suffix) {
|
|
1860
|
+
return `/context/organizations/${encodeURIComponent(_organizationId(client))}/${suffix}`;
|
|
1861
|
+
}
|
|
1862
|
+
/** @internal */
|
|
1863
|
+
function _fetch(client, httpRequest, query, params, options) {
|
|
1864
|
+
let url = storeUrl(client, "query");
|
|
1865
|
+
return _requestObservable(client, httpRequest, {
|
|
1866
|
+
...encodeQueryString({
|
|
1867
|
+
query,
|
|
1868
|
+
params
|
|
1869
|
+
}).length < 11264 ? {
|
|
1870
|
+
method: "GET",
|
|
1871
|
+
url: `${url}${encodeQueryString({
|
|
1872
|
+
query,
|
|
1873
|
+
params
|
|
1874
|
+
})}`
|
|
1875
|
+
} : {
|
|
1876
|
+
method: "POST",
|
|
1877
|
+
url,
|
|
1878
|
+
body: {
|
|
1879
|
+
query,
|
|
1880
|
+
params: params ?? {}
|
|
1881
|
+
}
|
|
1882
|
+
},
|
|
1883
|
+
...pick(options || {}, possibleStoreRequestOptions)
|
|
1884
|
+
}).pipe(map$1((response) => response.result));
|
|
1885
|
+
}
|
|
1886
|
+
/** @internal */
|
|
1887
|
+
function _listen(client, query, params, options) {
|
|
1888
|
+
let opts = options ?? {}, { requestTagPrefix } = client.config(), tag = opts.tag && requestTagPrefix ? [requestTagPrefix, opts.tag].join(".") : opts.tag, listenOpts = pick({
|
|
1889
|
+
...defaults_default(opts, defaultOptions),
|
|
1890
|
+
tag
|
|
1891
|
+
}, possibleOptions), qs = encodeQueryString({
|
|
1892
|
+
query,
|
|
1893
|
+
params,
|
|
1894
|
+
options: listenOpts
|
|
1895
|
+
}), uri = `${client.getUrl(storeUrl(client, "listen"))}${qs}`;
|
|
1896
|
+
return uri.length > 14800 ? throwError(() => /* @__PURE__ */ Error("Query too large for listener")) : _connectListenEventSource(client, uri, opts.events ? opts.events : ["mutation"]);
|
|
1897
|
+
}
|
|
1898
|
+
const ENTRY_TYPE = "sanity.context.entry", ISSUE_TYPE = "sanity.context.issue", MCP_TYPE = "sanity.context.mcp";
|
|
1899
|
+
function _one(client, httpRequest, query, params, options) {
|
|
1900
|
+
return lastValueFrom(_fetch(client, httpRequest, query, params, options));
|
|
1901
|
+
}
|
|
1902
|
+
/**
|
|
1903
|
+
* Drain every page of a `(_createdAt, _id)`-keyset read. Termination keys on
|
|
1904
|
+
* the raw page length before anything looks at the rows: a short page means
|
|
1905
|
+
* the store had nothing more to give, and filtering must never shorten a
|
|
1906
|
+
* full page into a false stop.
|
|
1907
|
+
*/
|
|
1908
|
+
async function _drainByCreatedAt(client, httpRequest, filter, params, options) {
|
|
1909
|
+
let all = [], cursor;
|
|
1910
|
+
for (;;) {
|
|
1911
|
+
let query = `*[${cursor ? `${filter} && (_createdAt > \$c || (_createdAt == \$c && _id > \$i))` : filter}] | order(_createdAt asc, _id asc) [0...200]`, page = await lastValueFrom(_fetch(client, httpRequest, query, cursor ? {
|
|
1912
|
+
...params,
|
|
1913
|
+
...cursor
|
|
1914
|
+
} : params, options));
|
|
1915
|
+
if (all.push(...page), page.length < 200) return all;
|
|
1916
|
+
let last = page[page.length - 1];
|
|
1917
|
+
cursor = {
|
|
1918
|
+
c: last._createdAt,
|
|
1919
|
+
i: last._id
|
|
1920
|
+
};
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
/** @internal */
|
|
1924
|
+
function _readEntry(client, httpRequest, knowledgeBaseId, path, options) {
|
|
1925
|
+
return _one(client, httpRequest, `*[_type == "${ENTRY_TYPE}" && knowledgeBaseId == $kb && path == $path][0]`, {
|
|
1926
|
+
kb: knowledgeBaseId,
|
|
1927
|
+
path
|
|
1928
|
+
}, options);
|
|
1929
|
+
}
|
|
1930
|
+
/** @internal */
|
|
1931
|
+
async function _listEntries(client, httpRequest, knowledgeBaseId, options) {
|
|
1932
|
+
let all = [], after = "";
|
|
1933
|
+
for (;;) {
|
|
1934
|
+
let page = await lastValueFrom(_fetch(client, httpRequest, `*[_type == "${ENTRY_TYPE}" && knowledgeBaseId == $kb && path > $after] | order(path asc) [0...200] {_id, path, title, tldr, status}`, {
|
|
1935
|
+
kb: knowledgeBaseId,
|
|
1936
|
+
after
|
|
1937
|
+
}, options));
|
|
1938
|
+
if (all.push(...page), page.length < 200) return all;
|
|
1939
|
+
after = page[page.length - 1].path;
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
/** @internal */
|
|
1943
|
+
function _listIssues(client, httpRequest, knowledgeBaseId, status, options) {
|
|
1944
|
+
return _drainByCreatedAt(client, httpRequest, `_type == "${ISSUE_TYPE}" && knowledgeBaseId == $kb${status === void 0 ? "" : " && status == $status"}`, status === void 0 ? { kb: knowledgeBaseId } : {
|
|
1945
|
+
kb: knowledgeBaseId,
|
|
1946
|
+
status
|
|
1947
|
+
}, options);
|
|
1948
|
+
}
|
|
1949
|
+
/** @internal */
|
|
1950
|
+
function _readIssue(client, httpRequest, knowledgeBaseId, issueId, options) {
|
|
1951
|
+
return _one(client, httpRequest, `*[_type == "${ISSUE_TYPE}" && knowledgeBaseId == $kb && _id == $id][0]`, {
|
|
1952
|
+
kb: knowledgeBaseId,
|
|
1953
|
+
id: issueId
|
|
1954
|
+
}, options);
|
|
1955
|
+
}
|
|
1956
|
+
/** @internal */
|
|
1957
|
+
function _listInstructions(client, httpRequest, knowledgeBaseId, options) {
|
|
1958
|
+
return _drainByCreatedAt(client, httpRequest, "_type == \"sanity.context.instruction\" && knowledgeBaseId == $kb && schemaVersion == 1", { kb: knowledgeBaseId }, options);
|
|
1959
|
+
}
|
|
1960
|
+
/** @internal */
|
|
1961
|
+
function _listMcpEndpoints(client, httpRequest, options) {
|
|
1962
|
+
return lastValueFrom(_fetch(client, httpRequest, `*[_type == "${MCP_TYPE}" && organizationId == $org] | order(_createdAt asc, _id asc) [0...500]`, { org: _organizationId(client) }, options));
|
|
1963
|
+
}
|
|
1964
|
+
/** @internal */
|
|
1965
|
+
function _readMcpEndpoint(client, httpRequest, name, options) {
|
|
1966
|
+
return _one(client, httpRequest, `*[_type == "${MCP_TYPE}" && organizationId == $org && name == $name][0]`, {
|
|
1967
|
+
org: _organizationId(client),
|
|
1968
|
+
name
|
|
1969
|
+
}, options);
|
|
1970
|
+
}
|
|
1971
|
+
/** @internal */
|
|
1972
|
+
function _readConversation(client, httpRequest, threadId, options) {
|
|
1973
|
+
return _one(client, httpRequest, "*[_type == \"sanity.context.conversation\" && organizationId == $org && threadId == $threadId][0]", {
|
|
1974
|
+
org: _organizationId(client),
|
|
1975
|
+
threadId
|
|
1976
|
+
}, options);
|
|
1977
|
+
}
|
|
1978
|
+
function _classPrivateMethodInitSpec(e, a) {
|
|
1979
|
+
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
1980
|
+
}
|
|
1981
|
+
const COLLECTION_URL = "/context/knowledge-bases";
|
|
1982
|
+
/**
|
|
1983
|
+
* The knowledge base every scoped method operates on comes from the client's
|
|
1984
|
+
* `resource` configuration, matching how media libraries and canvases are
|
|
1985
|
+
* addressed. Resolved per call so `withConfig` clones behave.
|
|
1986
|
+
*/
|
|
1987
|
+
function _resolveKnowledgeBaseId(client) {
|
|
1988
|
+
let resource = client.config().resource;
|
|
1989
|
+
if (resource?.type !== "knowledge-base") throw Error("`resource` of type `knowledge-base` must be configured to use knowledge-base methods");
|
|
1990
|
+
return resource.id;
|
|
1991
|
+
}
|
|
1992
|
+
function _knowledgeBaseUrl(knowledgeBaseId, suffix = "") {
|
|
1993
|
+
return `${COLLECTION_URL}/${encodeURIComponent(knowledgeBaseId)}${suffix}`;
|
|
1994
|
+
}
|
|
1995
|
+
/** Serialize defined values into query params, dropping the undefined ones. */
|
|
1996
|
+
function _conversationUrl(client, threadId) {
|
|
1997
|
+
let organizationId = client.config().context?.organizationId;
|
|
1998
|
+
if (!organizationId) throw Error("`context.organizationId` must be configured to record conversations");
|
|
1999
|
+
if (!threadId) throw Error("`threadId` must be provided");
|
|
2000
|
+
return `/context/organizations/${encodeURIComponent(organizationId)}/conversations/${encodeURIComponent(threadId)}`;
|
|
2001
|
+
}
|
|
2002
|
+
function _query(entries) {
|
|
2003
|
+
return Object.fromEntries(Object.entries(entries).flatMap(([key, value]) => value === void 0 ? [] : [[key, `${value}`]]));
|
|
2004
|
+
}
|
|
2005
|
+
function _fetchBody(file) {
|
|
2006
|
+
return ArrayBuffer.isView(file) ? file.buffer instanceof ArrayBuffer ? new Uint8Array(file.buffer, file.byteOffset, file.byteLength) : Uint8Array.from(file) : file;
|
|
2007
|
+
}
|
|
2008
|
+
var _client$7 = /* @__PURE__ */ new WeakMap(), _httpRequest$7 = /* @__PURE__ */ new WeakMap(), _ContextClient_brand = /* @__PURE__ */ new WeakSet(), ContextClient = class {
|
|
2009
|
+
constructor(client, httpRequest) {
|
|
2010
|
+
_classPrivateMethodInitSpec(this, _ContextClient_brand), _classPrivateFieldInitSpec(this, _client$7, void 0), _classPrivateFieldInitSpec(this, _httpRequest$7, void 0), _defineProperty(
|
|
2011
|
+
this,
|
|
2012
|
+
/** The knowledge base collection: management addressed per call. */
|
|
2013
|
+
"knowledgeBases",
|
|
2014
|
+
{
|
|
2015
|
+
/** Create a knowledge base. Requires the org-level knowledge-base create grant. */
|
|
2016
|
+
create: (params, options) => _request(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), {
|
|
2017
|
+
url: COLLECTION_URL,
|
|
2018
|
+
method: "POST",
|
|
2019
|
+
body: params,
|
|
2020
|
+
...options
|
|
2021
|
+
}),
|
|
2022
|
+
/** List the organization's knowledge bases. */
|
|
2023
|
+
list: (params) => _request(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), {
|
|
2024
|
+
url: COLLECTION_URL,
|
|
2025
|
+
query: _query({
|
|
2026
|
+
organizationId: params.organizationId,
|
|
2027
|
+
cursor: params.cursor,
|
|
2028
|
+
limit: params.limit
|
|
2029
|
+
}),
|
|
2030
|
+
signal: params.signal,
|
|
2031
|
+
tag: params.tag
|
|
2032
|
+
}),
|
|
2033
|
+
/** Fetch a knowledge base by its id. */
|
|
2034
|
+
get: (knowledgeBaseId, options) => _request(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), {
|
|
2035
|
+
url: _knowledgeBaseUrl(knowledgeBaseId),
|
|
2036
|
+
...options
|
|
2037
|
+
}),
|
|
2038
|
+
/** Edit a knowledge base's configuration. */
|
|
2039
|
+
edit: (knowledgeBaseId, params, options) => _request(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), {
|
|
2040
|
+
url: _knowledgeBaseUrl(knowledgeBaseId),
|
|
2041
|
+
method: "PATCH",
|
|
2042
|
+
body: params,
|
|
2043
|
+
...options
|
|
2044
|
+
}),
|
|
2045
|
+
/** Delete a knowledge base and its generated content. */
|
|
2046
|
+
delete: async (knowledgeBaseId, options) => {
|
|
2047
|
+
await _request(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), {
|
|
2048
|
+
url: _knowledgeBaseUrl(knowledgeBaseId),
|
|
2049
|
+
method: "DELETE",
|
|
2050
|
+
...options
|
|
2051
|
+
});
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
), _defineProperty(
|
|
2055
|
+
this,
|
|
2056
|
+
/**
|
|
2057
|
+
* Conversation telemetry. `threadId` identifies the conversation within
|
|
2058
|
+
* the organization — reuse means the same conversation. Beyond the canned
|
|
2059
|
+
* `get`, reads go through {@link fetch} and {@link listen} with GROQ
|
|
2060
|
+
* (`_type == "sanity.context.conversation"`).
|
|
2061
|
+
*
|
|
2062
|
+
* Requires `context.organizationId` in the client configuration.
|
|
2063
|
+
*/
|
|
2064
|
+
"conversations",
|
|
2065
|
+
{
|
|
2066
|
+
/**
|
|
2067
|
+
* Record a conversation. Messages replace the stored transcript
|
|
2068
|
+
* wholesale; `metadata` and model fields only overwrite when present.
|
|
2069
|
+
* Last write per thread wins — retries are safe.
|
|
2070
|
+
*/
|
|
2071
|
+
save: (params, options) => {
|
|
2072
|
+
let { threadId, ...body } = params;
|
|
2073
|
+
return _request(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), {
|
|
2074
|
+
url: _conversationUrl(_classPrivateFieldGet2(_client$7, this), threadId),
|
|
2075
|
+
method: "PUT",
|
|
2076
|
+
body,
|
|
2077
|
+
...options
|
|
2078
|
+
});
|
|
2079
|
+
},
|
|
2080
|
+
/**
|
|
2081
|
+
* Record the classification your own model produced for one thread:
|
|
2082
|
+
* exactly one of `coreMetrics` (a verdict) or `classificationError`
|
|
2083
|
+
* (why classification failed).
|
|
2084
|
+
*/
|
|
2085
|
+
classify: (params, options) => {
|
|
2086
|
+
let { threadId, ...body } = params;
|
|
2087
|
+
return _request(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), {
|
|
2088
|
+
url: _conversationUrl(_classPrivateFieldGet2(_client$7, this), threadId),
|
|
2089
|
+
method: "PATCH",
|
|
2090
|
+
body,
|
|
2091
|
+
...options
|
|
2092
|
+
});
|
|
2093
|
+
},
|
|
2094
|
+
/**
|
|
2095
|
+
* One recorded conversation by its thread id, or `null` when the thread
|
|
2096
|
+
* was never recorded. Runs:
|
|
2097
|
+
*
|
|
2098
|
+
* `*[_type == "sanity.context.conversation" && organizationId == $org && threadId == $threadId][0]`
|
|
2099
|
+
*
|
|
2100
|
+
* For anything more, use {@link fetch}.
|
|
2101
|
+
*/
|
|
2102
|
+
get: (params, options) => _readConversation(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), params.threadId, options)
|
|
2103
|
+
}
|
|
2104
|
+
), _defineProperty(
|
|
2105
|
+
this,
|
|
2106
|
+
/** Imports: feed content into the configured knowledge base. */
|
|
2107
|
+
"imports",
|
|
2108
|
+
{
|
|
2109
|
+
/**
|
|
2110
|
+
* Import content. One entry point, discriminated on `type`: inline
|
|
2111
|
+
* `text`, a website `crawl`, a Sanity `dataset` bind, or a `file`
|
|
2112
|
+
* upload. Processing queues automatically. The file variant stages the
|
|
2113
|
+
* upload, PUTs the bytes to a signed storage URL, and confirms; the
|
|
2114
|
+
* bytes never pass through the Context API.
|
|
2115
|
+
*/
|
|
2116
|
+
create: (params, options) => params.type === "file" ? _assertClassBrand(_ContextClient_brand, this, _uploadFile).call(this, params, options) : _assertClassBrand(_ContextClient_brand, this, _request2).call(this, "/imports", {
|
|
2117
|
+
method: "POST",
|
|
2118
|
+
body: params,
|
|
2119
|
+
...options
|
|
2120
|
+
}),
|
|
2121
|
+
list: (params) => _assertClassBrand(_ContextClient_brand, this, _list).call(this, "/imports", params),
|
|
2122
|
+
get: (params, options) => _assertClassBrand(_ContextClient_brand, this, _request2).call(this, `/imports/${encodeURIComponent(params.importId)}`, options),
|
|
2123
|
+
/** A short-lived signed URL for the original uploaded bytes. */
|
|
2124
|
+
download: (params, options) => _assertClassBrand(_ContextClient_brand, this, _request2).call(this, `/imports/${encodeURIComponent(params.importId)}/download`, options),
|
|
2125
|
+
delete: async (params, options) => {
|
|
2126
|
+
await _assertClassBrand(_ContextClient_brand, this, _request2).call(this, `/imports/${encodeURIComponent(params.importId)}`, {
|
|
2127
|
+
method: "DELETE",
|
|
2128
|
+
...options
|
|
2129
|
+
});
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
), _defineProperty(
|
|
2133
|
+
this,
|
|
2134
|
+
/** Jobs: poll async work (builds, imports) to a terminal state. */
|
|
2135
|
+
"jobs",
|
|
2136
|
+
{ get: (params, options) => _assertClassBrand(_ContextClient_brand, this, _request2).call(this, `/jobs/${encodeURIComponent(params.jobId)}`, options) }
|
|
2137
|
+
), _defineProperty(
|
|
2138
|
+
this,
|
|
2139
|
+
/**
|
|
2140
|
+
* Issues: findings from builds awaiting triage. Reads are canned GROQ
|
|
2141
|
+
* queries against the organization's document store; for anything more,
|
|
2142
|
+
* use {@link fetch}. Reads require `context.organizationId` alongside the
|
|
2143
|
+
* knowledge-base `resource` in the client configuration.
|
|
2144
|
+
*/
|
|
2145
|
+
"issues",
|
|
2146
|
+
{
|
|
2147
|
+
/**
|
|
2148
|
+
* Every issue on the knowledge base, oldest first, optionally narrowed
|
|
2149
|
+
* to one status. Drains keyset pages internally and resolves with the
|
|
2150
|
+
* complete set. Runs:
|
|
2151
|
+
*
|
|
2152
|
+
* `*[_type == "sanity.context.issue" && knowledgeBaseId == $kb && status == $status] | order(_createdAt asc, _id asc)`
|
|
2153
|
+
*
|
|
2154
|
+
* (the status clause only when given). For anything more, use {@link fetch}.
|
|
2155
|
+
*/
|
|
2156
|
+
list: (params, options) => _listIssues(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), _resolveKnowledgeBaseId(_classPrivateFieldGet2(_client$7, this)), params?.status, options),
|
|
2157
|
+
/**
|
|
2158
|
+
* One issue by its document id, or `null` when it does not exist. Runs:
|
|
2159
|
+
*
|
|
2160
|
+
* `*[_type == "sanity.context.issue" && knowledgeBaseId == $kb && _id == $id][0]`
|
|
2161
|
+
*
|
|
2162
|
+
* For anything more, use {@link fetch}.
|
|
2163
|
+
*/
|
|
2164
|
+
get: (params, options) => _readIssue(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), _resolveKnowledgeBaseId(_classPrivateFieldGet2(_client$7, this)), params.issueId, options),
|
|
2165
|
+
/** Resolve a conflict issue. Mints the standing instruction, same as the dashboard. */
|
|
2166
|
+
resolve: (params, options) => {
|
|
2167
|
+
let { issueId, ...body } = params;
|
|
2168
|
+
return _assertClassBrand(_ContextClient_brand, this, _request2).call(this, `/issues/${encodeURIComponent(issueId)}/resolve`, {
|
|
2169
|
+
method: "POST",
|
|
2170
|
+
body,
|
|
2171
|
+
...options
|
|
2172
|
+
});
|
|
2173
|
+
},
|
|
2174
|
+
dismiss: (params, options) => _assertClassBrand(_ContextClient_brand, this, _request2).call(this, `/issues/${encodeURIComponent(params.issueId)}/dismiss`, {
|
|
2175
|
+
method: "POST",
|
|
2176
|
+
...options
|
|
2177
|
+
}),
|
|
2178
|
+
reopen: (params, options) => _assertClassBrand(_ContextClient_brand, this, _request2).call(this, `/issues/${encodeURIComponent(params.issueId)}/reopen`, {
|
|
2179
|
+
method: "POST",
|
|
2180
|
+
...options
|
|
2181
|
+
}),
|
|
2182
|
+
/** Apply already-accepted issues to the knowledge base in one batch. */
|
|
2183
|
+
apply: (params, options) => _assertClassBrand(_ContextClient_brand, this, _request2).call(this, "/issues/apply", {
|
|
2184
|
+
method: "POST",
|
|
2185
|
+
body: params,
|
|
2186
|
+
...options
|
|
2187
|
+
})
|
|
2188
|
+
}
|
|
2189
|
+
), _defineProperty(
|
|
2190
|
+
this,
|
|
2191
|
+
/** Instructions: standing decisions that steer every build. */
|
|
2192
|
+
"instructions",
|
|
2193
|
+
{
|
|
2194
|
+
create: (params, options) => _assertClassBrand(_ContextClient_brand, this, _request2).call(this, "/instructions", {
|
|
2195
|
+
method: "POST",
|
|
2196
|
+
body: params,
|
|
2197
|
+
...options
|
|
2198
|
+
}),
|
|
2199
|
+
/**
|
|
2200
|
+
* Every current-schema instruction on the knowledge base, oldest first.
|
|
2201
|
+
* Drains keyset pages internally and resolves with the complete set.
|
|
2202
|
+
* Runs:
|
|
2203
|
+
*
|
|
2204
|
+
* `*[_type == "sanity.context.instruction" && knowledgeBaseId == $kb && schemaVersion == 1] | order(_createdAt asc, _id asc)`
|
|
2205
|
+
*
|
|
2206
|
+
* For anything more, use {@link fetch}. Requires `context.organizationId`
|
|
2207
|
+
* alongside the knowledge-base `resource` in the client configuration.
|
|
2208
|
+
*/
|
|
2209
|
+
list: (options) => _listInstructions(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), _resolveKnowledgeBaseId(_classPrivateFieldGet2(_client$7, this)), options),
|
|
2210
|
+
edit: (params, options) => {
|
|
2211
|
+
let { instructionId, ...body } = params;
|
|
2212
|
+
return _assertClassBrand(_ContextClient_brand, this, _request2).call(this, `/instructions/${encodeURIComponent(instructionId)}`, {
|
|
2213
|
+
method: "PATCH",
|
|
2214
|
+
body,
|
|
2215
|
+
...options
|
|
2216
|
+
});
|
|
2217
|
+
},
|
|
2218
|
+
delete: async (params, options) => {
|
|
2219
|
+
await _assertClassBrand(_ContextClient_brand, this, _request2).call(this, `/instructions/${encodeURIComponent(params.instructionId)}`, {
|
|
2220
|
+
method: "DELETE",
|
|
2221
|
+
...options
|
|
2222
|
+
});
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
), _defineProperty(
|
|
2226
|
+
this,
|
|
2227
|
+
/**
|
|
2228
|
+
* Entries: the built outline, one entry per node. Reads are canned GROQ
|
|
2229
|
+
* queries against the organization's document store; for anything more,
|
|
2230
|
+
* use {@link fetch}. Requires `context.organizationId` alongside the
|
|
2231
|
+
* knowledge-base `resource` in the client configuration.
|
|
2232
|
+
*/
|
|
2233
|
+
"entries",
|
|
2234
|
+
{
|
|
2235
|
+
/**
|
|
2236
|
+
* Every entry, path-ordered, as a metadata view (`_id`, `path`,
|
|
2237
|
+
* `title`, `tldr`, `status`) with bodies excluded. Drains keyset pages
|
|
2238
|
+
* internally and resolves with the complete set. Runs:
|
|
2239
|
+
*
|
|
2240
|
+
* `*[_type == "sanity.context.entry" && knowledgeBaseId == $kb && path > $after] | order(path asc) [0...200] {_id, path, title, tldr, status}`
|
|
2241
|
+
*
|
|
2242
|
+
* For bodies, use `entries.get` or {@link fetch}.
|
|
2243
|
+
*/
|
|
2244
|
+
list: (options) => _listEntries(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), _resolveKnowledgeBaseId(_classPrivateFieldGet2(_client$7, this)), options),
|
|
2245
|
+
/**
|
|
2246
|
+
* One entry with its full body and citations, by outline path (e.g.
|
|
2247
|
+
* `billing/refunds`), or `null` when no entry sits at that path. Runs:
|
|
2248
|
+
*
|
|
2249
|
+
* `*[_type == "sanity.context.entry" && knowledgeBaseId == $kb && path == $path][0]`
|
|
2250
|
+
*
|
|
2251
|
+
* For anything more, use {@link fetch}.
|
|
2252
|
+
*/
|
|
2253
|
+
get: (params, options) => _readEntry(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), _resolveKnowledgeBaseId(_classPrivateFieldGet2(_client$7, this)), params.path, options),
|
|
2254
|
+
/**
|
|
2255
|
+
* Rebuild one entry from its already-placed sources, by outline path.
|
|
2256
|
+
* Poll the returned job with {@link jobs}; `affectedEntries` lists every
|
|
2257
|
+
* entry the rebuild touches.
|
|
2258
|
+
*/
|
|
2259
|
+
rebuild: (params, options) => _assertClassBrand(_ContextClient_brand, this, _request2).call(this, `/entries/${encodeURIComponent(params.path)}/rebuild`, {
|
|
2260
|
+
method: "POST",
|
|
2261
|
+
...options
|
|
2262
|
+
})
|
|
2263
|
+
}
|
|
2264
|
+
), _defineProperty(
|
|
2265
|
+
this,
|
|
2266
|
+
/**
|
|
2267
|
+
* MCP endpoint configurations, org-owned documents read with canned GROQ
|
|
2268
|
+
* queries. Requires `context.organizationId` in the client configuration.
|
|
2269
|
+
*/
|
|
2270
|
+
"mcpEndpoints",
|
|
2271
|
+
{
|
|
2272
|
+
/**
|
|
2273
|
+
* The organization's MCP endpoint configurations, oldest first. Runs:
|
|
2274
|
+
*
|
|
2275
|
+
* `*[_type == "sanity.context.mcp" && organizationId == $org] | order(_createdAt asc, _id asc) [0...500]`
|
|
2276
|
+
*
|
|
2277
|
+
* For anything more, use {@link fetch}.
|
|
2278
|
+
*/
|
|
2279
|
+
list: (options) => _listMcpEndpoints(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), options),
|
|
2280
|
+
/**
|
|
2281
|
+
* One MCP endpoint configuration by its URL name, or `null` when none
|
|
2282
|
+
* carries that name. Runs:
|
|
2283
|
+
*
|
|
2284
|
+
* `*[_type == "sanity.context.mcp" && organizationId == $org && name == $name][0]`
|
|
2285
|
+
*
|
|
2286
|
+
* For anything more, use {@link fetch}.
|
|
2287
|
+
*/
|
|
2288
|
+
get: (params, options) => _readMcpEndpoint(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), params.name, options)
|
|
2289
|
+
}
|
|
2290
|
+
), _defineProperty(
|
|
2291
|
+
this,
|
|
2292
|
+
/** Sources: the distilled units builds cite. */
|
|
2293
|
+
"sources",
|
|
2294
|
+
{
|
|
2295
|
+
/**
|
|
2296
|
+
* List sources, optionally filtered by `status` or the `importId` they
|
|
2297
|
+
* came from. `ids` is a lookup mode: it resolves those exact sources
|
|
2298
|
+
* (e.g. from an entry's citations) and overrides `status` and `cursor`.
|
|
2299
|
+
*/
|
|
2300
|
+
list: (params) => _assertClassBrand(_ContextClient_brand, this, _list).call(this, "/sources", params, {
|
|
2301
|
+
status: params?.status,
|
|
2302
|
+
importId: params?.importId,
|
|
2303
|
+
ids: params?.ids?.join(",")
|
|
2304
|
+
}),
|
|
2305
|
+
get: (params, options) => _assertClassBrand(_ContextClient_brand, this, _request2).call(this, `/sources/${encodeURIComponent(params.sourceId)}`, options),
|
|
2306
|
+
/**
|
|
2307
|
+
* Distilled source content, optionally a line range: the evidence behind
|
|
2308
|
+
* a citation or an issue.
|
|
2309
|
+
*/
|
|
2310
|
+
content: (params, options) => _assertClassBrand(_ContextClient_brand, this, _request2).call(this, `/sources/${encodeURIComponent(params.sourceId)}/content`, {
|
|
2311
|
+
query: _query({
|
|
2312
|
+
startLine: params.startLine,
|
|
2313
|
+
endLine: params.endLine
|
|
2314
|
+
}),
|
|
2315
|
+
...options
|
|
2316
|
+
}),
|
|
2317
|
+
delete: async (params, options) => {
|
|
2318
|
+
await _assertClassBrand(_ContextClient_brand, this, _request2).call(this, `/sources/${encodeURIComponent(params.sourceId)}`, {
|
|
2319
|
+
method: "DELETE",
|
|
2320
|
+
...options
|
|
2321
|
+
});
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
), _classPrivateFieldSet2(_client$7, this, client), _classPrivateFieldSet2(_httpRequest$7, this, httpRequest);
|
|
2325
|
+
}
|
|
2326
|
+
/**
|
|
2327
|
+
* GROQ over the organization's Context documents (conversation telemetry
|
|
2328
|
+
* today; the store holds every Context family and the caller's access
|
|
2329
|
+
* decides what a query returns, so filter on `_type`).
|
|
2330
|
+
*
|
|
2331
|
+
* Requires `context.organizationId` in the client configuration.
|
|
2332
|
+
*/
|
|
2333
|
+
fetch(query, params, options) {
|
|
2334
|
+
return lastValueFrom(_fetch(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), query, params, options));
|
|
1837
2335
|
}
|
|
2336
|
+
/**
|
|
2337
|
+
* Listen for changes to the organization's Context documents. Mirrors
|
|
2338
|
+
* `client.listen(query, params, options)` and emits mutation events by
|
|
2339
|
+
* default.
|
|
2340
|
+
*/
|
|
2341
|
+
listen(query, params, options) {
|
|
2342
|
+
return _listen(_classPrivateFieldGet2(_client$7, this), query, params, options);
|
|
2343
|
+
}
|
|
2344
|
+
/**
|
|
2345
|
+
* Build the configured knowledge base. The server waits for pending import
|
|
2346
|
+
* processing before assembling, so importing and building back to back is
|
|
2347
|
+
* safe. Track the returned job with {@link jobs}.
|
|
2348
|
+
*/
|
|
2349
|
+
build(options) {
|
|
2350
|
+
return _assertClassBrand(_ContextClient_brand, this, _request2).call(this, "/build", {
|
|
2351
|
+
method: "POST",
|
|
2352
|
+
...options
|
|
2353
|
+
});
|
|
2354
|
+
}
|
|
2355
|
+
/** Cancel the running build, if any. */
|
|
2356
|
+
cancelBuild(options) {
|
|
2357
|
+
return _assertClassBrand(_ContextClient_brand, this, _request2).call(this, "/build/cancel", {
|
|
2358
|
+
method: "POST",
|
|
2359
|
+
...options
|
|
2360
|
+
});
|
|
2361
|
+
}
|
|
2362
|
+
/** Run an incremental refresh: re-check sources and apply what changed. */
|
|
2363
|
+
refresh(options) {
|
|
2364
|
+
return _assertClassBrand(_ContextClient_brand, this, _request2).call(this, "/refresh", {
|
|
2365
|
+
method: "POST",
|
|
2366
|
+
...options
|
|
2367
|
+
});
|
|
2368
|
+
}
|
|
2369
|
+
};
|
|
2370
|
+
/** Request against the configured knowledge base. */
|
|
2371
|
+
function _request2(suffix, reqOptions = {}) {
|
|
2372
|
+
return _request(_classPrivateFieldGet2(_client$7, this), _classPrivateFieldGet2(_httpRequest$7, this), {
|
|
2373
|
+
url: _knowledgeBaseUrl(_resolveKnowledgeBaseId(_classPrivateFieldGet2(_client$7, this)), suffix),
|
|
2374
|
+
...reqOptions
|
|
2375
|
+
});
|
|
2376
|
+
}
|
|
2377
|
+
/** Shared shape of every paginated list endpoint scoped to the knowledge base. */
|
|
2378
|
+
function _list(suffix, params, extraQuery) {
|
|
2379
|
+
return _assertClassBrand(_ContextClient_brand, this, _request2).call(this, suffix, {
|
|
2380
|
+
query: _query({
|
|
2381
|
+
cursor: params?.cursor,
|
|
2382
|
+
limit: params?.limit,
|
|
2383
|
+
...extraQuery
|
|
2384
|
+
}),
|
|
2385
|
+
signal: params?.signal,
|
|
2386
|
+
tag: params?.tag
|
|
2387
|
+
});
|
|
2388
|
+
}
|
|
2389
|
+
async function _uploadFile(params, options) {
|
|
2390
|
+
let staged = await _assertClassBrand(_ContextClient_brand, this, _request2).call(this, "/imports/uploads", {
|
|
2391
|
+
method: "POST",
|
|
2392
|
+
body: {
|
|
2393
|
+
filename: params.filename,
|
|
2394
|
+
...params.contentType && { contentType: params.contentType }
|
|
2395
|
+
},
|
|
2396
|
+
...options
|
|
2397
|
+
}), config = _classPrivateFieldGet2(_client$7, this).config(), putResponse = await (config.resolveFetch?.(config.proxy) ?? globalThis.fetch)(staged.uploadUrl, {
|
|
2398
|
+
method: "PUT",
|
|
2399
|
+
body: _fetchBody(params.file),
|
|
2400
|
+
...params.contentType && { headers: { "content-type": params.contentType } },
|
|
2401
|
+
signal: options?.signal
|
|
2402
|
+
});
|
|
2403
|
+
if (!putResponse.ok) throw Error(`File upload failed: ${putResponse.status} ${putResponse.statusText}`);
|
|
2404
|
+
return _assertClassBrand(_ContextClient_brand, this, _request2).call(this, `/imports/uploads/${encodeURIComponent(staged.importId)}/complete`, {
|
|
2405
|
+
method: "POST",
|
|
2406
|
+
body: {},
|
|
2407
|
+
...options
|
|
2408
|
+
});
|
|
2409
|
+
}
|
|
2410
|
+
var _client2$6 = /* @__PURE__ */ new WeakMap(), _httpRequest2$7 = /* @__PURE__ */ new WeakMap(), ObservableContextClient = class {
|
|
2411
|
+
constructor(client, httpRequest) {
|
|
2412
|
+
_classPrivateFieldInitSpec(this, _client2$6, void 0), _classPrivateFieldInitSpec(this, _httpRequest2$7, void 0), _defineProperty(
|
|
2413
|
+
this,
|
|
2414
|
+
/** The knowledge base collection: management addressed per call. */
|
|
2415
|
+
"knowledgeBases",
|
|
2416
|
+
{
|
|
2417
|
+
/** Create a knowledge base. Requires the org-level knowledge-base create grant. */
|
|
2418
|
+
create: (params, options) => _observe(options?.signal, (signal) => _request(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), {
|
|
2419
|
+
url: COLLECTION_URL,
|
|
2420
|
+
method: "POST",
|
|
2421
|
+
body: params,
|
|
2422
|
+
tag: options?.tag,
|
|
2423
|
+
signal
|
|
2424
|
+
})),
|
|
2425
|
+
/** List the organization's knowledge bases. */
|
|
2426
|
+
list: (params) => _observe(params.signal, (signal) => _request(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), {
|
|
2427
|
+
url: COLLECTION_URL,
|
|
2428
|
+
query: _query({
|
|
2429
|
+
organizationId: params.organizationId,
|
|
2430
|
+
cursor: params.cursor,
|
|
2431
|
+
limit: params.limit
|
|
2432
|
+
}),
|
|
2433
|
+
tag: params.tag,
|
|
2434
|
+
signal
|
|
2435
|
+
})),
|
|
2436
|
+
/** Fetch a knowledge base by its id. */
|
|
2437
|
+
get: (knowledgeBaseId, options) => _observe(options?.signal, (signal) => _request(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), {
|
|
2438
|
+
url: _knowledgeBaseUrl(knowledgeBaseId),
|
|
2439
|
+
tag: options?.tag,
|
|
2440
|
+
signal
|
|
2441
|
+
})),
|
|
2442
|
+
/** Edit a knowledge base's configuration. */
|
|
2443
|
+
edit: (knowledgeBaseId, params, options) => _observe(options?.signal, (signal) => _request(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), {
|
|
2444
|
+
url: _knowledgeBaseUrl(knowledgeBaseId),
|
|
2445
|
+
method: "PATCH",
|
|
2446
|
+
body: params,
|
|
2447
|
+
tag: options?.tag,
|
|
2448
|
+
signal
|
|
2449
|
+
})),
|
|
2450
|
+
/** Delete a knowledge base and its generated content. */
|
|
2451
|
+
delete: (knowledgeBaseId, options) => _observe(options?.signal, (signal) => _request(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), {
|
|
2452
|
+
url: _knowledgeBaseUrl(knowledgeBaseId),
|
|
2453
|
+
method: "DELETE",
|
|
2454
|
+
tag: options?.tag,
|
|
2455
|
+
signal
|
|
2456
|
+
}))
|
|
2457
|
+
}
|
|
2458
|
+
), _defineProperty(
|
|
2459
|
+
this,
|
|
2460
|
+
/**
|
|
2461
|
+
* Conversation telemetry. `threadId` identifies the conversation within
|
|
2462
|
+
* the organization — reuse means the same conversation. Beyond the canned
|
|
2463
|
+
* `get`, reads go through {@link fetch} and {@link listen} with GROQ
|
|
2464
|
+
* (`_type == "sanity.context.conversation"`).
|
|
2465
|
+
*
|
|
2466
|
+
* Requires `context.organizationId` in the client configuration.
|
|
2467
|
+
*/
|
|
2468
|
+
"conversations",
|
|
2469
|
+
{
|
|
2470
|
+
/**
|
|
2471
|
+
* Record a conversation. Messages replace the stored transcript
|
|
2472
|
+
* wholesale; `metadata` and model fields only overwrite when present.
|
|
2473
|
+
* Last write per thread wins — retries are safe.
|
|
2474
|
+
*/
|
|
2475
|
+
save: (params, options) => {
|
|
2476
|
+
let { threadId, ...body } = params;
|
|
2477
|
+
return _observe(options?.signal, (signal) => _request(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), {
|
|
2478
|
+
url: _conversationUrl(_classPrivateFieldGet2(_client2$6, this), threadId),
|
|
2479
|
+
method: "PUT",
|
|
2480
|
+
body,
|
|
2481
|
+
tag: options?.tag,
|
|
2482
|
+
signal
|
|
2483
|
+
}));
|
|
2484
|
+
},
|
|
2485
|
+
/**
|
|
2486
|
+
* Record the classification your own model produced for one thread:
|
|
2487
|
+
* exactly one of `coreMetrics` (a verdict) or `classificationError`
|
|
2488
|
+
* (why classification failed).
|
|
2489
|
+
*/
|
|
2490
|
+
classify: (params, options) => {
|
|
2491
|
+
let { threadId, ...body } = params;
|
|
2492
|
+
return _observe(options?.signal, (signal) => _request(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), {
|
|
2493
|
+
url: _conversationUrl(_classPrivateFieldGet2(_client2$6, this), threadId),
|
|
2494
|
+
method: "PATCH",
|
|
2495
|
+
body,
|
|
2496
|
+
tag: options?.tag,
|
|
2497
|
+
signal
|
|
2498
|
+
}));
|
|
2499
|
+
},
|
|
2500
|
+
/**
|
|
2501
|
+
* One recorded conversation by its thread id, or `null` when the thread
|
|
2502
|
+
* was never recorded. Runs:
|
|
2503
|
+
*
|
|
2504
|
+
* `*[_type == "sanity.context.conversation" && organizationId == $org && threadId == $threadId][0]`
|
|
2505
|
+
*
|
|
2506
|
+
* For anything more, use {@link fetch}.
|
|
2507
|
+
*/
|
|
2508
|
+
get: (params, options) => _observe(options?.signal, (signal) => _readConversation(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), params.threadId, {
|
|
2509
|
+
...options,
|
|
2510
|
+
signal
|
|
2511
|
+
}))
|
|
2512
|
+
}
|
|
2513
|
+
), _defineProperty(
|
|
2514
|
+
this,
|
|
2515
|
+
/**
|
|
2516
|
+
* Entries: the built outline, one entry per node. Reads are canned GROQ
|
|
2517
|
+
* queries against the organization's document store; for anything more,
|
|
2518
|
+
* use {@link fetch}. Requires `context.organizationId` alongside the
|
|
2519
|
+
* knowledge-base `resource` in the client configuration.
|
|
2520
|
+
*/
|
|
2521
|
+
"entries",
|
|
2522
|
+
{
|
|
2523
|
+
/**
|
|
2524
|
+
* Every entry, path-ordered, as a metadata view (`_id`, `path`,
|
|
2525
|
+
* `title`, `tldr`, `status`) with bodies excluded. Drains keyset pages
|
|
2526
|
+
* internally and emits the complete set. Runs:
|
|
2527
|
+
*
|
|
2528
|
+
* `*[_type == "sanity.context.entry" && knowledgeBaseId == $kb && path > $after] | order(path asc) [0...200] {_id, path, title, tldr, status}`
|
|
2529
|
+
*
|
|
2530
|
+
* For bodies, use `entries.get` or {@link fetch}.
|
|
2531
|
+
*/
|
|
2532
|
+
list: (options) => _observe(options?.signal, (signal) => _listEntries(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), _resolveKnowledgeBaseId(_classPrivateFieldGet2(_client2$6, this)), {
|
|
2533
|
+
...options,
|
|
2534
|
+
signal
|
|
2535
|
+
})),
|
|
2536
|
+
/**
|
|
2537
|
+
* One entry with its full body and citations, by outline path (e.g.
|
|
2538
|
+
* `billing/refunds`), or `null` when no entry sits at that path. Runs:
|
|
2539
|
+
*
|
|
2540
|
+
* `*[_type == "sanity.context.entry" && knowledgeBaseId == $kb && path == $path][0]`
|
|
2541
|
+
*
|
|
2542
|
+
* For anything more, use {@link fetch}.
|
|
2543
|
+
*/
|
|
2544
|
+
get: (params, options) => _observe(options?.signal, (signal) => _readEntry(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), _resolveKnowledgeBaseId(_classPrivateFieldGet2(_client2$6, this)), params.path, {
|
|
2545
|
+
...options,
|
|
2546
|
+
signal
|
|
2547
|
+
})),
|
|
2548
|
+
/**
|
|
2549
|
+
* Rebuild one entry from its already-placed sources, by outline path.
|
|
2550
|
+
* Poll the returned job with the promise client's `jobs`;
|
|
2551
|
+
* `affectedEntries` lists every entry the rebuild touches.
|
|
2552
|
+
*/
|
|
2553
|
+
rebuild: (params, options) => _observe(options?.signal, (signal) => _request(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), {
|
|
2554
|
+
url: _knowledgeBaseUrl(_resolveKnowledgeBaseId(_classPrivateFieldGet2(_client2$6, this)), `/entries/${encodeURIComponent(params.path)}/rebuild`),
|
|
2555
|
+
method: "POST",
|
|
2556
|
+
tag: options?.tag,
|
|
2557
|
+
signal
|
|
2558
|
+
}))
|
|
2559
|
+
}
|
|
2560
|
+
), _defineProperty(
|
|
2561
|
+
this,
|
|
2562
|
+
/**
|
|
2563
|
+
* Issues: findings from builds awaiting triage. Reads are canned GROQ
|
|
2564
|
+
* queries against the organization's document store; for anything more,
|
|
2565
|
+
* use {@link fetch}. Requires `context.organizationId` alongside the
|
|
2566
|
+
* knowledge-base `resource` in the client configuration.
|
|
2567
|
+
*/
|
|
2568
|
+
"issues",
|
|
2569
|
+
{
|
|
2570
|
+
/**
|
|
2571
|
+
* Every issue on the knowledge base, oldest first, optionally narrowed
|
|
2572
|
+
* to one status. Drains keyset pages internally and emits the complete
|
|
2573
|
+
* set. Runs:
|
|
2574
|
+
*
|
|
2575
|
+
* `*[_type == "sanity.context.issue" && knowledgeBaseId == $kb && status == $status] | order(_createdAt asc, _id asc)`
|
|
2576
|
+
*
|
|
2577
|
+
* (the status clause only when given). For anything more, use {@link fetch}.
|
|
2578
|
+
*/
|
|
2579
|
+
list: (params, options) => _observe(options?.signal, (signal) => _listIssues(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), _resolveKnowledgeBaseId(_classPrivateFieldGet2(_client2$6, this)), params?.status, {
|
|
2580
|
+
...options,
|
|
2581
|
+
signal
|
|
2582
|
+
})),
|
|
2583
|
+
/**
|
|
2584
|
+
* One issue by its document id, or `null` when it does not exist. Runs:
|
|
2585
|
+
*
|
|
2586
|
+
* `*[_type == "sanity.context.issue" && knowledgeBaseId == $kb && _id == $id][0]`
|
|
2587
|
+
*
|
|
2588
|
+
* For anything more, use {@link fetch}.
|
|
2589
|
+
*/
|
|
2590
|
+
get: (params, options) => _observe(options?.signal, (signal) => _readIssue(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), _resolveKnowledgeBaseId(_classPrivateFieldGet2(_client2$6, this)), params.issueId, {
|
|
2591
|
+
...options,
|
|
2592
|
+
signal
|
|
2593
|
+
}))
|
|
2594
|
+
}
|
|
2595
|
+
), _defineProperty(
|
|
2596
|
+
this,
|
|
2597
|
+
/**
|
|
2598
|
+
* Instructions: standing decisions that steer every build. The canned
|
|
2599
|
+
* GROQ read; writes are promise-based on `client.context`.
|
|
2600
|
+
*/
|
|
2601
|
+
"instructions",
|
|
2602
|
+
{
|
|
2603
|
+
/**
|
|
2604
|
+
* Every current-schema instruction on the knowledge base, oldest first.
|
|
2605
|
+
* Drains keyset pages internally and emits the complete set. Runs:
|
|
2606
|
+
*
|
|
2607
|
+
* `*[_type == "sanity.context.instruction" && knowledgeBaseId == $kb && schemaVersion == 1] | order(_createdAt asc, _id asc)`
|
|
2608
|
+
*
|
|
2609
|
+
* For anything more, use {@link fetch}. Requires `context.organizationId`
|
|
2610
|
+
* alongside the knowledge-base `resource` in the client configuration.
|
|
2611
|
+
*/
|
|
2612
|
+
list: (options) => _observe(options?.signal, (signal) => _listInstructions(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), _resolveKnowledgeBaseId(_classPrivateFieldGet2(_client2$6, this)), {
|
|
2613
|
+
...options,
|
|
2614
|
+
signal
|
|
2615
|
+
})) }
|
|
2616
|
+
), _defineProperty(
|
|
2617
|
+
this,
|
|
2618
|
+
/**
|
|
2619
|
+
* MCP endpoint configurations, org-owned documents read with canned GROQ
|
|
2620
|
+
* queries. Requires `context.organizationId` in the client configuration.
|
|
2621
|
+
*/
|
|
2622
|
+
"mcpEndpoints",
|
|
2623
|
+
{
|
|
2624
|
+
/**
|
|
2625
|
+
* The organization's MCP endpoint configurations, oldest first. Runs:
|
|
2626
|
+
*
|
|
2627
|
+
* `*[_type == "sanity.context.mcp" && organizationId == $org] | order(_createdAt asc, _id asc) [0...500]`
|
|
2628
|
+
*
|
|
2629
|
+
* For anything more, use {@link fetch}.
|
|
2630
|
+
*/
|
|
2631
|
+
list: (options) => _observe(options?.signal, (signal) => _listMcpEndpoints(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), {
|
|
2632
|
+
...options,
|
|
2633
|
+
signal
|
|
2634
|
+
})),
|
|
2635
|
+
/**
|
|
2636
|
+
* One MCP endpoint configuration by its URL name, or `null` when none
|
|
2637
|
+
* carries that name. Runs:
|
|
2638
|
+
*
|
|
2639
|
+
* `*[_type == "sanity.context.mcp" && organizationId == $org && name == $name][0]`
|
|
2640
|
+
*
|
|
2641
|
+
* For anything more, use {@link fetch}.
|
|
2642
|
+
*/
|
|
2643
|
+
get: (params, options) => _observe(options?.signal, (signal) => _readMcpEndpoint(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), params.name, {
|
|
2644
|
+
...options,
|
|
2645
|
+
signal
|
|
2646
|
+
}))
|
|
2647
|
+
}
|
|
2648
|
+
), _classPrivateFieldSet2(_client2$6, this, client), _classPrivateFieldSet2(_httpRequest2$7, this, httpRequest);
|
|
2649
|
+
}
|
|
2650
|
+
/**
|
|
2651
|
+
* GROQ over the organization's Context documents (conversation telemetry
|
|
2652
|
+
* today; the store holds every Context family and the caller's access
|
|
2653
|
+
* decides what a query returns, so filter on `_type`).
|
|
2654
|
+
*
|
|
2655
|
+
* Requires `context.organizationId` in the client configuration.
|
|
2656
|
+
*/
|
|
2657
|
+
fetch(query, params, options) {
|
|
2658
|
+
return _fetch(_classPrivateFieldGet2(_client2$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), query, params, options);
|
|
2659
|
+
}
|
|
2660
|
+
/**
|
|
2661
|
+
* Listen for changes to the organization's Context documents. Mirrors
|
|
2662
|
+
* `client.listen(query, params, options)` and emits mutation events by
|
|
2663
|
+
* default.
|
|
2664
|
+
*/
|
|
1838
2665
|
listen(query, params, options) {
|
|
1839
2666
|
return _listen(_classPrivateFieldGet2(_client2$6, this), query, params, options);
|
|
1840
2667
|
}
|
|
@@ -2857,14 +3684,19 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
|
|
|
2857
3684
|
}
|
|
2858
3685
|
}, _clientConfig = /* @__PURE__ */ new WeakMap(), _httpRequest = /* @__PURE__ */ new WeakMap(), ObservableSanityClient = class ObservableSanityClient {
|
|
2859
3686
|
constructor(httpRequest, config = defaultConfig) {
|
|
2860
|
-
_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),
|
|
3687
|
+
_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(
|
|
3688
|
+
this,
|
|
3689
|
+
/** @beta */
|
|
3690
|
+
"context",
|
|
3691
|
+
void 0
|
|
3692
|
+
), _classPrivateFieldInitSpec(this, _clientConfig, void 0), _classPrivateFieldInitSpec(this, _httpRequest, void 0), _defineProperty(
|
|
2861
3693
|
this,
|
|
2862
3694
|
/**
|
|
2863
3695
|
* Instance properties
|
|
2864
3696
|
*/
|
|
2865
3697
|
"listen",
|
|
2866
|
-
_listen$
|
|
2867
|
-
), 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));
|
|
3698
|
+
_listen$2
|
|
3699
|
+
), 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)), this.context = new ObservableContextClient(this, _classPrivateFieldGet2(_httpRequest, this));
|
|
2868
3700
|
}
|
|
2869
3701
|
/**
|
|
2870
3702
|
* Clone the client - returns a new instance
|
|
@@ -3082,6 +3914,11 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
|
|
|
3082
3914
|
}, _clientConfig2 = /* @__PURE__ */ new WeakMap(), _httpRequest2 = /* @__PURE__ */ new WeakMap(), SanityClient = class SanityClient {
|
|
3083
3915
|
constructor(httpRequest, config = defaultConfig) {
|
|
3084
3916
|
_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(
|
|
3917
|
+
this,
|
|
3918
|
+
/** @beta */
|
|
3919
|
+
"context",
|
|
3920
|
+
void 0
|
|
3921
|
+
), _defineProperty(
|
|
3085
3922
|
this,
|
|
3086
3923
|
/**
|
|
3087
3924
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
@@ -3094,8 +3931,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
|
|
|
3094
3931
|
* Instance properties
|
|
3095
3932
|
*/
|
|
3096
3933
|
"listen",
|
|
3097
|
-
_listen$
|
|
3098
|
-
), 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);
|
|
3934
|
+
_listen$2
|
|
3935
|
+
), 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.context = new ContextClient(this, _classPrivateFieldGet2(_httpRequest2, this)), this.observable = new ObservableSanityClient(httpRequest, config);
|
|
3099
3936
|
}
|
|
3100
3937
|
/**
|
|
3101
3938
|
* Clone the client - returns a new instance
|
|
@@ -3125,7 +3962,7 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
|
|
|
3125
3962
|
});
|
|
3126
3963
|
}
|
|
3127
3964
|
fetch(query, params, options) {
|
|
3128
|
-
return _fetch$
|
|
3965
|
+
return _fetch$2(this, _classPrivateFieldGet2(_httpRequest2, this), _classPrivateFieldGet2(_clientConfig2, this).stega, query, params, options);
|
|
3129
3966
|
}
|
|
3130
3967
|
getDocument(id, options) {
|
|
3131
3968
|
if (options?.includeAllVersions === !0) return _getDocument(this, _classPrivateFieldGet2(_httpRequest2, this), id, {
|
|
@@ -3358,6 +4195,6 @@ function defineDeprecatedCreateClient(createClient) {
|
|
|
3358
4195
|
};
|
|
3359
4196
|
}
|
|
3360
4197
|
const exp = defineCreateClientExports({ middleware: [] }, SanityClient), requester = exp.requester, createClient = exp.createClient, deprecatedCreateClient = defineDeprecatedCreateClient(createClient);
|
|
3361
|
-
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 };
|
|
4198
|
+
export { BasePatch, BaseTransaction, ChannelError, ClientError, ConnectionFailedError, types_exports as Context, 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 };
|
|
3362
4199
|
|
|
3363
4200
|
//# sourceMappingURL=index.js.map
|