@sanity/client 8.4.0 → 8.6.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 (42) hide show
  1. package/README.md +80 -4
  2. package/dist/{browserUpload-C7PwCs-C.js → browserUpload-CXcfRh-z.js} +2 -2
  3. package/dist/{browserUpload-C7PwCs-C.js.map → browserUpload-CXcfRh-z.js.map} +1 -1
  4. package/dist/{browserUpload-D-2Rmfjo.js → browserUpload-D3ST_REr.js} +2 -2
  5. package/dist/{browserUpload-D-2Rmfjo.js.map → browserUpload-D3ST_REr.js.map} +1 -1
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.js +204 -9
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.node.d.ts +325 -23
  10. package/dist/index.node.js +154 -16
  11. package/dist/index.node.js.map +1 -1
  12. package/dist/media-library.d.ts +1 -1
  13. package/dist/{request-SnMg7nUX.js → request-BzWeXkUo.js} +3 -2
  14. package/dist/request-BzWeXkUo.js.map +1 -0
  15. package/dist/{request-BhMuKj0D.js → request-SY_xwBuz.js} +3 -2
  16. package/dist/request-SY_xwBuz.js.map +1 -0
  17. package/dist/stega.js +2 -2
  18. package/dist/{dist-Z8cIRxoB.js → stegaClean-YZRATV86.js} +19 -2
  19. package/dist/stegaClean-YZRATV86.js.map +1 -0
  20. package/dist/{stegaEncodeSourceMap-YR3NQ3iz.js → stegaEncodeSourceMap-Dj29aWKG.js} +2 -2
  21. package/dist/{stegaEncodeSourceMap-YR3NQ3iz.js.map → stegaEncodeSourceMap-Dj29aWKG.js.map} +1 -1
  22. package/dist/{types-DiPF0ENT.d.ts → types-B1XLvey7.d.ts} +326 -24
  23. package/package.json +17 -14
  24. package/src/SanityClient.ts +176 -9
  25. package/src/agent/actions/AgentActionsClient.ts +8 -2
  26. package/src/assets/AssetsClient.ts +8 -2
  27. package/src/context/openapi.json +663 -2
  28. package/src/context/types.gen.ts +48 -1
  29. package/src/data/dataMethods.ts +2 -5
  30. package/src/data/live.ts +1 -0
  31. package/src/datasets/DatasetsClient.ts +8 -2
  32. package/src/http/request.ts +2 -10
  33. package/src/mediaLibrary/MediaLibraryVideoClient.ts +8 -2
  34. package/src/projects/ProjectsClient.ts +8 -2
  35. package/src/releases/ReleasesClient.ts +8 -2
  36. package/src/types.ts +49 -6
  37. package/src/users/UsersClient.ts +8 -2
  38. package/dist/dist-Z8cIRxoB.js.map +0 -1
  39. package/dist/request-BhMuKj0D.js.map +0 -1
  40. package/dist/request-SnMg7nUX.js.map +0 -1
  41. package/dist/stegaClean-C18wLWau.js +0 -21
  42. package/dist/stegaClean-C18wLWau.js.map +0 -1
@@ -1,7 +1,8 @@
1
1
  import { n as __exportAll } from "./rolldown-runtime-4YWMqDIC.js";
2
- import { a as ServerError, c as isHttpError, i as CorsOriginError, l as isQueryParseError, o as formatQueryParseError, r as ClientError, t as defineRequester } from "./request-SnMg7nUX.js";
2
+ import { a as ServerError, c as isHttpError, i as CorsOriginError, l as isQueryParseError, o as formatQueryParseError, r as ClientError, t as defineRequester } from "./request-BzWeXkUo.js";
3
3
  import { t as isRecord } from "./isRecord-Kfmt-nk-.js";
4
4
  import { t as require_dist } from "./dist-C5K_YcEU.js";
5
+ import { anySignal } from "any-signal";
5
6
  import { isTimeoutError } from "get-it";
6
7
  import { debug } from "get-it/middleware";
7
8
  import { Observable, catchError, concat, defer, finalize, isObservable, lastValueFrom, map, merge, mergeMap, of, share, tap, throwError, timer } from "rxjs";
@@ -1204,7 +1205,7 @@ function _prepareRequest(client, options) {
1204
1205
  function _observe(userSignal, run) {
1205
1206
  return new Observable((subscriber) => {
1206
1207
  let controller = new AbortController();
1207
- return run(userSignal ? AbortSignal.any([userSignal, controller.signal]) : controller.signal).then((value) => {
1208
+ return run(userSignal ? anySignal([userSignal, controller.signal]) : controller.signal).then((value) => {
1208
1209
  subscriber.next(value), subscriber.complete();
1209
1210
  }, (err) => subscriber.error(err)), () => controller.abort();
1210
1211
  });
@@ -1373,7 +1374,10 @@ function _translate(client, httpRequest, request) {
1373
1374
  body: request
1374
1375
  });
1375
1376
  }
1376
- /** @public */
1377
+ /**
1378
+ * @public
1379
+ * @inline
1380
+ */
1377
1381
  var ObservableAgentsActionClient = class {
1378
1382
  #client;
1379
1383
  #httpRequest;
@@ -1502,7 +1506,7 @@ function _upload(client, _httpRequest, assetType, body, opts = {}) {
1502
1506
  body
1503
1507
  };
1504
1508
  return typeof XMLHttpRequest < "u" ? defer(async () => {
1505
- let { uploadWithProgress } = await import("./browserUpload-C7PwCs-C.js"), req = _prepareRequest(client, { ...baseRequest });
1509
+ let { uploadWithProgress } = await import("./browserUpload-D3ST_REr.js"), req = _prepareRequest(client, { ...baseRequest });
1506
1510
  return uploadWithProgress({
1507
1511
  url: appendQuery(req.url, req.query),
1508
1512
  method: req.method ?? "POST",
@@ -2819,6 +2823,7 @@ function _shareReplayLatest(config) {
2819
2823
  const requiredApiVersion = "2021-03-25";
2820
2824
  /**
2821
2825
  * @public
2826
+ * @inline
2822
2827
  */
2823
2828
  var LiveClient = class {
2824
2829
  #client;
@@ -2945,7 +2950,10 @@ function checkCorsObservable(url, projectId, requireCredentials, fetcher) {
2945
2950
  * resolver — `undefined` covers the `globalThis.fetch` fallback.
2946
2951
  */
2947
2952
  const eventsCache = /* @__PURE__ */ new Map();
2948
- /** @internal */
2953
+ /**
2954
+ * @internal
2955
+ * @inline
2956
+ */
2949
2957
  var ObservableDatasetsClient = class {
2950
2958
  #client;
2951
2959
  #httpRequest;
@@ -3260,7 +3268,10 @@ function buildQueryParams(options) {
3260
3268
  }
3261
3269
  return options.expiration && (params.expiration = options.expiration), params;
3262
3270
  }
3263
- /** @internal */
3271
+ /**
3272
+ * @internal
3273
+ * @inline
3274
+ */
3264
3275
  var ObservableProjectsClient = class {
3265
3276
  #client;
3266
3277
  #httpRequest;
@@ -3387,7 +3398,10 @@ const getArgs = (releaseOrOptions, maybeOptions) => {
3387
3398
  options
3388
3399
  };
3389
3400
  };
3390
- /** @public */
3401
+ /**
3402
+ * @public
3403
+ * @inline
3404
+ */
3391
3405
  var ObservableReleasesClient = class {
3392
3406
  #client;
3393
3407
  #httpRequest;
@@ -3842,25 +3856,64 @@ var ObservableReleasesClient = class {
3842
3856
  return _request(this.#client, this.#httpRequest, { url: `/users/${id}` });
3843
3857
  }
3844
3858
  }, ObservableSanityClient = class ObservableSanityClient {
3859
+ /**
3860
+ * Upload, fetch and delete assets (images and files) in the configured dataset
3861
+ *
3862
+ * @category Assets
3863
+ */
3845
3864
  assets;
3865
+ /**
3866
+ * Create, list, edit and delete datasets in the configured project
3867
+ *
3868
+ * @category Projects & Datasets
3869
+ */
3846
3870
  datasets;
3871
+ /**
3872
+ * Subscribe to live content updates through the Live Content API
3873
+ *
3874
+ * @category Real-time
3875
+ */
3847
3876
  live;
3877
+ /**
3878
+ * Interact with Media Library assets
3879
+ *
3880
+ * @category Assets
3881
+ */
3848
3882
  mediaLibrary;
3883
+ /**
3884
+ * Fetch information about the projects the authenticated user has access to
3885
+ *
3886
+ * @category Projects & Datasets
3887
+ */
3849
3888
  projects;
3889
+ /**
3890
+ * Fetch information about users in the configured project
3891
+ *
3892
+ * @category Projects & Datasets
3893
+ */
3850
3894
  users;
3895
+ /**
3896
+ * Run Agent Actions - AI-powered operations to generate, transform, translate, prompt and patch documents
3897
+ *
3898
+ * @category Agent Actions
3899
+ */
3851
3900
  agent;
3852
3901
  collaboration;
3853
3902
  functions;
3903
+ /**
3904
+ * Create and manage content releases and their scheduled publishing
3905
+ *
3906
+ * @category Releases
3907
+ */
3854
3908
  releases;
3855
3909
  /** @beta */
3856
3910
  context;
3857
- /**
3858
- * Private properties
3859
- */
3860
3911
  #clientConfig;
3861
3912
  #httpRequest;
3862
3913
  /**
3863
- * Instance properties
3914
+ * Listen to document changes matching a GROQ query, delivered as server-sent events
3915
+ *
3916
+ * @category Real-time
3864
3917
  */
3865
3918
  listen = _listen$2;
3866
3919
  constructor(httpRequest, config = defaultConfig) {
@@ -3868,6 +3921,8 @@ var ObservableReleasesClient = class {
3868
3921
  }
3869
3922
  /**
3870
3923
  * Clone the client - returns a new instance
3924
+ *
3925
+ * @category Configuration
3871
3926
  */
3872
3927
  clone() {
3873
3928
  return new ObservableSanityClient(this.#httpRequest, this.config());
@@ -3880,6 +3935,8 @@ var ObservableReleasesClient = class {
3880
3935
  /**
3881
3936
  * Clone the client with a new (partial) configuration.
3882
3937
  *
3938
+ * @category Configuration
3939
+ *
3883
3940
  * @param newConfig - New client configuration properties, shallowly merged with existing configuration
3884
3941
  */
3885
3942
  withConfig(newConfig) {
@@ -3915,6 +3972,8 @@ var ObservableReleasesClient = class {
3915
3972
  * The order/position of documents is preserved based on the original array of IDs.
3916
3973
  * If any of the documents are missing, they will be replaced by a `null` entry in the returned array
3917
3974
  *
3975
+ * @category Querying
3976
+ *
3918
3977
  * @param ids - Document IDs to fetch
3919
3978
  * @param options - Request options
3920
3979
  */
@@ -3925,6 +3984,8 @@ var ObservableReleasesClient = class {
3925
3984
  * Convenient and bandwidth efficient method of checking wether a set of document IDs exists.
3926
3985
  * Returns a set of the IDs that exist.
3927
3986
  *
3987
+ * @category Querying
3988
+ *
3928
3989
  * @param ids - Document IDs to check
3929
3990
  * @param options - Request options
3930
3991
  */
@@ -3964,6 +4025,8 @@ var ObservableReleasesClient = class {
3964
4025
  * * Discarding a version with no `releaseId` will discard the draft version of the published document.
3965
4026
  * * If the draft or release version does not exist, any error will throw.
3966
4027
  *
4028
+ * @category Versions
4029
+ *
3967
4030
  * @param params - Version action parameters:
3968
4031
  * - `releaseId` - The ID of the release to discard the document from.
3969
4032
  * - `publishedId` - The published ID of the document to discard.
@@ -4007,6 +4070,8 @@ var ObservableReleasesClient = class {
4007
4070
  * @remarks
4008
4071
  * * If the published document does not exist, an error will be thrown.
4009
4072
  *
4073
+ * @category Versions
4074
+ *
4010
4075
  * @param params - Version action parameters:
4011
4076
  * - `releaseId` - The ID of the release to unpublish the document from.
4012
4077
  * - `publishedId` - The published ID of the document to unpublish.
@@ -4039,6 +4104,8 @@ var ObservableReleasesClient = class {
4039
4104
  /**
4040
4105
  * Create a new transaction of mutations
4041
4106
  *
4107
+ * @category Mutations
4108
+ *
4042
4109
  * @param operations - Optional array of mutation operations to initialize the transaction instance with
4043
4110
  */
4044
4111
  transaction(operations) {
@@ -4047,6 +4114,8 @@ var ObservableReleasesClient = class {
4047
4114
  /**
4048
4115
  * Perform action operations against the configured dataset
4049
4116
  *
4117
+ * @category Mutations
4118
+ *
4050
4119
  * @param operations - Action operation(s) to execute
4051
4120
  * @param options - Action options
4052
4121
  */
@@ -4056,6 +4125,8 @@ var ObservableReleasesClient = class {
4056
4125
  /**
4057
4126
  * Perform an HTTP request against the Sanity API
4058
4127
  *
4128
+ * @category HTTP
4129
+ *
4059
4130
  * @param options - Request options
4060
4131
  */
4061
4132
  request(options) {
@@ -4064,6 +4135,8 @@ var ObservableReleasesClient = class {
4064
4135
  /**
4065
4136
  * Get a Sanity API URL for the URI provided
4066
4137
  *
4138
+ * @category HTTP
4139
+ *
4067
4140
  * @param uri - URI/path to build URL for
4068
4141
  * @param canUseCdn - Whether or not to allow using the API CDN for this route
4069
4142
  */
@@ -4073,6 +4146,8 @@ var ObservableReleasesClient = class {
4073
4146
  /**
4074
4147
  * Get a Sanity API URL for the data operation and path provided
4075
4148
  *
4149
+ * @category HTTP
4150
+ *
4076
4151
  * @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
4077
4152
  * @param path - Path to append after the operation
4078
4153
  */
@@ -4080,29 +4155,70 @@ var ObservableReleasesClient = class {
4080
4155
  return _getDataUrl(this, operation, path);
4081
4156
  }
4082
4157
  }, SanityClient = class SanityClient {
4158
+ /**
4159
+ * Upload, fetch and delete assets (images and files) in the configured dataset
4160
+ *
4161
+ * @category Assets
4162
+ */
4083
4163
  assets;
4164
+ /**
4165
+ * Create, list, edit and delete datasets in the configured project
4166
+ *
4167
+ * @category Projects & Datasets
4168
+ */
4084
4169
  datasets;
4170
+ /**
4171
+ * Subscribe to live content updates through the Live Content API
4172
+ *
4173
+ * @category Real-time
4174
+ */
4085
4175
  live;
4176
+ /**
4177
+ * Interact with Media Library assets
4178
+ *
4179
+ * @category Assets
4180
+ */
4086
4181
  mediaLibrary;
4182
+ /**
4183
+ * Fetch information about the projects the authenticated user has access to
4184
+ *
4185
+ * @category Projects & Datasets
4186
+ */
4087
4187
  projects;
4188
+ /**
4189
+ * Fetch information about users in the configured project
4190
+ *
4191
+ * @category Projects & Datasets
4192
+ */
4088
4193
  users;
4194
+ /**
4195
+ * Run Agent Actions - AI-powered operations to generate, transform, translate, prompt and patch documents
4196
+ *
4197
+ * @category Agent Actions
4198
+ */
4089
4199
  agent;
4090
4200
  collaboration;
4091
4201
  functions;
4202
+ /**
4203
+ * Create and manage content releases and their scheduled publishing
4204
+ *
4205
+ * @category Releases
4206
+ */
4092
4207
  releases;
4093
4208
  /** @beta */
4094
4209
  context;
4095
4210
  /**
4096
4211
  * Observable version of the Sanity client, with the same configuration as the promise-based one
4212
+ *
4213
+ * @category Configuration
4097
4214
  */
4098
4215
  observable;
4099
- /**
4100
- * Private properties
4101
- */
4102
4216
  #clientConfig;
4103
4217
  #httpRequest;
4104
4218
  /**
4105
- * Instance properties
4219
+ * Listen to document changes matching a GROQ query, delivered as server-sent events
4220
+ *
4221
+ * @category Real-time
4106
4222
  */
4107
4223
  listen = _listen$2;
4108
4224
  constructor(httpRequest, config = defaultConfig) {
@@ -4110,6 +4226,8 @@ var ObservableReleasesClient = class {
4110
4226
  }
4111
4227
  /**
4112
4228
  * Clone the client - returns a new instance
4229
+ *
4230
+ * @category Configuration
4113
4231
  */
4114
4232
  clone() {
4115
4233
  return new SanityClient(this.#httpRequest, this.config());
@@ -4122,6 +4240,8 @@ var ObservableReleasesClient = class {
4122
4240
  /**
4123
4241
  * Clone the client with a new (partial) configuration.
4124
4242
  *
4243
+ * @category Configuration
4244
+ *
4125
4245
  * @param newConfig - New client configuration properties, shallowly merged with existing configuration
4126
4246
  */
4127
4247
  withConfig(newConfig) {
@@ -4157,6 +4277,8 @@ var ObservableReleasesClient = class {
4157
4277
  * The order/position of documents is preserved based on the original array of IDs.
4158
4278
  * If any of the documents are missing, they will be replaced by a `null` entry in the returned array
4159
4279
  *
4280
+ * @category Querying
4281
+ *
4160
4282
  * @param ids - Document IDs to fetch
4161
4283
  * @param options - Request options
4162
4284
  */
@@ -4167,6 +4289,8 @@ var ObservableReleasesClient = class {
4167
4289
  * Convenient and bandwidth efficient method of checking wether a set of document IDs exists.
4168
4290
  * Returns a set of the IDs that exist.
4169
4291
  *
4292
+ * @category Querying
4293
+ *
4170
4294
  * @param ids - Document IDs to check
4171
4295
  * @param options - Request options
4172
4296
  */
@@ -4206,6 +4330,8 @@ var ObservableReleasesClient = class {
4206
4330
  * * Discarding a version with no `releaseId` will discard the draft version of the published document.
4207
4331
  * * If the draft or release version does not exist, any error will throw.
4208
4332
  *
4333
+ * @category Versions
4334
+ *
4209
4335
  * @param params - Version action parameters:
4210
4336
  * - `releaseId` - The ID of the release to discard the document from.
4211
4337
  * - `publishedId` - The published ID of the document to discard.
@@ -4249,6 +4375,8 @@ var ObservableReleasesClient = class {
4249
4375
  * @remarks
4250
4376
  * * If the published document does not exist, an error will be thrown.
4251
4377
  *
4378
+ * @category Versions
4379
+ *
4252
4380
  * @param params - Version action parameters:
4253
4381
  * - `releaseId` - The ID of the release to unpublish the document from.
4254
4382
  * - `publishedId` - The published ID of the document to unpublish.
@@ -4281,6 +4409,8 @@ var ObservableReleasesClient = class {
4281
4409
  /**
4282
4410
  * Create a new transaction of mutations
4283
4411
  *
4412
+ * @category Mutations
4413
+ *
4284
4414
  * @param operations - Optional array of mutation operations to initialize the transaction instance with
4285
4415
  */
4286
4416
  transaction(operations) {
@@ -4290,6 +4420,8 @@ var ObservableReleasesClient = class {
4290
4420
  * Perform action operations against the configured dataset
4291
4421
  * Returns a promise that resolves to the transaction result
4292
4422
  *
4423
+ * @category Mutations
4424
+ *
4293
4425
  * @param operations - Action operation(s) to execute
4294
4426
  * @param options - Action options
4295
4427
  */
@@ -4300,6 +4432,8 @@ var ObservableReleasesClient = class {
4300
4432
  * Perform a request against the Sanity API
4301
4433
  * NOTE: Only use this for Sanity API endpoints, not for your own APIs!
4302
4434
  *
4435
+ * @category HTTP
4436
+ *
4303
4437
  * @param options - Request options
4304
4438
  * @returns Promise resolving to the response body
4305
4439
  */
@@ -4322,6 +4456,8 @@ var ObservableReleasesClient = class {
4322
4456
  /**
4323
4457
  * Get a Sanity API URL for the URI provided
4324
4458
  *
4459
+ * @category HTTP
4460
+ *
4325
4461
  * @param uri - URI/path to build URL for
4326
4462
  * @param canUseCdn - Whether or not to allow using the API CDN for this route
4327
4463
  */
@@ -4331,6 +4467,8 @@ var ObservableReleasesClient = class {
4331
4467
  /**
4332
4468
  * Get a Sanity API URL for the data operation and path provided
4333
4469
  *
4470
+ * @category HTTP
4471
+ *
4334
4472
  * @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
4335
4473
  * @param path - Path to append after the operation
4336
4474
  */
@@ -4368,7 +4506,7 @@ function defineDeprecatedCreateClient(createClient) {
4368
4506
  return printNoDefaultExport(), createClient(config);
4369
4507
  };
4370
4508
  }
4371
- var name = "@sanity/client", version = "8.4.0";
4509
+ var name = "@sanity/client", version = "8.6.0";
4372
4510
  const log = createDebug("sanity:client");
4373
4511
  function isNodeReadableStream(value) {
4374
4512
  return typeof value != "object" || !value || !("pipe" in value) ? !1 : typeof value.pipe == "function";