@sanity/client 6.28.3-instruct.0 → 6.28.3-instruct.1
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 +48 -55
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +157 -153
- package/dist/index.browser.d.ts +157 -153
- package/dist/index.browser.js +48 -55
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +43 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +157 -153
- package/dist/index.d.ts +157 -153
- package/dist/index.js +43 -43
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +159 -160
- package/dist/stega.browser.d.ts +159 -160
- package/dist/stega.d.cts +159 -160
- package/dist/stega.d.ts +159 -160
- package/package.json +20 -20
- package/src/SanityClient.ts +5 -5
- package/src/{assist/AssistClient.ts → ai/AiClient.ts} +18 -12
- package/src/{assist → ai}/types.ts +30 -27
- package/src/config.ts +9 -18
- package/src/data/listen.ts +1 -1
- package/src/http/requestOptions.ts +1 -1
- package/src/types.ts +9 -9
- package/src/warnings.ts +5 -0
- package/umd/sanityClient.js +55 -60
- package/umd/sanityClient.min.js +2 -2
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,
|
|
@@ -795,6 +795,42 @@ function _createAbortError(signal) {
|
|
|
795
795
|
const error = new Error(signal?.reason ?? "The operation was aborted.");
|
|
796
796
|
return error.name = "AbortError", error;
|
|
797
797
|
}
|
|
798
|
+
function _instruct(client, httpRequest, request) {
|
|
799
|
+
const dataset = config.hasDataset(client.config());
|
|
800
|
+
return _request(client, httpRequest, {
|
|
801
|
+
method: "POST",
|
|
802
|
+
uri: `/assist/tasks/instruct/${dataset}`,
|
|
803
|
+
body: request
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
class ObservableAiClient {
|
|
807
|
+
#client;
|
|
808
|
+
#httpRequest;
|
|
809
|
+
constructor(client, httpRequest) {
|
|
810
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* Run an ad-hoc instruction for a target document.
|
|
814
|
+
* @param request instruction request
|
|
815
|
+
*/
|
|
816
|
+
instruct(request) {
|
|
817
|
+
return _instruct(this.#client, this.#httpRequest, request);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
class AiClient {
|
|
821
|
+
#client;
|
|
822
|
+
#httpRequest;
|
|
823
|
+
constructor(client, httpRequest) {
|
|
824
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Run an ad-hoc instruction for a target document.
|
|
828
|
+
* @param request instruction request
|
|
829
|
+
*/
|
|
830
|
+
instruct(request) {
|
|
831
|
+
return rxjs.lastValueFrom(_instruct(this.#client, this.#httpRequest, request));
|
|
832
|
+
}
|
|
833
|
+
}
|
|
798
834
|
class ObservableAssetsClient {
|
|
799
835
|
#client;
|
|
800
836
|
#httpRequest;
|
|
@@ -854,42 +890,6 @@ function optionsFromFile(opts, file) {
|
|
|
854
890
|
opts
|
|
855
891
|
);
|
|
856
892
|
}
|
|
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
893
|
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
894
|
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
895
|
operators.map(({ default: EventSource2 }) => EventSource2),
|
|
@@ -918,7 +918,7 @@ function _listen(query, params, opts = {}) {
|
|
|
918
918
|
if (uri.length > MAX_URL_LENGTH)
|
|
919
919
|
return rxjs.throwError(() => new Error("Query too large for listener"));
|
|
920
920
|
const listenFor = options.events ? options.events : ["mutation"], esOptions = {};
|
|
921
|
-
return
|
|
921
|
+
return withCredentials && (esOptions.withCredentials = !0), token && (esOptions.headers = {
|
|
922
922
|
Authorization: `Bearer ${token}`
|
|
923
923
|
}), connectEventSource(() => (
|
|
924
924
|
// use polyfill if there is no global EventSource or if we need to set headers
|
|
@@ -1225,7 +1225,7 @@ class ObservableSanityClient {
|
|
|
1225
1225
|
live;
|
|
1226
1226
|
projects;
|
|
1227
1227
|
users;
|
|
1228
|
-
|
|
1228
|
+
ai;
|
|
1229
1229
|
/**
|
|
1230
1230
|
* Private properties
|
|
1231
1231
|
*/
|
|
@@ -1236,7 +1236,7 @@ class ObservableSanityClient {
|
|
|
1236
1236
|
*/
|
|
1237
1237
|
listen = _listen;
|
|
1238
1238
|
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), this.
|
|
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), this.ai = new ObservableAiClient(this, this.#httpRequest);
|
|
1240
1240
|
}
|
|
1241
1241
|
/**
|
|
1242
1242
|
* Clone the client - returns a new instance
|
|
@@ -1375,7 +1375,7 @@ class SanityClient {
|
|
|
1375
1375
|
live;
|
|
1376
1376
|
projects;
|
|
1377
1377
|
users;
|
|
1378
|
-
|
|
1378
|
+
ai;
|
|
1379
1379
|
/**
|
|
1380
1380
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
1381
1381
|
*/
|
|
@@ -1390,7 +1390,7 @@ class SanityClient {
|
|
|
1390
1390
|
*/
|
|
1391
1391
|
listen = _listen;
|
|
1392
1392
|
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.
|
|
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.ai = new AiClient(this, this.#httpRequest), this.observable = new ObservableSanityClient(httpRequest, config$1);
|
|
1394
1394
|
}
|
|
1395
1395
|
/**
|
|
1396
1396
|
* Clone the client - returns a new instance
|
|
@@ -1566,7 +1566,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
1566
1566
|
return config.printNoDefaultExport(), createClient2(config$1);
|
|
1567
1567
|
};
|
|
1568
1568
|
}
|
|
1569
|
-
var name = "@sanity/client", version = "6.28.3-instruct.
|
|
1569
|
+
var name = "@sanity/client", version = "6.28.3-instruct.1";
|
|
1570
1570
|
const middleware = [
|
|
1571
1571
|
middleware$1.debug({ verbose: !0, namespace: "sanity:client" }),
|
|
1572
1572
|
middleware$1.headers({ "User-Agent": `${name} ${version}` }),
|