@larc-iu/plaid-client 0.2.0-alpha.0 → 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 +662 -105
- package/package.json +1 -1
- package/src/http.js +266 -38
- package/src/index.js +1435 -357
- package/src/provenance.js +274 -26
- package/src/serviceSchema.js +50 -30
- package/src/services.js +212 -37
- package/src/sse.js +51 -1
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:
|
|
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(
|
|
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(
|
|
97
|
-
|
|
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?: {
|
|
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(
|
|
103
|
-
|
|
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(
|
|
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(
|
|
110
|
-
|
|
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(
|
|
115
|
-
|
|
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(
|
|
122
|
-
|
|
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(
|
|
126
|
-
|
|
127
|
-
|
|
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(
|
|
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(
|
|
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,61 +248,340 @@ interface TextsBundle {
|
|
|
156
248
|
|
|
157
249
|
interface UsersBundle {
|
|
158
250
|
list(asOf?: string): Promise<any[]>;
|
|
159
|
-
listPage(opts?: {
|
|
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(
|
|
162
|
-
|
|
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(
|
|
273
|
+
update(
|
|
274
|
+
id: string,
|
|
275
|
+
password?: string,
|
|
276
|
+
displayName?: string,
|
|
277
|
+
isAdmin?: boolean,
|
|
278
|
+
auditMessage?: string,
|
|
279
|
+
): Promise<any>;
|
|
280
|
+
/** URL for a user's profile picture, usable as an <img> src. Null when avatarHash is explicitly null. */
|
|
281
|
+
avatarUrl(id: string, avatarHash?: string | null): string | null;
|
|
282
|
+
getAvatar(id: string): Promise<any>;
|
|
283
|
+
setAvatar(id: string, file: File | Blob, auditMessage?: string): Promise<any>;
|
|
284
|
+
deleteAvatar(id: string, auditMessage?: string): Promise<any>;
|
|
285
|
+
}
|
|
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>>;
|
|
167
385
|
}
|
|
168
386
|
|
|
169
387
|
interface ApiTokensBundle {
|
|
170
388
|
list(userId: string): Promise<any[]>;
|
|
171
|
-
listPage(
|
|
172
|
-
|
|
173
|
-
|
|
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 }>;
|
|
174
402
|
revoke(userId: string, tokenId: string, auditMessage?: string): Promise<any>;
|
|
175
403
|
}
|
|
176
404
|
|
|
405
|
+
interface Invite {
|
|
406
|
+
id: string;
|
|
407
|
+
/** "signup" | "password-reset" */
|
|
408
|
+
kind: string;
|
|
409
|
+
/** "active" | "used" | "expired" | "revoked" */
|
|
410
|
+
status: string;
|
|
411
|
+
createdBy: string;
|
|
412
|
+
createdAt: string;
|
|
413
|
+
expiresAt: string;
|
|
414
|
+
maxUses: number;
|
|
415
|
+
uses: number;
|
|
416
|
+
revokedAt: string | null;
|
|
417
|
+
note: string | null;
|
|
418
|
+
targetUserId: string | null;
|
|
419
|
+
grantAdmin: boolean;
|
|
420
|
+
projectId: string | null;
|
|
421
|
+
projectRole: string | null;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
interface InvitePreview {
|
|
425
|
+
/** "signup" | "password-reset" */
|
|
426
|
+
kind: string;
|
|
427
|
+
/** "active" | "used" | "expired" | "revoked" */
|
|
428
|
+
status: string;
|
|
429
|
+
expiresAt: string;
|
|
430
|
+
grantAdmin: boolean;
|
|
431
|
+
projectName?: string;
|
|
432
|
+
projectRole?: string;
|
|
433
|
+
/** Present only for a password reset: the email of the account it belongs to. */
|
|
434
|
+
email?: string;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
interface CreateInviteOptions {
|
|
438
|
+
projectId?: string;
|
|
439
|
+
/** "reader" | "writer" | "maintainer" */
|
|
440
|
+
projectRole?: string;
|
|
441
|
+
grantAdmin?: boolean;
|
|
442
|
+
/** Makes this a password reset for that user (admin only). */
|
|
443
|
+
targetUserId?: string;
|
|
444
|
+
maxUses?: number;
|
|
445
|
+
ttlDays?: number;
|
|
446
|
+
note?: string;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
interface InvitesBundle {
|
|
450
|
+
list(opts?: { projectId?: string }): Promise<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[]>;
|
|
460
|
+
/** The `code` is returned ONCE and is not recoverable afterward. */
|
|
461
|
+
create(
|
|
462
|
+
opts?: CreateInviteOptions,
|
|
463
|
+
auditMessage?: string,
|
|
464
|
+
): Promise<Invite & { code: string }>;
|
|
465
|
+
revoke(id: string, auditMessage?: string): Promise<any>;
|
|
466
|
+
}
|
|
467
|
+
|
|
177
468
|
interface TokenLayersBundle {
|
|
178
|
-
shift(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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>;
|
|
182
494
|
get(tokenLayerId: string, asOf?: string): Promise<any>;
|
|
183
495
|
delete(tokenLayerId: string, auditMessage?: string): Promise<any>;
|
|
184
|
-
update(
|
|
496
|
+
update(
|
|
497
|
+
tokenLayerId: string,
|
|
498
|
+
name: string,
|
|
499
|
+
auditMessage?: string,
|
|
500
|
+
): Promise<any>;
|
|
185
501
|
}
|
|
186
502
|
|
|
187
503
|
interface DocumentsBundle {
|
|
188
504
|
checkLock(documentId: string, asOf?: string): Promise<any>;
|
|
189
505
|
acquireLock(documentId: string, auditMessage?: string): Promise<any>;
|
|
190
506
|
releaseLock(documentId: string, auditMessage?: string): Promise<any>;
|
|
191
|
-
getMedia(documentId: string
|
|
192
|
-
uploadMedia(
|
|
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>;
|
|
193
517
|
deleteMedia(documentId: string, auditMessage?: string): Promise<any>;
|
|
194
|
-
setMetadata(
|
|
518
|
+
setMetadata(
|
|
519
|
+
documentId: string,
|
|
520
|
+
body: any,
|
|
521
|
+
auditMessage?: string,
|
|
522
|
+
): Promise<any>;
|
|
195
523
|
deleteMetadata(documentId: string, auditMessage?: string): Promise<any>;
|
|
196
|
-
patchMetadata(
|
|
197
|
-
|
|
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[]>;
|
|
198
535
|
get(documentId: string, includeBody?: boolean, asOf?: string): Promise<any>;
|
|
199
536
|
delete(documentId: string, auditMessage?: string): Promise<any>;
|
|
200
537
|
update(documentId: string, name: string, auditMessage?: string): Promise<any>;
|
|
201
|
-
create(
|
|
538
|
+
create(
|
|
539
|
+
projectId: string,
|
|
540
|
+
name: string,
|
|
541
|
+
metadata?: any,
|
|
542
|
+
auditMessage?: string,
|
|
543
|
+
): Promise<any>;
|
|
202
544
|
}
|
|
203
545
|
|
|
204
546
|
interface MessagesBundle {
|
|
205
|
-
sendMessage(
|
|
206
|
-
|
|
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;
|
|
207
557
|
/** Discover the services seen on a project: online ones plus previously-seen offline ones (check `online`). */
|
|
208
558
|
discoverServices(projectId: string): Promise<DiscoveredService[]>;
|
|
209
559
|
/** Forget a previously-seen (offline) service. Maintainer-only; 409 if currently connected. */
|
|
210
560
|
discardService(projectId: string, serviceId: string): Promise<void>;
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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>;
|
|
214
585
|
}
|
|
215
586
|
|
|
216
587
|
interface ProjectsBundle {
|
|
@@ -218,32 +589,85 @@ interface ProjectsBundle {
|
|
|
218
589
|
removeWriter(id: string, userId: string, auditMessage?: string): Promise<any>;
|
|
219
590
|
addReader(id: string, userId: string, auditMessage?: string): Promise<any>;
|
|
220
591
|
removeReader(id: string, userId: string, auditMessage?: string): Promise<any>;
|
|
221
|
-
setConfig(
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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[]>;
|
|
226
621
|
linkVocab(id: string, vocabId: string, auditMessage?: string): Promise<any>;
|
|
227
622
|
unlinkVocab(id: string, vocabId: string, auditMessage?: string): Promise<any>;
|
|
228
623
|
get(id: string, asOf?: string): Promise<any>;
|
|
229
624
|
listDocuments(id: string): Promise<any[]>;
|
|
230
|
-
listDocumentsPage(
|
|
231
|
-
|
|
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[]>;
|
|
232
633
|
delete(id: string, auditMessage?: string): Promise<any>;
|
|
233
634
|
update(id: string, name: string, auditMessage?: string): Promise<any>;
|
|
234
635
|
list(asOf?: string): Promise<any[]>;
|
|
235
|
-
listPage(opts?: {
|
|
636
|
+
listPage(opts?: {
|
|
637
|
+
limit?: number;
|
|
638
|
+
cursor?: string;
|
|
639
|
+
asOf?: string;
|
|
640
|
+
}): Promise<Page>;
|
|
236
641
|
iterPages(opts?: { pageSize?: number; asOf?: string }): AsyncGenerator<any[]>;
|
|
237
642
|
create(name: string, auditMessage?: string): Promise<any>;
|
|
238
643
|
}
|
|
239
644
|
|
|
240
645
|
interface TextLayersBundle {
|
|
241
|
-
setConfig(
|
|
242
|
-
|
|
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>;
|
|
243
659
|
get(textLayerId: string, asOf?: string): Promise<any>;
|
|
244
660
|
delete(textLayerId: string, auditMessage?: string): Promise<any>;
|
|
245
|
-
update(
|
|
246
|
-
|
|
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>;
|
|
247
671
|
create(projectId: string, name: string, auditMessage?: string): Promise<any>;
|
|
248
672
|
}
|
|
249
673
|
|
|
@@ -251,7 +675,12 @@ interface VocabItemsBundle {
|
|
|
251
675
|
setMetadata(id: string, body: any, auditMessage?: string): Promise<any>;
|
|
252
676
|
deleteMetadata(id: string, auditMessage?: string): Promise<any>;
|
|
253
677
|
patchMetadata(id: string, body: any, auditMessage?: string): Promise<any>;
|
|
254
|
-
create(
|
|
678
|
+
create(
|
|
679
|
+
vocabLayerId: string,
|
|
680
|
+
form: string,
|
|
681
|
+
metadata?: any,
|
|
682
|
+
auditMessage?: string,
|
|
683
|
+
): Promise<any>;
|
|
255
684
|
bulkCreate(body: any[], auditMessage?: string): Promise<{ ids: string[] }>;
|
|
256
685
|
bulkDelete(body: any[], auditMessage?: string): Promise<void>;
|
|
257
686
|
get(id: string, asOf?: string): Promise<any>;
|
|
@@ -260,33 +689,90 @@ interface VocabItemsBundle {
|
|
|
260
689
|
}
|
|
261
690
|
|
|
262
691
|
interface RelationLayersBundle {
|
|
263
|
-
shift(
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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>;
|
|
267
715
|
get(relationLayerId: string, asOf?: string): Promise<any>;
|
|
268
716
|
delete(relationLayerId: string, auditMessage?: string): Promise<any>;
|
|
269
|
-
update(
|
|
717
|
+
update(
|
|
718
|
+
relationLayerId: string,
|
|
719
|
+
name: string,
|
|
720
|
+
auditMessage?: string,
|
|
721
|
+
): Promise<any>;
|
|
270
722
|
}
|
|
271
723
|
|
|
272
724
|
interface TokensBundle {
|
|
273
|
-
create(
|
|
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>;
|
|
274
734
|
get(tokenId: string, asOf?: string): Promise<any>;
|
|
275
735
|
delete(tokenId: string, auditMessage?: string): Promise<any>;
|
|
276
|
-
update(
|
|
736
|
+
update(
|
|
737
|
+
tokenId: string,
|
|
738
|
+
begin?: number,
|
|
739
|
+
end?: number,
|
|
740
|
+
precedence?: number | null,
|
|
741
|
+
auditMessage?: string,
|
|
742
|
+
): Promise<any>;
|
|
277
743
|
bulkCreate(body: any[], auditMessage?: string): Promise<{ ids: string[] }>;
|
|
278
744
|
bulkDelete(body: any[], auditMessage?: string): Promise<void>;
|
|
279
745
|
split(tokenId: string, position: number, auditMessage?: string): Promise<any>;
|
|
280
|
-
merge(
|
|
281
|
-
|
|
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>;
|
|
282
757
|
setMetadata(tokenId: string, body: any, auditMessage?: string): Promise<any>;
|
|
283
758
|
deleteMetadata(tokenId: string, auditMessage?: string): Promise<any>;
|
|
284
|
-
patchMetadata(
|
|
759
|
+
patchMetadata(
|
|
760
|
+
tokenId: string,
|
|
761
|
+
body: any,
|
|
762
|
+
auditMessage?: string,
|
|
763
|
+
): Promise<any>;
|
|
285
764
|
}
|
|
286
765
|
|
|
287
766
|
interface PlaidClientOptions {
|
|
288
767
|
/** Per-request timeout in ms (default 30000; 0 or null disables it). */
|
|
289
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;
|
|
290
776
|
/**
|
|
291
777
|
* Fired once when a request returns HTTP 401 (missing/expired/invalid token).
|
|
292
778
|
* Use it to discard the stored token and route back to login. 403 (forbidden)
|
|
@@ -295,10 +781,36 @@ interface PlaidClientOptions {
|
|
|
295
781
|
onAuthError?: ((error: Error) => void) | null;
|
|
296
782
|
}
|
|
297
783
|
|
|
784
|
+
export interface OperationGroupsBundle {
|
|
785
|
+
get(id: string): Promise<any>;
|
|
786
|
+
update(id: string, message: string | null): Promise<any>;
|
|
787
|
+
}
|
|
788
|
+
|
|
298
789
|
export declare class PlaidClient {
|
|
299
790
|
constructor(baseUrl: string, token: string, options?: PlaidClientOptions);
|
|
300
|
-
static login(
|
|
791
|
+
static login(
|
|
792
|
+
baseUrl: string,
|
|
793
|
+
userId: string,
|
|
794
|
+
password: string,
|
|
795
|
+
options?: PlaidClientOptions,
|
|
796
|
+
): Promise<PlaidClient>;
|
|
797
|
+
/** Build the link to hand someone for an invite code. */
|
|
798
|
+
static inviteUrl(appUrl: string, code: string): string;
|
|
799
|
+
/** Describe an invite code with no authentication (for a signup page). */
|
|
800
|
+
static lookupInvite(
|
|
801
|
+
baseUrl: string,
|
|
802
|
+
code: string,
|
|
803
|
+
options?: PlaidClientOptions,
|
|
804
|
+
): Promise<InvitePreview>;
|
|
805
|
+
/** Redeem an invite code with no authentication; resolves to a logged-in client. */
|
|
806
|
+
static redeemInvite(
|
|
807
|
+
baseUrl: string,
|
|
808
|
+
code: string,
|
|
809
|
+
credentials: { email?: string; password: string; displayName?: string },
|
|
810
|
+
options?: PlaidClientOptions,
|
|
811
|
+
): Promise<{ client: PlaidClient; userId: string; kind: string }>;
|
|
301
812
|
timeout: number | null;
|
|
813
|
+
batchTimeout: number | null;
|
|
302
814
|
/** Fired once on HTTP 401 (see PlaidClientOptions.onAuthError). */
|
|
303
815
|
onAuthError: ((error: Error) => void) | null;
|
|
304
816
|
|
|
@@ -314,12 +826,17 @@ export declare class PlaidClient {
|
|
|
314
826
|
enterStrictMode(documentId: string): void;
|
|
315
827
|
exitStrictMode(): void;
|
|
316
828
|
|
|
317
|
-
//
|
|
318
|
-
//
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
829
|
+
// Logical operations (audit-log grouping). While one is open every write is
|
|
830
|
+
// stamped with its group id so the audit log folds them into one entry.
|
|
831
|
+
// Not atomic; nesting flattens into the outer operation.
|
|
832
|
+
operationGroup: { id: string; message: string | null } | null;
|
|
833
|
+
beginOperation(message: string, opts?: { id?: string }): string;
|
|
834
|
+
endOperation(message?: string): Promise<void>;
|
|
835
|
+
withOperation<T>(
|
|
836
|
+
message: string,
|
|
837
|
+
fn: (setMessage: (msg: string) => void) => Promise<T> | T,
|
|
838
|
+
): Promise<T>;
|
|
839
|
+
operationGroups: OperationGroupsBundle;
|
|
323
840
|
|
|
324
841
|
// Query
|
|
325
842
|
query(body: any, auditMessage?: string): Promise<any>;
|
|
@@ -333,6 +850,9 @@ export declare class PlaidClient {
|
|
|
333
850
|
texts: TextsBundle;
|
|
334
851
|
users: UsersBundle;
|
|
335
852
|
apiTokens: ApiTokensBundle;
|
|
853
|
+
userData: UserDataBundle;
|
|
854
|
+
invites: InvitesBundle;
|
|
855
|
+
comments: CommentsBundle;
|
|
336
856
|
tokenLayers: TokenLayersBundle;
|
|
337
857
|
documents: DocumentsBundle;
|
|
338
858
|
messages: MessagesBundle;
|
|
@@ -364,22 +884,28 @@ export function cpIndexOf(s: string, sub: string, fromCp?: number): number;
|
|
|
364
884
|
// Substrate layers are tagged with a role at `config.plaid.role` (a scalar) so
|
|
365
885
|
// that different apps can share a project. See the manual, "Layer Interoperability".
|
|
366
886
|
/** The reserved config namespace for cross-app conventions. */
|
|
367
|
-
export const PLAID_NAMESPACE:
|
|
887
|
+
export const PLAID_NAMESPACE: "plaid";
|
|
368
888
|
/** The config key, under `plaid`, holding a layer's role. */
|
|
369
|
-
export const ROLE_KEY:
|
|
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;
|
|
370
893
|
/** The fixed role inventory; only these values are interoperable across apps. */
|
|
371
894
|
export const ROLES: {
|
|
372
|
-
readonly BASELINE:
|
|
373
|
-
readonly SENTENCE:
|
|
374
|
-
readonly WORD:
|
|
375
|
-
readonly SYNTACTIC_WORD:
|
|
376
|
-
readonly MORPHEME:
|
|
377
|
-
readonly 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";
|
|
378
901
|
};
|
|
379
902
|
/** The role recorded on a layer's `config`, or null if none. */
|
|
380
903
|
export function readRole(config?: object): string | null;
|
|
381
904
|
/** The first layer in `layers` carrying the given role, or null. */
|
|
382
|
-
export function findByRole<T extends { config?: object }>(
|
|
905
|
+
export function findByRole<T extends { config?: object }>(
|
|
906
|
+
layers: T[] | undefined,
|
|
907
|
+
role: string,
|
|
908
|
+
): T | null;
|
|
383
909
|
|
|
384
910
|
// --- Service self-description helpers ----------------------------------------
|
|
385
911
|
// Standardize how a service advertises (in `extras`) the tasks it serves, a
|
|
@@ -388,15 +914,19 @@ export function findByRole<T extends { config?: object }>(layers: T[] | undefine
|
|
|
388
914
|
// "Describing a service".
|
|
389
915
|
/** The controlled task vocabulary — the fixed integration-point goals. */
|
|
390
916
|
export const TASKS: {
|
|
391
|
-
readonly TOKENIZE:
|
|
392
|
-
readonly PARSE:
|
|
393
|
-
readonly TRANSCRIBE:
|
|
394
|
-
readonly LINK_VOCAB:
|
|
917
|
+
readonly TOKENIZE: "tokenize";
|
|
918
|
+
readonly PARSE: "parse";
|
|
919
|
+
readonly TRANSCRIBE: "transcribe";
|
|
920
|
+
readonly LINK_VOCAB: "link-vocab";
|
|
921
|
+
readonly ANALYZE: "analyze";
|
|
395
922
|
};
|
|
396
923
|
/** Whether a service serves a task (declared `extras.tasks`, legacy id-prefix fallback). */
|
|
397
924
|
export function servesTask(service: DiscoveredService, task: string): boolean;
|
|
398
925
|
/** The discovered services that serve `task`. */
|
|
399
|
-
export function filterServicesByTask(
|
|
926
|
+
export function filterServicesByTask(
|
|
927
|
+
services: DiscoveredService[] | undefined,
|
|
928
|
+
task: string,
|
|
929
|
+
): DiscoveredService[];
|
|
400
930
|
/** The parameter schema a service declares (ordered), or []. */
|
|
401
931
|
export function getParamSchema(service: DiscoveredService): ServiceParam[];
|
|
402
932
|
/** A service's human summary: `extras.summary`, else `description`, else ''. */
|
|
@@ -404,7 +934,10 @@ export function getServiceSummary(service: DiscoveredService): string;
|
|
|
404
934
|
/** Default form values keyed by param key. */
|
|
405
935
|
export function buildDefaultValues(schema: ServiceParam[]): Record<string, any>;
|
|
406
936
|
/** Coerce/validate raw form values against the schema. */
|
|
407
|
-
export function coerceParamValues(
|
|
937
|
+
export function coerceParamValues(
|
|
938
|
+
schema: ServiceParam[],
|
|
939
|
+
raw: Record<string, any>,
|
|
940
|
+
): { values: Record<string, any>; errors: Record<string, string> };
|
|
408
941
|
|
|
409
942
|
// --- Provenance ---------------------------------------------------------------
|
|
410
943
|
// Cross-app convention for machine-provided vs human-labeled information,
|
|
@@ -414,37 +947,61 @@ export function coerceParamValues(schema: ServiceParam[], raw: Record<string, an
|
|
|
414
947
|
// replace unverified machine material but must never touch human/verified
|
|
415
948
|
// material without an explicit overwrite opt-in; any human edit verifies.
|
|
416
949
|
// See the manual, "Provenance".
|
|
417
|
-
type ProvState =
|
|
950
|
+
type ProvState = "human" | "machine" | "verified";
|
|
418
951
|
export const PROV: {
|
|
419
|
-
readonly key:
|
|
420
|
-
readonly sourceKey:
|
|
421
|
-
readonly confirmedKey:
|
|
422
|
-
readonly probKey:
|
|
423
|
-
readonly detailKey:
|
|
424
|
-
readonly 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";
|
|
425
958
|
};
|
|
426
959
|
export const PROV_STATES: {
|
|
427
|
-
readonly HUMAN:
|
|
428
|
-
readonly MACHINE:
|
|
429
|
-
readonly VERIFIED:
|
|
960
|
+
readonly HUMAN: "human";
|
|
961
|
+
readonly MACHINE: "machine";
|
|
962
|
+
readonly VERIFIED: "verified";
|
|
430
963
|
};
|
|
431
964
|
/** Optional prediction extras: prob = a probability in [0,1] for the chosen value
|
|
432
965
|
* (flat + queryable; omit unless it honestly is one); detail = an open map of
|
|
433
966
|
* producer extras (top-k alternatives, model version, raw scores; keep it small).
|
|
434
967
|
* Both describe the ORIGINAL prediction — check provConfirmed before presenting
|
|
435
968
|
* provProb as confidence in the current value. */
|
|
436
|
-
interface ProvExtras {
|
|
969
|
+
interface ProvExtras {
|
|
970
|
+
prob?: number;
|
|
971
|
+
detail?: Record<string, any>;
|
|
972
|
+
}
|
|
437
973
|
/** The metadata fragment a machine writer merges into everything it creates. */
|
|
438
|
-
export function stampInferred(
|
|
439
|
-
|
|
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
|
+
};
|
|
440
983
|
/** stampInferred + provConfirmed — for machine material born verified (e.g. imports with upstream approval). */
|
|
441
|
-
export function confirmedInferred(
|
|
442
|
-
|
|
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
|
+
};
|
|
443
994
|
/** Classify an entity's metadata into one of the three provenance states. */
|
|
444
995
|
export function provState(metadata: object | null | undefined): ProvState;
|
|
445
|
-
/**
|
|
996
|
+
/** The verifying fragment, { provConfirmed: true }: PATCH it over existing metadata. */
|
|
997
|
+
export const PROV_CONFIRMED: { readonly provConfirmed: true };
|
|
998
|
+
/** Machine-made and not yet human-verified (needs review, replaceable, confirmable). */
|
|
999
|
+
export function isMachine(metadata: object | null | undefined): boolean;
|
|
1000
|
+
/** Whether a machine writer must leave this entity alone (human or verified). !isMachine. */
|
|
446
1001
|
export function isProtected(metadata: object | null | undefined): boolean;
|
|
447
|
-
/** The fragment a HUMAN edit should merge in:
|
|
448
|
-
export function verifyOnEdit(
|
|
1002
|
+
/** The fragment a HUMAN edit should merge in: PROV_CONFIRMED iff machine-unverified, else null. */
|
|
1003
|
+
export function verifyOnEdit(
|
|
1004
|
+
metadata: object | null | undefined,
|
|
1005
|
+
): { readonly provConfirmed: true } | null;
|
|
449
1006
|
/** Canonical provSource for a service: 'service:<serviceId>'. */
|
|
450
1007
|
export function serviceSource(serviceId: string): string;
|