@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.browser.cjs +44 -3
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +243 -3
- package/dist/index.browser.d.ts +243 -3
- package/dist/index.browser.js +44 -3
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +45 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +233 -4
- package/dist/index.d.ts +233 -4
- package/dist/index.js +45 -4
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +237 -3
- package/dist/stega.browser.d.ts +237 -3
- package/dist/stega.d.cts +237 -3
- package/dist/stega.d.ts +237 -3
- package/package.json +1 -1
- package/src/SanityClient.ts +5 -1
- package/src/assist/AssistClient.ts +87 -0
- package/src/assist/types.ts +203 -0
- package/src/index.ts +1 -1
- package/src/types.ts +13 -3
- package/src/util/shareReplayLatest.ts +4 -1
- package/umd/sanityClient.js +44 -3
- package/umd/sanityClient.min.js +2 -2
package/dist/index.browser.js
CHANGED
|
@@ -981,6 +981,42 @@ function optionsFromFile(opts, file) {
|
|
|
981
981
|
opts
|
|
982
982
|
);
|
|
983
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
|
+
}
|
|
984
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), {});
|
|
985
1021
|
const pick = (obj, props) => props.reduce((selection, prop) => (typeof obj[prop] > "u" || (selection[prop] = obj[prop]), selection), {}), eventSourcePolyfill = defer(() => import("@sanity/eventsource")).pipe(
|
|
986
1022
|
map(({ default: EventSource2 }) => EventSource2),
|
|
@@ -1042,7 +1078,10 @@ function _shareReplayLatest(config) {
|
|
|
1042
1078
|
}),
|
|
1043
1079
|
share(shareConfig)
|
|
1044
1080
|
), emitLatest = new Observable((subscriber) => {
|
|
1045
|
-
emitted && subscriber.next(
|
|
1081
|
+
emitted && subscriber.next(
|
|
1082
|
+
// this cast is safe because of the emitted check which asserts that we got T from the source
|
|
1083
|
+
latest
|
|
1084
|
+
), subscriber.complete();
|
|
1046
1085
|
});
|
|
1047
1086
|
return merge(wrapped, emitLatest);
|
|
1048
1087
|
};
|
|
@@ -1313,6 +1352,7 @@ class ObservableSanityClient {
|
|
|
1313
1352
|
live;
|
|
1314
1353
|
projects;
|
|
1315
1354
|
users;
|
|
1355
|
+
assist;
|
|
1316
1356
|
/**
|
|
1317
1357
|
* Private properties
|
|
1318
1358
|
*/
|
|
@@ -1323,7 +1363,7 @@ class ObservableSanityClient {
|
|
|
1323
1363
|
*/
|
|
1324
1364
|
listen = _listen;
|
|
1325
1365
|
constructor(httpRequest, config = defaultConfig) {
|
|
1326
|
-
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);
|
|
1366
|
+
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);
|
|
1327
1367
|
}
|
|
1328
1368
|
/**
|
|
1329
1369
|
* Clone the client - returns a new instance
|
|
@@ -1462,6 +1502,7 @@ class SanityClient {
|
|
|
1462
1502
|
live;
|
|
1463
1503
|
projects;
|
|
1464
1504
|
users;
|
|
1505
|
+
assist;
|
|
1465
1506
|
/**
|
|
1466
1507
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
1467
1508
|
*/
|
|
@@ -1476,7 +1517,7 @@ class SanityClient {
|
|
|
1476
1517
|
*/
|
|
1477
1518
|
listen = _listen;
|
|
1478
1519
|
constructor(httpRequest, config = defaultConfig) {
|
|
1479
|
-
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);
|
|
1520
|
+
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);
|
|
1480
1521
|
}
|
|
1481
1522
|
/**
|
|
1482
1523
|
* Clone the client - returns a new instance
|