@sanity/client 6.27.3-canary.1 → 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 +101 -21
- 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 +47 -5
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +226 -1
- package/dist/index.browser.d.ts +226 -1
- package/dist/index.browser.js +48 -6
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +45 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +215 -1
- package/dist/index.d.ts +215 -1
- package/dist/index.js +47 -7
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +220 -1
- package/dist/stega.browser.d.ts +220 -1
- package/dist/stega.browser.js +1 -1
- package/dist/stega.d.cts +220 -1
- package/dist/stega.d.ts +220 -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/data/listen.ts +1 -0
- package/src/types.ts +22 -1
- package/src/warnings.ts +5 -1
- package/umd/sanityClient.js +122 -86
- package/umd/sanityClient.min.js +2 -2
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
|
-
},
|
|
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),
|
|
@@ -869,6 +906,7 @@ const MAX_URL_LENGTH = 14800, possibleOptions = [
|
|
|
869
906
|
"includePreviousRevision",
|
|
870
907
|
"includeResult",
|
|
871
908
|
"includeMutations",
|
|
909
|
+
"includeAllVersions",
|
|
872
910
|
"visibility",
|
|
873
911
|
"effectFormat",
|
|
874
912
|
"tag"
|
|
@@ -1184,6 +1222,7 @@ class ObservableSanityClient {
|
|
|
1184
1222
|
live;
|
|
1185
1223
|
projects;
|
|
1186
1224
|
users;
|
|
1225
|
+
assist;
|
|
1187
1226
|
/**
|
|
1188
1227
|
* Private properties
|
|
1189
1228
|
*/
|
|
@@ -1194,7 +1233,7 @@ class ObservableSanityClient {
|
|
|
1194
1233
|
*/
|
|
1195
1234
|
listen = _listen;
|
|
1196
1235
|
constructor(httpRequest, config$1 = config.defaultConfig) {
|
|
1197
|
-
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);
|
|
1198
1237
|
}
|
|
1199
1238
|
/**
|
|
1200
1239
|
* Clone the client - returns a new instance
|
|
@@ -1333,6 +1372,7 @@ class SanityClient {
|
|
|
1333
1372
|
live;
|
|
1334
1373
|
projects;
|
|
1335
1374
|
users;
|
|
1375
|
+
assist;
|
|
1336
1376
|
/**
|
|
1337
1377
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
1338
1378
|
*/
|
|
@@ -1347,7 +1387,7 @@ class SanityClient {
|
|
|
1347
1387
|
*/
|
|
1348
1388
|
listen = _listen;
|
|
1349
1389
|
constructor(httpRequest, config$1 = config.defaultConfig) {
|
|
1350
|
-
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);
|
|
1351
1391
|
}
|
|
1352
1392
|
/**
|
|
1353
1393
|
* Clone the client - returns a new instance
|
|
@@ -1523,7 +1563,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
1523
1563
|
return config.printNoDefaultExport(), createClient2(config$1);
|
|
1524
1564
|
};
|
|
1525
1565
|
}
|
|
1526
|
-
var name = "@sanity/client", version = "6.
|
|
1566
|
+
var name = "@sanity/client", version = "6.28.0-instruct.0";
|
|
1527
1567
|
const middleware = [
|
|
1528
1568
|
middleware$1.debug({ verbose: !0, namespace: "sanity:client" }),
|
|
1529
1569
|
middleware$1.headers({ "User-Agent": `${name} ${version}` }),
|