@sanity/client 7.19.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 +49 -10
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +100 -24
- package/dist/index.browser.d.ts +100 -24
- package/dist/index.browser.js +49 -10
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +50 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +100 -24
- package/dist/index.d.ts +100 -24
- package/dist/index.js +50 -11
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +100 -24
- package/dist/stega.browser.d.ts +100 -24
- package/dist/stega.d.cts +100 -24
- package/dist/stega.d.ts +100 -24
- package/package.json +2 -2
- package/src/SanityClient.ts +38 -6
- package/src/data/live.ts +9 -0
- package/src/projects/ProjectsClient.ts +37 -36
- package/src/types.ts +62 -0
- package/umd/sanityClient.js +49 -10
- 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);
|
|
@@ -1787,9 +1788,18 @@ class ObservableProjectsClient {
|
|
|
1787
1788
|
constructor(client, httpRequest) {
|
|
1788
1789
|
this.#client = client, this.#httpRequest = httpRequest;
|
|
1789
1790
|
}
|
|
1791
|
+
/**
|
|
1792
|
+
* Fetch a list of projects the authenticated user has access to.
|
|
1793
|
+
*
|
|
1794
|
+
* @param options - Options for the list request
|
|
1795
|
+
* - `includeMembers` - Whether to include members in the response (default: true)
|
|
1796
|
+
* - `includeFeatures` - Whether to include features in the response (default: true)
|
|
1797
|
+
* - `organizationId` - ID of the organization to fetch projects for
|
|
1798
|
+
* - `onlyExplicitMembership` - Whether to include only projects with explicit membership (default: false)
|
|
1799
|
+
*/
|
|
1790
1800
|
list(options) {
|
|
1791
1801
|
const query = {}, uri = "/projects";
|
|
1792
|
-
return options?.includeMembers === !1 && (query.includeMembers = "false"), options?.organizationId && (query.organizationId = options.organizationId), options?.onlyExplicitMembership
|
|
1802
|
+
return options?.includeMembers === !1 && (query.includeMembers = "false"), options?.includeFeatures === !1 && (query.includeFeatures = "false"), options?.organizationId && (query.organizationId = options.organizationId), options?.onlyExplicitMembership && (query.onlyExplicitMembership = "true"), _request(this.#client, this.#httpRequest, { uri, query });
|
|
1793
1803
|
}
|
|
1794
1804
|
/**
|
|
1795
1805
|
* Fetch a project by project ID
|
|
@@ -1806,9 +1816,20 @@ class ProjectsClient {
|
|
|
1806
1816
|
constructor(client, httpRequest) {
|
|
1807
1817
|
this.#client = client, this.#httpRequest = httpRequest;
|
|
1808
1818
|
}
|
|
1819
|
+
/**
|
|
1820
|
+
* Fetch a list of projects the authenticated user has access to.
|
|
1821
|
+
*
|
|
1822
|
+
* @param options - Options for the list request
|
|
1823
|
+
* - `includeMembers` - Whether to include members in the response (default: true)
|
|
1824
|
+
* - `includeFeatures` - Whether to include features in the response (default: true)
|
|
1825
|
+
* - `organizationId` - ID of the organization to fetch projects for
|
|
1826
|
+
* - `onlyExplicitMembership` - Whether to include only projects with explicit membership (default: false)
|
|
1827
|
+
*/
|
|
1809
1828
|
list(options) {
|
|
1810
1829
|
const query = {}, uri = "/projects";
|
|
1811
|
-
return options?.includeMembers === !1 && (query.includeMembers = "false"), options?.organizationId && (query.organizationId = options.organizationId), options?.onlyExplicitMembership
|
|
1830
|
+
return options?.includeMembers === !1 && (query.includeMembers = "false"), options?.includeFeatures === !1 && (query.includeFeatures = "false"), options?.organizationId && (query.organizationId = options.organizationId), options?.onlyExplicitMembership && (query.onlyExplicitMembership = "true"), rxjs.lastValueFrom(
|
|
1831
|
+
_request(this.#client, this.#httpRequest, { uri, query })
|
|
1832
|
+
);
|
|
1812
1833
|
}
|
|
1813
1834
|
/**
|
|
1814
1835
|
* Fetch a project by project ID
|
|
@@ -2364,13 +2385,22 @@ class ObservableSanityClient {
|
|
|
2364
2385
|
* Private properties
|
|
2365
2386
|
*/
|
|
2366
2387
|
#clientConfig;
|
|
2388
|
+
#originalHttpRequest;
|
|
2367
2389
|
#httpRequest;
|
|
2368
2390
|
/**
|
|
2369
2391
|
* Instance properties
|
|
2370
2392
|
*/
|
|
2371
2393
|
listen = _listen;
|
|
2372
2394
|
constructor(httpRequest, config = defaultConfig) {
|
|
2373
|
-
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 = {
|
|
2374
2404
|
video: new ObservableMediaLibraryVideoClient(this, this.#httpRequest)
|
|
2375
2405
|
}, this.projects = new ObservableProjectsClient(this, this.#httpRequest), this.users = new ObservableUsersClient(this, this.#httpRequest), this.agent = {
|
|
2376
2406
|
action: new ObservableAgentsActionClient(this, this.#httpRequest)
|
|
@@ -2380,7 +2410,7 @@ class ObservableSanityClient {
|
|
|
2380
2410
|
* Clone the client - returns a new instance
|
|
2381
2411
|
*/
|
|
2382
2412
|
clone() {
|
|
2383
|
-
return new ObservableSanityClient(this.#
|
|
2413
|
+
return new ObservableSanityClient(this.#originalHttpRequest, this.config());
|
|
2384
2414
|
}
|
|
2385
2415
|
config(newConfig) {
|
|
2386
2416
|
if (newConfig === void 0)
|
|
@@ -2398,7 +2428,7 @@ class ObservableSanityClient {
|
|
|
2398
2428
|
*/
|
|
2399
2429
|
withConfig(newConfig) {
|
|
2400
2430
|
const thisConfig = this.config();
|
|
2401
|
-
return new ObservableSanityClient(this.#
|
|
2431
|
+
return new ObservableSanityClient(this.#originalHttpRequest, {
|
|
2402
2432
|
...thisConfig,
|
|
2403
2433
|
...newConfig,
|
|
2404
2434
|
stega: {
|
|
@@ -2628,13 +2658,22 @@ class SanityClient {
|
|
|
2628
2658
|
* Private properties
|
|
2629
2659
|
*/
|
|
2630
2660
|
#clientConfig;
|
|
2661
|
+
#originalHttpRequest;
|
|
2631
2662
|
#httpRequest;
|
|
2632
2663
|
/**
|
|
2633
2664
|
* Instance properties
|
|
2634
2665
|
*/
|
|
2635
2666
|
listen = _listen;
|
|
2636
2667
|
constructor(httpRequest, config = defaultConfig) {
|
|
2637
|
-
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 = {
|
|
2638
2677
|
video: new MediaLibraryVideoClient(this, this.#httpRequest)
|
|
2639
2678
|
}, this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.agent = {
|
|
2640
2679
|
action: new AgentActionsClient(this, this.#httpRequest)
|
|
@@ -2644,7 +2683,7 @@ class SanityClient {
|
|
|
2644
2683
|
* Clone the client - returns a new instance
|
|
2645
2684
|
*/
|
|
2646
2685
|
clone() {
|
|
2647
|
-
return new SanityClient(this.#
|
|
2686
|
+
return new SanityClient(this.#originalHttpRequest, this.config());
|
|
2648
2687
|
}
|
|
2649
2688
|
config(newConfig) {
|
|
2650
2689
|
if (newConfig === void 0)
|
|
@@ -2662,7 +2701,7 @@ class SanityClient {
|
|
|
2662
2701
|
*/
|
|
2663
2702
|
withConfig(newConfig) {
|
|
2664
2703
|
const thisConfig = this.config();
|
|
2665
|
-
return new SanityClient(this.#
|
|
2704
|
+
return new SanityClient(this.#originalHttpRequest, {
|
|
2666
2705
|
...thisConfig,
|
|
2667
2706
|
...newConfig,
|
|
2668
2707
|
stega: {
|