@sanity/client 7.20.0 → 7.21.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 +27 -8
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +70 -0
- package/dist/index.browser.d.ts +70 -0
- package/dist/index.browser.js +27 -8
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +28 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +70 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.js +28 -9
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +70 -0
- package/dist/stega.browser.d.ts +70 -0
- package/dist/stega.d.cts +70 -0
- package/dist/stega.d.ts +70 -0
- package/package.json +2 -2
- package/src/SanityClient.ts +38 -6
- package/src/data/live.ts +9 -0
- package/src/types.ts +61 -0
- package/umd/sanityClient.js +27 -8
- package/umd/sanityClient.min.js +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1283,7 +1283,8 @@ class LiveClient {
|
|
|
1283
1283
|
*/
|
|
1284
1284
|
events({
|
|
1285
1285
|
includeDrafts = !1,
|
|
1286
|
-
tag: _tag
|
|
1286
|
+
tag: _tag,
|
|
1287
|
+
waitFor
|
|
1287
1288
|
} = {}) {
|
|
1288
1289
|
const {
|
|
1289
1290
|
projectId,
|
|
@@ -1302,7 +1303,7 @@ class LiveClient {
|
|
|
1302
1303
|
"The live events API requires a token or withCredentials when 'includeDrafts: true'. Please update your client configuration. The token should have the lowest possible access role."
|
|
1303
1304
|
);
|
|
1304
1305
|
const path = _getDataUrl(this.#client, "live/events"), url = new URL(this.#client.getUrl(path, !1)), tag = _tag && requestTagPrefix ? [requestTagPrefix, _tag].join(".") : _tag;
|
|
1305
|
-
tag && url.searchParams.set("tag", tag), includeDrafts && url.searchParams.set("includeDrafts", "true");
|
|
1306
|
+
tag && url.searchParams.set("tag", tag), includeDrafts && url.searchParams.set("includeDrafts", "true"), waitFor && url.searchParams.set("waitFor", waitFor);
|
|
1306
1307
|
const esOptions = {};
|
|
1307
1308
|
includeDrafts && withCredentials && (esOptions.withCredentials = !0), (includeDrafts && token || configHeaders) && (esOptions.headers = {}, includeDrafts && token && (esOptions.headers.Authorization = `Bearer ${token}`), configHeaders && Object.assign(esOptions.headers, configHeaders));
|
|
1308
1309
|
const key = `${url.href}::${JSON.stringify(esOptions)}`, existing = eventsCache.get(key);
|
|
@@ -2200,13 +2201,22 @@ class ObservableSanityClient {
|
|
|
2200
2201
|
* Private properties
|
|
2201
2202
|
*/
|
|
2202
2203
|
#clientConfig;
|
|
2204
|
+
#originalHttpRequest;
|
|
2203
2205
|
#httpRequest;
|
|
2204
2206
|
/**
|
|
2205
2207
|
* Instance properties
|
|
2206
2208
|
*/
|
|
2207
2209
|
listen = _listen;
|
|
2208
2210
|
constructor(httpRequest, config$1 = config.defaultConfig) {
|
|
2209
|
-
this.config(config$1), this.#
|
|
2211
|
+
this.config(config$1), this.#originalHttpRequest = httpRequest;
|
|
2212
|
+
const requestHandler = config$1._requestHandler;
|
|
2213
|
+
this.#httpRequest = requestHandler ? /* @__PURE__ */ (() => {
|
|
2214
|
+
let bareClient;
|
|
2215
|
+
return (options, requester2) => {
|
|
2216
|
+
const opts = options;
|
|
2217
|
+
return bareClient || (bareClient = new SanityClient(httpRequest, { ...config$1, _requestHandler: void 0 })), requestHandler(opts, (o) => httpRequest(o, requester2), bareClient);
|
|
2218
|
+
};
|
|
2219
|
+
})() : httpRequest, this.assets = new ObservableAssetsClient(this, this.#httpRequest), this.datasets = new ObservableDatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.mediaLibrary = {
|
|
2210
2220
|
video: new ObservableMediaLibraryVideoClient(this, this.#httpRequest)
|
|
2211
2221
|
}, this.projects = new ObservableProjectsClient(this, this.#httpRequest), this.users = new ObservableUsersClient(this, this.#httpRequest), this.agent = {
|
|
2212
2222
|
action: new ObservableAgentsActionClient(this, this.#httpRequest)
|
|
@@ -2216,7 +2226,7 @@ class ObservableSanityClient {
|
|
|
2216
2226
|
* Clone the client - returns a new instance
|
|
2217
2227
|
*/
|
|
2218
2228
|
clone() {
|
|
2219
|
-
return new ObservableSanityClient(this.#
|
|
2229
|
+
return new ObservableSanityClient(this.#originalHttpRequest, this.config());
|
|
2220
2230
|
}
|
|
2221
2231
|
config(newConfig) {
|
|
2222
2232
|
if (newConfig === void 0)
|
|
@@ -2234,7 +2244,7 @@ class ObservableSanityClient {
|
|
|
2234
2244
|
*/
|
|
2235
2245
|
withConfig(newConfig) {
|
|
2236
2246
|
const thisConfig = this.config();
|
|
2237
|
-
return new ObservableSanityClient(this.#
|
|
2247
|
+
return new ObservableSanityClient(this.#originalHttpRequest, {
|
|
2238
2248
|
...thisConfig,
|
|
2239
2249
|
...newConfig,
|
|
2240
2250
|
stega: {
|
|
@@ -2464,13 +2474,22 @@ class SanityClient {
|
|
|
2464
2474
|
* Private properties
|
|
2465
2475
|
*/
|
|
2466
2476
|
#clientConfig;
|
|
2477
|
+
#originalHttpRequest;
|
|
2467
2478
|
#httpRequest;
|
|
2468
2479
|
/**
|
|
2469
2480
|
* Instance properties
|
|
2470
2481
|
*/
|
|
2471
2482
|
listen = _listen;
|
|
2472
2483
|
constructor(httpRequest, config$1 = config.defaultConfig) {
|
|
2473
|
-
this.config(config$1), this.#
|
|
2484
|
+
this.config(config$1), this.#originalHttpRequest = httpRequest;
|
|
2485
|
+
const requestHandler = config$1._requestHandler;
|
|
2486
|
+
this.#httpRequest = requestHandler ? /* @__PURE__ */ (() => {
|
|
2487
|
+
let bareClient;
|
|
2488
|
+
return (options, requester2) => {
|
|
2489
|
+
const opts = options;
|
|
2490
|
+
return bareClient || (bareClient = new SanityClient(httpRequest, { ...config$1, _requestHandler: void 0 })), requestHandler(opts, (o) => httpRequest(o, requester2), bareClient);
|
|
2491
|
+
};
|
|
2492
|
+
})() : httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.mediaLibrary = {
|
|
2474
2493
|
video: new MediaLibraryVideoClient(this, this.#httpRequest)
|
|
2475
2494
|
}, this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.agent = {
|
|
2476
2495
|
action: new AgentActionsClient(this, this.#httpRequest)
|
|
@@ -2480,7 +2499,7 @@ class SanityClient {
|
|
|
2480
2499
|
* Clone the client - returns a new instance
|
|
2481
2500
|
*/
|
|
2482
2501
|
clone() {
|
|
2483
|
-
return new SanityClient(this.#
|
|
2502
|
+
return new SanityClient(this.#originalHttpRequest, this.config());
|
|
2484
2503
|
}
|
|
2485
2504
|
config(newConfig) {
|
|
2486
2505
|
if (newConfig === void 0)
|
|
@@ -2498,7 +2517,7 @@ class SanityClient {
|
|
|
2498
2517
|
*/
|
|
2499
2518
|
withConfig(newConfig) {
|
|
2500
2519
|
const thisConfig = this.config();
|
|
2501
|
-
return new SanityClient(this.#
|
|
2520
|
+
return new SanityClient(this.#originalHttpRequest, {
|
|
2502
2521
|
...thisConfig,
|
|
2503
2522
|
...newConfig,
|
|
2504
2523
|
stega: {
|
|
@@ -2769,7 +2788,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
2769
2788
|
return config.printNoDefaultExport(), createClient2(config$1);
|
|
2770
2789
|
};
|
|
2771
2790
|
}
|
|
2772
|
-
var name = "@sanity/client", version = "7.
|
|
2791
|
+
var name = "@sanity/client", version = "7.21.0";
|
|
2773
2792
|
const middleware = [
|
|
2774
2793
|
middleware$1.debug({ verbose: !0, namespace: "sanity:client" }),
|
|
2775
2794
|
middleware$1.headers({ "User-Agent": `${name} ${version}` }),
|