@sanity/client 7.8.2 → 7.10.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.
@@ -2629,9 +2629,13 @@ export declare class ObservableProjectsClient {
2629
2629
  *
2630
2630
  * @param options - Options for the list request
2631
2631
  * - `includeMembers` - Whether to include members in the response (default: true)
2632
+ * - `organizationId` - ID of the organization to fetch projects for
2632
2633
  */
2633
- list(options?: {includeMembers?: true}): Observable<SanityProject[]>
2634
- list(options?: {includeMembers?: false}): Observable<Omit<SanityProject, 'members'>[]>
2634
+ list(options?: {includeMembers?: true; organizationId?: string}): Observable<SanityProject[]>
2635
+ list(options?: {
2636
+ includeMembers?: false
2637
+ organizationId?: string
2638
+ }): Observable<Omit<SanityProject, 'members'>[]>
2635
2639
  /**
2636
2640
  * Fetch a project by project ID
2637
2641
  *
@@ -3989,9 +3993,13 @@ export declare class ProjectsClient {
3989
3993
  *
3990
3994
  * @param options - Options for the list request
3991
3995
  * - `includeMembers` - Whether to include members in the response (default: true)
3996
+ * - `organizationId` - ID of the organization to fetch projects for
3992
3997
  */
3993
- list(options?: {includeMembers?: true}): Promise<SanityProject[]>
3994
- list(options?: {includeMembers?: false}): Promise<Omit<SanityProject, 'members'>[]>
3998
+ list(options?: {includeMembers?: true; organizationId?: string}): Promise<SanityProject[]>
3999
+ list(options?: {
4000
+ includeMembers?: false
4001
+ organizationId?: string
4002
+ }): Promise<Omit<SanityProject, 'members'>[]>
3995
4003
  /**
3996
4004
  * Fetch a project by project ID
3997
4005
  *
@@ -4284,6 +4292,9 @@ export declare type ReleaseAction =
4284
4292
  | UnscheduleReleaseAction
4285
4293
  | DeleteReleaseAction
4286
4294
 
4295
+ /** @public */
4296
+ export declare type ReleaseCardinality = 'many' | 'one' | undefined
4297
+
4287
4298
  /** @internal */
4288
4299
  export declare interface ReleaseDocument extends SanityDocument {
4289
4300
  /**
@@ -4320,6 +4331,7 @@ export declare interface ReleaseDocument extends SanityDocument {
4320
4331
  description?: string
4321
4332
  intendedPublishAt?: string
4322
4333
  releaseType: ReleaseType
4334
+ cardinality?: ReleaseCardinality
4323
4335
  }
4324
4336
  }
4325
4337
 
@@ -2629,9 +2629,13 @@ export declare class ObservableProjectsClient {
2629
2629
  *
2630
2630
  * @param options - Options for the list request
2631
2631
  * - `includeMembers` - Whether to include members in the response (default: true)
2632
+ * - `organizationId` - ID of the organization to fetch projects for
2632
2633
  */
2633
- list(options?: {includeMembers?: true}): Observable<SanityProject[]>
2634
- list(options?: {includeMembers?: false}): Observable<Omit<SanityProject, 'members'>[]>
2634
+ list(options?: {includeMembers?: true; organizationId?: string}): Observable<SanityProject[]>
2635
+ list(options?: {
2636
+ includeMembers?: false
2637
+ organizationId?: string
2638
+ }): Observable<Omit<SanityProject, 'members'>[]>
2635
2639
  /**
2636
2640
  * Fetch a project by project ID
2637
2641
  *
@@ -3989,9 +3993,13 @@ export declare class ProjectsClient {
3989
3993
  *
3990
3994
  * @param options - Options for the list request
3991
3995
  * - `includeMembers` - Whether to include members in the response (default: true)
3996
+ * - `organizationId` - ID of the organization to fetch projects for
3992
3997
  */
3993
- list(options?: {includeMembers?: true}): Promise<SanityProject[]>
3994
- list(options?: {includeMembers?: false}): Promise<Omit<SanityProject, 'members'>[]>
3998
+ list(options?: {includeMembers?: true; organizationId?: string}): Promise<SanityProject[]>
3999
+ list(options?: {
4000
+ includeMembers?: false
4001
+ organizationId?: string
4002
+ }): Promise<Omit<SanityProject, 'members'>[]>
3995
4003
  /**
3996
4004
  * Fetch a project by project ID
3997
4005
  *
@@ -4284,6 +4292,9 @@ export declare type ReleaseAction =
4284
4292
  | UnscheduleReleaseAction
4285
4293
  | DeleteReleaseAction
4286
4294
 
4295
+ /** @public */
4296
+ export declare type ReleaseCardinality = 'many' | 'one' | undefined
4297
+
4287
4298
  /** @internal */
4288
4299
  export declare interface ReleaseDocument extends SanityDocument {
4289
4300
  /**
@@ -4320,6 +4331,7 @@ export declare interface ReleaseDocument extends SanityDocument {
4320
4331
  description?: string
4321
4332
  intendedPublishAt?: string
4322
4333
  releaseType: ReleaseType
4334
+ cardinality?: ReleaseCardinality
4323
4335
  }
4324
4336
  }
4325
4337
 
package/dist/stega.d.cts CHANGED
@@ -2629,9 +2629,13 @@ export declare class ObservableProjectsClient {
2629
2629
  *
2630
2630
  * @param options - Options for the list request
2631
2631
  * - `includeMembers` - Whether to include members in the response (default: true)
2632
+ * - `organizationId` - ID of the organization to fetch projects for
2632
2633
  */
2633
- list(options?: {includeMembers?: true}): Observable<SanityProject[]>
2634
- list(options?: {includeMembers?: false}): Observable<Omit<SanityProject, 'members'>[]>
2634
+ list(options?: {includeMembers?: true; organizationId?: string}): Observable<SanityProject[]>
2635
+ list(options?: {
2636
+ includeMembers?: false
2637
+ organizationId?: string
2638
+ }): Observable<Omit<SanityProject, 'members'>[]>
2635
2639
  /**
2636
2640
  * Fetch a project by project ID
2637
2641
  *
@@ -3989,9 +3993,13 @@ export declare class ProjectsClient {
3989
3993
  *
3990
3994
  * @param options - Options for the list request
3991
3995
  * - `includeMembers` - Whether to include members in the response (default: true)
3996
+ * - `organizationId` - ID of the organization to fetch projects for
3992
3997
  */
3993
- list(options?: {includeMembers?: true}): Promise<SanityProject[]>
3994
- list(options?: {includeMembers?: false}): Promise<Omit<SanityProject, 'members'>[]>
3998
+ list(options?: {includeMembers?: true; organizationId?: string}): Promise<SanityProject[]>
3999
+ list(options?: {
4000
+ includeMembers?: false
4001
+ organizationId?: string
4002
+ }): Promise<Omit<SanityProject, 'members'>[]>
3995
4003
  /**
3996
4004
  * Fetch a project by project ID
3997
4005
  *
@@ -4284,6 +4292,9 @@ export declare type ReleaseAction =
4284
4292
  | UnscheduleReleaseAction
4285
4293
  | DeleteReleaseAction
4286
4294
 
4295
+ /** @public */
4296
+ export declare type ReleaseCardinality = 'many' | 'one' | undefined
4297
+
4287
4298
  /** @internal */
4288
4299
  export declare interface ReleaseDocument extends SanityDocument {
4289
4300
  /**
@@ -4320,6 +4331,7 @@ export declare interface ReleaseDocument extends SanityDocument {
4320
4331
  description?: string
4321
4332
  intendedPublishAt?: string
4322
4333
  releaseType: ReleaseType
4334
+ cardinality?: ReleaseCardinality
4323
4335
  }
4324
4336
  }
4325
4337
 
package/dist/stega.d.ts CHANGED
@@ -2629,9 +2629,13 @@ export declare class ObservableProjectsClient {
2629
2629
  *
2630
2630
  * @param options - Options for the list request
2631
2631
  * - `includeMembers` - Whether to include members in the response (default: true)
2632
+ * - `organizationId` - ID of the organization to fetch projects for
2632
2633
  */
2633
- list(options?: {includeMembers?: true}): Observable<SanityProject[]>
2634
- list(options?: {includeMembers?: false}): Observable<Omit<SanityProject, 'members'>[]>
2634
+ list(options?: {includeMembers?: true; organizationId?: string}): Observable<SanityProject[]>
2635
+ list(options?: {
2636
+ includeMembers?: false
2637
+ organizationId?: string
2638
+ }): Observable<Omit<SanityProject, 'members'>[]>
2635
2639
  /**
2636
2640
  * Fetch a project by project ID
2637
2641
  *
@@ -3989,9 +3993,13 @@ export declare class ProjectsClient {
3989
3993
  *
3990
3994
  * @param options - Options for the list request
3991
3995
  * - `includeMembers` - Whether to include members in the response (default: true)
3996
+ * - `organizationId` - ID of the organization to fetch projects for
3992
3997
  */
3993
- list(options?: {includeMembers?: true}): Promise<SanityProject[]>
3994
- list(options?: {includeMembers?: false}): Promise<Omit<SanityProject, 'members'>[]>
3998
+ list(options?: {includeMembers?: true; organizationId?: string}): Promise<SanityProject[]>
3999
+ list(options?: {
4000
+ includeMembers?: false
4001
+ organizationId?: string
4002
+ }): Promise<Omit<SanityProject, 'members'>[]>
3995
4003
  /**
3996
4004
  * Fetch a project by project ID
3997
4005
  *
@@ -4284,6 +4292,9 @@ export declare type ReleaseAction =
4284
4292
  | UnscheduleReleaseAction
4285
4293
  | DeleteReleaseAction
4286
4294
 
4295
+ /** @public */
4296
+ export declare type ReleaseCardinality = 'many' | 'one' | undefined
4297
+
4287
4298
  /** @internal */
4288
4299
  export declare interface ReleaseDocument extends SanityDocument {
4289
4300
  /**
@@ -4320,6 +4331,7 @@ export declare interface ReleaseDocument extends SanityDocument {
4320
4331
  description?: string
4321
4332
  intendedPublishAt?: string
4322
4333
  releaseType: ReleaseType
4334
+ cardinality?: ReleaseCardinality
4323
4335
  }
4324
4336
  }
4325
4337
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/client",
3
- "version": "7.8.2",
3
+ "version": "7.10.0",
4
4
  "description": "Client for retrieving, creating and patching data from Sanity.io",
5
5
  "keywords": [
6
6
  "sanity",
@@ -47,8 +47,16 @@ export class ObservableDatasetsClient {
47
47
  * Fetch a list of datasets for the configured project
48
48
  */
49
49
  list(): Observable<DatasetsResponse> {
50
+ validate.resourceGuard('dataset', this.#client.config())
51
+ const config = this.#client.config()
52
+ const projectId = config.projectId
53
+ let uri = '/datasets'
54
+ if (config.useProjectHostname === false) {
55
+ uri = `/projects/${projectId}/datasets`
56
+ }
57
+
50
58
  return _request<DatasetsResponse>(this.#client, this.#httpRequest, {
51
- uri: '/datasets',
59
+ uri,
52
60
  tag: null,
53
61
  })
54
62
  }
@@ -104,8 +112,15 @@ export class DatasetsClient {
104
112
  */
105
113
  list(): Promise<DatasetsResponse> {
106
114
  validate.resourceGuard('dataset', this.#client.config())
115
+ const config = this.#client.config()
116
+ const projectId = config.projectId
117
+ let uri = '/datasets'
118
+ if (config.useProjectHostname === false) {
119
+ uri = `/projects/${projectId}/datasets`
120
+ }
121
+
107
122
  return lastValueFrom(
108
- _request<DatasetsResponse>(this.#client, this.#httpRequest, {uri: '/datasets', tag: null}),
123
+ _request<DatasetsResponse>(this.#client, this.#httpRequest, {uri, tag: null}),
109
124
  )
110
125
  }
111
126
  }
@@ -119,6 +134,7 @@ function _modify<R = unknown>(
119
134
  ) {
120
135
  validate.resourceGuard('dataset', client.config())
121
136
  validate.dataset(name)
137
+
122
138
  return _request<R>(client, httpRequest, {
123
139
  method,
124
140
  uri: `/datasets/${name}`,
@@ -3,7 +3,6 @@ import {lastValueFrom, type Observable} from 'rxjs'
3
3
  import {_request} from '../data/dataMethods'
4
4
  import type {ObservableSanityClient, SanityClient} from '../SanityClient'
5
5
  import type {HttpRequest, SanityProject} from '../types'
6
- import * as validate from '../validators'
7
6
 
8
7
  /** @internal */
9
8
  export class ObservableProjectsClient {
@@ -19,15 +18,27 @@ export class ObservableProjectsClient {
19
18
  *
20
19
  * @param options - Options for the list request
21
20
  * - `includeMembers` - Whether to include members in the response (default: true)
21
+ * - `organizationId` - ID of the organization to fetch projects for
22
22
  */
23
- list(options?: {includeMembers?: true}): Observable<SanityProject[]>
24
- list(options?: {includeMembers?: false}): Observable<Omit<SanityProject, 'members'>[]>
23
+ list(options?: {includeMembers?: true; organizationId?: string}): Observable<SanityProject[]>
24
+ list(options?: {
25
+ includeMembers?: false
26
+ organizationId?: string
27
+ }): Observable<Omit<SanityProject, 'members'>[]>
25
28
  list(options?: {
26
29
  includeMembers?: boolean
30
+ organizationId?: string
27
31
  }): Observable<SanityProject[] | Omit<SanityProject, 'members'>[]> {
28
- validate.resourceGuard('projects', this.#client.config())
29
- const uri = options?.includeMembers === false ? '/projects?includeMembers=false' : '/projects'
30
- return _request<SanityProject[]>(this.#client, this.#httpRequest, {uri})
32
+ const query: Record<string, string> = {}
33
+ const uri = '/projects'
34
+ if (options?.includeMembers === false) {
35
+ query.includeMembers = 'false'
36
+ }
37
+ if (options?.organizationId) {
38
+ query.organizationId = options.organizationId
39
+ }
40
+
41
+ return _request<SanityProject[]>(this.#client, this.#httpRequest, {uri, query})
31
42
  }
32
43
 
33
44
  /**
@@ -36,7 +47,6 @@ export class ObservableProjectsClient {
36
47
  * @param projectId - ID of the project to fetch
37
48
  */
38
49
  getById(projectId: string): Observable<SanityProject> {
39
- validate.resourceGuard('projects', this.#client.config())
40
50
  return _request<SanityProject>(this.#client, this.#httpRequest, {uri: `/projects/${projectId}`})
41
51
  }
42
52
  }
@@ -55,13 +65,26 @@ export class ProjectsClient {
55
65
  *
56
66
  * @param options - Options for the list request
57
67
  * - `includeMembers` - Whether to include members in the response (default: true)
68
+ * - `organizationId` - ID of the organization to fetch projects for
58
69
  */
59
- list(options?: {includeMembers?: true}): Promise<SanityProject[]>
60
- list(options?: {includeMembers?: false}): Promise<Omit<SanityProject, 'members'>[]>
61
- list(options?: {includeMembers?: boolean}): Promise<SanityProject[]> {
62
- validate.resourceGuard('projects', this.#client.config())
63
- const uri = options?.includeMembers === false ? '/projects?includeMembers=false' : '/projects'
64
- return lastValueFrom(_request<SanityProject[]>(this.#client, this.#httpRequest, {uri}))
70
+ list(options?: {includeMembers?: true; organizationId?: string}): Promise<SanityProject[]>
71
+ list(options?: {
72
+ includeMembers?: false
73
+ organizationId?: string
74
+ }): Promise<Omit<SanityProject, 'members'>[]>
75
+ list(options?: {
76
+ includeMembers?: boolean
77
+ organizationId?: string
78
+ }): Promise<SanityProject[] | Omit<SanityProject, 'members'>[]> {
79
+ const query: Record<string, string> = {}
80
+ const uri = '/projects'
81
+ if (options?.includeMembers === false) {
82
+ query.includeMembers = 'false'
83
+ }
84
+ if (options?.organizationId) {
85
+ query.organizationId = options.organizationId
86
+ }
87
+ return lastValueFrom(_request<SanityProject[]>(this.#client, this.#httpRequest, {uri, query}))
65
88
  }
66
89
 
67
90
  /**
@@ -70,7 +93,6 @@ export class ProjectsClient {
70
93
  * @param projectId - ID of the project to fetch
71
94
  */
72
95
  getById(projectId: string): Promise<SanityProject> {
73
- validate.resourceGuard('projects', this.#client.config())
74
96
  return lastValueFrom(
75
97
  _request<SanityProject>(this.#client, this.#httpRequest, {uri: `/projects/${projectId}`}),
76
98
  )
package/src/types.ts CHANGED
@@ -1476,6 +1476,9 @@ export type ReleaseState =
1476
1476
  /** @internal */
1477
1477
  export type ReleaseType = 'asap' | 'scheduled' | 'undecided'
1478
1478
 
1479
+ /** @public */
1480
+ export type ReleaseCardinality = 'many' | 'one' | undefined
1481
+
1479
1482
  /** @internal */
1480
1483
  export interface ReleaseDocument extends SanityDocument {
1481
1484
  /**
@@ -1512,6 +1515,7 @@ export interface ReleaseDocument extends SanityDocument {
1512
1515
  description?: string
1513
1516
  intendedPublishAt?: string
1514
1517
  releaseType: ReleaseType
1518
+ cardinality?: ReleaseCardinality
1515
1519
  }
1516
1520
  }
1517
1521
 
@@ -3509,8 +3509,11 @@ ${selectionOpts}`);
3509
3509
  * Fetch a list of datasets for the configured project
3510
3510
  */
3511
3511
  list() {
3512
- return _request(this.#client, this.#httpRequest, {
3513
- uri: "/datasets",
3512
+ resourceGuard("dataset", this.#client.config());
3513
+ const config = this.#client.config(), projectId2 = config.projectId;
3514
+ let uri = "/datasets";
3515
+ return config.useProjectHostname === false && (uri = `/projects/${projectId2}/datasets`), _request(this.#client, this.#httpRequest, {
3516
+ uri,
3514
3517
  tag: null
3515
3518
  });
3516
3519
  }
@@ -3555,8 +3558,11 @@ ${selectionOpts}`);
3555
3558
  * Fetch a list of datasets for the configured project
3556
3559
  */
3557
3560
  list() {
3558
- return resourceGuard("dataset", this.#client.config()), lastValueFrom(
3559
- _request(this.#client, this.#httpRequest, { uri: "/datasets", tag: null })
3561
+ resourceGuard("dataset", this.#client.config());
3562
+ const config = this.#client.config(), projectId2 = config.projectId;
3563
+ let uri = "/datasets";
3564
+ return config.useProjectHostname === false && (uri = `/projects/${projectId2}/datasets`), lastValueFrom(
3565
+ _request(this.#client, this.#httpRequest, { uri, tag: null })
3560
3566
  );
3561
3567
  }
3562
3568
  }
@@ -3575,9 +3581,8 @@ ${selectionOpts}`);
3575
3581
  this.#client = client, this.#httpRequest = httpRequest;
3576
3582
  }
3577
3583
  list(options) {
3578
- resourceGuard("projects", this.#client.config());
3579
- const uri = options?.includeMembers === false ? "/projects?includeMembers=false" : "/projects";
3580
- return _request(this.#client, this.#httpRequest, { uri });
3584
+ const query = {}, uri = "/projects";
3585
+ return options?.includeMembers === false && (query.includeMembers = "false"), options?.organizationId && (query.organizationId = options.organizationId), _request(this.#client, this.#httpRequest, { uri, query });
3581
3586
  }
3582
3587
  /**
3583
3588
  * Fetch a project by project ID
@@ -3585,7 +3590,7 @@ ${selectionOpts}`);
3585
3590
  * @param projectId - ID of the project to fetch
3586
3591
  */
3587
3592
  getById(projectId2) {
3588
- return resourceGuard("projects", this.#client.config()), _request(this.#client, this.#httpRequest, { uri: `/projects/${projectId2}` });
3593
+ return _request(this.#client, this.#httpRequest, { uri: `/projects/${projectId2}` });
3589
3594
  }
3590
3595
  }
3591
3596
  class ProjectsClient {
@@ -3595,9 +3600,8 @@ ${selectionOpts}`);
3595
3600
  this.#client = client, this.#httpRequest = httpRequest;
3596
3601
  }
3597
3602
  list(options) {
3598
- resourceGuard("projects", this.#client.config());
3599
- const uri = options?.includeMembers === false ? "/projects?includeMembers=false" : "/projects";
3600
- return lastValueFrom(_request(this.#client, this.#httpRequest, { uri }));
3603
+ const query = {}, uri = "/projects";
3604
+ return options?.includeMembers === false && (query.includeMembers = "false"), options?.organizationId && (query.organizationId = options.organizationId), lastValueFrom(_request(this.#client, this.#httpRequest, { uri, query }));
3601
3605
  }
3602
3606
  /**
3603
3607
  * Fetch a project by project ID
@@ -3605,7 +3609,7 @@ ${selectionOpts}`);
3605
3609
  * @param projectId - ID of the project to fetch
3606
3610
  */
3607
3611
  getById(projectId2) {
3608
- return resourceGuard("projects", this.#client.config()), lastValueFrom(
3612
+ return lastValueFrom(
3609
3613
  _request(this.#client, this.#httpRequest, { uri: `/projects/${projectId2}` })
3610
3614
  );
3611
3615
  }