@sanity/client 6.28.2 → 6.28.3-instruct.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -854,6 +854,42 @@ function optionsFromFile(opts, file) {
854
854
  opts
855
855
  );
856
856
  }
857
+ function _instruct(client, httpRequest, request) {
858
+ const dataset = config.hasDataset(client.config());
859
+ return _request(client, httpRequest, {
860
+ method: "POST",
861
+ uri: `/assist/tasks/instruct/${dataset}`,
862
+ body: request
863
+ });
864
+ }
865
+ class ObservableAssistClient {
866
+ #client;
867
+ #httpRequest;
868
+ constructor(client, httpRequest) {
869
+ this.#client = client, this.#httpRequest = httpRequest;
870
+ }
871
+ /**
872
+ * Run an ad-hoc instruction for a target document.
873
+ * @param request instruction request
874
+ */
875
+ instruct(request) {
876
+ return _instruct(this.#client, this.#httpRequest, request);
877
+ }
878
+ }
879
+ class AssistClient {
880
+ #client;
881
+ #httpRequest;
882
+ constructor(client, httpRequest) {
883
+ this.#client = client, this.#httpRequest = httpRequest;
884
+ }
885
+ /**
886
+ * Run an ad-hoc instruction for a target document.
887
+ * @param request instruction request
888
+ */
889
+ instruct(request) {
890
+ return rxjs.lastValueFrom(_instruct(this.#client, this.#httpRequest, request));
891
+ }
892
+ }
857
893
  var defaults = (obj, defaults2) => Object.keys(defaults2).concat(Object.keys(obj)).reduce((target, prop) => (target[prop] = typeof obj[prop] > "u" ? defaults2[prop] : obj[prop], target), {});
858
894
  const pick = (obj, props) => props.reduce((selection, prop) => (typeof obj[prop] > "u" || (selection[prop] = obj[prop]), selection), {}), eventSourcePolyfill = rxjs.defer(() => import("@sanity/eventsource")).pipe(
859
895
  operators.map(({ default: EventSource2 }) => EventSource2),
@@ -915,7 +951,10 @@ function _shareReplayLatest(config2) {
915
951
  }),
916
952
  rxjs.share(shareConfig)
917
953
  ), emitLatest = new rxjs.Observable((subscriber) => {
918
- emitted && subscriber.next(latest), subscriber.complete();
954
+ emitted && subscriber.next(
955
+ // this cast is safe because of the emitted check which asserts that we got T from the source
956
+ latest
957
+ ), subscriber.complete();
919
958
  });
920
959
  return rxjs.merge(wrapped, emitLatest);
921
960
  };
@@ -1186,6 +1225,7 @@ class ObservableSanityClient {
1186
1225
  live;
1187
1226
  projects;
1188
1227
  users;
1228
+ assist;
1189
1229
  /**
1190
1230
  * Private properties
1191
1231
  */
@@ -1196,7 +1236,7 @@ class ObservableSanityClient {
1196
1236
  */
1197
1237
  listen = _listen;
1198
1238
  constructor(httpRequest, config$1 = config.defaultConfig) {
1199
- this.config(config$1), this.#httpRequest = httpRequest, this.assets = new ObservableAssetsClient(this, this.#httpRequest), this.datasets = new ObservableDatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ObservableProjectsClient(this, this.#httpRequest), this.users = new ObservableUsersClient(this, this.#httpRequest);
1239
+ this.config(config$1), this.#httpRequest = httpRequest, this.assets = new ObservableAssetsClient(this, this.#httpRequest), this.datasets = new ObservableDatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ObservableProjectsClient(this, this.#httpRequest), this.users = new ObservableUsersClient(this, this.#httpRequest), this.assist = new ObservableAssistClient(this, this.#httpRequest);
1200
1240
  }
1201
1241
  /**
1202
1242
  * Clone the client - returns a new instance
@@ -1335,6 +1375,7 @@ class SanityClient {
1335
1375
  live;
1336
1376
  projects;
1337
1377
  users;
1378
+ assist;
1338
1379
  /**
1339
1380
  * Observable version of the Sanity client, with the same configuration as the promise-based one
1340
1381
  */
@@ -1349,7 +1390,7 @@ class SanityClient {
1349
1390
  */
1350
1391
  listen = _listen;
1351
1392
  constructor(httpRequest, config$1 = config.defaultConfig) {
1352
- this.config(config$1), this.#httpRequest = httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.observable = new ObservableSanityClient(httpRequest, config$1);
1393
+ this.config(config$1), this.#httpRequest = httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.assist = new AssistClient(this, this.#httpRequest), this.observable = new ObservableSanityClient(httpRequest, config$1);
1353
1394
  }
1354
1395
  /**
1355
1396
  * Clone the client - returns a new instance
@@ -1525,7 +1566,7 @@ function defineDeprecatedCreateClient(createClient2) {
1525
1566
  return config.printNoDefaultExport(), createClient2(config$1);
1526
1567
  };
1527
1568
  }
1528
- var name = "@sanity/client", version = "6.28.2";
1569
+ var name = "@sanity/client", version = "6.28.3-instruct.0";
1529
1570
  const middleware = [
1530
1571
  middleware$1.debug({ verbose: !0, namespace: "sanity:client" }),
1531
1572
  middleware$1.headers({ "User-Agent": `${name} ${version}` }),