@sanity/client 8.4.0 → 8.5.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/README.md +80 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +200 -6
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +277 -22
- package/dist/index.node.js +150 -13
- package/dist/index.node.js.map +1 -1
- package/dist/media-library.d.ts +1 -1
- package/dist/stega.js +2 -2
- package/dist/{dist-Z8cIRxoB.js → stegaClean-YZRATV86.js} +19 -2
- package/dist/stegaClean-YZRATV86.js.map +1 -0
- package/dist/{stegaEncodeSourceMap-YR3NQ3iz.js → stegaEncodeSourceMap-Dj29aWKG.js} +2 -2
- package/dist/{stegaEncodeSourceMap-YR3NQ3iz.js.map → stegaEncodeSourceMap-Dj29aWKG.js.map} +1 -1
- package/dist/{types-DiPF0ENT.d.ts → types-CtHEe8SF.d.ts} +278 -23
- package/package.json +16 -14
- package/src/SanityClient.ts +176 -9
- package/src/agent/actions/AgentActionsClient.ts +8 -2
- package/src/assets/AssetsClient.ts +8 -2
- package/src/data/live.ts +1 -0
- package/src/datasets/DatasetsClient.ts +8 -2
- package/src/mediaLibrary/MediaLibraryVideoClient.ts +8 -2
- package/src/projects/ProjectsClient.ts +8 -2
- package/src/releases/ReleasesClient.ts +8 -2
- package/src/types.ts +49 -6
- package/src/users/UsersClient.ts +8 -2
- package/dist/dist-Z8cIRxoB.js.map +0 -1
- package/dist/stegaClean-C18wLWau.js +0 -21
- package/dist/stegaClean-C18wLWau.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/client",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.5.0",
|
|
4
4
|
"description": "Client for retrieving, creating and patching data from Sanity.io",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -49,38 +49,39 @@
|
|
|
49
49
|
"./package.json": "./package.json"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"eventsource": "^5.1.
|
|
53
|
-
"get-it": "^9.5.
|
|
52
|
+
"eventsource": "^5.1.1",
|
|
53
|
+
"get-it": "^9.5.2",
|
|
54
54
|
"obug": "^2.1.4",
|
|
55
55
|
"rxjs": "^7.8.2"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@changesets/cli": "^2.31.1",
|
|
59
|
-
"@cloudflare/vitest-pool-workers": "^0.
|
|
59
|
+
"@cloudflare/vitest-pool-workers": "^0.22.0",
|
|
60
60
|
"@edge-runtime/types": "^4.0.0",
|
|
61
61
|
"@edge-runtime/vm": "^5.0.0",
|
|
62
|
-
"@sanity/pkg-utils": "^12.
|
|
62
|
+
"@sanity/pkg-utils": "^12.3.3",
|
|
63
63
|
"@types/json-diff": "^1.0.3",
|
|
64
64
|
"@types/node": "^22.20.1",
|
|
65
65
|
"@types/react": "^19.2.18",
|
|
66
66
|
"@vercel/stega": "1.1.0",
|
|
67
|
-
"@vitest/browser": "^4.1.
|
|
68
|
-
"@vitest/browser-playwright": "^4.1.
|
|
69
|
-
"@vitest/coverage-v8": "^4.1.
|
|
67
|
+
"@vitest/browser": "^4.1.11",
|
|
68
|
+
"@vitest/browser-playwright": "^4.1.11",
|
|
69
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
70
70
|
"eventsource-encoder": "^1.0.2",
|
|
71
|
-
"happy-dom": "^20.11.
|
|
71
|
+
"happy-dom": "^20.11.12",
|
|
72
72
|
"json-diff": "^1.0.6",
|
|
73
|
-
"knip": "^6.32.
|
|
73
|
+
"knip": "^6.32.3",
|
|
74
74
|
"ls-engines": "^0.10.1",
|
|
75
|
-
"next": "^16.3.
|
|
76
|
-
"oxfmt": "^0.
|
|
77
|
-
"oxlint": "^1.
|
|
75
|
+
"next": "^16.3.3",
|
|
76
|
+
"oxfmt": "^0.65.0",
|
|
77
|
+
"oxlint": "^1.80.0",
|
|
78
78
|
"oxlint-tsgolint": "^7.0.2001",
|
|
79
79
|
"pkg-pr-new": "^0.0.88",
|
|
80
80
|
"playwright": "^1.62.1",
|
|
81
|
+
"rolldown": "^1.2.6",
|
|
81
82
|
"typescript": "7.0.2",
|
|
82
83
|
"undici": "^7.29.0",
|
|
83
|
-
"vitest": "^4.1.
|
|
84
|
+
"vitest": "^4.1.11"
|
|
84
85
|
},
|
|
85
86
|
"browserslist": "extends @sanity/browserslist-config",
|
|
86
87
|
"engines": {
|
|
@@ -92,6 +93,7 @@
|
|
|
92
93
|
"scripts": {
|
|
93
94
|
"build": "pkg build --strict && pkg --strict",
|
|
94
95
|
"coverage": "vitest run --coverage",
|
|
96
|
+
"docs:build": "pnpm --filter @sanity/client-docs exec typedoc --options ../../typedoc.json",
|
|
95
97
|
"lint": "oxlint",
|
|
96
98
|
"release": "changeset publish",
|
|
97
99
|
"test": "vitest",
|
package/src/SanityClient.ts
CHANGED
|
@@ -78,15 +78,52 @@ export type {
|
|
|
78
78
|
|
|
79
79
|
/** @public */
|
|
80
80
|
export class ObservableSanityClient {
|
|
81
|
+
/**
|
|
82
|
+
* Upload, fetch and delete assets (images and files) in the configured dataset
|
|
83
|
+
*
|
|
84
|
+
* @category Assets
|
|
85
|
+
*/
|
|
81
86
|
assets: ObservableAssetsClient
|
|
87
|
+
/**
|
|
88
|
+
* Create, list, edit and delete datasets in the configured project
|
|
89
|
+
*
|
|
90
|
+
* @category Projects & Datasets
|
|
91
|
+
*/
|
|
82
92
|
datasets: ObservableDatasetsClient
|
|
93
|
+
/**
|
|
94
|
+
* Subscribe to live content updates through the Live Content API
|
|
95
|
+
*
|
|
96
|
+
* @category Real-time
|
|
97
|
+
*/
|
|
83
98
|
live: LiveClient
|
|
99
|
+
/**
|
|
100
|
+
* Interact with Media Library assets
|
|
101
|
+
*
|
|
102
|
+
* @category Assets
|
|
103
|
+
*/
|
|
84
104
|
mediaLibrary: {
|
|
105
|
+
/** Upload and manage Media Library video assets */
|
|
85
106
|
video: ObservableMediaLibraryVideoClient
|
|
86
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Fetch information about the projects the authenticated user has access to
|
|
110
|
+
*
|
|
111
|
+
* @category Projects & Datasets
|
|
112
|
+
*/
|
|
87
113
|
projects: ObservableProjectsClient
|
|
114
|
+
/**
|
|
115
|
+
* Fetch information about users in the configured project
|
|
116
|
+
*
|
|
117
|
+
* @category Projects & Datasets
|
|
118
|
+
*/
|
|
88
119
|
users: ObservableUsersClient
|
|
120
|
+
/**
|
|
121
|
+
* Run Agent Actions - AI-powered operations to generate, transform, translate, prompt and patch documents
|
|
122
|
+
*
|
|
123
|
+
* @category Agent Actions
|
|
124
|
+
*/
|
|
89
125
|
agent: {
|
|
126
|
+
/** Run individual Agent Action operations */
|
|
90
127
|
action: ObservableAgentsActionClient
|
|
91
128
|
}
|
|
92
129
|
collaboration: {
|
|
@@ -94,18 +131,22 @@ export class ObservableSanityClient {
|
|
|
94
131
|
comments: ObservableCollaborationCommentsClient
|
|
95
132
|
}
|
|
96
133
|
functions: ObservableFunctionsClient
|
|
134
|
+
/**
|
|
135
|
+
* Create and manage content releases and their scheduled publishing
|
|
136
|
+
*
|
|
137
|
+
* @category Releases
|
|
138
|
+
*/
|
|
97
139
|
releases: ObservableReleasesClient
|
|
98
140
|
/** @beta */
|
|
99
141
|
context: ObservableContextClient
|
|
100
142
|
|
|
101
|
-
/**
|
|
102
|
-
* Private properties
|
|
103
|
-
*/
|
|
104
143
|
#clientConfig: InitializedClientConfig
|
|
105
144
|
#httpRequest: HttpRequest
|
|
106
145
|
|
|
107
146
|
/**
|
|
108
|
-
*
|
|
147
|
+
* Listen to document changes matching a GROQ query, delivered as server-sent events
|
|
148
|
+
*
|
|
149
|
+
* @category Real-time
|
|
109
150
|
*/
|
|
110
151
|
listen = _listen
|
|
111
152
|
|
|
@@ -135,6 +176,8 @@ export class ObservableSanityClient {
|
|
|
135
176
|
|
|
136
177
|
/**
|
|
137
178
|
* Clone the client - returns a new instance
|
|
179
|
+
*
|
|
180
|
+
* @category Configuration
|
|
138
181
|
*/
|
|
139
182
|
clone(): ObservableSanityClient {
|
|
140
183
|
return new ObservableSanityClient(this.#httpRequest, this.config())
|
|
@@ -142,6 +185,8 @@ export class ObservableSanityClient {
|
|
|
142
185
|
|
|
143
186
|
/**
|
|
144
187
|
* Returns the current client configuration
|
|
188
|
+
*
|
|
189
|
+
* @category Configuration
|
|
145
190
|
*/
|
|
146
191
|
config(): InitializedClientConfig
|
|
147
192
|
/**
|
|
@@ -166,6 +211,8 @@ export class ObservableSanityClient {
|
|
|
166
211
|
/**
|
|
167
212
|
* Clone the client with a new (partial) configuration.
|
|
168
213
|
*
|
|
214
|
+
* @category Configuration
|
|
215
|
+
*
|
|
169
216
|
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
170
217
|
*/
|
|
171
218
|
withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityClient {
|
|
@@ -185,6 +232,8 @@ export class ObservableSanityClient {
|
|
|
185
232
|
/**
|
|
186
233
|
* Perform a GROQ-query against the configured dataset.
|
|
187
234
|
*
|
|
235
|
+
* @category Querying
|
|
236
|
+
*
|
|
188
237
|
* @param query - GROQ-query to perform
|
|
189
238
|
*/
|
|
190
239
|
fetch<
|
|
@@ -258,6 +307,8 @@ export class ObservableSanityClient {
|
|
|
258
307
|
/**
|
|
259
308
|
* Fetch a single document with the given ID.
|
|
260
309
|
*
|
|
310
|
+
* @category Querying
|
|
311
|
+
*
|
|
261
312
|
* @param id - Document ID to fetch
|
|
262
313
|
* @param options - Request options
|
|
263
314
|
*/
|
|
@@ -317,6 +368,8 @@ export class ObservableSanityClient {
|
|
|
317
368
|
* The order/position of documents is preserved based on the original array of IDs.
|
|
318
369
|
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
319
370
|
*
|
|
371
|
+
* @category Querying
|
|
372
|
+
*
|
|
320
373
|
* @param ids - Document IDs to fetch
|
|
321
374
|
* @param options - Request options
|
|
322
375
|
*/
|
|
@@ -331,6 +384,8 @@ export class ObservableSanityClient {
|
|
|
331
384
|
* Convenient and bandwidth efficient method of checking wether a set of document IDs exists.
|
|
332
385
|
* Returns a set of the IDs that exist.
|
|
333
386
|
*
|
|
387
|
+
* @category Querying
|
|
388
|
+
*
|
|
334
389
|
* @param ids - Document IDs to check
|
|
335
390
|
* @param options - Request options
|
|
336
391
|
*/
|
|
@@ -345,6 +400,8 @@ export class ObservableSanityClient {
|
|
|
345
400
|
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
346
401
|
* Returns an observable that resolves to the created document.
|
|
347
402
|
*
|
|
403
|
+
* @category Mutations
|
|
404
|
+
*
|
|
348
405
|
* @param document - Document to create
|
|
349
406
|
* @param options - Mutation options
|
|
350
407
|
*/
|
|
@@ -414,6 +471,8 @@ export class ObservableSanityClient {
|
|
|
414
471
|
* Create a document if no document with the same ID already exists.
|
|
415
472
|
* Returns an observable that resolves to the created document.
|
|
416
473
|
*
|
|
474
|
+
* @category Mutations
|
|
475
|
+
*
|
|
417
476
|
* @param document - Document to create
|
|
418
477
|
* @param options - Mutation options
|
|
419
478
|
*/
|
|
@@ -483,6 +542,8 @@ export class ObservableSanityClient {
|
|
|
483
542
|
* Create a document if it does not exist, or replace a document with the same document ID
|
|
484
543
|
* Returns an observable that resolves to the created document.
|
|
485
544
|
*
|
|
545
|
+
* @category Mutations
|
|
546
|
+
*
|
|
486
547
|
* @param document - Document to either create or replace
|
|
487
548
|
* @param options - Mutation options
|
|
488
549
|
*/
|
|
@@ -691,6 +752,8 @@ export class ObservableSanityClient {
|
|
|
691
752
|
* Deletes a document with the given document ID.
|
|
692
753
|
* Returns an observable that resolves to the deleted document.
|
|
693
754
|
*
|
|
755
|
+
* @category Mutations
|
|
756
|
+
*
|
|
694
757
|
* @param id - Document ID to delete
|
|
695
758
|
* @param options - Options for the mutation
|
|
696
759
|
*/
|
|
@@ -811,6 +874,8 @@ export class ObservableSanityClient {
|
|
|
811
874
|
* * Discarding a version with no `releaseId` will discard the draft version of the published document.
|
|
812
875
|
* * If the draft or release version does not exist, any error will throw.
|
|
813
876
|
*
|
|
877
|
+
* @category Versions
|
|
878
|
+
*
|
|
814
879
|
* @param params - Version action parameters:
|
|
815
880
|
* - `releaseId` - The ID of the release to discard the document from.
|
|
816
881
|
* - `publishedId` - The published ID of the document to discard.
|
|
@@ -858,6 +923,8 @@ export class ObservableSanityClient {
|
|
|
858
923
|
* * Replacing a version with no `releaseId` will replace the draft version of the published document.
|
|
859
924
|
* * At least one of the **version** or **published** documents must exist.
|
|
860
925
|
*
|
|
926
|
+
* @category Versions
|
|
927
|
+
*
|
|
861
928
|
* @param params - Version action parameters:
|
|
862
929
|
* - `document` - The new document to replace the version with.
|
|
863
930
|
* - `releaseId` - The ID of the release where the document version is replaced.
|
|
@@ -964,6 +1031,8 @@ export class ObservableSanityClient {
|
|
|
964
1031
|
* @remarks
|
|
965
1032
|
* * If the published document does not exist, an error will be thrown.
|
|
966
1033
|
*
|
|
1034
|
+
* @category Versions
|
|
1035
|
+
*
|
|
967
1036
|
* @param params - Version action parameters:
|
|
968
1037
|
* - `releaseId` - The ID of the release to unpublish the document from.
|
|
969
1038
|
* - `publishedId` - The published ID of the document to unpublish.
|
|
@@ -995,6 +1064,8 @@ export class ObservableSanityClient {
|
|
|
995
1064
|
* Perform mutation operations against the configured dataset
|
|
996
1065
|
* Returns an observable that resolves to the first mutated document.
|
|
997
1066
|
*
|
|
1067
|
+
* @category Mutations
|
|
1068
|
+
*
|
|
998
1069
|
* @param operations - Mutation operations to execute
|
|
999
1070
|
* @param options - Mutation options
|
|
1000
1071
|
*/
|
|
@@ -1063,6 +1134,8 @@ export class ObservableSanityClient {
|
|
|
1063
1134
|
/**
|
|
1064
1135
|
* Create a new buildable patch of operations to perform
|
|
1065
1136
|
*
|
|
1137
|
+
* @category Mutations
|
|
1138
|
+
*
|
|
1066
1139
|
* @param documentId - Document ID to patch
|
|
1067
1140
|
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
1068
1141
|
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
@@ -1101,6 +1174,8 @@ export class ObservableSanityClient {
|
|
|
1101
1174
|
/**
|
|
1102
1175
|
* Create a new transaction of mutations
|
|
1103
1176
|
*
|
|
1177
|
+
* @category Mutations
|
|
1178
|
+
*
|
|
1104
1179
|
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
|
1105
1180
|
*/
|
|
1106
1181
|
transaction<R extends Record<string, Any> = Record<string, Any>>(
|
|
@@ -1112,6 +1187,8 @@ export class ObservableSanityClient {
|
|
|
1112
1187
|
/**
|
|
1113
1188
|
* Perform action operations against the configured dataset
|
|
1114
1189
|
*
|
|
1190
|
+
* @category Mutations
|
|
1191
|
+
*
|
|
1115
1192
|
* @param operations - Action operation(s) to execute
|
|
1116
1193
|
* @param options - Action options
|
|
1117
1194
|
*/
|
|
@@ -1125,6 +1202,8 @@ export class ObservableSanityClient {
|
|
|
1125
1202
|
/**
|
|
1126
1203
|
* Perform an HTTP request against the Sanity API
|
|
1127
1204
|
*
|
|
1205
|
+
* @category HTTP
|
|
1206
|
+
*
|
|
1128
1207
|
* @param options - Request options
|
|
1129
1208
|
*/
|
|
1130
1209
|
request<R = Any>(options: RawRequestOptions): Observable<R> {
|
|
@@ -1134,6 +1213,8 @@ export class ObservableSanityClient {
|
|
|
1134
1213
|
/**
|
|
1135
1214
|
* Get a Sanity API URL for the URI provided
|
|
1136
1215
|
*
|
|
1216
|
+
* @category HTTP
|
|
1217
|
+
*
|
|
1137
1218
|
* @param uri - URI/path to build URL for
|
|
1138
1219
|
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
|
1139
1220
|
*/
|
|
@@ -1144,6 +1225,8 @@ export class ObservableSanityClient {
|
|
|
1144
1225
|
/**
|
|
1145
1226
|
* Get a Sanity API URL for the data operation and path provided
|
|
1146
1227
|
*
|
|
1228
|
+
* @category HTTP
|
|
1229
|
+
*
|
|
1147
1230
|
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
|
1148
1231
|
* @param path - Path to append after the operation
|
|
1149
1232
|
*/
|
|
@@ -1154,15 +1237,52 @@ export class ObservableSanityClient {
|
|
|
1154
1237
|
|
|
1155
1238
|
/** @public */
|
|
1156
1239
|
export class SanityClient {
|
|
1240
|
+
/**
|
|
1241
|
+
* Upload, fetch and delete assets (images and files) in the configured dataset
|
|
1242
|
+
*
|
|
1243
|
+
* @category Assets
|
|
1244
|
+
*/
|
|
1157
1245
|
assets: AssetsClient
|
|
1246
|
+
/**
|
|
1247
|
+
* Create, list, edit and delete datasets in the configured project
|
|
1248
|
+
*
|
|
1249
|
+
* @category Projects & Datasets
|
|
1250
|
+
*/
|
|
1158
1251
|
datasets: DatasetsClient
|
|
1252
|
+
/**
|
|
1253
|
+
* Subscribe to live content updates through the Live Content API
|
|
1254
|
+
*
|
|
1255
|
+
* @category Real-time
|
|
1256
|
+
*/
|
|
1159
1257
|
live: LiveClient
|
|
1258
|
+
/**
|
|
1259
|
+
* Interact with Media Library assets
|
|
1260
|
+
*
|
|
1261
|
+
* @category Assets
|
|
1262
|
+
*/
|
|
1160
1263
|
mediaLibrary: {
|
|
1264
|
+
/** Upload and manage Media Library video assets */
|
|
1161
1265
|
video: MediaLibraryVideoClient
|
|
1162
1266
|
}
|
|
1267
|
+
/**
|
|
1268
|
+
* Fetch information about the projects the authenticated user has access to
|
|
1269
|
+
*
|
|
1270
|
+
* @category Projects & Datasets
|
|
1271
|
+
*/
|
|
1163
1272
|
projects: ProjectsClient
|
|
1273
|
+
/**
|
|
1274
|
+
* Fetch information about users in the configured project
|
|
1275
|
+
*
|
|
1276
|
+
* @category Projects & Datasets
|
|
1277
|
+
*/
|
|
1164
1278
|
users: UsersClient
|
|
1279
|
+
/**
|
|
1280
|
+
* Run Agent Actions - AI-powered operations to generate, transform, translate, prompt and patch documents
|
|
1281
|
+
*
|
|
1282
|
+
* @category Agent Actions
|
|
1283
|
+
*/
|
|
1165
1284
|
agent: {
|
|
1285
|
+
/** Run individual Agent Action operations */
|
|
1166
1286
|
action: AgentActionsClient
|
|
1167
1287
|
}
|
|
1168
1288
|
collaboration: {
|
|
@@ -1170,23 +1290,29 @@ export class SanityClient {
|
|
|
1170
1290
|
comments: CollaborationCommentsClient
|
|
1171
1291
|
}
|
|
1172
1292
|
functions: FunctionsClient
|
|
1293
|
+
/**
|
|
1294
|
+
* Create and manage content releases and their scheduled publishing
|
|
1295
|
+
*
|
|
1296
|
+
* @category Releases
|
|
1297
|
+
*/
|
|
1173
1298
|
releases: ReleasesClient
|
|
1174
1299
|
/** @beta */
|
|
1175
1300
|
context: ContextClient
|
|
1176
1301
|
|
|
1177
1302
|
/**
|
|
1178
1303
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
1304
|
+
*
|
|
1305
|
+
* @category Configuration
|
|
1179
1306
|
*/
|
|
1180
1307
|
observable: ObservableSanityClient
|
|
1181
1308
|
|
|
1182
|
-
/**
|
|
1183
|
-
* Private properties
|
|
1184
|
-
*/
|
|
1185
1309
|
#clientConfig: InitializedClientConfig
|
|
1186
1310
|
#httpRequest: HttpRequest
|
|
1187
1311
|
|
|
1188
1312
|
/**
|
|
1189
|
-
*
|
|
1313
|
+
* Listen to document changes matching a GROQ query, delivered as server-sent events
|
|
1314
|
+
*
|
|
1315
|
+
* @category Real-time
|
|
1190
1316
|
*/
|
|
1191
1317
|
listen = _listen
|
|
1192
1318
|
|
|
@@ -1218,6 +1344,8 @@ export class SanityClient {
|
|
|
1218
1344
|
|
|
1219
1345
|
/**
|
|
1220
1346
|
* Clone the client - returns a new instance
|
|
1347
|
+
*
|
|
1348
|
+
* @category Configuration
|
|
1221
1349
|
*/
|
|
1222
1350
|
clone(): SanityClient {
|
|
1223
1351
|
return new SanityClient(this.#httpRequest, this.config())
|
|
@@ -1225,6 +1353,8 @@ export class SanityClient {
|
|
|
1225
1353
|
|
|
1226
1354
|
/**
|
|
1227
1355
|
* Returns the current client configuration
|
|
1356
|
+
*
|
|
1357
|
+
* @category Configuration
|
|
1228
1358
|
*/
|
|
1229
1359
|
config(): InitializedClientConfig
|
|
1230
1360
|
/**
|
|
@@ -1253,6 +1383,8 @@ export class SanityClient {
|
|
|
1253
1383
|
/**
|
|
1254
1384
|
* Clone the client with a new (partial) configuration.
|
|
1255
1385
|
*
|
|
1386
|
+
* @category Configuration
|
|
1387
|
+
*
|
|
1256
1388
|
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
1257
1389
|
*/
|
|
1258
1390
|
withConfig(newConfig?: Partial<ClientConfig>): SanityClient {
|
|
@@ -1272,6 +1404,8 @@ export class SanityClient {
|
|
|
1272
1404
|
/**
|
|
1273
1405
|
* Perform a GROQ-query against the configured dataset.
|
|
1274
1406
|
*
|
|
1407
|
+
* @category Querying
|
|
1408
|
+
*
|
|
1275
1409
|
* @param query - GROQ-query to perform
|
|
1276
1410
|
*/
|
|
1277
1411
|
fetch<
|
|
@@ -1345,6 +1479,8 @@ export class SanityClient {
|
|
|
1345
1479
|
/**
|
|
1346
1480
|
* Fetch a single document with the given ID.
|
|
1347
1481
|
*
|
|
1482
|
+
* @category Querying
|
|
1483
|
+
*
|
|
1348
1484
|
* @param id - Document ID to fetch
|
|
1349
1485
|
* @param options - Request options
|
|
1350
1486
|
*/
|
|
@@ -1404,6 +1540,8 @@ export class SanityClient {
|
|
|
1404
1540
|
* The order/position of documents is preserved based on the original array of IDs.
|
|
1405
1541
|
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
1406
1542
|
*
|
|
1543
|
+
* @category Querying
|
|
1544
|
+
*
|
|
1407
1545
|
* @param ids - Document IDs to fetch
|
|
1408
1546
|
* @param options - Request options
|
|
1409
1547
|
*/
|
|
@@ -1418,6 +1556,8 @@ export class SanityClient {
|
|
|
1418
1556
|
* Convenient and bandwidth efficient method of checking wether a set of document IDs exists.
|
|
1419
1557
|
* Returns a set of the IDs that exist.
|
|
1420
1558
|
*
|
|
1559
|
+
* @category Querying
|
|
1560
|
+
*
|
|
1421
1561
|
* @param ids - Document IDs to check
|
|
1422
1562
|
* @param options - Request options
|
|
1423
1563
|
*/
|
|
@@ -1432,6 +1572,8 @@ export class SanityClient {
|
|
|
1432
1572
|
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1433
1573
|
* Returns a promise that resolves to the created document.
|
|
1434
1574
|
*
|
|
1575
|
+
* @category Mutations
|
|
1576
|
+
*
|
|
1435
1577
|
* @param document - Document to create
|
|
1436
1578
|
* @param options - Mutation options
|
|
1437
1579
|
*/
|
|
@@ -1501,6 +1643,8 @@ export class SanityClient {
|
|
|
1501
1643
|
* Create a document if no document with the same ID already exists.
|
|
1502
1644
|
* Returns a promise that resolves to the created document.
|
|
1503
1645
|
*
|
|
1646
|
+
* @category Mutations
|
|
1647
|
+
*
|
|
1504
1648
|
* @param document - Document to create
|
|
1505
1649
|
* @param options - Mutation options
|
|
1506
1650
|
*/
|
|
@@ -1570,6 +1714,8 @@ export class SanityClient {
|
|
|
1570
1714
|
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1571
1715
|
* Returns a promise that resolves to the created document.
|
|
1572
1716
|
*
|
|
1717
|
+
* @category Mutations
|
|
1718
|
+
*
|
|
1573
1719
|
* @param document - Document to either create or replace
|
|
1574
1720
|
* @param options - Mutation options
|
|
1575
1721
|
*/
|
|
@@ -1766,6 +1912,8 @@ export class SanityClient {
|
|
|
1766
1912
|
* Deletes a document with the given document ID.
|
|
1767
1913
|
* Returns a promise that resolves to the deleted document.
|
|
1768
1914
|
*
|
|
1915
|
+
* @category Mutations
|
|
1916
|
+
*
|
|
1769
1917
|
* @param id - Document ID to delete
|
|
1770
1918
|
* @param options - Options for the mutation
|
|
1771
1919
|
*/
|
|
@@ -1886,6 +2034,8 @@ export class SanityClient {
|
|
|
1886
2034
|
* * Discarding a version with no `releaseId` will discard the draft version of the published document.
|
|
1887
2035
|
* * If the draft or release version does not exist, any error will throw.
|
|
1888
2036
|
*
|
|
2037
|
+
* @category Versions
|
|
2038
|
+
*
|
|
1889
2039
|
* @param params - Version action parameters:
|
|
1890
2040
|
* - `releaseId` - The ID of the release to discard the document from.
|
|
1891
2041
|
* - `publishedId` - The published ID of the document to discard.
|
|
@@ -1927,6 +2077,8 @@ export class SanityClient {
|
|
|
1927
2077
|
* * Replacing a version with no `releaseId` will replace the draft version of the published document.
|
|
1928
2078
|
* * At least one of the **version** or **published** documents must exist.
|
|
1929
2079
|
*
|
|
2080
|
+
* @category Versions
|
|
2081
|
+
*
|
|
1930
2082
|
* @param params - Version action parameters:
|
|
1931
2083
|
* - `document` - The new document to replace the version with.
|
|
1932
2084
|
* - `releaseId` - The ID of the release where the document version is replaced.
|
|
@@ -1980,7 +2132,6 @@ export class SanityClient {
|
|
|
1980
2132
|
* // }
|
|
1981
2133
|
* ```
|
|
1982
2134
|
*/
|
|
1983
|
-
|
|
1984
2135
|
replaceVersion<R extends Record<string, Any>>(
|
|
1985
2136
|
args: {
|
|
1986
2137
|
document: SanityDocumentStub<R>
|
|
@@ -2029,6 +2180,8 @@ export class SanityClient {
|
|
|
2029
2180
|
* @remarks
|
|
2030
2181
|
* * If the published document does not exist, an error will be thrown.
|
|
2031
2182
|
*
|
|
2183
|
+
* @category Versions
|
|
2184
|
+
*
|
|
2032
2185
|
* @param params - Version action parameters:
|
|
2033
2186
|
* - `releaseId` - The ID of the release to unpublish the document from.
|
|
2034
2187
|
* - `publishedId` - The published ID of the document to unpublish.
|
|
@@ -2054,6 +2207,8 @@ export class SanityClient {
|
|
|
2054
2207
|
* Perform mutation operations against the configured dataset
|
|
2055
2208
|
* Returns a promise that resolves to the first mutated document.
|
|
2056
2209
|
*
|
|
2210
|
+
* @category Mutations
|
|
2211
|
+
*
|
|
2057
2212
|
* @param operations - Mutation operations to execute
|
|
2058
2213
|
* @param options - Mutation options
|
|
2059
2214
|
*/
|
|
@@ -2122,6 +2277,8 @@ export class SanityClient {
|
|
|
2122
2277
|
/**
|
|
2123
2278
|
* Create a new buildable patch of operations to perform
|
|
2124
2279
|
*
|
|
2280
|
+
* @category Mutations
|
|
2281
|
+
*
|
|
2125
2282
|
* @param documentId - Document ID to patch
|
|
2126
2283
|
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2127
2284
|
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
@@ -2160,6 +2317,8 @@ export class SanityClient {
|
|
|
2160
2317
|
/**
|
|
2161
2318
|
* Create a new transaction of mutations
|
|
2162
2319
|
*
|
|
2320
|
+
* @category Mutations
|
|
2321
|
+
*
|
|
2163
2322
|
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
|
2164
2323
|
*/
|
|
2165
2324
|
transaction<R extends Record<string, Any> = Record<string, Any>>(
|
|
@@ -2172,6 +2331,8 @@ export class SanityClient {
|
|
|
2172
2331
|
* Perform action operations against the configured dataset
|
|
2173
2332
|
* Returns a promise that resolves to the transaction result
|
|
2174
2333
|
*
|
|
2334
|
+
* @category Mutations
|
|
2335
|
+
*
|
|
2175
2336
|
* @param operations - Action operation(s) to execute
|
|
2176
2337
|
* @param options - Action options
|
|
2177
2338
|
*/
|
|
@@ -2186,6 +2347,8 @@ export class SanityClient {
|
|
|
2186
2347
|
* Perform a request against the Sanity API
|
|
2187
2348
|
* NOTE: Only use this for Sanity API endpoints, not for your own APIs!
|
|
2188
2349
|
*
|
|
2350
|
+
* @category HTTP
|
|
2351
|
+
*
|
|
2189
2352
|
* @param options - Request options
|
|
2190
2353
|
* @returns Promise resolving to the response body
|
|
2191
2354
|
*/
|
|
@@ -2210,6 +2373,8 @@ export class SanityClient {
|
|
|
2210
2373
|
/**
|
|
2211
2374
|
* Get a Sanity API URL for the URI provided
|
|
2212
2375
|
*
|
|
2376
|
+
* @category HTTP
|
|
2377
|
+
*
|
|
2213
2378
|
* @param uri - URI/path to build URL for
|
|
2214
2379
|
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
|
2215
2380
|
*/
|
|
@@ -2220,6 +2385,8 @@ export class SanityClient {
|
|
|
2220
2385
|
/**
|
|
2221
2386
|
* Get a Sanity API URL for the data operation and path provided
|
|
2222
2387
|
*
|
|
2388
|
+
* @category HTTP
|
|
2389
|
+
*
|
|
2223
2390
|
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
|
2224
2391
|
* @param path - Path to append after the operation
|
|
2225
2392
|
*/
|
|
@@ -8,7 +8,10 @@ import {_prompt, type PromptRequest} from './prompt'
|
|
|
8
8
|
import {_transform, _transformObservable, type TransformDocument} from './transform'
|
|
9
9
|
import {_translate, _translateObservable, type TranslateDocument} from './translate'
|
|
10
10
|
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
* @inline
|
|
14
|
+
*/
|
|
12
15
|
export class ObservableAgentsActionClient {
|
|
13
16
|
#client: ObservableSanityClient
|
|
14
17
|
#httpRequest: HttpRequest
|
|
@@ -60,7 +63,10 @@ export class ObservableAgentsActionClient {
|
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
|
|
63
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* @public
|
|
68
|
+
* @inline
|
|
69
|
+
*/
|
|
64
70
|
export class AgentActionsClient {
|
|
65
71
|
#client: SanityClient
|
|
66
72
|
#httpRequest: HttpRequest
|
|
@@ -18,7 +18,10 @@ import type {
|
|
|
18
18
|
} from '../types'
|
|
19
19
|
import * as validators from '../validators'
|
|
20
20
|
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
* @inline
|
|
24
|
+
*/
|
|
22
25
|
export class ObservableAssetsClient {
|
|
23
26
|
#client: ObservableSanityClient
|
|
24
27
|
#httpRequest: HttpRequest
|
|
@@ -78,7 +81,10 @@ export class ObservableAssetsClient {
|
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
|
|
81
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* @internal
|
|
86
|
+
* @inline
|
|
87
|
+
*/
|
|
82
88
|
export class AssetsClient {
|
|
83
89
|
#client: SanityClient
|
|
84
90
|
#httpRequest: HttpRequest
|
package/src/data/live.ts
CHANGED
|
@@ -13,7 +13,10 @@ import type {
|
|
|
13
13
|
} from '../types'
|
|
14
14
|
import * as validate from '../validators'
|
|
15
15
|
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* @internal
|
|
18
|
+
* @inline
|
|
19
|
+
*/
|
|
17
20
|
export class ObservableDatasetsClient {
|
|
18
21
|
#client: ObservableSanityClient
|
|
19
22
|
#httpRequest: HttpRequest
|
|
@@ -107,7 +110,10 @@ export class ObservableDatasetsClient {
|
|
|
107
110
|
}
|
|
108
111
|
}
|
|
109
112
|
|
|
110
|
-
/**
|
|
113
|
+
/**
|
|
114
|
+
* @internal
|
|
115
|
+
* @inline
|
|
116
|
+
*/
|
|
111
117
|
export class DatasetsClient {
|
|
112
118
|
#client: SanityClient
|
|
113
119
|
#httpRequest: HttpRequest
|