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

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;
@@ -25,6 +25,8 @@ interface ServiceParam {
25
25
  min?: number;
26
26
  max?: number;
27
27
  step?: number;
28
+ /** `number` only: render as a slider to drag rather than a box to type in. */
29
+ slider?: boolean;
28
30
  /** `string` only. */
29
31
  placeholder?: string;
30
32
  multiline?: boolean;
@@ -62,16 +64,49 @@ interface DiscoveredService {
62
64
 
63
65
  interface ServiceRegistration {
64
66
  stop(): void;
67
+ /** Still serving, including while retrying a channel through a server restart. */
65
68
  isRunning(): boolean;
69
+ /** Channel open right now, i.e. the server currently sees this service as online. */
70
+ isConnected(): boolean;
66
71
  serviceInfo: ServiceInfo & { extras: any };
67
72
  }
68
73
 
74
+ /** Connection-state transitions reported by a service registration. */
75
+ type ServiceStatusEvent = "registered" | "reconnected" | "disconnected";
76
+
69
77
  interface ResponseHelper {
70
- progress(percent: number, message: string): void;
78
+ requestId: string;
79
+ requesterId: string | null;
80
+ /** True once the requester has asked this request to stop. */
81
+ readonly cancelled: boolean;
82
+ /**
83
+ * Report progress — and a cancellation CHECKPOINT: throws
84
+ * `ServiceCancelled` once a stop has been asked for, which is what makes a
85
+ * service that already reports progress cancellable for free.
86
+ */
87
+ progress(percent: number, message: string, extra?: Record<string, any>): void;
88
+ /** Stop here if the requester has asked the request to stop. */
89
+ raiseIfCancelled(): void;
90
+ /** Run `fn` as a stretch that must finish once begun, usually the writes. */
91
+ critical<T>(fn: () => T | Promise<T>): Promise<T>;
71
92
  complete(data: any): void;
93
+ /** End the request because it was asked to stop; result carries `stopped: true`. */
94
+ stopped(data?: any): void;
72
95
  error(error: string | Error): void;
73
96
  }
74
97
 
98
+ /** Thrown inside a handler when the requester has asked it to stop. */
99
+ export class ServiceCancelled extends Error {
100
+ constructor(message?: string);
101
+ }
102
+
103
+ /** The cancellation half of a responseHelper, on its own. */
104
+ export function createCancelScope(isCancelled: () => boolean): {
105
+ readonly cancelled: boolean;
106
+ raiseIfCancelled(): void;
107
+ critical<T>(fn: () => T | Promise<T>): Promise<T>;
108
+ };
109
+
75
110
  interface SSEConnection {
76
111
  close(): void;
77
112
  getStats(): any;
@@ -79,7 +114,12 @@ interface SSEConnection {
79
114
  }
80
115
 
81
116
  interface VocabLinksBundle {
82
- create(vocabItem: string, tokens: any[], metadata?: any, auditMessage?: string): Promise<any>;
117
+ create(
118
+ vocabItem: string,
119
+ tokens: any[],
120
+ metadata?: any,
121
+ auditMessage?: string,
122
+ ): Promise<any>;
83
123
  bulkCreate(body: any[], auditMessage?: string): Promise<{ ids: string[] }>;
84
124
  bulkDelete(body: any[], auditMessage?: string): Promise<void>;
85
125
  setMetadata(id: string, body: any, auditMessage?: string): Promise<any>;
@@ -93,43 +133,118 @@ interface VocabLayersBundle {
93
133
  get(id: string, includeItems?: boolean, asOf?: string): Promise<any>;
94
134
  delete(id: string, auditMessage?: string): Promise<any>;
95
135
  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>;
136
+ setConfig(
137
+ id: string,
138
+ namespace: string,
139
+ configKey: string,
140
+ configValue: any,
141
+ auditMessage?: string,
142
+ ): Promise<any>;
143
+ deleteConfig(
144
+ id: string,
145
+ namespace: string,
146
+ configKey: string,
147
+ auditMessage?: string,
148
+ ): Promise<any>;
98
149
  list(asOf?: string): Promise<any[]>;
99
- listPage(opts?: { limit?: number; cursor?: string; asOf?: string }): Promise<Page>;
150
+ listPage(opts?: {
151
+ limit?: number;
152
+ cursor?: string;
153
+ asOf?: string;
154
+ }): Promise<Page>;
100
155
  iterPages(opts?: { pageSize?: number; asOf?: string }): AsyncGenerator<any[]>;
101
156
  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>;
157
+ addMaintainer(
158
+ id: string,
159
+ userId: string,
160
+ auditMessage?: string,
161
+ ): Promise<any>;
162
+ removeMaintainer(
163
+ id: string,
164
+ userId: string,
165
+ auditMessage?: string,
166
+ ): Promise<any>;
104
167
  }
105
168
 
106
169
  interface RelationsBundle {
107
- setMetadata(relationId: string, body: any, auditMessage?: string): Promise<any>;
170
+ setMetadata(
171
+ relationId: string,
172
+ body: any,
173
+ auditMessage?: string,
174
+ ): Promise<any>;
108
175
  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>;
176
+ patchMetadata(
177
+ relationId: string,
178
+ body: any,
179
+ auditMessage?: string,
180
+ ): Promise<any>;
181
+ setTarget(
182
+ relationId: string,
183
+ spanId: string,
184
+ auditMessage?: string,
185
+ ): Promise<any>;
111
186
  get(relationId: string, asOf?: string): Promise<any>;
112
187
  delete(relationId: string, auditMessage?: string): Promise<any>;
113
188
  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>;
189
+ setSource(
190
+ relationId: string,
191
+ spanId: string,
192
+ auditMessage?: string,
193
+ ): Promise<any>;
194
+ create(
195
+ layerId: string,
196
+ sourceId: string,
197
+ targetId: string,
198
+ value: any,
199
+ metadata?: any,
200
+ auditMessage?: string,
201
+ ): Promise<any>;
116
202
  bulkCreate(body: any[], auditMessage?: string): Promise<{ ids: string[] }>;
117
203
  bulkDelete(body: any[], auditMessage?: string): Promise<void>;
118
204
  }
119
205
 
120
206
  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>;
207
+ setConfig(
208
+ spanLayerId: string,
209
+ namespace: string,
210
+ configKey: string,
211
+ configValue: any,
212
+ auditMessage?: string,
213
+ ): Promise<any>;
214
+ deleteConfig(
215
+ spanLayerId: string,
216
+ namespace: string,
217
+ configKey: string,
218
+ auditMessage?: string,
219
+ ): Promise<any>;
123
220
  get(spanLayerId: string, asOf?: string): Promise<any>;
124
221
  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>;
222
+ update(
223
+ spanLayerId: string,
224
+ name: string,
225
+ auditMessage?: string,
226
+ ): Promise<any>;
227
+ create(
228
+ tokenLayerId: string,
229
+ name: string,
230
+ auditMessage?: string,
231
+ ): Promise<any>;
232
+ shift(
233
+ spanLayerId: string,
234
+ direction: string,
235
+ auditMessage?: string,
236
+ ): Promise<any>;
128
237
  }
129
238
 
130
239
  interface SpansBundle {
131
240
  setTokens(spanId: string, tokens: any[], auditMessage?: string): Promise<any>;
132
- create(spanLayerId: string, tokens: any[], value: any, metadata?: any, auditMessage?: string): Promise<any>;
241
+ create(
242
+ spanLayerId: string,
243
+ tokens: any[],
244
+ value: any,
245
+ metadata?: any,
246
+ auditMessage?: string,
247
+ ): Promise<any>;
133
248
  get(spanId: string, asOf?: string): Promise<any>;
134
249
  delete(spanId: string, auditMessage?: string): Promise<any>;
135
250
  update(spanId: string, value: any, auditMessage?: string): Promise<any>;
@@ -148,7 +263,13 @@ interface TextsBundle {
148
263
  setMetadata(textId: string, body: any, auditMessage?: string): Promise<any>;
149
264
  deleteMetadata(textId: string, auditMessage?: string): Promise<any>;
150
265
  patchMetadata(textId: string, body: any, auditMessage?: string): Promise<any>;
151
- create(textLayerId: string, documentId: string, body: string, metadata?: any, auditMessage?: string): Promise<any>;
266
+ create(
267
+ textLayerId: string,
268
+ documentId: string,
269
+ body: string,
270
+ metadata?: any,
271
+ auditMessage?: string,
272
+ ): Promise<any>;
152
273
  get(textId: string, asOf?: string): Promise<any>;
153
274
  delete(textId: string, auditMessage?: string): Promise<any>;
154
275
  update(textId: string, body: any, auditMessage?: string): Promise<any>;
@@ -156,14 +277,36 @@ interface TextsBundle {
156
277
 
157
278
  interface UsersBundle {
158
279
  list(asOf?: string): Promise<any[]>;
159
- listPage(opts?: { limit?: number; cursor?: string; asOf?: string }): Promise<Page>;
280
+ listPage(opts?: {
281
+ limit?: number;
282
+ cursor?: string;
283
+ asOf?: string;
284
+ }): Promise<Page>;
160
285
  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[]>;
286
+ create(
287
+ email: string,
288
+ password: string,
289
+ isAdmin: boolean,
290
+ displayName?: string,
291
+ auditMessage?: string,
292
+ ): Promise<any>;
293
+ audit(
294
+ userId: string,
295
+ startTime?: string,
296
+ endTime?: string,
297
+ asOf?: string,
298
+ ): Promise<any[]>;
299
+ auditPage(userId: string, opts?: AuditPageOptions): Promise<Page>;
163
300
  get(id: string, asOf?: string): Promise<any>;
164
301
  delete(id: string, auditMessage?: string): Promise<any>;
165
302
  activate(id: string, auditMessage?: string): Promise<any>;
166
- update(id: string, password?: string, username?: string, isAdmin?: boolean, auditMessage?: string): Promise<any>;
303
+ update(
304
+ id: string,
305
+ password?: string,
306
+ displayName?: string,
307
+ isAdmin?: boolean,
308
+ auditMessage?: string,
309
+ ): Promise<any>;
167
310
  /** URL for a user's profile picture, usable as an <img> src. Null when avatarHash is explicitly null. */
168
311
  avatarUrl(id: string, avatarHash?: string | null): string | null;
169
312
  getAvatar(id: string): Promise<any>;
@@ -171,11 +314,116 @@ interface UsersBundle {
171
314
  deleteAvatar(id: string, auditMessage?: string): Promise<any>;
172
315
  }
173
316
 
317
+ interface UserDataEntry {
318
+ key: string;
319
+ updatedAt: string;
320
+ value?: any;
321
+ }
322
+
323
+ /** Private per-user key/value storage (owner or admin only; not audited). */
324
+ interface UserDataBundle {
325
+ list(
326
+ userId: string,
327
+ opts?: { prefix?: string; includeValues?: boolean },
328
+ ): Promise<UserDataEntry[]>;
329
+ get(userId: string, key: string): Promise<UserDataEntry & { value: any }>;
330
+ put(
331
+ userId: string,
332
+ key: string,
333
+ value: any,
334
+ ): Promise<{ key: string; updatedAt: string }>;
335
+ delete(userId: string, key: string): Promise<any>;
336
+ }
337
+
338
+ interface CommentFilters {
339
+ documentId?: string;
340
+ entityType?: CommentableType;
341
+ entityId?: string;
342
+ }
343
+
344
+ /** Entities that can carry a comment. */
345
+ type CommentableType =
346
+ "document" | "text" | "token" | "span" | "relation" | "vocab-item";
347
+
348
+ interface Comment {
349
+ id: string;
350
+ /** The owning project, or null for a comment on a vocabulary entry. */
351
+ projectId: string | null;
352
+ /** The owning document, or null for a comment on a vocabulary entry. */
353
+ documentId: string | null;
354
+ /** The owning vocab layer, set only for a comment on a vocabulary entry. */
355
+ vocabLayerId: string | null;
356
+ entityType: CommentableType;
357
+ entityId: string;
358
+ /**
359
+ * What the comment is about, in words, captured when it was posted. A
360
+ * comment outlives its anchor, and this is what is left to show once the
361
+ * anchor has been deleted.
362
+ */
363
+ anchorLabel: string | null;
364
+ authorId: string;
365
+ body: string;
366
+ createdAt: string;
367
+ updatedAt: string;
368
+ /** True once the body has been rewritten since it was posted. */
369
+ edited: boolean;
370
+ }
371
+
372
+ interface CommentsBundle {
373
+ create(
374
+ entityType: CommentableType,
375
+ entityId: string,
376
+ body: string,
377
+ opts?: { anchorLabel?: string },
378
+ ): Promise<Comment>;
379
+ get(id: string): Promise<Comment>;
380
+ update(id: string, body: string): Promise<Comment>;
381
+ delete(id: string): Promise<any>;
382
+ list(projectId: string, filters?: CommentFilters): Promise<Comment[]>;
383
+ listPage(
384
+ projectId: string,
385
+ opts?: CommentFilters & { limit?: number; cursor?: string },
386
+ ): Promise<Page<Comment>>;
387
+ iterPages(
388
+ projectId: string,
389
+ opts?: CommentFilters & { pageSize?: number },
390
+ ): AsyncGenerator<Comment[]>;
391
+ /** `{entityId: count}`; keys are raw entity ids, never key-transformed. */
392
+ counts(
393
+ projectId: string,
394
+ filters?: CommentFilters,
395
+ ): Promise<Record<string, number>>;
396
+ /** Comments on a vocabulary's entries, oldest first. */
397
+ listInVocab(
398
+ vocabId: string,
399
+ filters?: { entityId?: string },
400
+ ): Promise<Comment[]>;
401
+ listInVocabPage(
402
+ vocabId: string,
403
+ opts?: { entityId?: string; limit?: number; cursor?: string },
404
+ ): Promise<Page<Comment>>;
405
+ /** `{entryId: count}` over a vocabulary; keys are raw entry ids. */
406
+ countsInVocab(
407
+ vocabId: string,
408
+ filters?: { entityId?: string },
409
+ ): Promise<Record<string, number>>;
410
+ }
411
+
174
412
  interface ApiTokensBundle {
175
413
  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 }>;
414
+ listPage(
415
+ userId: string,
416
+ opts?: { limit?: number; cursor?: string },
417
+ ): Promise<Page>;
418
+ iterPages(
419
+ userId: string,
420
+ opts?: { pageSize?: number },
421
+ ): AsyncGenerator<any[]>;
422
+ create(
423
+ userId: string,
424
+ name: string,
425
+ auditMessage?: string,
426
+ ): Promise<{ id: string; name: string; token: string }>;
179
427
  revoke(userId: string, tokenId: string, auditMessage?: string): Promise<any>;
180
428
  }
181
429
 
@@ -207,8 +455,8 @@ interface InvitePreview {
207
455
  grantAdmin: boolean;
208
456
  projectName?: string;
209
457
  projectRole?: string;
210
- /** Present only for a password reset: whose account the link belongs to. */
211
- username?: string;
458
+ /** Present only for a password reset: the email of the account it belongs to. */
459
+ email?: string;
212
460
  }
213
461
 
214
462
  interface CreateInviteOptions {
@@ -223,52 +471,327 @@ interface CreateInviteOptions {
223
471
  note?: string;
224
472
  }
225
473
 
474
+ /** Server limits, as reported by /api/v1/info. An unset limit is absent. */
475
+ interface ServerLimits {
476
+ mediaFileBytes?: number;
477
+ jsonBodyBytes?: number;
478
+ batchOperations?: number;
479
+ metadataDepth?: number;
480
+ metadataKeyCount?: number;
481
+ metadataStringLength?: number;
482
+ metadataTotalBytes?: number;
483
+ userDataValueBytes?: number;
484
+ }
485
+
486
+ interface ServerHealth {
487
+ ok: boolean;
488
+ version: string;
489
+ uptimeMs: number;
490
+ audit: { dbSizeMb?: number; auditRows?: number; error?: string };
491
+ }
492
+
493
+ interface DocumentLock {
494
+ documentId: string;
495
+ userId: string;
496
+ expiresAt: number;
497
+ }
498
+
499
+ interface RateLimitBucket {
500
+ ip: string;
501
+ userId?: string;
502
+ failures: number;
503
+ limit: number;
504
+ blocked: boolean;
505
+ }
506
+
507
+ interface RateLimitSnapshot {
508
+ windowMs: number;
509
+ logins: RateLimitBucket[];
510
+ ips: RateLimitBucket[];
511
+ invites: RateLimitBucket[];
512
+ }
513
+
514
+ interface BackupStatus {
515
+ enabled: boolean;
516
+ directory: string;
517
+ retention: number;
518
+ time: string;
519
+ backups: Array<{ name: string; bytes: number; modified: string }>;
520
+ ok?: boolean;
521
+ }
522
+
523
+ interface ServerReport {
524
+ version: string;
525
+ jvm: {
526
+ uptimeMs: number;
527
+ startedAt: string;
528
+ java: string;
529
+ heapUsed: number;
530
+ heapMax: number;
531
+ };
532
+ database: {
533
+ path: string | null;
534
+ bytes: number | null;
535
+ walBytes: number | null;
536
+ slowQueryThresholdMs?: number;
537
+ journalMode?: string;
538
+ maxPoolSize?: number;
539
+ tables: Record<string, number | null>;
540
+ };
541
+ media: {
542
+ directory: string;
543
+ files: number;
544
+ bytes: number;
545
+ orphans: number;
546
+ orphanBytes: number;
547
+ };
548
+ backup: BackupStatus;
549
+ settings: Record<string, any>;
550
+ }
551
+
552
+ /** Server-level facts. `info` is fetched at most once per client. */
553
+ interface ServerBundle {
554
+ info(): Promise<{ limits: ServerLimits }>;
555
+ limits(): Promise<ServerLimits>;
556
+ health(): Promise<ServerHealth>;
557
+ }
558
+
559
+ /** Instance-wide operations. Every method requires a global admin. */
560
+ interface AdminBundle {
561
+ server(): Promise<ServerReport>;
562
+ backup(): Promise<BackupStatus>;
563
+ locks(): Promise<{ entries: DocumentLock[] }>;
564
+ releaseLock(documentId: string): Promise<{ result: string }>;
565
+ rateLimits(): Promise<RateLimitSnapshot>;
566
+ clearRateLimits(opts?: {
567
+ ip?: string;
568
+ userId?: string;
569
+ }): Promise<{ result: string }>;
570
+ logs(opts?: {
571
+ lines?: number;
572
+ }): Promise<{ file: string | null; lines: string[]; error?: string }>;
573
+ userData(opts?: AdminUserDataOptions): Promise<AdminUserDataEntry[]>;
574
+ userDataPage(
575
+ opts?: AdminUserDataOptions & { limit?: number; cursor?: string },
576
+ ): Promise<Page<AdminUserDataEntry>>;
577
+ }
578
+
579
+ /** Narrowings for the cross-account private-data listing. */
580
+ interface AdminUserDataOptions {
581
+ /** Only keys starting with this literal head. */
582
+ prefix?: string;
583
+ /** Only keys matching this GLOB (`*` any run, `?` one character). */
584
+ pattern?: string;
585
+ includeValues?: boolean;
586
+ }
587
+
588
+ type AdminUserDataEntry = UserDataEntry & { userId: string };
589
+
590
+ /** Options for a single page of any audit log. */
591
+ interface AuditPageOptions {
592
+ startTime?: string;
593
+ endTime?: string;
594
+ asOf?: string;
595
+ opTypes?: string[] | string;
596
+ /** "desc" pages newest-first; a cursor belongs to the direction that made it. */
597
+ order?: "asc" | "desc";
598
+ limit?: number;
599
+ cursor?: string;
600
+ }
601
+
602
+ /** One user's activity over a scope and window. */
603
+ interface ActivityTallyRow {
604
+ user: { id: string; displayName?: string };
605
+ operations: number;
606
+ changes: number;
607
+ documents: number;
608
+ firstTs: string;
609
+ lastTs: string;
610
+ byDay?: Array<{ date: string; changes: number }>;
611
+ }
612
+
613
+ /** Instance-wide audit reads and the per-user aggregate. */
614
+ interface AuditBundle {
615
+ /** Admin only. */
616
+ list(opts?: {
617
+ startTime?: string;
618
+ endTime?: string;
619
+ opTypes?: string[] | string;
620
+ }): Promise<any[]>;
621
+ /** Admin only. */
622
+ listPage(opts?: AuditPageOptions): Promise<Page>;
623
+ /** Admin only. */
624
+ iterPages(opts?: {
625
+ startTime?: string;
626
+ endTime?: string;
627
+ opTypes?: string[] | string;
628
+ pageSize?: number;
629
+ }): AsyncGenerator<any[]>;
630
+ /** With projectId, open to that project's maintainers; without one, admin only. */
631
+ tally(opts?: {
632
+ projectId?: string;
633
+ startTime?: string;
634
+ endTime?: string;
635
+ daily?: boolean;
636
+ }): Promise<ActivityTallyRow[]>;
637
+ }
638
+
226
639
  interface InvitesBundle {
227
- 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[]>;
640
+ list(opts?: { projectId?: string; all?: boolean }): Promise<Invite[]>;
641
+ listPage(opts?: {
642
+ projectId?: string;
643
+ all?: boolean;
644
+ limit?: number;
645
+ cursor?: string;
646
+ }): Promise<Page>;
647
+ iterPages(opts?: {
648
+ projectId?: string;
649
+ all?: boolean;
650
+ pageSize?: number;
651
+ }): AsyncGenerator<Invite[]>;
230
652
  /** The `code` is returned ONCE and is not recoverable afterward. */
231
- create(opts?: CreateInviteOptions, auditMessage?: string): Promise<Invite & { code: string }>;
653
+ create(
654
+ opts?: CreateInviteOptions,
655
+ auditMessage?: string,
656
+ ): Promise<Invite & { code: string }>;
232
657
  revoke(id: string, auditMessage?: string): Promise<any>;
233
658
  }
234
659
 
235
660
  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>;
661
+ shift(
662
+ tokenLayerId: string,
663
+ direction: string,
664
+ auditMessage?: string,
665
+ ): Promise<any>;
666
+ create(
667
+ textLayerId: string,
668
+ name: string,
669
+ overlapMode?: string,
670
+ parentTokenLayerId?: string,
671
+ auditMessage?: string,
672
+ ): Promise<any>;
673
+ setConfig(
674
+ tokenLayerId: string,
675
+ namespace: string,
676
+ configKey: string,
677
+ configValue: any,
678
+ auditMessage?: string,
679
+ ): Promise<any>;
680
+ deleteConfig(
681
+ tokenLayerId: string,
682
+ namespace: string,
683
+ configKey: string,
684
+ auditMessage?: string,
685
+ ): Promise<any>;
240
686
  get(tokenLayerId: string, asOf?: string): Promise<any>;
241
687
  delete(tokenLayerId: string, auditMessage?: string): Promise<any>;
242
- update(tokenLayerId: string, name: string, auditMessage?: string): Promise<any>;
688
+ update(
689
+ tokenLayerId: string,
690
+ name: string,
691
+ auditMessage?: string,
692
+ ): Promise<any>;
243
693
  }
244
694
 
245
695
  interface DocumentsBundle {
246
696
  checkLock(documentId: string, asOf?: string): Promise<any>;
247
697
  acquireLock(documentId: string, auditMessage?: string): Promise<any>;
248
698
  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>;
699
+ getMedia(documentId: string): Promise<ArrayBuffer>;
700
+ uploadMedia(
701
+ documentId: string,
702
+ file: File,
703
+ auditMessage?: string,
704
+ options?: {
705
+ /** Called with the bytes sent so far as the file goes up (`total` is null when unknown). */
706
+ onProgress?: (progress: { loaded: number; total: number | null }) => void;
707
+ },
708
+ ): Promise<any>;
251
709
  deleteMedia(documentId: string, auditMessage?: string): Promise<any>;
252
- setMetadata(documentId: string, body: any, auditMessage?: string): Promise<any>;
710
+ setMetadata(
711
+ documentId: string,
712
+ body: any,
713
+ auditMessage?: string,
714
+ ): Promise<any>;
253
715
  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[]>;
716
+ patchMetadata(
717
+ documentId: string,
718
+ body: any,
719
+ auditMessage?: string,
720
+ ): Promise<any>;
721
+ audit(
722
+ documentId: string,
723
+ startTime?: string,
724
+ endTime?: string,
725
+ asOf?: string,
726
+ ): Promise<any[]>;
727
+ auditPage(documentId: string, opts?: AuditPageOptions): Promise<Page>;
256
728
  get(documentId: string, includeBody?: boolean, asOf?: string): Promise<any>;
257
729
  delete(documentId: string, auditMessage?: string): Promise<any>;
258
730
  update(documentId: string, name: string, auditMessage?: string): Promise<any>;
259
- create(projectId: string, name: string, metadata?: any, auditMessage?: string): Promise<any>;
731
+ create(
732
+ projectId: string,
733
+ name: string,
734
+ metadata?: any,
735
+ auditMessage?: string,
736
+ ): Promise<any>;
737
+ /** Copy a document and everything in it into a new document of the same project. */
738
+ copy(
739
+ documentId: string,
740
+ name: string,
741
+ options?: { includeMedia?: boolean },
742
+ auditMessage?: string,
743
+ ): Promise<{ id: string; mediaError?: string }>;
744
+ restore(
745
+ documentId: string,
746
+ asOf: string,
747
+ options?: { dryRun?: boolean },
748
+ auditMessage?: string,
749
+ ): Promise<any>;
260
750
  }
261
751
 
262
752
  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;
753
+ sendMessage(
754
+ projectId: string,
755
+ data: any,
756
+ auditMessage?: string,
757
+ ): Promise<any>;
758
+ listen(
759
+ projectId: string,
760
+ onEvent: (eventType: string, data: any) => void | boolean,
761
+ path?: string,
762
+ ): SSEConnection;
265
763
  /** Discover the services seen on a project: online ones plus previously-seen offline ones (check `online`). */
266
764
  discoverServices(projectId: string): Promise<DiscoveredService[]>;
267
765
  /** Forget a previously-seen (offline) service. Maintainer-only; 409 if currently connected. */
268
766
  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>;
767
+ /**
768
+ * Register as a service and handle work requests. The registration reopens
769
+ * its channel whenever it drops, so a server restart needs no service restart.
770
+ */
771
+ serve(
772
+ projectId: string,
773
+ serviceInfo: ServiceInfo,
774
+ onServiceRequest: (data: any, responseHelper: ResponseHelper) => void,
775
+ extras?: any,
776
+ onStatus?: (
777
+ event: ServiceStatusEvent,
778
+ projectId: string,
779
+ detail?: string,
780
+ ) => void,
781
+ ): ServiceRegistration;
782
+ /**
783
+ * Submit work to a service; streams progress to `onProgress`, resolves with
784
+ * the result. Aborting `signal` stops waiting and rejects with an AbortError;
785
+ * the service is not told and finishes its work regardless.
786
+ */
787
+ requestService(
788
+ projectId: string,
789
+ serviceId: string,
790
+ data: any,
791
+ timeout?: number,
792
+ onProgress?: (progress: any) => void,
793
+ signal?: AbortSignal,
794
+ ): Promise<any>;
272
795
  }
273
796
 
274
797
  interface ProjectsBundle {
@@ -276,32 +799,86 @@ interface ProjectsBundle {
276
799
  removeWriter(id: string, userId: string, auditMessage?: string): Promise<any>;
277
800
  addReader(id: string, userId: string, auditMessage?: string): Promise<any>;
278
801
  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[]>;
802
+ setConfig(
803
+ id: string,
804
+ namespace: string,
805
+ configKey: string,
806
+ configValue: any,
807
+ auditMessage?: string,
808
+ ): Promise<any>;
809
+ deleteConfig(
810
+ id: string,
811
+ namespace: string,
812
+ configKey: string,
813
+ auditMessage?: string,
814
+ ): Promise<any>;
815
+ addMaintainer(
816
+ id: string,
817
+ userId: string,
818
+ auditMessage?: string,
819
+ ): Promise<any>;
820
+ removeMaintainer(
821
+ id: string,
822
+ userId: string,
823
+ auditMessage?: string,
824
+ ): Promise<any>;
825
+ audit(
826
+ projectId: string,
827
+ startTime?: string,
828
+ endTime?: string,
829
+ asOf?: string,
830
+ ): Promise<any[]>;
831
+ auditPage(projectId: string, opts?: AuditPageOptions): Promise<Page>;
284
832
  linkVocab(id: string, vocabId: string, auditMessage?: string): Promise<any>;
285
833
  unlinkVocab(id: string, vocabId: string, auditMessage?: string): Promise<any>;
286
834
  get(id: string, asOf?: string): Promise<any>;
287
835
  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[]>;
836
+ listDocumentsPage(
837
+ id: string,
838
+ opts?: { limit?: number; cursor?: string },
839
+ ): Promise<Page>;
840
+ iterDocuments(
841
+ id: string,
842
+ opts?: { pageSize?: number },
843
+ ): AsyncGenerator<any[]>;
290
844
  delete(id: string, auditMessage?: string): Promise<any>;
291
845
  update(id: string, name: string, auditMessage?: string): Promise<any>;
292
846
  list(asOf?: string): Promise<any[]>;
293
- listPage(opts?: { limit?: number; cursor?: string; asOf?: string }): Promise<Page>;
847
+ listPage(opts?: {
848
+ limit?: number;
849
+ cursor?: string;
850
+ asOf?: string;
851
+ }): Promise<Page>;
294
852
  iterPages(opts?: { pageSize?: number; asOf?: string }): AsyncGenerator<any[]>;
295
853
  create(name: string, auditMessage?: string): Promise<any>;
296
854
  }
297
855
 
298
856
  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>;
857
+ setConfig(
858
+ textLayerId: string,
859
+ namespace: string,
860
+ configKey: string,
861
+ configValue: any,
862
+ auditMessage?: string,
863
+ ): Promise<any>;
864
+ deleteConfig(
865
+ textLayerId: string,
866
+ namespace: string,
867
+ configKey: string,
868
+ auditMessage?: string,
869
+ ): Promise<any>;
301
870
  get(textLayerId: string, asOf?: string): Promise<any>;
302
871
  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>;
872
+ update(
873
+ textLayerId: string,
874
+ name: string,
875
+ auditMessage?: string,
876
+ ): Promise<any>;
877
+ shift(
878
+ textLayerId: string,
879
+ direction: string,
880
+ auditMessage?: string,
881
+ ): Promise<any>;
305
882
  create(projectId: string, name: string, auditMessage?: string): Promise<any>;
306
883
  }
307
884
 
@@ -309,7 +886,12 @@ interface VocabItemsBundle {
309
886
  setMetadata(id: string, body: any, auditMessage?: string): Promise<any>;
310
887
  deleteMetadata(id: string, auditMessage?: string): Promise<any>;
311
888
  patchMetadata(id: string, body: any, auditMessage?: string): Promise<any>;
312
- create(vocabLayerId: string, form: string, metadata?: any, auditMessage?: string): Promise<any>;
889
+ create(
890
+ vocabLayerId: string,
891
+ form: string,
892
+ metadata?: any,
893
+ auditMessage?: string,
894
+ ): Promise<any>;
313
895
  bulkCreate(body: any[], auditMessage?: string): Promise<{ ids: string[] }>;
314
896
  bulkDelete(body: any[], auditMessage?: string): Promise<void>;
315
897
  get(id: string, asOf?: string): Promise<any>;
@@ -318,33 +900,90 @@ interface VocabItemsBundle {
318
900
  }
319
901
 
320
902
  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>;
903
+ shift(
904
+ relationLayerId: string,
905
+ direction: string,
906
+ auditMessage?: string,
907
+ ): Promise<any>;
908
+ create(
909
+ spanLayerId: string,
910
+ name: string,
911
+ auditMessage?: string,
912
+ ): Promise<any>;
913
+ setConfig(
914
+ relationLayerId: string,
915
+ namespace: string,
916
+ configKey: string,
917
+ configValue: any,
918
+ auditMessage?: string,
919
+ ): Promise<any>;
920
+ deleteConfig(
921
+ relationLayerId: string,
922
+ namespace: string,
923
+ configKey: string,
924
+ auditMessage?: string,
925
+ ): Promise<any>;
325
926
  get(relationLayerId: string, asOf?: string): Promise<any>;
326
927
  delete(relationLayerId: string, auditMessage?: string): Promise<any>;
327
- update(relationLayerId: string, name: string, auditMessage?: string): Promise<any>;
928
+ update(
929
+ relationLayerId: string,
930
+ name: string,
931
+ auditMessage?: string,
932
+ ): Promise<any>;
328
933
  }
329
934
 
330
935
  interface TokensBundle {
331
- create(tokenLayerId: string, text: string, begin: number, end: number, precedence?: number | null, metadata?: any, auditMessage?: string): Promise<any>;
936
+ create(
937
+ tokenLayerId: string,
938
+ text: string,
939
+ begin: number,
940
+ end: number,
941
+ precedence?: number | null,
942
+ metadata?: any,
943
+ auditMessage?: string,
944
+ ): Promise<any>;
332
945
  get(tokenId: string, asOf?: string): Promise<any>;
333
946
  delete(tokenId: string, auditMessage?: string): Promise<any>;
334
- update(tokenId: string, begin?: number, end?: number, precedence?: number | null, auditMessage?: string): Promise<any>;
947
+ update(
948
+ tokenId: string,
949
+ begin?: number,
950
+ end?: number,
951
+ precedence?: number | null,
952
+ auditMessage?: string,
953
+ ): Promise<any>;
335
954
  bulkCreate(body: any[], auditMessage?: string): Promise<{ ids: string[] }>;
336
955
  bulkDelete(body: any[], auditMessage?: string): Promise<void>;
337
956
  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>;
957
+ merge(
958
+ tokenId: string,
959
+ otherTokenId: string,
960
+ auditMessage?: string,
961
+ ): Promise<any>;
962
+ shift(
963
+ tokenId: string,
964
+ begin?: number,
965
+ end?: number,
966
+ auditMessage?: string,
967
+ ): Promise<any>;
340
968
  setMetadata(tokenId: string, body: any, auditMessage?: string): Promise<any>;
341
969
  deleteMetadata(tokenId: string, auditMessage?: string): Promise<any>;
342
- patchMetadata(tokenId: string, body: any, auditMessage?: string): Promise<any>;
970
+ patchMetadata(
971
+ tokenId: string,
972
+ body: any,
973
+ auditMessage?: string,
974
+ ): Promise<any>;
343
975
  }
344
976
 
345
977
  interface PlaidClientOptions {
346
978
  /** Per-request timeout in ms (default 30000; 0 or null disables it). */
347
979
  timeout?: number | null;
980
+ /**
981
+ * Timeout for batch submissions in ms (default 180000; 0 or null disables it).
982
+ * Batches get their own, longer budget: aborting one does NOT stop the
983
+ * server, which keeps running the transaction and holding the single SQLite
984
+ * write lock. Defaults to `timeout` when that is given and this is not.
985
+ */
986
+ batchTimeout?: number | null;
348
987
  /**
349
988
  * Fired once when a request returns HTTP 401 (missing/expired/invalid token).
350
989
  * Use it to discard the stored token and route back to login. 403 (forbidden)
@@ -360,19 +999,29 @@ export interface OperationGroupsBundle {
360
999
 
361
1000
  export declare class PlaidClient {
362
1001
  constructor(baseUrl: string, token: string, options?: PlaidClientOptions);
363
- static login(baseUrl: string, userId: string, password: string, options?: PlaidClientOptions): Promise<PlaidClient>;
1002
+ static login(
1003
+ baseUrl: string,
1004
+ userId: string,
1005
+ password: string,
1006
+ options?: PlaidClientOptions,
1007
+ ): Promise<PlaidClient>;
364
1008
  /** Build the link to hand someone for an invite code. */
365
1009
  static inviteUrl(appUrl: string, code: string): string;
366
1010
  /** Describe an invite code with no authentication (for a signup page). */
367
- static lookupInvite(baseUrl: string, code: string, options?: PlaidClientOptions): Promise<InvitePreview>;
1011
+ static lookupInvite(
1012
+ baseUrl: string,
1013
+ code: string,
1014
+ options?: PlaidClientOptions,
1015
+ ): Promise<InvitePreview>;
368
1016
  /** Redeem an invite code with no authentication; resolves to a logged-in client. */
369
1017
  static redeemInvite(
370
1018
  baseUrl: string,
371
1019
  code: string,
372
- credentials: { username?: string; password: string },
1020
+ credentials: { email?: string; password: string; displayName?: string },
373
1021
  options?: PlaidClientOptions,
374
1022
  ): Promise<{ client: PlaidClient; userId: string; kind: string }>;
375
1023
  timeout: number | null;
1024
+ batchTimeout: number | null;
376
1025
  /** Fired once on HTTP 401 (see PlaidClientOptions.onAuthError). */
377
1026
  onAuthError: ((error: Error) => void) | null;
378
1027
 
@@ -394,7 +1043,10 @@ export declare class PlaidClient {
394
1043
  operationGroup: { id: string; message: string | null } | null;
395
1044
  beginOperation(message: string, opts?: { id?: string }): string;
396
1045
  endOperation(message?: string): Promise<void>;
397
- withOperation<T>(message: string, fn: (setMessage: (msg: string) => void) => Promise<T> | T): Promise<T>;
1046
+ withOperation<T>(
1047
+ message: string,
1048
+ fn: (setMessage: (msg: string) => void) => Promise<T> | T,
1049
+ ): Promise<T>;
398
1050
  operationGroups: OperationGroupsBundle;
399
1051
 
400
1052
  // Query
@@ -409,7 +1061,12 @@ export declare class PlaidClient {
409
1061
  texts: TextsBundle;
410
1062
  users: UsersBundle;
411
1063
  apiTokens: ApiTokensBundle;
1064
+ userData: UserDataBundle;
412
1065
  invites: InvitesBundle;
1066
+ server: ServerBundle;
1067
+ admin: AdminBundle;
1068
+ audit: AuditBundle;
1069
+ comments: CommentsBundle;
413
1070
  tokenLayers: TokenLayersBundle;
414
1071
  documents: DocumentsBundle;
415
1072
  messages: MessagesBundle;
@@ -441,22 +1098,28 @@ export function cpIndexOf(s: string, sub: string, fromCp?: number): number;
441
1098
  // Substrate layers are tagged with a role at `config.plaid.role` (a scalar) so
442
1099
  // that different apps can share a project. See the manual, "Layer Interoperability".
443
1100
  /** The reserved config namespace for cross-app conventions. */
444
- export const PLAID_NAMESPACE: 'plaid';
1101
+ export const PLAID_NAMESPACE: "plaid";
445
1102
  /** The config key, under `plaid`, holding a layer's role. */
446
- export const ROLE_KEY: 'role';
1103
+ export const ROLE_KEY: "role";
1104
+
1105
+ /** The server's cap on operations per batch request; a larger batch goes as consecutive requests. */
1106
+ export const MAX_BATCH_OPS: 1000;
447
1107
  /** The fixed role inventory; only these values are interoperable across apps. */
448
1108
  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';
1109
+ readonly BASELINE: "baseline";
1110
+ readonly SENTENCE: "sentence";
1111
+ readonly WORD: "word";
1112
+ readonly SYNTACTIC_WORD: "syntactic-word";
1113
+ readonly MORPHEME: "morpheme";
1114
+ readonly TIME_ALIGNMENT: "time-alignment";
455
1115
  };
456
1116
  /** The role recorded on a layer's `config`, or null if none. */
457
1117
  export function readRole(config?: object): string | null;
458
1118
  /** 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;
1119
+ export function findByRole<T extends { config?: object }>(
1120
+ layers: T[] | undefined,
1121
+ role: string,
1122
+ ): T | null;
460
1123
 
461
1124
  // --- Service self-description helpers ----------------------------------------
462
1125
  // Standardize how a service advertises (in `extras`) the tasks it serves, a
@@ -465,15 +1128,22 @@ export function findByRole<T extends { config?: object }>(layers: T[] | undefine
465
1128
  // "Describing a service".
466
1129
  /** The controlled task vocabulary — the fixed integration-point goals. */
467
1130
  export const TASKS: {
468
- readonly TOKENIZE: 'tokenize';
469
- readonly PARSE: 'parse';
470
- readonly TRANSCRIBE: 'transcribe';
471
- readonly LINK_VOCAB: 'link-vocab';
1131
+ readonly TOKENIZE: "tokenize";
1132
+ readonly PARSE: "parse";
1133
+ readonly TRANSCRIBE: "transcribe";
1134
+ readonly LINK_VOCAB: "link-vocab";
1135
+ readonly ANALYZE: "analyze";
1136
+ readonly TRANSLATE: "translate";
1137
+ readonly ASSIST: "assist";
1138
+ readonly DETECT_SPEECH: "detect-speech";
472
1139
  };
473
1140
  /** Whether a service serves a task (declared `extras.tasks`, legacy id-prefix fallback). */
474
1141
  export function servesTask(service: DiscoveredService, task: string): boolean;
475
1142
  /** The discovered services that serve `task`. */
476
- export function filterServicesByTask(services: DiscoveredService[] | undefined, task: string): DiscoveredService[];
1143
+ export function filterServicesByTask(
1144
+ services: DiscoveredService[] | undefined,
1145
+ task: string,
1146
+ ): DiscoveredService[];
477
1147
  /** The parameter schema a service declares (ordered), or []. */
478
1148
  export function getParamSchema(service: DiscoveredService): ServiceParam[];
479
1149
  /** A service's human summary: `extras.summary`, else `description`, else ''. */
@@ -481,7 +1151,10 @@ export function getServiceSummary(service: DiscoveredService): string;
481
1151
  /** Default form values keyed by param key. */
482
1152
  export function buildDefaultValues(schema: ServiceParam[]): Record<string, any>;
483
1153
  /** 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> };
1154
+ export function coerceParamValues(
1155
+ schema: ServiceParam[],
1156
+ raw: Record<string, any>,
1157
+ ): { values: Record<string, any>; errors: Record<string, string> };
485
1158
 
486
1159
  // --- Provenance ---------------------------------------------------------------
487
1160
  // Cross-app convention for machine-provided vs human-labeled information,
@@ -491,32 +1164,50 @@ export function coerceParamValues(schema: ServiceParam[], raw: Record<string, an
491
1164
  // replace unverified machine material but must never touch human/verified
492
1165
  // material without an explicit overwrite opt-in; any human edit verifies.
493
1166
  // See the manual, "Provenance".
494
- type ProvState = 'human' | 'machine' | 'verified';
1167
+ type ProvState = "human" | "machine" | "verified";
495
1168
  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';
1169
+ readonly key: "prov";
1170
+ readonly sourceKey: "provSource";
1171
+ readonly confirmedKey: "provConfirmed";
1172
+ readonly probKey: "provProb";
1173
+ readonly detailKey: "provDetail";
1174
+ readonly INFERRED: "inferred";
502
1175
  };
503
1176
  export const PROV_STATES: {
504
- readonly HUMAN: 'human';
505
- readonly MACHINE: 'machine';
506
- readonly VERIFIED: 'verified';
1177
+ readonly HUMAN: "human";
1178
+ readonly MACHINE: "machine";
1179
+ readonly VERIFIED: "verified";
507
1180
  };
508
1181
  /** Optional prediction extras: prob = a probability in [0,1] for the chosen value
509
1182
  * (flat + queryable; omit unless it honestly is one); detail = an open map of
510
1183
  * producer extras (top-k alternatives, model version, raw scores; keep it small).
511
1184
  * Both describe the ORIGINAL prediction — check provConfirmed before presenting
512
1185
  * provProb as confidence in the current value. */
513
- interface ProvExtras { prob?: number; detail?: Record<string, any> }
1186
+ interface ProvExtras {
1187
+ prob?: number;
1188
+ detail?: Record<string, any>;
1189
+ }
514
1190
  /** 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> };
1191
+ export function stampInferred(
1192
+ source: string,
1193
+ extras?: ProvExtras,
1194
+ ): {
1195
+ prov: "inferred";
1196
+ provSource: string;
1197
+ provProb?: number;
1198
+ provDetail?: Record<string, any>;
1199
+ };
517
1200
  /** 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> };
1201
+ export function confirmedInferred(
1202
+ source: string,
1203
+ extras?: ProvExtras,
1204
+ ): {
1205
+ prov: "inferred";
1206
+ provSource: string;
1207
+ provConfirmed: true;
1208
+ provProb?: number;
1209
+ provDetail?: Record<string, any>;
1210
+ };
520
1211
  /** Classify an entity's metadata into one of the three provenance states. */
521
1212
  export function provState(metadata: object | null | undefined): ProvState;
522
1213
  /** The verifying fragment, { provConfirmed: true }: PATCH it over existing metadata. */
@@ -526,6 +1217,8 @@ export function isMachine(metadata: object | null | undefined): boolean;
526
1217
  /** Whether a machine writer must leave this entity alone (human or verified). !isMachine. */
527
1218
  export function isProtected(metadata: object | null | undefined): boolean;
528
1219
  /** 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;
1220
+ export function verifyOnEdit(
1221
+ metadata: object | null | undefined,
1222
+ ): { readonly provConfirmed: true } | null;
530
1223
  /** Canonical provSource for a service: 'service:<serviceId>'. */
531
1224
  export function serviceSource(serviceId: string): string;