@sanity/client 8.1.0 → 8.3.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.
@@ -1224,6 +1224,508 @@ declare function _listen<R extends Record<string, Any> = Record<string, Any>>(th
1224
1224
  * @public
1225
1225
  */
1226
1226
  declare function _listen<R extends Record<string, Any> = Record<string, Any>, Opts extends ListenOptions | ResumableListenOptions = ListenOptions | ResumableListenOptions>(this: SanityClient | ObservableSanityClient, query: string, params?: ListenParams, options?: Opts): Observable<ListenEventFromOptions<R, Opts>>;
1227
+ /** @internal */
1228
+ declare const possibleRequestOptions: readonly ['headers', 'signal', 'tag', 'timeout', 'token'];
1229
+ /**
1230
+ * Request options honored by the collaboration comments methods.
1231
+ *
1232
+ * @alpha
1233
+ */
1234
+ type CollaborationCommentsRequestOptions = Pick<RequestOptions, (typeof possibleRequestOptions)[number]>;
1235
+ /**
1236
+ * Options for collaboration comments write methods.
1237
+ *
1238
+ * @alpha
1239
+ */
1240
+ type CollaborationCommentsWriteOptions = CollaborationCommentsRequestOptions & {
1241
+ /** Transaction ID to associate the write with */
1242
+ transactionId?: string;
1243
+ };
1244
+ /**
1245
+ * Listener options for `collaboration.comments.listen`.
1246
+ *
1247
+ * `includeAllVersions` is left out: comments are stored as `sanity.comment`
1248
+ * documents with no drafts or versions, so it would never make a difference.
1249
+ *
1250
+ * @alpha
1251
+ */
1252
+ type CollaborationCommentsListenOptions = Omit<ListenOptions, 'includeAllVersions'> | Omit<ResumableListenOptions, 'includeAllVersions'>;
1253
+ /**
1254
+ * Status of a comment thread. Replies always share the status of their parent comment.
1255
+ *
1256
+ * @alpha
1257
+ */
1258
+ type CollaborationCommentStatus = 'open' | 'resolved';
1259
+ /**
1260
+ * Emoji short names that can be used as comment reactions.
1261
+ *
1262
+ * @alpha
1263
+ */
1264
+ type CollaborationCommentReactionShortName = ':-1:' | ':+1:' | ':eyes:' | ':heart:' | ':heavy_plus_sign:' | ':rocket:';
1265
+ /**
1266
+ * A single Portable Text block, as used in comment messages and content snapshots.
1267
+ *
1268
+ * @alpha
1269
+ */
1270
+ interface CollaborationCommentPortableTextBlock {
1271
+ _type: string;
1272
+ children: Array<{
1273
+ _type: string;
1274
+ [key: string]: Any;
1275
+ }>;
1276
+ [key: string]: Any;
1277
+ }
1278
+ /**
1279
+ * Comment message, as an array of Portable Text blocks.
1280
+ *
1281
+ * @alpha
1282
+ */
1283
+ type CollaborationCommentMessage = CollaborationCommentPortableTextBlock[];
1284
+ /**
1285
+ * The text an inline comment was anchored to, resolved by the API when the
1286
+ * comment was created.
1287
+ *
1288
+ * Holds one entry per Portable Text block the selection spans, keyed by the
1289
+ * block it came from. `text` is the plain text of that block with the selected
1290
+ * part wrapped in the marker characters `\uF000` (start) and `\uF001` (end).
1291
+ *
1292
+ * @alpha
1293
+ */
1294
+ interface CollaborationCommentSelection {
1295
+ type: 'text';
1296
+ value: {
1297
+ _key: string;
1298
+ text: string;
1299
+ }[];
1300
+ }
1301
+ /**
1302
+ * A comment document, as stored by the Comments API.
1303
+ *
1304
+ * @alpha
1305
+ */
1306
+ interface CollaborationCommentDocument extends SanityDocument {
1307
+ _type: 'sanity.comment';
1308
+ _system?: {
1309
+ /** ID of the user that created the comment */
1310
+ createdBy?: string;
1311
+ };
1312
+ /** ID shared by a top-level comment and all of its replies */
1313
+ threadId?: string;
1314
+ /** Set on replies, pointing to the comment being replied to */
1315
+ parentCommentId?: string;
1316
+ message: CollaborationCommentMessage;
1317
+ reactions: {
1318
+ _key: string;
1319
+ shortName: CollaborationCommentReactionShortName;
1320
+ userId: string;
1321
+ addedAt: string;
1322
+ }[];
1323
+ /** Arbitrary metadata stored with the comment by the creating application */
1324
+ context?: Record<string, unknown>;
1325
+ target: {
1326
+ /** Global document reference (`resourceType:resourceId:documentId`, using the published document ID) */
1327
+ document: {
1328
+ _ref: `${string}:${string}:${string}`;
1329
+ _type: 'globalDocumentReference';
1330
+ _weak: true;
1331
+ };
1332
+ documentType: string;
1333
+ /** The exact document ID the comment was created against, e.g. a draft or version ID */
1334
+ sourceDocumentId: string;
1335
+ documentRevisionId?: string;
1336
+ /**
1337
+ * Set for field and inline comments. `field` is the `path` the comment was
1338
+ * created with; `selection` is set for inline comments only.
1339
+ */
1340
+ path?: {
1341
+ field: string;
1342
+ selection?: CollaborationCommentSelection;
1343
+ };
1344
+ };
1345
+ /**
1346
+ * Copy of the commented content, as it looked when the comment was created.
1347
+ * Set for inline comments only, and holds just the selected fragment of each
1348
+ * Portable Text block the selection spans.
1349
+ */
1350
+ contentSnapshot?: CollaborationCommentPortableTextBlock[];
1351
+ status: CollaborationCommentStatus;
1352
+ /** Set when the message has been updated after creation */
1353
+ lastEditedAt?: string;
1354
+ }
1355
+ /**
1356
+ * Inline text selection within a Portable Text field.
1357
+ * Each endpoint pairs the `_key` of a Portable Text block with a character
1358
+ * offset into that block's plain text.
1359
+ *
1360
+ * @alpha
1361
+ */
1362
+ interface CollaborationCommentRange {
1363
+ start: {
1364
+ _key: string;
1365
+ offset: number;
1366
+ };
1367
+ end: {
1368
+ _key: string;
1369
+ offset: number;
1370
+ };
1371
+ }
1372
+ /**
1373
+ * Portable Text covering a comment `range`. Callers can send just the blocks
1374
+ * from the `range` start `_key` through end `_key`, or the full field.
1375
+ *
1376
+ * @alpha
1377
+ */
1378
+ type CollaborationCommentFieldValue = Array<{
1379
+ _type: string;
1380
+ _key: string;
1381
+ [key: string]: Any;
1382
+ }>;
1383
+ /**
1384
+ * Target for a top-level comment. Inline selections require both `path` and
1385
+ * `range`; field-level comments may set `path` alone.
1386
+ *
1387
+ * The created comment stores this in a different shape: `path` becomes
1388
+ * `target.path.field`, and `range` is resolved against the document into
1389
+ * `target.path.selection` and `contentSnapshot` rather than being stored.
1390
+ *
1391
+ * An optional `fieldValue` is Portable Text covering the `range`. When set,
1392
+ * the `range` is resolved from those blocks instead of from the live document.
1393
+ *
1394
+ * @alpha
1395
+ */
1396
+ type CollaborationCommentTarget = {
1397
+ documentId: string;
1398
+ documentType: string;
1399
+ documentRevisionId?: string;
1400
+ } & ({
1401
+ /** Path to the field containing the inline comment selection */
1402
+ path: string;
1403
+ range: CollaborationCommentRange;
1404
+ /**
1405
+ * Portable Text covering the `range`. When set, the `range` is resolved
1406
+ * from these blocks instead of from the live document.
1407
+ */
1408
+ fieldValue?: CollaborationCommentFieldValue;
1409
+ } | {
1410
+ /** Path to the commented field */
1411
+ path?: string;
1412
+ range?: never;
1413
+ fieldValue?: never;
1414
+ });
1415
+ /**
1416
+ * Comment to create with `collaboration.comments.create`.
1417
+ *
1418
+ * A top-level comment requires `target`; a reply requires `parentCommentId` (never both).
1419
+ * Replies inherit `target`, `status`, and `threadId` from the parent comment.
1420
+ *
1421
+ * ### Examples
1422
+ *
1423
+ * #### Top-level comment
1424
+ * ```ts
1425
+ * // `message` is an array of Portable Text blocks
1426
+ * await client.collaboration.comments.create({
1427
+ * message,
1428
+ * target: {documentId: 'doc-1', documentType: 'article'},
1429
+ * })
1430
+ * ```
1431
+ *
1432
+ * #### Inline comment
1433
+ * ```ts
1434
+ * await client.collaboration.comments.create({
1435
+ * message,
1436
+ * target: {
1437
+ * documentId: 'doc-1',
1438
+ * documentType: 'article',
1439
+ * path: 'body',
1440
+ * range: {start: {_key: 'block-1', offset: 0}, end: {_key: 'block-1', offset: 5}},
1441
+ * },
1442
+ * })
1443
+ * ```
1444
+ *
1445
+ * #### Reply
1446
+ * ```ts
1447
+ * await client.collaboration.comments.create({
1448
+ * message,
1449
+ * parentCommentId: 'comment-1',
1450
+ * })
1451
+ * ```
1452
+ *
1453
+ * @alpha
1454
+ */
1455
+ type CollaborationCommentCreate = {
1456
+ /** Provide to control the ID of the created comment document */
1457
+ _id?: string;
1458
+ message: CollaborationCommentMessage;
1459
+ context?: Record<string, unknown>;
1460
+ } & ({
1461
+ target: CollaborationCommentTarget;
1462
+ threadId?: string;
1463
+ parentCommentId?: never;
1464
+ } | {
1465
+ parentCommentId: string;
1466
+ target?: never;
1467
+ threadId?: never;
1468
+ });
1469
+ /**
1470
+ * Fields that can be updated on an existing comment.
1471
+ *
1472
+ * A `range` re-anchors the comment within the field it already targets.
1473
+ * Pass `null` to remove the selection and leave a field-level comment.
1474
+ * An optional `fieldValue` is Portable Text covering that `range`; when set,
1475
+ * the `range` is resolved from those blocks instead of from the live document.
1476
+ * `fieldValue` cannot be sent alone or together with `range: null`.
1477
+ *
1478
+ * @alpha
1479
+ */
1480
+ type CollaborationCommentUpdate = {
1481
+ /** Replaces the current message */
1482
+ message?: CollaborationCommentMessage;
1483
+ /** Cascades to the comment's replies */
1484
+ status?: CollaborationCommentStatus;
1485
+ } & ({
1486
+ range: CollaborationCommentRange;
1487
+ /**
1488
+ * Portable Text covering the `range`. When set, the `range` is resolved
1489
+ * from these blocks instead of from the live document.
1490
+ */
1491
+ fieldValue?: CollaborationCommentFieldValue;
1492
+ } | {
1493
+ range: null;
1494
+ fieldValue?: never;
1495
+ } | {
1496
+ range?: undefined;
1497
+ fieldValue?: never;
1498
+ });
1499
+ /**
1500
+ * Comments on the configured organization resource.
1501
+ *
1502
+ * Requires `collaboration.organizationId`, plus either `resource` or `projectId` and `dataset`.
1503
+ *
1504
+ * @alpha
1505
+ */
1506
+ declare class ObservableCollaborationCommentsClient {
1507
+ #private;
1508
+ constructor(client: ObservableSanityClient, httpRequest: HttpRequest);
1509
+ /**
1510
+ * Create a comment or reply on the configured resource.
1511
+ *
1512
+ * A top-level comment requires `target`; a reply requires `parentCommentId` (never both).
1513
+ * Replies inherit `target`, `status`, and `threadId` from the parent comment.
1514
+ *
1515
+ * @param body - Comment to create
1516
+ * @param options - Optional request options
1517
+ * @returns The created comment
1518
+ */
1519
+ create(body: CollaborationCommentCreate, options?: CollaborationCommentsWriteOptions): Observable<CollaborationCommentDocument>;
1520
+ /**
1521
+ * Update an existing comment.
1522
+ *
1523
+ * Updating `status` cascades to the comment's replies.
1524
+ *
1525
+ * @param id - Comment document ID
1526
+ * @param body - Fields to update
1527
+ * @param options - Optional request options
1528
+ * @returns The updated comment
1529
+ */
1530
+ update(id: string, body: CollaborationCommentUpdate, options?: CollaborationCommentsWriteOptions): Observable<CollaborationCommentDocument>;
1531
+ /**
1532
+ * Delete a comment and its replies.
1533
+ *
1534
+ * @param id - Comment document ID
1535
+ * @param options - Optional request options
1536
+ * @returns Mutation result, where `documentIds` covers the comment and every deleted reply
1537
+ */
1538
+ delete(id: string, options?: CollaborationCommentsWriteOptions): Observable<MultipleMutationResult>;
1539
+ /**
1540
+ * Add the current user's reaction to a comment.
1541
+ *
1542
+ * @param id - Comment document ID
1543
+ * @param shortName - Emoji short name, for example `:+1:`
1544
+ * @param options - Optional request options
1545
+ * @returns The comment, with the reaction applied
1546
+ */
1547
+ addReaction(id: string, shortName: CollaborationCommentReactionShortName, options?: CollaborationCommentsWriteOptions): Observable<CollaborationCommentDocument>;
1548
+ /**
1549
+ * Remove the current user's reaction from a comment.
1550
+ *
1551
+ * @param id - Comment document ID
1552
+ * @param shortName - Emoji short name, for example `:+1:`
1553
+ * @param options - Optional request options
1554
+ * @returns The comment, with the reaction removed
1555
+ */
1556
+ removeReaction(id: string, shortName: CollaborationCommentReactionShortName, options?: CollaborationCommentsWriteOptions): Observable<CollaborationCommentDocument>;
1557
+ /**
1558
+ * Build the global document reference used by `target.document._ref`, for use in
1559
+ * queries and listeners.
1560
+ *
1561
+ * The reference is built from the configured `resource` and the published ID of
1562
+ * the given document ID, since comment references always use published IDs.
1563
+ *
1564
+ * @example
1565
+ * ```ts
1566
+ * client.collaboration.comments.listen(
1567
+ * '*[_type == "sanity.comment" && target.document._ref == $ref]',
1568
+ * {ref: client.collaboration.comments.getTargetDocumentRef('doc-1')},
1569
+ * )
1570
+ * ```
1571
+ *
1572
+ * @param documentId - Document ID, in published, draft or version form
1573
+ * @returns Global document reference, of the form `resourceType:resourceId:documentId`
1574
+ */
1575
+ getTargetDocumentRef(documentId: string): CollaborationCommentDocument['target']['document']['_ref'];
1576
+ /**
1577
+ * Fetch comments on the configured resource.
1578
+ *
1579
+ * Takes the same `query` and `params` as `client.fetch`, and switches from a
1580
+ * GET to a POST for queries too large for the request URL in the same way,
1581
+ * but queries the comments endpoint, which accepts none of the query options
1582
+ * `client.fetch` does (`perspective`, `useCdn`, `filterResponse`,
1583
+ * `resultSourceMap`, stega).
1584
+ *
1585
+ * The query runs against the organization store, which is not scoped to
1586
+ * comments, so filter on `_type == "sanity.comment"`.
1587
+ *
1588
+ * @param query - GROQ-query to perform
1589
+ * @param params - Optional query parameters
1590
+ * @param options - Optional request options
1591
+ */
1592
+ fetch<R = unknown>(query: string, params?: QueryParams, options?: CollaborationCommentsRequestOptions): Observable<R>;
1593
+ /**
1594
+ * Listen for changes to comments on the configured resource.
1595
+ *
1596
+ * Mirrors `client.listen(query, params)`, and emits mutation events.
1597
+ *
1598
+ * @param query - GROQ-filter to listen to changes for
1599
+ * @param params - Optional query parameters
1600
+ */
1601
+ listen(query: string, params?: QueryParams): Observable<MutationEvent<CollaborationCommentDocument>>;
1602
+ /**
1603
+ * Listen for changes to comments on the configured resource.
1604
+ *
1605
+ * Mirrors `client.listen(query, params, options)`.
1606
+ *
1607
+ * @param query - GROQ-filter to listen to changes for
1608
+ * @param params - Optional query parameters
1609
+ * @param options - The same listener options `client.listen` takes, forwarded
1610
+ * to the organization store's listener
1611
+ */
1612
+ listen<Opts extends CollaborationCommentsListenOptions>(query: string, params: QueryParams | undefined, options: Opts): Observable<ListenEventFromOptions<CollaborationCommentDocument, Opts>>;
1613
+ }
1614
+ /**
1615
+ * Comments on the configured organization resource.
1616
+ *
1617
+ * Requires `collaboration.organizationId`, plus either `resource` or `projectId` and `dataset`.
1618
+ *
1619
+ * @alpha
1620
+ */
1621
+ declare class CollaborationCommentsClient {
1622
+ #private;
1623
+ constructor(client: SanityClient, httpRequest: HttpRequest);
1624
+ /**
1625
+ * Create a comment or reply on the configured resource.
1626
+ *
1627
+ * A top-level comment requires `target`; a reply requires `parentCommentId` (never both).
1628
+ * Replies inherit `target`, `status`, and `threadId` from the parent comment.
1629
+ *
1630
+ * @param body - Comment to create
1631
+ * @param options - Optional request options
1632
+ * @returns The created comment
1633
+ */
1634
+ create(body: CollaborationCommentCreate, options?: CollaborationCommentsWriteOptions): Promise<CollaborationCommentDocument>;
1635
+ /**
1636
+ * Update an existing comment.
1637
+ *
1638
+ * Updating `status` cascades to the comment's replies.
1639
+ *
1640
+ * @param id - Comment document ID
1641
+ * @param body - Fields to update
1642
+ * @param options - Optional request options
1643
+ * @returns The updated comment
1644
+ */
1645
+ update(id: string, body: CollaborationCommentUpdate, options?: CollaborationCommentsWriteOptions): Promise<CollaborationCommentDocument>;
1646
+ /**
1647
+ * Delete a comment and its replies.
1648
+ *
1649
+ * @param id - Comment document ID
1650
+ * @param options - Optional request options
1651
+ * @returns Mutation result, where `documentIds` covers the comment and every deleted reply
1652
+ */
1653
+ delete(id: string, options?: CollaborationCommentsWriteOptions): Promise<MultipleMutationResult>;
1654
+ /**
1655
+ * Add the current user's reaction to a comment.
1656
+ *
1657
+ * @param id - Comment document ID
1658
+ * @param shortName - Emoji short name, for example `:+1:`
1659
+ * @param options - Optional request options
1660
+ * @returns The comment, with the reaction applied
1661
+ */
1662
+ addReaction(id: string, shortName: CollaborationCommentReactionShortName, options?: CollaborationCommentsWriteOptions): Promise<CollaborationCommentDocument>;
1663
+ /**
1664
+ * Remove the current user's reaction from a comment.
1665
+ *
1666
+ * @param id - Comment document ID
1667
+ * @param shortName - Emoji short name, for example `:+1:`
1668
+ * @param options - Optional request options
1669
+ * @returns The comment, with the reaction removed
1670
+ */
1671
+ removeReaction(id: string, shortName: CollaborationCommentReactionShortName, options?: CollaborationCommentsWriteOptions): Promise<CollaborationCommentDocument>;
1672
+ /**
1673
+ * Build the global document reference used by `target.document._ref`, for use in
1674
+ * queries and listeners.
1675
+ *
1676
+ * The reference is built from the configured `resource` and the published ID of
1677
+ * the given document ID, since comment references always use published IDs.
1678
+ *
1679
+ * @example
1680
+ * ```ts
1681
+ * const comments = await client.collaboration.comments.fetch(
1682
+ * '*[_type == "sanity.comment" && target.document._ref == $ref]',
1683
+ * {ref: client.collaboration.comments.getTargetDocumentRef('doc-1')},
1684
+ * )
1685
+ * ```
1686
+ *
1687
+ * @param documentId - Document ID, in published, draft or version form
1688
+ * @returns Global document reference, of the form `resourceType:resourceId:documentId`
1689
+ */
1690
+ getTargetDocumentRef(documentId: string): CollaborationCommentDocument['target']['document']['_ref'];
1691
+ /**
1692
+ * Fetch comments on the configured resource.
1693
+ *
1694
+ * Takes the same `query` and `params` as `client.fetch`, and switches from a
1695
+ * GET to a POST for queries too large for the request URL in the same way,
1696
+ * but queries the comments endpoint, which accepts none of the query options
1697
+ * `client.fetch` does (`perspective`, `useCdn`, `filterResponse`,
1698
+ * `resultSourceMap`, stega).
1699
+ *
1700
+ * The query runs against the organization store, which is not scoped to
1701
+ * comments, so filter on `_type == "sanity.comment"`.
1702
+ *
1703
+ * @param query - GROQ-query to perform
1704
+ * @param params - Optional query parameters
1705
+ * @param options - Optional request options
1706
+ */
1707
+ fetch<R = unknown>(query: string, params?: QueryParams, options?: CollaborationCommentsRequestOptions): Promise<R>;
1708
+ /**
1709
+ * Listen for changes to comments on the configured resource.
1710
+ *
1711
+ * Mirrors `client.listen(query, params)`, and emits mutation events.
1712
+ *
1713
+ * @param query - GROQ-filter to listen to changes for
1714
+ * @param params - Optional query parameters
1715
+ */
1716
+ listen(query: string, params?: QueryParams): Observable<MutationEvent<CollaborationCommentDocument>>;
1717
+ /**
1718
+ * Listen for changes to comments on the configured resource.
1719
+ *
1720
+ * Mirrors `client.listen(query, params, options)`.
1721
+ *
1722
+ * @param query - GROQ-filter to listen to changes for
1723
+ * @param params - Optional query parameters
1724
+ * @param options - The same listener options `client.listen` takes, forwarded
1725
+ * to the organization store's listener
1726
+ */
1727
+ listen<Opts extends CollaborationCommentsListenOptions>(query: string, params: QueryParams | undefined, options: Opts): Observable<ListenEventFromOptions<CollaborationCommentDocument, Opts>>;
1728
+ }
1227
1729
  /**
1228
1730
  * @public
1229
1731
  */
@@ -1719,6 +2221,17 @@ interface InvokeFunctionRequest {
1719
2221
  signal?: AbortSignal;
1720
2222
  }
1721
2223
  /** @public */
2224
+ interface InvokeFunctionOptions {
2225
+ /**
2226
+ * Wait for the function to finish and resolve with its return value.
2227
+ *
2228
+ * Defaults to `false`: the invocation is started, the request resolves as soon
2229
+ * as it is accepted, and the value is always `undefined`. Only function types
2230
+ * that support running inline can be invoked synchronously.
2231
+ */
2232
+ sync?: boolean;
2233
+ }
2234
+ /** @public */
1722
2235
  declare class ObservableFunctionsClient {
1723
2236
  #private;
1724
2237
  constructor(client: ObservableSanityClient, httpRequest: HttpRequest);
@@ -1726,12 +2239,21 @@ declare class ObservableFunctionsClient {
1726
2239
  * Invoke a deployed function by its blueprint name.
1727
2240
  *
1728
2241
  * The name is resolved within the stack given by `stackId` on the request or
1729
- * the client config. Passes the function's return value once it finishes.
2242
+ * the client config. Starts the invocation and emits `undefined` as soon as
2243
+ * it is accepted; pass `{sync: true}` to wait for the function's return value
2244
+ * instead.
1730
2245
  *
1731
2246
  * @param functionName - name of the function, as declared in the blueprint
1732
2247
  * @param request - payload and request options
2248
+ * @param options - invocation options
1733
2249
  */
1734
- invoke<R = unknown>(functionName: string, request?: InvokeFunctionRequest): Observable<R | undefined>;
2250
+ invoke(functionName: string, request?: InvokeFunctionRequest, options?: InvokeFunctionOptions & {
2251
+ sync?: false;
2252
+ }): Observable<undefined>;
2253
+ invoke<R = unknown>(functionName: string, request: InvokeFunctionRequest | undefined, options: InvokeFunctionOptions & {
2254
+ sync: true;
2255
+ }): Observable<R>;
2256
+ invoke<R = unknown>(functionName: string, request?: InvokeFunctionRequest, options?: InvokeFunctionOptions): Observable<R | undefined>;
1735
2257
  }
1736
2258
  /** @public */
1737
2259
  declare class FunctionsClient {
@@ -1742,20 +2264,30 @@ declare class FunctionsClient {
1742
2264
  *
1743
2265
  * The name is resolved within the stack given by `stackId` on the request or
1744
2266
  * the client config, which costs one extra request per call. Rejects if the
1745
- * stack has no function by that name, or if the name resolves to anything
1746
- * other than a `sanity.function.pubsub` function.
2267
+ * stack has no function by that name, or if the name resolves to a function
2268
+ * type that cannot be invoked the way it was asked for.
1747
2269
  *
1748
2270
  * The lookup is scoped to `projectId`, or to `organizationId` when one is set
1749
2271
  * for a stack deployed at organization scope.
1750
2272
  *
1751
- * The request stays open until the function finishes, and resolves with its
1752
- * return value, or `undefined` if it returns nothing. Long-running functions
1753
- * may need an explicit `timeout`.
2273
+ * The invocation is started by default: the promise resolves with `undefined`
2274
+ * as soon as the call is accepted, without waiting for the function to run.
2275
+ * Pass `{sync: true}` to keep the request open until the function finishes
2276
+ * and resolve with its return value — long-running functions may then need an
2277
+ * explicit `timeout`. Only `sanity.function.pubsub` functions can be invoked
2278
+ * synchronously.
1754
2279
  *
1755
2280
  * @param functionName - name of the function, as declared in the blueprint
1756
2281
  * @param request - payload and request options
2282
+ * @param options - invocation options
1757
2283
  */
1758
- invoke<R = unknown>(functionName: string, request?: InvokeFunctionRequest): Promise<R | undefined>;
2284
+ invoke(functionName: string, request?: InvokeFunctionRequest, options?: InvokeFunctionOptions & {
2285
+ sync?: false;
2286
+ }): Promise<undefined>;
2287
+ invoke<R = unknown>(functionName: string, request: InvokeFunctionRequest | undefined, options: InvokeFunctionOptions & {
2288
+ sync: true;
2289
+ }): Promise<R>;
2290
+ invoke<R = unknown>(functionName: string, request?: InvokeFunctionRequest, options?: InvokeFunctionOptions): Promise<R | undefined>;
1759
2291
  }
1760
2292
  /** @internal */
1761
2293
  declare class ObservableMediaLibraryVideoClient {
@@ -2351,6 +2883,10 @@ declare class ObservableSanityClient {
2351
2883
  agent: {
2352
2884
  action: ObservableAgentsActionClient;
2353
2885
  };
2886
+ collaboration: {
2887
+ /** @alpha */
2888
+ comments: ObservableCollaborationCommentsClient;
2889
+ };
2354
2890
  functions: ObservableFunctionsClient;
2355
2891
  releases: ObservableReleasesClient;
2356
2892
  /**
@@ -2981,6 +3517,10 @@ declare class SanityClient {
2981
3517
  agent: {
2982
3518
  action: AgentActionsClient;
2983
3519
  };
3520
+ collaboration: {
3521
+ /** @alpha */
3522
+ comments: CollaborationCommentsClient;
3523
+ };
2984
3524
  functions: FunctionsClient;
2985
3525
  releases: ReleasesClient;
2986
3526
  /**
@@ -4109,6 +4649,16 @@ interface ClientConfig {
4109
4649
  * ID of the organization owning the blueprints stack
4110
4650
  */
4111
4651
  organizationId?: string;
4652
+ /**
4653
+ * Organization-scoped configuration for collaboration APIs.
4654
+ *
4655
+ * Currently this is used by `collaboration.comments` methods.
4656
+ *
4657
+ * @alpha
4658
+ */
4659
+ collaboration?: {
4660
+ organizationId?: string;
4661
+ };
4112
4662
  }
4113
4663
  /** @public */
4114
4664
  interface InitializedClientConfig extends ClientConfig {
@@ -4590,8 +5140,13 @@ type ReleaseAction = CreateReleaseAction | EditReleaseAction | PublishReleaseAct
4590
5140
  type VariantDefinitionAction = CreateVariantDefinitionAction | EditVariantDefinitionAction | DeleteVariantDefinitionAction;
4591
5141
  /** @public */
4592
5142
  type VersionAction = CreateVersionAction | DiscardVersionAction | ReplaceVersionAction | UnpublishVersionAction;
5143
+ /**
5144
+ * @public
5145
+ * @beta
5146
+ */
5147
+ type VariantAction = CreateVariantAction | EditVariantAction | DeleteVariantAction | PublishVariantAction | UnpublishVariantAction;
4593
5148
  /** @public */
4594
- type Action = CreateAction | ReplaceDraftAction | EditAction | DeleteAction | DiscardAction | PublishAction | UnpublishAction | VersionAction | ReleaseAction | VariantDefinitionAction;
5149
+ type Action = CreateAction | ReplaceDraftAction | EditAction | DeleteAction | DiscardAction | PublishAction | UnpublishAction | VersionAction | VariantAction | ReleaseAction | VariantDefinitionAction;
4595
5150
  /** @public */
4596
5151
  type ImportReleaseAction = {
4597
5152
  actionType: 'sanity.action.release.import';
@@ -4730,6 +5285,175 @@ interface UnpublishVersionAction {
4730
5285
  versionId: string;
4731
5286
  publishedId: string;
4732
5287
  }
5288
+ /**
5289
+ * Creates a variant of a document, either by supplying the full document
5290
+ * content, or the base ID of a document to copy.
5291
+ *
5292
+ * @public
5293
+ * @beta
5294
+ */
5295
+ type CreateVariantAction = {
5296
+ actionType: 'sanity.action.document.variant.create';
5297
+ /**
5298
+ * ID of the document group to create a variant in. Must be a published
5299
+ * document ID, without a `drafts.` or `versions.` prefix.
5300
+ */
5301
+ publishedId: string;
5302
+ /**
5303
+ * Name of the variant definition this document belongs to, as in
5304
+ * `_.variants.{variantName}`. Must be a bare name, not a full document ID.
5305
+ */
5306
+ variantId: string;
5307
+ /**
5308
+ * Source bundle: `'drafts'`, or a release id.
5309
+ *
5310
+ * Defaults to the published bundle.
5311
+ */
5312
+ bundleId?: 'drafts' | (string & {});
5313
+ } & ({
5314
+ /**
5315
+ * The full document content. Requires a `_type` property.
5316
+ */
5317
+ document: SanityDocumentStub;
5318
+ baseId?: never;
5319
+ ifBaseRevisionId?: never;
5320
+ } | {
5321
+ /**
5322
+ * ID of an existing document to copy the content from.
5323
+ */
5324
+ baseId: string;
5325
+ /**
5326
+ * When set, the action fails unless the current revision of the base
5327
+ * document matches this value.
5328
+ */
5329
+ ifBaseRevisionId?: string;
5330
+ document?: never;
5331
+ });
5332
+ /**
5333
+ * Modifies a variant version of a document by applying a patch.
5334
+ *
5335
+ * If no such variant document exists it is first created, by copying the
5336
+ * variant's published sibling, or the published document if the variant was
5337
+ * never published.
5338
+ *
5339
+ * @public
5340
+ * @beta
5341
+ */
5342
+ interface EditVariantAction {
5343
+ actionType: 'sanity.action.document.variant.edit';
5344
+ /**
5345
+ * ID of the document group the variant belongs to. Must be a published
5346
+ * document ID, without a `drafts.` or `versions.` prefix.
5347
+ */
5348
+ publishedId: string;
5349
+ /**
5350
+ * Name of the variant definition this document belongs to, as in
5351
+ * `_.variants.{variantName}`. Must be a bare name, not a full document ID.
5352
+ */
5353
+ variantId: string;
5354
+ /**
5355
+ * Source bundle: `'drafts'`, or a release id.
5356
+ *
5357
+ * Defaults to the published bundle.
5358
+ */
5359
+ bundleId?: 'drafts' | (string & {});
5360
+ /**
5361
+ * Patch operations to apply.
5362
+ */
5363
+ patch: PatchOperations;
5364
+ }
5365
+ /**
5366
+ * Deletes a variant of a document.
5367
+ *
5368
+ * @public
5369
+ * @beta
5370
+ */
5371
+ interface DeleteVariantAction {
5372
+ actionType: 'sanity.action.document.variant.delete';
5373
+ /**
5374
+ * ID of the document group the variant belongs to. Must be a published
5375
+ * document ID, without a `drafts.` or `versions.` prefix.
5376
+ */
5377
+ publishedId: string;
5378
+ /**
5379
+ * Name of the variant definition this document belongs to, as in
5380
+ * `_.variants.{variantName}`. Must be a bare name, not a full document ID.
5381
+ */
5382
+ variantId: string;
5383
+ /**
5384
+ * Source bundle: `'drafts'`, or a release id.
5385
+ *
5386
+ * Defaults to the published bundle.
5387
+ */
5388
+ bundleId?: 'drafts' | (string & {});
5389
+ /**
5390
+ * Delete document history.
5391
+ */
5392
+ purge?: boolean;
5393
+ }
5394
+ /**
5395
+ * Publishes a variant version of a document, replacing the published variant
5396
+ * and removing the source variant document.
5397
+ *
5398
+ * @public
5399
+ * @beta
5400
+ */
5401
+ interface PublishVariantAction {
5402
+ actionType: 'sanity.action.document.variant.publish';
5403
+ /**
5404
+ * ID of the document group the variant belongs to. Must be a published
5405
+ * document ID, without a `drafts.` or `versions.` prefix.
5406
+ */
5407
+ publishedId: string;
5408
+ /**
5409
+ * Name of the variant definition this document belongs to, as in
5410
+ * `_.variants.{variantName}`. Must be a bare name, not a full document ID.
5411
+ */
5412
+ variantId: string;
5413
+ /**
5414
+ * Bundle to publish from: `'drafts'`, or a release id.
5415
+ */
5416
+ bundleId: 'drafts' | (string & {});
5417
+ /**
5418
+ * When set, publishing fails unless the current revision of the source
5419
+ * variant document matches this value.
5420
+ */
5421
+ ifVersionRevisionId?: string;
5422
+ /**
5423
+ * When set, publishing fails unless the current revision of the published
5424
+ * variant document matches this value.
5425
+ */
5426
+ ifPublishedVariantRevisionId?: string;
5427
+ }
5428
+ /**
5429
+ * Unpublishes a variant version of a document.
5430
+ *
5431
+ * By default the published variant is removed and preserved as a draft
5432
+ * variant. When a release id is given as the `bundleId`, the deletion is
5433
+ * instead staged in that release, and takes effect when it is published.
5434
+ *
5435
+ * @public
5436
+ * @beta
5437
+ */
5438
+ interface UnpublishVariantAction {
5439
+ actionType: 'sanity.action.document.variant.unpublish';
5440
+ /**
5441
+ * ID of the document group the variant belongs to. Must be a published
5442
+ * document ID, without a `drafts.` or `versions.` prefix.
5443
+ */
5444
+ publishedId: string;
5445
+ /**
5446
+ * Name of the variant definition this document belongs to, as in
5447
+ * `_.variants.{variantName}`. Must be a bare name, not a full document ID.
5448
+ */
5449
+ variantId: string;
5450
+ /**
5451
+ * The content release in which to stage the unpublish.
5452
+ *
5453
+ * By default, the currently published document is unpublished immediately.
5454
+ */
5455
+ bundleId?: string;
5456
+ }
4733
5457
  /**
4734
5458
  * Creates a new `system.variant` definition document.
4735
5459
  *
@@ -5998,5 +6722,5 @@ declare const createClient: (config: ClientConfig) => SanityClient;
5998
6722
  * @deprecated Use the named export `createClient` instead of the `default` export
5999
6723
  */
6000
6724
  declare const deprecatedCreateClient: (config: ClientConfig) => SanityClient;
6001
- export { Action, ActionError, ActionErrorItem, type AgentActionParam, type AgentActionParams, type AgentActionPath, type AgentActionPathSegment, type AgentActionTarget, AllDocumentIdsMutationOptions, AllDocumentsMutationOptions, AnimatedImageFormat, AnimatedTransformOptions, Any, ApiError, ArchiveReleaseAction, AssetMetadataType, type AssetsClient, AttributeSet, AuthProvider, AuthProviderResponse, BaseActionOptions, BaseMutationOptions, BasePatch, BaseTransaction, ChannelError, ChannelErrorEvent, ClientConfig, ClientError, ClientPerspective, ClientReturn, ClientVariant, ClientVariantConditions, ConnectionFailedError, type ConstantAgentActionParam, ContentSourceMap, ContentSourceMapDocument, ContentSourceMapDocumentBase, ContentSourceMapDocumentValueSource, ContentSourceMapDocuments, ContentSourceMapLiteralSource, ContentSourceMapMapping, ContentSourceMapMappings, type ContentSourceMapParsedPath, type ContentSourceMapParsedPathKeyedSegment, ContentSourceMapPaths, ContentSourceMapRemoteDocument, ContentSourceMapSource, ContentSourceMapUnknownSource, ContentSourceMapValueMapping, CorsOriginError, CreateAction, CreateReleaseAction, CreateVariantDefinitionAction, CreateVersionAction, CurrentSanityUser, DatasetAclMode, DatasetCreateOptions, DatasetEditOptions, DatasetResponse, type DatasetsClient, DatasetsResponse, DeleteAction, DeleteReleaseAction, DeleteVariantDefinitionAction, DiscardAction, DiscardVersionAction, DisconnectError, DisconnectEvent, type DocumentAgentActionParam, EXPERIMENTAL_API_WARNING, EditAction, EditReleaseAction, EditVariantDefinitionAction, EditableReleaseDocument, EmbeddingsSettings, EmbeddingsSettingsBody, ErrorProps, type EventSourceEvent, type EventSourceInstance, type FieldAgentActionParam, type FilterDefault, FilteredResponseQueryOptions, FirstDocumentIdMutationOptions, FirstDocumentMutationOptions, FitMode, type GenerateInstruction, type GenerateOperation, type GenerateTarget, type GenerateTargetDocument, type GenerateTargetInclude, type GroqAgentActionParam, type HttpError, HttpRequest, IdentifiedSanityDocumentStub, type ImageDescriptionOperation, ImportReleaseAction, InitializedClientConfig, type InitializedStegaConfig, InsertPatch, type InvokeFunctionEvent, type InvokeFunctionRequest, ListenEvent, ListenEventName, ListenOptions, ListenParams, type LiveClient, LiveEvent, LiveEventGoAway, LiveEventMessage, LiveEventReconnect, LiveEventRestart, LiveEventWelcome, type Logger, MediaLibraryAssetDocument, MediaLibraryAssetInstanceIdentifier, MediaLibraryAssetVersion, MediaLibraryPlaybackInfoOptions, type MediaLibraryVideoClient, MediaLibraryVideoPlaybackTransformations, MessageError, MessageParseError, MultipleActionResult, MultipleMutationResult, Mutation, MutationError, MutationErrorItem, MutationEvent, MutationOperation, MutationSelection, MutationSelectionQueryParams, type ObservableAssetsClient, type ObservableDatasetsClient, type ObservableMediaLibraryVideoClient, ObservablePatch, ObservablePatchBuilder, type ObservableProjectsClient, ObservableSanityClient, ObservableTransaction, type ObservableUsersClient, OpenEvent, PartialExcept, Patch, PatchBuilder, type PatchDocument, PatchMutationOperation, type PatchOperation, PatchOperations, PatchSelection, type PatchTarget, type ProjectsClient, type PromptRequest, PublishAction, PublishReleaseAction, QueryOptions, QueryParams, QueryParseError, QueryWithoutParams, RawQueryResponse, RawQuerylessQueryResponse, RawRequestOptions, ReconnectEvent, ReleaseAction, ReleaseCardinality, ReleaseDocument, ReleaseId, ReleaseState, ReleaseType, ReplaceDraftAction, ReplaceVersionAction, RequestHandler, RequestHandlerOptions, RequestObservableOptions, RequestOptions, RequestUrlOptions, Requester, ResetEvent, type ResolveStudioUrl, ResponseQueryOptions, ResumableListenEventNames, ResumableListenOptions, SanityAssetDocument, SanityClient, SanityDocument, SanityDocumentStub, SanityImageAssetDocument, SanityImagePalette, SanityProject, SanityProjectMember, SanityQueries, SanityReference, SanityUser, ScheduleReleaseAction, ServerError, type ServerSentEvent, SingleActionResult, SingleMutationResult, StackablePerspective, type StegaConfig, type StegaConfigRequiredKeys, StillImageFormat, StoryboardTransformOptions, type StudioBaseRoute, type StudioBaseUrl, type StudioUrl, SyncTag, ThumbnailTransformOptions, type TimeoutErrorLike, Transaction, TransactionAllDocumentIdsMutationOptions, TransactionAllDocumentsMutationOptions, TransactionFirstDocumentIdMutationOptions, TransactionFirstDocumentMutationOptions, TransactionMutationOptions, type TransformDocument, type TransformOperation, type TransformTarget, type TransformTargetDocument, type TransformTargetInclude, type TranslateDocument, type TranslateTarget, type TranslateTargetInclude, UnarchiveReleaseAction, UnfilteredResponseQueryOptions, UnfilteredResponseWithoutQuery, UnpublishAction, UnpublishVersionAction, UnscheduleReleaseAction, UploadBody, UploadClientConfig, UploadEvent, UploadProgressEvent, UploadResponseEvent, type UsersClient, VariantDefinitionAction, VersionAction, VideoPlaybackInfo, VideoPlaybackInfoItem, VideoPlaybackInfoItemPublic, VideoPlaybackInfoItemSigned, VideoPlaybackInfoPublic, VideoPlaybackInfoSigned, VideoPlaybackTokens, VideoRenditionInfo, VideoRenditionInfoPublic, VideoRenditionInfoSigned, VideoSubtitleInfo, VideoSubtitleInfoPublic, VideoSubtitleInfoSigned, WelcomeBackEvent, WelcomeEvent, type _listen, connectEventSource, createClient, deprecatedCreateClient as default, formatQueryParseError, isHttpError, isQueryParseError, isTimeoutError, requester, validateApiPerspective };
6725
+ export { Action, ActionError, ActionErrorItem, type AgentActionParam, type AgentActionParams, type AgentActionPath, type AgentActionPathSegment, type AgentActionTarget, AllDocumentIdsMutationOptions, AllDocumentsMutationOptions, AnimatedImageFormat, AnimatedTransformOptions, Any, ApiError, ArchiveReleaseAction, AssetMetadataType, type AssetsClient, AttributeSet, AuthProvider, AuthProviderResponse, BaseActionOptions, BaseMutationOptions, BasePatch, BaseTransaction, ChannelError, ChannelErrorEvent, ClientConfig, ClientError, ClientPerspective, ClientReturn, ClientVariant, ClientVariantConditions, type CollaborationCommentCreate, type CollaborationCommentDocument, type CollaborationCommentFieldValue, type CollaborationCommentMessage, type CollaborationCommentPortableTextBlock, type CollaborationCommentRange, type CollaborationCommentReactionShortName, type CollaborationCommentSelection, type CollaborationCommentStatus, type CollaborationCommentTarget, type CollaborationCommentUpdate, type CollaborationCommentsClient, type CollaborationCommentsListenOptions, type CollaborationCommentsRequestOptions, type CollaborationCommentsWriteOptions, ConnectionFailedError, type ConstantAgentActionParam, ContentSourceMap, ContentSourceMapDocument, ContentSourceMapDocumentBase, ContentSourceMapDocumentValueSource, ContentSourceMapDocuments, ContentSourceMapLiteralSource, ContentSourceMapMapping, ContentSourceMapMappings, type ContentSourceMapParsedPath, type ContentSourceMapParsedPathKeyedSegment, ContentSourceMapPaths, ContentSourceMapRemoteDocument, ContentSourceMapSource, ContentSourceMapUnknownSource, ContentSourceMapValueMapping, CorsOriginError, CreateAction, CreateReleaseAction, CreateVariantAction, CreateVariantDefinitionAction, CreateVersionAction, CurrentSanityUser, DatasetAclMode, DatasetCreateOptions, DatasetEditOptions, DatasetResponse, type DatasetsClient, DatasetsResponse, DeleteAction, DeleteReleaseAction, DeleteVariantAction, DeleteVariantDefinitionAction, DiscardAction, DiscardVersionAction, DisconnectError, DisconnectEvent, type DocumentAgentActionParam, EXPERIMENTAL_API_WARNING, EditAction, EditReleaseAction, EditVariantAction, EditVariantDefinitionAction, EditableReleaseDocument, EmbeddingsSettings, EmbeddingsSettingsBody, ErrorProps, type EventSourceEvent, type EventSourceInstance, type FieldAgentActionParam, type FilterDefault, FilteredResponseQueryOptions, FirstDocumentIdMutationOptions, FirstDocumentMutationOptions, FitMode, type GenerateInstruction, type GenerateOperation, type GenerateTarget, type GenerateTargetDocument, type GenerateTargetInclude, type GroqAgentActionParam, type HttpError, HttpRequest, IdentifiedSanityDocumentStub, type ImageDescriptionOperation, ImportReleaseAction, InitializedClientConfig, type InitializedStegaConfig, InsertPatch, type InvokeFunctionEvent, type InvokeFunctionOptions, type InvokeFunctionRequest, ListenEvent, ListenEventName, ListenOptions, ListenParams, type LiveClient, LiveEvent, LiveEventGoAway, LiveEventMessage, LiveEventReconnect, LiveEventRestart, LiveEventWelcome, type Logger, MediaLibraryAssetDocument, MediaLibraryAssetInstanceIdentifier, MediaLibraryAssetVersion, MediaLibraryPlaybackInfoOptions, type MediaLibraryVideoClient, MediaLibraryVideoPlaybackTransformations, MessageError, MessageParseError, MultipleActionResult, MultipleMutationResult, Mutation, MutationError, MutationErrorItem, MutationEvent, MutationOperation, MutationSelection, MutationSelectionQueryParams, type ObservableAssetsClient, type ObservableCollaborationCommentsClient, type ObservableDatasetsClient, type ObservableMediaLibraryVideoClient, ObservablePatch, ObservablePatchBuilder, type ObservableProjectsClient, ObservableSanityClient, ObservableTransaction, type ObservableUsersClient, OpenEvent, PartialExcept, Patch, PatchBuilder, type PatchDocument, PatchMutationOperation, type PatchOperation, PatchOperations, PatchSelection, type PatchTarget, type ProjectsClient, type PromptRequest, PublishAction, PublishReleaseAction, PublishVariantAction, QueryOptions, QueryParams, QueryParseError, QueryWithoutParams, RawQueryResponse, RawQuerylessQueryResponse, RawRequestOptions, ReconnectEvent, ReleaseAction, ReleaseCardinality, ReleaseDocument, ReleaseId, ReleaseState, ReleaseType, ReplaceDraftAction, ReplaceVersionAction, RequestHandler, RequestHandlerOptions, RequestObservableOptions, RequestOptions, RequestUrlOptions, Requester, ResetEvent, type ResolveStudioUrl, ResponseQueryOptions, ResumableListenEventNames, ResumableListenOptions, SanityAssetDocument, SanityClient, SanityDocument, SanityDocumentStub, SanityImageAssetDocument, SanityImagePalette, SanityProject, SanityProjectMember, SanityQueries, SanityReference, SanityUser, ScheduleReleaseAction, ServerError, type ServerSentEvent, SingleActionResult, SingleMutationResult, StackablePerspective, type StegaConfig, type StegaConfigRequiredKeys, StillImageFormat, StoryboardTransformOptions, type StudioBaseRoute, type StudioBaseUrl, type StudioUrl, SyncTag, ThumbnailTransformOptions, type TimeoutErrorLike, Transaction, TransactionAllDocumentIdsMutationOptions, TransactionAllDocumentsMutationOptions, TransactionFirstDocumentIdMutationOptions, TransactionFirstDocumentMutationOptions, TransactionMutationOptions, type TransformDocument, type TransformOperation, type TransformTarget, type TransformTargetDocument, type TransformTargetInclude, type TranslateDocument, type TranslateTarget, type TranslateTargetInclude, UnarchiveReleaseAction, UnfilteredResponseQueryOptions, UnfilteredResponseWithoutQuery, UnpublishAction, UnpublishVariantAction, UnpublishVersionAction, UnscheduleReleaseAction, UploadBody, UploadClientConfig, UploadEvent, UploadProgressEvent, UploadResponseEvent, type UsersClient, VariantAction, VariantDefinitionAction, VersionAction, VideoPlaybackInfo, VideoPlaybackInfoItem, VideoPlaybackInfoItemPublic, VideoPlaybackInfoItemSigned, VideoPlaybackInfoPublic, VideoPlaybackInfoSigned, VideoPlaybackTokens, VideoRenditionInfo, VideoRenditionInfoPublic, VideoRenditionInfoSigned, VideoSubtitleInfo, VideoSubtitleInfoPublic, VideoSubtitleInfoSigned, WelcomeBackEvent, WelcomeEvent, type _listen, connectEventSource, createClient, deprecatedCreateClient as default, formatQueryParseError, isHttpError, isQueryParseError, isTimeoutError, requester, validateApiPerspective };
6002
6726
  //# sourceMappingURL=index.node.d.ts.map