@sanity/client 5.0.0-esm.1 → 5.0.0-esm.3

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.d.ts CHANGED
@@ -62,11 +62,11 @@ export declare class AuthClient {
62
62
  /**
63
63
  * Fetch available login providers
64
64
  */
65
- getLoginProviders<R = AuthProviderResponse>(): Promise<R>
65
+ getLoginProviders(): Promise<AuthProviderResponse>
66
66
  /**
67
67
  * Revoke the configured session/token
68
68
  */
69
- logout<R = any>(): Promise<R>
69
+ logout(): Promise<void>
70
70
  }
71
71
 
72
72
  export declare interface AuthProvider {
@@ -79,73 +79,6 @@ export declare type AuthProviderResponse = {
79
79
  providers: AuthProvider[]
80
80
  }
81
81
 
82
- export declare class BaseDatasetsClient {
83
- #private
84
- client: SanityClient | ObservableSanityClient
85
- /**
86
- * Create a new dataset with the given name
87
- *
88
- * @param name - Name of the dataset to create
89
- * @param options - Options for the dataset
90
- */
91
- create(
92
- this: DatasetsClient,
93
- name: string,
94
- options?: {
95
- aclMode?: DatasetAclMode
96
- }
97
- ): Promise<DatasetResponse>
98
- create(
99
- this: ObservableDatasetsClient,
100
- name: string,
101
- options?: {
102
- aclMode?: DatasetAclMode
103
- }
104
- ): Observable<DatasetResponse>
105
- /**
106
- * Edit a dataset with the given name
107
- *
108
- * @param name - Name of the dataset to edit
109
- * @param options - New options for the dataset
110
- */
111
- edit(
112
- this: DatasetsClient,
113
- name: string,
114
- options?: {
115
- aclMode?: DatasetAclMode
116
- }
117
- ): Promise<DatasetResponse>
118
- edit(
119
- this: ObservableDatasetsClient,
120
- name: string,
121
- options?: {
122
- aclMode?: DatasetAclMode
123
- }
124
- ): Observable<DatasetResponse>
125
- /**
126
- * Delete a dataset with the given name
127
- *
128
- * @param name - Name of the dataset to delete
129
- */
130
- delete(
131
- this: DatasetsClient,
132
- name: string
133
- ): Promise<{
134
- deleted: true
135
- }>
136
- delete(
137
- this: ObservableDatasetsClient,
138
- name: string
139
- ): Observable<{
140
- deleted: true
141
- }>
142
- /**
143
- * Fetch a list of datasets for the configured project
144
- */
145
- list(this: DatasetsClient): Promise<DatasetsResponse>
146
- list(this: ObservableDatasetsClient): Observable<DatasetsResponse>
147
- }
148
-
149
82
  export declare type BaseMutationOptions = RequestOptions & {
150
83
  visibility?: 'sync' | 'async' | 'deferred'
151
84
  returnDocuments?: boolean
@@ -260,22 +193,6 @@ export declare class BasePatch {
260
193
  protected _set(op: keyof PatchOperations, props: any): this
261
194
  }
262
195
 
263
- export declare class BaseProjectsClient {
264
- client: SanityClient | ObservableSanityClient
265
- /**
266
- * Fetch a list of projects the authenticated user has access to
267
- */
268
- list(this: ProjectsClient): Promise<SanityProject[]>
269
- list(this: ObservableProjectsClient): Observable<SanityProject[]>
270
- /**
271
- * Fetch a project by project ID
272
- *
273
- * @param projectId - ID of the project to fetch
274
- */
275
- getById(this: ProjectsClient, projectId: string): Promise<SanityProject>
276
- getById(this: ObservableProjectsClient, projectId: string): Observable<SanityProject>
277
- }
278
-
279
196
  export declare class BaseTransaction {
280
197
  protected operations: Mutation[]
281
198
  protected trxId?: string
@@ -337,23 +254,6 @@ export declare class BaseTransaction {
337
254
  protected _add(mut: Mutation): this
338
255
  }
339
256
 
340
- export declare class BaseUsersClient {
341
- client: SanityClient | ObservableSanityClient
342
- /**
343
- * Fetch a user by user ID
344
- *
345
- * @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
346
- */
347
- getById<T extends 'me' | string>(
348
- this: UsersClient,
349
- id: T
350
- ): Promise<T extends 'me' ? CurrentSanityUser : SanityUser>
351
- getById<T extends 'me' | string>(
352
- this: ObservableUsersClient,
353
- id: T
354
- ): Observable<T extends 'me' ? CurrentSanityUser : SanityUser>
355
- }
356
-
357
257
  export declare type ChannelErrorEvent = {
358
258
  type: 'channelError'
359
259
  message: string
@@ -407,9 +307,45 @@ export declare type DatasetResponse = {
407
307
  aclMode: DatasetAclMode
408
308
  }
409
309
 
410
- export declare class DatasetsClient extends BaseDatasetsClient {
411
- client: SanityClient
412
- constructor(client: SanityClient)
310
+ export declare class DatasetsClient {
311
+ #private
312
+ constructor(client: SanityClient, httpRequest: HttpRequest)
313
+ /**
314
+ * Create a new dataset with the given name
315
+ *
316
+ * @param name - Name of the dataset to create
317
+ * @param options - Options for the dataset
318
+ */
319
+ create(
320
+ name: string,
321
+ options?: {
322
+ aclMode?: DatasetAclMode
323
+ }
324
+ ): Promise<DatasetResponse>
325
+ /**
326
+ * Edit a dataset with the given name
327
+ *
328
+ * @param name - Name of the dataset to edit
329
+ * @param options - New options for the dataset
330
+ */
331
+ edit(
332
+ name: string,
333
+ options?: {
334
+ aclMode?: DatasetAclMode
335
+ }
336
+ ): Promise<DatasetResponse>
337
+ /**
338
+ * Delete a dataset with the given name
339
+ *
340
+ * @param name - Name of the dataset to delete
341
+ */
342
+ delete(name: string): Promise<{
343
+ deleted: true
344
+ }>
345
+ /**
346
+ * Fetch a list of datasets for the configured project
347
+ */
348
+ list(): Promise<DatasetsResponse>
413
349
  }
414
350
 
415
351
  export declare type DatasetsResponse = {
@@ -640,16 +576,52 @@ export declare class ObservableAuthClient {
640
576
  /**
641
577
  * Fetch available login providers
642
578
  */
643
- getLoginProviders<R = AuthProviderResponse>(): Observable<R>
579
+ getLoginProviders(): Observable<AuthProviderResponse>
644
580
  /**
645
581
  * Revoke the configured session/token
646
582
  */
647
- logout<R = any>(): Observable<R>
583
+ logout(): Observable<void>
648
584
  }
649
585
 
650
- export declare class ObservableDatasetsClient extends BaseDatasetsClient {
651
- client: ObservableSanityClient
652
- constructor(client: ObservableSanityClient)
586
+ export declare class ObservableDatasetsClient {
587
+ #private
588
+ constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
589
+ /**
590
+ * Create a new dataset with the given name
591
+ *
592
+ * @param name - Name of the dataset to create
593
+ * @param options - Options for the dataset
594
+ */
595
+ create(
596
+ name: string,
597
+ options?: {
598
+ aclMode?: DatasetAclMode
599
+ }
600
+ ): Observable<DatasetResponse>
601
+ /**
602
+ * Edit a dataset with the given name
603
+ *
604
+ * @param name - Name of the dataset to edit
605
+ * @param options - New options for the dataset
606
+ */
607
+ edit(
608
+ name: string,
609
+ options?: {
610
+ aclMode?: DatasetAclMode
611
+ }
612
+ ): Observable<DatasetResponse>
613
+ /**
614
+ * Delete a dataset with the given name
615
+ *
616
+ * @param name - Name of the dataset to delete
617
+ */
618
+ delete(name: string): Observable<{
619
+ deleted: true
620
+ }>
621
+ /**
622
+ * Fetch a list of datasets for the configured project
623
+ */
624
+ list(): Observable<DatasetsResponse>
653
625
  }
654
626
 
655
627
  export declare class ObservablePatch extends BasePatch {
@@ -703,9 +675,19 @@ export declare class ObservablePatch extends BasePatch {
703
675
 
704
676
  export declare type ObservablePatchBuilder = (patch: ObservablePatch) => ObservablePatch
705
677
 
706
- export declare class ObservableProjectsClient extends BaseProjectsClient {
707
- client: ObservableSanityClient
708
- constructor(client: ObservableSanityClient)
678
+ export declare class ObservableProjectsClient {
679
+ #private
680
+ constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
681
+ /**
682
+ * Fetch a list of projects the authenticated user has access to
683
+ */
684
+ list(): Observable<SanityProject[]>
685
+ /**
686
+ * Fetch a project by project ID
687
+ *
688
+ * @param projectId - ID of the project to fetch
689
+ */
690
+ getById(projectId: string): Observable<SanityProject>
709
691
  }
710
692
 
711
693
  export declare class ObservableSanityClient {
@@ -1144,22 +1126,6 @@ export declare class ObservableSanityClient {
1144
1126
  * @param options Request options
1145
1127
  */
1146
1128
  request<R = any>(options: RawRequestOptions): Observable<R>
1147
- /**
1148
- * DEPRECATED: Get a Sanity API URL for the URI provided
1149
- *
1150
- * @deprecated Should be an internal concern
1151
- * @param uri URI/path to build URL for
1152
- * @param canUseCdn Whether or not to allow using the API CDN for this route
1153
- */
1154
- getUrl(uri: string, canUseCdn?: boolean): string
1155
- /**
1156
- * DEPRECATED: Get a Sanity API URL for the data operation and path provided
1157
- *
1158
- * @deprecated Should be an internal concern
1159
- * @param operation Data operation
1160
- * @param path Path to append
1161
- */
1162
- getDataUrl(operation: string, path?: string): string
1163
1129
  }
1164
1130
 
1165
1131
  export declare class ObservableTransaction extends BaseTransaction {
@@ -1220,9 +1186,17 @@ export declare class ObservableTransaction extends BaseTransaction {
1220
1186
  patch(patch: ObservablePatch): this
1221
1187
  }
1222
1188
 
1223
- export declare class ObservableUsersClient extends BaseUsersClient {
1224
- client: ObservableSanityClient
1225
- constructor(client: ObservableSanityClient)
1189
+ export declare class ObservableUsersClient {
1190
+ #private
1191
+ constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
1192
+ /**
1193
+ * Fetch a user by user ID
1194
+ *
1195
+ * @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
1196
+ */
1197
+ getById<T extends 'me' | string>(
1198
+ id: T
1199
+ ): Observable<T extends 'me' ? CurrentSanityUser : SanityUser>
1226
1200
  }
1227
1201
 
1228
1202
  export declare class Patch extends BasePatch {
@@ -1307,9 +1281,19 @@ declare interface ProgressEvent_2 {
1307
1281
  }
1308
1282
  export {ProgressEvent_2 as ProgressEvent}
1309
1283
 
1310
- export declare class ProjectsClient extends BaseProjectsClient {
1311
- client: SanityClient
1312
- constructor(client: SanityClient)
1284
+ export declare class ProjectsClient {
1285
+ #private
1286
+ constructor(client: SanityClient, httpRequest: HttpRequest)
1287
+ /**
1288
+ * Fetch a list of projects the authenticated user has access to
1289
+ */
1290
+ list(): Promise<SanityProject[]>
1291
+ /**
1292
+ * Fetch a project by project ID
1293
+ *
1294
+ * @param projectId - ID of the project to fetch
1295
+ */
1296
+ getById(projectId: string): Promise<SanityProject>
1313
1297
  }
1314
1298
 
1315
1299
  export declare type QueryParams = {
@@ -1841,22 +1825,6 @@ export declare class SanityClient {
1841
1825
  * @param options Request options
1842
1826
  */
1843
1827
  dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<any>
1844
- /**
1845
- * DEPRECATED: Get a Sanity API URL for the URI provided
1846
- *
1847
- * @deprecated Should be an internal concern
1848
- * @param uri URI/path to build URL for
1849
- * @param canUseCdn Whether or not to allow using the API CDN for this route
1850
- */
1851
- getUrl(uri: string, canUseCdn?: boolean): string
1852
- /**
1853
- * DEPRECATED: Get a Sanity API URL for the data operation and path provided
1854
- *
1855
- * @deprecated Should be an internal concern
1856
- * @param operation Data operation
1857
- * @param path Path to append
1858
- */
1859
- getDataUrl(operation: string, path?: string): string
1860
1828
  }
1861
1829
 
1862
1830
  export declare type SanityDocument<T extends Record<string, any> = Record<string, any>> = {
@@ -2123,9 +2091,15 @@ export declare interface UploadClientConfig {
2123
2091
  }
2124
2092
  }
2125
2093
 
2126
- export declare class UsersClient extends BaseUsersClient {
2127
- client: SanityClient
2128
- constructor(client: SanityClient)
2094
+ export declare class UsersClient {
2095
+ #private
2096
+ constructor(client: SanityClient, httpRequest: HttpRequest)
2097
+ /**
2098
+ * Fetch a user by user ID
2099
+ *
2100
+ * @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
2101
+ */
2102
+ getById<T extends 'me' | string>(id: T): Promise<T extends 'me' ? CurrentSanityUser : SanityUser>
2129
2103
  }
2130
2104
 
2131
2105
  export declare type WelcomeEvent = {