@sanity/client 8.3.0 → 8.5.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.
Files changed (54) hide show
  1. package/README.md +80 -4
  2. package/dist/{browserUpload-2tz6Sdqp.js → browserUpload-C7PwCs-C.js} +6 -9
  3. package/dist/browserUpload-C7PwCs-C.js.map +1 -0
  4. package/dist/{browserUpload-CwpNx7Vl.js → browserUpload-D-2Rmfjo.js} +6 -9
  5. package/dist/browserUpload-D-2Rmfjo.js.map +1 -0
  6. package/dist/{config-3wiPP-sZ.js → config-CgJ16jET.js} +4 -2
  7. package/dist/config-CgJ16jET.js.map +1 -0
  8. package/dist/csm.js +1 -1
  9. package/dist/{dist-C9ExSk2R.js → dist-C5K_YcEU.js} +3 -2
  10. package/dist/{dist-C9ExSk2R.js.map → dist-C5K_YcEU.js.map} +1 -1
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.js +1111 -80
  13. package/dist/index.js.map +1 -1
  14. package/dist/index.node.d.ts +3561 -53
  15. package/dist/index.node.js +983 -30
  16. package/dist/index.node.js.map +1 -1
  17. package/dist/media-library.d.ts +1 -1
  18. package/dist/rolldown-runtime-4YWMqDIC.js +9 -0
  19. package/dist/stega.js +2 -2
  20. package/dist/{dist-Z8cIRxoB.js → stegaClean-YZRATV86.js} +19 -2
  21. package/dist/stegaClean-YZRATV86.js.map +1 -0
  22. package/dist/{stegaEncodeSourceMap-DbM2fTN4.js → stegaEncodeSourceMap-CO1HKnm2.js} +2 -2
  23. package/dist/{stegaEncodeSourceMap-DbM2fTN4.js.map → stegaEncodeSourceMap-CO1HKnm2.js.map} +1 -1
  24. package/dist/{stegaEncodeSourceMap-YR3NQ3iz.js → stegaEncodeSourceMap-Dj29aWKG.js} +2 -2
  25. package/dist/{stegaEncodeSourceMap-YR3NQ3iz.js.map → stegaEncodeSourceMap-Dj29aWKG.js.map} +1 -1
  26. package/dist/{types-0x2hPfhJ.d.ts → types-CtHEe8SF.d.ts} +3562 -54
  27. package/package.json +18 -15
  28. package/src/SanityClient.ts +183 -9
  29. package/src/agent/actions/AgentActionsClient.ts +8 -2
  30. package/src/assets/AssetsClient.ts +13 -2
  31. package/src/config.ts +1 -0
  32. package/src/context/ContextClient.ts +1006 -0
  33. package/src/context/openapi.json +5345 -0
  34. package/src/context/reads.ts +206 -0
  35. package/src/context/store.ts +100 -0
  36. package/src/context/types.gen.ts +2428 -0
  37. package/src/context/types.ts +228 -0
  38. package/src/data/dataMethods.ts +4 -1
  39. package/src/data/live.ts +1 -0
  40. package/src/datasets/DatasetsClient.ts +8 -2
  41. package/src/defineCreateClient.ts +1 -0
  42. package/src/http/browserUpload.ts +0 -12
  43. package/src/mediaLibrary/MediaLibraryVideoClient.ts +8 -2
  44. package/src/projects/ProjectsClient.ts +8 -2
  45. package/src/releases/ReleasesClient.ts +8 -2
  46. package/src/types.ts +68 -4
  47. package/src/users/UsersClient.ts +8 -2
  48. package/src/validators.ts +1 -0
  49. package/dist/browserUpload-2tz6Sdqp.js.map +0 -1
  50. package/dist/browserUpload-CwpNx7Vl.js.map +0 -1
  51. package/dist/config-3wiPP-sZ.js.map +0 -1
  52. package/dist/dist-Z8cIRxoB.js.map +0 -1
  53. package/dist/stegaClean-C18wLWau.js +0 -21
  54. package/dist/stegaClean-C18wLWau.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
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-3wiPP-sZ.js";
4
- import { t as stegaClean } from "./stegaClean-C18wLWau.js";
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";
5
+ import { t as stegaClean } from "./stegaClean-YZRATV86.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";
7
8
  import { getDraftId, getPublishedId, getVersionFromId, getVersionId, isDraftId, isVersionId } from "@sanity/client/csm";
@@ -337,41 +338,41 @@ var BasePatch = class {
337
338
  _set(op, props) {
338
339
  return this._assign(op, props, !1);
339
340
  }
340
- }, _client$11 = /* @__PURE__ */ new WeakMap(), ObservablePatch = class ObservablePatch extends BasePatch {
341
+ }, _client$12 = /* @__PURE__ */ new WeakMap(), ObservablePatch = class ObservablePatch extends BasePatch {
341
342
  constructor(selection, operations, client) {
342
- super(selection, operations), _classPrivateFieldInitSpec(this, _client$11, void 0), _classPrivateFieldSet2(_client$11, 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$11, this));
349
+ return new ObservablePatch(this.selection, { ...this.operations }, _classPrivateFieldGet2(_client$12, this));
349
350
  }
350
351
  commit(options) {
351
- if (!_classPrivateFieldGet2(_client$11, this)) throw Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
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$11, this).mutate({ patch: this.serialize() }, opts);
357
+ return _classPrivateFieldGet2(_client$12, this).mutate({ patch: this.serialize() }, opts);
357
358
  }
358
- }, _client2$10 = /* @__PURE__ */ new WeakMap(), Patch = class Patch extends BasePatch {
359
+ }, _client2$11 = /* @__PURE__ */ new WeakMap(), Patch = class Patch extends BasePatch {
359
360
  constructor(selection, operations, client) {
360
- super(selection, operations), _classPrivateFieldInitSpec(this, _client2$10, void 0), _classPrivateFieldSet2(_client2$10, this, client);
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$10, this));
367
+ return new Patch(this.selection, { ...this.operations }, _classPrivateFieldGet2(_client2$11, this));
367
368
  }
368
369
  commit(options) {
369
- if (!_classPrivateFieldGet2(_client2$10, this)) throw Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
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$10, this).mutate({ patch: this.serialize() }, opts);
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$10 = /* @__PURE__ */ new WeakMap(), Transaction = class Transaction extends BaseTransaction {
446
+ }, _client$11 = /* @__PURE__ */ new WeakMap(), Transaction = class Transaction extends BaseTransaction {
446
447
  constructor(operations, client, transactionId) {
447
- super(operations, transactionId), _classPrivateFieldInitSpec(this, _client$10, void 0), _classPrivateFieldSet2(_client$10, 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$10, this), this.trxId);
454
+ return new Transaction([...this.operations], _classPrivateFieldGet2(_client$11, this), this.trxId);
454
455
  }
455
456
  commit(options) {
456
- if (!_classPrivateFieldGet2(_client$10, this)) throw Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
457
- return _classPrivateFieldGet2(_client$10, this).mutate(this.serialize(), Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {}));
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$10, this)));
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$10, this));
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$9 = /* @__PURE__ */ new WeakMap(), ObservableTransaction = class ObservableTransaction extends BaseTransaction {
477
+ }, _client2$10 = /* @__PURE__ */ new WeakMap(), ObservableTransaction = class ObservableTransaction extends BaseTransaction {
477
478
  constructor(operations, client, transactionId) {
478
- super(operations, transactionId), _classPrivateFieldInitSpec(this, _client2$9, void 0), _classPrivateFieldSet2(_client2$9, this, client);
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$9, this), this.trxId);
485
+ return new ObservableTransaction([...this.operations], _classPrivateFieldGet2(_client2$10, this), this.trxId);
485
486
  }
486
487
  commit(options) {
487
- if (!_classPrivateFieldGet2(_client2$9, this)) throw Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
488
- return _classPrivateFieldGet2(_client2$9, this).mutate(this.serialize(), Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {}));
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$9, this)));
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$1(client, httpRequest, _stega, query, _params, {
615
+ return _observe(options.signal, (signal) => _fetch$2(client, httpRequest, _stega, query, _params, {
607
616
  ...options,
608
617
  signal
609
618
  }));
@@ -613,12 +622,12 @@ function _fetchObservable(client, httpRequest, _stega, query, _params = {}, opti
613
622
  *
614
623
  * @internal
615
624
  */
616
- function _fetch$1(client, httpRequest, _stega, query, _params = {}, options = {}) {
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
620
629
  }, reqOpts);
621
- return stega.enabled ? Promise.all([request, import("./stegaEncodeSourceMap-YR3NQ3iz.js").then((n) => n.n)]).then(([res, { stegaEncodeSourceMap }]) => {
630
+ return stega.enabled ? Promise.all([request, import("./stegaEncodeSourceMap-Dj29aWKG.js").then((n) => n.n)]).then(([res, { stegaEncodeSourceMap }]) => {
622
631
  let result = stegaEncodeSourceMap(res.result, res.resultSourceMap, stega);
623
632
  return mapResponse({
624
633
  ...res,
@@ -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$9 = /* @__PURE__ */ new WeakMap(), _httpRequest$8 = /* @__PURE__ */ new WeakMap(), ObservableAgentsActionClient = class {
1252
+ var _client$10 = /* @__PURE__ */ new WeakMap(), _httpRequest$9 = /* @__PURE__ */ new WeakMap(), ObservableAgentsActionClient = class {
1243
1253
  constructor(client, httpRequest) {
1244
- _classPrivateFieldInitSpec(this, _client$9, void 0), _classPrivateFieldInitSpec(this, _httpRequest$8, void 0), _classPrivateFieldSet2(_client$9, this, client), _classPrivateFieldSet2(_httpRequest$8, this, httpRequest);
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$9, this), _classPrivateFieldGet2(_httpRequest$8, this), request);
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$9, this), _classPrivateFieldGet2(_httpRequest$8, this), request);
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$9, this), _classPrivateFieldGet2(_httpRequest$8, this), request);
1275
+ return _translateObservable(_classPrivateFieldGet2(_client$10, this), _classPrivateFieldGet2(_httpRequest$9, this), request);
1266
1276
  }
1267
- }, _client2$8 = /* @__PURE__ */ new WeakMap(), _httpRequest2$9 = /* @__PURE__ */ new WeakMap(), AgentActionsClient = class {
1277
+ }, _client2$9 = /* @__PURE__ */ new WeakMap(), _httpRequest2$10 = /* @__PURE__ */ new WeakMap(), AgentActionsClient = class {
1268
1278
  constructor(client, httpRequest) {
1269
- _classPrivateFieldInitSpec(this, _client2$8, void 0), _classPrivateFieldInitSpec(this, _httpRequest2$9, void 0), _classPrivateFieldSet2(_client2$8, this, client), _classPrivateFieldSet2(_httpRequest2$9, this, httpRequest);
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$8, this), _classPrivateFieldGet2(_httpRequest2$9, this), request);
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$8, this), _classPrivateFieldGet2(_httpRequest2$9, this), request);
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$8, this), _classPrivateFieldGet2(_httpRequest2$9, this), request);
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$8, this), _classPrivateFieldGet2(_httpRequest2$9, this), request);
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$8, this), _classPrivateFieldGet2(_httpRequest2$9, this), request);
1315
+ return _patch(_classPrivateFieldGet2(_client2$9, this), _classPrivateFieldGet2(_httpRequest2$10, this), request);
1306
1316
  }
1307
- }, _client$8 = /* @__PURE__ */ new WeakMap(), _httpRequest2$8 = /* @__PURE__ */ new WeakMap(), ObservableAssetsClient = class {
1317
+ }, _client$9 = /* @__PURE__ */ new WeakMap(), _httpRequest2$9 = /* @__PURE__ */ new WeakMap(), ObservableAssetsClient = class {
1308
1318
  constructor(client, httpRequest) {
1309
- _classPrivateFieldInitSpec(this, _client$8, void 0), _classPrivateFieldInitSpec(this, _httpRequest2$8, void 0), _classPrivateFieldSet2(_client$8, this, client), _classPrivateFieldSet2(_httpRequest2$8, this, httpRequest);
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$8, this), _classPrivateFieldGet2(_httpRequest2$8, this), assetType, body, options);
1322
+ return _upload(_classPrivateFieldGet2(_client$9, this), _classPrivateFieldGet2(_httpRequest2$9, this), assetType, body, options);
1313
1323
  }
1314
- }, _client2$7 = /* @__PURE__ */ new WeakMap(), _httpRequest3 = /* @__PURE__ */ new WeakMap(), AssetsClient = class {
1324
+ }, _client2$8 = /* @__PURE__ */ new WeakMap(), _httpRequest3 = /* @__PURE__ */ new WeakMap(), AssetsClient = class {
1315
1325
  constructor(client, httpRequest) {
1316
- _classPrivateFieldInitSpec(this, _client2$7, void 0), _classPrivateFieldInitSpec(this, _httpRequest3, void 0), _classPrivateFieldSet2(_client2$7, this, client), _classPrivateFieldSet2(_httpRequest3, this, httpRequest);
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$7, this), _classPrivateFieldGet2(_httpRequest3, this), assetType, body, options);
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-CwpNx7Vl.js"), req = _prepareRequest(client, { ...baseRequest });
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$1(query, params, opts = {}) {
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$7 = /* @__PURE__ */ new WeakMap(), _httpRequest$7 = /* @__PURE__ */ new WeakMap(), ObservableCollaborationCommentsClient = class {
1642
+ var _client$8 = /* @__PURE__ */ new WeakMap(), _httpRequest$8 = /* @__PURE__ */ new WeakMap(), ObservableCollaborationCommentsClient = class {
1632
1643
  constructor(client, httpRequest) {
1633
- _classPrivateFieldInitSpec(this, _client$7, void 0), _classPrivateFieldInitSpec(this, _httpRequest$7, void 0), _classPrivateFieldSet2(_client$7, this, client), _classPrivateFieldSet2(_httpRequest$7, this, httpRequest);
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$7, this), _classPrivateFieldGet2(_httpRequest$7, this), body, options);
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$7, this), _classPrivateFieldGet2(_httpRequest$7, this), id, body, options);
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$7, this), _classPrivateFieldGet2(_httpRequest$7, this), id, options);
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$7, this), _classPrivateFieldGet2(_httpRequest$7, this), id, shortName, options);
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$7, this), _classPrivateFieldGet2(_httpRequest$7, this), id, shortName, options);
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$7, this), documentId);
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$7, this), _classPrivateFieldGet2(_httpRequest$7, this), query, params, options);
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$7, this), query, params, options);
1745
+ return _listen$1(_classPrivateFieldGet2(_client$8, this), query, params, options);
1735
1746
  }
1736
- }, _client2$6 = /* @__PURE__ */ new WeakMap(), _httpRequest2$7 = /* @__PURE__ */ new WeakMap(), CollaborationCommentsClient = class {
1747
+ }, _client2$7 = /* @__PURE__ */ new WeakMap(), _httpRequest2$8 = /* @__PURE__ */ new WeakMap(), CollaborationCommentsClient = class {
1737
1748
  constructor(client, httpRequest) {
1738
- _classPrivateFieldInitSpec(this, _client2$6, void 0), _classPrivateFieldInitSpec(this, _httpRequest2$7, void 0), _classPrivateFieldSet2(_client2$6, this, client), _classPrivateFieldSet2(_httpRequest2$7, this, httpRequest);
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$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), body, options));
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$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), id, body, options));
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$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), id, options));
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$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), id, shortName, options));
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$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), id, shortName, options));
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$6, this), documentId);
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$6, this), _classPrivateFieldGet2(_httpRequest2$7, this), query, params, options));
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,17 +3684,98 @@ 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), _classPrivateFieldInitSpec(this, _clientConfig, void 0), _classPrivateFieldInitSpec(this, _httpRequest, void 0), _defineProperty(
3687
+ _defineProperty(
3688
+ this,
3689
+ /**
3690
+ * Upload, fetch and delete assets (images and files) in the configured dataset
3691
+ *
3692
+ * @category Assets
3693
+ */
3694
+ "assets",
3695
+ void 0
3696
+ ), _defineProperty(
3697
+ this,
3698
+ /**
3699
+ * Create, list, edit and delete datasets in the configured project
3700
+ *
3701
+ * @category Projects & Datasets
3702
+ */
3703
+ "datasets",
3704
+ void 0
3705
+ ), _defineProperty(
3706
+ this,
3707
+ /**
3708
+ * Subscribe to live content updates through the Live Content API
3709
+ *
3710
+ * @category Real-time
3711
+ */
3712
+ "live",
3713
+ void 0
3714
+ ), _defineProperty(
3715
+ this,
3716
+ /**
3717
+ * Interact with Media Library assets
3718
+ *
3719
+ * @category Assets
3720
+ */
3721
+ "mediaLibrary",
3722
+ void 0
3723
+ ), _defineProperty(
3724
+ this,
3725
+ /**
3726
+ * Fetch information about the projects the authenticated user has access to
3727
+ *
3728
+ * @category Projects & Datasets
3729
+ */
3730
+ "projects",
3731
+ void 0
3732
+ ), _defineProperty(
3733
+ this,
3734
+ /**
3735
+ * Fetch information about users in the configured project
3736
+ *
3737
+ * @category Projects & Datasets
3738
+ */
3739
+ "users",
3740
+ void 0
3741
+ ), _defineProperty(
2861
3742
  this,
2862
3743
  /**
2863
- * Instance properties
3744
+ * Run Agent Actions - AI-powered operations to generate, transform, translate, prompt and patch documents
3745
+ *
3746
+ * @category Agent Actions
3747
+ */
3748
+ "agent",
3749
+ void 0
3750
+ ), _defineProperty(this, "collaboration", void 0), _defineProperty(this, "functions", void 0), _defineProperty(
3751
+ this,
3752
+ /**
3753
+ * Create and manage content releases and their scheduled publishing
3754
+ *
3755
+ * @category Releases
3756
+ */
3757
+ "releases",
3758
+ void 0
3759
+ ), _defineProperty(
3760
+ this,
3761
+ /** @beta */
3762
+ "context",
3763
+ void 0
3764
+ ), _classPrivateFieldInitSpec(this, _clientConfig, void 0), _classPrivateFieldInitSpec(this, _httpRequest, void 0), _defineProperty(
3765
+ this,
3766
+ /**
3767
+ * Listen to document changes matching a GROQ query, delivered as server-sent events
3768
+ *
3769
+ * @category Real-time
2864
3770
  */
2865
3771
  "listen",
2866
- _listen$1
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));
3772
+ _listen$2
3773
+ ), 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
3774
  }
2869
3775
  /**
2870
3776
  * Clone the client - returns a new instance
3777
+ *
3778
+ * @category Configuration
2871
3779
  */
2872
3780
  clone() {
2873
3781
  return new ObservableSanityClient(_classPrivateFieldGet2(_httpRequest, this), this.config());
@@ -2880,6 +3788,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
2880
3788
  /**
2881
3789
  * Clone the client with a new (partial) configuration.
2882
3790
  *
3791
+ * @category Configuration
3792
+ *
2883
3793
  * @param newConfig - New client configuration properties, shallowly merged with existing configuration
2884
3794
  */
2885
3795
  withConfig(newConfig) {
@@ -2915,6 +3825,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
2915
3825
  * The order/position of documents is preserved based on the original array of IDs.
2916
3826
  * If any of the documents are missing, they will be replaced by a `null` entry in the returned array
2917
3827
  *
3828
+ * @category Querying
3829
+ *
2918
3830
  * @param ids - Document IDs to fetch
2919
3831
  * @param options - Request options
2920
3832
  */
@@ -2925,6 +3837,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
2925
3837
  * Convenient and bandwidth efficient method of checking wether a set of document IDs exists.
2926
3838
  * Returns a set of the IDs that exist.
2927
3839
  *
3840
+ * @category Querying
3841
+ *
2928
3842
  * @param ids - Document IDs to check
2929
3843
  * @param options - Request options
2930
3844
  */
@@ -2964,6 +3878,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
2964
3878
  * * Discarding a version with no `releaseId` will discard the draft version of the published document.
2965
3879
  * * If the draft or release version does not exist, any error will throw.
2966
3880
  *
3881
+ * @category Versions
3882
+ *
2967
3883
  * @param params - Version action parameters:
2968
3884
  * - `releaseId` - The ID of the release to discard the document from.
2969
3885
  * - `publishedId` - The published ID of the document to discard.
@@ -3007,6 +3923,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
3007
3923
  * @remarks
3008
3924
  * * If the published document does not exist, an error will be thrown.
3009
3925
  *
3926
+ * @category Versions
3927
+ *
3010
3928
  * @param params - Version action parameters:
3011
3929
  * - `releaseId` - The ID of the release to unpublish the document from.
3012
3930
  * - `publishedId` - The published ID of the document to unpublish.
@@ -3039,6 +3957,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
3039
3957
  /**
3040
3958
  * Create a new transaction of mutations
3041
3959
  *
3960
+ * @category Mutations
3961
+ *
3042
3962
  * @param operations - Optional array of mutation operations to initialize the transaction instance with
3043
3963
  */
3044
3964
  transaction(operations) {
@@ -3047,6 +3967,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
3047
3967
  /**
3048
3968
  * Perform action operations against the configured dataset
3049
3969
  *
3970
+ * @category Mutations
3971
+ *
3050
3972
  * @param operations - Action operation(s) to execute
3051
3973
  * @param options - Action options
3052
3974
  */
@@ -3056,6 +3978,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
3056
3978
  /**
3057
3979
  * Perform an HTTP request against the Sanity API
3058
3980
  *
3981
+ * @category HTTP
3982
+ *
3059
3983
  * @param options - Request options
3060
3984
  */
3061
3985
  request(options) {
@@ -3064,6 +3988,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
3064
3988
  /**
3065
3989
  * Get a Sanity API URL for the URI provided
3066
3990
  *
3991
+ * @category HTTP
3992
+ *
3067
3993
  * @param uri - URI/path to build URL for
3068
3994
  * @param canUseCdn - Whether or not to allow using the API CDN for this route
3069
3995
  */
@@ -3073,6 +3999,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
3073
3999
  /**
3074
4000
  * Get a Sanity API URL for the data operation and path provided
3075
4001
  *
4002
+ * @category HTTP
4003
+ *
3076
4004
  * @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
3077
4005
  * @param path - Path to append after the operation
3078
4006
  */
@@ -3081,24 +4009,107 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
3081
4009
  }
3082
4010
  }, _clientConfig2 = /* @__PURE__ */ new WeakMap(), _httpRequest2 = /* @__PURE__ */ new WeakMap(), SanityClient = class SanityClient {
3083
4011
  constructor(httpRequest, config = defaultConfig) {
3084
- _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(
4012
+ _defineProperty(
4013
+ this,
4014
+ /**
4015
+ * Upload, fetch and delete assets (images and files) in the configured dataset
4016
+ *
4017
+ * @category Assets
4018
+ */
4019
+ "assets",
4020
+ void 0
4021
+ ), _defineProperty(
4022
+ this,
4023
+ /**
4024
+ * Create, list, edit and delete datasets in the configured project
4025
+ *
4026
+ * @category Projects & Datasets
4027
+ */
4028
+ "datasets",
4029
+ void 0
4030
+ ), _defineProperty(
4031
+ this,
4032
+ /**
4033
+ * Subscribe to live content updates through the Live Content API
4034
+ *
4035
+ * @category Real-time
4036
+ */
4037
+ "live",
4038
+ void 0
4039
+ ), _defineProperty(
4040
+ this,
4041
+ /**
4042
+ * Interact with Media Library assets
4043
+ *
4044
+ * @category Assets
4045
+ */
4046
+ "mediaLibrary",
4047
+ void 0
4048
+ ), _defineProperty(
4049
+ this,
4050
+ /**
4051
+ * Fetch information about the projects the authenticated user has access to
4052
+ *
4053
+ * @category Projects & Datasets
4054
+ */
4055
+ "projects",
4056
+ void 0
4057
+ ), _defineProperty(
4058
+ this,
4059
+ /**
4060
+ * Fetch information about users in the configured project
4061
+ *
4062
+ * @category Projects & Datasets
4063
+ */
4064
+ "users",
4065
+ void 0
4066
+ ), _defineProperty(
4067
+ this,
4068
+ /**
4069
+ * Run Agent Actions - AI-powered operations to generate, transform, translate, prompt and patch documents
4070
+ *
4071
+ * @category Agent Actions
4072
+ */
4073
+ "agent",
4074
+ void 0
4075
+ ), _defineProperty(this, "collaboration", void 0), _defineProperty(this, "functions", void 0), _defineProperty(
4076
+ this,
4077
+ /**
4078
+ * Create and manage content releases and their scheduled publishing
4079
+ *
4080
+ * @category Releases
4081
+ */
4082
+ "releases",
4083
+ void 0
4084
+ ), _defineProperty(
4085
+ this,
4086
+ /** @beta */
4087
+ "context",
4088
+ void 0
4089
+ ), _defineProperty(
3085
4090
  this,
3086
4091
  /**
3087
4092
  * Observable version of the Sanity client, with the same configuration as the promise-based one
4093
+ *
4094
+ * @category Configuration
3088
4095
  */
3089
4096
  "observable",
3090
4097
  void 0
3091
4098
  ), _classPrivateFieldInitSpec(this, _clientConfig2, void 0), _classPrivateFieldInitSpec(this, _httpRequest2, void 0), _defineProperty(
3092
4099
  this,
3093
4100
  /**
3094
- * Instance properties
4101
+ * Listen to document changes matching a GROQ query, delivered as server-sent events
4102
+ *
4103
+ * @category Real-time
3095
4104
  */
3096
4105
  "listen",
3097
- _listen$1
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);
4106
+ _listen$2
4107
+ ), 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
4108
  }
3100
4109
  /**
3101
4110
  * Clone the client - returns a new instance
4111
+ *
4112
+ * @category Configuration
3102
4113
  */
3103
4114
  clone() {
3104
4115
  return new SanityClient(_classPrivateFieldGet2(_httpRequest2, this), this.config());
@@ -3111,6 +4122,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
3111
4122
  /**
3112
4123
  * Clone the client with a new (partial) configuration.
3113
4124
  *
4125
+ * @category Configuration
4126
+ *
3114
4127
  * @param newConfig - New client configuration properties, shallowly merged with existing configuration
3115
4128
  */
3116
4129
  withConfig(newConfig) {
@@ -3125,7 +4138,7 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
3125
4138
  });
3126
4139
  }
3127
4140
  fetch(query, params, options) {
3128
- return _fetch$1(this, _classPrivateFieldGet2(_httpRequest2, this), _classPrivateFieldGet2(_clientConfig2, this).stega, query, params, options);
4141
+ return _fetch$2(this, _classPrivateFieldGet2(_httpRequest2, this), _classPrivateFieldGet2(_clientConfig2, this).stega, query, params, options);
3129
4142
  }
3130
4143
  getDocument(id, options) {
3131
4144
  if (options?.includeAllVersions === !0) return _getDocument(this, _classPrivateFieldGet2(_httpRequest2, this), id, {
@@ -3146,6 +4159,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
3146
4159
  * The order/position of documents is preserved based on the original array of IDs.
3147
4160
  * If any of the documents are missing, they will be replaced by a `null` entry in the returned array
3148
4161
  *
4162
+ * @category Querying
4163
+ *
3149
4164
  * @param ids - Document IDs to fetch
3150
4165
  * @param options - Request options
3151
4166
  */
@@ -3156,6 +4171,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
3156
4171
  * Convenient and bandwidth efficient method of checking wether a set of document IDs exists.
3157
4172
  * Returns a set of the IDs that exist.
3158
4173
  *
4174
+ * @category Querying
4175
+ *
3159
4176
  * @param ids - Document IDs to check
3160
4177
  * @param options - Request options
3161
4178
  */
@@ -3195,6 +4212,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
3195
4212
  * * Discarding a version with no `releaseId` will discard the draft version of the published document.
3196
4213
  * * If the draft or release version does not exist, any error will throw.
3197
4214
  *
4215
+ * @category Versions
4216
+ *
3198
4217
  * @param params - Version action parameters:
3199
4218
  * - `releaseId` - The ID of the release to discard the document from.
3200
4219
  * - `publishedId` - The published ID of the document to discard.
@@ -3238,6 +4257,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
3238
4257
  * @remarks
3239
4258
  * * If the published document does not exist, an error will be thrown.
3240
4259
  *
4260
+ * @category Versions
4261
+ *
3241
4262
  * @param params - Version action parameters:
3242
4263
  * - `releaseId` - The ID of the release to unpublish the document from.
3243
4264
  * - `publishedId` - The published ID of the document to unpublish.
@@ -3270,6 +4291,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
3270
4291
  /**
3271
4292
  * Create a new transaction of mutations
3272
4293
  *
4294
+ * @category Mutations
4295
+ *
3273
4296
  * @param operations - Optional array of mutation operations to initialize the transaction instance with
3274
4297
  */
3275
4298
  transaction(operations) {
@@ -3279,6 +4302,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
3279
4302
  * Perform action operations against the configured dataset
3280
4303
  * Returns a promise that resolves to the transaction result
3281
4304
  *
4305
+ * @category Mutations
4306
+ *
3282
4307
  * @param operations - Action operation(s) to execute
3283
4308
  * @param options - Action options
3284
4309
  */
@@ -3289,6 +4314,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
3289
4314
  * Perform a request against the Sanity API
3290
4315
  * NOTE: Only use this for Sanity API endpoints, not for your own APIs!
3291
4316
  *
4317
+ * @category HTTP
4318
+ *
3292
4319
  * @param options - Request options
3293
4320
  * @returns Promise resolving to the response body
3294
4321
  */
@@ -3311,6 +4338,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
3311
4338
  /**
3312
4339
  * Get a Sanity API URL for the URI provided
3313
4340
  *
4341
+ * @category HTTP
4342
+ *
3314
4343
  * @param uri - URI/path to build URL for
3315
4344
  * @param canUseCdn - Whether or not to allow using the API CDN for this route
3316
4345
  */
@@ -3320,6 +4349,8 @@ var _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */
3320
4349
  /**
3321
4350
  * Get a Sanity API URL for the data operation and path provided
3322
4351
  *
4352
+ * @category HTTP
4353
+ *
3323
4354
  * @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
3324
4355
  * @param path - Path to append after the operation
3325
4356
  */
@@ -3358,6 +4389,6 @@ function defineDeprecatedCreateClient(createClient) {
3358
4389
  };
3359
4390
  }
3360
4391
  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 };
4392
+ 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
4393
 
3363
4394
  //# sourceMappingURL=index.js.map