@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/umd/sanityClient.js
CHANGED
|
@@ -3425,7 +3425,8 @@ ${selectionOpts}`);
|
|
|
3425
3425
|
*/
|
|
3426
3426
|
events({
|
|
3427
3427
|
includeDrafts = false,
|
|
3428
|
-
tag: _tag
|
|
3428
|
+
tag: _tag,
|
|
3429
|
+
waitFor
|
|
3429
3430
|
} = {}) {
|
|
3430
3431
|
const {
|
|
3431
3432
|
projectId: projectId2,
|
|
@@ -3444,7 +3445,7 @@ ${selectionOpts}`);
|
|
|
3444
3445
|
"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."
|
|
3445
3446
|
);
|
|
3446
3447
|
const path = _getDataUrl(this.#client, "live/events"), url = new URL(this.#client.getUrl(path, false)), tag = _tag && requestTagPrefix ? [requestTagPrefix, _tag].join(".") : _tag;
|
|
3447
|
-
tag && url.searchParams.set("tag", tag), includeDrafts && url.searchParams.set("includeDrafts", "true");
|
|
3448
|
+
tag && url.searchParams.set("tag", tag), includeDrafts && url.searchParams.set("includeDrafts", "true"), waitFor && url.searchParams.set("waitFor", waitFor);
|
|
3448
3449
|
const esOptions = {};
|
|
3449
3450
|
includeDrafts && withCredentials && (esOptions.withCredentials = true), (includeDrafts && token || configHeaders) && (esOptions.headers = {}, includeDrafts && token && (esOptions.headers.Authorization = `Bearer ${token}`), configHeaders && Object.assign(esOptions.headers, configHeaders));
|
|
3450
3451
|
const key = `${url.href}::${JSON.stringify(esOptions)}`, existing = eventsCache.get(key);
|
|
@@ -4342,13 +4343,22 @@ ${selectionOpts}`);
|
|
|
4342
4343
|
* Private properties
|
|
4343
4344
|
*/
|
|
4344
4345
|
#clientConfig;
|
|
4346
|
+
#originalHttpRequest;
|
|
4345
4347
|
#httpRequest;
|
|
4346
4348
|
/**
|
|
4347
4349
|
* Instance properties
|
|
4348
4350
|
*/
|
|
4349
4351
|
listen = _listen;
|
|
4350
4352
|
constructor(httpRequest, config = defaultConfig) {
|
|
4351
|
-
this.config(config), this.#
|
|
4353
|
+
this.config(config), this.#originalHttpRequest = httpRequest;
|
|
4354
|
+
const requestHandler = config._requestHandler;
|
|
4355
|
+
this.#httpRequest = requestHandler ? /* @__PURE__ */ (() => {
|
|
4356
|
+
let bareClient;
|
|
4357
|
+
return (options, requester2) => {
|
|
4358
|
+
const opts = options;
|
|
4359
|
+
return bareClient || (bareClient = new SanityClient(httpRequest, { ...config, _requestHandler: void 0 })), requestHandler(opts, (o) => httpRequest(o, requester2), bareClient);
|
|
4360
|
+
};
|
|
4361
|
+
})() : httpRequest, this.assets = new ObservableAssetsClient(this, this.#httpRequest), this.datasets = new ObservableDatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.mediaLibrary = {
|
|
4352
4362
|
video: new ObservableMediaLibraryVideoClient(this, this.#httpRequest)
|
|
4353
4363
|
}, this.projects = new ObservableProjectsClient(this, this.#httpRequest), this.users = new ObservableUsersClient(this, this.#httpRequest), this.agent = {
|
|
4354
4364
|
action: new ObservableAgentsActionClient(this, this.#httpRequest)
|
|
@@ -4358,7 +4368,7 @@ ${selectionOpts}`);
|
|
|
4358
4368
|
* Clone the client - returns a new instance
|
|
4359
4369
|
*/
|
|
4360
4370
|
clone() {
|
|
4361
|
-
return new ObservableSanityClient(this.#
|
|
4371
|
+
return new ObservableSanityClient(this.#originalHttpRequest, this.config());
|
|
4362
4372
|
}
|
|
4363
4373
|
config(newConfig) {
|
|
4364
4374
|
if (newConfig === void 0)
|
|
@@ -4376,7 +4386,7 @@ ${selectionOpts}`);
|
|
|
4376
4386
|
*/
|
|
4377
4387
|
withConfig(newConfig) {
|
|
4378
4388
|
const thisConfig = this.config();
|
|
4379
|
-
return new ObservableSanityClient(this.#
|
|
4389
|
+
return new ObservableSanityClient(this.#originalHttpRequest, {
|
|
4380
4390
|
...thisConfig,
|
|
4381
4391
|
...newConfig,
|
|
4382
4392
|
stega: {
|
|
@@ -4606,13 +4616,22 @@ ${selectionOpts}`);
|
|
|
4606
4616
|
* Private properties
|
|
4607
4617
|
*/
|
|
4608
4618
|
#clientConfig;
|
|
4619
|
+
#originalHttpRequest;
|
|
4609
4620
|
#httpRequest;
|
|
4610
4621
|
/**
|
|
4611
4622
|
* Instance properties
|
|
4612
4623
|
*/
|
|
4613
4624
|
listen = _listen;
|
|
4614
4625
|
constructor(httpRequest, config = defaultConfig) {
|
|
4615
|
-
this.config(config), this.#
|
|
4626
|
+
this.config(config), this.#originalHttpRequest = httpRequest;
|
|
4627
|
+
const requestHandler = config._requestHandler;
|
|
4628
|
+
this.#httpRequest = requestHandler ? /* @__PURE__ */ (() => {
|
|
4629
|
+
let bareClient;
|
|
4630
|
+
return (options, requester2) => {
|
|
4631
|
+
const opts = options;
|
|
4632
|
+
return bareClient || (bareClient = new SanityClient(httpRequest, { ...config, _requestHandler: void 0 })), requestHandler(opts, (o) => httpRequest(o, requester2), bareClient);
|
|
4633
|
+
};
|
|
4634
|
+
})() : httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.mediaLibrary = {
|
|
4616
4635
|
video: new MediaLibraryVideoClient(this, this.#httpRequest)
|
|
4617
4636
|
}, this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.agent = {
|
|
4618
4637
|
action: new AgentActionsClient(this, this.#httpRequest)
|
|
@@ -4622,7 +4641,7 @@ ${selectionOpts}`);
|
|
|
4622
4641
|
* Clone the client - returns a new instance
|
|
4623
4642
|
*/
|
|
4624
4643
|
clone() {
|
|
4625
|
-
return new SanityClient(this.#
|
|
4644
|
+
return new SanityClient(this.#originalHttpRequest, this.config());
|
|
4626
4645
|
}
|
|
4627
4646
|
config(newConfig) {
|
|
4628
4647
|
if (newConfig === void 0)
|
|
@@ -4640,7 +4659,7 @@ ${selectionOpts}`);
|
|
|
4640
4659
|
*/
|
|
4641
4660
|
withConfig(newConfig) {
|
|
4642
4661
|
const thisConfig = this.config();
|
|
4643
|
-
return new SanityClient(this.#
|
|
4662
|
+
return new SanityClient(this.#originalHttpRequest, {
|
|
4644
4663
|
...thisConfig,
|
|
4645
4664
|
...newConfig,
|
|
4646
4665
|
stega: {
|