@larc-iu/plaid-client 0.2.0-alpha.18 → 0.2.0-alpha.20

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/index.d.ts CHANGED
@@ -1,3 +1,12 @@
1
+ /**
2
+ * A config write's compare-and-set. With `expected` present (null or
3
+ * undefined for a key that was absent) the write is refused with a 409 when
4
+ * the stored value is no longer `expected`.
5
+ */
6
+ interface ConfigWriteOptions {
7
+ expected?: any;
8
+ }
9
+
1
10
  /** A single page of a cursor-paginated collection. */
2
11
  interface Page<T = any> {
3
12
  entries: T[];
@@ -150,6 +159,7 @@ interface VocabLinksBundle {
150
159
  tokens: any[],
151
160
  metadata?: any,
152
161
  auditMessage?: string,
162
+ opts?: { id?: string },
153
163
  ): Promise<any>;
154
164
  bulkCreate(body: any[], auditMessage?: string): Promise<{ ids: string[] }>;
155
165
  bulkDelete(body: any[], auditMessage?: string): Promise<void>;
@@ -184,6 +194,7 @@ interface VocabLayersBundle {
184
194
  endTime?: string,
185
195
  opTypes?: string[] | string,
186
196
  itemId?: string,
197
+ kinds?: OperationKind[] | string,
187
198
  ): Promise<any[]>;
188
199
  auditPage(id: string, opts?: AuditPageOptions & { itemId?: string }): Promise<Page>;
189
200
  /** Put one entry back as it was at `asOf`. Maintainers of the vocabulary only. */
@@ -202,17 +213,19 @@ interface VocabLayersBundle {
202
213
  configKey: string,
203
214
  configValue: any,
204
215
  auditMessage?: string,
216
+ options?: ConfigWriteOptions,
205
217
  ): Promise<any>;
206
218
  deleteConfig(
207
219
  id: string,
208
220
  namespace: string,
209
221
  configKey: string,
210
222
  auditMessage?: string,
223
+ options?: ConfigWriteOptions,
211
224
  ): Promise<any>;
212
225
  list(): Promise<any[]>;
213
226
  listPage(opts?: { limit?: number; cursor?: string }): Promise<Page>;
214
227
  iterPages(opts?: { pageSize?: number }): AsyncGenerator<any[]>;
215
- create(name: string, auditMessage?: string): Promise<any>;
228
+ create(name: string, auditMessage?: string, opts?: { id?: string }): Promise<any>;
216
229
  addMaintainer(
217
230
  id: string,
218
231
  userId: string,
@@ -257,6 +270,7 @@ interface RelationsBundle {
257
270
  value: any,
258
271
  metadata?: any,
259
272
  auditMessage?: string,
273
+ opts?: { id?: string },
260
274
  ): Promise<any>;
261
275
  bulkCreate(body: any[], auditMessage?: string): Promise<{ ids: string[] }>;
262
276
  bulkDelete(body: any[], auditMessage?: string): Promise<void>;
@@ -270,12 +284,14 @@ interface SpanLayersBundle {
270
284
  configKey: string,
271
285
  configValue: any,
272
286
  auditMessage?: string,
287
+ options?: ConfigWriteOptions,
273
288
  ): Promise<any>;
274
289
  deleteConfig(
275
290
  spanLayerId: string,
276
291
  namespace: string,
277
292
  configKey: string,
278
293
  auditMessage?: string,
294
+ options?: ConfigWriteOptions,
279
295
  ): Promise<any>;
280
296
  get(spanLayerId: string): Promise<any>;
281
297
  delete(spanLayerId: string, auditMessage?: string): Promise<any>;
@@ -288,12 +304,41 @@ interface SpanLayersBundle {
288
304
  tokenLayerId: string,
289
305
  name: string,
290
306
  auditMessage?: string,
307
+ opts?: { id?: string },
291
308
  ): Promise<any>;
292
309
  shift(
293
310
  spanLayerId: string,
294
311
  direction: string,
295
312
  auditMessage?: string,
296
313
  ): Promise<any>;
314
+ setConstraints(
315
+ layerId: string,
316
+ namespace: string,
317
+ constraints: LayerConstraint[],
318
+ auditMessage?: string,
319
+ options?: ConstraintWriteOptions,
320
+ ): Promise<{ constraints: Record<string, LayerConstraint[]> }>;
321
+ deleteConstraints(
322
+ layerId: string,
323
+ namespace: string,
324
+ auditMessage?: string,
325
+ options?: ConstraintWriteOptions,
326
+ ): Promise<any>;
327
+ checkConstraints(
328
+ layerId: string,
329
+ constraints: LayerConstraint[],
330
+ ): Promise<{ violations: ConstraintViolation[]; violationCount: number }>;
331
+ repairConstraints(
332
+ layerId: string,
333
+ constraints: LayerConstraint[],
334
+ auditMessage?: string,
335
+ options?: { document?: string },
336
+ ): Promise<{
337
+ repaired: { document: string; constraint: string; deleted: number; joined: number }[];
338
+ locked: { document: string; lockedBy: string }[];
339
+ violations: ConstraintViolation[];
340
+ violationCount: number;
341
+ }>;
297
342
  }
298
343
 
299
344
  interface SpansBundle {
@@ -304,6 +349,7 @@ interface SpansBundle {
304
349
  value: any,
305
350
  metadata?: any,
306
351
  auditMessage?: string,
352
+ opts?: { id?: string },
307
353
  ): Promise<any>;
308
354
  get(spanId: string): Promise<any>;
309
355
  delete(spanId: string, auditMessage?: string): Promise<any>;
@@ -326,10 +372,14 @@ interface TextsBundle {
326
372
  body: string,
327
373
  metadata?: any,
328
374
  auditMessage?: string,
375
+ opts?: { id?: string },
329
376
  ): Promise<any>;
330
377
  get(textId: string): Promise<any>;
331
378
  delete(textId: string, auditMessage?: string): Promise<any>;
332
- update(textId: string, body: any, auditMessage?: string): Promise<any>;
379
+ /** With `base` (a text's `digest`) the update applies only to that body. */
380
+ update(textId: string, body: any, auditMessage?: string, opts?: { base?: string; versioned?: boolean }): Promise<any>;
381
+ /** Edits made at the caret; with `base` they apply only to that body. Answers the text with `digest` and `reshape`. */
382
+ edit(textId: string, edits: TextEditOp[], auditMessage?: string, opts?: { base?: string; versioned?: boolean }): Promise<any>;
333
383
  }
334
384
 
335
385
  interface UsersBundle {
@@ -349,6 +399,7 @@ interface UsersBundle {
349
399
  startTime?: string,
350
400
  endTime?: string,
351
401
  opTypes?: string[] | string,
402
+ kinds?: OperationKind[] | string,
352
403
  ): Promise<any[]>;
353
404
  auditPage(userId: string, opts?: AuditPageOptions): Promise<Page>;
354
405
  get(id: string): Promise<any>;
@@ -437,7 +488,7 @@ interface GuidelinesBundle {
437
488
  create(
438
489
  projectId: string,
439
490
  title: string,
440
- opts?: { body?: string; pinned?: boolean },
491
+ opts?: { body?: string; pinned?: boolean; id?: string },
441
492
  auditMessage?: string,
442
493
  ): Promise<{ id: string }>;
443
494
  get(id: string): Promise<Guideline>;
@@ -555,7 +606,7 @@ interface CommentsBundle {
555
606
  entityType: CommentableType,
556
607
  entityId: string,
557
608
  body: string,
558
- opts?: { anchorLabel?: string },
609
+ opts?: { anchorLabel?: string; id?: string },
559
610
  ): Promise<Comment>;
560
611
  get(id: string): Promise<Comment>;
561
612
  update(id: string, body: string): Promise<Comment>;
@@ -866,6 +917,8 @@ interface AuditPageOptions {
866
917
  startTime?: string;
867
918
  endTime?: string;
868
919
  opTypes?: string[] | string;
920
+ /** Only the entries of operations of these kinds, each whole. */
921
+ kinds?: OperationKind[] | string;
869
922
  /** "desc" pages newest-first; a cursor belongs to the direction that made it. */
870
923
  order?: "asc" | "desc";
871
924
  limit?: number;
@@ -890,6 +943,7 @@ interface AuditBundle {
890
943
  startTime?: string;
891
944
  endTime?: string;
892
945
  opTypes?: string[] | string;
946
+ kinds?: OperationKind[] | string;
893
947
  }): Promise<any[]>;
894
948
  /** Admin only. */
895
949
  listPage(opts?: AuditPageOptions): Promise<Page>;
@@ -898,6 +952,7 @@ interface AuditBundle {
898
952
  startTime?: string;
899
953
  endTime?: string;
900
954
  opTypes?: string[] | string;
955
+ kinds?: OperationKind[] | string;
901
956
  pageSize?: number;
902
957
  }): AsyncGenerator<any[]>;
903
958
  /** With projectId, open to that project's maintainers; without one, admin only. */
@@ -942,6 +997,7 @@ interface TokenLayersBundle {
942
997
  overlapMode?: string,
943
998
  parentTokenLayerId?: string,
944
999
  auditMessage?: string,
1000
+ opts?: { id?: string },
945
1001
  ): Promise<any>;
946
1002
  setConfig(
947
1003
  tokenLayerId: string,
@@ -949,12 +1005,14 @@ interface TokenLayersBundle {
949
1005
  configKey: string,
950
1006
  configValue: any,
951
1007
  auditMessage?: string,
1008
+ options?: ConfigWriteOptions,
952
1009
  ): Promise<any>;
953
1010
  deleteConfig(
954
1011
  tokenLayerId: string,
955
1012
  namespace: string,
956
1013
  configKey: string,
957
1014
  auditMessage?: string,
1015
+ options?: ConfigWriteOptions,
958
1016
  ): Promise<any>;
959
1017
  get(tokenLayerId: string): Promise<any>;
960
1018
  delete(tokenLayerId: string, auditMessage?: string): Promise<any>;
@@ -963,6 +1021,34 @@ interface TokenLayersBundle {
963
1021
  name: string,
964
1022
  auditMessage?: string,
965
1023
  ): Promise<any>;
1024
+ setConstraints(
1025
+ layerId: string,
1026
+ namespace: string,
1027
+ constraints: LayerConstraint[],
1028
+ auditMessage?: string,
1029
+ options?: ConstraintWriteOptions,
1030
+ ): Promise<{ constraints: Record<string, LayerConstraint[]> }>;
1031
+ deleteConstraints(
1032
+ layerId: string,
1033
+ namespace: string,
1034
+ auditMessage?: string,
1035
+ options?: ConstraintWriteOptions,
1036
+ ): Promise<any>;
1037
+ checkConstraints(
1038
+ layerId: string,
1039
+ constraints: LayerConstraint[],
1040
+ ): Promise<{ violations: ConstraintViolation[]; violationCount: number }>;
1041
+ repairConstraints(
1042
+ layerId: string,
1043
+ constraints: LayerConstraint[],
1044
+ auditMessage?: string,
1045
+ options?: { document?: string },
1046
+ ): Promise<{
1047
+ repaired: { document: string; constraint: string; deleted: number; joined: number }[];
1048
+ locked: { document: string; lockedBy: string }[];
1049
+ violations: ConstraintViolation[];
1050
+ violationCount: number;
1051
+ }>;
966
1052
  }
967
1053
 
968
1054
  /** Handle passed to a `documents.locked()` block. */
@@ -988,8 +1074,16 @@ export const DOCUMENT_LOCK_TTL_MS: 60000;
988
1074
 
989
1075
  interface DocumentsBundle {
990
1076
  checkLock(documentId: string): Promise<any>;
991
- /** Take the lock as a new holder. The answer's `lockId` names it. */
992
- acquireLock(documentId: string, auditMessage?: string): Promise<any>;
1077
+ /**
1078
+ * Take the lock as a new holder. The answer's `lockId` names it:
1079
+ * `newLockId` when the client minted one, which makes a retried acquire
1080
+ * idempotent and a lost answer releasable.
1081
+ */
1082
+ acquireLock(
1083
+ documentId: string,
1084
+ auditMessage?: string,
1085
+ newLockId?: string,
1086
+ ): Promise<any>;
993
1087
  /** Renew `lockId`'s lock while it is live. 423 once it has lapsed. */
994
1088
  renewLock(
995
1089
  documentId: string,
@@ -1038,6 +1132,7 @@ interface DocumentsBundle {
1038
1132
  startTime?: string,
1039
1133
  endTime?: string,
1040
1134
  opTypes?: string[] | string,
1135
+ kinds?: OperationKind[] | string,
1041
1136
  ): Promise<any[]>;
1042
1137
  auditPage(documentId: string, opts?: AuditPageOptions): Promise<Page>;
1043
1138
  /**
@@ -1057,12 +1152,13 @@ interface DocumentsBundle {
1057
1152
  name: string,
1058
1153
  metadata?: any,
1059
1154
  auditMessage?: string,
1155
+ opts?: { id?: string },
1060
1156
  ): Promise<any>;
1061
1157
  /** Copy a document and everything in it into a new document of the same project. */
1062
1158
  copy(
1063
1159
  documentId: string,
1064
1160
  name: string,
1065
- options?: { includeMedia?: boolean },
1161
+ options?: { includeMedia?: boolean; id?: string },
1066
1162
  auditMessage?: string,
1067
1163
  ): Promise<{ id: string; mediaError?: string }>;
1068
1164
  restore(
@@ -1154,12 +1250,14 @@ interface ProjectsBundle {
1154
1250
  configKey: string,
1155
1251
  configValue: any,
1156
1252
  auditMessage?: string,
1253
+ options?: ConfigWriteOptions,
1157
1254
  ): Promise<any>;
1158
1255
  deleteConfig(
1159
1256
  id: string,
1160
1257
  namespace: string,
1161
1258
  configKey: string,
1162
1259
  auditMessage?: string,
1260
+ options?: ConfigWriteOptions,
1163
1261
  ): Promise<any>;
1164
1262
  addMaintainer(
1165
1263
  id: string,
@@ -1176,6 +1274,7 @@ interface ProjectsBundle {
1176
1274
  startTime?: string,
1177
1275
  endTime?: string,
1178
1276
  opTypes?: string[] | string,
1277
+ kinds?: OperationKind[] | string,
1179
1278
  ): Promise<any[]>;
1180
1279
  auditPage(projectId: string, opts?: AuditPageOptions): Promise<Page>;
1181
1280
  /**
@@ -1206,7 +1305,7 @@ interface ProjectsBundle {
1206
1305
  list(): Promise<any[]>;
1207
1306
  listPage(opts?: { limit?: number; cursor?: string }): Promise<Page>;
1208
1307
  iterPages(opts?: { pageSize?: number }): AsyncGenerator<any[]>;
1209
- create(name: string, auditMessage?: string): Promise<any>;
1308
+ create(name: string, auditMessage?: string, opts?: { id?: string }): Promise<any>;
1210
1309
  }
1211
1310
 
1212
1311
  interface TextLayersBundle {
@@ -1216,12 +1315,14 @@ interface TextLayersBundle {
1216
1315
  configKey: string,
1217
1316
  configValue: any,
1218
1317
  auditMessage?: string,
1318
+ options?: ConfigWriteOptions,
1219
1319
  ): Promise<any>;
1220
1320
  deleteConfig(
1221
1321
  textLayerId: string,
1222
1322
  namespace: string,
1223
1323
  configKey: string,
1224
1324
  auditMessage?: string,
1325
+ options?: ConfigWriteOptions,
1225
1326
  ): Promise<any>;
1226
1327
  get(textLayerId: string): Promise<any>;
1227
1328
  delete(textLayerId: string, auditMessage?: string): Promise<any>;
@@ -1235,7 +1336,7 @@ interface TextLayersBundle {
1235
1336
  direction: string,
1236
1337
  auditMessage?: string,
1237
1338
  ): Promise<any>;
1238
- create(projectId: string, name: string, auditMessage?: string): Promise<any>;
1339
+ create(projectId: string, name: string, auditMessage?: string, opts?: { id?: string }): Promise<any>;
1239
1340
  }
1240
1341
 
1241
1342
  interface VocabItemsBundle {
@@ -1247,12 +1348,22 @@ interface VocabItemsBundle {
1247
1348
  form: string,
1248
1349
  metadata?: any,
1249
1350
  auditMessage?: string,
1351
+ opts?: { id?: string },
1250
1352
  ): Promise<any>;
1251
1353
  bulkCreate(body: any[], auditMessage?: string): Promise<{ ids: string[] }>;
1252
1354
  bulkDelete(body: any[], auditMessage?: string): Promise<void>;
1253
1355
  bulkUpdate(body: any[], auditMessage?: string): Promise<{ count: number }>;
1254
1356
  get(id: string): Promise<any>;
1255
- delete(id: string, auditMessage?: string): Promise<any>;
1357
+ delete(
1358
+ id: string,
1359
+ auditMessage?: string,
1360
+ options?: { expectedLinkCount?: number },
1361
+ ): Promise<any>;
1362
+ merge(
1363
+ survivorId: string,
1364
+ loserIds: string[],
1365
+ auditMessage?: string,
1366
+ ): Promise<{ moved: number; duplicates: number; removed: string[] }>;
1256
1367
  update(id: string, form: string, auditMessage?: string): Promise<any>;
1257
1368
  }
1258
1369
 
@@ -1266,6 +1377,7 @@ interface RelationLayersBundle {
1266
1377
  spanLayerId: string,
1267
1378
  name: string,
1268
1379
  auditMessage?: string,
1380
+ opts?: { id?: string },
1269
1381
  ): Promise<any>;
1270
1382
  setConfig(
1271
1383
  relationLayerId: string,
@@ -1273,12 +1385,14 @@ interface RelationLayersBundle {
1273
1385
  configKey: string,
1274
1386
  configValue: any,
1275
1387
  auditMessage?: string,
1388
+ options?: ConfigWriteOptions,
1276
1389
  ): Promise<any>;
1277
1390
  deleteConfig(
1278
1391
  relationLayerId: string,
1279
1392
  namespace: string,
1280
1393
  configKey: string,
1281
1394
  auditMessage?: string,
1395
+ options?: ConfigWriteOptions,
1282
1396
  ): Promise<any>;
1283
1397
  get(relationLayerId: string): Promise<any>;
1284
1398
  delete(relationLayerId: string, auditMessage?: string): Promise<any>;
@@ -1287,6 +1401,34 @@ interface RelationLayersBundle {
1287
1401
  name: string,
1288
1402
  auditMessage?: string,
1289
1403
  ): Promise<any>;
1404
+ setConstraints(
1405
+ layerId: string,
1406
+ namespace: string,
1407
+ constraints: LayerConstraint[],
1408
+ auditMessage?: string,
1409
+ options?: ConstraintWriteOptions,
1410
+ ): Promise<{ constraints: Record<string, LayerConstraint[]> }>;
1411
+ deleteConstraints(
1412
+ layerId: string,
1413
+ namespace: string,
1414
+ auditMessage?: string,
1415
+ options?: ConstraintWriteOptions,
1416
+ ): Promise<any>;
1417
+ checkConstraints(
1418
+ layerId: string,
1419
+ constraints: LayerConstraint[],
1420
+ ): Promise<{ violations: ConstraintViolation[]; violationCount: number }>;
1421
+ repairConstraints(
1422
+ layerId: string,
1423
+ constraints: LayerConstraint[],
1424
+ auditMessage?: string,
1425
+ options?: { document?: string },
1426
+ ): Promise<{
1427
+ repaired: { document: string; constraint: string; deleted: number; joined: number }[];
1428
+ locked: { document: string; lockedBy: string }[];
1429
+ violations: ConstraintViolation[];
1430
+ violationCount: number;
1431
+ }>;
1290
1432
  }
1291
1433
 
1292
1434
  interface TokensBundle {
@@ -1298,6 +1440,7 @@ interface TokensBundle {
1298
1440
  precedence?: number | null,
1299
1441
  metadata?: any,
1300
1442
  auditMessage?: string,
1443
+ opts?: { id?: string },
1301
1444
  ): Promise<any>;
1302
1445
  get(tokenId: string): Promise<any>;
1303
1446
  delete(tokenId: string, auditMessage?: string): Promise<any>;
@@ -1311,7 +1454,12 @@ interface TokensBundle {
1311
1454
  bulkCreate(body: any[], auditMessage?: string): Promise<{ ids: string[] }>;
1312
1455
  bulkDelete(body: any[], auditMessage?: string): Promise<void>;
1313
1456
  bulkUpdate(body: any[], auditMessage?: string): Promise<{ count: number }>;
1314
- split(tokenId: string, position: number, auditMessage?: string): Promise<any>;
1457
+ split(
1458
+ tokenId: string,
1459
+ position: number,
1460
+ auditMessage?: string,
1461
+ options?: { id?: string },
1462
+ ): Promise<any>;
1315
1463
  merge(
1316
1464
  tokenId: string,
1317
1465
  otherTokenId: string,
@@ -1342,6 +1490,11 @@ interface PlaidClientOptions {
1342
1490
  * write lock. Defaults to `timeout` when that is given and this is not.
1343
1491
  */
1344
1492
  batchTimeout?: number | null;
1493
+ /**
1494
+ * Delays in ms before sending a keyed write again when its answer was lost
1495
+ * (no response, 502 or 504). Default [1000, 3000, 9000].
1496
+ */
1497
+ retryDelaysMs?: number[];
1345
1498
  /**
1346
1499
  * Fired once when a request returns HTTP 401 (missing/expired/invalid token).
1347
1500
  * Use it to discard the stored token and route back to login. 403 (forbidden)
@@ -1357,7 +1510,8 @@ export type OperationKind =
1357
1510
  | 'import'
1358
1511
  | 'bulk-edit'
1359
1512
  | 'guess-adoption'
1360
- | 'repair';
1513
+ | 'repair'
1514
+ | 'review';
1361
1515
 
1362
1516
  export interface OperationGroupsBundle {
1363
1517
  get(id: string): Promise<any>;
@@ -1384,6 +1538,27 @@ export interface PlaidBatch extends PlaidClient {
1384
1538
  submit(): Promise<any[]>;
1385
1539
  /** Drop the queued operations without sending them. */
1386
1540
  abort(): void;
1541
+ /**
1542
+ * A stand-in for the id a queued operation will create, to put in a later
1543
+ * operation's body on this batch, so a create and the write that uses it go
1544
+ * in one transaction: op n's `id`, or with `index` the k-th of the `ids` a
1545
+ * bulk create answers. `opIndex` counts from 0, or from the end when
1546
+ * negative (-1, the default, is the op queued last). It goes only in the
1547
+ * body of a later write on this batch, at any depth. Anywhere else (a path,
1548
+ * another batch, a call made on the client) the client refuses it.
1549
+ */
1550
+ ref(opIndex?: number, index?: number): BatchRef;
1551
+ }
1552
+
1553
+ /**
1554
+ * See `PlaidBatch.ref`. A marker object, not data: the client takes it out of
1555
+ * the body when its write is queued and sends where it was beside the body.
1556
+ */
1557
+ export interface BatchRef {
1558
+ /** The op, counted from 0 in the batch, whose id this stands for. */
1559
+ readonly $ref: number;
1560
+ /** For a bulk create, which of its ids. */
1561
+ readonly index?: number;
1387
1562
  }
1388
1563
 
1389
1564
  export declare class PlaidClient {
@@ -1425,6 +1600,7 @@ export declare class PlaidClient {
1425
1600
  token: string;
1426
1601
  timeout: number | null;
1427
1602
  batchTimeout: number | null;
1603
+ retryDelaysMs: number[] | undefined;
1428
1604
  /** The document strict mode is entered for, or null. */
1429
1605
  readonly strictModeDocumentId: string | null;
1430
1606
  /** The DocumentLockLost of the open `locked()` block whose lock lapsed, or null. Cleared when that block exits. */
@@ -1472,13 +1648,15 @@ export declare class PlaidClient {
1472
1648
  } | null;
1473
1649
  beginOperation(
1474
1650
  message: string,
1475
- opts?: { id?: string; kind?: OperationKind; ref?: string },
1651
+ opts?: { id?: string; kind?: OperationKind; ref?: string; keys?: KeySeed; minted?: Set<string> },
1476
1652
  ): string;
1653
+ /** A seed for the Idempotency-Keys of an operation that may be run again (see beginOperation's `keys`). */
1654
+ keySeed(): KeySeed;
1477
1655
  endOperation(message?: string): Promise<void>;
1478
1656
  withOperation<T>(
1479
1657
  message: string,
1480
1658
  fn: (setMessage: (msg: string) => void) => Promise<T> | T,
1481
- opts?: { kind?: OperationKind; ref?: string },
1659
+ opts?: { kind?: OperationKind; ref?: string; id?: string; keys?: KeySeed; minted?: Set<string> },
1482
1660
  ): Promise<T>;
1483
1661
  operationGroups: OperationGroupsBundle;
1484
1662
 
@@ -1529,6 +1707,25 @@ export function cpToUtf16(s: string, cp: number): number;
1529
1707
  /** Like indexOf, but the result and `fromCp` are code-point indices; -1 if absent. */
1530
1708
  export function cpIndexOf(s: string, sub: string, fromCp?: number): number;
1531
1709
 
1710
+ // --- Text edit operations (code points, running coordinates) ---------------
1711
+ /** One op as `PATCH /texts/:id` takes it; each index is in the body the ops before it left. */
1712
+ export type TextEditOp =
1713
+ | { type: "insert"; index: number; value: string }
1714
+ | { type: "delete"; index: number; value: number }
1715
+ | { type: "replace"; index: number; length: number; value: string };
1716
+ /** Old-body code points [start, end) give way to `value`. */
1717
+ export interface TextGap {
1718
+ start: number;
1719
+ end: number;
1720
+ value: string;
1721
+ }
1722
+ /** The net change of `ops` on `body` as gaps: sorted, never touching, no-op gaps dropped. Throws on a bad op. */
1723
+ export function composeTextEdits(body: string, ops: TextEditOp[]): TextGap[];
1724
+ /** Gaps as running ops: insert, delete or replace. */
1725
+ export function gapsToOps(gaps: TextGap[]): TextEditOp[];
1726
+ /** `body` with `ops` applied in turn. Throws on a bad op. */
1727
+ export function applyTextOps(body: string, ops: TextEditOp[]): string;
1728
+
1532
1729
  // --- Shared layer-role vocabulary (cross-app interoperability) --------------
1533
1730
  // Substrate layers are tagged with a role at `config.plaid.role` (a scalar) so
1534
1731
  // that different apps can share a project. See the manual, "Layer Interoperability".
@@ -1538,6 +1735,10 @@ export const PLAID_NAMESPACE: "plaid";
1538
1735
  export const ROLE_KEY: "role";
1539
1736
  /** Layer config key naming the metadata keys a token born of a SPLIT inherits. */
1540
1737
  export const PRESERVE_ON_SPLIT_KEY: "preserveOnSplit";
1738
+ /** Layer config key asking Plaid to take a text edit plainly on the layer (see the manual's "Changing a text's body"). */
1739
+ export const PLAIN_EDITS_KEY: "plainEdits";
1740
+ /** Layer config key: a space typed inside a word of the text splits it (beside plainEdits). */
1741
+ export const SPLIT_ON_SPACE_KEY: "splitOnSpace";
1541
1742
 
1542
1743
  /** The server's cap on operations per batch request; a larger batch goes as consecutive requests. */
1543
1744
  export const MAX_BATCH_OPS: 1000;
@@ -1691,6 +1892,15 @@ export function mergeMetadata(
1691
1892
 
1692
1893
  // --- Create responses ---------------------------------------------------------
1693
1894
  /** The id a single create answered with, read off the call's response or its batch result (`{status, body}`). Undefined when it gave none. */
1895
+ /** Idempotency-Key seed for an operation run more than once (client.keySeed()). */
1896
+ export interface KeySeed {
1897
+ seed: string;
1898
+ stamps: Map<number, number | null>;
1899
+ }
1900
+ /** A fresh UUIDv7, for the id of something a client creates. */
1901
+ export function uuidv7(): string;
1902
+ /** Whether a write's answer was replayed from its Idempotency-Key's first send (`Idempotent-Replayed: true`), so it wrote nothing new. Marked on an object or list answer as a non-enumerable `replayed: true`. */
1903
+ export function wasReplayed(answer: unknown): boolean;
1694
1904
  export function createdId(result: any): string | undefined;
1695
1905
  /** The ids a bulk create answered with, in input order, read off the call's response or its batch result. Empty when it gave none. */
1696
1906
  export function createdIds(result: any): string[];
@@ -1764,3 +1974,41 @@ export function writerPolicy(contributorId?: string | null): {
1764
1974
  /** The same test over a provState. */
1765
1975
  readonly reviewableState: (state: string) => boolean;
1766
1976
  };
1977
+
1978
+ // --- Layer constraints -------------------------------------------------------
1979
+ /** A constraint an app declares on a layer, e.g. {type: "value-set", values: ["N"]}. */
1980
+ export interface LayerConstraint {
1981
+ type:
1982
+ | "max-in-degree"
1983
+ | "acyclic"
1984
+ | "same-ancestor"
1985
+ | "single-span"
1986
+ | "value-set"
1987
+ | "coextensive"
1988
+ | "single-link";
1989
+ [param: string]: any;
1990
+ }
1991
+ /** `expected`: the list read for the namespace, null when it was absent. */
1992
+ export interface ConstraintWriteOptions {
1993
+ expected?: LayerConstraint[] | null;
1994
+ }
1995
+ /** One violation a 422 lists. */
1996
+ export interface ConstraintViolation {
1997
+ constraint: string;
1998
+ namespace: string | null;
1999
+ layer: string;
2000
+ layerName: string;
2001
+ document: string | null;
2002
+ at: string | null;
2003
+ ids: string[];
2004
+ value?: any;
2005
+ parts?: string[];
2006
+ }
2007
+ /** The constraint types. */
2008
+ export const CONSTRAINT_TYPES: readonly string[];
2009
+ /** The camelCased violations of a write refused by a layer constraint, or null. */
2010
+ export function violationsOf(err: any): ConstraintViolation[] | null;
2011
+ export function valueSetAllows(
2012
+ constraint: { values: string[]; delimiters?: string; parts?: "all" | "first" },
2013
+ value: any,
2014
+ ): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@larc-iu/plaid-client",
3
- "version": "0.2.0-alpha.18",
3
+ "version": "0.2.0-alpha.20",
4
4
  "description": "JavaScript client for the Plaid annotation API",
5
5
  "type": "module",
6
6
  "repository": {