@sanity/client 6.28.3-instruct.0 → 6.28.3-instruct.2
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/_chunks-cjs/config.cjs +6 -13
- package/dist/_chunks-cjs/config.cjs.map +1 -1
- package/dist/_chunks-es/config.js +6 -13
- package/dist/_chunks-es/config.js.map +1 -1
- package/dist/index.browser.cjs +32 -55
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +143 -153
- package/dist/index.browser.d.ts +143 -153
- package/dist/index.browser.js +32 -55
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +27 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +143 -153
- package/dist/index.d.ts +143 -153
- package/dist/index.js +27 -43
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +145 -160
- package/dist/stega.browser.d.ts +145 -160
- package/dist/stega.d.cts +145 -160
- package/dist/stega.d.ts +145 -160
- package/package.json +20 -20
- package/src/SanityClient.ts +46 -5
- package/src/config.ts +9 -18
- package/src/data/listen.ts +1 -1
- package/src/http/requestOptions.ts +1 -1
- package/src/instruct/instruct.ts +24 -0
- package/src/{assist → instruct}/types.ts +30 -27
- package/src/types.ts +9 -9
- package/src/warnings.ts +5 -0
- package/umd/sanityClient.js +39 -60
- package/umd/sanityClient.min.js +2 -2
- package/src/assist/AssistClient.ts +0 -87
package/dist/index.cjs
CHANGED
|
@@ -570,7 +570,7 @@ const projectHeader = "X-Sanity-Project-ID";
|
|
|
570
570
|
function requestOptions(config2, overrides = {}) {
|
|
571
571
|
const headers = {}, token = overrides.token || config2.token;
|
|
572
572
|
token && (headers.Authorization = `Bearer ${token}`), !overrides.useGlobalApi && !config2.useProjectHostname && config2.projectId && (headers[projectHeader] = config2.projectId);
|
|
573
|
-
const withCredentials = !!(typeof overrides.withCredentials > "u" ? config2.
|
|
573
|
+
const withCredentials = !!(typeof overrides.withCredentials > "u" ? config2.withCredentials : overrides.withCredentials), timeout = typeof overrides.timeout > "u" ? config2.timeout : overrides.timeout;
|
|
574
574
|
return Object.assign({}, overrides, {
|
|
575
575
|
headers: Object.assign({}, headers, overrides.headers || {}),
|
|
576
576
|
timeout: typeof timeout > "u" ? 5 * 60 * 1e3 : timeout,
|
|
@@ -854,42 +854,6 @@ function optionsFromFile(opts, file) {
|
|
|
854
854
|
opts
|
|
855
855
|
);
|
|
856
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
|
-
}
|
|
893
857
|
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), {});
|
|
894
858
|
const pick = (obj, props) => props.reduce((selection, prop) => (typeof obj[prop] > "u" || (selection[prop] = obj[prop]), selection), {}), eventSourcePolyfill = rxjs.defer(() => import("@sanity/eventsource")).pipe(
|
|
895
859
|
operators.map(({ default: EventSource2 }) => EventSource2),
|
|
@@ -918,7 +882,7 @@ function _listen(query, params, opts = {}) {
|
|
|
918
882
|
if (uri.length > MAX_URL_LENGTH)
|
|
919
883
|
return rxjs.throwError(() => new Error("Query too large for listener"));
|
|
920
884
|
const listenFor = options.events ? options.events : ["mutation"], esOptions = {};
|
|
921
|
-
return
|
|
885
|
+
return withCredentials && (esOptions.withCredentials = !0), token && (esOptions.headers = {
|
|
922
886
|
Authorization: `Bearer ${token}`
|
|
923
887
|
}), connectEventSource(() => (
|
|
924
888
|
// use polyfill if there is no global EventSource or if we need to set headers
|
|
@@ -1141,6 +1105,14 @@ function _modify(client, httpRequest, method, name2, options) {
|
|
|
1141
1105
|
tag: null
|
|
1142
1106
|
});
|
|
1143
1107
|
}
|
|
1108
|
+
function _instruct(client, httpRequest, request) {
|
|
1109
|
+
const dataset = config.hasDataset(client.config());
|
|
1110
|
+
return _request(client, httpRequest, {
|
|
1111
|
+
method: "POST",
|
|
1112
|
+
uri: `/assist/tasks/instruct/${dataset}`,
|
|
1113
|
+
body: request
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1144
1116
|
class ObservableProjectsClient {
|
|
1145
1117
|
#client;
|
|
1146
1118
|
#httpRequest;
|
|
@@ -1225,7 +1197,6 @@ class ObservableSanityClient {
|
|
|
1225
1197
|
live;
|
|
1226
1198
|
projects;
|
|
1227
1199
|
users;
|
|
1228
|
-
assist;
|
|
1229
1200
|
/**
|
|
1230
1201
|
* Private properties
|
|
1231
1202
|
*/
|
|
@@ -1236,7 +1207,7 @@ class ObservableSanityClient {
|
|
|
1236
1207
|
*/
|
|
1237
1208
|
listen = _listen;
|
|
1238
1209
|
constructor(httpRequest, config$1 = config.defaultConfig) {
|
|
1239
|
-
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)
|
|
1210
|
+
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);
|
|
1240
1211
|
}
|
|
1241
1212
|
/**
|
|
1242
1213
|
* Clone the client - returns a new instance
|
|
@@ -1368,6 +1339,13 @@ class ObservableSanityClient {
|
|
|
1368
1339
|
getDataUrl(operation, path) {
|
|
1369
1340
|
return _getDataUrl(this, operation, path);
|
|
1370
1341
|
}
|
|
1342
|
+
/**
|
|
1343
|
+
* Run an ad-hoc instruction for a target document.
|
|
1344
|
+
* @param request instruction request
|
|
1345
|
+
*/
|
|
1346
|
+
instruct(request) {
|
|
1347
|
+
return _instruct(this, this.#httpRequest, request);
|
|
1348
|
+
}
|
|
1371
1349
|
}
|
|
1372
1350
|
class SanityClient {
|
|
1373
1351
|
assets;
|
|
@@ -1375,7 +1353,6 @@ class SanityClient {
|
|
|
1375
1353
|
live;
|
|
1376
1354
|
projects;
|
|
1377
1355
|
users;
|
|
1378
|
-
assist;
|
|
1379
1356
|
/**
|
|
1380
1357
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
1381
1358
|
*/
|
|
@@ -1390,7 +1367,7 @@ class SanityClient {
|
|
|
1390
1367
|
*/
|
|
1391
1368
|
listen = _listen;
|
|
1392
1369
|
constructor(httpRequest, config$1 = config.defaultConfig) {
|
|
1393
|
-
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.
|
|
1370
|
+
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);
|
|
1394
1371
|
}
|
|
1395
1372
|
/**
|
|
1396
1373
|
* Clone the client - returns a new instance
|
|
@@ -1546,6 +1523,13 @@ class SanityClient {
|
|
|
1546
1523
|
getDataUrl(operation, path) {
|
|
1547
1524
|
return _getDataUrl(this, operation, path);
|
|
1548
1525
|
}
|
|
1526
|
+
/**
|
|
1527
|
+
* Run an ad-hoc instruction for a target document.
|
|
1528
|
+
* @param request instruction request
|
|
1529
|
+
*/
|
|
1530
|
+
instruct(request) {
|
|
1531
|
+
return rxjs.lastValueFrom(_instruct(this, this.#httpRequest, request));
|
|
1532
|
+
}
|
|
1549
1533
|
}
|
|
1550
1534
|
function defineCreateClientExports(envMiddleware, ClassConstructor) {
|
|
1551
1535
|
return { requester: defineHttpRequest(envMiddleware), createClient: (config2) => {
|
|
@@ -1566,7 +1550,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
1566
1550
|
return config.printNoDefaultExport(), createClient2(config$1);
|
|
1567
1551
|
};
|
|
1568
1552
|
}
|
|
1569
|
-
var name = "@sanity/client", version = "6.28.3-instruct.
|
|
1553
|
+
var name = "@sanity/client", version = "6.28.3-instruct.2";
|
|
1570
1554
|
const middleware = [
|
|
1571
1555
|
middleware$1.debug({ verbose: !0, namespace: "sanity:client" }),
|
|
1572
1556
|
middleware$1.headers({ "User-Agent": `${name} ${version}` }),
|