@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.js
CHANGED
|
@@ -837,6 +837,42 @@ function optionsFromFile(opts, file) {
|
|
|
837
837
|
opts
|
|
838
838
|
);
|
|
839
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
|
+
}
|
|
840
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), {});
|
|
841
877
|
const pick = (obj, props) => props.reduce((selection, prop) => (typeof obj[prop] > "u" || (selection[prop] = obj[prop]), selection), {}), eventSourcePolyfill = defer(() => import("@sanity/eventsource")).pipe(
|
|
842
878
|
map(({ default: EventSource2 }) => EventSource2),
|
|
@@ -898,7 +934,10 @@ function _shareReplayLatest(config) {
|
|
|
898
934
|
}),
|
|
899
935
|
share(shareConfig)
|
|
900
936
|
), emitLatest = new Observable((subscriber) => {
|
|
901
|
-
emitted && subscriber.next(
|
|
937
|
+
emitted && subscriber.next(
|
|
938
|
+
// this cast is safe because of the emitted check which asserts that we got T from the source
|
|
939
|
+
latest
|
|
940
|
+
), subscriber.complete();
|
|
902
941
|
});
|
|
903
942
|
return merge(wrapped, emitLatest);
|
|
904
943
|
};
|
|
@@ -1169,6 +1208,7 @@ class ObservableSanityClient {
|
|
|
1169
1208
|
live;
|
|
1170
1209
|
projects;
|
|
1171
1210
|
users;
|
|
1211
|
+
assist;
|
|
1172
1212
|
/**
|
|
1173
1213
|
* Private properties
|
|
1174
1214
|
*/
|
|
@@ -1179,7 +1219,7 @@ class ObservableSanityClient {
|
|
|
1179
1219
|
*/
|
|
1180
1220
|
listen = _listen;
|
|
1181
1221
|
constructor(httpRequest, config = defaultConfig) {
|
|
1182
|
-
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);
|
|
1222
|
+
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);
|
|
1183
1223
|
}
|
|
1184
1224
|
/**
|
|
1185
1225
|
* Clone the client - returns a new instance
|
|
@@ -1318,6 +1358,7 @@ class SanityClient {
|
|
|
1318
1358
|
live;
|
|
1319
1359
|
projects;
|
|
1320
1360
|
users;
|
|
1361
|
+
assist;
|
|
1321
1362
|
/**
|
|
1322
1363
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
1323
1364
|
*/
|
|
@@ -1332,7 +1373,7 @@ class SanityClient {
|
|
|
1332
1373
|
*/
|
|
1333
1374
|
listen = _listen;
|
|
1334
1375
|
constructor(httpRequest, config = defaultConfig) {
|
|
1335
|
-
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);
|
|
1376
|
+
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);
|
|
1336
1377
|
}
|
|
1337
1378
|
/**
|
|
1338
1379
|
* Clone the client - returns a new instance
|
|
@@ -1508,7 +1549,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
1508
1549
|
return printNoDefaultExport(), createClient2(config);
|
|
1509
1550
|
};
|
|
1510
1551
|
}
|
|
1511
|
-
var name = "@sanity/client", version = "6.28.
|
|
1552
|
+
var name = "@sanity/client", version = "6.28.3-instruct.0";
|
|
1512
1553
|
const middleware = [
|
|
1513
1554
|
debug({ verbose: !0, namespace: "sanity:client" }),
|
|
1514
1555
|
headers({ "User-Agent": `${name} ${version}` }),
|