@larc-iu/plaid-client 0.2.0-alpha.16 → 0.2.0-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +285 -60
- package/package.json +1 -1
- package/src/created.js +29 -0
- package/src/http.js +153 -56
- package/src/index.js +323 -195
- package/src/metadataOps.js +117 -0
- package/src/provenance.js +2 -16
- package/src/services.js +42 -5
- package/src/sse.js +29 -3
- package/src/transforms.js +7 -1
package/index.d.ts
CHANGED
|
@@ -77,7 +77,8 @@ interface ServiceRegistration {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/** Connection-state transitions reported by a service registration. */
|
|
80
|
-
|
|
80
|
+
/** "stopped": the server refused the channel for a reason retrying cannot fix (a revoked token, no write access, no such project), which ends the registration. */
|
|
81
|
+
type ServiceStatusEvent = "registered" | "reconnected" | "disconnected" | "stopped";
|
|
81
82
|
|
|
82
83
|
interface ResponseHelper {
|
|
83
84
|
requestId: string;
|
|
@@ -116,6 +117,11 @@ interface SSEConnection {
|
|
|
116
117
|
close(): void;
|
|
117
118
|
getStats(): any;
|
|
118
119
|
readyState: number;
|
|
120
|
+
/**
|
|
121
|
+
* Once CLOSED, why: null when this side closed it. A refused stream's error
|
|
122
|
+
* carries the HTTP `status`, and one the server ended is named "StreamClosed".
|
|
123
|
+
*/
|
|
124
|
+
error: (Error & { status?: number }) | null;
|
|
119
125
|
}
|
|
120
126
|
|
|
121
127
|
interface VocabLinksBundle {
|
|
@@ -129,13 +135,45 @@ interface VocabLinksBundle {
|
|
|
129
135
|
bulkDelete(body: any[], auditMessage?: string): Promise<void>;
|
|
130
136
|
setMetadata(id: string, body: any, auditMessage?: string): Promise<any>;
|
|
131
137
|
deleteMetadata(id: string, auditMessage?: string): Promise<any>;
|
|
132
|
-
patchMetadata(id: string, body:
|
|
133
|
-
get(id: string
|
|
138
|
+
patchMetadata(id: string, body: MetadataOp[], auditMessage?: string): Promise<any>;
|
|
139
|
+
get(id: string): Promise<any>;
|
|
134
140
|
delete(id: string, auditMessage?: string): Promise<any>;
|
|
135
141
|
}
|
|
136
142
|
|
|
143
|
+
/** What `vocabLayers.restoreItem` did, or with `dryRun` would do. */
|
|
144
|
+
interface VocabItemRestoreSummary {
|
|
145
|
+
/** The entry was gone and came back under its old id. */
|
|
146
|
+
inserted: boolean;
|
|
147
|
+
/** A living entry's form was set back. */
|
|
148
|
+
form: boolean;
|
|
149
|
+
/** A living entry's fields were set back. */
|
|
150
|
+
metadata: boolean;
|
|
151
|
+
/** 0 when nothing changes. */
|
|
152
|
+
total: number;
|
|
153
|
+
}
|
|
154
|
+
|
|
137
155
|
interface VocabLayersBundle {
|
|
156
|
+
/** `asOf` reads the vocabulary as it was at that instant. */
|
|
138
157
|
get(id: string, includeItems?: boolean, asOf?: string): Promise<any>;
|
|
158
|
+
/** One entry as it was at `asOf`, also when it has been deleted since. */
|
|
159
|
+
getItemAt(id: string, itemId: string, asOf: string): Promise<any>;
|
|
160
|
+
/** `itemId` keeps only the changes that wrote that one entry. */
|
|
161
|
+
audit(
|
|
162
|
+
id: string,
|
|
163
|
+
startTime?: string,
|
|
164
|
+
endTime?: string,
|
|
165
|
+
opTypes?: string[] | string,
|
|
166
|
+
itemId?: string,
|
|
167
|
+
): Promise<any[]>;
|
|
168
|
+
auditPage(id: string, opts?: AuditPageOptions & { itemId?: string }): Promise<Page>;
|
|
169
|
+
/** Put one entry back as it was at `asOf`. Maintainers of the vocabulary only. */
|
|
170
|
+
restoreItem(
|
|
171
|
+
id: string,
|
|
172
|
+
itemId: string,
|
|
173
|
+
asOf: string,
|
|
174
|
+
options?: { dryRun?: boolean },
|
|
175
|
+
auditMessage?: string,
|
|
176
|
+
): Promise<VocabItemRestoreSummary>;
|
|
139
177
|
delete(id: string, auditMessage?: string): Promise<any>;
|
|
140
178
|
update(id: string, name: string, auditMessage?: string): Promise<any>;
|
|
141
179
|
setConfig(
|
|
@@ -151,13 +189,9 @@ interface VocabLayersBundle {
|
|
|
151
189
|
configKey: string,
|
|
152
190
|
auditMessage?: string,
|
|
153
191
|
): Promise<any>;
|
|
154
|
-
list(
|
|
155
|
-
listPage(opts?: {
|
|
156
|
-
|
|
157
|
-
cursor?: string;
|
|
158
|
-
asOf?: string;
|
|
159
|
-
}): Promise<Page>;
|
|
160
|
-
iterPages(opts?: { pageSize?: number; asOf?: string }): AsyncGenerator<any[]>;
|
|
192
|
+
list(): Promise<any[]>;
|
|
193
|
+
listPage(opts?: { limit?: number; cursor?: string }): Promise<Page>;
|
|
194
|
+
iterPages(opts?: { pageSize?: number }): AsyncGenerator<any[]>;
|
|
161
195
|
create(name: string, auditMessage?: string): Promise<any>;
|
|
162
196
|
addMaintainer(
|
|
163
197
|
id: string,
|
|
@@ -180,7 +214,7 @@ interface RelationsBundle {
|
|
|
180
214
|
deleteMetadata(relationId: string, auditMessage?: string): Promise<any>;
|
|
181
215
|
patchMetadata(
|
|
182
216
|
relationId: string,
|
|
183
|
-
body:
|
|
217
|
+
body: MetadataOp[],
|
|
184
218
|
auditMessage?: string,
|
|
185
219
|
): Promise<any>;
|
|
186
220
|
setTarget(
|
|
@@ -188,7 +222,7 @@ interface RelationsBundle {
|
|
|
188
222
|
spanId: string,
|
|
189
223
|
auditMessage?: string,
|
|
190
224
|
): Promise<any>;
|
|
191
|
-
get(relationId: string
|
|
225
|
+
get(relationId: string): Promise<any>;
|
|
192
226
|
delete(relationId: string, auditMessage?: string): Promise<any>;
|
|
193
227
|
update(relationId: string, value: any, auditMessage?: string): Promise<any>;
|
|
194
228
|
setSource(
|
|
@@ -223,7 +257,7 @@ interface SpanLayersBundle {
|
|
|
223
257
|
configKey: string,
|
|
224
258
|
auditMessage?: string,
|
|
225
259
|
): Promise<any>;
|
|
226
|
-
get(spanLayerId: string
|
|
260
|
+
get(spanLayerId: string): Promise<any>;
|
|
227
261
|
delete(spanLayerId: string, auditMessage?: string): Promise<any>;
|
|
228
262
|
update(
|
|
229
263
|
spanLayerId: string,
|
|
@@ -251,7 +285,7 @@ interface SpansBundle {
|
|
|
251
285
|
metadata?: any,
|
|
252
286
|
auditMessage?: string,
|
|
253
287
|
): Promise<any>;
|
|
254
|
-
get(spanId: string
|
|
288
|
+
get(spanId: string): Promise<any>;
|
|
255
289
|
delete(spanId: string, auditMessage?: string): Promise<any>;
|
|
256
290
|
update(spanId: string, value: any, auditMessage?: string): Promise<any>;
|
|
257
291
|
bulkCreate(body: any[], auditMessage?: string): Promise<{ ids: string[] }>;
|
|
@@ -259,13 +293,13 @@ interface SpansBundle {
|
|
|
259
293
|
bulkUpdate(body: any[], auditMessage?: string): Promise<{ count: number }>;
|
|
260
294
|
setMetadata(spanId: string, body: any, auditMessage?: string): Promise<any>;
|
|
261
295
|
deleteMetadata(spanId: string, auditMessage?: string): Promise<any>;
|
|
262
|
-
patchMetadata(spanId: string, body:
|
|
296
|
+
patchMetadata(spanId: string, body: MetadataOp[], auditMessage?: string): Promise<any>;
|
|
263
297
|
}
|
|
264
298
|
|
|
265
299
|
interface TextsBundle {
|
|
266
300
|
setMetadata(textId: string, body: any, auditMessage?: string): Promise<any>;
|
|
267
301
|
deleteMetadata(textId: string, auditMessage?: string): Promise<any>;
|
|
268
|
-
patchMetadata(textId: string, body:
|
|
302
|
+
patchMetadata(textId: string, body: MetadataOp[], auditMessage?: string): Promise<any>;
|
|
269
303
|
create(
|
|
270
304
|
textLayerId: string,
|
|
271
305
|
documentId: string,
|
|
@@ -273,19 +307,16 @@ interface TextsBundle {
|
|
|
273
307
|
metadata?: any,
|
|
274
308
|
auditMessage?: string,
|
|
275
309
|
): Promise<any>;
|
|
276
|
-
get(textId: string
|
|
310
|
+
get(textId: string): Promise<any>;
|
|
277
311
|
delete(textId: string, auditMessage?: string): Promise<any>;
|
|
278
312
|
update(textId: string, body: any, auditMessage?: string): Promise<any>;
|
|
279
313
|
}
|
|
280
314
|
|
|
281
315
|
interface UsersBundle {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
asOf?: string;
|
|
287
|
-
}): Promise<Page>;
|
|
288
|
-
iterPages(opts?: { pageSize?: number; asOf?: string }): AsyncGenerator<any[]>;
|
|
316
|
+
/** `q` narrows to users whose id or display name contains it (admin or maintainer). */
|
|
317
|
+
list(opts?: { q?: string }): Promise<any[]>;
|
|
318
|
+
listPage(opts?: { q?: string; limit?: number; cursor?: string }): Promise<Page>;
|
|
319
|
+
iterPages(opts?: { q?: string; pageSize?: number }): AsyncGenerator<any[]>;
|
|
289
320
|
create(
|
|
290
321
|
email: string,
|
|
291
322
|
password: string,
|
|
@@ -297,10 +328,10 @@ interface UsersBundle {
|
|
|
297
328
|
userId: string,
|
|
298
329
|
startTime?: string,
|
|
299
330
|
endTime?: string,
|
|
300
|
-
|
|
331
|
+
opTypes?: string[] | string,
|
|
301
332
|
): Promise<any[]>;
|
|
302
333
|
auditPage(userId: string, opts?: AuditPageOptions): Promise<Page>;
|
|
303
|
-
get(id: string
|
|
334
|
+
get(id: string): Promise<any>;
|
|
304
335
|
delete(id: string, auditMessage?: string): Promise<any>;
|
|
305
336
|
activate(id: string, auditMessage?: string): Promise<any>;
|
|
306
337
|
update(
|
|
@@ -473,6 +504,10 @@ interface CommentsBundle {
|
|
|
473
504
|
vocabId: string,
|
|
474
505
|
opts?: { entityId?: string; limit?: number; cursor?: string },
|
|
475
506
|
): Promise<Page<Comment>>;
|
|
507
|
+
iterInVocabPages(
|
|
508
|
+
vocabId: string,
|
|
509
|
+
opts?: { entityId?: string; pageSize?: number },
|
|
510
|
+
): AsyncGenerator<Comment[]>;
|
|
476
511
|
/** `{entryId: count}` over a vocabulary; keys are raw entry ids. */
|
|
477
512
|
countsInVocab(
|
|
478
513
|
vocabId: string,
|
|
@@ -552,6 +587,12 @@ interface ServerLimits {
|
|
|
552
587
|
metadataStringLength?: number;
|
|
553
588
|
metadataTotalBytes?: number;
|
|
554
589
|
userDataValueBytes?: number;
|
|
590
|
+
guidelineTitleLength?: number;
|
|
591
|
+
guidelineBodyLength?: number;
|
|
592
|
+
/** The shortest password the server accepts on any path. */
|
|
593
|
+
passwordMinLength?: number;
|
|
594
|
+
/** How long a document lock is held before it lapses. */
|
|
595
|
+
lockExpirationMs?: number;
|
|
555
596
|
}
|
|
556
597
|
|
|
557
598
|
interface ServerHealth {
|
|
@@ -561,7 +602,8 @@ interface ServerHealth {
|
|
|
561
602
|
audit: { dbSizeMb?: number; auditRows?: number; error?: string };
|
|
562
603
|
}
|
|
563
604
|
|
|
564
|
-
|
|
605
|
+
/** A document lock as the admin lock listing reports it. */
|
|
606
|
+
interface DocumentLockInfo {
|
|
565
607
|
documentId: string;
|
|
566
608
|
userId: string;
|
|
567
609
|
expiresAt: number;
|
|
@@ -620,6 +662,15 @@ interface ServerReport {
|
|
|
620
662
|
settings: Record<string, any>;
|
|
621
663
|
}
|
|
622
664
|
|
|
665
|
+
/** The signed-in user's sign-ins. Signing in is `PlaidClient.login`. */
|
|
666
|
+
interface AuthBundle {
|
|
667
|
+
/**
|
|
668
|
+
* End every sign-in of this user on every device, this client's included.
|
|
669
|
+
* Named API tokens are not affected. Goes out at once even on a batch.
|
|
670
|
+
*/
|
|
671
|
+
logoutEverywhere(): Promise<void>;
|
|
672
|
+
}
|
|
673
|
+
|
|
623
674
|
/** Server-level facts. `info` is fetched at most once per client. */
|
|
624
675
|
interface ServerBundle {
|
|
625
676
|
info(): Promise<{ limits: ServerLimits }>;
|
|
@@ -631,7 +682,7 @@ interface ServerBundle {
|
|
|
631
682
|
interface AdminBundle {
|
|
632
683
|
server(): Promise<ServerReport>;
|
|
633
684
|
backup(): Promise<BackupStatus>;
|
|
634
|
-
locks(): Promise<{ entries:
|
|
685
|
+
locks(): Promise<{ entries: DocumentLockInfo[] }>;
|
|
635
686
|
releaseLock(documentId: string): Promise<{ result: string }>;
|
|
636
687
|
rateLimits(): Promise<RateLimitSnapshot>;
|
|
637
688
|
clearRateLimits(opts?: {
|
|
@@ -735,7 +786,6 @@ type AdminUserDataEntry = UserDataEntry & { userId: string };
|
|
|
735
786
|
interface AuditPageOptions {
|
|
736
787
|
startTime?: string;
|
|
737
788
|
endTime?: string;
|
|
738
|
-
asOf?: string;
|
|
739
789
|
opTypes?: string[] | string;
|
|
740
790
|
/** "desc" pages newest-first; a cursor belongs to the direction that made it. */
|
|
741
791
|
order?: "asc" | "desc";
|
|
@@ -827,7 +877,7 @@ interface TokenLayersBundle {
|
|
|
827
877
|
configKey: string,
|
|
828
878
|
auditMessage?: string,
|
|
829
879
|
): Promise<any>;
|
|
830
|
-
get(tokenLayerId: string
|
|
880
|
+
get(tokenLayerId: string): Promise<any>;
|
|
831
881
|
delete(tokenLayerId: string, auditMessage?: string): Promise<any>;
|
|
832
882
|
update(
|
|
833
883
|
tokenLayerId: string,
|
|
@@ -856,7 +906,7 @@ export declare class DocumentLockLost extends Error {
|
|
|
856
906
|
export const DOCUMENT_LOCK_TTL_MS: 60000;
|
|
857
907
|
|
|
858
908
|
interface DocumentsBundle {
|
|
859
|
-
checkLock(documentId: string
|
|
909
|
+
checkLock(documentId: string): Promise<any>;
|
|
860
910
|
acquireLock(documentId: string, auditMessage?: string): Promise<any>;
|
|
861
911
|
releaseLock(documentId: string, auditMessage?: string): Promise<any>;
|
|
862
912
|
/**
|
|
@@ -888,17 +938,26 @@ interface DocumentsBundle {
|
|
|
888
938
|
deleteMetadata(documentId: string, auditMessage?: string): Promise<any>;
|
|
889
939
|
patchMetadata(
|
|
890
940
|
documentId: string,
|
|
891
|
-
body:
|
|
941
|
+
body: MetadataOp[],
|
|
892
942
|
auditMessage?: string,
|
|
893
943
|
): Promise<any>;
|
|
894
944
|
audit(
|
|
895
945
|
documentId: string,
|
|
896
946
|
startTime?: string,
|
|
897
947
|
endTime?: string,
|
|
898
|
-
|
|
948
|
+
opTypes?: string[] | string,
|
|
899
949
|
): Promise<any[]>;
|
|
900
950
|
auditPage(documentId: string, opts?: AuditPageOptions): Promise<Page>;
|
|
901
|
-
|
|
951
|
+
/**
|
|
952
|
+
* `asOf` reads the document as it was at that instant. `layers` narrows a
|
|
953
|
+
* body read to the named layers (ids of any kind), and needs `includeBody`.
|
|
954
|
+
*/
|
|
955
|
+
get(
|
|
956
|
+
documentId: string,
|
|
957
|
+
includeBody?: boolean,
|
|
958
|
+
asOf?: string,
|
|
959
|
+
layers?: string[] | string,
|
|
960
|
+
): Promise<any>;
|
|
902
961
|
delete(documentId: string, auditMessage?: string): Promise<any>;
|
|
903
962
|
update(documentId: string, name: string, auditMessage?: string): Promise<any>;
|
|
904
963
|
create(
|
|
@@ -923,11 +982,8 @@ interface DocumentsBundle {
|
|
|
923
982
|
}
|
|
924
983
|
|
|
925
984
|
interface MessagesBundle {
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
data: any,
|
|
929
|
-
auditMessage?: string,
|
|
930
|
-
): Promise<any>;
|
|
985
|
+
/** Broadcast to the project's listeners. Never saved and never part of an operation. */
|
|
986
|
+
sendMessage(projectId: string, data: any): Promise<any>;
|
|
931
987
|
listen(
|
|
932
988
|
projectId: string,
|
|
933
989
|
onEvent: (eventType: string, data: any) => void | boolean,
|
|
@@ -964,7 +1020,33 @@ interface MessagesBundle {
|
|
|
964
1020
|
timeout?: number,
|
|
965
1021
|
onProgress?: (progress: any) => void,
|
|
966
1022
|
signal?: AbortSignal,
|
|
1023
|
+
opts?: {
|
|
1024
|
+
/** A request id you mint, so you know it before submitting; resubmitting one rejoins that request. */
|
|
1025
|
+
requestId?: string;
|
|
1026
|
+
/** Called with the request id as soon as the server has taken the request. */
|
|
1027
|
+
onAccepted?: (requestId: string) => void;
|
|
1028
|
+
/** Other projects the request is about. A delegating service's token reaches `projectId` and those of these the requester can read, nothing else. */
|
|
1029
|
+
projectIds?: string[];
|
|
1030
|
+
},
|
|
1031
|
+
): Promise<any>;
|
|
1032
|
+
/**
|
|
1033
|
+
* Rejoin a request made earlier: the latest progress is replayed, then the
|
|
1034
|
+
* result, or at once if it already finished. Only its submitter (or an
|
|
1035
|
+
* admin). Rejects with a 404 when the request is unknown or expired.
|
|
1036
|
+
*/
|
|
1037
|
+
attachServiceRequest(
|
|
1038
|
+
projectId: string,
|
|
1039
|
+
requestId: string,
|
|
1040
|
+
timeout?: number,
|
|
1041
|
+
onProgress?: (progress: any) => void,
|
|
1042
|
+
signal?: AbortSignal,
|
|
967
1043
|
): Promise<any>;
|
|
1044
|
+
/**
|
|
1045
|
+
* Ask the service to stop a request made earlier. The request still ends
|
|
1046
|
+
* with whatever the service then reports. 404 if unknown or expired, 409
|
|
1047
|
+
* once finished.
|
|
1048
|
+
*/
|
|
1049
|
+
cancelServiceRequest(projectId: string, requestId: string): Promise<void>;
|
|
968
1050
|
}
|
|
969
1051
|
|
|
970
1052
|
interface ProjectsBundle {
|
|
@@ -999,12 +1081,18 @@ interface ProjectsBundle {
|
|
|
999
1081
|
projectId: string,
|
|
1000
1082
|
startTime?: string,
|
|
1001
1083
|
endTime?: string,
|
|
1002
|
-
|
|
1084
|
+
opTypes?: string[] | string,
|
|
1003
1085
|
): Promise<any[]>;
|
|
1004
1086
|
auditPage(projectId: string, opts?: AuditPageOptions): Promise<Page>;
|
|
1087
|
+
/**
|
|
1088
|
+
* When the calling user last wrote to each document of the project, as a
|
|
1089
|
+
* `{documentId: timestamp}` map; documents they never wrote to are absent.
|
|
1090
|
+
* The keys are document ids, so the response is not key-transformed.
|
|
1091
|
+
*/
|
|
1092
|
+
myLastEdits(projectId: string): Promise<Record<string, string>>;
|
|
1005
1093
|
linkVocab(id: string, vocabId: string, auditMessage?: string): Promise<any>;
|
|
1006
1094
|
unlinkVocab(id: string, vocabId: string, auditMessage?: string): Promise<any>;
|
|
1007
|
-
get(id: string
|
|
1095
|
+
get(id: string): Promise<any>;
|
|
1008
1096
|
listDocuments(id: string): Promise<any[]>;
|
|
1009
1097
|
listDocumentsPage(
|
|
1010
1098
|
id: string,
|
|
@@ -1014,15 +1102,16 @@ interface ProjectsBundle {
|
|
|
1014
1102
|
id: string,
|
|
1015
1103
|
opts?: { pageSize?: number },
|
|
1016
1104
|
): AsyncGenerator<any[]>;
|
|
1017
|
-
delete(id: string, auditMessage?: string): Promise<any>;
|
|
1018
1105
|
update(id: string, name: string, auditMessage?: string): Promise<any>;
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1106
|
+
/** The project is gone when this returns, and what it holds is removed on the server afterwards. The timeout defaults to the client's. */
|
|
1107
|
+
delete(
|
|
1108
|
+
id: string,
|
|
1109
|
+
auditMessage?: string,
|
|
1110
|
+
options?: { timeout?: number | null },
|
|
1111
|
+
): Promise<any>;
|
|
1112
|
+
list(): Promise<any[]>;
|
|
1113
|
+
listPage(opts?: { limit?: number; cursor?: string }): Promise<Page>;
|
|
1114
|
+
iterPages(opts?: { pageSize?: number }): AsyncGenerator<any[]>;
|
|
1026
1115
|
create(name: string, auditMessage?: string): Promise<any>;
|
|
1027
1116
|
}
|
|
1028
1117
|
|
|
@@ -1040,7 +1129,7 @@ interface TextLayersBundle {
|
|
|
1040
1129
|
configKey: string,
|
|
1041
1130
|
auditMessage?: string,
|
|
1042
1131
|
): Promise<any>;
|
|
1043
|
-
get(textLayerId: string
|
|
1132
|
+
get(textLayerId: string): Promise<any>;
|
|
1044
1133
|
delete(textLayerId: string, auditMessage?: string): Promise<any>;
|
|
1045
1134
|
update(
|
|
1046
1135
|
textLayerId: string,
|
|
@@ -1058,7 +1147,7 @@ interface TextLayersBundle {
|
|
|
1058
1147
|
interface VocabItemsBundle {
|
|
1059
1148
|
setMetadata(id: string, body: any, auditMessage?: string): Promise<any>;
|
|
1060
1149
|
deleteMetadata(id: string, auditMessage?: string): Promise<any>;
|
|
1061
|
-
patchMetadata(id: string, body:
|
|
1150
|
+
patchMetadata(id: string, body: MetadataOp[], auditMessage?: string): Promise<any>;
|
|
1062
1151
|
create(
|
|
1063
1152
|
vocabLayerId: string,
|
|
1064
1153
|
form: string,
|
|
@@ -1068,7 +1157,7 @@ interface VocabItemsBundle {
|
|
|
1068
1157
|
bulkCreate(body: any[], auditMessage?: string): Promise<{ ids: string[] }>;
|
|
1069
1158
|
bulkDelete(body: any[], auditMessage?: string): Promise<void>;
|
|
1070
1159
|
bulkUpdate(body: any[], auditMessage?: string): Promise<{ count: number }>;
|
|
1071
|
-
get(id: string
|
|
1160
|
+
get(id: string): Promise<any>;
|
|
1072
1161
|
delete(id: string, auditMessage?: string): Promise<any>;
|
|
1073
1162
|
update(id: string, form: string, auditMessage?: string): Promise<any>;
|
|
1074
1163
|
}
|
|
@@ -1097,7 +1186,7 @@ interface RelationLayersBundle {
|
|
|
1097
1186
|
configKey: string,
|
|
1098
1187
|
auditMessage?: string,
|
|
1099
1188
|
): Promise<any>;
|
|
1100
|
-
get(relationLayerId: string
|
|
1189
|
+
get(relationLayerId: string): Promise<any>;
|
|
1101
1190
|
delete(relationLayerId: string, auditMessage?: string): Promise<any>;
|
|
1102
1191
|
update(
|
|
1103
1192
|
relationLayerId: string,
|
|
@@ -1116,7 +1205,7 @@ interface TokensBundle {
|
|
|
1116
1205
|
metadata?: any,
|
|
1117
1206
|
auditMessage?: string,
|
|
1118
1207
|
): Promise<any>;
|
|
1119
|
-
get(tokenId: string
|
|
1208
|
+
get(tokenId: string): Promise<any>;
|
|
1120
1209
|
delete(tokenId: string, auditMessage?: string): Promise<any>;
|
|
1121
1210
|
update(
|
|
1122
1211
|
tokenId: string,
|
|
@@ -1144,7 +1233,7 @@ interface TokensBundle {
|
|
|
1144
1233
|
deleteMetadata(tokenId: string, auditMessage?: string): Promise<any>;
|
|
1145
1234
|
patchMetadata(
|
|
1146
1235
|
tokenId: string,
|
|
1147
|
-
body:
|
|
1236
|
+
body: MetadataOp[],
|
|
1148
1237
|
auditMessage?: string,
|
|
1149
1238
|
): Promise<any>;
|
|
1150
1239
|
}
|
|
@@ -1181,7 +1270,14 @@ export interface PlaidBatch extends PlaidClient {
|
|
|
1181
1270
|
readonly client: PlaidClient;
|
|
1182
1271
|
/** The queued operations, in order. */
|
|
1183
1272
|
readonly operations: Array<{ path: string; method: string; body?: any }>;
|
|
1184
|
-
/**
|
|
1273
|
+
/**
|
|
1274
|
+
* Send the queued operations and resolve to one result per operation, in
|
|
1275
|
+
* order. Up to MAX_BATCH_OPS operations go as one atomic request. A larger
|
|
1276
|
+
* batch goes as consecutive requests, each atomic on its own, so a failure
|
|
1277
|
+
* in a later one leaves the earlier ones committed. The error then carries
|
|
1278
|
+
* `committed`, how many operations were saved (0 when none were), and
|
|
1279
|
+
* `committedResults`, their results in queue order.
|
|
1280
|
+
*/
|
|
1185
1281
|
submit(): Promise<any[]>;
|
|
1186
1282
|
/** Drop the queued operations without sending them. */
|
|
1187
1283
|
abort(): void;
|
|
@@ -1189,6 +1285,16 @@ export interface PlaidBatch extends PlaidClient {
|
|
|
1189
1285
|
|
|
1190
1286
|
export declare class PlaidClient {
|
|
1191
1287
|
constructor(baseUrl: string, token: string, options?: PlaidClientOptions);
|
|
1288
|
+
/** Liveness, version and database size, with no authentication. */
|
|
1289
|
+
static health(
|
|
1290
|
+
baseUrl: string,
|
|
1291
|
+
options?: { timeout?: number | null },
|
|
1292
|
+
): Promise<ServerHealth>;
|
|
1293
|
+
/** The limits this server enforces, with no authentication. */
|
|
1294
|
+
static info(
|
|
1295
|
+
baseUrl: string,
|
|
1296
|
+
options?: { timeout?: number | null },
|
|
1297
|
+
): Promise<{ limits: ServerLimits }>;
|
|
1192
1298
|
static login(
|
|
1193
1299
|
baseUrl: string,
|
|
1194
1300
|
userId: string,
|
|
@@ -1210,10 +1316,22 @@ export declare class PlaidClient {
|
|
|
1210
1316
|
credentials: { email?: string; password: string; displayName?: string },
|
|
1211
1317
|
options?: PlaidClientOptions,
|
|
1212
1318
|
): Promise<{ client: PlaidClient; userId: string; kind: string }>;
|
|
1319
|
+
/** The server's base URL, without a trailing slash. */
|
|
1320
|
+
readonly baseUrl: string;
|
|
1321
|
+
/** The bearer token every request carries. */
|
|
1322
|
+
token: string;
|
|
1213
1323
|
timeout: number | null;
|
|
1214
1324
|
batchTimeout: number | null;
|
|
1325
|
+
/** The document strict mode is entered for, or null. */
|
|
1326
|
+
readonly strictModeDocumentId: string | null;
|
|
1327
|
+
/** The DocumentLockLost of the open `locked()` block whose lock lapsed, or null. Cleared when that block exits. */
|
|
1328
|
+
documentLockLost: DocumentLockLost | null;
|
|
1215
1329
|
/** Fired once on HTTP 401 (see PlaidClientOptions.onAuthError). */
|
|
1216
1330
|
onAuthError: ((error: Error) => void) | null;
|
|
1331
|
+
/** The latest version seen for each document written through this client, keyed by document id. */
|
|
1332
|
+
documentVersions: Record<string, number>;
|
|
1333
|
+
/** True once a response left its version list out (X-Document-Versions-Omitted, past fifty documents). Every version held was then forgotten, and the strict-mode document's is read again before the next write. */
|
|
1334
|
+
documentVersionsOmitted?: boolean;
|
|
1217
1335
|
|
|
1218
1336
|
// Batches.
|
|
1219
1337
|
//
|
|
@@ -1225,9 +1343,9 @@ export declare class PlaidClient {
|
|
|
1225
1343
|
// reporting its progress, taking and dropping a document lock, the admin
|
|
1226
1344
|
// actions on the server itself), goes over the wire even when made on the
|
|
1227
1345
|
// batch.
|
|
1228
|
-
/** Open a batch. Queue writes on it, then `submit()` them
|
|
1346
|
+
/** Open a batch. Queue writes on it, then `submit()` them (one atomic request up to MAX_BATCH_OPS operations), or `abort()`. Not nestable. */
|
|
1229
1347
|
batch(): PlaidBatch;
|
|
1230
|
-
/** Run `fn` with a batch, then submit
|
|
1348
|
+
/** Run `fn` with a batch, then submit it as `submit()` does (or abort if `fn` throws). Resolves to the results array, one entry per queued write. */
|
|
1231
1349
|
batched(fn: (batch: PlaidBatch) => void | Promise<void>): Promise<any[]>;
|
|
1232
1350
|
|
|
1233
1351
|
// Strict mode methods
|
|
@@ -1247,7 +1365,7 @@ export declare class PlaidClient {
|
|
|
1247
1365
|
operationGroups: OperationGroupsBundle;
|
|
1248
1366
|
|
|
1249
1367
|
// Query
|
|
1250
|
-
query(body: any
|
|
1368
|
+
query(body: any): Promise<any>;
|
|
1251
1369
|
|
|
1252
1370
|
vocabLinks: VocabLinksBundle;
|
|
1253
1371
|
vocabLayers: VocabLayersBundle;
|
|
@@ -1260,6 +1378,7 @@ export declare class PlaidClient {
|
|
|
1260
1378
|
userData: UserDataBundle;
|
|
1261
1379
|
invites: InvitesBundle;
|
|
1262
1380
|
server: ServerBundle;
|
|
1381
|
+
auth: AuthBundle;
|
|
1263
1382
|
admin: AdminBundle;
|
|
1264
1383
|
audit: AuditBundle;
|
|
1265
1384
|
comments: CommentsBundle;
|
|
@@ -1298,6 +1417,8 @@ export function cpIndexOf(s: string, sub: string, fromCp?: number): number;
|
|
|
1298
1417
|
export const PLAID_NAMESPACE: "plaid";
|
|
1299
1418
|
/** The config key, under `plaid`, holding a layer's role. */
|
|
1300
1419
|
export const ROLE_KEY: "role";
|
|
1420
|
+
/** Layer config key naming the metadata keys a token born of a SPLIT inherits. */
|
|
1421
|
+
export const PRESERVE_ON_SPLIT_KEY: "preserveOnSplit";
|
|
1301
1422
|
|
|
1302
1423
|
/** The server's cap on operations per batch request; a larger batch goes as consecutive requests. */
|
|
1303
1424
|
export const MAX_BATCH_OPS: 1000;
|
|
@@ -1330,6 +1451,7 @@ export const TASKS: {
|
|
|
1330
1451
|
readonly TRANSCRIBE: "transcribe";
|
|
1331
1452
|
readonly LINK_VOCAB: "link-vocab";
|
|
1332
1453
|
readonly ANALYZE: "analyze";
|
|
1454
|
+
readonly DRAFT_GRAPH: "draft-graph";
|
|
1333
1455
|
readonly TRANSLATE: "translate";
|
|
1334
1456
|
readonly ASSIST: "assist";
|
|
1335
1457
|
readonly DETECT_SPEECH: "detect-speech";
|
|
@@ -1362,7 +1484,7 @@ export function coerceParamValues(
|
|
|
1362
1484
|
// replace unverified machine material but must never touch human/verified
|
|
1363
1485
|
// material without an explicit overwrite opt-in; any human edit verifies.
|
|
1364
1486
|
// See the manual, "Provenance".
|
|
1365
|
-
type ProvState = "human" | "machine" | "verified";
|
|
1487
|
+
type ProvState = "human" | "machine" | "contributed" | "verified";
|
|
1366
1488
|
export const PROV: {
|
|
1367
1489
|
readonly key: "prov";
|
|
1368
1490
|
readonly sourceKey: "provSource";
|
|
@@ -1370,12 +1492,16 @@ export const PROV: {
|
|
|
1370
1492
|
readonly probKey: "provProb";
|
|
1371
1493
|
readonly detailKey: "provDetail";
|
|
1372
1494
|
readonly INFERRED: "inferred";
|
|
1495
|
+
readonly CONTRIBUTED: "contributed";
|
|
1373
1496
|
};
|
|
1374
1497
|
export const PROV_STATES: {
|
|
1375
1498
|
readonly HUMAN: "human";
|
|
1376
1499
|
readonly MACHINE: "machine";
|
|
1500
|
+
readonly CONTRIBUTED: "contributed";
|
|
1377
1501
|
readonly VERIFIED: "verified";
|
|
1378
1502
|
};
|
|
1503
|
+
/** The provenance keys Plaid itself owns — what a split carries and a reshape keeps. */
|
|
1504
|
+
export const PROVENANCE_KEYS: readonly string[];
|
|
1379
1505
|
/** Optional prediction extras: prob = a probability in [0,1] for the chosen value
|
|
1380
1506
|
* (flat + queryable; omit unless it honestly is one); detail = an open map of
|
|
1381
1507
|
* producer extras (top-k alternatives, model version, raw scores; keep it small).
|
|
@@ -1420,3 +1546,102 @@ export function verifyOnEdit(
|
|
|
1420
1546
|
): { readonly provConfirmed: true } | null;
|
|
1421
1547
|
/** Canonical provSource for a service: 'service:<serviceId>'. */
|
|
1422
1548
|
export function serviceSource(serviceId: string): string;
|
|
1549
|
+
/** Canonical provSource for a contributor: 'user:<userId>'. */
|
|
1550
|
+
export function userSource(userId: string): string;
|
|
1551
|
+
/** The metadata fragment a contributor's work carries. */
|
|
1552
|
+
export function stampContributed(userId: string): {
|
|
1553
|
+
prov: "contributed";
|
|
1554
|
+
provSource: string;
|
|
1555
|
+
};
|
|
1556
|
+
/** Where an entity came from, confirmed or not: what a verified entity's tooltip needs. */
|
|
1557
|
+
export function provOrigin(
|
|
1558
|
+
metadata: object | null | undefined,
|
|
1559
|
+
): null | "inferred" | "contributed";
|
|
1560
|
+
/** Whether a verifier still has to look at this entity: machine-made or contributed, unconfirmed. */
|
|
1561
|
+
export function needsReview(metadata: object | null | undefined): boolean;
|
|
1562
|
+
/** The fragment a CONTRIBUTOR's edit merges in: the contributed stamp, dropping any confirmation. */
|
|
1563
|
+
export function contributeOnEdit(
|
|
1564
|
+
metadata: object | null | undefined,
|
|
1565
|
+
userId: string,
|
|
1566
|
+
): { prov: "contributed"; provSource: string; provConfirmed: null };
|
|
1567
|
+
/** Merge a fragment into a local copy, a null value deleting the key: applyMetadataOps(metadata, metadataOps(fragment)), refused where the server would refuse it. Returns a new object. */
|
|
1568
|
+
export function mergeMetadata(
|
|
1569
|
+
metadata: object | null | undefined,
|
|
1570
|
+
fragment: object | null | undefined,
|
|
1571
|
+
): Record<string, any>;
|
|
1572
|
+
|
|
1573
|
+
// --- Create responses ---------------------------------------------------------
|
|
1574
|
+
/** The id a single create answered with, read off the call's response or its batch result (`{status, body}`). Undefined when it gave none. */
|
|
1575
|
+
export function createdId(result: any): string | undefined;
|
|
1576
|
+
/** The ids a bulk create answered with, in input order, read off the call's response or its batch result. Empty when it gave none. */
|
|
1577
|
+
export function createdIds(result: any): string[];
|
|
1578
|
+
|
|
1579
|
+
// --- Metadata ops -------------------------------------------------------------
|
|
1580
|
+
/** One metadata edit: the body of a metadata PATCH is a list of these. */
|
|
1581
|
+
export type MetadataOp =
|
|
1582
|
+
| { op: "set"; path: string[]; value: any }
|
|
1583
|
+
| { op: "delete"; path: string[] };
|
|
1584
|
+
/** The ops that set each top-level key of a fragment, a null value deleting it. */
|
|
1585
|
+
export function metadataOps(
|
|
1586
|
+
fragment: object | null | undefined,
|
|
1587
|
+
): MetadataOp[];
|
|
1588
|
+
/** Apply ops to a local copy the way the server does. Returns a new object; throws where the server would refuse. */
|
|
1589
|
+
export function applyMetadataOps(
|
|
1590
|
+
metadata: object | null | undefined,
|
|
1591
|
+
ops: MetadataOp[],
|
|
1592
|
+
): Record<string, any>;
|
|
1593
|
+
/** True for a top-level metadata key Plaid keeps for itself (`plaid` and the provenance keys), never a user's field. */
|
|
1594
|
+
export function isReservedMetadataKey(key: string): boolean;
|
|
1595
|
+
|
|
1596
|
+
// --- Review: whose work is reviewed (a project-config norm) -------------------
|
|
1597
|
+
/** The config key, under the `plaid` namespace, holding the review lists. */
|
|
1598
|
+
export const REVIEW_KEY: "review";
|
|
1599
|
+
/** The project roles a review list may name. */
|
|
1600
|
+
export const PROJECT_ROLES: readonly ["reader", "writer", "maintainer"];
|
|
1601
|
+
/** A project's review lists, normalized. */
|
|
1602
|
+
export function readReview(config?: object | null): {
|
|
1603
|
+
users: string[];
|
|
1604
|
+
roles: string[];
|
|
1605
|
+
};
|
|
1606
|
+
/** A person's role in a project from its ACL lists; an admin with no entry is a maintainer. */
|
|
1607
|
+
export function projectRole(
|
|
1608
|
+
project: object | null | undefined,
|
|
1609
|
+
userId: string | null | undefined,
|
|
1610
|
+
opts?: { isAdmin?: boolean },
|
|
1611
|
+
): "maintainer" | "writer" | "reader" | null;
|
|
1612
|
+
/** Whether this person's work is reviewed here: named in review.users, or holding a role in review.roles. */
|
|
1613
|
+
export function isReviewed(
|
|
1614
|
+
project: object | null | undefined,
|
|
1615
|
+
userId: string | null | undefined,
|
|
1616
|
+
opts?: { isAdmin?: boolean },
|
|
1617
|
+
): boolean;
|
|
1618
|
+
/** The review lists with one person added to or removed from `users`. Pure. */
|
|
1619
|
+
export function withReviewedUser(
|
|
1620
|
+
review: { users?: string[]; roles?: string[] } | null | undefined,
|
|
1621
|
+
userId: string,
|
|
1622
|
+
reviewed: boolean,
|
|
1623
|
+
): { users: string[]; roles: string[] };
|
|
1624
|
+
/** What one writer's writes carry and what their review gestures act on. */
|
|
1625
|
+
export function writerPolicy(contributorId?: string | null): {
|
|
1626
|
+
readonly contributorId: string | null;
|
|
1627
|
+
readonly isContributor: boolean;
|
|
1628
|
+
/** The metadata a NEW entity carries: null for a verifier. */
|
|
1629
|
+
readonly createStamp: Record<string, any> | null;
|
|
1630
|
+
/** The fragment an EDIT merges, or null when there is nothing to merge. */
|
|
1631
|
+
readonly editStamp: (
|
|
1632
|
+
metadata: object | null | undefined,
|
|
1633
|
+
) => Record<string, any> | null;
|
|
1634
|
+
/** The fragment an explicit confirm gesture merges, or null. */
|
|
1635
|
+
readonly confirmStamp: (
|
|
1636
|
+
metadata: object | null | undefined,
|
|
1637
|
+
) => Record<string, any> | null;
|
|
1638
|
+
/** What an adopted suggestion is written with. */
|
|
1639
|
+
readonly adoptStamp: (
|
|
1640
|
+
source: string,
|
|
1641
|
+
detail?: Record<string, any>,
|
|
1642
|
+
) => Record<string, any>;
|
|
1643
|
+
/** Whether this writer's review gesture acts on the entity. */
|
|
1644
|
+
readonly reviewable: (metadata: object | null | undefined) => boolean;
|
|
1645
|
+
/** The same test over a provState. */
|
|
1646
|
+
readonly reviewableState: (state: string) => boolean;
|
|
1647
|
+
};
|