@sanity/client 6.27.2-resources.2 → 6.27.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 +2 -16
- package/dist/_chunks-cjs/config.cjs.map +1 -1
- package/dist/_chunks-es/config.js +2 -16
- package/dist/_chunks-es/config.js.map +1 -1
- package/dist/index.browser.cjs +11 -57
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +0 -7
- package/dist/index.browser.d.ts +0 -7
- package/dist/index.browser.js +11 -57
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +10 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -7
- package/dist/index.d.ts +0 -7
- package/dist/index.js +10 -42
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +0 -7
- package/dist/stega.browser.d.ts +0 -7
- package/dist/stega.d.cts +0 -7
- package/dist/stega.d.ts +0 -7
- package/package.json +1 -1
- package/src/SanityClient.ts +2 -9
- package/src/assets/AssetsClient.ts +2 -3
- package/src/config.ts +0 -23
- package/src/data/dataMethods.ts +4 -39
- package/src/data/eventsource.ts +0 -2
- package/src/datasets/DatasetsClient.ts +0 -22
- package/src/types.ts +0 -8
- package/umd/sanityClient.js +11 -57
- package/umd/sanityClient.min.js +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -388,13 +388,6 @@ export declare interface ClientConfig {
|
|
|
388
388
|
* Options for how, if enabled, Content Source Maps are encoded into query results using steganography
|
|
389
389
|
*/
|
|
390
390
|
stega?: StegaConfig | boolean
|
|
391
|
-
/**
|
|
392
|
-
* @deprecated Don't use
|
|
393
|
-
*/
|
|
394
|
-
experimental_resource?: {
|
|
395
|
-
id: string
|
|
396
|
-
type: string
|
|
397
|
-
}
|
|
398
391
|
}
|
|
399
392
|
|
|
400
393
|
/** @public */
|
package/dist/index.d.ts
CHANGED
|
@@ -388,13 +388,6 @@ export declare interface ClientConfig {
|
|
|
388
388
|
* Options for how, if enabled, Content Source Maps are encoded into query results using steganography
|
|
389
389
|
*/
|
|
390
390
|
stega?: StegaConfig | boolean
|
|
391
|
-
/**
|
|
392
|
-
* @deprecated Don't use
|
|
393
|
-
*/
|
|
394
|
-
experimental_resource?: {
|
|
395
|
-
id: string
|
|
396
|
-
type: string
|
|
397
|
-
}
|
|
398
391
|
}
|
|
399
392
|
|
|
400
393
|
/** @public */
|
package/dist/index.js
CHANGED
|
@@ -149,7 +149,7 @@ function connectWithESInstance(es, events) {
|
|
|
149
149
|
return new Observable((observer) => {
|
|
150
150
|
const emitOpen = events.includes("open"), emitReconnect = events.includes("reconnect");
|
|
151
151
|
function onError(evt) {
|
|
152
|
-
if (
|
|
152
|
+
if ("data" in evt) {
|
|
153
153
|
const [parseError, event] = parseEvent(evt);
|
|
154
154
|
observer.error(
|
|
155
155
|
parseError ? new MessageParseError("Unable to parse EventSource error message", { cause: event }) : new MessageError((event?.data).message, event)
|
|
@@ -720,20 +720,11 @@ function _create(client, httpRequest, doc, op, options = {}) {
|
|
|
720
720
|
const mutation = { [op]: doc }, opts = Object.assign({ returnFirst: !0, returnDocuments: !0 }, options);
|
|
721
721
|
return _dataRequest(client, httpRequest, "mutate", { mutations: [mutation] }, opts);
|
|
722
722
|
}
|
|
723
|
-
function _resourceBase(resource) {
|
|
724
|
-
return `/${resource.type}/${resource.id}`;
|
|
725
|
-
}
|
|
726
|
-
function isDataRequestUri(uri, resource) {
|
|
727
|
-
return resource ? uri.indexOf(`/${_resourceBase(resource)}/data/`) === 0 : uri.indexOf("/data/") === 0;
|
|
728
|
-
}
|
|
729
|
-
function isDataQueryRequestUri(uri, resource) {
|
|
730
|
-
return resource ? uri.indexOf(`/${_resourceBase(resource)}/data/query`) === 0 : uri.indexOf("/data/query") === 0;
|
|
731
|
-
}
|
|
732
723
|
function _requestObservable(client, httpRequest, options) {
|
|
733
|
-
const uri = options.url || options.uri, config = client.config(), canUseCdn = typeof options.canUseCdn > "u" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 &&
|
|
724
|
+
const uri = options.url || options.uri, config = client.config(), canUseCdn = typeof options.canUseCdn > "u" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/") === 0 : options.canUseCdn;
|
|
734
725
|
let useCdn = (options.useCdn ?? config.useCdn) && canUseCdn;
|
|
735
726
|
const tag = options.tag && config.requestTagPrefix ? [config.requestTagPrefix, options.tag].join(".") : options.tag || config.requestTagPrefix;
|
|
736
|
-
if (tag && options.tag !== null && (options.query = { tag: requestTag(tag), ...options.query }), ["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 &&
|
|
727
|
+
if (tag && options.tag !== null && (options.query = { tag: requestTag(tag), ...options.query }), ["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
|
|
737
728
|
const resultSourceMap = options.resultSourceMap ?? config.resultSourceMap;
|
|
738
729
|
resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
|
|
739
730
|
const perspectiveOption = options.perspective || config.perspective;
|
|
@@ -759,18 +750,12 @@ function _request(client, httpRequest, options) {
|
|
|
759
750
|
);
|
|
760
751
|
}
|
|
761
752
|
function _getDataUrl(client, operation, path) {
|
|
762
|
-
const config = client.config()
|
|
763
|
-
if (config.experimental_resource) {
|
|
764
|
-
const baseUri2 = `/${operation}`;
|
|
765
|
-
return (path ? `${baseUri2}/${path}` : baseUri2).replace(/\/($|\?)/, "$1");
|
|
766
|
-
}
|
|
767
|
-
const catalog = hasDataset(config), baseUri = `/${operation}/${catalog}`;
|
|
753
|
+
const config = client.config(), catalog = hasDataset(config), baseUri = `/${operation}/${catalog}`;
|
|
768
754
|
return `/data${path ? `${baseUri}/${path}` : baseUri}`.replace(/\/($|\?)/, "$1");
|
|
769
755
|
}
|
|
770
756
|
function _getUrl(client, uri, canUseCdn = !1) {
|
|
771
|
-
const { url, cdnUrl
|
|
772
|
-
|
|
773
|
-
return experimental_resource && uri.indexOf("/users") !== -1 && (base = base.replace(_resourceBase(experimental_resource), "")), `${base}/${uri.replace(/^\//, "")}`;
|
|
757
|
+
const { url, cdnUrl } = client.config();
|
|
758
|
+
return `${canUseCdn ? cdnUrl : url}/${uri.replace(/^\//, "")}`;
|
|
774
759
|
}
|
|
775
760
|
function _withAbortSignal(signal) {
|
|
776
761
|
return (input) => new Observable((observer) => {
|
|
@@ -824,7 +809,7 @@ function _upload(client, httpRequest, assetType, body, opts = {}) {
|
|
|
824
809
|
validateAssetType(assetType);
|
|
825
810
|
let meta = opts.extract || void 0;
|
|
826
811
|
meta && !meta.length && (meta = ["none"]);
|
|
827
|
-
const
|
|
812
|
+
const dataset2 = hasDataset(client.config()), assetEndpoint = assetType === "image" ? "images" : "files", options = optionsFromFile(opts, body), { tag, label, title, description, creditLine, filename, source } = options, query = {
|
|
828
813
|
label,
|
|
829
814
|
title,
|
|
830
815
|
description,
|
|
@@ -836,7 +821,7 @@ function _upload(client, httpRequest, assetType, body, opts = {}) {
|
|
|
836
821
|
tag,
|
|
837
822
|
method: "POST",
|
|
838
823
|
timeout: options.timeout || 0,
|
|
839
|
-
uri:
|
|
824
|
+
uri: `/assets/${assetEndpoint}/${dataset2}`,
|
|
840
825
|
headers: options.contentType ? { "Content-Type": options.contentType } : {},
|
|
841
826
|
query,
|
|
842
827
|
body
|
|
@@ -1059,23 +1044,6 @@ class DatasetsClient {
|
|
|
1059
1044
|
);
|
|
1060
1045
|
}
|
|
1061
1046
|
}
|
|
1062
|
-
class ThrowingDatasetsClient extends DatasetsClient {
|
|
1063
|
-
constructor(client, httpRequest) {
|
|
1064
|
-
super(client, httpRequest);
|
|
1065
|
-
}
|
|
1066
|
-
create() {
|
|
1067
|
-
throw new Error("cannot create dataset with the current client configuration");
|
|
1068
|
-
}
|
|
1069
|
-
edit() {
|
|
1070
|
-
throw new Error("cannot edit dataset with the current client configuration");
|
|
1071
|
-
}
|
|
1072
|
-
delete() {
|
|
1073
|
-
throw new Error("cannot delete dataset with the current client configuration");
|
|
1074
|
-
}
|
|
1075
|
-
list() {
|
|
1076
|
-
throw new Error("cannot list dataset with the current client configuration");
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
1047
|
function _modify(client, httpRequest, method, name2, options) {
|
|
1080
1048
|
return dataset(name2), _request(client, httpRequest, {
|
|
1081
1049
|
method,
|
|
@@ -1331,7 +1299,7 @@ class SanityClient {
|
|
|
1331
1299
|
*/
|
|
1332
1300
|
listen = _listen;
|
|
1333
1301
|
constructor(httpRequest, config = defaultConfig) {
|
|
1334
|
-
this.config(config), this.#httpRequest = httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets =
|
|
1302
|
+
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);
|
|
1335
1303
|
}
|
|
1336
1304
|
/**
|
|
1337
1305
|
* Clone the client - returns a new instance
|
|
@@ -1507,7 +1475,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
1507
1475
|
return printNoDefaultExport(), createClient2(config);
|
|
1508
1476
|
};
|
|
1509
1477
|
}
|
|
1510
|
-
var name = "@sanity/client", version = "6.27.2
|
|
1478
|
+
var name = "@sanity/client", version = "6.27.2";
|
|
1511
1479
|
const middleware = [
|
|
1512
1480
|
debug({ verbose: !0, namespace: "sanity:client" }),
|
|
1513
1481
|
headers({ "User-Agent": `${name} ${version}` }),
|