@sanity/client 7.18.0 → 7.20.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 +22 -2
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +57 -24
- package/dist/index.browser.d.ts +57 -24
- package/dist/index.browser.js +22 -2
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +23 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +57 -24
- package/dist/index.d.ts +57 -24
- package/dist/index.js +23 -3
- package/dist/index.js.map +1 -1
- package/dist/media-library.cjs.map +1 -1
- package/dist/media-library.d.cts +27 -0
- package/dist/media-library.d.ts +27 -0
- package/dist/media-library.js.map +1 -1
- package/dist/stega.browser.d.cts +57 -24
- package/dist/stega.browser.d.ts +57 -24
- package/dist/stega.d.cts +57 -24
- package/dist/stega.d.ts +57 -24
- package/package.json +1 -1
- package/src/media-library.ts +1 -0
- package/src/projects/ProjectsClient.ts +37 -36
- package/src/types.ts +28 -0
- package/umd/sanityClient.js +22 -2
- package/umd/sanityClient.min.js +2 -2
|
@@ -4,6 +4,17 @@ import {_request} from '../data/dataMethods'
|
|
|
4
4
|
import type {ObservableSanityClient, SanityClient} from '../SanityClient'
|
|
5
5
|
import type {HttpRequest, SanityProject} from '../types'
|
|
6
6
|
|
|
7
|
+
type ListOptions = {
|
|
8
|
+
includeMembers?: boolean
|
|
9
|
+
includeFeatures?: boolean
|
|
10
|
+
organizationId?: string
|
|
11
|
+
onlyExplicitMembership?: boolean
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type OmittedProjectFields<T extends ListOptions | undefined> =
|
|
15
|
+
| (T extends {includeMembers: false} ? 'members' : never)
|
|
16
|
+
| (T extends {includeFeatures: false} ? 'features' : never)
|
|
17
|
+
|
|
7
18
|
/** @internal */
|
|
8
19
|
export class ObservableProjectsClient {
|
|
9
20
|
#client: ObservableSanityClient
|
|
@@ -18,37 +29,31 @@ export class ObservableProjectsClient {
|
|
|
18
29
|
*
|
|
19
30
|
* @param options - Options for the list request
|
|
20
31
|
* - `includeMembers` - Whether to include members in the response (default: true)
|
|
32
|
+
* - `includeFeatures` - Whether to include features in the response (default: true)
|
|
21
33
|
* - `organizationId` - ID of the organization to fetch projects for
|
|
22
|
-
* - `onlyExplicitMembership` -
|
|
34
|
+
* - `onlyExplicitMembership` - Whether to include only projects with explicit membership (default: false)
|
|
23
35
|
*/
|
|
24
|
-
list(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
onlyExplicitMembership?: boolean
|
|
28
|
-
}): Observable<SanityProject[]>
|
|
29
|
-
list(options?: {
|
|
30
|
-
includeMembers?: false
|
|
31
|
-
organizationId?: string
|
|
32
|
-
onlyExplicitMembership?: boolean
|
|
33
|
-
}): Observable<Omit<SanityProject, 'members'>[]>
|
|
34
|
-
list(options?: {
|
|
35
|
-
includeMembers?: boolean
|
|
36
|
-
organizationId?: string
|
|
37
|
-
onlyExplicitMembership?: boolean
|
|
38
|
-
}): Observable<SanityProject[] | Omit<SanityProject, 'members'>[]> {
|
|
36
|
+
list<T extends ListOptions>(
|
|
37
|
+
options?: T,
|
|
38
|
+
): Observable<Omit<SanityProject, OmittedProjectFields<T>>[]> {
|
|
39
39
|
const query: Record<string, string> = {}
|
|
40
40
|
const uri = '/projects'
|
|
41
41
|
if (options?.includeMembers === false) {
|
|
42
42
|
query.includeMembers = 'false'
|
|
43
43
|
}
|
|
44
|
+
if (options?.includeFeatures === false) {
|
|
45
|
+
query.includeFeatures = 'false'
|
|
46
|
+
}
|
|
44
47
|
if (options?.organizationId) {
|
|
45
48
|
query.organizationId = options.organizationId
|
|
46
49
|
}
|
|
47
|
-
if (options?.onlyExplicitMembership
|
|
50
|
+
if (options?.onlyExplicitMembership) {
|
|
48
51
|
query.onlyExplicitMembership = 'true'
|
|
49
52
|
}
|
|
50
53
|
|
|
51
|
-
return _request<SanityProject[]>(this.#client, this.#httpRequest, {uri, query})
|
|
54
|
+
return _request<SanityProject[]>(this.#client, this.#httpRequest, {uri, query}) as Observable<
|
|
55
|
+
Omit<SanityProject, OmittedProjectFields<T>>[]
|
|
56
|
+
>
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
/**
|
|
@@ -75,36 +80,32 @@ export class ProjectsClient {
|
|
|
75
80
|
*
|
|
76
81
|
* @param options - Options for the list request
|
|
77
82
|
* - `includeMembers` - Whether to include members in the response (default: true)
|
|
83
|
+
* - `includeFeatures` - Whether to include features in the response (default: true)
|
|
78
84
|
* - `organizationId` - ID of the organization to fetch projects for
|
|
79
|
-
* - `onlyExplicitMembership` -
|
|
85
|
+
* - `onlyExplicitMembership` - Whether to include only projects with explicit membership (default: false)
|
|
80
86
|
*/
|
|
81
|
-
list(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
onlyExplicitMembership?: boolean
|
|
85
|
-
}): Promise<SanityProject[]>
|
|
86
|
-
list(options?: {
|
|
87
|
-
includeMembers?: false
|
|
88
|
-
organizationId?: string
|
|
89
|
-
onlyExplicitMembership?: boolean
|
|
90
|
-
}): Promise<Omit<SanityProject, 'members'>[]>
|
|
91
|
-
list(options?: {
|
|
92
|
-
includeMembers?: boolean
|
|
93
|
-
organizationId?: string
|
|
94
|
-
onlyExplicitMembership?: boolean
|
|
95
|
-
}): Promise<SanityProject[] | Omit<SanityProject, 'members'>[]> {
|
|
87
|
+
list<T extends ListOptions>(
|
|
88
|
+
options?: T,
|
|
89
|
+
): Promise<Omit<SanityProject, OmittedProjectFields<T>>[]> {
|
|
96
90
|
const query: Record<string, string> = {}
|
|
97
91
|
const uri = '/projects'
|
|
98
92
|
if (options?.includeMembers === false) {
|
|
99
93
|
query.includeMembers = 'false'
|
|
100
94
|
}
|
|
95
|
+
if (options?.includeFeatures === false) {
|
|
96
|
+
query.includeFeatures = 'false'
|
|
97
|
+
}
|
|
101
98
|
if (options?.organizationId) {
|
|
102
99
|
query.organizationId = options.organizationId
|
|
103
100
|
}
|
|
104
|
-
if (options?.onlyExplicitMembership
|
|
101
|
+
if (options?.onlyExplicitMembership) {
|
|
105
102
|
query.onlyExplicitMembership = 'true'
|
|
106
103
|
}
|
|
107
|
-
return lastValueFrom(
|
|
104
|
+
return lastValueFrom(
|
|
105
|
+
_request<SanityProject[]>(this.#client, this.#httpRequest, {uri, query}) as Observable<
|
|
106
|
+
Omit<SanityProject, OmittedProjectFields<T>>[]
|
|
107
|
+
>,
|
|
108
|
+
)
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
/**
|
package/src/types.ts
CHANGED
|
@@ -529,6 +529,7 @@ export interface SanityProject {
|
|
|
529
529
|
pendingInvites?: number
|
|
530
530
|
maxRetentionDays?: number
|
|
531
531
|
members: SanityProjectMember[]
|
|
532
|
+
features: string[]
|
|
532
533
|
metadata: {
|
|
533
534
|
cliInitializedAt?: string
|
|
534
535
|
color?: string
|
|
@@ -1996,12 +1997,38 @@ export interface VideoRenditionInfoSigned extends VideoRenditionInfoPublic {
|
|
|
1996
1997
|
/** @public */
|
|
1997
1998
|
export type VideoRenditionInfo = VideoRenditionInfoPublic | VideoRenditionInfoSigned
|
|
1998
1999
|
|
|
2000
|
+
/** @public */
|
|
2001
|
+
export interface VideoSubtitleInfoPublic {
|
|
2002
|
+
/** Subtitle track identifier */
|
|
2003
|
+
trackId: string
|
|
2004
|
+
/** ISO 639-1 language code */
|
|
2005
|
+
languageCode: string
|
|
2006
|
+
/** URL to the subtitle file */
|
|
2007
|
+
url: string
|
|
2008
|
+
/** Whether this track contains closed captions */
|
|
2009
|
+
closedCaptions: boolean
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
/** @public */
|
|
2013
|
+
export interface VideoSubtitleInfoSigned extends VideoSubtitleInfoPublic {
|
|
2014
|
+
/** Authentication token for signed playback */
|
|
2015
|
+
token: string
|
|
2016
|
+
/** Token expiration time in ISO 8601 format */
|
|
2017
|
+
expiresAt: string
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
/** @public */
|
|
2021
|
+
export type VideoSubtitleInfo = VideoSubtitleInfoPublic | VideoSubtitleInfoSigned
|
|
2022
|
+
|
|
1999
2023
|
/** @public */
|
|
2000
2024
|
export interface VideoPlaybackInfo<
|
|
2001
2025
|
T extends VideoPlaybackInfoItem = VideoPlaybackInfoItem,
|
|
2002
2026
|
R extends VideoRenditionInfo = T extends VideoPlaybackInfoItemSigned
|
|
2003
2027
|
? VideoRenditionInfoSigned
|
|
2004
2028
|
: VideoRenditionInfo,
|
|
2029
|
+
S extends VideoSubtitleInfo = T extends VideoPlaybackInfoItemSigned
|
|
2030
|
+
? VideoSubtitleInfoSigned
|
|
2031
|
+
: VideoSubtitleInfo,
|
|
2005
2032
|
> {
|
|
2006
2033
|
id: string
|
|
2007
2034
|
thumbnail: T
|
|
@@ -2011,6 +2038,7 @@ export interface VideoPlaybackInfo<
|
|
|
2011
2038
|
duration: number
|
|
2012
2039
|
aspectRatio: number
|
|
2013
2040
|
renditions?: R[]
|
|
2041
|
+
subtitles?: S[]
|
|
2014
2042
|
}
|
|
2015
2043
|
|
|
2016
2044
|
/** @public */
|
package/umd/sanityClient.js
CHANGED
|
@@ -3745,9 +3745,18 @@ ${selectionOpts}`);
|
|
|
3745
3745
|
constructor(client, httpRequest) {
|
|
3746
3746
|
this.#client = client, this.#httpRequest = httpRequest;
|
|
3747
3747
|
}
|
|
3748
|
+
/**
|
|
3749
|
+
* Fetch a list of projects the authenticated user has access to.
|
|
3750
|
+
*
|
|
3751
|
+
* @param options - Options for the list request
|
|
3752
|
+
* - `includeMembers` - Whether to include members in the response (default: true)
|
|
3753
|
+
* - `includeFeatures` - Whether to include features in the response (default: true)
|
|
3754
|
+
* - `organizationId` - ID of the organization to fetch projects for
|
|
3755
|
+
* - `onlyExplicitMembership` - Whether to include only projects with explicit membership (default: false)
|
|
3756
|
+
*/
|
|
3748
3757
|
list(options) {
|
|
3749
3758
|
const query = {}, uri = "/projects";
|
|
3750
|
-
return options?.includeMembers === false && (query.includeMembers = "false"), options?.organizationId && (query.organizationId = options.organizationId), options?.onlyExplicitMembership
|
|
3759
|
+
return options?.includeMembers === false && (query.includeMembers = "false"), options?.includeFeatures === false && (query.includeFeatures = "false"), options?.organizationId && (query.organizationId = options.organizationId), options?.onlyExplicitMembership && (query.onlyExplicitMembership = "true"), _request(this.#client, this.#httpRequest, { uri, query });
|
|
3751
3760
|
}
|
|
3752
3761
|
/**
|
|
3753
3762
|
* Fetch a project by project ID
|
|
@@ -3764,9 +3773,20 @@ ${selectionOpts}`);
|
|
|
3764
3773
|
constructor(client, httpRequest) {
|
|
3765
3774
|
this.#client = client, this.#httpRequest = httpRequest;
|
|
3766
3775
|
}
|
|
3776
|
+
/**
|
|
3777
|
+
* Fetch a list of projects the authenticated user has access to.
|
|
3778
|
+
*
|
|
3779
|
+
* @param options - Options for the list request
|
|
3780
|
+
* - `includeMembers` - Whether to include members in the response (default: true)
|
|
3781
|
+
* - `includeFeatures` - Whether to include features in the response (default: true)
|
|
3782
|
+
* - `organizationId` - ID of the organization to fetch projects for
|
|
3783
|
+
* - `onlyExplicitMembership` - Whether to include only projects with explicit membership (default: false)
|
|
3784
|
+
*/
|
|
3767
3785
|
list(options) {
|
|
3768
3786
|
const query = {}, uri = "/projects";
|
|
3769
|
-
return options?.includeMembers === false && (query.includeMembers = "false"), options?.organizationId && (query.organizationId = options.organizationId), options?.onlyExplicitMembership
|
|
3787
|
+
return options?.includeMembers === false && (query.includeMembers = "false"), options?.includeFeatures === false && (query.includeFeatures = "false"), options?.organizationId && (query.organizationId = options.organizationId), options?.onlyExplicitMembership && (query.onlyExplicitMembership = "true"), lastValueFrom(
|
|
3788
|
+
_request(this.#client, this.#httpRequest, { uri, query })
|
|
3789
|
+
);
|
|
3770
3790
|
}
|
|
3771
3791
|
/**
|
|
3772
3792
|
* Fetch a project by project ID
|