@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.browser.cjs
CHANGED
|
@@ -1467,7 +1467,8 @@ class LiveClient {
|
|
|
1467
1467
|
*/
|
|
1468
1468
|
events({
|
|
1469
1469
|
includeDrafts = !1,
|
|
1470
|
-
tag: _tag
|
|
1470
|
+
tag: _tag,
|
|
1471
|
+
waitFor
|
|
1471
1472
|
} = {}) {
|
|
1472
1473
|
const {
|
|
1473
1474
|
projectId: projectId2,
|
|
@@ -1486,7 +1487,7 @@ class LiveClient {
|
|
|
1486
1487
|
"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."
|
|
1487
1488
|
);
|
|
1488
1489
|
const path = _getDataUrl(this.#client, "live/events"), url = new URL(this.#client.getUrl(path, !1)), tag = _tag && requestTagPrefix ? [requestTagPrefix, _tag].join(".") : _tag;
|
|
1489
|
-
tag && url.searchParams.set("tag", tag), includeDrafts && url.searchParams.set("includeDrafts", "true");
|
|
1490
|
+
tag && url.searchParams.set("tag", tag), includeDrafts && url.searchParams.set("includeDrafts", "true"), waitFor && url.searchParams.set("waitFor", waitFor);
|
|
1490
1491
|
const esOptions = {};
|
|
1491
1492
|
includeDrafts && withCredentials && (esOptions.withCredentials = !0), (includeDrafts && token || configHeaders) && (esOptions.headers = {}, includeDrafts && token && (esOptions.headers.Authorization = `Bearer ${token}`), configHeaders && Object.assign(esOptions.headers, configHeaders));
|
|
1492
1493
|
const key = `${url.href}::${JSON.stringify(esOptions)}`, existing = eventsCache.get(key);
|
|
@@ -2384,13 +2385,22 @@ class ObservableSanityClient {
|
|
|
2384
2385
|
* Private properties
|
|
2385
2386
|
*/
|
|
2386
2387
|
#clientConfig;
|
|
2388
|
+
#originalHttpRequest;
|
|
2387
2389
|
#httpRequest;
|
|
2388
2390
|
/**
|
|
2389
2391
|
* Instance properties
|
|
2390
2392
|
*/
|
|
2391
2393
|
listen = _listen;
|
|
2392
2394
|
constructor(httpRequest, config = defaultConfig) {
|
|
2393
|
-
this.config(config), this.#
|
|
2395
|
+
this.config(config), this.#originalHttpRequest = httpRequest;
|
|
2396
|
+
const requestHandler = config._requestHandler;
|
|
2397
|
+
this.#httpRequest = requestHandler ? /* @__PURE__ */ (() => {
|
|
2398
|
+
let bareClient;
|
|
2399
|
+
return (options, requester2) => {
|
|
2400
|
+
const opts = options;
|
|
2401
|
+
return bareClient || (bareClient = new SanityClient(httpRequest, { ...config, _requestHandler: void 0 })), requestHandler(opts, (o) => httpRequest(o, requester2), bareClient);
|
|
2402
|
+
};
|
|
2403
|
+
})() : httpRequest, this.assets = new ObservableAssetsClient(this, this.#httpRequest), this.datasets = new ObservableDatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.mediaLibrary = {
|
|
2394
2404
|
video: new ObservableMediaLibraryVideoClient(this, this.#httpRequest)
|
|
2395
2405
|
}, this.projects = new ObservableProjectsClient(this, this.#httpRequest), this.users = new ObservableUsersClient(this, this.#httpRequest), this.agent = {
|
|
2396
2406
|
action: new ObservableAgentsActionClient(this, this.#httpRequest)
|
|
@@ -2400,7 +2410,7 @@ class ObservableSanityClient {
|
|
|
2400
2410
|
* Clone the client - returns a new instance
|
|
2401
2411
|
*/
|
|
2402
2412
|
clone() {
|
|
2403
|
-
return new ObservableSanityClient(this.#
|
|
2413
|
+
return new ObservableSanityClient(this.#originalHttpRequest, this.config());
|
|
2404
2414
|
}
|
|
2405
2415
|
config(newConfig) {
|
|
2406
2416
|
if (newConfig === void 0)
|
|
@@ -2418,7 +2428,7 @@ class ObservableSanityClient {
|
|
|
2418
2428
|
*/
|
|
2419
2429
|
withConfig(newConfig) {
|
|
2420
2430
|
const thisConfig = this.config();
|
|
2421
|
-
return new ObservableSanityClient(this.#
|
|
2431
|
+
return new ObservableSanityClient(this.#originalHttpRequest, {
|
|
2422
2432
|
...thisConfig,
|
|
2423
2433
|
...newConfig,
|
|
2424
2434
|
stega: {
|
|
@@ -2648,13 +2658,22 @@ class SanityClient {
|
|
|
2648
2658
|
* Private properties
|
|
2649
2659
|
*/
|
|
2650
2660
|
#clientConfig;
|
|
2661
|
+
#originalHttpRequest;
|
|
2651
2662
|
#httpRequest;
|
|
2652
2663
|
/**
|
|
2653
2664
|
* Instance properties
|
|
2654
2665
|
*/
|
|
2655
2666
|
listen = _listen;
|
|
2656
2667
|
constructor(httpRequest, config = defaultConfig) {
|
|
2657
|
-
this.config(config), this.#
|
|
2668
|
+
this.config(config), this.#originalHttpRequest = httpRequest;
|
|
2669
|
+
const requestHandler = config._requestHandler;
|
|
2670
|
+
this.#httpRequest = requestHandler ? /* @__PURE__ */ (() => {
|
|
2671
|
+
let bareClient;
|
|
2672
|
+
return (options, requester2) => {
|
|
2673
|
+
const opts = options;
|
|
2674
|
+
return bareClient || (bareClient = new SanityClient(httpRequest, { ...config, _requestHandler: void 0 })), requestHandler(opts, (o) => httpRequest(o, requester2), bareClient);
|
|
2675
|
+
};
|
|
2676
|
+
})() : httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.mediaLibrary = {
|
|
2658
2677
|
video: new MediaLibraryVideoClient(this, this.#httpRequest)
|
|
2659
2678
|
}, this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.agent = {
|
|
2660
2679
|
action: new AgentActionsClient(this, this.#httpRequest)
|
|
@@ -2664,7 +2683,7 @@ class SanityClient {
|
|
|
2664
2683
|
* Clone the client - returns a new instance
|
|
2665
2684
|
*/
|
|
2666
2685
|
clone() {
|
|
2667
|
-
return new SanityClient(this.#
|
|
2686
|
+
return new SanityClient(this.#originalHttpRequest, this.config());
|
|
2668
2687
|
}
|
|
2669
2688
|
config(newConfig) {
|
|
2670
2689
|
if (newConfig === void 0)
|
|
@@ -2682,7 +2701,7 @@ class SanityClient {
|
|
|
2682
2701
|
*/
|
|
2683
2702
|
withConfig(newConfig) {
|
|
2684
2703
|
const thisConfig = this.config();
|
|
2685
|
-
return new SanityClient(this.#
|
|
2704
|
+
return new SanityClient(this.#originalHttpRequest, {
|
|
2686
2705
|
...thisConfig,
|
|
2687
2706
|
...newConfig,
|
|
2688
2707
|
stega: {
|