@sanity/client 8.1.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.
- package/README.md +171 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +408 -61
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +650 -2
- package/dist/index.node.js +379 -19
- package/dist/index.node.js.map +1 -1
- package/dist/media-library.d.ts +1 -1
- package/dist/{types-BODIEY7F.d.ts → types-nJhm5Nyq.d.ts} +651 -3
- package/package.json +1 -1
- package/src/SanityClient.ts +20 -0
- package/src/collaboration/CollaborationCommentsClient.ts +387 -0
- package/src/collaboration/comments.ts +313 -0
- package/src/collaboration/types.ts +252 -0
- package/src/data/dataMethods.ts +7 -1
- package/src/data/listen.ts +20 -5
- package/src/types.ts +234 -0
|
@@ -1140,6 +1140,462 @@ declare function _listen<R extends Record<string, Any$1> = Record<string, Any$1>
|
|
|
1140
1140
|
* @public
|
|
1141
1141
|
*/
|
|
1142
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
|
+
}
|
|
1143
1599
|
/**
|
|
1144
1600
|
* @public
|
|
1145
1601
|
*/
|
|
@@ -2267,6 +2723,10 @@ declare class ObservableSanityClient$1 {
|
|
|
2267
2723
|
agent: {
|
|
2268
2724
|
action: ObservableAgentsActionClient;
|
|
2269
2725
|
};
|
|
2726
|
+
collaboration: {
|
|
2727
|
+
/** @alpha */
|
|
2728
|
+
comments: ObservableCollaborationCommentsClient;
|
|
2729
|
+
};
|
|
2270
2730
|
functions: ObservableFunctionsClient;
|
|
2271
2731
|
releases: ObservableReleasesClient;
|
|
2272
2732
|
/**
|
|
@@ -2897,6 +3357,10 @@ declare class SanityClient$1 {
|
|
|
2897
3357
|
agent: {
|
|
2898
3358
|
action: AgentActionsClient;
|
|
2899
3359
|
};
|
|
3360
|
+
collaboration: {
|
|
3361
|
+
/** @alpha */
|
|
3362
|
+
comments: CollaborationCommentsClient;
|
|
3363
|
+
};
|
|
2900
3364
|
functions: FunctionsClient;
|
|
2901
3365
|
releases: ReleasesClient;
|
|
2902
3366
|
/**
|
|
@@ -4025,6 +4489,16 @@ interface ClientConfig$1 {
|
|
|
4025
4489
|
* ID of the organization owning the blueprints stack
|
|
4026
4490
|
*/
|
|
4027
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
|
+
};
|
|
4028
4502
|
}
|
|
4029
4503
|
/** @public */
|
|
4030
4504
|
interface InitializedClientConfig$1 extends ClientConfig$1 {
|
|
@@ -4506,8 +4980,13 @@ type ReleaseAction = CreateReleaseAction | EditReleaseAction | PublishReleaseAct
|
|
|
4506
4980
|
type VariantDefinitionAction = CreateVariantDefinitionAction | EditVariantDefinitionAction | DeleteVariantDefinitionAction;
|
|
4507
4981
|
/** @public */
|
|
4508
4982
|
type VersionAction = CreateVersionAction | DiscardVersionAction | ReplaceVersionAction | UnpublishVersionAction;
|
|
4983
|
+
/**
|
|
4984
|
+
* @public
|
|
4985
|
+
* @beta
|
|
4986
|
+
*/
|
|
4987
|
+
type VariantAction = CreateVariantAction | EditVariantAction | DeleteVariantAction | PublishVariantAction | UnpublishVariantAction;
|
|
4509
4988
|
/** @public */
|
|
4510
|
-
type Action = CreateAction | ReplaceDraftAction | EditAction | DeleteAction | DiscardAction | PublishAction | UnpublishAction | VersionAction | ReleaseAction | VariantDefinitionAction;
|
|
4989
|
+
type Action = CreateAction | ReplaceDraftAction | EditAction | DeleteAction | DiscardAction | PublishAction | UnpublishAction | VersionAction | VariantAction | ReleaseAction | VariantDefinitionAction;
|
|
4511
4990
|
/** @public */
|
|
4512
4991
|
type ImportReleaseAction = {
|
|
4513
4992
|
actionType: 'sanity.action.release.import';
|
|
@@ -4646,6 +5125,175 @@ interface UnpublishVersionAction {
|
|
|
4646
5125
|
versionId: string;
|
|
4647
5126
|
publishedId: string;
|
|
4648
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
|
+
}
|
|
4649
5297
|
/**
|
|
4650
5298
|
* Creates a new `system.variant` definition document.
|
|
4651
5299
|
*
|
|
@@ -5736,5 +6384,5 @@ interface MediaLibraryAssetDocument {
|
|
|
5736
6384
|
parent?: SanityReference | null;
|
|
5737
6385
|
rootDirectory?: Any$1;
|
|
5738
6386
|
}
|
|
5739
|
-
export {
|
|
5740
|
-
//# sourceMappingURL=types-
|
|
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
|