@sanity/client 8.0.0 → 8.2.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.
Files changed (58) hide show
  1. package/README.md +265 -0
  2. package/dist/{browserUpload-CQgx9YYo.js → browserUpload-2tz6Sdqp.js} +4 -3
  3. package/dist/browserUpload-2tz6Sdqp.js.map +1 -0
  4. package/dist/{browserUpload-icWlVP15.js → browserUpload-CwpNx7Vl.js} +4 -3
  5. package/dist/browserUpload-CwpNx7Vl.js.map +1 -0
  6. package/dist/{config-a8VajuEY.js → config-3wiPP-sZ.js} +2 -2
  7. package/dist/config-3wiPP-sZ.js.map +1 -0
  8. package/dist/csm.js +2 -2
  9. package/dist/csm.js.map +1 -1
  10. package/dist/index.d.ts +17 -11
  11. package/dist/index.js +610 -136
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.node.d.ts +918 -26
  14. package/dist/index.node.js +559 -66
  15. package/dist/index.node.js.map +1 -1
  16. package/dist/media-library.d.ts +1 -1
  17. package/dist/{request-CJxcN16k.js → request-BhMuKj0D.js} +10 -9
  18. package/dist/request-BhMuKj0D.js.map +1 -0
  19. package/dist/{request-k7VS_NnC.js → request-SnMg7nUX.js} +10 -9
  20. package/dist/request-SnMg7nUX.js.map +1 -0
  21. package/dist/{resolveEditInfo-sq7yF78q.js → resolveEditInfo-Cz-smq3a.js} +17 -3
  22. package/dist/resolveEditInfo-Cz-smq3a.js.map +1 -0
  23. package/dist/stega.js +1 -1
  24. package/dist/{stegaEncodeSourceMap-DkoIlutY.js → stegaEncodeSourceMap-DbM2fTN4.js} +8 -2
  25. package/dist/stegaEncodeSourceMap-DbM2fTN4.js.map +1 -0
  26. package/dist/{stegaEncodeSourceMap-B2fGArSf.js → stegaEncodeSourceMap-YR3NQ3iz.js} +2 -2
  27. package/dist/{stegaEncodeSourceMap-B2fGArSf.js.map → stegaEncodeSourceMap-YR3NQ3iz.js.map} +1 -1
  28. package/dist/{types-CUxZSgB2.d.ts → types-nJhm5Nyq.d.ts} +910 -24
  29. package/package.json +26 -11
  30. package/src/SanityClient.ts +39 -20
  31. package/src/assets/AssetsClient.ts +54 -5
  32. package/src/collaboration/CollaborationCommentsClient.ts +387 -0
  33. package/src/collaboration/comments.ts +313 -0
  34. package/src/collaboration/types.ts +252 -0
  35. package/src/csm/applySourceDocuments.ts +2 -4
  36. package/src/csm/draftUtils.ts +23 -4
  37. package/src/data/dataMethods.ts +9 -20
  38. package/src/data/eventsource.ts +71 -41
  39. package/src/data/listen.ts +20 -5
  40. package/src/data/live.ts +17 -9
  41. package/src/data/resolveEventSourceFetch.ts +9 -1
  42. package/src/defineCreateClient.ts +5 -1
  43. package/src/functions/FunctionsClient.ts +66 -0
  44. package/src/functions/invoke.ts +176 -0
  45. package/src/http/browserUpload.ts +1 -0
  46. package/src/http/errors.ts +2 -1
  47. package/src/http/request.ts +8 -14
  48. package/src/mediaLibrary/MediaLibraryVideoClient.ts +1 -1
  49. package/src/types.ts +420 -4
  50. package/src/validators.ts +1 -1
  51. package/src/warnings.ts +7 -1
  52. package/dist/browserUpload-CQgx9YYo.js.map +0 -1
  53. package/dist/browserUpload-icWlVP15.js.map +0 -1
  54. package/dist/config-a8VajuEY.js.map +0 -1
  55. package/dist/request-CJxcN16k.js.map +0 -1
  56. package/dist/request-k7VS_NnC.js.map +0 -1
  57. package/dist/resolveEditInfo-sq7yF78q.js.map +0 -1
  58. package/dist/stegaEncodeSourceMap-DkoIlutY.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { f as StegaConfig, l as InitializedStegaConfig } from "./types-CfGzbXrl.js";
2
- import { FetchFunction } from "get-it";
2
+ import { FetchFunction, RequestOptions } from "get-it";
3
3
  import { Observable } from "rxjs";
4
4
  import { ClientPerspective } from "@sanity/client";
5
5
  /**
@@ -1066,6 +1066,16 @@ declare class AssetsClient {
1066
1066
  /**
1067
1067
  * Uploads a file asset to the configured dataset
1068
1068
  *
1069
+ * Note: when the client is configured against a Media Library
1070
+ * (`resource: {type: 'media-library', id}`), this resolves to a
1071
+ * {@link MediaLibraryAssetDocument} at runtime, not to a
1072
+ * {@link SanityAssetDocument}. The declared type cannot express that: the
1073
+ * shape depends on the client's configuration rather than on the arguments,
1074
+ * so an overload cannot discriminate it, and widening the return type into a
1075
+ * union would be a breaking change for every existing caller. Narrow the
1076
+ * result yourself (for example, check for `currentVersion`) if you upload to
1077
+ * a Media Library. Typing this honestly is deferred to the next major.
1078
+ *
1069
1079
  * @param assetType - Asset type (file)
1070
1080
  * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
1071
1081
  * @param options - Options to use for the upload
@@ -1074,6 +1084,10 @@ declare class AssetsClient {
1074
1084
  /**
1075
1085
  * Uploads an image asset to the configured dataset
1076
1086
  *
1087
+ * Note: against a Media Library this resolves to a
1088
+ * {@link MediaLibraryAssetDocument} at runtime. See the `'file'` overload
1089
+ * above for why the declared type cannot say so.
1090
+ *
1077
1091
  * @param assetType - Asset type (image)
1078
1092
  * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
1079
1093
  * @param options - Options to use for the upload
@@ -1126,6 +1140,462 @@ declare function _listen<R extends Record<string, Any$1> = Record<string, Any$1>
1126
1140
  * @public
1127
1141
  */
1128
1142
  declare function _listen<R extends Record<string, Any$1> = Record<string, Any$1>, Opts extends ListenOptions | ResumableListenOptions = ListenOptions | ResumableListenOptions>(this: SanityClient$1 | ObservableSanityClient$1, query: string, params?: ListenParams, options?: Opts): Observable<ListenEventFromOptions<R, Opts>>;
1143
+ /** @internal */
1144
+ declare const possibleRequestOptions: readonly ['headers', 'signal', 'tag', 'timeout', 'token'];
1145
+ /**
1146
+ * Request options honored by the collaboration comments methods.
1147
+ *
1148
+ * @alpha
1149
+ */
1150
+ type CollaborationCommentsRequestOptions = Pick<RequestOptions$1, (typeof possibleRequestOptions)[number]>;
1151
+ /**
1152
+ * Options for collaboration comments write methods.
1153
+ *
1154
+ * @alpha
1155
+ */
1156
+ type CollaborationCommentsWriteOptions = CollaborationCommentsRequestOptions & {
1157
+ /** Transaction ID to associate the write with */
1158
+ transactionId?: string;
1159
+ };
1160
+ /**
1161
+ * Listener options for `collaboration.comments.listen`.
1162
+ *
1163
+ * `includeAllVersions` is left out: comments are stored as `sanity.comment`
1164
+ * documents with no drafts or versions, so it would never make a difference.
1165
+ *
1166
+ * @alpha
1167
+ */
1168
+ type CollaborationCommentsListenOptions = Omit<ListenOptions, 'includeAllVersions'> | Omit<ResumableListenOptions, 'includeAllVersions'>;
1169
+ /**
1170
+ * Status of a comment thread. Replies always share the status of their parent comment.
1171
+ *
1172
+ * @alpha
1173
+ */
1174
+ type CollaborationCommentStatus = 'open' | 'resolved';
1175
+ /**
1176
+ * Emoji short names that can be used as comment reactions.
1177
+ *
1178
+ * @alpha
1179
+ */
1180
+ type CollaborationCommentReactionShortName = ':-1:' | ':+1:' | ':eyes:' | ':heart:' | ':heavy_plus_sign:' | ':rocket:';
1181
+ /**
1182
+ * A single Portable Text block, as used in comment messages and content snapshots.
1183
+ *
1184
+ * @alpha
1185
+ */
1186
+ interface CollaborationCommentPortableTextBlock {
1187
+ _type: string;
1188
+ children: Array<{
1189
+ _type: string;
1190
+ [key: string]: Any$1;
1191
+ }>;
1192
+ [key: string]: Any$1;
1193
+ }
1194
+ /**
1195
+ * Comment message, as an array of Portable Text blocks.
1196
+ *
1197
+ * @alpha
1198
+ */
1199
+ type CollaborationCommentMessage = CollaborationCommentPortableTextBlock[];
1200
+ /**
1201
+ * The text an inline comment was anchored to, resolved by the API when the
1202
+ * comment was created.
1203
+ *
1204
+ * Holds one entry per Portable Text block the selection spans, keyed by the
1205
+ * block it came from. `text` is the plain text of that block with the selected
1206
+ * part wrapped in the marker characters `\uF000` (start) and `\uF001` (end).
1207
+ *
1208
+ * @alpha
1209
+ */
1210
+ interface CollaborationCommentSelection {
1211
+ type: 'text';
1212
+ value: {
1213
+ _key: string;
1214
+ text: string;
1215
+ }[];
1216
+ }
1217
+ /**
1218
+ * A comment document, as stored by the Comments API.
1219
+ *
1220
+ * @alpha
1221
+ */
1222
+ interface CollaborationCommentDocument extends SanityDocument$1 {
1223
+ _type: 'sanity.comment';
1224
+ _system?: {
1225
+ /** ID of the user that created the comment */
1226
+ createdBy?: string;
1227
+ };
1228
+ /** ID shared by a top-level comment and all of its replies */
1229
+ threadId?: string;
1230
+ /** Set on replies, pointing to the comment being replied to */
1231
+ parentCommentId?: string;
1232
+ message: CollaborationCommentMessage;
1233
+ reactions: {
1234
+ _key: string;
1235
+ shortName: CollaborationCommentReactionShortName;
1236
+ userId: string;
1237
+ addedAt: string;
1238
+ }[];
1239
+ /** Arbitrary metadata stored with the comment by the creating application */
1240
+ context?: Record<string, unknown>;
1241
+ target: {
1242
+ /** Global document reference (`resourceType:resourceId:documentId`, using the published document ID) */
1243
+ document: {
1244
+ _ref: `${string}:${string}:${string}`;
1245
+ _type: 'globalDocumentReference';
1246
+ _weak: true;
1247
+ };
1248
+ documentType: string;
1249
+ /** The exact document ID the comment was created against, e.g. a draft or version ID */
1250
+ sourceDocumentId: string;
1251
+ documentRevisionId?: string;
1252
+ /**
1253
+ * Set for field and inline comments. `field` is the `path` the comment was
1254
+ * created with; `selection` is set for inline comments only.
1255
+ */
1256
+ path?: {
1257
+ field: string;
1258
+ selection?: CollaborationCommentSelection;
1259
+ };
1260
+ };
1261
+ /**
1262
+ * Copy of the commented content, as it looked when the comment was created.
1263
+ * Set for inline comments only, and holds just the selected fragment of each
1264
+ * Portable Text block the selection spans.
1265
+ */
1266
+ contentSnapshot?: CollaborationCommentPortableTextBlock[];
1267
+ status: CollaborationCommentStatus;
1268
+ /** Set when the message has been updated after creation */
1269
+ lastEditedAt?: string;
1270
+ }
1271
+ /**
1272
+ * Inline text selection within a Portable Text field.
1273
+ * Each endpoint pairs the `_key` of a Portable Text block with a character
1274
+ * offset into that block's plain text.
1275
+ *
1276
+ * @alpha
1277
+ */
1278
+ interface CollaborationCommentRange {
1279
+ start: {
1280
+ _key: string;
1281
+ offset: number;
1282
+ };
1283
+ end: {
1284
+ _key: string;
1285
+ offset: number;
1286
+ };
1287
+ }
1288
+ /**
1289
+ * Target for a top-level comment. Inline selections require both `path` and
1290
+ * `range`; field-level comments may set `path` alone.
1291
+ *
1292
+ * The created comment stores this in a different shape: `path` becomes
1293
+ * `target.path.field`, and `range` is resolved against the document into
1294
+ * `target.path.selection` and `contentSnapshot` rather than being stored.
1295
+ *
1296
+ * @alpha
1297
+ */
1298
+ type CollaborationCommentTarget = {
1299
+ documentId: string;
1300
+ documentType: string;
1301
+ documentRevisionId?: string;
1302
+ } & ({
1303
+ /** Path to the field containing the inline comment selection */
1304
+ path: string;
1305
+ range: CollaborationCommentRange;
1306
+ } | {
1307
+ /** Path to the commented field */
1308
+ path?: string;
1309
+ range?: never;
1310
+ });
1311
+ /**
1312
+ * Comment to create with `collaboration.comments.create`.
1313
+ *
1314
+ * A top-level comment requires `target`; a reply requires `parentCommentId` (never both).
1315
+ * Replies inherit `target`, `status`, and `threadId` from the parent comment.
1316
+ *
1317
+ * ### Examples
1318
+ *
1319
+ * #### Top-level comment
1320
+ * ```ts
1321
+ * // `message` is an array of Portable Text blocks
1322
+ * await client.collaboration.comments.create({
1323
+ * message,
1324
+ * target: {documentId: 'doc-1', documentType: 'article'},
1325
+ * })
1326
+ * ```
1327
+ *
1328
+ * #### Reply
1329
+ * ```ts
1330
+ * await client.collaboration.comments.create({
1331
+ * message,
1332
+ * parentCommentId: 'comment-1',
1333
+ * })
1334
+ * ```
1335
+ *
1336
+ * @alpha
1337
+ */
1338
+ type CollaborationCommentCreate = {
1339
+ /** Provide to control the ID of the created comment document */
1340
+ _id?: string;
1341
+ message: CollaborationCommentMessage;
1342
+ context?: Record<string, unknown>;
1343
+ } & ({
1344
+ target: CollaborationCommentTarget;
1345
+ threadId?: string;
1346
+ parentCommentId?: never;
1347
+ } | {
1348
+ parentCommentId: string;
1349
+ target?: never;
1350
+ threadId?: never;
1351
+ });
1352
+ /**
1353
+ * Fields that can be updated on an existing comment.
1354
+ *
1355
+ * @alpha
1356
+ */
1357
+ interface CollaborationCommentUpdate {
1358
+ /** Replaces the current message */
1359
+ message?: CollaborationCommentMessage;
1360
+ /** Cascades to the comment's replies */
1361
+ status?: CollaborationCommentStatus;
1362
+ /**
1363
+ * Re-anchors the comment within the field and source document it already
1364
+ * targets. Pass `null` to remove the selection and leave a field-level
1365
+ * comment.
1366
+ */
1367
+ range?: CollaborationCommentRange | null;
1368
+ }
1369
+ /**
1370
+ * Comments on the configured organization resource.
1371
+ *
1372
+ * Requires `collaboration.organizationId`, plus either `resource` or `projectId` and `dataset`.
1373
+ *
1374
+ * @alpha
1375
+ */
1376
+ declare class ObservableCollaborationCommentsClient {
1377
+ #private;
1378
+ constructor(client: ObservableSanityClient$1, httpRequest: HttpRequest);
1379
+ /**
1380
+ * Create a comment or reply on the configured resource.
1381
+ *
1382
+ * A top-level comment requires `target`; a reply requires `parentCommentId` (never both).
1383
+ * Replies inherit `target`, `status`, and `threadId` from the parent comment.
1384
+ *
1385
+ * @param body - Comment to create
1386
+ * @param options - Optional request options
1387
+ * @returns The created comment
1388
+ */
1389
+ create(body: CollaborationCommentCreate, options?: CollaborationCommentsWriteOptions): Observable<CollaborationCommentDocument>;
1390
+ /**
1391
+ * Update an existing comment.
1392
+ *
1393
+ * Updating `status` cascades to the comment's replies.
1394
+ *
1395
+ * @param id - Comment document ID
1396
+ * @param body - Fields to update
1397
+ * @param options - Optional request options
1398
+ * @returns The updated comment
1399
+ */
1400
+ update(id: string, body: CollaborationCommentUpdate, options?: CollaborationCommentsWriteOptions): Observable<CollaborationCommentDocument>;
1401
+ /**
1402
+ * Delete a comment and its replies.
1403
+ *
1404
+ * @param id - Comment document ID
1405
+ * @param options - Optional request options
1406
+ * @returns Mutation result, where `documentIds` covers the comment and every deleted reply
1407
+ */
1408
+ delete(id: string, options?: CollaborationCommentsWriteOptions): Observable<MultipleMutationResult>;
1409
+ /**
1410
+ * Add the current user's reaction to a comment.
1411
+ *
1412
+ * @param id - Comment document ID
1413
+ * @param shortName - Emoji short name, for example `:+1:`
1414
+ * @param options - Optional request options
1415
+ * @returns The comment, with the reaction applied
1416
+ */
1417
+ addReaction(id: string, shortName: CollaborationCommentReactionShortName, options?: CollaborationCommentsWriteOptions): Observable<CollaborationCommentDocument>;
1418
+ /**
1419
+ * Remove the current user's reaction from a comment.
1420
+ *
1421
+ * @param id - Comment document ID
1422
+ * @param shortName - Emoji short name, for example `:+1:`
1423
+ * @param options - Optional request options
1424
+ * @returns The comment, with the reaction removed
1425
+ */
1426
+ removeReaction(id: string, shortName: CollaborationCommentReactionShortName, options?: CollaborationCommentsWriteOptions): Observable<CollaborationCommentDocument>;
1427
+ /**
1428
+ * Build the global document reference used by `target.document._ref`, for use in
1429
+ * queries and listeners.
1430
+ *
1431
+ * The reference is built from the configured `resource` and the published ID of
1432
+ * the given document ID, since comment references always use published IDs.
1433
+ *
1434
+ * @example
1435
+ * ```ts
1436
+ * client.collaboration.comments.listen(
1437
+ * '*[_type == "sanity.comment" && target.document._ref == $ref]',
1438
+ * {ref: client.collaboration.comments.getTargetDocumentRef('doc-1')},
1439
+ * )
1440
+ * ```
1441
+ *
1442
+ * @param documentId - Document ID, in published, draft or version form
1443
+ * @returns Global document reference, of the form `resourceType:resourceId:documentId`
1444
+ */
1445
+ getTargetDocumentRef(documentId: string): CollaborationCommentDocument['target']['document']['_ref'];
1446
+ /**
1447
+ * Fetch comments on the configured resource.
1448
+ *
1449
+ * Takes the same `query` and `params` as `client.fetch`, and switches from a
1450
+ * GET to a POST for queries too large for the request URL in the same way,
1451
+ * but queries the comments endpoint, which accepts none of the query options
1452
+ * `client.fetch` does (`perspective`, `useCdn`, `filterResponse`,
1453
+ * `resultSourceMap`, stega).
1454
+ *
1455
+ * The query runs against the organization store, which is not scoped to
1456
+ * comments, so filter on `_type == "sanity.comment"`.
1457
+ *
1458
+ * @param query - GROQ-query to perform
1459
+ * @param params - Optional query parameters
1460
+ * @param options - Optional request options
1461
+ */
1462
+ fetch<R = unknown>(query: string, params?: QueryParams, options?: CollaborationCommentsRequestOptions): Observable<R>;
1463
+ /**
1464
+ * Listen for changes to comments on the configured resource.
1465
+ *
1466
+ * Mirrors `client.listen(query, params)`, and emits mutation events.
1467
+ *
1468
+ * @param query - GROQ-filter to listen to changes for
1469
+ * @param params - Optional query parameters
1470
+ */
1471
+ listen(query: string, params?: QueryParams): Observable<MutationEvent<CollaborationCommentDocument>>;
1472
+ /**
1473
+ * Listen for changes to comments on the configured resource.
1474
+ *
1475
+ * Mirrors `client.listen(query, params, options)`.
1476
+ *
1477
+ * @param query - GROQ-filter to listen to changes for
1478
+ * @param params - Optional query parameters
1479
+ * @param options - The same listener options `client.listen` takes, forwarded
1480
+ * to the organization store's listener
1481
+ */
1482
+ listen<Opts extends CollaborationCommentsListenOptions>(query: string, params: QueryParams | undefined, options: Opts): Observable<ListenEventFromOptions<CollaborationCommentDocument, Opts>>;
1483
+ }
1484
+ /**
1485
+ * Comments on the configured organization resource.
1486
+ *
1487
+ * Requires `collaboration.organizationId`, plus either `resource` or `projectId` and `dataset`.
1488
+ *
1489
+ * @alpha
1490
+ */
1491
+ declare class CollaborationCommentsClient {
1492
+ #private;
1493
+ constructor(client: SanityClient$1, httpRequest: HttpRequest);
1494
+ /**
1495
+ * Create a comment or reply on the configured resource.
1496
+ *
1497
+ * A top-level comment requires `target`; a reply requires `parentCommentId` (never both).
1498
+ * Replies inherit `target`, `status`, and `threadId` from the parent comment.
1499
+ *
1500
+ * @param body - Comment to create
1501
+ * @param options - Optional request options
1502
+ * @returns The created comment
1503
+ */
1504
+ create(body: CollaborationCommentCreate, options?: CollaborationCommentsWriteOptions): Promise<CollaborationCommentDocument>;
1505
+ /**
1506
+ * Update an existing comment.
1507
+ *
1508
+ * Updating `status` cascades to the comment's replies.
1509
+ *
1510
+ * @param id - Comment document ID
1511
+ * @param body - Fields to update
1512
+ * @param options - Optional request options
1513
+ * @returns The updated comment
1514
+ */
1515
+ update(id: string, body: CollaborationCommentUpdate, options?: CollaborationCommentsWriteOptions): Promise<CollaborationCommentDocument>;
1516
+ /**
1517
+ * Delete a comment and its replies.
1518
+ *
1519
+ * @param id - Comment document ID
1520
+ * @param options - Optional request options
1521
+ * @returns Mutation result, where `documentIds` covers the comment and every deleted reply
1522
+ */
1523
+ delete(id: string, options?: CollaborationCommentsWriteOptions): Promise<MultipleMutationResult>;
1524
+ /**
1525
+ * Add the current user's reaction to a comment.
1526
+ *
1527
+ * @param id - Comment document ID
1528
+ * @param shortName - Emoji short name, for example `:+1:`
1529
+ * @param options - Optional request options
1530
+ * @returns The comment, with the reaction applied
1531
+ */
1532
+ addReaction(id: string, shortName: CollaborationCommentReactionShortName, options?: CollaborationCommentsWriteOptions): Promise<CollaborationCommentDocument>;
1533
+ /**
1534
+ * Remove the current user's reaction from a comment.
1535
+ *
1536
+ * @param id - Comment document ID
1537
+ * @param shortName - Emoji short name, for example `:+1:`
1538
+ * @param options - Optional request options
1539
+ * @returns The comment, with the reaction removed
1540
+ */
1541
+ removeReaction(id: string, shortName: CollaborationCommentReactionShortName, options?: CollaborationCommentsWriteOptions): Promise<CollaborationCommentDocument>;
1542
+ /**
1543
+ * Build the global document reference used by `target.document._ref`, for use in
1544
+ * queries and listeners.
1545
+ *
1546
+ * The reference is built from the configured `resource` and the published ID of
1547
+ * the given document ID, since comment references always use published IDs.
1548
+ *
1549
+ * @example
1550
+ * ```ts
1551
+ * const comments = await client.collaboration.comments.fetch(
1552
+ * '*[_type == "sanity.comment" && target.document._ref == $ref]',
1553
+ * {ref: client.collaboration.comments.getTargetDocumentRef('doc-1')},
1554
+ * )
1555
+ * ```
1556
+ *
1557
+ * @param documentId - Document ID, in published, draft or version form
1558
+ * @returns Global document reference, of the form `resourceType:resourceId:documentId`
1559
+ */
1560
+ getTargetDocumentRef(documentId: string): CollaborationCommentDocument['target']['document']['_ref'];
1561
+ /**
1562
+ * Fetch comments on the configured resource.
1563
+ *
1564
+ * Takes the same `query` and `params` as `client.fetch`, and switches from a
1565
+ * GET to a POST for queries too large for the request URL in the same way,
1566
+ * but queries the comments endpoint, which accepts none of the query options
1567
+ * `client.fetch` does (`perspective`, `useCdn`, `filterResponse`,
1568
+ * `resultSourceMap`, stega).
1569
+ *
1570
+ * The query runs against the organization store, which is not scoped to
1571
+ * comments, so filter on `_type == "sanity.comment"`.
1572
+ *
1573
+ * @param query - GROQ-query to perform
1574
+ * @param params - Optional query parameters
1575
+ * @param options - Optional request options
1576
+ */
1577
+ fetch<R = unknown>(query: string, params?: QueryParams, options?: CollaborationCommentsRequestOptions): Promise<R>;
1578
+ /**
1579
+ * Listen for changes to comments on the configured resource.
1580
+ *
1581
+ * Mirrors `client.listen(query, params)`, and emits mutation events.
1582
+ *
1583
+ * @param query - GROQ-filter to listen to changes for
1584
+ * @param params - Optional query parameters
1585
+ */
1586
+ listen(query: string, params?: QueryParams): Observable<MutationEvent<CollaborationCommentDocument>>;
1587
+ /**
1588
+ * Listen for changes to comments on the configured resource.
1589
+ *
1590
+ * Mirrors `client.listen(query, params, options)`.
1591
+ *
1592
+ * @param query - GROQ-filter to listen to changes for
1593
+ * @param params - Optional query parameters
1594
+ * @param options - The same listener options `client.listen` takes, forwarded
1595
+ * to the organization store's listener
1596
+ */
1597
+ listen<Opts extends CollaborationCommentsListenOptions>(query: string, params: QueryParams | undefined, options: Opts): Observable<ListenEventFromOptions<CollaborationCommentDocument, Opts>>;
1598
+ }
1129
1599
  /**
1130
1600
  * @public
1131
1601
  */
@@ -1593,6 +2063,72 @@ declare class DatasetsClient {
1593
2063
  */
1594
2064
  editEmbeddingsSettings(name: string, settings: EmbeddingsSettingsBody): Promise<void>;
1595
2065
  }
2066
+ /** @public */
2067
+ interface InvokeFunctionEvent {
2068
+ /**
2069
+ * Payload handed to the function.
2070
+ * The function receives it as `event.data`.
2071
+ */
2072
+ data?: unknown;
2073
+ }
2074
+ /** @public */
2075
+ interface InvokeFunctionRequest {
2076
+ event?: InvokeFunctionEvent;
2077
+ /**
2078
+ * Stack to resolve the function name against.
2079
+ * Overrides `stackId` from the client config.
2080
+ */
2081
+ stackId?: string;
2082
+ /**
2083
+ * Organization owning the stack.
2084
+ */
2085
+ organizationId?: string;
2086
+ /**
2087
+ * Milliseconds to wait for the function to return.
2088
+ */
2089
+ timeout?: number;
2090
+ /** Abort the invocation. */
2091
+ signal?: AbortSignal;
2092
+ }
2093
+ /** @public */
2094
+ declare class ObservableFunctionsClient {
2095
+ #private;
2096
+ constructor(client: ObservableSanityClient$1, httpRequest: HttpRequest);
2097
+ /**
2098
+ * Invoke a deployed function by its blueprint name.
2099
+ *
2100
+ * The name is resolved within the stack given by `stackId` on the request or
2101
+ * the client config. Passes the function's return value once it finishes.
2102
+ *
2103
+ * @param functionName - name of the function, as declared in the blueprint
2104
+ * @param request - payload and request options
2105
+ */
2106
+ invoke<R = unknown>(functionName: string, request?: InvokeFunctionRequest): Observable<R | undefined>;
2107
+ }
2108
+ /** @public */
2109
+ declare class FunctionsClient {
2110
+ #private;
2111
+ constructor(client: SanityClient$1, httpRequest: HttpRequest);
2112
+ /**
2113
+ * Invoke a deployed function by its blueprint name.
2114
+ *
2115
+ * The name is resolved within the stack given by `stackId` on the request or
2116
+ * the client config, which costs one extra request per call. Rejects if the
2117
+ * stack has no function by that name, or if the name resolves to anything
2118
+ * other than a `sanity.function.pubsub` function.
2119
+ *
2120
+ * The lookup is scoped to `projectId`, or to `organizationId` when one is set
2121
+ * for a stack deployed at organization scope.
2122
+ *
2123
+ * The request stays open until the function finishes, and resolves with its
2124
+ * return value, or `undefined` if it returns nothing. Long-running functions
2125
+ * may need an explicit `timeout`.
2126
+ *
2127
+ * @param functionName - name of the function, as declared in the blueprint
2128
+ * @param request - payload and request options
2129
+ */
2130
+ invoke<R = unknown>(functionName: string, request?: InvokeFunctionRequest): Promise<R | undefined>;
2131
+ }
1596
2132
  /** @internal */
1597
2133
  declare class ObservableMediaLibraryVideoClient {
1598
2134
  #private;
@@ -2187,6 +2723,11 @@ declare class ObservableSanityClient$1 {
2187
2723
  agent: {
2188
2724
  action: ObservableAgentsActionClient;
2189
2725
  };
2726
+ collaboration: {
2727
+ /** @alpha */
2728
+ comments: ObservableCollaborationCommentsClient;
2729
+ };
2730
+ functions: ObservableFunctionsClient;
2190
2731
  releases: ObservableReleasesClient;
2191
2732
  /**
2192
2733
  * Instance properties
@@ -2526,12 +3067,12 @@ declare class ObservableSanityClient$1 {
2526
3067
  delete(id: string, options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>;
2527
3068
  /**
2528
3069
  * Deletes a document with the given document ID.
2529
- * Returns an observable that resolves to the deleted document.
3070
+ * Returns an observable that resolves to a mutation result object containing the deleted document ID.
2530
3071
  *
2531
3072
  * @param id - Document ID to delete
2532
3073
  * @param options - Options for the mutation
2533
3074
  */
2534
- delete<R extends Record<string, Any$1> = Record<string, Any$1>>(id: string, options?: BaseMutationOptions): Observable<SanityDocument$1<R>>;
3075
+ delete(id: string, options?: BaseMutationOptions): Observable<MultipleMutationResult>;
2535
3076
  /**
2536
3077
  * Deletes one or more documents matching the given query or document ID.
2537
3078
  * Returns an observable that resolves to first deleted document.
@@ -2566,12 +3107,12 @@ declare class ObservableSanityClient$1 {
2566
3107
  delete(selection: MutationSelection, options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>;
2567
3108
  /**
2568
3109
  * Deletes one or more documents matching the given query or document ID.
2569
- * Returns an observable that resolves to first deleted document.
3110
+ * Returns an observable that resolves to a mutation result object containing the document IDs that were deleted.
2570
3111
  *
2571
3112
  * @param selection - An object with either an `id` or `query` key defining what to delete
2572
3113
  * @param options - Options for the mutation
2573
3114
  */
2574
- delete<R extends Record<string, Any$1> = Record<string, Any$1>>(selection: MutationSelection, options?: BaseMutationOptions): Observable<SanityDocument$1<R>>;
3115
+ delete(selection: MutationSelection, options?: BaseMutationOptions): Observable<MultipleMutationResult>;
2575
3116
  /**
2576
3117
  * @public
2577
3118
  *
@@ -2738,12 +3279,12 @@ declare class ObservableSanityClient$1 {
2738
3279
  mutate<R extends Record<string, Any$1> = Record<string, Any$1>>(operations: Mutation<R>[] | ObservablePatch | ObservableTransaction, options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>;
2739
3280
  /**
2740
3281
  * Perform mutation operations against the configured dataset
2741
- * Returns an observable that resolves to the first mutated document.
3282
+ * Returns an observable that resolves to a mutation result object containing the mutated document IDs.
2742
3283
  *
2743
3284
  * @param operations - Mutation operations to execute
2744
3285
  * @param options - Mutation options
2745
3286
  */
2746
- mutate<R extends Record<string, Any$1> = Record<string, Any$1>>(operations: Mutation<R>[] | ObservablePatch | ObservableTransaction, options?: BaseMutationOptions): Observable<SanityDocument$1<R>>;
3287
+ mutate<R extends Record<string, Any$1> = Record<string, Any$1>>(operations: Mutation<R>[] | ObservablePatch | ObservableTransaction, options?: BaseMutationOptions): Observable<MultipleMutationResult>;
2747
3288
  /**
2748
3289
  * Create a new buildable patch of operations to perform
2749
3290
  *
@@ -2816,6 +3357,11 @@ declare class SanityClient$1 {
2816
3357
  agent: {
2817
3358
  action: AgentActionsClient;
2818
3359
  };
3360
+ collaboration: {
3361
+ /** @alpha */
3362
+ comments: CollaborationCommentsClient;
3363
+ };
3364
+ functions: FunctionsClient;
2819
3365
  releases: ReleasesClient;
2820
3366
  /**
2821
3367
  * Observable version of the Sanity client, with the same configuration as the promise-based one
@@ -3148,12 +3694,12 @@ declare class SanityClient$1 {
3148
3694
  delete(id: string, options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>;
3149
3695
  /**
3150
3696
  * Deletes a document with the given document ID.
3151
- * Returns a promise that resolves to the deleted document.
3697
+ * Returns a promise that resolves to a mutation result object containing the deleted document ID.
3152
3698
  *
3153
3699
  * @param id - Document ID to delete
3154
3700
  * @param options - Options for the mutation
3155
3701
  */
3156
- delete<R extends Record<string, Any$1> = Record<string, Any$1>>(id: string, options?: BaseMutationOptions): Promise<SanityDocument$1<R>>;
3702
+ delete(id: string, options?: BaseMutationOptions): Promise<MultipleMutationResult>;
3157
3703
  /**
3158
3704
  * Deletes one or more documents matching the given query or document ID.
3159
3705
  * Returns a promise that resolves to first deleted document.
@@ -3188,12 +3734,12 @@ declare class SanityClient$1 {
3188
3734
  delete(selection: MutationSelection, options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>;
3189
3735
  /**
3190
3736
  * Deletes one or more documents matching the given query or document ID.
3191
- * Returns a promise that resolves to first deleted document.
3737
+ * Returns a promise that resolves to a mutation result object containing the document IDs that were deleted.
3192
3738
  *
3193
3739
  * @param selection - An object with either an `id` or `query` key defining what to delete
3194
3740
  * @param options - Options for the mutation
3195
3741
  */
3196
- delete<R extends Record<string, Any$1> = Record<string, Any$1>>(selection: MutationSelection, options?: BaseMutationOptions): Promise<SanityDocument$1<R>>;
3742
+ delete(selection: MutationSelection, options?: BaseMutationOptions): Promise<MultipleMutationResult>;
3197
3743
  /**
3198
3744
  * @public
3199
3745
  *
@@ -3360,12 +3906,12 @@ declare class SanityClient$1 {
3360
3906
  mutate<R extends Record<string, Any$1> = Record<string, Any$1>>(operations: Mutation<R>[] | Patch | Transaction, options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>;
3361
3907
  /**
3362
3908
  * Perform mutation operations against the configured dataset
3363
- * Returns a promise that resolves to the first mutated document.
3909
+ * Returns a promise that resolves to a mutation result object containing the mutated document IDs.
3364
3910
  *
3365
3911
  * @param operations - Mutation operations to execute
3366
3912
  * @param options - Mutation options
3367
3913
  */
3368
- mutate<R extends Record<string, Any$1> = Record<string, Any$1>>(operations: Mutation<R>[] | Patch | Transaction, options?: BaseMutationOptions): Promise<SanityDocument$1<R>>;
3914
+ mutate<R extends Record<string, Any$1> = Record<string, Any$1>>(operations: Mutation<R>[] | Patch | Transaction, options?: BaseMutationOptions): Promise<MultipleMutationResult>;
3369
3915
  /**
3370
3916
  * Create a new buildable patch of operations to perform
3371
3917
  *
@@ -3687,8 +4233,9 @@ type GenerateAsyncInstruction<T extends Record<string, Any$1> = Record<string, A
3687
4233
  /** @beta */
3688
4234
  type GenerateInstruction<T extends Record<string, Any$1> = Record<string, Any$1>> = GenerateSyncInstruction<T> | GenerateAsyncInstruction<T>;
3689
4235
  /**
3690
- * Low-level requester returned by `defineHttpRequest`. Surfaces as
3691
- * `client.config().requester` and as the named `requester` export.
4236
+ * Low-level requester returned by `defineRequester(...).observable`.
4237
+ * Surfaces as `client.config().requester` and as the named `requester`
4238
+ * export.
3692
4239
  *
3693
4240
  * Defined locally rather than imported from `http/request` so api-extractor
3694
4241
  * inlines it into the bundled `.d.ts` instead of emitting a relative import
@@ -3710,7 +4257,7 @@ declare global {
3710
4257
  /** @public */
3711
4258
  type UploadBody = File | Blob | Buffer | NodeJS.ReadableStream;
3712
4259
  /** @public */
3713
- interface RequestOptions {
4260
+ interface RequestOptions$1 {
3714
4261
  timeout?: number;
3715
4262
  token?: string;
3716
4263
  tag?: string;
@@ -3720,6 +4267,25 @@ interface RequestOptions {
3720
4267
  body?: Any$1;
3721
4268
  signal?: AbortSignal;
3722
4269
  }
4270
+ /**
4271
+ * The fully resolved request passed to a {@link RequestHandler}.
4272
+ *
4273
+ * @public
4274
+ */
4275
+ type RequestHandlerOptions = RequestOptions;
4276
+ /**
4277
+ * Intercepts a client request around the normal HTTP pipeline.
4278
+ *
4279
+ * Call `next(request)` to execute the request. It resolves to the parsed
4280
+ * response body and rejects with the same errors the client normally exposes,
4281
+ * including {@link ClientError} and {@link ServerError}. A handler can modify
4282
+ * the request, retry it by calling `next` again, or return a synthetic body.
4283
+ *
4284
+ * Browser asset uploads and server-sent event connections do not use this handler.
4285
+ *
4286
+ * @public
4287
+ */
4288
+ type RequestHandler = (request: RequestHandlerOptions, next: (request: RequestHandlerOptions) => Promise<unknown>) => Promise<unknown>;
3723
4289
  /**
3724
4290
  * @public
3725
4291
  * @deprecated – The `r`-prefix is not required, use `string` instead
@@ -3812,6 +4378,19 @@ interface ClientConfig$1 {
3812
4378
  * Optional request tag prefix for all request tags
3813
4379
  */
3814
4380
  requestTagPrefix?: string;
4381
+ /**
4382
+ * Intercepts requests after the client has resolved their URL, headers, and
4383
+ * transport options. The handler wraps the normal client pipeline, so errors
4384
+ * from `next` are already converted to {@link ClientError} or
4385
+ * {@link ServerError}.
4386
+ *
4387
+ * A handler supplied through `withConfig()` replaces the current handler.
4388
+ * To compose handlers, read the current handler from `client.config()` and
4389
+ * call it from the replacement.
4390
+ *
4391
+ * Browser asset uploads and server-sent event connections are not intercepted.
4392
+ */
4393
+ requestHandler?: RequestHandler;
3815
4394
  /**
3816
4395
  * Optional default headers to include with all requests
3817
4396
  *
@@ -3901,6 +4480,25 @@ interface ClientConfig$1 {
3901
4480
  * Lineage token for recursion control
3902
4481
  */
3903
4482
  lineage?: string;
4483
+ /**
4484
+ * ID of the blueprints stack that `functions.invoke()` resolves function
4485
+ * names against. Function names are unique within a stack
4486
+ */
4487
+ stackId?: string;
4488
+ /**
4489
+ * ID of the organization owning the blueprints stack
4490
+ */
4491
+ organizationId?: string;
4492
+ /**
4493
+ * Organization-scoped configuration for collaboration APIs.
4494
+ *
4495
+ * Currently this is used by `collaboration.comments` methods.
4496
+ *
4497
+ * @alpha
4498
+ */
4499
+ collaboration?: {
4500
+ organizationId?: string;
4501
+ };
3904
4502
  }
3905
4503
  /** @public */
3906
4504
  interface InitializedClientConfig$1 extends ClientConfig$1 {
@@ -4095,7 +4693,7 @@ interface ErrorProps {
4095
4693
  * @internal
4096
4694
  */
4097
4695
  type HttpRequest = {
4098
- (options: Any$1): Promise<unknown>;
4696
+ (options: Any$1, requestHandler?: RequestHandler): Promise<unknown>;
4099
4697
  };
4100
4698
  /**
4101
4699
  * Target URL for a request. Exactly one of `url` or the deprecated `uri` alias
@@ -4114,7 +4712,7 @@ type RequestUrlOptions = {
4114
4712
  url?: never;
4115
4713
  };
4116
4714
  /** @internal */
4117
- type RequestObservableOptions = RequestUrlOptions & Omit<RequestOptions, 'url'> & {
4715
+ type RequestObservableOptions = RequestUrlOptions & Omit<RequestOptions$1, 'url'> & {
4118
4716
  canUseCdn?: boolean;
4119
4717
  useCdn?: boolean;
4120
4718
  tag?: string;
@@ -4375,10 +4973,20 @@ type Mutation<R extends Record<string, Any$1> = Record<string, Any$1>> = {
4375
4973
  };
4376
4974
  /** @public */
4377
4975
  type ReleaseAction = CreateReleaseAction | EditReleaseAction | PublishReleaseAction | ArchiveReleaseAction | UnarchiveReleaseAction | ScheduleReleaseAction | UnscheduleReleaseAction | DeleteReleaseAction | ImportReleaseAction;
4976
+ /**
4977
+ * @public
4978
+ * @beta
4979
+ */
4980
+ type VariantDefinitionAction = CreateVariantDefinitionAction | EditVariantDefinitionAction | DeleteVariantDefinitionAction;
4378
4981
  /** @public */
4379
4982
  type VersionAction = CreateVersionAction | DiscardVersionAction | ReplaceVersionAction | UnpublishVersionAction;
4983
+ /**
4984
+ * @public
4985
+ * @beta
4986
+ */
4987
+ type VariantAction = CreateVariantAction | EditVariantAction | DeleteVariantAction | PublishVariantAction | UnpublishVariantAction;
4380
4988
  /** @public */
4381
- type Action = CreateAction | ReplaceDraftAction | EditAction | DeleteAction | DiscardAction | PublishAction | UnpublishAction | VersionAction | ReleaseAction;
4989
+ type Action = CreateAction | ReplaceDraftAction | EditAction | DeleteAction | DiscardAction | PublishAction | UnpublishAction | VersionAction | VariantAction | ReleaseAction | VariantDefinitionAction;
4382
4990
  /** @public */
4383
4991
  type ImportReleaseAction = {
4384
4992
  actionType: 'sanity.action.release.import';
@@ -4517,6 +5125,245 @@ interface UnpublishVersionAction {
4517
5125
  versionId: string;
4518
5126
  publishedId: string;
4519
5127
  }
5128
+ /**
5129
+ * Creates a variant of a document, either by supplying the full document
5130
+ * content, or the base ID of a document to copy.
5131
+ *
5132
+ * @public
5133
+ * @beta
5134
+ */
5135
+ type CreateVariantAction = {
5136
+ actionType: 'sanity.action.document.variant.create';
5137
+ /**
5138
+ * ID of the document group to create a variant in. Must be a published
5139
+ * document ID, without a `drafts.` or `versions.` prefix.
5140
+ */
5141
+ publishedId: string;
5142
+ /**
5143
+ * Name of the variant definition this document belongs to, as in
5144
+ * `_.variants.{variantName}`. Must be a bare name, not a full document ID.
5145
+ */
5146
+ variantId: string;
5147
+ /**
5148
+ * Source bundle: `'drafts'`, or a release id.
5149
+ *
5150
+ * Defaults to the published bundle.
5151
+ */
5152
+ bundleId?: 'drafts' | (string & {});
5153
+ } & ({
5154
+ /**
5155
+ * The full document content. Requires a `_type` property.
5156
+ */
5157
+ document: SanityDocumentStub;
5158
+ baseId?: never;
5159
+ ifBaseRevisionId?: never;
5160
+ } | {
5161
+ /**
5162
+ * ID of an existing document to copy the content from.
5163
+ */
5164
+ baseId: string;
5165
+ /**
5166
+ * When set, the action fails unless the current revision of the base
5167
+ * document matches this value.
5168
+ */
5169
+ ifBaseRevisionId?: string;
5170
+ document?: never;
5171
+ });
5172
+ /**
5173
+ * Modifies a variant version of a document by applying a patch.
5174
+ *
5175
+ * If no such variant document exists it is first created, by copying the
5176
+ * variant's published sibling, or the published document if the variant was
5177
+ * never published.
5178
+ *
5179
+ * @public
5180
+ * @beta
5181
+ */
5182
+ interface EditVariantAction {
5183
+ actionType: 'sanity.action.document.variant.edit';
5184
+ /**
5185
+ * ID of the document group the variant belongs to. Must be a published
5186
+ * document ID, without a `drafts.` or `versions.` prefix.
5187
+ */
5188
+ publishedId: string;
5189
+ /**
5190
+ * Name of the variant definition this document belongs to, as in
5191
+ * `_.variants.{variantName}`. Must be a bare name, not a full document ID.
5192
+ */
5193
+ variantId: string;
5194
+ /**
5195
+ * Source bundle: `'drafts'`, or a release id.
5196
+ *
5197
+ * Defaults to the published bundle.
5198
+ */
5199
+ bundleId?: 'drafts' | (string & {});
5200
+ /**
5201
+ * Patch operations to apply.
5202
+ */
5203
+ patch: PatchOperations;
5204
+ }
5205
+ /**
5206
+ * Deletes a variant of a document.
5207
+ *
5208
+ * @public
5209
+ * @beta
5210
+ */
5211
+ interface DeleteVariantAction {
5212
+ actionType: 'sanity.action.document.variant.delete';
5213
+ /**
5214
+ * ID of the document group the variant belongs to. Must be a published
5215
+ * document ID, without a `drafts.` or `versions.` prefix.
5216
+ */
5217
+ publishedId: string;
5218
+ /**
5219
+ * Name of the variant definition this document belongs to, as in
5220
+ * `_.variants.{variantName}`. Must be a bare name, not a full document ID.
5221
+ */
5222
+ variantId: string;
5223
+ /**
5224
+ * Source bundle: `'drafts'`, or a release id.
5225
+ *
5226
+ * Defaults to the published bundle.
5227
+ */
5228
+ bundleId?: 'drafts' | (string & {});
5229
+ /**
5230
+ * Delete document history.
5231
+ */
5232
+ purge?: boolean;
5233
+ }
5234
+ /**
5235
+ * Publishes a variant version of a document, replacing the published variant
5236
+ * and removing the source variant document.
5237
+ *
5238
+ * @public
5239
+ * @beta
5240
+ */
5241
+ interface PublishVariantAction {
5242
+ actionType: 'sanity.action.document.variant.publish';
5243
+ /**
5244
+ * ID of the document group the variant belongs to. Must be a published
5245
+ * document ID, without a `drafts.` or `versions.` prefix.
5246
+ */
5247
+ publishedId: string;
5248
+ /**
5249
+ * Name of the variant definition this document belongs to, as in
5250
+ * `_.variants.{variantName}`. Must be a bare name, not a full document ID.
5251
+ */
5252
+ variantId: string;
5253
+ /**
5254
+ * Bundle to publish from: `'drafts'`, or a release id.
5255
+ */
5256
+ bundleId: 'drafts' | (string & {});
5257
+ /**
5258
+ * When set, publishing fails unless the current revision of the source
5259
+ * variant document matches this value.
5260
+ */
5261
+ ifVersionRevisionId?: string;
5262
+ /**
5263
+ * When set, publishing fails unless the current revision of the published
5264
+ * variant document matches this value.
5265
+ */
5266
+ ifPublishedVariantRevisionId?: string;
5267
+ }
5268
+ /**
5269
+ * Unpublishes a variant version of a document.
5270
+ *
5271
+ * By default the published variant is removed and preserved as a draft
5272
+ * variant. When a release id is given as the `bundleId`, the deletion is
5273
+ * instead staged in that release, and takes effect when it is published.
5274
+ *
5275
+ * @public
5276
+ * @beta
5277
+ */
5278
+ interface UnpublishVariantAction {
5279
+ actionType: 'sanity.action.document.variant.unpublish';
5280
+ /**
5281
+ * ID of the document group the variant belongs to. Must be a published
5282
+ * document ID, without a `drafts.` or `versions.` prefix.
5283
+ */
5284
+ publishedId: string;
5285
+ /**
5286
+ * Name of the variant definition this document belongs to, as in
5287
+ * `_.variants.{variantName}`. Must be a bare name, not a full document ID.
5288
+ */
5289
+ variantId: string;
5290
+ /**
5291
+ * The content release in which to stage the unpublish.
5292
+ *
5293
+ * By default, the currently published document is unpublished immediately.
5294
+ */
5295
+ bundleId?: string;
5296
+ }
5297
+ /**
5298
+ * Creates a new `system.variant` definition document.
5299
+ *
5300
+ * @public
5301
+ * @beta
5302
+ */
5303
+ interface CreateVariantDefinitionAction {
5304
+ actionType: 'sanity.action.variant.definition.create';
5305
+ /**
5306
+ * Name of the variant definition to create, as in
5307
+ * `_.variants.{variantName}`. Must be a bare name, not a full document ID.
5308
+ */
5309
+ variantId: string;
5310
+ /**
5311
+ * Conditions used to select this variant.
5312
+ */
5313
+ conditions?: ClientVariantConditions;
5314
+ /**
5315
+ * Selection priority. Higher values are preferred when multiple variants
5316
+ * match.
5317
+ *
5318
+ * Defaults to `0`.
5319
+ */
5320
+ priority?: number;
5321
+ metadata?: Record<string, Any$1>;
5322
+ }
5323
+ /**
5324
+ * Edits an existing variant definition.
5325
+ *
5326
+ * @public
5327
+ * @beta
5328
+ */
5329
+ interface EditVariantDefinitionAction {
5330
+ actionType: 'sanity.action.variant.definition.edit';
5331
+ /**
5332
+ * Name of the variant definition to edit, as in `_.variants.{variantName}`.
5333
+ * Must be a bare name, not a full document ID.
5334
+ */
5335
+ variantId: string;
5336
+ /**
5337
+ * Patch operations to apply.
5338
+ */
5339
+ patch: PatchOperations;
5340
+ /**
5341
+ * When set, the action fails unless the current revision of the variant
5342
+ * definition matches this value.
5343
+ */
5344
+ ifRevisionId?: string;
5345
+ }
5346
+ /**
5347
+ * Deletes a variant definition.
5348
+ *
5349
+ * Deletion fails if any document holds a strong reference to this variant.
5350
+ *
5351
+ * @public
5352
+ * @beta
5353
+ */
5354
+ interface DeleteVariantDefinitionAction {
5355
+ actionType: 'sanity.action.variant.definition.delete';
5356
+ /**
5357
+ * Name of the variant definition to delete, as in
5358
+ * `_.variants.{variantName}`. Must be a bare name, not a full document ID.
5359
+ */
5360
+ variantId: string;
5361
+ /**
5362
+ * When set, the action fails unless the current revision of the variant
5363
+ * definition matches this value.
5364
+ */
5365
+ ifRevisionId?: string;
5366
+ }
4520
5367
  /**
4521
5368
  * Creates a new draft document. The published version of the document must not already exist.
4522
5369
  * If the draft version of the document already exists the action will fail by default, but
@@ -4949,7 +5796,7 @@ interface ResumableListenOptions extends Omit<ListenOptions, 'events' | 'enableR
4949
5796
  events?: ResumableListenEventNames[];
4950
5797
  }
4951
5798
  /** @public */
4952
- interface ResponseQueryOptions extends RequestOptions {
5799
+ interface ResponseQueryOptions extends RequestOptions$1 {
4953
5800
  perspective?: ClientPerspective$1;
4954
5801
  /**
4955
5802
  * @beta
@@ -5008,7 +5855,7 @@ interface RawQueryResponse$1<R> {
5008
5855
  /** @public */
5009
5856
  type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse$1<R>, 'query'>;
5010
5857
  /** @internal */
5011
- type BaseMutationOptions = RequestOptions & {
5858
+ type BaseMutationOptions = RequestOptions$1 & {
5012
5859
  visibility?: 'sync' | 'async' | 'deferred';
5013
5860
  returnDocuments?: boolean;
5014
5861
  returnFirst?: boolean;
@@ -5084,7 +5931,7 @@ type TransactionAllDocumentIdsMutationOptions = BaseMutationOptions & {
5084
5931
  /** @internal */
5085
5932
  type TransactionMutationOptions = TransactionFirstDocumentMutationOptions | TransactionFirstDocumentIdMutationOptions | TransactionAllDocumentsMutationOptions | TransactionAllDocumentIdsMutationOptions;
5086
5933
  /** @internal */
5087
- type BaseActionOptions = RequestOptions & {
5934
+ type BaseActionOptions = RequestOptions$1 & {
5088
5935
  transactionId?: string;
5089
5936
  skipCrossDatasetReferenceValidation?: boolean;
5090
5937
  dryRun?: boolean;
@@ -5498,5 +6345,44 @@ interface VideoPlaybackTokens {
5498
6345
  }
5499
6346
  /** @public */
5500
6347
  type MediaLibraryAssetInstanceIdentifier = string | SanityReference;
5501
- export { EditableReleaseDocument as $, VideoRenditionInfo as $n, DocumentAgentActionParam as $r, ReleaseState as $t, ContentSourceMapMappings as A, TransactionAllDocumentsMutationOptions as An, LiveClient as Ar, MutationEvent as At, DatasetAclMode as B, UploadBody as Bn, TransformTarget as Br, PublishReleaseAction as Bt, ContentSourceMap$1 as C, SingleMutationResult as Cn, ObservablePatchBuilder as Cr, MediaLibraryPlaybackInfoOptions as Ct, ContentSourceMapDocuments$1 as D, SyncTag as Dn, BasePatch as Dr, Mutation as Dt, ContentSourceMapDocumentValueSource as E, StoryboardTransformOptions as En, Transaction as Er, MultipleMutationResult as Et, ContentSourceMapValueMapping as F, UnfilteredResponseQueryOptions as Fn, TranslateTarget as Fr, PartialExcept as Ft, DeleteAction as G, VersionAction as Gn, PatchOperation as Gr, RawQueryResponse$1 as Gt, DatasetEditOptions as H, UploadEvent as Hn, TransformTargetInclude as Hr, QueryParams as Ht, CreateAction as I, UnfilteredResponseWithoutQuery as In, TranslateTargetInclude as Ir, PatchMutationOperation as It, DiscardVersionAction as J, VideoPlaybackInfoItemPublic as Jn, AgentActionParams as Jr, ReconnectEvent as Jt, DeleteReleaseAction as K, VideoPlaybackInfo as Kn, PatchTarget as Kr, RawQuerylessQueryResponse as Kt, CreateReleaseAction as L, UnpublishAction as Ln, ImageDescriptionOperation as Lr, PatchOperations as Lt, ContentSourceMapRemoteDocument as M, TransactionFirstDocumentMutationOptions as Mn, AssetsClient as Mr, MutationSelection as Mt, ContentSourceMapSource as N, TransactionMutationOptions as Nn, ObservableAssetsClient as Nr, MutationSelectionQueryParams as Nt, ContentSourceMapLiteralSource as O, ThumbnailTransformOptions as On, ObservablePatch as Or, MutationError as Ot, ContentSourceMapUnknownSource as P, UnarchiveReleaseAction as Pn, TranslateDocument as Pr, OpenEvent as Pt, EditReleaseAction as Q, VideoPlaybackTokens as Qn, ConstantAgentActionParam as Qr, ReleaseId as Qt, CreateVersionAction as R, UnpublishVersionAction as Rn, TransformDocument as Rr, PatchSelection as Rt, ClientVariantConditions as S, SingleActionResult as Sn, BaseTransaction as Sr, MediaLibraryAssetInstanceIdentifier as St, ContentSourceMapDocumentBase as T, StillImageFormat as Tn, PatchBuilder as Tr, MultipleActionResult as Tt, DatasetResponse as U, UploadProgressEvent as Un, PromptRequest as Ur, QueryParseError as Ut, DatasetCreateOptions as V, UploadClientConfig as Vn, TransformTargetDocument as Vr, QueryOptions as Vt, DatasetsResponse as W, UploadResponseEvent as Wn, PatchDocument as Wr, QueryWithoutParams as Wt, EXPERIMENTAL_API_WARNING as X, VideoPlaybackInfoPublic as Xn, AgentActionPathSegment as Xr, ReleaseCardinality as Xt, DisconnectEvent as Y, VideoPlaybackInfoItemSigned as Yn, AgentActionPath as Yr, ReleaseAction as Yt, EditAction as Z, VideoPlaybackInfoSigned as Zn, AgentActionTarget as Zr, ReleaseDocument as Zt, ChannelErrorEvent as _, SanityProjectMember as _n, ProjectsClient as _r, LiveEventGoAway as _t, AllDocumentsMutationOptions as a, RequestUrlOptions as an, WelcomeBackEvent as ar, FirstDocumentMutationOptions as at, ClientReturn$1 as b, SanityUser as bn, DatasetsClient as br, LiveEventRestart as bt, Any$1 as c, ResponseQueryOptions as cn, GenerateOperation as cr, IdentifiedSanityDocumentStub as ct, AssetMetadataType as d, SanityAssetDocument as dn, GenerateTargetInclude as dr, InsertPatch as dt, FieldAgentActionParam as ei, ReleaseType as en, VideoRenditionInfoPublic as er, EmbeddingsSettings as et, AttributeSet as f, SanityDocument$1 as fn, ObservableSanityClient$1 as fr, ListenEvent as ft, BaseMutationOptions as g, SanityProject as gn, ObservableProjectsClient as gr, LiveEvent as gt, BaseActionOptions as h, SanityImagePalette as hn, UsersClient as hr, ListenParams as ht, AllDocumentIdsMutationOptions as i, RequestOptions as in, VideoSubtitleInfoSigned as ir, FirstDocumentIdMutationOptions as it, ContentSourceMapPaths as j, TransactionFirstDocumentIdMutationOptions as jn, _listen as jr, MutationOperation as jt, ContentSourceMapMapping as k, TransactionAllDocumentIdsMutationOptions as kn, Patch as kr, MutationErrorItem as kt, ApiError as l, ResumableListenEventNames as ln, GenerateTarget as lr, ImportReleaseAction as lt, AuthProviderResponse as m, SanityImageAssetDocument as mn, ObservableUsersClient as mr, ListenOptions as mt, ActionError as n, ReplaceVersionAction as nn, VideoSubtitleInfo as nr, ErrorProps as nt, AnimatedImageFormat as o, Requester as on, WelcomeEvent as or, FitMode as ot, AuthProvider as p, SanityDocumentStub as pn, SanityClient$1 as pr, ListenEventName as pt, DiscardAction as q, VideoPlaybackInfoItem as qn, AgentActionParam as qr, RawRequestOptions as qt, ActionErrorItem as r, RequestObservableOptions as rn, VideoSubtitleInfoPublic as rr, FilteredResponseQueryOptions as rt, AnimatedTransformOptions as s, ResetEvent as sn, GenerateInstruction as sr, HttpRequest as st, Action as t, GroqAgentActionParam as ti, ReplaceDraftAction as tn, VideoRenditionInfoSigned as tr, EmbeddingsSettingsBody as tt, ArchiveReleaseAction as u, ResumableListenOptions as un, GenerateTargetDocument as ur, InitializedClientConfig$1 as ut, ClientConfig$1 as v, SanityQueries as vn, MediaLibraryVideoClient as vr, LiveEventMessage as vt, ContentSourceMapDocument as w, StackablePerspective as wn, ObservableTransaction as wr, MediaLibraryVideoPlaybackTransformations as wt, ClientVariant as x, ScheduleReleaseAction as xn, ObservableDatasetsClient as xr, LiveEventWelcome as xt, ClientPerspective$1 as y, SanityReference as yn, ObservableMediaLibraryVideoClient as yr, LiveEventReconnect as yt, CurrentSanityUser as z, UnscheduleReleaseAction as zn, TransformOperation as zr, PublishAction as zt };
5502
- //# sourceMappingURL=types-CUxZSgB2.d.ts.map
6348
+ /**
6349
+ * A single tracked version of a Media Library asset - one uploaded instance,
6350
+ * referencing the underlying (Content Lake shaped) asset document it wraps.
6351
+ *
6352
+ * @public
6353
+ */
6354
+ interface MediaLibraryAssetVersion {
6355
+ _key: string;
6356
+ _type: 'sanity.asset.version';
6357
+ title?: string;
6358
+ instance: SanityReference;
6359
+ }
6360
+ /**
6361
+ * The document returned by the Media Library upload endpoint
6362
+ * (`POST /media-libraries/:id/upload`).
6363
+ *
6364
+ * This is _not_ the same shape as {@link SanityAssetDocument} /
6365
+ * {@link SanityImageAssetDocument}: a Media Library asset is a `sanity.asset`
6366
+ * document that tracks one or more uploaded versions, each pointing at its
6367
+ * own underlying Content Lake asset document via `currentVersion`/`versions`.
6368
+ *
6369
+ * Modelled directly on an observed API response. Fields whose full shape has
6370
+ * not been confirmed (`parent`, `rootDirectory`, `aspects`) are typed loosely
6371
+ * on purpose - widen them once their shape is confirmed.
6372
+ *
6373
+ * @public
6374
+ */
6375
+ interface MediaLibraryAssetDocument {
6376
+ _id: string;
6377
+ _type: 'sanity.asset';
6378
+ assetType: string;
6379
+ title?: string;
6380
+ cdnAccessPolicy?: string;
6381
+ currentVersion: SanityReference;
6382
+ versions: MediaLibraryAssetVersion[];
6383
+ aspects?: Record<string, Any$1>;
6384
+ parent?: SanityReference | null;
6385
+ rootDirectory?: Any$1;
6386
+ }
6387
+ export { DisconnectEvent as $, UploadClientConfig as $n, CollaborationCommentRange as $r, QueryWithoutParams as $t, ContentSourceMapMappings as A, DocumentAgentActionParam as Ai, SanityReference as An, ObservableProjectsClient as Ar, MediaLibraryAssetVersion as At, CreateVersionAction as B, TransactionAllDocumentIdsMutationOptions as Bn, ObservableTransaction as Br, MutationSelection as Bt, ContentSourceMap$1 as C, PatchTarget as Ci, SanityDocument$1 as Cn, GenerateTarget as Cr, LiveEventGoAway as Ct, ContentSourceMapDocuments$1 as D, AgentActionPathSegment as Di, SanityProject as Dn, SanityClient$1 as Dr, LiveEventWelcome as Dt, ContentSourceMapDocumentValueSource as E, AgentActionPath as Ei, SanityImagePalette as En, ObservableSanityClient$1 as Er, LiveEventRestart as Et, ContentSourceMapValueMapping as F, StackablePerspective as Fn, InvokeFunctionRequest as Fr, Mutation as Ft, DatasetResponse as G, UnarchiveReleaseAction as Gn, Patch as Gr, PatchOperations as Gt, DatasetAclMode as H, TransactionFirstDocumentIdMutationOptions as Hn, Transaction as Hr, OpenEvent as Ht, CreateAction as I, StillImageFormat as In, DatasetsClient as Ir, MutationError as It, DeleteReleaseAction as J, UnpublishAction as Jn, ObservableCollaborationCommentsClient as Jr, PublishReleaseAction as Jt, DatasetsResponse as K, UnfilteredResponseQueryOptions as Kn, LiveClient as Kr, PatchSelection as Kt, CreateReleaseAction as L, StoryboardTransformOptions as Ln, ObservableDatasetsClient as Lr, MutationErrorItem as Lt, ContentSourceMapRemoteDocument as M, GroqAgentActionParam as Mi, ScheduleReleaseAction as Mn, MediaLibraryVideoClient as Mr, MediaLibraryVideoPlaybackTransformations as Mt, ContentSourceMapSource as N, SingleActionResult as Nn, ObservableMediaLibraryVideoClient as Nr, MultipleActionResult as Nt, ContentSourceMapLiteralSource as O, AgentActionTarget as Oi, SanityProjectMember as On, ObservableUsersClient as Or, MediaLibraryAssetDocument as Ot, ContentSourceMapUnknownSource as P, SingleMutationResult as Pn, InvokeFunctionEvent as Pr, MultipleMutationResult as Pt, DiscardVersionAction as Q, UploadBody as Qn, CollaborationCommentPortableTextBlock as Qr, QueryParseError as Qt, CreateVariantAction as R, SyncTag as Rn, BaseTransaction as Rr, MutationEvent as Rt, ClientVariantConditions as S, PatchOperation as Si, SanityAssetDocument as Sn, GenerateOperation as Sr, LiveEvent as St, ContentSourceMapDocumentBase as T, AgentActionParams as Ti, SanityImageAssetDocument as Tn, GenerateTargetInclude as Tr, LiveEventReconnect as Tt, DatasetCreateOptions as U, TransactionFirstDocumentMutationOptions as Un, BasePatch as Ur, PartialExcept as Ut, CurrentSanityUser as V, TransactionAllDocumentsMutationOptions as Vn, PatchBuilder as Vr, MutationSelectionQueryParams as Vt, DatasetEditOptions as W, TransactionMutationOptions as Wn, ObservablePatch as Wr, PatchMutationOperation as Wt, DeleteVariantDefinitionAction as X, UnpublishVersionAction as Xn, CollaborationCommentDocument as Xr, QueryOptions as Xt, DeleteVariantAction as Y, UnpublishVariantAction as Yn, CollaborationCommentCreate as Yr, PublishVariantAction as Yt, DiscardAction as Z, UnscheduleReleaseAction as Zn, CollaborationCommentMessage as Zr, QueryParams as Zt, ChannelErrorEvent as _, TransformTarget as _i, Requester as _n, VideoSubtitleInfoPublic as _r, InsertPatch as _t, AllDocumentsMutationOptions as a, CollaborationCommentsListenOptions as ai, ReleaseCardinality as an, VersionAction as ar, EditableReleaseDocument as at, ClientReturn$1 as b, PromptRequest as bi, ResumableListenEventNames as bn, WelcomeEvent as br, ListenOptions as bt, Any$1 as c, _listen as ci, ReleaseState as cn, VideoPlaybackInfoItemPublic as cr, ErrorProps as ct, AssetMetadataType as d, TranslateDocument as di, ReplaceVersionAction as dn, VideoPlaybackInfoSigned as dr, FirstDocumentMutationOptions as dt, CollaborationCommentReactionShortName as ei, RawQueryResponse$1 as en, UploadEvent as er, EXPERIMENTAL_API_WARNING as et, AttributeSet as f, TranslateTarget as fi, RequestHandler as fn, VideoPlaybackTokens as fr, FitMode as ft, BaseMutationOptions as g, TransformOperation as gi, RequestUrlOptions as gn, VideoSubtitleInfo as gr, InitializedClientConfig$1 as gt, BaseActionOptions as h, TransformDocument as hi, RequestOptions$1 as hn, VideoRenditionInfoSigned as hr, ImportReleaseAction as ht, AllDocumentIdsMutationOptions as i, CollaborationCommentUpdate as ii, ReleaseAction as in, VariantDefinitionAction as ir, EditVariantDefinitionAction as it, ContentSourceMapPaths as j, FieldAgentActionParam as ji, SanityUser as jn, ProjectsClient as jr, MediaLibraryPlaybackInfoOptions as jt, ContentSourceMapMapping as k, ConstantAgentActionParam as ki, SanityQueries as kn, UsersClient as kr, MediaLibraryAssetInstanceIdentifier as kt, ApiError as l, AssetsClient as li, ReleaseType as ln, VideoPlaybackInfoItemSigned as lr, FilteredResponseQueryOptions as lt, AuthProviderResponse as m, ImageDescriptionOperation as mi, RequestObservableOptions as mn, VideoRenditionInfoPublic as mr, IdentifiedSanityDocumentStub as mt, ActionError as n, CollaborationCommentStatus as ni, RawRequestOptions as nn, UploadResponseEvent as nr, EditReleaseAction as nt, AnimatedImageFormat as o, CollaborationCommentsRequestOptions as oi, ReleaseDocument as on, VideoPlaybackInfo as or, EmbeddingsSettings as ot, AuthProvider as p, TranslateTargetInclude as pi, RequestHandlerOptions as pn, VideoRenditionInfo as pr, HttpRequest as pt, DeleteAction as q, UnfilteredResponseWithoutQuery as qn, CollaborationCommentsClient as qr, PublishAction as qt, ActionErrorItem as r, CollaborationCommentTarget as ri, ReconnectEvent as rn, VariantAction as rr, EditVariantAction as rt, AnimatedTransformOptions as s, CollaborationCommentsWriteOptions as si, ReleaseId as sn, VideoPlaybackInfoItem as sr, EmbeddingsSettingsBody as st, Action as t, CollaborationCommentSelection as ti, RawQuerylessQueryResponse as tn, UploadProgressEvent as tr, EditAction as tt, ArchiveReleaseAction as u, ObservableAssetsClient as ui, ReplaceDraftAction as un, VideoPlaybackInfoPublic as ur, FirstDocumentIdMutationOptions as ut, ClientConfig$1 as v, TransformTargetDocument as vi, ResetEvent as vn, VideoSubtitleInfoSigned as vr, ListenEvent as vt, ContentSourceMapDocument as w, AgentActionParam as wi, SanityDocumentStub as wn, GenerateTargetDocument as wr, LiveEventMessage as wt, ClientVariant as x, PatchDocument as xi, ResumableListenOptions as xn, GenerateInstruction as xr, ListenParams as xt, ClientPerspective$1 as y, TransformTargetInclude as yi, ResponseQueryOptions as yn, WelcomeBackEvent as yr, ListenEventName as yt, CreateVariantDefinitionAction as z, ThumbnailTransformOptions as zn, ObservablePatchBuilder as zr, MutationOperation as zt };
6388
+ //# sourceMappingURL=types-nJhm5Nyq.d.ts.map