@sanity/client 6.27.3-canary.2 → 6.28.0-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
@@ -745,10 +745,11 @@ function _requestObservable(client, httpRequest, options) {
745
745
  const resultSourceMap = options.resultSourceMap ?? config$1.resultSourceMap;
746
746
  resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
747
747
  const perspectiveOption = options.perspective || config$1.perspective;
748
- typeof perspectiveOption < "u" && (config.validateApiPerspective(perspectiveOption), options.query = {
748
+ typeof perspectiveOption < "u" && (perspectiveOption === "previewDrafts" && config.printPreviewDraftsDeprecationWarning(), config.validateApiPerspective(perspectiveOption), options.query = {
749
749
  perspective: Array.isArray(perspectiveOption) ? perspectiveOption.join(",") : perspectiveOption,
750
750
  ...options.query
751
- }, perspectiveOption === "previewDrafts" && useCdn && (useCdn = !1, config.printCdnPreviewDraftsWarning())), options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query }), useCdn && options.cacheMode == "noStale" && (options.query = { cacheMode: "noStale", ...options.query });
751
+ }, (Array.isArray(perspectiveOption) && perspectiveOption.length > 0 || // previewDrafts was renamed to drafts, but keep for backwards compat
752
+ perspectiveOption === "previewDrafts" || perspectiveOption === "drafts") && useCdn && (useCdn = !1, config.printCdnPreviewDraftsWarning())), options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query }), useCdn && options.cacheMode == "noStale" && (options.query = { cacheMode: "noStale", ...options.query });
752
753
  }
753
754
  const reqOptions = requestOptions(
754
755
  config$1,
@@ -853,6 +854,42 @@ function optionsFromFile(opts, file) {
853
854
  opts
854
855
  );
855
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
+ }
856
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), {});
857
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(
858
895
  operators.map(({ default: EventSource2 }) => EventSource2),
@@ -1185,6 +1222,7 @@ class ObservableSanityClient {
1185
1222
  live;
1186
1223
  projects;
1187
1224
  users;
1225
+ assist;
1188
1226
  /**
1189
1227
  * Private properties
1190
1228
  */
@@ -1195,7 +1233,7 @@ class ObservableSanityClient {
1195
1233
  */
1196
1234
  listen = _listen;
1197
1235
  constructor(httpRequest, config$1 = config.defaultConfig) {
1198
- 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);
1236
+ 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);
1199
1237
  }
1200
1238
  /**
1201
1239
  * Clone the client - returns a new instance
@@ -1334,6 +1372,7 @@ class SanityClient {
1334
1372
  live;
1335
1373
  projects;
1336
1374
  users;
1375
+ assist;
1337
1376
  /**
1338
1377
  * Observable version of the Sanity client, with the same configuration as the promise-based one
1339
1378
  */
@@ -1348,7 +1387,7 @@ class SanityClient {
1348
1387
  */
1349
1388
  listen = _listen;
1350
1389
  constructor(httpRequest, config$1 = config.defaultConfig) {
1351
- 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);
1390
+ 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);
1352
1391
  }
1353
1392
  /**
1354
1393
  * Clone the client - returns a new instance
@@ -1524,7 +1563,7 @@ function defineDeprecatedCreateClient(createClient2) {
1524
1563
  return config.printNoDefaultExport(), createClient2(config$1);
1525
1564
  };
1526
1565
  }
1527
- var name = "@sanity/client", version = "6.27.3-canary.2";
1566
+ var name = "@sanity/client", version = "6.28.0-instruct.0";
1528
1567
  const middleware = [
1529
1568
  middleware$1.debug({ verbose: !0, namespace: "sanity:client" }),
1530
1569
  middleware$1.headers({ "User-Agent": `${name} ${version}` }),