@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.d.cts
CHANGED
|
@@ -810,6 +810,32 @@ export declare interface ClientConfig {
|
|
|
810
810
|
* Lineage token for recursion control
|
|
811
811
|
*/
|
|
812
812
|
lineage?: string
|
|
813
|
+
/**
|
|
814
|
+
* A custom request handler that intercepts all HTTP requests made by the client.
|
|
815
|
+
*
|
|
816
|
+
* Useful for logging, adding custom headers, refreshing auth tokens, rate limiting, etc.
|
|
817
|
+
*
|
|
818
|
+
* When using `withConfig()`, the new handler **replaces** the previous one (it does not
|
|
819
|
+
* wrap it). To compose handlers, you can chain them manually:
|
|
820
|
+
*
|
|
821
|
+
* ```ts
|
|
822
|
+
* const parent = createClient({...config, _requestHandler: handlerA})
|
|
823
|
+
* const child = parent.withConfig({
|
|
824
|
+
* _requestHandler: (req, defaultRequester) =>
|
|
825
|
+
* handlerB(req, (opts) => handlerA(opts, defaultRequester)),
|
|
826
|
+
* })
|
|
827
|
+
* ```
|
|
828
|
+
*
|
|
829
|
+
* Setting `_requestHandler` to `undefined` via `withConfig()` removes the handler.
|
|
830
|
+
*
|
|
831
|
+
* Note: This only applies to HTTP requests. Real-time listener connections
|
|
832
|
+
* (`client.listen()`) use EventSource and are not intercepted by this handler.
|
|
833
|
+
*
|
|
834
|
+
* @internal
|
|
835
|
+
* @deprecated Don't use outside of Sanity internals
|
|
836
|
+
* @see {@link RequestHandler}
|
|
837
|
+
*/
|
|
838
|
+
_requestHandler?: RequestHandler
|
|
813
839
|
}
|
|
814
840
|
|
|
815
841
|
declare type ClientConfigResource =
|
|
@@ -2142,6 +2168,13 @@ export declare type ListenParams = {
|
|
|
2142
2168
|
[key: string]: Any
|
|
2143
2169
|
}
|
|
2144
2170
|
|
|
2171
|
+
declare type ListOptions = {
|
|
2172
|
+
includeMembers?: boolean
|
|
2173
|
+
includeFeatures?: boolean
|
|
2174
|
+
organizationId?: string
|
|
2175
|
+
onlyExplicitMembership?: boolean
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2145
2178
|
/**
|
|
2146
2179
|
* @public
|
|
2147
2180
|
*/
|
|
@@ -2154,6 +2187,7 @@ export declare class LiveClient {
|
|
|
2154
2187
|
events({
|
|
2155
2188
|
includeDrafts,
|
|
2156
2189
|
tag: _tag,
|
|
2190
|
+
waitFor,
|
|
2157
2191
|
}?: {
|
|
2158
2192
|
includeDrafts?: boolean
|
|
2159
2193
|
/**
|
|
@@ -2162,6 +2196,11 @@ export declare class LiveClient {
|
|
|
2162
2196
|
* @defaultValue `undefined`
|
|
2163
2197
|
*/
|
|
2164
2198
|
tag?: string
|
|
2199
|
+
/**
|
|
2200
|
+
* Delays events until after a Sanity Function has processed them and called the callback endpoint.
|
|
2201
|
+
* When omitted, events are delivered immediately.
|
|
2202
|
+
*/
|
|
2203
|
+
waitFor?: 'function'
|
|
2165
2204
|
}): Observable<LiveEvent>
|
|
2166
2205
|
}
|
|
2167
2206
|
|
|
@@ -2698,19 +2737,13 @@ export declare class ObservableProjectsClient {
|
|
|
2698
2737
|
*
|
|
2699
2738
|
* @param options - Options for the list request
|
|
2700
2739
|
* - `includeMembers` - Whether to include members in the response (default: true)
|
|
2740
|
+
* - `includeFeatures` - Whether to include features in the response (default: true)
|
|
2701
2741
|
* - `organizationId` - ID of the organization to fetch projects for
|
|
2702
|
-
* - `onlyExplicitMembership` -
|
|
2703
|
-
*/
|
|
2704
|
-
list(
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
onlyExplicitMembership?: boolean
|
|
2708
|
-
}): Observable<SanityProject[]>
|
|
2709
|
-
list(options?: {
|
|
2710
|
-
includeMembers?: false
|
|
2711
|
-
organizationId?: string
|
|
2712
|
-
onlyExplicitMembership?: boolean
|
|
2713
|
-
}): Observable<Omit<SanityProject, 'members'>[]>
|
|
2742
|
+
* - `onlyExplicitMembership` - Whether to include only projects with explicit membership (default: false)
|
|
2743
|
+
*/
|
|
2744
|
+
list<T extends ListOptions>(
|
|
2745
|
+
options?: T,
|
|
2746
|
+
): Observable<Omit<SanityProject, OmittedProjectFields<T>>[]>
|
|
2714
2747
|
/**
|
|
2715
2748
|
* Fetch a project by project ID
|
|
2716
2749
|
*
|
|
@@ -3865,6 +3898,18 @@ export declare class ObservableUsersClient {
|
|
|
3865
3898
|
): Observable<T extends 'me' ? CurrentSanityUser : SanityUser>
|
|
3866
3899
|
}
|
|
3867
3900
|
|
|
3901
|
+
declare type OmittedProjectFields<T extends ListOptions | undefined> =
|
|
3902
|
+
| (T extends {
|
|
3903
|
+
includeMembers: false
|
|
3904
|
+
}
|
|
3905
|
+
? 'members'
|
|
3906
|
+
: never)
|
|
3907
|
+
| (T extends {
|
|
3908
|
+
includeFeatures: false
|
|
3909
|
+
}
|
|
3910
|
+
? 'features'
|
|
3911
|
+
: never)
|
|
3912
|
+
|
|
3868
3913
|
/**
|
|
3869
3914
|
* The listener connection has been established
|
|
3870
3915
|
* note: it's usually a better option to use the 'welcome' event
|
|
@@ -4081,19 +4126,11 @@ export declare class ProjectsClient {
|
|
|
4081
4126
|
*
|
|
4082
4127
|
* @param options - Options for the list request
|
|
4083
4128
|
* - `includeMembers` - Whether to include members in the response (default: true)
|
|
4129
|
+
* - `includeFeatures` - Whether to include features in the response (default: true)
|
|
4084
4130
|
* - `organizationId` - ID of the organization to fetch projects for
|
|
4085
|
-
* - `onlyExplicitMembership` -
|
|
4086
|
-
*/
|
|
4087
|
-
list(options?:
|
|
4088
|
-
includeMembers?: true
|
|
4089
|
-
organizationId?: string
|
|
4090
|
-
onlyExplicitMembership?: boolean
|
|
4091
|
-
}): Promise<SanityProject[]>
|
|
4092
|
-
list(options?: {
|
|
4093
|
-
includeMembers?: false
|
|
4094
|
-
organizationId?: string
|
|
4095
|
-
onlyExplicitMembership?: boolean
|
|
4096
|
-
}): Promise<Omit<SanityProject, 'members'>[]>
|
|
4131
|
+
* - `onlyExplicitMembership` - Whether to include only projects with explicit membership (default: false)
|
|
4132
|
+
*/
|
|
4133
|
+
list<T extends ListOptions>(options?: T): Promise<Omit<SanityProject, OmittedProjectFields<T>>[]>
|
|
4097
4134
|
/**
|
|
4098
4135
|
* Fetch a project by project ID
|
|
4099
4136
|
*
|
|
@@ -4773,6 +4810,44 @@ export declare interface ReplaceVersionAction {
|
|
|
4773
4810
|
/** @public */
|
|
4774
4811
|
export declare const requester: Requester
|
|
4775
4812
|
|
|
4813
|
+
/**
|
|
4814
|
+
* A function that intercepts HTTP requests made by the client.
|
|
4815
|
+
*
|
|
4816
|
+
* Receives the resolved request options, a `defaultRequester` function that
|
|
4817
|
+
* executes the request through the normal pipeline, and a `client` instance
|
|
4818
|
+
* without a `_requestHandler` (to avoid recursive interception).
|
|
4819
|
+
*
|
|
4820
|
+
* The consumer can:
|
|
4821
|
+
* - Modify request options before calling `defaultRequester`
|
|
4822
|
+
* - Transform the response stream (e.g. via `pipe`)
|
|
4823
|
+
* - Skip `defaultRequester` entirely and return a custom Observable
|
|
4824
|
+
* - Use `client` to make additional requests (e.g. refresh an auth token on 401)
|
|
4825
|
+
*
|
|
4826
|
+
* When set via `withConfig()`, the new handler **replaces** (not wraps) the previous one.
|
|
4827
|
+
*
|
|
4828
|
+
* Note: This only applies to HTTP requests. Real-time listener connections
|
|
4829
|
+
* (`client.listen()`) use EventSource and are not intercepted by this handler.
|
|
4830
|
+
*
|
|
4831
|
+
* @param request - The resolved request options including `url`
|
|
4832
|
+
* @param defaultRequester - Executes the request through the normal pipeline
|
|
4833
|
+
* @param client - A client instance with the same configuration but without a `_requestHandler`,
|
|
4834
|
+
* useful for making side requests (e.g. token refresh) without triggering the handler recursively
|
|
4835
|
+
*
|
|
4836
|
+
* @internal
|
|
4837
|
+
* @deprecated Don't use outside of Sanity internals
|
|
4838
|
+
*/
|
|
4839
|
+
export declare type RequestHandler = (
|
|
4840
|
+
request: RequestOptions & {
|
|
4841
|
+
url: string
|
|
4842
|
+
},
|
|
4843
|
+
defaultRequester: (
|
|
4844
|
+
options: RequestOptions & {
|
|
4845
|
+
url: string
|
|
4846
|
+
},
|
|
4847
|
+
) => Observable<HttpRequestEvent>,
|
|
4848
|
+
client: SanityClient,
|
|
4849
|
+
) => Observable<HttpRequestEvent>
|
|
4850
|
+
|
|
4776
4851
|
/** @internal */
|
|
4777
4852
|
export declare interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {
|
|
4778
4853
|
url?: string
|
|
@@ -5746,6 +5821,7 @@ export declare interface SanityProject {
|
|
|
5746
5821
|
pendingInvites?: number
|
|
5747
5822
|
maxRetentionDays?: number
|
|
5748
5823
|
members: SanityProjectMember[]
|
|
5824
|
+
features: string[]
|
|
5749
5825
|
metadata: {
|
|
5750
5826
|
cliInitializedAt?: string
|
|
5751
5827
|
color?: string
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -810,6 +810,32 @@ export declare interface ClientConfig {
|
|
|
810
810
|
* Lineage token for recursion control
|
|
811
811
|
*/
|
|
812
812
|
lineage?: string
|
|
813
|
+
/**
|
|
814
|
+
* A custom request handler that intercepts all HTTP requests made by the client.
|
|
815
|
+
*
|
|
816
|
+
* Useful for logging, adding custom headers, refreshing auth tokens, rate limiting, etc.
|
|
817
|
+
*
|
|
818
|
+
* When using `withConfig()`, the new handler **replaces** the previous one (it does not
|
|
819
|
+
* wrap it). To compose handlers, you can chain them manually:
|
|
820
|
+
*
|
|
821
|
+
* ```ts
|
|
822
|
+
* const parent = createClient({...config, _requestHandler: handlerA})
|
|
823
|
+
* const child = parent.withConfig({
|
|
824
|
+
* _requestHandler: (req, defaultRequester) =>
|
|
825
|
+
* handlerB(req, (opts) => handlerA(opts, defaultRequester)),
|
|
826
|
+
* })
|
|
827
|
+
* ```
|
|
828
|
+
*
|
|
829
|
+
* Setting `_requestHandler` to `undefined` via `withConfig()` removes the handler.
|
|
830
|
+
*
|
|
831
|
+
* Note: This only applies to HTTP requests. Real-time listener connections
|
|
832
|
+
* (`client.listen()`) use EventSource and are not intercepted by this handler.
|
|
833
|
+
*
|
|
834
|
+
* @internal
|
|
835
|
+
* @deprecated Don't use outside of Sanity internals
|
|
836
|
+
* @see {@link RequestHandler}
|
|
837
|
+
*/
|
|
838
|
+
_requestHandler?: RequestHandler
|
|
813
839
|
}
|
|
814
840
|
|
|
815
841
|
declare type ClientConfigResource =
|
|
@@ -2142,6 +2168,13 @@ export declare type ListenParams = {
|
|
|
2142
2168
|
[key: string]: Any
|
|
2143
2169
|
}
|
|
2144
2170
|
|
|
2171
|
+
declare type ListOptions = {
|
|
2172
|
+
includeMembers?: boolean
|
|
2173
|
+
includeFeatures?: boolean
|
|
2174
|
+
organizationId?: string
|
|
2175
|
+
onlyExplicitMembership?: boolean
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2145
2178
|
/**
|
|
2146
2179
|
* @public
|
|
2147
2180
|
*/
|
|
@@ -2154,6 +2187,7 @@ export declare class LiveClient {
|
|
|
2154
2187
|
events({
|
|
2155
2188
|
includeDrafts,
|
|
2156
2189
|
tag: _tag,
|
|
2190
|
+
waitFor,
|
|
2157
2191
|
}?: {
|
|
2158
2192
|
includeDrafts?: boolean
|
|
2159
2193
|
/**
|
|
@@ -2162,6 +2196,11 @@ export declare class LiveClient {
|
|
|
2162
2196
|
* @defaultValue `undefined`
|
|
2163
2197
|
*/
|
|
2164
2198
|
tag?: string
|
|
2199
|
+
/**
|
|
2200
|
+
* Delays events until after a Sanity Function has processed them and called the callback endpoint.
|
|
2201
|
+
* When omitted, events are delivered immediately.
|
|
2202
|
+
*/
|
|
2203
|
+
waitFor?: 'function'
|
|
2165
2204
|
}): Observable<LiveEvent>
|
|
2166
2205
|
}
|
|
2167
2206
|
|
|
@@ -2698,19 +2737,13 @@ export declare class ObservableProjectsClient {
|
|
|
2698
2737
|
*
|
|
2699
2738
|
* @param options - Options for the list request
|
|
2700
2739
|
* - `includeMembers` - Whether to include members in the response (default: true)
|
|
2740
|
+
* - `includeFeatures` - Whether to include features in the response (default: true)
|
|
2701
2741
|
* - `organizationId` - ID of the organization to fetch projects for
|
|
2702
|
-
* - `onlyExplicitMembership` -
|
|
2703
|
-
*/
|
|
2704
|
-
list(
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
onlyExplicitMembership?: boolean
|
|
2708
|
-
}): Observable<SanityProject[]>
|
|
2709
|
-
list(options?: {
|
|
2710
|
-
includeMembers?: false
|
|
2711
|
-
organizationId?: string
|
|
2712
|
-
onlyExplicitMembership?: boolean
|
|
2713
|
-
}): Observable<Omit<SanityProject, 'members'>[]>
|
|
2742
|
+
* - `onlyExplicitMembership` - Whether to include only projects with explicit membership (default: false)
|
|
2743
|
+
*/
|
|
2744
|
+
list<T extends ListOptions>(
|
|
2745
|
+
options?: T,
|
|
2746
|
+
): Observable<Omit<SanityProject, OmittedProjectFields<T>>[]>
|
|
2714
2747
|
/**
|
|
2715
2748
|
* Fetch a project by project ID
|
|
2716
2749
|
*
|
|
@@ -3865,6 +3898,18 @@ export declare class ObservableUsersClient {
|
|
|
3865
3898
|
): Observable<T extends 'me' ? CurrentSanityUser : SanityUser>
|
|
3866
3899
|
}
|
|
3867
3900
|
|
|
3901
|
+
declare type OmittedProjectFields<T extends ListOptions | undefined> =
|
|
3902
|
+
| (T extends {
|
|
3903
|
+
includeMembers: false
|
|
3904
|
+
}
|
|
3905
|
+
? 'members'
|
|
3906
|
+
: never)
|
|
3907
|
+
| (T extends {
|
|
3908
|
+
includeFeatures: false
|
|
3909
|
+
}
|
|
3910
|
+
? 'features'
|
|
3911
|
+
: never)
|
|
3912
|
+
|
|
3868
3913
|
/**
|
|
3869
3914
|
* The listener connection has been established
|
|
3870
3915
|
* note: it's usually a better option to use the 'welcome' event
|
|
@@ -4081,19 +4126,11 @@ export declare class ProjectsClient {
|
|
|
4081
4126
|
*
|
|
4082
4127
|
* @param options - Options for the list request
|
|
4083
4128
|
* - `includeMembers` - Whether to include members in the response (default: true)
|
|
4129
|
+
* - `includeFeatures` - Whether to include features in the response (default: true)
|
|
4084
4130
|
* - `organizationId` - ID of the organization to fetch projects for
|
|
4085
|
-
* - `onlyExplicitMembership` -
|
|
4086
|
-
*/
|
|
4087
|
-
list(options?:
|
|
4088
|
-
includeMembers?: true
|
|
4089
|
-
organizationId?: string
|
|
4090
|
-
onlyExplicitMembership?: boolean
|
|
4091
|
-
}): Promise<SanityProject[]>
|
|
4092
|
-
list(options?: {
|
|
4093
|
-
includeMembers?: false
|
|
4094
|
-
organizationId?: string
|
|
4095
|
-
onlyExplicitMembership?: boolean
|
|
4096
|
-
}): Promise<Omit<SanityProject, 'members'>[]>
|
|
4131
|
+
* - `onlyExplicitMembership` - Whether to include only projects with explicit membership (default: false)
|
|
4132
|
+
*/
|
|
4133
|
+
list<T extends ListOptions>(options?: T): Promise<Omit<SanityProject, OmittedProjectFields<T>>[]>
|
|
4097
4134
|
/**
|
|
4098
4135
|
* Fetch a project by project ID
|
|
4099
4136
|
*
|
|
@@ -4773,6 +4810,44 @@ export declare interface ReplaceVersionAction {
|
|
|
4773
4810
|
/** @public */
|
|
4774
4811
|
export declare const requester: Requester
|
|
4775
4812
|
|
|
4813
|
+
/**
|
|
4814
|
+
* A function that intercepts HTTP requests made by the client.
|
|
4815
|
+
*
|
|
4816
|
+
* Receives the resolved request options, a `defaultRequester` function that
|
|
4817
|
+
* executes the request through the normal pipeline, and a `client` instance
|
|
4818
|
+
* without a `_requestHandler` (to avoid recursive interception).
|
|
4819
|
+
*
|
|
4820
|
+
* The consumer can:
|
|
4821
|
+
* - Modify request options before calling `defaultRequester`
|
|
4822
|
+
* - Transform the response stream (e.g. via `pipe`)
|
|
4823
|
+
* - Skip `defaultRequester` entirely and return a custom Observable
|
|
4824
|
+
* - Use `client` to make additional requests (e.g. refresh an auth token on 401)
|
|
4825
|
+
*
|
|
4826
|
+
* When set via `withConfig()`, the new handler **replaces** (not wraps) the previous one.
|
|
4827
|
+
*
|
|
4828
|
+
* Note: This only applies to HTTP requests. Real-time listener connections
|
|
4829
|
+
* (`client.listen()`) use EventSource and are not intercepted by this handler.
|
|
4830
|
+
*
|
|
4831
|
+
* @param request - The resolved request options including `url`
|
|
4832
|
+
* @param defaultRequester - Executes the request through the normal pipeline
|
|
4833
|
+
* @param client - A client instance with the same configuration but without a `_requestHandler`,
|
|
4834
|
+
* useful for making side requests (e.g. token refresh) without triggering the handler recursively
|
|
4835
|
+
*
|
|
4836
|
+
* @internal
|
|
4837
|
+
* @deprecated Don't use outside of Sanity internals
|
|
4838
|
+
*/
|
|
4839
|
+
export declare type RequestHandler = (
|
|
4840
|
+
request: RequestOptions & {
|
|
4841
|
+
url: string
|
|
4842
|
+
},
|
|
4843
|
+
defaultRequester: (
|
|
4844
|
+
options: RequestOptions & {
|
|
4845
|
+
url: string
|
|
4846
|
+
},
|
|
4847
|
+
) => Observable<HttpRequestEvent>,
|
|
4848
|
+
client: SanityClient,
|
|
4849
|
+
) => Observable<HttpRequestEvent>
|
|
4850
|
+
|
|
4776
4851
|
/** @internal */
|
|
4777
4852
|
export declare interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {
|
|
4778
4853
|
url?: string
|
|
@@ -5746,6 +5821,7 @@ export declare interface SanityProject {
|
|
|
5746
5821
|
pendingInvites?: number
|
|
5747
5822
|
maxRetentionDays?: number
|
|
5748
5823
|
members: SanityProjectMember[]
|
|
5824
|
+
features: string[]
|
|
5749
5825
|
metadata: {
|
|
5750
5826
|
cliInitializedAt?: string
|
|
5751
5827
|
color?: string
|
package/dist/index.browser.js
CHANGED
|
@@ -1451,7 +1451,8 @@ class LiveClient {
|
|
|
1451
1451
|
*/
|
|
1452
1452
|
events({
|
|
1453
1453
|
includeDrafts = !1,
|
|
1454
|
-
tag: _tag
|
|
1454
|
+
tag: _tag,
|
|
1455
|
+
waitFor
|
|
1455
1456
|
} = {}) {
|
|
1456
1457
|
const {
|
|
1457
1458
|
projectId: projectId2,
|
|
@@ -1470,7 +1471,7 @@ class LiveClient {
|
|
|
1470
1471
|
"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."
|
|
1471
1472
|
);
|
|
1472
1473
|
const path = _getDataUrl(this.#client, "live/events"), url = new URL(this.#client.getUrl(path, !1)), tag = _tag && requestTagPrefix ? [requestTagPrefix, _tag].join(".") : _tag;
|
|
1473
|
-
tag && url.searchParams.set("tag", tag), includeDrafts && url.searchParams.set("includeDrafts", "true");
|
|
1474
|
+
tag && url.searchParams.set("tag", tag), includeDrafts && url.searchParams.set("includeDrafts", "true"), waitFor && url.searchParams.set("waitFor", waitFor);
|
|
1474
1475
|
const esOptions = {};
|
|
1475
1476
|
includeDrafts && withCredentials && (esOptions.withCredentials = !0), (includeDrafts && token || configHeaders) && (esOptions.headers = {}, includeDrafts && token && (esOptions.headers.Authorization = `Bearer ${token}`), configHeaders && Object.assign(esOptions.headers, configHeaders));
|
|
1476
1477
|
const key = `${url.href}::${JSON.stringify(esOptions)}`, existing = eventsCache.get(key);
|
|
@@ -1771,9 +1772,18 @@ class ObservableProjectsClient {
|
|
|
1771
1772
|
constructor(client, httpRequest) {
|
|
1772
1773
|
this.#client = client, this.#httpRequest = httpRequest;
|
|
1773
1774
|
}
|
|
1775
|
+
/**
|
|
1776
|
+
* Fetch a list of projects the authenticated user has access to.
|
|
1777
|
+
*
|
|
1778
|
+
* @param options - Options for the list request
|
|
1779
|
+
* - `includeMembers` - Whether to include members in the response (default: true)
|
|
1780
|
+
* - `includeFeatures` - Whether to include features in the response (default: true)
|
|
1781
|
+
* - `organizationId` - ID of the organization to fetch projects for
|
|
1782
|
+
* - `onlyExplicitMembership` - Whether to include only projects with explicit membership (default: false)
|
|
1783
|
+
*/
|
|
1774
1784
|
list(options) {
|
|
1775
1785
|
const query = {}, uri = "/projects";
|
|
1776
|
-
return options?.includeMembers === !1 && (query.includeMembers = "false"), options?.organizationId && (query.organizationId = options.organizationId), options?.onlyExplicitMembership
|
|
1786
|
+
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 });
|
|
1777
1787
|
}
|
|
1778
1788
|
/**
|
|
1779
1789
|
* Fetch a project by project ID
|
|
@@ -1790,9 +1800,20 @@ class ProjectsClient {
|
|
|
1790
1800
|
constructor(client, httpRequest) {
|
|
1791
1801
|
this.#client = client, this.#httpRequest = httpRequest;
|
|
1792
1802
|
}
|
|
1803
|
+
/**
|
|
1804
|
+
* Fetch a list of projects the authenticated user has access to.
|
|
1805
|
+
*
|
|
1806
|
+
* @param options - Options for the list request
|
|
1807
|
+
* - `includeMembers` - Whether to include members in the response (default: true)
|
|
1808
|
+
* - `includeFeatures` - Whether to include features in the response (default: true)
|
|
1809
|
+
* - `organizationId` - ID of the organization to fetch projects for
|
|
1810
|
+
* - `onlyExplicitMembership` - Whether to include only projects with explicit membership (default: false)
|
|
1811
|
+
*/
|
|
1793
1812
|
list(options) {
|
|
1794
1813
|
const query = {}, uri = "/projects";
|
|
1795
|
-
return options?.includeMembers === !1 && (query.includeMembers = "false"), options?.organizationId && (query.organizationId = options.organizationId), options?.onlyExplicitMembership
|
|
1814
|
+
return options?.includeMembers === !1 && (query.includeMembers = "false"), options?.includeFeatures === !1 && (query.includeFeatures = "false"), options?.organizationId && (query.organizationId = options.organizationId), options?.onlyExplicitMembership && (query.onlyExplicitMembership = "true"), lastValueFrom(
|
|
1815
|
+
_request(this.#client, this.#httpRequest, { uri, query })
|
|
1816
|
+
);
|
|
1796
1817
|
}
|
|
1797
1818
|
/**
|
|
1798
1819
|
* Fetch a project by project ID
|
|
@@ -2348,13 +2369,22 @@ class ObservableSanityClient {
|
|
|
2348
2369
|
* Private properties
|
|
2349
2370
|
*/
|
|
2350
2371
|
#clientConfig;
|
|
2372
|
+
#originalHttpRequest;
|
|
2351
2373
|
#httpRequest;
|
|
2352
2374
|
/**
|
|
2353
2375
|
* Instance properties
|
|
2354
2376
|
*/
|
|
2355
2377
|
listen = _listen;
|
|
2356
2378
|
constructor(httpRequest, config = defaultConfig) {
|
|
2357
|
-
this.config(config), this.#
|
|
2379
|
+
this.config(config), this.#originalHttpRequest = httpRequest;
|
|
2380
|
+
const requestHandler = config._requestHandler;
|
|
2381
|
+
this.#httpRequest = requestHandler ? /* @__PURE__ */ (() => {
|
|
2382
|
+
let bareClient;
|
|
2383
|
+
return (options, requester2) => {
|
|
2384
|
+
const opts = options;
|
|
2385
|
+
return bareClient || (bareClient = new SanityClient(httpRequest, { ...config, _requestHandler: void 0 })), requestHandler(opts, (o) => httpRequest(o, requester2), bareClient);
|
|
2386
|
+
};
|
|
2387
|
+
})() : httpRequest, this.assets = new ObservableAssetsClient(this, this.#httpRequest), this.datasets = new ObservableDatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.mediaLibrary = {
|
|
2358
2388
|
video: new ObservableMediaLibraryVideoClient(this, this.#httpRequest)
|
|
2359
2389
|
}, this.projects = new ObservableProjectsClient(this, this.#httpRequest), this.users = new ObservableUsersClient(this, this.#httpRequest), this.agent = {
|
|
2360
2390
|
action: new ObservableAgentsActionClient(this, this.#httpRequest)
|
|
@@ -2364,7 +2394,7 @@ class ObservableSanityClient {
|
|
|
2364
2394
|
* Clone the client - returns a new instance
|
|
2365
2395
|
*/
|
|
2366
2396
|
clone() {
|
|
2367
|
-
return new ObservableSanityClient(this.#
|
|
2397
|
+
return new ObservableSanityClient(this.#originalHttpRequest, this.config());
|
|
2368
2398
|
}
|
|
2369
2399
|
config(newConfig) {
|
|
2370
2400
|
if (newConfig === void 0)
|
|
@@ -2382,7 +2412,7 @@ class ObservableSanityClient {
|
|
|
2382
2412
|
*/
|
|
2383
2413
|
withConfig(newConfig) {
|
|
2384
2414
|
const thisConfig = this.config();
|
|
2385
|
-
return new ObservableSanityClient(this.#
|
|
2415
|
+
return new ObservableSanityClient(this.#originalHttpRequest, {
|
|
2386
2416
|
...thisConfig,
|
|
2387
2417
|
...newConfig,
|
|
2388
2418
|
stega: {
|
|
@@ -2612,13 +2642,22 @@ class SanityClient {
|
|
|
2612
2642
|
* Private properties
|
|
2613
2643
|
*/
|
|
2614
2644
|
#clientConfig;
|
|
2645
|
+
#originalHttpRequest;
|
|
2615
2646
|
#httpRequest;
|
|
2616
2647
|
/**
|
|
2617
2648
|
* Instance properties
|
|
2618
2649
|
*/
|
|
2619
2650
|
listen = _listen;
|
|
2620
2651
|
constructor(httpRequest, config = defaultConfig) {
|
|
2621
|
-
this.config(config), this.#
|
|
2652
|
+
this.config(config), this.#originalHttpRequest = httpRequest;
|
|
2653
|
+
const requestHandler = config._requestHandler;
|
|
2654
|
+
this.#httpRequest = requestHandler ? /* @__PURE__ */ (() => {
|
|
2655
|
+
let bareClient;
|
|
2656
|
+
return (options, requester2) => {
|
|
2657
|
+
const opts = options;
|
|
2658
|
+
return bareClient || (bareClient = new SanityClient(httpRequest, { ...config, _requestHandler: void 0 })), requestHandler(opts, (o) => httpRequest(o, requester2), bareClient);
|
|
2659
|
+
};
|
|
2660
|
+
})() : httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.mediaLibrary = {
|
|
2622
2661
|
video: new MediaLibraryVideoClient(this, this.#httpRequest)
|
|
2623
2662
|
}, this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.agent = {
|
|
2624
2663
|
action: new AgentActionsClient(this, this.#httpRequest)
|
|
@@ -2628,7 +2667,7 @@ class SanityClient {
|
|
|
2628
2667
|
* Clone the client - returns a new instance
|
|
2629
2668
|
*/
|
|
2630
2669
|
clone() {
|
|
2631
|
-
return new SanityClient(this.#
|
|
2670
|
+
return new SanityClient(this.#originalHttpRequest, this.config());
|
|
2632
2671
|
}
|
|
2633
2672
|
config(newConfig) {
|
|
2634
2673
|
if (newConfig === void 0)
|
|
@@ -2646,7 +2685,7 @@ class SanityClient {
|
|
|
2646
2685
|
*/
|
|
2647
2686
|
withConfig(newConfig) {
|
|
2648
2687
|
const thisConfig = this.config();
|
|
2649
|
-
return new SanityClient(this.#
|
|
2688
|
+
return new SanityClient(this.#originalHttpRequest, {
|
|
2650
2689
|
...thisConfig,
|
|
2651
2690
|
...newConfig,
|
|
2652
2691
|
stega: {
|