@sanity/client 6.28.1 → 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 +250 -10
- package/dist/index.browser.d.ts +250 -10
- 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 +240 -11
- package/dist/index.d.ts +240 -11
- package/dist/index.js +45 -4
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +244 -10
- package/dist/stega.browser.d.ts +244 -10
- package/dist/stega.d.cts +244 -10
- package/dist/stega.d.ts +244 -10
- 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 +20 -10
- package/src/util/shareReplayLatest.ts +4 -1
- package/umd/sanityClient.js +44 -3
- package/umd/sanityClient.min.js +2 -2
package/dist/index.browser.cjs
CHANGED
|
@@ -999,6 +999,42 @@ function optionsFromFile(opts, file) {
|
|
|
999
999
|
opts
|
|
1000
1000
|
);
|
|
1001
1001
|
}
|
|
1002
|
+
function _instruct(client, httpRequest, request) {
|
|
1003
|
+
const dataset2 = hasDataset(client.config());
|
|
1004
|
+
return _request(client, httpRequest, {
|
|
1005
|
+
method: "POST",
|
|
1006
|
+
uri: `/assist/tasks/instruct/${dataset2}`,
|
|
1007
|
+
body: request
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
class ObservableAssistClient {
|
|
1011
|
+
#client;
|
|
1012
|
+
#httpRequest;
|
|
1013
|
+
constructor(client, httpRequest) {
|
|
1014
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
1015
|
+
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Run an ad-hoc instruction for a target document.
|
|
1018
|
+
* @param request instruction request
|
|
1019
|
+
*/
|
|
1020
|
+
instruct(request) {
|
|
1021
|
+
return _instruct(this.#client, this.#httpRequest, request);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
class AssistClient {
|
|
1025
|
+
#client;
|
|
1026
|
+
#httpRequest;
|
|
1027
|
+
constructor(client, httpRequest) {
|
|
1028
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
1029
|
+
}
|
|
1030
|
+
/**
|
|
1031
|
+
* Run an ad-hoc instruction for a target document.
|
|
1032
|
+
* @param request instruction request
|
|
1033
|
+
*/
|
|
1034
|
+
instruct(request) {
|
|
1035
|
+
return rxjs.lastValueFrom(_instruct(this.#client, this.#httpRequest, request));
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1002
1038
|
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), {});
|
|
1003
1039
|
const pick = (obj, props) => props.reduce((selection, prop) => (typeof obj[prop] > "u" || (selection[prop] = obj[prop]), selection), {}), eventSourcePolyfill = rxjs.defer(() => import("@sanity/eventsource")).pipe(
|
|
1004
1040
|
operators.map(({ default: EventSource2 }) => EventSource2),
|
|
@@ -1060,7 +1096,10 @@ function _shareReplayLatest(config) {
|
|
|
1060
1096
|
}),
|
|
1061
1097
|
rxjs.share(shareConfig)
|
|
1062
1098
|
), emitLatest = new rxjs.Observable((subscriber) => {
|
|
1063
|
-
emitted && subscriber.next(
|
|
1099
|
+
emitted && subscriber.next(
|
|
1100
|
+
// this cast is safe because of the emitted check which asserts that we got T from the source
|
|
1101
|
+
latest
|
|
1102
|
+
), subscriber.complete();
|
|
1064
1103
|
});
|
|
1065
1104
|
return rxjs.merge(wrapped, emitLatest);
|
|
1066
1105
|
};
|
|
@@ -1331,6 +1370,7 @@ class ObservableSanityClient {
|
|
|
1331
1370
|
live;
|
|
1332
1371
|
projects;
|
|
1333
1372
|
users;
|
|
1373
|
+
assist;
|
|
1334
1374
|
/**
|
|
1335
1375
|
* Private properties
|
|
1336
1376
|
*/
|
|
@@ -1341,7 +1381,7 @@ class ObservableSanityClient {
|
|
|
1341
1381
|
*/
|
|
1342
1382
|
listen = _listen;
|
|
1343
1383
|
constructor(httpRequest, config = defaultConfig) {
|
|
1344
|
-
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);
|
|
1384
|
+
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);
|
|
1345
1385
|
}
|
|
1346
1386
|
/**
|
|
1347
1387
|
* Clone the client - returns a new instance
|
|
@@ -1480,6 +1520,7 @@ class SanityClient {
|
|
|
1480
1520
|
live;
|
|
1481
1521
|
projects;
|
|
1482
1522
|
users;
|
|
1523
|
+
assist;
|
|
1483
1524
|
/**
|
|
1484
1525
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
1485
1526
|
*/
|
|
@@ -1494,7 +1535,7 @@ class SanityClient {
|
|
|
1494
1535
|
*/
|
|
1495
1536
|
listen = _listen;
|
|
1496
1537
|
constructor(httpRequest, config = defaultConfig) {
|
|
1497
|
-
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);
|
|
1538
|
+
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);
|
|
1498
1539
|
}
|
|
1499
1540
|
/**
|
|
1500
1541
|
* Clone the client - returns a new instance
|