@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.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getIt } from "get-it";
|
|
2
2
|
import { adapter, environment } from "get-it";
|
|
3
3
|
import { retry, jsonRequest, jsonResponse, progress, observable, debug, headers, agent } 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
|
-
import { validateObject, validateInsert, requireDocumentId, validateDocumentId, requestTag, validateApiPerspective, printCdnPreviewDraftsWarning,
|
|
7
|
+
import { validateObject, validateInsert, requireDocumentId, validateDocumentId, hasDataset, requestTag, printPreviewDraftsDeprecationWarning, validateApiPerspective, printCdnPreviewDraftsWarning, validateAssetType, dataset, defaultConfig, initConfig, printNoDefaultExport } from "./_chunks-es/config.js";
|
|
8
8
|
class ClientError extends Error {
|
|
9
9
|
response;
|
|
10
10
|
statusCode = 400;
|
|
@@ -728,10 +728,11 @@ function _requestObservable(client, httpRequest, options) {
|
|
|
728
728
|
const resultSourceMap = options.resultSourceMap ?? config.resultSourceMap;
|
|
729
729
|
resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
|
|
730
730
|
const perspectiveOption = options.perspective || config.perspective;
|
|
731
|
-
typeof perspectiveOption < "u" && (validateApiPerspective(perspectiveOption), options.query = {
|
|
731
|
+
typeof perspectiveOption < "u" && (perspectiveOption === "previewDrafts" && printPreviewDraftsDeprecationWarning(), validateApiPerspective(perspectiveOption), options.query = {
|
|
732
732
|
perspective: Array.isArray(perspectiveOption) ? perspectiveOption.join(",") : perspectiveOption,
|
|
733
733
|
...options.query
|
|
734
|
-
},
|
|
734
|
+
}, (Array.isArray(perspectiveOption) && perspectiveOption.length > 0 || // previewDrafts was renamed to drafts, but keep for backwards compat
|
|
735
|
+
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 });
|
|
735
736
|
}
|
|
736
737
|
const reqOptions = requestOptions(
|
|
737
738
|
config,
|
|
@@ -836,6 +837,42 @@ function optionsFromFile(opts, file) {
|
|
|
836
837
|
opts
|
|
837
838
|
);
|
|
838
839
|
}
|
|
840
|
+
function _instruct(client, httpRequest, request) {
|
|
841
|
+
const dataset2 = hasDataset(client.config());
|
|
842
|
+
return _request(client, httpRequest, {
|
|
843
|
+
method: "POST",
|
|
844
|
+
uri: `/assist/tasks/instruct/${dataset2}`,
|
|
845
|
+
body: request
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
class ObservableAssistClient {
|
|
849
|
+
#client;
|
|
850
|
+
#httpRequest;
|
|
851
|
+
constructor(client, httpRequest) {
|
|
852
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Run an ad-hoc instruction for a target document.
|
|
856
|
+
* @param request instruction request
|
|
857
|
+
*/
|
|
858
|
+
instruct(request) {
|
|
859
|
+
return _instruct(this.#client, this.#httpRequest, request);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
class AssistClient {
|
|
863
|
+
#client;
|
|
864
|
+
#httpRequest;
|
|
865
|
+
constructor(client, httpRequest) {
|
|
866
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Run an ad-hoc instruction for a target document.
|
|
870
|
+
* @param request instruction request
|
|
871
|
+
*/
|
|
872
|
+
instruct(request) {
|
|
873
|
+
return lastValueFrom(_instruct(this.#client, this.#httpRequest, request));
|
|
874
|
+
}
|
|
875
|
+
}
|
|
839
876
|
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), {});
|
|
840
877
|
const pick = (obj, props) => props.reduce((selection, prop) => (typeof obj[prop] > "u" || (selection[prop] = obj[prop]), selection), {}), eventSourcePolyfill = defer(() => import("@sanity/eventsource")).pipe(
|
|
841
878
|
map(({ default: EventSource2 }) => EventSource2),
|
|
@@ -852,6 +889,7 @@ const MAX_URL_LENGTH = 14800, possibleOptions = [
|
|
|
852
889
|
"includePreviousRevision",
|
|
853
890
|
"includeResult",
|
|
854
891
|
"includeMutations",
|
|
892
|
+
"includeAllVersions",
|
|
855
893
|
"visibility",
|
|
856
894
|
"effectFormat",
|
|
857
895
|
"tag"
|
|
@@ -1167,6 +1205,7 @@ class ObservableSanityClient {
|
|
|
1167
1205
|
live;
|
|
1168
1206
|
projects;
|
|
1169
1207
|
users;
|
|
1208
|
+
assist;
|
|
1170
1209
|
/**
|
|
1171
1210
|
* Private properties
|
|
1172
1211
|
*/
|
|
@@ -1177,7 +1216,7 @@ class ObservableSanityClient {
|
|
|
1177
1216
|
*/
|
|
1178
1217
|
listen = _listen;
|
|
1179
1218
|
constructor(httpRequest, config = defaultConfig) {
|
|
1180
|
-
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);
|
|
1219
|
+
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);
|
|
1181
1220
|
}
|
|
1182
1221
|
/**
|
|
1183
1222
|
* Clone the client - returns a new instance
|
|
@@ -1316,6 +1355,7 @@ class SanityClient {
|
|
|
1316
1355
|
live;
|
|
1317
1356
|
projects;
|
|
1318
1357
|
users;
|
|
1358
|
+
assist;
|
|
1319
1359
|
/**
|
|
1320
1360
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
1321
1361
|
*/
|
|
@@ -1330,7 +1370,7 @@ class SanityClient {
|
|
|
1330
1370
|
*/
|
|
1331
1371
|
listen = _listen;
|
|
1332
1372
|
constructor(httpRequest, config = defaultConfig) {
|
|
1333
|
-
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);
|
|
1373
|
+
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);
|
|
1334
1374
|
}
|
|
1335
1375
|
/**
|
|
1336
1376
|
* Clone the client - returns a new instance
|
|
@@ -1506,7 +1546,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
1506
1546
|
return printNoDefaultExport(), createClient2(config);
|
|
1507
1547
|
};
|
|
1508
1548
|
}
|
|
1509
|
-
var name = "@sanity/client", version = "6.
|
|
1549
|
+
var name = "@sanity/client", version = "6.28.0-instruct.0";
|
|
1510
1550
|
const middleware = [
|
|
1511
1551
|
debug({ verbose: !0, namespace: "sanity:client" }),
|
|
1512
1552
|
headers({ "User-Agent": `${name} ${version}` }),
|