@larc-iu/plaid-client 0.2.0-alpha.14 → 0.2.0-alpha.17

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
@@ -15,7 +15,7 @@ interface ServiceParam {
15
15
  /** Key the value is sent under in the request payload. */
16
16
  key: string;
17
17
  label: string;
18
- type: "string" | "number" | "boolean" | "enum" | "multiselect";
18
+ type: "string" | "number" | "boolean" | "enum" | "multiselect" | "field";
19
19
  description?: string;
20
20
  default?: any;
21
21
  required?: boolean;
@@ -30,6 +30,11 @@ interface ServiceParam {
30
30
  /** `string` only. */
31
31
  placeholder?: string;
32
32
  multiline?: boolean;
33
+ /**
34
+ * `field` only: the scope of the project's annotation fields the value names
35
+ * one of. A `field` value is a string everywhere else.
36
+ */
37
+ scope?: "Sentence" | "Word" | "Morpheme";
33
38
  }
34
39
 
35
40
  /** A service's standardized self-description (lives in `extras`). */
@@ -72,7 +77,8 @@ interface ServiceRegistration {
72
77
  }
73
78
 
74
79
  /** Connection-state transitions reported by a service registration. */
75
- type ServiceStatusEvent = "registered" | "reconnected" | "disconnected";
80
+ /** "stopped": the server refused the channel for a reason retrying cannot fix (a revoked token, no write access, no such project), which ends the registration. */
81
+ type ServiceStatusEvent = "registered" | "reconnected" | "disconnected" | "stopped";
76
82
 
77
83
  interface ResponseHelper {
78
84
  requestId: string;
@@ -111,6 +117,11 @@ interface SSEConnection {
111
117
  close(): void;
112
118
  getStats(): any;
113
119
  readyState: number;
120
+ /**
121
+ * Once CLOSED, why: null when this side closed it. A refused stream's error
122
+ * carries the HTTP `status`, and one the server ended is named "StreamClosed".
123
+ */
124
+ error: (Error & { status?: number }) | null;
114
125
  }
115
126
 
116
127
  interface VocabLinksBundle {
@@ -124,13 +135,45 @@ interface VocabLinksBundle {
124
135
  bulkDelete(body: any[], auditMessage?: string): Promise<void>;
125
136
  setMetadata(id: string, body: any, auditMessage?: string): Promise<any>;
126
137
  deleteMetadata(id: string, auditMessage?: string): Promise<any>;
127
- patchMetadata(id: string, body: any, auditMessage?: string): Promise<any>;
128
- get(id: string, asOf?: string): Promise<any>;
138
+ patchMetadata(id: string, body: MetadataOp[], auditMessage?: string): Promise<any>;
139
+ get(id: string): Promise<any>;
129
140
  delete(id: string, auditMessage?: string): Promise<any>;
130
141
  }
131
142
 
143
+ /** What `vocabLayers.restoreItem` did, or with `dryRun` would do. */
144
+ interface VocabItemRestoreSummary {
145
+ /** The entry was gone and came back under its old id. */
146
+ inserted: boolean;
147
+ /** A living entry's form was set back. */
148
+ form: boolean;
149
+ /** A living entry's fields were set back. */
150
+ metadata: boolean;
151
+ /** 0 when nothing changes. */
152
+ total: number;
153
+ }
154
+
132
155
  interface VocabLayersBundle {
156
+ /** `asOf` reads the vocabulary as it was at that instant. */
133
157
  get(id: string, includeItems?: boolean, asOf?: string): Promise<any>;
158
+ /** One entry as it was at `asOf`, also when it has been deleted since. */
159
+ getItemAt(id: string, itemId: string, asOf: string): Promise<any>;
160
+ /** `itemId` keeps only the changes that wrote that one entry. */
161
+ audit(
162
+ id: string,
163
+ startTime?: string,
164
+ endTime?: string,
165
+ opTypes?: string[] | string,
166
+ itemId?: string,
167
+ ): Promise<any[]>;
168
+ auditPage(id: string, opts?: AuditPageOptions & { itemId?: string }): Promise<Page>;
169
+ /** Put one entry back as it was at `asOf`. Maintainers of the vocabulary only. */
170
+ restoreItem(
171
+ id: string,
172
+ itemId: string,
173
+ asOf: string,
174
+ options?: { dryRun?: boolean },
175
+ auditMessage?: string,
176
+ ): Promise<VocabItemRestoreSummary>;
134
177
  delete(id: string, auditMessage?: string): Promise<any>;
135
178
  update(id: string, name: string, auditMessage?: string): Promise<any>;
136
179
  setConfig(
@@ -146,13 +189,9 @@ interface VocabLayersBundle {
146
189
  configKey: string,
147
190
  auditMessage?: string,
148
191
  ): Promise<any>;
149
- list(asOf?: string): Promise<any[]>;
150
- listPage(opts?: {
151
- limit?: number;
152
- cursor?: string;
153
- asOf?: string;
154
- }): Promise<Page>;
155
- iterPages(opts?: { pageSize?: number; asOf?: string }): AsyncGenerator<any[]>;
192
+ list(): Promise<any[]>;
193
+ listPage(opts?: { limit?: number; cursor?: string }): Promise<Page>;
194
+ iterPages(opts?: { pageSize?: number }): AsyncGenerator<any[]>;
156
195
  create(name: string, auditMessage?: string): Promise<any>;
157
196
  addMaintainer(
158
197
  id: string,
@@ -175,7 +214,7 @@ interface RelationsBundle {
175
214
  deleteMetadata(relationId: string, auditMessage?: string): Promise<any>;
176
215
  patchMetadata(
177
216
  relationId: string,
178
- body: any,
217
+ body: MetadataOp[],
179
218
  auditMessage?: string,
180
219
  ): Promise<any>;
181
220
  setTarget(
@@ -183,7 +222,7 @@ interface RelationsBundle {
183
222
  spanId: string,
184
223
  auditMessage?: string,
185
224
  ): Promise<any>;
186
- get(relationId: string, asOf?: string): Promise<any>;
225
+ get(relationId: string): Promise<any>;
187
226
  delete(relationId: string, auditMessage?: string): Promise<any>;
188
227
  update(relationId: string, value: any, auditMessage?: string): Promise<any>;
189
228
  setSource(
@@ -218,7 +257,7 @@ interface SpanLayersBundle {
218
257
  configKey: string,
219
258
  auditMessage?: string,
220
259
  ): Promise<any>;
221
- get(spanLayerId: string, asOf?: string): Promise<any>;
260
+ get(spanLayerId: string): Promise<any>;
222
261
  delete(spanLayerId: string, auditMessage?: string): Promise<any>;
223
262
  update(
224
263
  spanLayerId: string,
@@ -246,7 +285,7 @@ interface SpansBundle {
246
285
  metadata?: any,
247
286
  auditMessage?: string,
248
287
  ): Promise<any>;
249
- get(spanId: string, asOf?: string): Promise<any>;
288
+ get(spanId: string): Promise<any>;
250
289
  delete(spanId: string, auditMessage?: string): Promise<any>;
251
290
  update(spanId: string, value: any, auditMessage?: string): Promise<any>;
252
291
  bulkCreate(body: any[], auditMessage?: string): Promise<{ ids: string[] }>;
@@ -254,17 +293,13 @@ interface SpansBundle {
254
293
  bulkUpdate(body: any[], auditMessage?: string): Promise<{ count: number }>;
255
294
  setMetadata(spanId: string, body: any, auditMessage?: string): Promise<any>;
256
295
  deleteMetadata(spanId: string, auditMessage?: string): Promise<any>;
257
- patchMetadata(spanId: string, body: any, auditMessage?: string): Promise<any>;
258
- }
259
-
260
- interface BatchBundle {
261
- submit(body: any[], auditMessage?: string): Promise<any>;
296
+ patchMetadata(spanId: string, body: MetadataOp[], auditMessage?: string): Promise<any>;
262
297
  }
263
298
 
264
299
  interface TextsBundle {
265
300
  setMetadata(textId: string, body: any, auditMessage?: string): Promise<any>;
266
301
  deleteMetadata(textId: string, auditMessage?: string): Promise<any>;
267
- patchMetadata(textId: string, body: any, auditMessage?: string): Promise<any>;
302
+ patchMetadata(textId: string, body: MetadataOp[], auditMessage?: string): Promise<any>;
268
303
  create(
269
304
  textLayerId: string,
270
305
  documentId: string,
@@ -272,19 +307,16 @@ interface TextsBundle {
272
307
  metadata?: any,
273
308
  auditMessage?: string,
274
309
  ): Promise<any>;
275
- get(textId: string, asOf?: string): Promise<any>;
310
+ get(textId: string): Promise<any>;
276
311
  delete(textId: string, auditMessage?: string): Promise<any>;
277
312
  update(textId: string, body: any, auditMessage?: string): Promise<any>;
278
313
  }
279
314
 
280
315
  interface UsersBundle {
281
- list(asOf?: string): Promise<any[]>;
282
- listPage(opts?: {
283
- limit?: number;
284
- cursor?: string;
285
- asOf?: string;
286
- }): Promise<Page>;
287
- iterPages(opts?: { pageSize?: number; asOf?: string }): AsyncGenerator<any[]>;
316
+ /** `q` narrows to users whose id or display name contains it (admin or maintainer). */
317
+ list(opts?: { q?: string }): Promise<any[]>;
318
+ listPage(opts?: { q?: string; limit?: number; cursor?: string }): Promise<Page>;
319
+ iterPages(opts?: { q?: string; pageSize?: number }): AsyncGenerator<any[]>;
288
320
  create(
289
321
  email: string,
290
322
  password: string,
@@ -296,10 +328,10 @@ interface UsersBundle {
296
328
  userId: string,
297
329
  startTime?: string,
298
330
  endTime?: string,
299
- asOf?: string,
331
+ opTypes?: string[] | string,
300
332
  ): Promise<any[]>;
301
333
  auditPage(userId: string, opts?: AuditPageOptions): Promise<Page>;
302
- get(id: string, asOf?: string): Promise<any>;
334
+ get(id: string): Promise<any>;
303
335
  delete(id: string, auditMessage?: string): Promise<any>;
304
336
  activate(id: string, auditMessage?: string): Promise<any>;
305
337
  update(
@@ -361,6 +393,60 @@ interface CommentFilters {
361
393
  type CommentableType =
362
394
  "document" | "text" | "token" | "span" | "relation" | "vocab-item";
363
395
 
396
+ /**
397
+ * One entry in a project's annotation manual: a short Markdown document
398
+ * stating a convention the project follows. Read by the people on the
399
+ * project, and by the assistant before it proposes anything.
400
+ */
401
+ interface Guideline {
402
+ id: string;
403
+ projectId: string;
404
+ /** The handle the assistant asks for a guideline by. Not required to be unique. */
405
+ title: string;
406
+ /** The Markdown text. Present on a single read and on a list made with `includeBodies`. */
407
+ body?: string;
408
+ /** The body's length in characters. Present on a list made WITHOUT `includeBodies`. */
409
+ bodyChars?: number;
410
+ /** Whether the assistant is given this one in full on every turn. */
411
+ pinned: boolean;
412
+ createdAt: string;
413
+ updatedAt: string;
414
+ }
415
+
416
+ interface GuidelinesBundle {
417
+ create(
418
+ projectId: string,
419
+ title: string,
420
+ opts?: { body?: string; pinned?: boolean },
421
+ auditMessage?: string,
422
+ ): Promise<{ id: string }>;
423
+ get(id: string): Promise<Guideline>;
424
+ update(
425
+ id: string,
426
+ changes?: {
427
+ title?: string;
428
+ body?: string;
429
+ pinned?: boolean;
430
+ /** Write only if this is still the stored updatedAt; 409 otherwise. */
431
+ expectedUpdatedAt?: string;
432
+ },
433
+ auditMessage?: string,
434
+ ): Promise<Guideline>;
435
+ delete(id: string, auditMessage?: string): Promise<any>;
436
+ list(
437
+ projectId: string,
438
+ opts?: { includeBodies?: boolean },
439
+ ): Promise<Guideline[]>;
440
+ listPage(
441
+ projectId: string,
442
+ opts?: { includeBodies?: boolean; limit?: number; cursor?: string },
443
+ ): Promise<Page<Guideline>>;
444
+ iterPages(
445
+ projectId: string,
446
+ opts?: { includeBodies?: boolean; pageSize?: number },
447
+ ): AsyncGenerator<Guideline[]>;
448
+ }
449
+
364
450
  interface Comment {
365
451
  id: string;
366
452
  /** The owning project, or null for a comment on a vocabulary entry. */
@@ -418,6 +504,10 @@ interface CommentsBundle {
418
504
  vocabId: string,
419
505
  opts?: { entityId?: string; limit?: number; cursor?: string },
420
506
  ): Promise<Page<Comment>>;
507
+ iterInVocabPages(
508
+ vocabId: string,
509
+ opts?: { entityId?: string; pageSize?: number },
510
+ ): AsyncGenerator<Comment[]>;
421
511
  /** `{entryId: count}` over a vocabulary; keys are raw entry ids. */
422
512
  countsInVocab(
423
513
  vocabId: string,
@@ -497,6 +587,12 @@ interface ServerLimits {
497
587
  metadataStringLength?: number;
498
588
  metadataTotalBytes?: number;
499
589
  userDataValueBytes?: number;
590
+ guidelineTitleLength?: number;
591
+ guidelineBodyLength?: number;
592
+ /** The shortest password the server accepts on any path. */
593
+ passwordMinLength?: number;
594
+ /** How long a document lock is held before it lapses. */
595
+ lockExpirationMs?: number;
500
596
  }
501
597
 
502
598
  interface ServerHealth {
@@ -506,7 +602,8 @@ interface ServerHealth {
506
602
  audit: { dbSizeMb?: number; auditRows?: number; error?: string };
507
603
  }
508
604
 
509
- interface DocumentLock {
605
+ /** A document lock as the admin lock listing reports it. */
606
+ interface DocumentLockInfo {
510
607
  documentId: string;
511
608
  userId: string;
512
609
  expiresAt: number;
@@ -565,6 +662,15 @@ interface ServerReport {
565
662
  settings: Record<string, any>;
566
663
  }
567
664
 
665
+ /** The signed-in user's sign-ins. Signing in is `PlaidClient.login`. */
666
+ interface AuthBundle {
667
+ /**
668
+ * End every sign-in of this user on every device, this client's included.
669
+ * Named API tokens are not affected. Goes out at once even on a batch.
670
+ */
671
+ logoutEverywhere(): Promise<void>;
672
+ }
673
+
568
674
  /** Server-level facts. `info` is fetched at most once per client. */
569
675
  interface ServerBundle {
570
676
  info(): Promise<{ limits: ServerLimits }>;
@@ -576,7 +682,7 @@ interface ServerBundle {
576
682
  interface AdminBundle {
577
683
  server(): Promise<ServerReport>;
578
684
  backup(): Promise<BackupStatus>;
579
- locks(): Promise<{ entries: DocumentLock[] }>;
685
+ locks(): Promise<{ entries: DocumentLockInfo[] }>;
580
686
  releaseLock(documentId: string): Promise<{ result: string }>;
581
687
  rateLimits(): Promise<RateLimitSnapshot>;
582
688
  clearRateLimits(opts?: {
@@ -680,7 +786,6 @@ type AdminUserDataEntry = UserDataEntry & { userId: string };
680
786
  interface AuditPageOptions {
681
787
  startTime?: string;
682
788
  endTime?: string;
683
- asOf?: string;
684
789
  opTypes?: string[] | string;
685
790
  /** "desc" pages newest-first; a cursor belongs to the direction that made it. */
686
791
  order?: "asc" | "desc";
@@ -772,7 +877,7 @@ interface TokenLayersBundle {
772
877
  configKey: string,
773
878
  auditMessage?: string,
774
879
  ): Promise<any>;
775
- get(tokenLayerId: string, asOf?: string): Promise<any>;
880
+ get(tokenLayerId: string): Promise<any>;
776
881
  delete(tokenLayerId: string, auditMessage?: string): Promise<any>;
777
882
  update(
778
883
  tokenLayerId: string,
@@ -801,7 +906,7 @@ export declare class DocumentLockLost extends Error {
801
906
  export const DOCUMENT_LOCK_TTL_MS: 60000;
802
907
 
803
908
  interface DocumentsBundle {
804
- checkLock(documentId: string, asOf?: string): Promise<any>;
909
+ checkLock(documentId: string): Promise<any>;
805
910
  acquireLock(documentId: string, auditMessage?: string): Promise<any>;
806
911
  releaseLock(documentId: string, auditMessage?: string): Promise<any>;
807
912
  /**
@@ -833,17 +938,26 @@ interface DocumentsBundle {
833
938
  deleteMetadata(documentId: string, auditMessage?: string): Promise<any>;
834
939
  patchMetadata(
835
940
  documentId: string,
836
- body: any,
941
+ body: MetadataOp[],
837
942
  auditMessage?: string,
838
943
  ): Promise<any>;
839
944
  audit(
840
945
  documentId: string,
841
946
  startTime?: string,
842
947
  endTime?: string,
843
- asOf?: string,
948
+ opTypes?: string[] | string,
844
949
  ): Promise<any[]>;
845
950
  auditPage(documentId: string, opts?: AuditPageOptions): Promise<Page>;
846
- get(documentId: string, includeBody?: boolean, asOf?: string): Promise<any>;
951
+ /**
952
+ * `asOf` reads the document as it was at that instant. `layers` narrows a
953
+ * body read to the named layers (ids of any kind), and needs `includeBody`.
954
+ */
955
+ get(
956
+ documentId: string,
957
+ includeBody?: boolean,
958
+ asOf?: string,
959
+ layers?: string[] | string,
960
+ ): Promise<any>;
847
961
  delete(documentId: string, auditMessage?: string): Promise<any>;
848
962
  update(documentId: string, name: string, auditMessage?: string): Promise<any>;
849
963
  create(
@@ -868,11 +982,8 @@ interface DocumentsBundle {
868
982
  }
869
983
 
870
984
  interface MessagesBundle {
871
- sendMessage(
872
- projectId: string,
873
- data: any,
874
- auditMessage?: string,
875
- ): Promise<any>;
985
+ /** Broadcast to the project's listeners. Never saved and never part of an operation. */
986
+ sendMessage(projectId: string, data: any): Promise<any>;
876
987
  listen(
877
988
  projectId: string,
878
989
  onEvent: (eventType: string, data: any) => void | boolean,
@@ -909,7 +1020,33 @@ interface MessagesBundle {
909
1020
  timeout?: number,
910
1021
  onProgress?: (progress: any) => void,
911
1022
  signal?: AbortSignal,
1023
+ opts?: {
1024
+ /** A request id you mint, so you know it before submitting; resubmitting one rejoins that request. */
1025
+ requestId?: string;
1026
+ /** Called with the request id as soon as the server has taken the request. */
1027
+ onAccepted?: (requestId: string) => void;
1028
+ /** Other projects the request is about. A delegating service's token reaches `projectId` and those of these the requester can read, nothing else. */
1029
+ projectIds?: string[];
1030
+ },
1031
+ ): Promise<any>;
1032
+ /**
1033
+ * Rejoin a request made earlier: the latest progress is replayed, then the
1034
+ * result, or at once if it already finished. Only its submitter (or an
1035
+ * admin). Rejects with a 404 when the request is unknown or expired.
1036
+ */
1037
+ attachServiceRequest(
1038
+ projectId: string,
1039
+ requestId: string,
1040
+ timeout?: number,
1041
+ onProgress?: (progress: any) => void,
1042
+ signal?: AbortSignal,
912
1043
  ): Promise<any>;
1044
+ /**
1045
+ * Ask the service to stop a request made earlier. The request still ends
1046
+ * with whatever the service then reports. 404 if unknown or expired, 409
1047
+ * once finished.
1048
+ */
1049
+ cancelServiceRequest(projectId: string, requestId: string): Promise<void>;
913
1050
  }
914
1051
 
915
1052
  interface ProjectsBundle {
@@ -944,12 +1081,18 @@ interface ProjectsBundle {
944
1081
  projectId: string,
945
1082
  startTime?: string,
946
1083
  endTime?: string,
947
- asOf?: string,
1084
+ opTypes?: string[] | string,
948
1085
  ): Promise<any[]>;
949
1086
  auditPage(projectId: string, opts?: AuditPageOptions): Promise<Page>;
1087
+ /**
1088
+ * When the calling user last wrote to each document of the project, as a
1089
+ * `{documentId: timestamp}` map; documents they never wrote to are absent.
1090
+ * The keys are document ids, so the response is not key-transformed.
1091
+ */
1092
+ myLastEdits(projectId: string): Promise<Record<string, string>>;
950
1093
  linkVocab(id: string, vocabId: string, auditMessage?: string): Promise<any>;
951
1094
  unlinkVocab(id: string, vocabId: string, auditMessage?: string): Promise<any>;
952
- get(id: string, asOf?: string): Promise<any>;
1095
+ get(id: string): Promise<any>;
953
1096
  listDocuments(id: string): Promise<any[]>;
954
1097
  listDocumentsPage(
955
1098
  id: string,
@@ -959,15 +1102,16 @@ interface ProjectsBundle {
959
1102
  id: string,
960
1103
  opts?: { pageSize?: number },
961
1104
  ): AsyncGenerator<any[]>;
962
- delete(id: string, auditMessage?: string): Promise<any>;
963
1105
  update(id: string, name: string, auditMessage?: string): Promise<any>;
964
- list(asOf?: string): Promise<any[]>;
965
- listPage(opts?: {
966
- limit?: number;
967
- cursor?: string;
968
- asOf?: string;
969
- }): Promise<Page>;
970
- iterPages(opts?: { pageSize?: number; asOf?: string }): AsyncGenerator<any[]>;
1106
+ /** The project is gone when this returns, and what it holds is removed on the server afterwards. The timeout defaults to the client's. */
1107
+ delete(
1108
+ id: string,
1109
+ auditMessage?: string,
1110
+ options?: { timeout?: number | null },
1111
+ ): Promise<any>;
1112
+ list(): Promise<any[]>;
1113
+ listPage(opts?: { limit?: number; cursor?: string }): Promise<Page>;
1114
+ iterPages(opts?: { pageSize?: number }): AsyncGenerator<any[]>;
971
1115
  create(name: string, auditMessage?: string): Promise<any>;
972
1116
  }
973
1117
 
@@ -985,7 +1129,7 @@ interface TextLayersBundle {
985
1129
  configKey: string,
986
1130
  auditMessage?: string,
987
1131
  ): Promise<any>;
988
- get(textLayerId: string, asOf?: string): Promise<any>;
1132
+ get(textLayerId: string): Promise<any>;
989
1133
  delete(textLayerId: string, auditMessage?: string): Promise<any>;
990
1134
  update(
991
1135
  textLayerId: string,
@@ -1003,7 +1147,7 @@ interface TextLayersBundle {
1003
1147
  interface VocabItemsBundle {
1004
1148
  setMetadata(id: string, body: any, auditMessage?: string): Promise<any>;
1005
1149
  deleteMetadata(id: string, auditMessage?: string): Promise<any>;
1006
- patchMetadata(id: string, body: any, auditMessage?: string): Promise<any>;
1150
+ patchMetadata(id: string, body: MetadataOp[], auditMessage?: string): Promise<any>;
1007
1151
  create(
1008
1152
  vocabLayerId: string,
1009
1153
  form: string,
@@ -1012,7 +1156,8 @@ interface VocabItemsBundle {
1012
1156
  ): Promise<any>;
1013
1157
  bulkCreate(body: any[], auditMessage?: string): Promise<{ ids: string[] }>;
1014
1158
  bulkDelete(body: any[], auditMessage?: string): Promise<void>;
1015
- get(id: string, asOf?: string): Promise<any>;
1159
+ bulkUpdate(body: any[], auditMessage?: string): Promise<{ count: number }>;
1160
+ get(id: string): Promise<any>;
1016
1161
  delete(id: string, auditMessage?: string): Promise<any>;
1017
1162
  update(id: string, form: string, auditMessage?: string): Promise<any>;
1018
1163
  }
@@ -1041,7 +1186,7 @@ interface RelationLayersBundle {
1041
1186
  configKey: string,
1042
1187
  auditMessage?: string,
1043
1188
  ): Promise<any>;
1044
- get(relationLayerId: string, asOf?: string): Promise<any>;
1189
+ get(relationLayerId: string): Promise<any>;
1045
1190
  delete(relationLayerId: string, auditMessage?: string): Promise<any>;
1046
1191
  update(
1047
1192
  relationLayerId: string,
@@ -1060,7 +1205,7 @@ interface TokensBundle {
1060
1205
  metadata?: any,
1061
1206
  auditMessage?: string,
1062
1207
  ): Promise<any>;
1063
- get(tokenId: string, asOf?: string): Promise<any>;
1208
+ get(tokenId: string): Promise<any>;
1064
1209
  delete(tokenId: string, auditMessage?: string): Promise<any>;
1065
1210
  update(
1066
1211
  tokenId: string,
@@ -1088,7 +1233,7 @@ interface TokensBundle {
1088
1233
  deleteMetadata(tokenId: string, auditMessage?: string): Promise<any>;
1089
1234
  patchMetadata(
1090
1235
  tokenId: string,
1091
- body: any,
1236
+ body: MetadataOp[],
1092
1237
  auditMessage?: string,
1093
1238
  ): Promise<any>;
1094
1239
  }
@@ -1116,8 +1261,40 @@ export interface OperationGroupsBundle {
1116
1261
  update(id: string, message: string | null): Promise<any>;
1117
1262
  }
1118
1263
 
1264
+ /**
1265
+ * A batch: the client's bundles, on which every write of project data queues
1266
+ * until `submit()`. See `PlaidClient.batch()`.
1267
+ */
1268
+ export interface PlaidBatch extends PlaidClient {
1269
+ /** The client this batch was opened on. */
1270
+ readonly client: PlaidClient;
1271
+ /** The queued operations, in order. */
1272
+ readonly operations: Array<{ path: string; method: string; body?: any }>;
1273
+ /**
1274
+ * Send the queued operations and resolve to one result per operation, in
1275
+ * order. Up to MAX_BATCH_OPS operations go as one atomic request. A larger
1276
+ * batch goes as consecutive requests, each atomic on its own, so a failure
1277
+ * in a later one leaves the earlier ones committed. The error then carries
1278
+ * `committed`, how many operations were saved (0 when none were), and
1279
+ * `committedResults`, their results in queue order.
1280
+ */
1281
+ submit(): Promise<any[]>;
1282
+ /** Drop the queued operations without sending them. */
1283
+ abort(): void;
1284
+ }
1285
+
1119
1286
  export declare class PlaidClient {
1120
1287
  constructor(baseUrl: string, token: string, options?: PlaidClientOptions);
1288
+ /** Liveness, version and database size, with no authentication. */
1289
+ static health(
1290
+ baseUrl: string,
1291
+ options?: { timeout?: number | null },
1292
+ ): Promise<ServerHealth>;
1293
+ /** The limits this server enforces, with no authentication. */
1294
+ static info(
1295
+ baseUrl: string,
1296
+ options?: { timeout?: number | null },
1297
+ ): Promise<{ limits: ServerLimits }>;
1121
1298
  static login(
1122
1299
  baseUrl: string,
1123
1300
  userId: string,
@@ -1139,28 +1316,37 @@ export declare class PlaidClient {
1139
1316
  credentials: { email?: string; password: string; displayName?: string },
1140
1317
  options?: PlaidClientOptions,
1141
1318
  ): Promise<{ client: PlaidClient; userId: string; kind: string }>;
1319
+ /** The server's base URL, without a trailing slash. */
1320
+ readonly baseUrl: string;
1321
+ /** The bearer token every request carries. */
1322
+ token: string;
1142
1323
  timeout: number | null;
1143
1324
  batchTimeout: number | null;
1325
+ /** The document strict mode is entered for, or null. */
1326
+ readonly strictModeDocumentId: string | null;
1327
+ /** The DocumentLockLost of the open `locked()` block whose lock lapsed, or null. Cleared when that block exits. */
1328
+ documentLockLost: DocumentLockLost | null;
1144
1329
  /** Fired once on HTTP 401 (see PlaidClientOptions.onAuthError). */
1145
1330
  onAuthError: ((error: Error) => void) | null;
1331
+ /** The latest version seen for each document written through this client, keyed by document id. */
1332
+ documentVersions: Record<string, number>;
1333
+ /** True once a response left its version list out (X-Document-Versions-Omitted, past fifty documents). Every version held was then forgotten, and the strict-mode document's is read again before the next write. */
1334
+ documentVersionsOmitted?: boolean;
1146
1335
 
1147
- // Batch control methods.
1336
+ // Batches.
1148
1337
  //
1149
- // Batch mode is one flag on the whole client, so it catches every write made
1150
- // while it is open, including writes made by code that knows nothing about
1151
- // the batch. Reads are never caught: every read method goes over the wire
1152
- // while a batch is open and is answered from the state the batch has not
1153
- // committed yet, so app chrome sharing a client with an importer keeps
1154
- // working. Neither are the calls that signal something out of band rather
1155
- // than write project data: stopping a service request, a service reporting
1156
- // its progress or result, taking and dropping a document lock, and the admin
1157
- // actions on the server itself.
1158
- beginBatch(): void;
1159
- submitBatch(): Promise<any[]>;
1160
- abortBatch(): void;
1161
- isBatchMode(): boolean;
1162
- /** Run `fn` with a batch open, then submit atomically (or abort if `fn` throws). Resolves to the results array. Writes inside `fn` queue; reads go over the wire and see the pre-batch state. */
1163
- batched(fn: () => void | Promise<void>): Promise<any[]>;
1338
+ // A batch is a view of the client with the same bundles. A write of project
1339
+ // data made on the batch queues; a call made on the client itself always
1340
+ // goes over the wire, whatever batches are open, so a write by code that
1341
+ // knows nothing about a batch can never land inside it. A read, or a signal
1342
+ // that carries no project data (stopping a service request, a service
1343
+ // reporting its progress, taking and dropping a document lock, the admin
1344
+ // actions on the server itself), goes over the wire even when made on the
1345
+ // batch.
1346
+ /** Open a batch. Queue writes on it, then `submit()` them (one atomic request up to MAX_BATCH_OPS operations), or `abort()`. Not nestable. */
1347
+ batch(): PlaidBatch;
1348
+ /** Run `fn` with a batch, then submit it as `submit()` does (or abort if `fn` throws). Resolves to the results array, one entry per queued write. */
1349
+ batched(fn: (batch: PlaidBatch) => void | Promise<void>): Promise<any[]>;
1164
1350
 
1165
1351
  // Strict mode methods
1166
1352
  enterStrictMode(documentId: string): void;
@@ -1179,23 +1365,24 @@ export declare class PlaidClient {
1179
1365
  operationGroups: OperationGroupsBundle;
1180
1366
 
1181
1367
  // Query
1182
- query(body: any, auditMessage?: string): Promise<any>;
1368
+ query(body: any): Promise<any>;
1183
1369
 
1184
1370
  vocabLinks: VocabLinksBundle;
1185
1371
  vocabLayers: VocabLayersBundle;
1186
1372
  relations: RelationsBundle;
1187
1373
  spanLayers: SpanLayersBundle;
1188
1374
  spans: SpansBundle;
1189
- batch: BatchBundle;
1190
1375
  texts: TextsBundle;
1191
1376
  users: UsersBundle;
1192
1377
  apiTokens: ApiTokensBundle;
1193
1378
  userData: UserDataBundle;
1194
1379
  invites: InvitesBundle;
1195
1380
  server: ServerBundle;
1381
+ auth: AuthBundle;
1196
1382
  admin: AdminBundle;
1197
1383
  audit: AuditBundle;
1198
1384
  comments: CommentsBundle;
1385
+ guidelines: GuidelinesBundle;
1199
1386
  tokenLayers: TokenLayersBundle;
1200
1387
  documents: DocumentsBundle;
1201
1388
  messages: MessagesBundle;
@@ -1230,6 +1417,8 @@ export function cpIndexOf(s: string, sub: string, fromCp?: number): number;
1230
1417
  export const PLAID_NAMESPACE: "plaid";
1231
1418
  /** The config key, under `plaid`, holding a layer's role. */
1232
1419
  export const ROLE_KEY: "role";
1420
+ /** Layer config key naming the metadata keys a token born of a SPLIT inherits. */
1421
+ export const PRESERVE_ON_SPLIT_KEY: "preserveOnSplit";
1233
1422
 
1234
1423
  /** The server's cap on operations per batch request; a larger batch goes as consecutive requests. */
1235
1424
  export const MAX_BATCH_OPS: 1000;
@@ -1262,9 +1451,11 @@ export const TASKS: {
1262
1451
  readonly TRANSCRIBE: "transcribe";
1263
1452
  readonly LINK_VOCAB: "link-vocab";
1264
1453
  readonly ANALYZE: "analyze";
1454
+ readonly DRAFT_GRAPH: "draft-graph";
1265
1455
  readonly TRANSLATE: "translate";
1266
1456
  readonly ASSIST: "assist";
1267
1457
  readonly DETECT_SPEECH: "detect-speech";
1458
+ readonly COMPARE: "compare";
1268
1459
  };
1269
1460
  /** Whether a service serves a task (declared `extras.tasks`, legacy id-prefix fallback). */
1270
1461
  export function servesTask(service: DiscoveredService, task: string): boolean;
@@ -1293,7 +1484,7 @@ export function coerceParamValues(
1293
1484
  // replace unverified machine material but must never touch human/verified
1294
1485
  // material without an explicit overwrite opt-in; any human edit verifies.
1295
1486
  // See the manual, "Provenance".
1296
- type ProvState = "human" | "machine" | "verified";
1487
+ type ProvState = "human" | "machine" | "contributed" | "verified";
1297
1488
  export const PROV: {
1298
1489
  readonly key: "prov";
1299
1490
  readonly sourceKey: "provSource";
@@ -1301,12 +1492,16 @@ export const PROV: {
1301
1492
  readonly probKey: "provProb";
1302
1493
  readonly detailKey: "provDetail";
1303
1494
  readonly INFERRED: "inferred";
1495
+ readonly CONTRIBUTED: "contributed";
1304
1496
  };
1305
1497
  export const PROV_STATES: {
1306
1498
  readonly HUMAN: "human";
1307
1499
  readonly MACHINE: "machine";
1500
+ readonly CONTRIBUTED: "contributed";
1308
1501
  readonly VERIFIED: "verified";
1309
1502
  };
1503
+ /** The provenance keys Plaid itself owns — what a split carries and a reshape keeps. */
1504
+ export const PROVENANCE_KEYS: readonly string[];
1310
1505
  /** Optional prediction extras: prob = a probability in [0,1] for the chosen value
1311
1506
  * (flat + queryable; omit unless it honestly is one); detail = an open map of
1312
1507
  * producer extras (top-k alternatives, model version, raw scores; keep it small).
@@ -1351,3 +1546,102 @@ export function verifyOnEdit(
1351
1546
  ): { readonly provConfirmed: true } | null;
1352
1547
  /** Canonical provSource for a service: 'service:<serviceId>'. */
1353
1548
  export function serviceSource(serviceId: string): string;
1549
+ /** Canonical provSource for a contributor: 'user:<userId>'. */
1550
+ export function userSource(userId: string): string;
1551
+ /** The metadata fragment a contributor's work carries. */
1552
+ export function stampContributed(userId: string): {
1553
+ prov: "contributed";
1554
+ provSource: string;
1555
+ };
1556
+ /** Where an entity came from, confirmed or not: what a verified entity's tooltip needs. */
1557
+ export function provOrigin(
1558
+ metadata: object | null | undefined,
1559
+ ): null | "inferred" | "contributed";
1560
+ /** Whether a verifier still has to look at this entity: machine-made or contributed, unconfirmed. */
1561
+ export function needsReview(metadata: object | null | undefined): boolean;
1562
+ /** The fragment a CONTRIBUTOR's edit merges in: the contributed stamp, dropping any confirmation. */
1563
+ export function contributeOnEdit(
1564
+ metadata: object | null | undefined,
1565
+ userId: string,
1566
+ ): { prov: "contributed"; provSource: string; provConfirmed: null };
1567
+ /** Merge a fragment into a local copy, a null value deleting the key: applyMetadataOps(metadata, metadataOps(fragment)), refused where the server would refuse it. Returns a new object. */
1568
+ export function mergeMetadata(
1569
+ metadata: object | null | undefined,
1570
+ fragment: object | null | undefined,
1571
+ ): Record<string, any>;
1572
+
1573
+ // --- Create responses ---------------------------------------------------------
1574
+ /** The id a single create answered with, read off the call's response or its batch result (`{status, body}`). Undefined when it gave none. */
1575
+ export function createdId(result: any): string | undefined;
1576
+ /** 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. */
1577
+ export function createdIds(result: any): string[];
1578
+
1579
+ // --- Metadata ops -------------------------------------------------------------
1580
+ /** One metadata edit: the body of a metadata PATCH is a list of these. */
1581
+ export type MetadataOp =
1582
+ | { op: "set"; path: string[]; value: any }
1583
+ | { op: "delete"; path: string[] };
1584
+ /** The ops that set each top-level key of a fragment, a null value deleting it. */
1585
+ export function metadataOps(
1586
+ fragment: object | null | undefined,
1587
+ ): MetadataOp[];
1588
+ /** Apply ops to a local copy the way the server does. Returns a new object; throws where the server would refuse. */
1589
+ export function applyMetadataOps(
1590
+ metadata: object | null | undefined,
1591
+ ops: MetadataOp[],
1592
+ ): Record<string, any>;
1593
+ /** True for a top-level metadata key Plaid keeps for itself (`plaid` and the provenance keys), never a user's field. */
1594
+ export function isReservedMetadataKey(key: string): boolean;
1595
+
1596
+ // --- Review: whose work is reviewed (a project-config norm) -------------------
1597
+ /** The config key, under the `plaid` namespace, holding the review lists. */
1598
+ export const REVIEW_KEY: "review";
1599
+ /** The project roles a review list may name. */
1600
+ export const PROJECT_ROLES: readonly ["reader", "writer", "maintainer"];
1601
+ /** A project's review lists, normalized. */
1602
+ export function readReview(config?: object | null): {
1603
+ users: string[];
1604
+ roles: string[];
1605
+ };
1606
+ /** A person's role in a project from its ACL lists; an admin with no entry is a maintainer. */
1607
+ export function projectRole(
1608
+ project: object | null | undefined,
1609
+ userId: string | null | undefined,
1610
+ opts?: { isAdmin?: boolean },
1611
+ ): "maintainer" | "writer" | "reader" | null;
1612
+ /** Whether this person's work is reviewed here: named in review.users, or holding a role in review.roles. */
1613
+ export function isReviewed(
1614
+ project: object | null | undefined,
1615
+ userId: string | null | undefined,
1616
+ opts?: { isAdmin?: boolean },
1617
+ ): boolean;
1618
+ /** The review lists with one person added to or removed from `users`. Pure. */
1619
+ export function withReviewedUser(
1620
+ review: { users?: string[]; roles?: string[] } | null | undefined,
1621
+ userId: string,
1622
+ reviewed: boolean,
1623
+ ): { users: string[]; roles: string[] };
1624
+ /** What one writer's writes carry and what their review gestures act on. */
1625
+ export function writerPolicy(contributorId?: string | null): {
1626
+ readonly contributorId: string | null;
1627
+ readonly isContributor: boolean;
1628
+ /** The metadata a NEW entity carries: null for a verifier. */
1629
+ readonly createStamp: Record<string, any> | null;
1630
+ /** The fragment an EDIT merges, or null when there is nothing to merge. */
1631
+ readonly editStamp: (
1632
+ metadata: object | null | undefined,
1633
+ ) => Record<string, any> | null;
1634
+ /** The fragment an explicit confirm gesture merges, or null. */
1635
+ readonly confirmStamp: (
1636
+ metadata: object | null | undefined,
1637
+ ) => Record<string, any> | null;
1638
+ /** What an adopted suggestion is written with. */
1639
+ readonly adoptStamp: (
1640
+ source: string,
1641
+ detail?: Record<string, any>,
1642
+ ) => Record<string, any>;
1643
+ /** Whether this writer's review gesture acts on the entity. */
1644
+ readonly reviewable: (metadata: object | null | undefined) => boolean;
1645
+ /** The same test over a provState. */
1646
+ readonly reviewableState: (state: string) => boolean;
1647
+ };