@larc-iu/plaid-client 0.2.0-alpha.1 → 0.2.0-alpha.11

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";
19
19
  description?: string;
20
20
  default?: any;
21
21
  required?: boolean;
@@ -62,10 +62,16 @@ interface DiscoveredService {
62
62
 
63
63
  interface ServiceRegistration {
64
64
  stop(): void;
65
+ /** Still serving, including while retrying a channel through a server restart. */
65
66
  isRunning(): boolean;
67
+ /** Channel open right now, i.e. the server currently sees this service as online. */
68
+ isConnected(): boolean;
66
69
  serviceInfo: ServiceInfo & { extras: any };
67
70
  }
68
71
 
72
+ /** Connection-state transitions reported by a service registration. */
73
+ type ServiceStatusEvent = 'registered' | 'reconnected' | 'disconnected';
74
+
69
75
  interface ResponseHelper {
70
76
  progress(percent: number, message: string): void;
71
77
  complete(data: any): void;
@@ -79,7 +85,12 @@ interface SSEConnection {
79
85
  }
80
86
 
81
87
  interface VocabLinksBundle {
82
- create(vocabItem: string, tokens: any[], metadata?: any, auditMessage?: string): Promise<any>;
88
+ create(
89
+ vocabItem: string,
90
+ tokens: any[],
91
+ metadata?: any,
92
+ auditMessage?: string,
93
+ ): Promise<any>;
83
94
  bulkCreate(body: any[], auditMessage?: string): Promise<{ ids: string[] }>;
84
95
  bulkDelete(body: any[], auditMessage?: string): Promise<void>;
85
96
  setMetadata(id: string, body: any, auditMessage?: string): Promise<any>;
@@ -93,43 +104,118 @@ interface VocabLayersBundle {
93
104
  get(id: string, includeItems?: boolean, asOf?: string): Promise<any>;
94
105
  delete(id: string, auditMessage?: string): Promise<any>;
95
106
  update(id: string, name: string, auditMessage?: string): Promise<any>;
96
- setConfig(id: string, namespace: string, configKey: string, configValue: any, auditMessage?: string): Promise<any>;
97
- deleteConfig(id: string, namespace: string, configKey: string, auditMessage?: string): Promise<any>;
107
+ setConfig(
108
+ id: string,
109
+ namespace: string,
110
+ configKey: string,
111
+ configValue: any,
112
+ auditMessage?: string,
113
+ ): Promise<any>;
114
+ deleteConfig(
115
+ id: string,
116
+ namespace: string,
117
+ configKey: string,
118
+ auditMessage?: string,
119
+ ): Promise<any>;
98
120
  list(asOf?: string): Promise<any[]>;
99
- listPage(opts?: { limit?: number; cursor?: string; asOf?: string }): Promise<Page>;
121
+ listPage(opts?: {
122
+ limit?: number;
123
+ cursor?: string;
124
+ asOf?: string;
125
+ }): Promise<Page>;
100
126
  iterPages(opts?: { pageSize?: number; asOf?: string }): AsyncGenerator<any[]>;
101
127
  create(name: string, auditMessage?: string): Promise<any>;
102
- addMaintainer(id: string, userId: string, auditMessage?: string): Promise<any>;
103
- removeMaintainer(id: string, userId: string, auditMessage?: string): Promise<any>;
128
+ addMaintainer(
129
+ id: string,
130
+ userId: string,
131
+ auditMessage?: string,
132
+ ): Promise<any>;
133
+ removeMaintainer(
134
+ id: string,
135
+ userId: string,
136
+ auditMessage?: string,
137
+ ): Promise<any>;
104
138
  }
105
139
 
106
140
  interface RelationsBundle {
107
- setMetadata(relationId: string, body: any, auditMessage?: string): Promise<any>;
141
+ setMetadata(
142
+ relationId: string,
143
+ body: any,
144
+ auditMessage?: string,
145
+ ): Promise<any>;
108
146
  deleteMetadata(relationId: string, auditMessage?: string): Promise<any>;
109
- patchMetadata(relationId: string, body: any, auditMessage?: string): Promise<any>;
110
- setTarget(relationId: string, spanId: string, auditMessage?: string): Promise<any>;
147
+ patchMetadata(
148
+ relationId: string,
149
+ body: any,
150
+ auditMessage?: string,
151
+ ): Promise<any>;
152
+ setTarget(
153
+ relationId: string,
154
+ spanId: string,
155
+ auditMessage?: string,
156
+ ): Promise<any>;
111
157
  get(relationId: string, asOf?: string): Promise<any>;
112
158
  delete(relationId: string, auditMessage?: string): Promise<any>;
113
159
  update(relationId: string, value: any, auditMessage?: string): Promise<any>;
114
- setSource(relationId: string, spanId: string, auditMessage?: string): Promise<any>;
115
- create(layerId: string, sourceId: string, targetId: string, value: any, metadata?: any, auditMessage?: string): Promise<any>;
160
+ setSource(
161
+ relationId: string,
162
+ spanId: string,
163
+ auditMessage?: string,
164
+ ): Promise<any>;
165
+ create(
166
+ layerId: string,
167
+ sourceId: string,
168
+ targetId: string,
169
+ value: any,
170
+ metadata?: any,
171
+ auditMessage?: string,
172
+ ): Promise<any>;
116
173
  bulkCreate(body: any[], auditMessage?: string): Promise<{ ids: string[] }>;
117
174
  bulkDelete(body: any[], auditMessage?: string): Promise<void>;
118
175
  }
119
176
 
120
177
  interface SpanLayersBundle {
121
- setConfig(spanLayerId: string, namespace: string, configKey: string, configValue: any, auditMessage?: string): Promise<any>;
122
- deleteConfig(spanLayerId: string, namespace: string, configKey: string, auditMessage?: string): Promise<any>;
178
+ setConfig(
179
+ spanLayerId: string,
180
+ namespace: string,
181
+ configKey: string,
182
+ configValue: any,
183
+ auditMessage?: string,
184
+ ): Promise<any>;
185
+ deleteConfig(
186
+ spanLayerId: string,
187
+ namespace: string,
188
+ configKey: string,
189
+ auditMessage?: string,
190
+ ): Promise<any>;
123
191
  get(spanLayerId: string, asOf?: string): Promise<any>;
124
192
  delete(spanLayerId: string, auditMessage?: string): Promise<any>;
125
- update(spanLayerId: string, name: string, auditMessage?: string): Promise<any>;
126
- create(tokenLayerId: string, name: string, auditMessage?: string): Promise<any>;
127
- shift(spanLayerId: string, direction: string, auditMessage?: string): Promise<any>;
193
+ update(
194
+ spanLayerId: string,
195
+ name: string,
196
+ auditMessage?: string,
197
+ ): Promise<any>;
198
+ create(
199
+ tokenLayerId: string,
200
+ name: string,
201
+ auditMessage?: string,
202
+ ): Promise<any>;
203
+ shift(
204
+ spanLayerId: string,
205
+ direction: string,
206
+ auditMessage?: string,
207
+ ): Promise<any>;
128
208
  }
129
209
 
130
210
  interface SpansBundle {
131
211
  setTokens(spanId: string, tokens: any[], auditMessage?: string): Promise<any>;
132
- create(spanLayerId: string, tokens: any[], value: any, metadata?: any, auditMessage?: string): Promise<any>;
212
+ create(
213
+ spanLayerId: string,
214
+ tokens: any[],
215
+ value: any,
216
+ metadata?: any,
217
+ auditMessage?: string,
218
+ ): Promise<any>;
133
219
  get(spanId: string, asOf?: string): Promise<any>;
134
220
  delete(spanId: string, auditMessage?: string): Promise<any>;
135
221
  update(spanId: string, value: any, auditMessage?: string): Promise<any>;
@@ -148,7 +234,13 @@ interface TextsBundle {
148
234
  setMetadata(textId: string, body: any, auditMessage?: string): Promise<any>;
149
235
  deleteMetadata(textId: string, auditMessage?: string): Promise<any>;
150
236
  patchMetadata(textId: string, body: any, auditMessage?: string): Promise<any>;
151
- create(textLayerId: string, documentId: string, body: string, metadata?: any, auditMessage?: string): Promise<any>;
237
+ create(
238
+ textLayerId: string,
239
+ documentId: string,
240
+ body: string,
241
+ metadata?: any,
242
+ auditMessage?: string,
243
+ ): Promise<any>;
152
244
  get(textId: string, asOf?: string): Promise<any>;
153
245
  delete(textId: string, auditMessage?: string): Promise<any>;
154
246
  update(textId: string, body: any, auditMessage?: string): Promise<any>;
@@ -156,14 +248,35 @@ interface TextsBundle {
156
248
 
157
249
  interface UsersBundle {
158
250
  list(asOf?: string): Promise<any[]>;
159
- listPage(opts?: { limit?: number; cursor?: string; asOf?: string }): Promise<Page>;
251
+ listPage(opts?: {
252
+ limit?: number;
253
+ cursor?: string;
254
+ asOf?: string;
255
+ }): Promise<Page>;
160
256
  iterPages(opts?: { pageSize?: number; asOf?: string }): AsyncGenerator<any[]>;
161
- create(username: string, password: string, isAdmin: boolean, auditMessage?: string): Promise<any>;
162
- audit(userId: string, startTime?: string, endTime?: string, asOf?: string): Promise<any[]>;
257
+ create(
258
+ email: string,
259
+ password: string,
260
+ isAdmin: boolean,
261
+ displayName?: string,
262
+ auditMessage?: string,
263
+ ): Promise<any>;
264
+ audit(
265
+ userId: string,
266
+ startTime?: string,
267
+ endTime?: string,
268
+ asOf?: string,
269
+ ): Promise<any[]>;
163
270
  get(id: string, asOf?: string): Promise<any>;
164
271
  delete(id: string, auditMessage?: string): Promise<any>;
165
272
  activate(id: string, auditMessage?: string): Promise<any>;
166
- update(id: string, password?: string, username?: string, isAdmin?: boolean, auditMessage?: string): Promise<any>;
273
+ update(
274
+ id: string,
275
+ password?: string,
276
+ displayName?: string,
277
+ isAdmin?: boolean,
278
+ auditMessage?: string,
279
+ ): Promise<any>;
167
280
  /** URL for a user's profile picture, usable as an <img> src. Null when avatarHash is explicitly null. */
168
281
  avatarUrl(id: string, avatarHash?: string | null): string | null;
169
282
  getAvatar(id: string): Promise<any>;
@@ -171,11 +284,121 @@ interface UsersBundle {
171
284
  deleteAvatar(id: string, auditMessage?: string): Promise<any>;
172
285
  }
173
286
 
287
+ interface UserDataEntry {
288
+ key: string;
289
+ updatedAt: string;
290
+ value?: any;
291
+ }
292
+
293
+ /** Private per-user key/value storage (owner or admin only; not audited). */
294
+ interface UserDataBundle {
295
+ list(
296
+ userId: string,
297
+ opts?: { prefix?: string; includeValues?: boolean },
298
+ ): Promise<UserDataEntry[]>;
299
+ get(userId: string, key: string): Promise<UserDataEntry & { value: any }>;
300
+ put(
301
+ userId: string,
302
+ key: string,
303
+ value: any,
304
+ ): Promise<{ key: string; updatedAt: string }>;
305
+ delete(userId: string, key: string): Promise<any>;
306
+ }
307
+
308
+ interface CommentFilters {
309
+ documentId?: string;
310
+ entityType?: CommentableType;
311
+ entityId?: string;
312
+ }
313
+
314
+ /** Entities that can carry a comment. */
315
+ type CommentableType =
316
+ | "document"
317
+ | "text"
318
+ | "token"
319
+ | "span"
320
+ | "relation"
321
+ | "vocab-item";
322
+
323
+ interface Comment {
324
+ id: string;
325
+ /** The owning project, or null for a comment on a vocabulary entry. */
326
+ projectId: string | null;
327
+ /** The owning document, or null for a comment on a vocabulary entry. */
328
+ documentId: string | null;
329
+ /** The owning vocab layer, set only for a comment on a vocabulary entry. */
330
+ vocabLayerId: string | null;
331
+ entityType: CommentableType;
332
+ entityId: string;
333
+ /**
334
+ * What the comment is about, in words, captured when it was posted. A
335
+ * comment outlives its anchor, and this is what is left to show once the
336
+ * anchor has been deleted.
337
+ */
338
+ anchorLabel: string | null;
339
+ authorId: string;
340
+ body: string;
341
+ createdAt: string;
342
+ updatedAt: string;
343
+ /** True once the body has been rewritten since it was posted. */
344
+ edited: boolean;
345
+ }
346
+
347
+ interface CommentsBundle {
348
+ create(
349
+ entityType: CommentableType,
350
+ entityId: string,
351
+ body: string,
352
+ opts?: { anchorLabel?: string },
353
+ ): Promise<Comment>;
354
+ get(id: string): Promise<Comment>;
355
+ update(id: string, body: string): Promise<Comment>;
356
+ delete(id: string): Promise<any>;
357
+ list(projectId: string, filters?: CommentFilters): Promise<Comment[]>;
358
+ listPage(
359
+ projectId: string,
360
+ opts?: CommentFilters & { limit?: number; cursor?: string },
361
+ ): Promise<Page<Comment>>;
362
+ iterPages(
363
+ projectId: string,
364
+ opts?: CommentFilters & { pageSize?: number },
365
+ ): AsyncGenerator<Comment[]>;
366
+ /** `{entityId: count}`; keys are raw entity ids, never key-transformed. */
367
+ counts(
368
+ projectId: string,
369
+ filters?: CommentFilters,
370
+ ): Promise<Record<string, number>>;
371
+ /** Comments on a vocabulary's entries, oldest first. */
372
+ listInVocab(
373
+ vocabId: string,
374
+ filters?: { entityId?: string },
375
+ ): Promise<Comment[]>;
376
+ listInVocabPage(
377
+ vocabId: string,
378
+ opts?: { entityId?: string; limit?: number; cursor?: string },
379
+ ): Promise<Page<Comment>>;
380
+ /** `{entryId: count}` over a vocabulary; keys are raw entry ids. */
381
+ countsInVocab(
382
+ vocabId: string,
383
+ filters?: { entityId?: string },
384
+ ): Promise<Record<string, number>>;
385
+ }
386
+
174
387
  interface ApiTokensBundle {
175
388
  list(userId: string): Promise<any[]>;
176
- listPage(userId: string, opts?: { limit?: number; cursor?: string }): Promise<Page>;
177
- iterPages(userId: string, opts?: { pageSize?: number }): AsyncGenerator<any[]>;
178
- create(userId: string, name: string, auditMessage?: string): Promise<{ id: string; name: string; token: string }>;
389
+ listPage(
390
+ userId: string,
391
+ opts?: { limit?: number; cursor?: string },
392
+ ): Promise<Page>;
393
+ iterPages(
394
+ userId: string,
395
+ opts?: { pageSize?: number },
396
+ ): AsyncGenerator<any[]>;
397
+ create(
398
+ userId: string,
399
+ name: string,
400
+ auditMessage?: string,
401
+ ): Promise<{ id: string; name: string; token: string }>;
179
402
  revoke(userId: string, tokenId: string, auditMessage?: string): Promise<any>;
180
403
  }
181
404
 
@@ -207,8 +430,8 @@ interface InvitePreview {
207
430
  grantAdmin: boolean;
208
431
  projectName?: string;
209
432
  projectRole?: string;
210
- /** Present only for a password reset: whose account the link belongs to. */
211
- username?: string;
433
+ /** Present only for a password reset: the email of the account it belongs to. */
434
+ email?: string;
212
435
  }
213
436
 
214
437
  interface CreateInviteOptions {
@@ -225,50 +448,140 @@ interface CreateInviteOptions {
225
448
 
226
449
  interface InvitesBundle {
227
450
  list(opts?: { projectId?: string }): Promise<Invite[]>;
228
- listPage(opts?: { projectId?: string; limit?: number; cursor?: string }): Promise<Page>;
229
- iterPages(opts?: { projectId?: string; pageSize?: number }): AsyncGenerator<Invite[]>;
451
+ listPage(opts?: {
452
+ projectId?: string;
453
+ limit?: number;
454
+ cursor?: string;
455
+ }): Promise<Page>;
456
+ iterPages(opts?: {
457
+ projectId?: string;
458
+ pageSize?: number;
459
+ }): AsyncGenerator<Invite[]>;
230
460
  /** The `code` is returned ONCE and is not recoverable afterward. */
231
- create(opts?: CreateInviteOptions, auditMessage?: string): Promise<Invite & { code: string }>;
461
+ create(
462
+ opts?: CreateInviteOptions,
463
+ auditMessage?: string,
464
+ ): Promise<Invite & { code: string }>;
232
465
  revoke(id: string, auditMessage?: string): Promise<any>;
233
466
  }
234
467
 
235
468
  interface TokenLayersBundle {
236
- shift(tokenLayerId: string, direction: string, auditMessage?: string): Promise<any>;
237
- create(textLayerId: string, name: string, overlapMode?: string, parentTokenLayerId?: string, auditMessage?: string): Promise<any>;
238
- setConfig(tokenLayerId: string, namespace: string, configKey: string, configValue: any, auditMessage?: string): Promise<any>;
239
- deleteConfig(tokenLayerId: string, namespace: string, configKey: string, auditMessage?: string): Promise<any>;
469
+ shift(
470
+ tokenLayerId: string,
471
+ direction: string,
472
+ auditMessage?: string,
473
+ ): Promise<any>;
474
+ create(
475
+ textLayerId: string,
476
+ name: string,
477
+ overlapMode?: string,
478
+ parentTokenLayerId?: string,
479
+ auditMessage?: string,
480
+ ): Promise<any>;
481
+ setConfig(
482
+ tokenLayerId: string,
483
+ namespace: string,
484
+ configKey: string,
485
+ configValue: any,
486
+ auditMessage?: string,
487
+ ): Promise<any>;
488
+ deleteConfig(
489
+ tokenLayerId: string,
490
+ namespace: string,
491
+ configKey: string,
492
+ auditMessage?: string,
493
+ ): Promise<any>;
240
494
  get(tokenLayerId: string, asOf?: string): Promise<any>;
241
495
  delete(tokenLayerId: string, auditMessage?: string): Promise<any>;
242
- update(tokenLayerId: string, name: string, auditMessage?: string): Promise<any>;
496
+ update(
497
+ tokenLayerId: string,
498
+ name: string,
499
+ auditMessage?: string,
500
+ ): Promise<any>;
243
501
  }
244
502
 
245
503
  interface DocumentsBundle {
246
504
  checkLock(documentId: string, asOf?: string): Promise<any>;
247
505
  acquireLock(documentId: string, auditMessage?: string): Promise<any>;
248
506
  releaseLock(documentId: string, auditMessage?: string): Promise<any>;
249
- getMedia(documentId: string, asOf?: string): Promise<ArrayBuffer>;
250
- uploadMedia(documentId: string, file: File, auditMessage?: string): Promise<any>;
507
+ getMedia(documentId: string): Promise<ArrayBuffer>;
508
+ uploadMedia(
509
+ documentId: string,
510
+ file: File,
511
+ auditMessage?: string,
512
+ options?: {
513
+ /** Called with the bytes sent so far as the file goes up (`total` is null when unknown). */
514
+ onProgress?: (progress: { loaded: number; total: number | null }) => void;
515
+ },
516
+ ): Promise<any>;
251
517
  deleteMedia(documentId: string, auditMessage?: string): Promise<any>;
252
- setMetadata(documentId: string, body: any, auditMessage?: string): Promise<any>;
518
+ setMetadata(
519
+ documentId: string,
520
+ body: any,
521
+ auditMessage?: string,
522
+ ): Promise<any>;
253
523
  deleteMetadata(documentId: string, auditMessage?: string): Promise<any>;
254
- patchMetadata(documentId: string, body: any, auditMessage?: string): Promise<any>;
255
- audit(documentId: string, startTime?: string, endTime?: string, asOf?: string): Promise<any[]>;
524
+ patchMetadata(
525
+ documentId: string,
526
+ body: any,
527
+ auditMessage?: string,
528
+ ): Promise<any>;
529
+ audit(
530
+ documentId: string,
531
+ startTime?: string,
532
+ endTime?: string,
533
+ asOf?: string,
534
+ ): Promise<any[]>;
256
535
  get(documentId: string, includeBody?: boolean, asOf?: string): Promise<any>;
257
536
  delete(documentId: string, auditMessage?: string): Promise<any>;
258
537
  update(documentId: string, name: string, auditMessage?: string): Promise<any>;
259
- create(projectId: string, name: string, metadata?: any, auditMessage?: string): Promise<any>;
538
+ create(
539
+ projectId: string,
540
+ name: string,
541
+ metadata?: any,
542
+ auditMessage?: string,
543
+ ): Promise<any>;
260
544
  }
261
545
 
262
546
  interface MessagesBundle {
263
- sendMessage(projectId: string, data: any, auditMessage?: string): Promise<any>;
264
- listen(projectId: string, onEvent: (eventType: string, data: any) => void | boolean, path?: string): SSEConnection;
547
+ sendMessage(
548
+ projectId: string,
549
+ data: any,
550
+ auditMessage?: string,
551
+ ): Promise<any>;
552
+ listen(
553
+ projectId: string,
554
+ onEvent: (eventType: string, data: any) => void | boolean,
555
+ path?: string,
556
+ ): SSEConnection;
265
557
  /** Discover the services seen on a project: online ones plus previously-seen offline ones (check `online`). */
266
558
  discoverServices(projectId: string): Promise<DiscoveredService[]>;
267
559
  /** Forget a previously-seen (offline) service. Maintainer-only; 409 if currently connected. */
268
560
  discardService(projectId: string, serviceId: string): Promise<void>;
269
- serve(projectId: string, serviceInfo: ServiceInfo, onServiceRequest: (data: any, responseHelper: ResponseHelper) => void, extras?: any): ServiceRegistration;
270
- /** Submit work to a service; streams progress to `onProgress`, resolves with the result. */
271
- requestService(projectId: string, serviceId: string, data: any, timeout?: number, onProgress?: (progress: any) => void): Promise<any>;
561
+ /**
562
+ * Register as a service and handle work requests. The registration reopens
563
+ * its channel whenever it drops, so a server restart needs no service restart.
564
+ */
565
+ serve(
566
+ projectId: string,
567
+ serviceInfo: ServiceInfo,
568
+ onServiceRequest: (data: any, responseHelper: ResponseHelper) => void,
569
+ extras?: any,
570
+ onStatus?: (event: ServiceStatusEvent, projectId: string, detail?: string) => void,
571
+ ): ServiceRegistration;
572
+ /**
573
+ * Submit work to a service; streams progress to `onProgress`, resolves with
574
+ * the result. Aborting `signal` stops waiting and rejects with an AbortError;
575
+ * the service is not told and finishes its work regardless.
576
+ */
577
+ requestService(
578
+ projectId: string,
579
+ serviceId: string,
580
+ data: any,
581
+ timeout?: number,
582
+ onProgress?: (progress: any) => void,
583
+ signal?: AbortSignal,
584
+ ): Promise<any>;
272
585
  }
273
586
 
274
587
  interface ProjectsBundle {
@@ -276,32 +589,85 @@ interface ProjectsBundle {
276
589
  removeWriter(id: string, userId: string, auditMessage?: string): Promise<any>;
277
590
  addReader(id: string, userId: string, auditMessage?: string): Promise<any>;
278
591
  removeReader(id: string, userId: string, auditMessage?: string): Promise<any>;
279
- setConfig(id: string, namespace: string, configKey: string, configValue: any, auditMessage?: string): Promise<any>;
280
- deleteConfig(id: string, namespace: string, configKey: string, auditMessage?: string): Promise<any>;
281
- addMaintainer(id: string, userId: string, auditMessage?: string): Promise<any>;
282
- removeMaintainer(id: string, userId: string, auditMessage?: string): Promise<any>;
283
- audit(projectId: string, startTime?: string, endTime?: string, asOf?: string): Promise<any[]>;
592
+ setConfig(
593
+ id: string,
594
+ namespace: string,
595
+ configKey: string,
596
+ configValue: any,
597
+ auditMessage?: string,
598
+ ): Promise<any>;
599
+ deleteConfig(
600
+ id: string,
601
+ namespace: string,
602
+ configKey: string,
603
+ auditMessage?: string,
604
+ ): Promise<any>;
605
+ addMaintainer(
606
+ id: string,
607
+ userId: string,
608
+ auditMessage?: string,
609
+ ): Promise<any>;
610
+ removeMaintainer(
611
+ id: string,
612
+ userId: string,
613
+ auditMessage?: string,
614
+ ): Promise<any>;
615
+ audit(
616
+ projectId: string,
617
+ startTime?: string,
618
+ endTime?: string,
619
+ asOf?: string,
620
+ ): Promise<any[]>;
284
621
  linkVocab(id: string, vocabId: string, auditMessage?: string): Promise<any>;
285
622
  unlinkVocab(id: string, vocabId: string, auditMessage?: string): Promise<any>;
286
623
  get(id: string, asOf?: string): Promise<any>;
287
624
  listDocuments(id: string): Promise<any[]>;
288
- listDocumentsPage(id: string, opts?: { limit?: number; cursor?: string }): Promise<Page>;
289
- iterDocuments(id: string, opts?: { pageSize?: number }): AsyncGenerator<any[]>;
625
+ listDocumentsPage(
626
+ id: string,
627
+ opts?: { limit?: number; cursor?: string },
628
+ ): Promise<Page>;
629
+ iterDocuments(
630
+ id: string,
631
+ opts?: { pageSize?: number },
632
+ ): AsyncGenerator<any[]>;
290
633
  delete(id: string, auditMessage?: string): Promise<any>;
291
634
  update(id: string, name: string, auditMessage?: string): Promise<any>;
292
635
  list(asOf?: string): Promise<any[]>;
293
- listPage(opts?: { limit?: number; cursor?: string; asOf?: string }): Promise<Page>;
636
+ listPage(opts?: {
637
+ limit?: number;
638
+ cursor?: string;
639
+ asOf?: string;
640
+ }): Promise<Page>;
294
641
  iterPages(opts?: { pageSize?: number; asOf?: string }): AsyncGenerator<any[]>;
295
642
  create(name: string, auditMessage?: string): Promise<any>;
296
643
  }
297
644
 
298
645
  interface TextLayersBundle {
299
- setConfig(textLayerId: string, namespace: string, configKey: string, configValue: any, auditMessage?: string): Promise<any>;
300
- deleteConfig(textLayerId: string, namespace: string, configKey: string, auditMessage?: string): Promise<any>;
646
+ setConfig(
647
+ textLayerId: string,
648
+ namespace: string,
649
+ configKey: string,
650
+ configValue: any,
651
+ auditMessage?: string,
652
+ ): Promise<any>;
653
+ deleteConfig(
654
+ textLayerId: string,
655
+ namespace: string,
656
+ configKey: string,
657
+ auditMessage?: string,
658
+ ): Promise<any>;
301
659
  get(textLayerId: string, asOf?: string): Promise<any>;
302
660
  delete(textLayerId: string, auditMessage?: string): Promise<any>;
303
- update(textLayerId: string, name: string, auditMessage?: string): Promise<any>;
304
- shift(textLayerId: string, direction: string, auditMessage?: string): Promise<any>;
661
+ update(
662
+ textLayerId: string,
663
+ name: string,
664
+ auditMessage?: string,
665
+ ): Promise<any>;
666
+ shift(
667
+ textLayerId: string,
668
+ direction: string,
669
+ auditMessage?: string,
670
+ ): Promise<any>;
305
671
  create(projectId: string, name: string, auditMessage?: string): Promise<any>;
306
672
  }
307
673
 
@@ -309,7 +675,12 @@ interface VocabItemsBundle {
309
675
  setMetadata(id: string, body: any, auditMessage?: string): Promise<any>;
310
676
  deleteMetadata(id: string, auditMessage?: string): Promise<any>;
311
677
  patchMetadata(id: string, body: any, auditMessage?: string): Promise<any>;
312
- create(vocabLayerId: string, form: string, metadata?: any, auditMessage?: string): Promise<any>;
678
+ create(
679
+ vocabLayerId: string,
680
+ form: string,
681
+ metadata?: any,
682
+ auditMessage?: string,
683
+ ): Promise<any>;
313
684
  bulkCreate(body: any[], auditMessage?: string): Promise<{ ids: string[] }>;
314
685
  bulkDelete(body: any[], auditMessage?: string): Promise<void>;
315
686
  get(id: string, asOf?: string): Promise<any>;
@@ -318,33 +689,90 @@ interface VocabItemsBundle {
318
689
  }
319
690
 
320
691
  interface RelationLayersBundle {
321
- shift(relationLayerId: string, direction: string, auditMessage?: string): Promise<any>;
322
- create(spanLayerId: string, name: string, auditMessage?: string): Promise<any>;
323
- setConfig(relationLayerId: string, namespace: string, configKey: string, configValue: any, auditMessage?: string): Promise<any>;
324
- deleteConfig(relationLayerId: string, namespace: string, configKey: string, auditMessage?: string): Promise<any>;
692
+ shift(
693
+ relationLayerId: string,
694
+ direction: string,
695
+ auditMessage?: string,
696
+ ): Promise<any>;
697
+ create(
698
+ spanLayerId: string,
699
+ name: string,
700
+ auditMessage?: string,
701
+ ): Promise<any>;
702
+ setConfig(
703
+ relationLayerId: string,
704
+ namespace: string,
705
+ configKey: string,
706
+ configValue: any,
707
+ auditMessage?: string,
708
+ ): Promise<any>;
709
+ deleteConfig(
710
+ relationLayerId: string,
711
+ namespace: string,
712
+ configKey: string,
713
+ auditMessage?: string,
714
+ ): Promise<any>;
325
715
  get(relationLayerId: string, asOf?: string): Promise<any>;
326
716
  delete(relationLayerId: string, auditMessage?: string): Promise<any>;
327
- update(relationLayerId: string, name: string, auditMessage?: string): Promise<any>;
717
+ update(
718
+ relationLayerId: string,
719
+ name: string,
720
+ auditMessage?: string,
721
+ ): Promise<any>;
328
722
  }
329
723
 
330
724
  interface TokensBundle {
331
- create(tokenLayerId: string, text: string, begin: number, end: number, precedence?: number | null, metadata?: any, auditMessage?: string): Promise<any>;
725
+ create(
726
+ tokenLayerId: string,
727
+ text: string,
728
+ begin: number,
729
+ end: number,
730
+ precedence?: number | null,
731
+ metadata?: any,
732
+ auditMessage?: string,
733
+ ): Promise<any>;
332
734
  get(tokenId: string, asOf?: string): Promise<any>;
333
735
  delete(tokenId: string, auditMessage?: string): Promise<any>;
334
- update(tokenId: string, begin?: number, end?: number, precedence?: number | null, auditMessage?: string): Promise<any>;
736
+ update(
737
+ tokenId: string,
738
+ begin?: number,
739
+ end?: number,
740
+ precedence?: number | null,
741
+ auditMessage?: string,
742
+ ): Promise<any>;
335
743
  bulkCreate(body: any[], auditMessage?: string): Promise<{ ids: string[] }>;
336
744
  bulkDelete(body: any[], auditMessage?: string): Promise<void>;
337
745
  split(tokenId: string, position: number, auditMessage?: string): Promise<any>;
338
- merge(tokenId: string, otherTokenId: string, auditMessage?: string): Promise<any>;
339
- shift(tokenId: string, begin?: number, end?: number, auditMessage?: string): Promise<any>;
746
+ merge(
747
+ tokenId: string,
748
+ otherTokenId: string,
749
+ auditMessage?: string,
750
+ ): Promise<any>;
751
+ shift(
752
+ tokenId: string,
753
+ begin?: number,
754
+ end?: number,
755
+ auditMessage?: string,
756
+ ): Promise<any>;
340
757
  setMetadata(tokenId: string, body: any, auditMessage?: string): Promise<any>;
341
758
  deleteMetadata(tokenId: string, auditMessage?: string): Promise<any>;
342
- patchMetadata(tokenId: string, body: any, auditMessage?: string): Promise<any>;
759
+ patchMetadata(
760
+ tokenId: string,
761
+ body: any,
762
+ auditMessage?: string,
763
+ ): Promise<any>;
343
764
  }
344
765
 
345
766
  interface PlaidClientOptions {
346
767
  /** Per-request timeout in ms (default 30000; 0 or null disables it). */
347
768
  timeout?: number | null;
769
+ /**
770
+ * Timeout for batch submissions in ms (default 180000; 0 or null disables it).
771
+ * Batches get their own, longer budget: aborting one does NOT stop the
772
+ * server, which keeps running the transaction and holding the single SQLite
773
+ * write lock. Defaults to `timeout` when that is given and this is not.
774
+ */
775
+ batchTimeout?: number | null;
348
776
  /**
349
777
  * Fired once when a request returns HTTP 401 (missing/expired/invalid token).
350
778
  * Use it to discard the stored token and route back to login. 403 (forbidden)
@@ -360,19 +788,29 @@ export interface OperationGroupsBundle {
360
788
 
361
789
  export declare class PlaidClient {
362
790
  constructor(baseUrl: string, token: string, options?: PlaidClientOptions);
363
- static login(baseUrl: string, userId: string, password: string, options?: PlaidClientOptions): Promise<PlaidClient>;
791
+ static login(
792
+ baseUrl: string,
793
+ userId: string,
794
+ password: string,
795
+ options?: PlaidClientOptions,
796
+ ): Promise<PlaidClient>;
364
797
  /** Build the link to hand someone for an invite code. */
365
798
  static inviteUrl(appUrl: string, code: string): string;
366
799
  /** Describe an invite code with no authentication (for a signup page). */
367
- static lookupInvite(baseUrl: string, code: string, options?: PlaidClientOptions): Promise<InvitePreview>;
800
+ static lookupInvite(
801
+ baseUrl: string,
802
+ code: string,
803
+ options?: PlaidClientOptions,
804
+ ): Promise<InvitePreview>;
368
805
  /** Redeem an invite code with no authentication; resolves to a logged-in client. */
369
806
  static redeemInvite(
370
807
  baseUrl: string,
371
808
  code: string,
372
- credentials: { username?: string; password: string },
809
+ credentials: { email?: string; password: string; displayName?: string },
373
810
  options?: PlaidClientOptions,
374
811
  ): Promise<{ client: PlaidClient; userId: string; kind: string }>;
375
812
  timeout: number | null;
813
+ batchTimeout: number | null;
376
814
  /** Fired once on HTTP 401 (see PlaidClientOptions.onAuthError). */
377
815
  onAuthError: ((error: Error) => void) | null;
378
816
 
@@ -394,7 +832,10 @@ export declare class PlaidClient {
394
832
  operationGroup: { id: string; message: string | null } | null;
395
833
  beginOperation(message: string, opts?: { id?: string }): string;
396
834
  endOperation(message?: string): Promise<void>;
397
- withOperation<T>(message: string, fn: (setMessage: (msg: string) => void) => Promise<T> | T): Promise<T>;
835
+ withOperation<T>(
836
+ message: string,
837
+ fn: (setMessage: (msg: string) => void) => Promise<T> | T,
838
+ ): Promise<T>;
398
839
  operationGroups: OperationGroupsBundle;
399
840
 
400
841
  // Query
@@ -409,7 +850,9 @@ export declare class PlaidClient {
409
850
  texts: TextsBundle;
410
851
  users: UsersBundle;
411
852
  apiTokens: ApiTokensBundle;
853
+ userData: UserDataBundle;
412
854
  invites: InvitesBundle;
855
+ comments: CommentsBundle;
413
856
  tokenLayers: TokenLayersBundle;
414
857
  documents: DocumentsBundle;
415
858
  messages: MessagesBundle;
@@ -441,22 +884,28 @@ export function cpIndexOf(s: string, sub: string, fromCp?: number): number;
441
884
  // Substrate layers are tagged with a role at `config.plaid.role` (a scalar) so
442
885
  // that different apps can share a project. See the manual, "Layer Interoperability".
443
886
  /** The reserved config namespace for cross-app conventions. */
444
- export const PLAID_NAMESPACE: 'plaid';
887
+ export const PLAID_NAMESPACE: "plaid";
445
888
  /** The config key, under `plaid`, holding a layer's role. */
446
- export const ROLE_KEY: 'role';
889
+ export const ROLE_KEY: "role";
890
+
891
+ /** The server's cap on operations per batch request; a larger batch goes as consecutive requests. */
892
+ export const MAX_BATCH_OPS: 1000;
447
893
  /** The fixed role inventory; only these values are interoperable across apps. */
448
894
  export const ROLES: {
449
- readonly BASELINE: 'baseline';
450
- readonly SENTENCE: 'sentence';
451
- readonly WORD: 'word';
452
- readonly SYNTACTIC_WORD: 'syntactic-word';
453
- readonly MORPHEME: 'morpheme';
454
- readonly TIME_ALIGNMENT: 'time-alignment';
895
+ readonly BASELINE: "baseline";
896
+ readonly SENTENCE: "sentence";
897
+ readonly WORD: "word";
898
+ readonly SYNTACTIC_WORD: "syntactic-word";
899
+ readonly MORPHEME: "morpheme";
900
+ readonly TIME_ALIGNMENT: "time-alignment";
455
901
  };
456
902
  /** The role recorded on a layer's `config`, or null if none. */
457
903
  export function readRole(config?: object): string | null;
458
904
  /** The first layer in `layers` carrying the given role, or null. */
459
- export function findByRole<T extends { config?: object }>(layers: T[] | undefined, role: string): T | null;
905
+ export function findByRole<T extends { config?: object }>(
906
+ layers: T[] | undefined,
907
+ role: string,
908
+ ): T | null;
460
909
 
461
910
  // --- Service self-description helpers ----------------------------------------
462
911
  // Standardize how a service advertises (in `extras`) the tasks it serves, a
@@ -465,15 +914,19 @@ export function findByRole<T extends { config?: object }>(layers: T[] | undefine
465
914
  // "Describing a service".
466
915
  /** The controlled task vocabulary — the fixed integration-point goals. */
467
916
  export const TASKS: {
468
- readonly TOKENIZE: 'tokenize';
469
- readonly PARSE: 'parse';
470
- readonly TRANSCRIBE: 'transcribe';
471
- readonly LINK_VOCAB: 'link-vocab';
917
+ readonly TOKENIZE: "tokenize";
918
+ readonly PARSE: "parse";
919
+ readonly TRANSCRIBE: "transcribe";
920
+ readonly LINK_VOCAB: "link-vocab";
921
+ readonly ANALYZE: "analyze";
472
922
  };
473
923
  /** Whether a service serves a task (declared `extras.tasks`, legacy id-prefix fallback). */
474
924
  export function servesTask(service: DiscoveredService, task: string): boolean;
475
925
  /** The discovered services that serve `task`. */
476
- export function filterServicesByTask(services: DiscoveredService[] | undefined, task: string): DiscoveredService[];
926
+ export function filterServicesByTask(
927
+ services: DiscoveredService[] | undefined,
928
+ task: string,
929
+ ): DiscoveredService[];
477
930
  /** The parameter schema a service declares (ordered), or []. */
478
931
  export function getParamSchema(service: DiscoveredService): ServiceParam[];
479
932
  /** A service's human summary: `extras.summary`, else `description`, else ''. */
@@ -481,7 +934,10 @@ export function getServiceSummary(service: DiscoveredService): string;
481
934
  /** Default form values keyed by param key. */
482
935
  export function buildDefaultValues(schema: ServiceParam[]): Record<string, any>;
483
936
  /** Coerce/validate raw form values against the schema. */
484
- export function coerceParamValues(schema: ServiceParam[], raw: Record<string, any>): { values: Record<string, any>; errors: Record<string, string> };
937
+ export function coerceParamValues(
938
+ schema: ServiceParam[],
939
+ raw: Record<string, any>,
940
+ ): { values: Record<string, any>; errors: Record<string, string> };
485
941
 
486
942
  // --- Provenance ---------------------------------------------------------------
487
943
  // Cross-app convention for machine-provided vs human-labeled information,
@@ -491,32 +947,50 @@ export function coerceParamValues(schema: ServiceParam[], raw: Record<string, an
491
947
  // replace unverified machine material but must never touch human/verified
492
948
  // material without an explicit overwrite opt-in; any human edit verifies.
493
949
  // See the manual, "Provenance".
494
- type ProvState = 'human' | 'machine' | 'verified';
950
+ type ProvState = "human" | "machine" | "verified";
495
951
  export const PROV: {
496
- readonly key: 'prov';
497
- readonly sourceKey: 'provSource';
498
- readonly confirmedKey: 'provConfirmed';
499
- readonly probKey: 'provProb';
500
- readonly detailKey: 'provDetail';
501
- readonly INFERRED: 'inferred';
952
+ readonly key: "prov";
953
+ readonly sourceKey: "provSource";
954
+ readonly confirmedKey: "provConfirmed";
955
+ readonly probKey: "provProb";
956
+ readonly detailKey: "provDetail";
957
+ readonly INFERRED: "inferred";
502
958
  };
503
959
  export const PROV_STATES: {
504
- readonly HUMAN: 'human';
505
- readonly MACHINE: 'machine';
506
- readonly VERIFIED: 'verified';
960
+ readonly HUMAN: "human";
961
+ readonly MACHINE: "machine";
962
+ readonly VERIFIED: "verified";
507
963
  };
508
964
  /** Optional prediction extras: prob = a probability in [0,1] for the chosen value
509
965
  * (flat + queryable; omit unless it honestly is one); detail = an open map of
510
966
  * producer extras (top-k alternatives, model version, raw scores; keep it small).
511
967
  * Both describe the ORIGINAL prediction — check provConfirmed before presenting
512
968
  * provProb as confidence in the current value. */
513
- interface ProvExtras { prob?: number; detail?: Record<string, any> }
969
+ interface ProvExtras {
970
+ prob?: number;
971
+ detail?: Record<string, any>;
972
+ }
514
973
  /** The metadata fragment a machine writer merges into everything it creates. */
515
- export function stampInferred(source: string, extras?: ProvExtras):
516
- { prov: 'inferred'; provSource: string; provProb?: number; provDetail?: Record<string, any> };
974
+ export function stampInferred(
975
+ source: string,
976
+ extras?: ProvExtras,
977
+ ): {
978
+ prov: "inferred";
979
+ provSource: string;
980
+ provProb?: number;
981
+ provDetail?: Record<string, any>;
982
+ };
517
983
  /** stampInferred + provConfirmed — for machine material born verified (e.g. imports with upstream approval). */
518
- export function confirmedInferred(source: string, extras?: ProvExtras):
519
- { prov: 'inferred'; provSource: string; provConfirmed: true; provProb?: number; provDetail?: Record<string, any> };
984
+ export function confirmedInferred(
985
+ source: string,
986
+ extras?: ProvExtras,
987
+ ): {
988
+ prov: "inferred";
989
+ provSource: string;
990
+ provConfirmed: true;
991
+ provProb?: number;
992
+ provDetail?: Record<string, any>;
993
+ };
520
994
  /** Classify an entity's metadata into one of the three provenance states. */
521
995
  export function provState(metadata: object | null | undefined): ProvState;
522
996
  /** The verifying fragment, { provConfirmed: true }: PATCH it over existing metadata. */
@@ -526,6 +1000,8 @@ export function isMachine(metadata: object | null | undefined): boolean;
526
1000
  /** Whether a machine writer must leave this entity alone (human or verified). !isMachine. */
527
1001
  export function isProtected(metadata: object | null | undefined): boolean;
528
1002
  /** The fragment a HUMAN edit should merge in: PROV_CONFIRMED iff machine-unverified, else null. */
529
- export function verifyOnEdit(metadata: object | null | undefined): { readonly provConfirmed: true } | null;
1003
+ export function verifyOnEdit(
1004
+ metadata: object | null | undefined,
1005
+ ): { readonly provConfirmed: true } | null;
530
1006
  /** Canonical provSource for a service: 'service:<serviceId>'. */
531
1007
  export function serviceSource(serviceId: string): string;