@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/README.md +85 -5
- package/dist/_chunks-cjs/config.cjs +4 -1
- package/dist/_chunks-cjs/config.cjs.map +1 -1
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs +1 -1
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +1 -1
- package/dist/_chunks-es/config.js +4 -1
- package/dist/_chunks-es/config.js.map +1 -1
- package/dist/_chunks-es/stegaEncodeSourceMap.js +1 -1
- package/dist/_chunks-es/stegaEncodeSourceMap.js.map +1 -1
- package/dist/csm.d.cts +6 -1
- package/dist/csm.d.ts +6 -1
- package/dist/index.browser.cjs +46 -5
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +221 -1
- package/dist/index.browser.d.ts +221 -1
- package/dist/index.browser.js +47 -6
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +44 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +210 -1
- package/dist/index.d.ts +210 -1
- package/dist/index.js +46 -7
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +215 -1
- package/dist/stega.browser.d.ts +215 -1
- package/dist/stega.browser.js +1 -1
- package/dist/stega.d.cts +215 -1
- package/dist/stega.d.ts +215 -1
- package/dist/stega.js +1 -1
- package/package.json +11 -12
- package/src/SanityClient.ts +5 -1
- package/src/assist/AssistClient.ts +87 -0
- package/src/assist/types.ts +178 -0
- package/src/data/dataMethods.ts +12 -3
- package/src/types.ts +16 -1
- package/src/warnings.ts +5 -1
- package/umd/sanityClient.js +121 -86
- package/umd/sanityClient.min.js +2 -2
package/dist/index.browser.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getIt } from "get-it";
|
|
2
2
|
import { adapter, environment } from "get-it";
|
|
3
3
|
import { retry, jsonRequest, jsonResponse, progress, observable } from "get-it/middleware";
|
|
4
|
-
import { Observable, defer,
|
|
4
|
+
import { Observable, defer, of, isObservable, mergeMap, from, lastValueFrom, shareReplay, catchError, concat, throwError, timer, tap, finalize, share, merge, EMPTY } from "rxjs";
|
|
5
5
|
import { stegaClean } from "./_chunks-es/stegaClean.js";
|
|
6
6
|
import { combineLatestWith, map, filter, finalize as finalize$1 } from "rxjs/operators";
|
|
7
7
|
class ClientError extends Error {
|
|
@@ -171,8 +171,10 @@ const createWarningPrinter = (message) => (
|
|
|
171
171
|
"global, edge-cached API-CDN. If you wish to have content delivered faster, set",
|
|
172
172
|
"`useCdn: false` to use the Live API. Note: You may incur higher costs using the live API."
|
|
173
173
|
]), printCdnPreviewDraftsWarning = createWarningPrinter([
|
|
174
|
-
"The Sanity client is configured with the `perspective` set to `previewDrafts`, which doesn't support the API-CDN.",
|
|
174
|
+
"The Sanity client is configured with the `perspective` set to `drafts` or `previewDrafts`, which doesn't support the API-CDN.",
|
|
175
175
|
"The Live API will be used instead. Set `useCdn: false` in your configuration to hide this warning."
|
|
176
|
+
]), printPreviewDraftsDeprecationWarning = createWarningPrinter([
|
|
177
|
+
"The `previewDrafts` perspective has been renamed to `drafts` and will be removed in a future API version"
|
|
176
178
|
]), printBrowserTokenWarning = createWarningPrinter([
|
|
177
179
|
"You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",
|
|
178
180
|
`See ${generateHelpUrl(
|
|
@@ -870,10 +872,11 @@ function _requestObservable(client, httpRequest, options) {
|
|
|
870
872
|
const resultSourceMap = options.resultSourceMap ?? config.resultSourceMap;
|
|
871
873
|
resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
|
|
872
874
|
const perspectiveOption = options.perspective || config.perspective;
|
|
873
|
-
typeof perspectiveOption < "u" && (validateApiPerspective(perspectiveOption), options.query = {
|
|
875
|
+
typeof perspectiveOption < "u" && (perspectiveOption === "previewDrafts" && printPreviewDraftsDeprecationWarning(), validateApiPerspective(perspectiveOption), options.query = {
|
|
874
876
|
perspective: Array.isArray(perspectiveOption) ? perspectiveOption.join(",") : perspectiveOption,
|
|
875
877
|
...options.query
|
|
876
|
-
},
|
|
878
|
+
}, (Array.isArray(perspectiveOption) && perspectiveOption.length > 0 || // previewDrafts was renamed to drafts, but keep for backwards compat
|
|
879
|
+
perspectiveOption === "previewDrafts" || perspectiveOption === "drafts") && useCdn && (useCdn = !1, 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 });
|
|
877
880
|
}
|
|
878
881
|
const reqOptions = requestOptions(
|
|
879
882
|
config,
|
|
@@ -978,6 +981,42 @@ function optionsFromFile(opts, file) {
|
|
|
978
981
|
opts
|
|
979
982
|
);
|
|
980
983
|
}
|
|
984
|
+
function _instruct(client, httpRequest, request) {
|
|
985
|
+
const dataset2 = hasDataset(client.config());
|
|
986
|
+
return _request(client, httpRequest, {
|
|
987
|
+
method: "POST",
|
|
988
|
+
uri: `/assist/tasks/instruct/${dataset2}`,
|
|
989
|
+
body: request
|
|
990
|
+
});
|
|
991
|
+
}
|
|
992
|
+
class ObservableAssistClient {
|
|
993
|
+
#client;
|
|
994
|
+
#httpRequest;
|
|
995
|
+
constructor(client, httpRequest) {
|
|
996
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
997
|
+
}
|
|
998
|
+
/**
|
|
999
|
+
* Run an ad-hoc instruction for a target document.
|
|
1000
|
+
* @param request instruction request
|
|
1001
|
+
*/
|
|
1002
|
+
instruct(request) {
|
|
1003
|
+
return _instruct(this.#client, this.#httpRequest, request);
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
class AssistClient {
|
|
1007
|
+
#client;
|
|
1008
|
+
#httpRequest;
|
|
1009
|
+
constructor(client, httpRequest) {
|
|
1010
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Run an ad-hoc instruction for a target document.
|
|
1014
|
+
* @param request instruction request
|
|
1015
|
+
*/
|
|
1016
|
+
instruct(request) {
|
|
1017
|
+
return lastValueFrom(_instruct(this.#client, this.#httpRequest, request));
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
981
1020
|
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), {});
|
|
982
1021
|
const pick = (obj, props) => props.reduce((selection, prop) => (typeof obj[prop] > "u" || (selection[prop] = obj[prop]), selection), {}), eventSourcePolyfill = defer(() => import("@sanity/eventsource")).pipe(
|
|
983
1022
|
map(({ default: EventSource2 }) => EventSource2),
|
|
@@ -1310,6 +1349,7 @@ class ObservableSanityClient {
|
|
|
1310
1349
|
live;
|
|
1311
1350
|
projects;
|
|
1312
1351
|
users;
|
|
1352
|
+
assist;
|
|
1313
1353
|
/**
|
|
1314
1354
|
* Private properties
|
|
1315
1355
|
*/
|
|
@@ -1320,7 +1360,7 @@ class ObservableSanityClient {
|
|
|
1320
1360
|
*/
|
|
1321
1361
|
listen = _listen;
|
|
1322
1362
|
constructor(httpRequest, config = defaultConfig) {
|
|
1323
|
-
this.config(config), 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);
|
|
1363
|
+
this.config(config), 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);
|
|
1324
1364
|
}
|
|
1325
1365
|
/**
|
|
1326
1366
|
* Clone the client - returns a new instance
|
|
@@ -1459,6 +1499,7 @@ class SanityClient {
|
|
|
1459
1499
|
live;
|
|
1460
1500
|
projects;
|
|
1461
1501
|
users;
|
|
1502
|
+
assist;
|
|
1462
1503
|
/**
|
|
1463
1504
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
1464
1505
|
*/
|
|
@@ -1473,7 +1514,7 @@ class SanityClient {
|
|
|
1473
1514
|
*/
|
|
1474
1515
|
listen = _listen;
|
|
1475
1516
|
constructor(httpRequest, config = defaultConfig) {
|
|
1476
|
-
this.config(config), 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);
|
|
1517
|
+
this.config(config), 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);
|
|
1477
1518
|
}
|
|
1478
1519
|
/**
|
|
1479
1520
|
* Clone the client - returns a new instance
|