@larc-iu/plaid-client 0.2.0-alpha.29 → 0.2.0-alpha.30
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/package.json +3 -2
- package/src/apiAnnotations.d.ts +508 -0
- package/src/apiAnnotations.js +543 -0
- package/src/apiDocuments.d.ts +569 -0
- package/src/apiDocuments.js +551 -0
- package/src/apiLayers.d.ts +369 -0
- package/src/apiLayers.js +222 -0
- package/src/apiMessages.d.ts +293 -0
- package/src/apiMessages.js +265 -0
- package/src/apiPeople.d.ts +626 -0
- package/src/apiPeople.js +698 -0
- package/src/apiProject.d.ts +761 -0
- package/src/apiProject.js +774 -0
- package/src/apiServer.d.ts +455 -0
- package/src/apiServer.js +422 -0
- package/src/apiVocab.d.ts +456 -0
- package/src/apiVocab.js +425 -0
- package/src/batch.d.ts +54 -0
- package/src/batch.js +323 -0
- package/src/client.d.ts +1321 -0
- package/src/client.js +743 -0
- package/src/constraints.d.ts +8 -0
- package/src/constraints.js +14 -0
- package/src/documentLock.d.ts +18 -4
- package/src/documentLock.js +43 -9
- package/src/entryForms.d.ts +63 -0
- package/src/entryForms.js +152 -0
- package/src/events.js +2 -1
- package/src/families.d.ts +349 -0
- package/src/families.js +396 -0
- package/src/http.d.ts +39 -18
- package/src/http.js +127 -87
- package/src/index.d.ts +90 -4557
- package/src/index.js +113 -5172
- package/src/operations.d.ts +36 -0
- package/src/operations.js +164 -0
- package/src/provenance.d.ts +47 -4
- package/src/provenance.js +168 -12
- package/src/roles.d.ts +39 -0
- package/src/roles.js +44 -0
- package/src/serviceSchema.d.ts +19 -13
- package/src/serviceSchema.js +30 -15
- package/src/services.d.ts +20 -3
- package/src/services.js +45 -8
- package/src/sse.js +10 -1
- package/src/testing.d.ts +128 -0
- package/src/testing.js +379 -0
- package/src/types.d.ts +867 -0
- package/src/types.js +663 -0
package/src/types.js
ADDED
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shapes the Plaid API answers with and takes, as JSDoc typedefs, for
|
|
3
|
+
* editors and for the declarations `npm run types` generates (types.d.ts).
|
|
4
|
+
* The package root re-exports every one of them. No runtime code.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {import("./textEdits.js").TextEditOp} TextEditOp
|
|
9
|
+
* @typedef {import("./textEdits.js").TextGap} TextGap
|
|
10
|
+
* @typedef {import("./metadataOps.js").MetadataOp} MetadataOp
|
|
11
|
+
* @typedef {import("./constraints.js").LayerConstraint} LayerConstraint
|
|
12
|
+
* @typedef {import("./constraints.js").ConstraintWriteOptions} ConstraintWriteOptions
|
|
13
|
+
* @typedef {import("./constraints.js").ConstraintViolation} ConstraintViolation
|
|
14
|
+
* @typedef {import("./requester.js").Requester} Requester
|
|
15
|
+
* @typedef {import("./batchRef.js").BatchRef} BatchRef
|
|
16
|
+
* @typedef {import("./serviceSchema.js").ServiceParam} ServiceParam
|
|
17
|
+
* @typedef {import("./serviceSchema.js").ServiceInfo} ServiceInfo
|
|
18
|
+
* @typedef {import("./serviceSchema.js").DiscoveredService} DiscoveredService
|
|
19
|
+
* @typedef {import("./services.js").ResponseHelper} ResponseHelper
|
|
20
|
+
* @typedef {import("./services.js").ServiceRegistration} ServiceRegistration
|
|
21
|
+
* @typedef {import("./services.js").ServiceStatusEvent} ServiceStatusEvent
|
|
22
|
+
* @typedef {import("./client.js").PlaidClient["operationGroups"]} OperationGroupsBundle
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A single page of a cursor-paginated collection.
|
|
27
|
+
* @template [T=any]
|
|
28
|
+
* @typedef {{entries: T[], nextCursor: string | null}} Page
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Client options.
|
|
33
|
+
* @typedef {object} PlaidClientOptions
|
|
34
|
+
* @property {number | null} [timeout] Per-request timeout in ms (default
|
|
35
|
+
* 30000, 0 or null disables it).
|
|
36
|
+
* @property {number | null} [batchTimeout] Timeout for batch submissions in
|
|
37
|
+
* ms (default 180000, 0 or null disables it). Aborting a batch does NOT
|
|
38
|
+
* stop the server, which keeps running the transaction and holding the
|
|
39
|
+
* write lock. Defaults to `timeout` when that is given and this is not.
|
|
40
|
+
* @property {number[]} [retryDelaysMs] Delays in ms before sending a keyed
|
|
41
|
+
* write again when its answer was lost (no response, 502 or 504). Default
|
|
42
|
+
* [1000, 3000, 9000].
|
|
43
|
+
* @property {((error: Error) => void) | null} [onAuthError] Fired once when
|
|
44
|
+
* a request returns HTTP 401 (missing, expired or invalid token). 403 does
|
|
45
|
+
* NOT trigger it.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* What kind of operation a logical-operation group is (`?group-kind=`).
|
|
50
|
+
* @typedef {"assistant-plan" | "service-run" | "import" | "bulk-edit"
|
|
51
|
+
* | "guess-adoption" | "repair" | "review"} OperationKind
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Idempotency-Key seed for an operation run more than once (`client.keySeed()`).
|
|
56
|
+
* @typedef {{seed: string, stamps: Map<number, number | null>}} KeySeed
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A batch: the client's bundles, on which every write of project data queues
|
|
61
|
+
* until `submit()`. See `PlaidClient.batch()`. `submit()` resolves to one
|
|
62
|
+
* result per operation, in order. `ref(opIndex, index)` stands for the id a
|
|
63
|
+
* queued operation will create, in the body of a later write on this batch.
|
|
64
|
+
* @typedef {import("./client.js").PlaidClient & {
|
|
65
|
+
* readonly client: import("./client.js").PlaidClient,
|
|
66
|
+
* readonly operations: Array<{path: string, method: string, body?: any}>,
|
|
67
|
+
* submit(): Promise<any[]>,
|
|
68
|
+
* abort(): void,
|
|
69
|
+
* ref(opIndex?: number, index?: number): BatchRef,
|
|
70
|
+
* }} PlaidBatch
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Options for a single page of any audit log. `kinds` keeps only the entries
|
|
75
|
+
* of operations of these kinds, each whole. `order: "desc"` pages newest
|
|
76
|
+
* first, and a cursor belongs to the direction that made it. `opsLimit` keeps
|
|
77
|
+
* only each entry's oldest N operations in `ops` (1..1000), and every entry
|
|
78
|
+
* has `opCount`. `entryId` reads only that entry rather than a page.
|
|
79
|
+
* @typedef {object} AuditPageOptions
|
|
80
|
+
* @property {string} [startTime]
|
|
81
|
+
* @property {string} [endTime]
|
|
82
|
+
* @property {string[] | string} [opTypes]
|
|
83
|
+
* @property {OperationKind[] | string} [kinds]
|
|
84
|
+
* @property {"asc" | "desc"} [order]
|
|
85
|
+
* @property {number} [limit]
|
|
86
|
+
* @property {string} [cursor]
|
|
87
|
+
* @property {number} [opsLimit]
|
|
88
|
+
* @property {string} [entryId]
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* What `vocabLayers.restoreItem` did, or with `dryRun` would do.
|
|
93
|
+
* @typedef {object} VocabItemRestoreSummary
|
|
94
|
+
* @property {boolean} inserted The entry was gone and came back under its old id.
|
|
95
|
+
* @property {boolean} form A living entry's form was set back.
|
|
96
|
+
* @property {boolean} metadata A living entry's fields were set back.
|
|
97
|
+
* @property {number} total 0 when nothing changes.
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* One private data entry. `version` is raised by one on every write of the
|
|
102
|
+
* entry, and a new entry is 1.
|
|
103
|
+
* @typedef {{key: string, updatedAt: string, version: number, value?: any}} UserDataEntry
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
/** @typedef {UserDataEntry & {userId: string}} AdminUserDataEntry */
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* One user's activity over a scope and window (`audit.tally`).
|
|
110
|
+
* @typedef {object} ActivityTallyRow
|
|
111
|
+
* @property {{id: string, displayName?: string}} user
|
|
112
|
+
* @property {number} operations
|
|
113
|
+
* @property {number} changes
|
|
114
|
+
* @property {number} documents
|
|
115
|
+
* @property {string} firstTs
|
|
116
|
+
* @property {string} lastTs
|
|
117
|
+
* @property {Array<{date: string, changes: number}>} [byDay]
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* What a constraint repair did in one document.
|
|
122
|
+
* @typedef {{document: string, constraint: string, deleted: number, joined: number}} ConstraintRepair
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* A value-set rule as `refusedValues` takes it: the list, the characters a
|
|
127
|
+
* value is split on, and whether every part (`"all"`, the default) or only
|
|
128
|
+
* the first must be listed.
|
|
129
|
+
* @typedef {{values: string[], delimiters?: string, parts?: "all" | "first"}} ValueSetRule
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* What a value-set rule would refuse in a layer's stored values: how many,
|
|
134
|
+
* how many distinct, and the most frequent with the parts not listed.
|
|
135
|
+
* @typedef {object} RefusedValues
|
|
136
|
+
* @property {number} count
|
|
137
|
+
* @property {number} valueCount
|
|
138
|
+
* @property {Array<{value: any, parts: string[], count: number}>} values
|
|
139
|
+
*/
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Entities that can carry a comment.
|
|
143
|
+
* @typedef {"document" | "text" | "token" | "span" | "relation" | "vocab-item"} CommentableType
|
|
144
|
+
*/
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* One comment. `projectId` and `documentId` are null for a comment on a
|
|
148
|
+
* vocabulary entry, and `vocabLayerId` is set only for one. `anchorLabel` is
|
|
149
|
+
* what the comment is about, in words, captured when it was posted: a
|
|
150
|
+
* comment outlives its anchor. `edited` is true once the body has been
|
|
151
|
+
* rewritten since it was posted.
|
|
152
|
+
* @typedef {object} Comment
|
|
153
|
+
* @property {string} id
|
|
154
|
+
* @property {string | null} projectId
|
|
155
|
+
* @property {string | null} documentId
|
|
156
|
+
* @property {string | null} vocabLayerId
|
|
157
|
+
* @property {CommentableType} entityType
|
|
158
|
+
* @property {string} entityId
|
|
159
|
+
* @property {string | null} anchorLabel
|
|
160
|
+
* @property {string} authorId
|
|
161
|
+
* @property {string} body
|
|
162
|
+
* @property {string} createdAt
|
|
163
|
+
* @property {string} updatedAt
|
|
164
|
+
* @property {boolean} edited
|
|
165
|
+
*/
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* One entry in a project's annotation manual. `body` is present on a single
|
|
169
|
+
* read and on a list made with `includeBodies`, `bodyChars` on a list made
|
|
170
|
+
* without. `pinned`: the assistant is given this one in full on every turn.
|
|
171
|
+
* @typedef {object} Guideline
|
|
172
|
+
* @property {string} id
|
|
173
|
+
* @property {string} projectId
|
|
174
|
+
* @property {string} title
|
|
175
|
+
* @property {string} [body]
|
|
176
|
+
* @property {number} [bodyChars]
|
|
177
|
+
* @property {boolean} pinned
|
|
178
|
+
* @property {string} createdAt
|
|
179
|
+
* @property {string} updatedAt
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* A research-telemetry event type.
|
|
184
|
+
* @typedef {"suggestion.shown" | "suggestion.adopted" | "suggestion.dismissed" | "plan.opened"} ClientEventType
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* One research-telemetry event as the server stores it.
|
|
189
|
+
* @typedef {object} ClientEvent
|
|
190
|
+
* @property {number} id
|
|
191
|
+
* @property {string} projectId
|
|
192
|
+
* @property {string | null} documentId
|
|
193
|
+
* @property {string} userId
|
|
194
|
+
* @property {ClientEventType} type
|
|
195
|
+
* @property {string | null} targetId
|
|
196
|
+
* @property {Record<string, any> | null} data
|
|
197
|
+
* @property {string | null} clientTs
|
|
198
|
+
* @property {string} ts
|
|
199
|
+
*/
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* An invite. `kind` is "signup" or "password-reset", `status` "active",
|
|
203
|
+
* "used", "expired", "revoked" or "inactive".
|
|
204
|
+
* @typedef {object} Invite
|
|
205
|
+
* @property {string} id
|
|
206
|
+
* @property {string} kind
|
|
207
|
+
* @property {string} status
|
|
208
|
+
* @property {string} createdBy
|
|
209
|
+
* @property {string} createdAt
|
|
210
|
+
* @property {string} expiresAt
|
|
211
|
+
* @property {number} maxUses
|
|
212
|
+
* @property {number} uses
|
|
213
|
+
* @property {string | null} revokedAt
|
|
214
|
+
* @property {string | null} note
|
|
215
|
+
* @property {string | null} targetUserId
|
|
216
|
+
* @property {boolean} grantAdmin
|
|
217
|
+
* @property {string | null} projectId
|
|
218
|
+
* @property {string | null} projectRole
|
|
219
|
+
*/
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Server limits, as reported by /api/v1/info. An unset limit is absent.
|
|
223
|
+
* `passwordMinLength` is the shortest password the server accepts on any
|
|
224
|
+
* path, `lockExpirationMs` how long a document lock is held before it lapses.
|
|
225
|
+
* `queryBranches` is the most branches a query's `or` and `seq` may expand
|
|
226
|
+
* to, `queryClauseDepth` the deepest its clauses may nest.
|
|
227
|
+
* @typedef {object} ServerLimits
|
|
228
|
+
* @property {number} [mediaFileBytes]
|
|
229
|
+
* @property {number} [jsonBodyBytes]
|
|
230
|
+
* @property {number} [batchOperations]
|
|
231
|
+
* @property {number} [metadataDepth]
|
|
232
|
+
* @property {number} [metadataKeyCount]
|
|
233
|
+
* @property {number} [metadataStringLength]
|
|
234
|
+
* @property {number} [metadataTotalBytes]
|
|
235
|
+
* @property {number} [userDataValueBytes]
|
|
236
|
+
* @property {number} [guidelineTitleLength]
|
|
237
|
+
* @property {number} [guidelineBodyLength]
|
|
238
|
+
* @property {number} [commentBodyLength]
|
|
239
|
+
* @property {number} [passwordMinLength]
|
|
240
|
+
* @property {number} [lockExpirationMs]
|
|
241
|
+
* @property {number} [queryBranches]
|
|
242
|
+
* @property {number} [queryClauseDepth]
|
|
243
|
+
*/
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* @typedef {object} ServerHealth
|
|
247
|
+
* @property {boolean} ok
|
|
248
|
+
* @property {string} version
|
|
249
|
+
* @property {number} uptimeMs
|
|
250
|
+
* @property {{dbSizeMb?: number, auditRows?: number, error?: string}} audit
|
|
251
|
+
*/
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @typedef {{ip: string, userId?: string, failures: number, limit: number, blocked: boolean}} RateLimitBucket
|
|
255
|
+
*/
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* @typedef {object} RateLimitSnapshot
|
|
259
|
+
* @property {number} windowMs
|
|
260
|
+
* @property {RateLimitBucket[]} logins
|
|
261
|
+
* @property {RateLimitBucket[]} ips
|
|
262
|
+
* @property {RateLimitBucket[]} invites
|
|
263
|
+
*/
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* @typedef {object} BackupStatus
|
|
267
|
+
* @property {boolean} enabled
|
|
268
|
+
* @property {string} directory
|
|
269
|
+
* @property {number} retention
|
|
270
|
+
* @property {string} time
|
|
271
|
+
* @property {Array<{name: string, bytes: number, modified: string}>} backups
|
|
272
|
+
* @property {boolean} [ok]
|
|
273
|
+
*/
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* @typedef {object} ServerReport
|
|
277
|
+
* @property {string} version
|
|
278
|
+
* @property {{uptimeMs: number, startedAt: string, java: string, heapUsed: number, heapMax: number}} jvm
|
|
279
|
+
* @property {{path: string | null, bytes: number | null, walBytes: number | null,
|
|
280
|
+
* slowQueryThresholdMs?: number, journalMode?: string, maxPoolSize?: number,
|
|
281
|
+
* tables: Record<string, number | null>}} database
|
|
282
|
+
* @property {{directory: string, files: number, bytes: number, orphans: number, orphanBytes: number}} media
|
|
283
|
+
* @property {BackupStatus} backup
|
|
284
|
+
* @property {Record<string, any>} settings
|
|
285
|
+
*/
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* The live log. Requests and events are buffered separately, so a burst of
|
|
289
|
+
* requests cannot evict an error. In each, `matched` is how many passed the
|
|
290
|
+
* filters (which may exceed what `entries` holds) and `held` how many are
|
|
291
|
+
* buffered in total. `file` is the configured log file's absolute path, or
|
|
292
|
+
* null when logging to stdout.
|
|
293
|
+
* @typedef {object} LiveLog
|
|
294
|
+
* @property {{entries: object[], matched: number, held: number, capacity: number,
|
|
295
|
+
* stats: Record<string, number | null>}} requests
|
|
296
|
+
* @property {{entries: object[], matched: number, held: number, capacity: number,
|
|
297
|
+
* byLevel: Record<string, number>}} events
|
|
298
|
+
* @property {string | null} file
|
|
299
|
+
*/
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* An open server-sent-events stream. Once CLOSED, `error` says why: null when
|
|
303
|
+
* this side closed it. A refused stream's error carries the HTTP `status`,
|
|
304
|
+
* and one the server ended is named "StreamClosed".
|
|
305
|
+
* @typedef {object} SSEConnection
|
|
306
|
+
* @property {() => void} close
|
|
307
|
+
* @property {() => SSEStats} getStats
|
|
308
|
+
* @property {number} readyState
|
|
309
|
+
* @property {(Error & {status?: number}) | null} error
|
|
310
|
+
*/
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* How an SSE connection has fared so far. `events` counts what arrived by
|
|
314
|
+
* event type ("audit-log", "message", "heartbeat", "connected", "other").
|
|
315
|
+
* @typedef {object} SSEStats
|
|
316
|
+
* @property {number} durationSeconds
|
|
317
|
+
* @property {boolean} isConnected
|
|
318
|
+
* @property {boolean} isClosed
|
|
319
|
+
* @property {string | null} clientId
|
|
320
|
+
* @property {Record<string, number>} events
|
|
321
|
+
* @property {number} readyState
|
|
322
|
+
*/
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* A value a span or relation holds: a JSON scalar.
|
|
326
|
+
* @typedef {string | number | boolean | null} AtomicValue
|
|
327
|
+
*/
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* What a create answers: the new record's id.
|
|
331
|
+
* @typedef {{id: string}} Created
|
|
332
|
+
*/
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* A project. `textLayers` nests its layers in their display order, each
|
|
336
|
+
* with the layers built on it, and `vocabs` lists the vocabularies linked to
|
|
337
|
+
* it.
|
|
338
|
+
* @typedef {object} Project
|
|
339
|
+
* @property {string} id
|
|
340
|
+
* @property {string} name
|
|
341
|
+
* @property {Record<string, any>} config
|
|
342
|
+
* @property {string[]} readers
|
|
343
|
+
* @property {string[]} writers
|
|
344
|
+
* @property {string[]} maintainers
|
|
345
|
+
* @property {ProjectTextLayer[]} textLayers
|
|
346
|
+
* @property {ProjectVocab[]} vocabs
|
|
347
|
+
*/
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* @typedef {{id: string, name: string, config: Record<string, any>, tokenLayers: ProjectTokenLayer[]}} ProjectTextLayer
|
|
351
|
+
* @typedef {{id: string, name: string, config: Record<string, any>,
|
|
352
|
+
* constraints: Record<string, LayerConstraint[]>, spanLayers: ProjectSpanLayer[]}} ProjectTokenLayer
|
|
353
|
+
* @typedef {{id: string, name: string, config: Record<string, any>,
|
|
354
|
+
* constraints: Record<string, LayerConstraint[]>, relationLayers: ProjectRelationLayer[]}} ProjectSpanLayer
|
|
355
|
+
* @typedef {{id: string, name: string, config: Record<string, any>,
|
|
356
|
+
* constraints: Record<string, LayerConstraint[]>}} ProjectRelationLayer
|
|
357
|
+
* @typedef {{id: string, name: string, maintainers: string[], config: Record<string, any>}} ProjectVocab
|
|
358
|
+
*/
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* A document. `version` rises by one on every write to it or its layers.
|
|
362
|
+
* A read with `includeBody` also carries `textLayers`, the document's
|
|
363
|
+
* annotation nested under each layer.
|
|
364
|
+
* @typedef {object} PlaidDocument
|
|
365
|
+
* @property {string} id
|
|
366
|
+
* @property {string} name
|
|
367
|
+
* @property {string} project
|
|
368
|
+
* @property {number} version
|
|
369
|
+
* @property {string} timeCreated
|
|
370
|
+
* @property {string} timeModified
|
|
371
|
+
* @property {Record<string, any>} [metadata]
|
|
372
|
+
* @property {DocumentTextLayer[]} [textLayers]
|
|
373
|
+
*/
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* A text layer as a document read nests it: `text` is null where the
|
|
377
|
+
* document has no text in this layer.
|
|
378
|
+
* @typedef {object} DocumentTextLayer
|
|
379
|
+
* @property {string} id
|
|
380
|
+
* @property {string} name
|
|
381
|
+
* @property {Record<string, any>} config
|
|
382
|
+
* @property {{id: string, document: string, body: string, digest: string,
|
|
383
|
+
* metadata?: Record<string, any>} | null} text
|
|
384
|
+
* @property {DocumentTokenLayer[]} tokenLayers
|
|
385
|
+
*/
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* @typedef {object} DocumentTokenLayer
|
|
389
|
+
* @property {string} id
|
|
390
|
+
* @property {string} name
|
|
391
|
+
* @property {Record<string, any>} config
|
|
392
|
+
* @property {Record<string, LayerConstraint[]>} constraints
|
|
393
|
+
* @property {string} overlapMode
|
|
394
|
+
* @property {string | null} parentTokenLayer
|
|
395
|
+
* @property {Array<{id: string, begin: number, end: number, precedence: number | null,
|
|
396
|
+
* metadata?: Record<string, any>}>} tokens
|
|
397
|
+
* @property {DocumentSpanLayer[]} spanLayers
|
|
398
|
+
* @property {Array<ProjectVocab & {vocabLinks: Array<{id: string, vocabItem: VocabItem,
|
|
399
|
+
* tokens: string[], metadata?: Record<string, any>}>}>} vocabs
|
|
400
|
+
*/
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* @typedef {object} DocumentSpanLayer
|
|
404
|
+
* @property {string} id
|
|
405
|
+
* @property {string} name
|
|
406
|
+
* @property {Record<string, any>} config
|
|
407
|
+
* @property {Record<string, LayerConstraint[]>} constraints
|
|
408
|
+
* @property {Array<{id: string, value: AtomicValue, tokens: string[],
|
|
409
|
+
* metadata?: Record<string, any>}>} spans
|
|
410
|
+
* @property {Array<ProjectRelationLayer & {relations: Array<{id: string, source: string,
|
|
411
|
+
* target: string, value: AtomicValue, metadata?: Record<string, any>}>}>} relationLayers
|
|
412
|
+
*/
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* A text: one document's body in one text layer. `digest` names the body,
|
|
416
|
+
* as an edit's `base`.
|
|
417
|
+
* @typedef {object} PlaidText
|
|
418
|
+
* @property {string} id
|
|
419
|
+
* @property {string} body
|
|
420
|
+
* @property {string} document
|
|
421
|
+
* @property {string} layer
|
|
422
|
+
* @property {string} digest
|
|
423
|
+
* @property {Record<string, any>} [metadata]
|
|
424
|
+
*/
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* What a text write changed besides the body: the tokens whose extent
|
|
428
|
+
* moved (with `layer` and `text` on one the write made), the spans and
|
|
429
|
+
* vocabulary links whose tokens or value changed, and the ids of what it
|
|
430
|
+
* deleted.
|
|
431
|
+
* @typedef {object} TextReshape
|
|
432
|
+
* @property {Array<{id: string, begin: number, end: number, layer?: string, text?: string}>} tokens
|
|
433
|
+
* @property {Array<{id: string, tokens?: string[], value?: AtomicValue}>} spans
|
|
434
|
+
* @property {Array<{id: string, tokens: string[]}>} vocabLinks
|
|
435
|
+
* @property {{tokens: string[], spans: string[], relations: string[], vocabLinks: string[]}} deleted
|
|
436
|
+
*/
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* A token. `value` is the text it covers.
|
|
440
|
+
* @typedef {object} Token
|
|
441
|
+
* @property {string} id
|
|
442
|
+
* @property {string} text
|
|
443
|
+
* @property {number} begin
|
|
444
|
+
* @property {number} end
|
|
445
|
+
* @property {string} layer
|
|
446
|
+
* @property {string} document
|
|
447
|
+
* @property {number | null} precedence
|
|
448
|
+
* @property {string} value
|
|
449
|
+
* @property {Record<string, any>} [metadata]
|
|
450
|
+
*/
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* @typedef {object} Span
|
|
454
|
+
* @property {string} id
|
|
455
|
+
* @property {string} layer
|
|
456
|
+
* @property {string} document
|
|
457
|
+
* @property {AtomicValue} value
|
|
458
|
+
* @property {string[]} tokens
|
|
459
|
+
* @property {Record<string, any>} [metadata]
|
|
460
|
+
*/
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* A relation, from the span `source` to the span `target`.
|
|
464
|
+
* @typedef {object} Relation
|
|
465
|
+
* @property {string} id
|
|
466
|
+
* @property {string} layer
|
|
467
|
+
* @property {string} document
|
|
468
|
+
* @property {string} source
|
|
469
|
+
* @property {string} target
|
|
470
|
+
* @property {AtomicValue} value
|
|
471
|
+
* @property {Record<string, any>} [metadata]
|
|
472
|
+
*/
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* @typedef {object} VocabItem
|
|
476
|
+
* @property {string} id
|
|
477
|
+
* @property {string} layer
|
|
478
|
+
* @property {string} form
|
|
479
|
+
* @property {Record<string, any>} [metadata]
|
|
480
|
+
*/
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* A link from a vocabulary entry to the tokens of one occurrence.
|
|
484
|
+
* @typedef {object} VocabLink
|
|
485
|
+
* @property {string} id
|
|
486
|
+
* @property {string} vocabItem
|
|
487
|
+
* @property {string} document
|
|
488
|
+
* @property {string[]} tokens
|
|
489
|
+
* @property {Record<string, any>} [metadata]
|
|
490
|
+
*/
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* A vocabulary. `items` is there on a read made with `includeItems`.
|
|
494
|
+
* @typedef {object} VocabLayer
|
|
495
|
+
* @property {string} id
|
|
496
|
+
* @property {string} name
|
|
497
|
+
* @property {string} timeCreated
|
|
498
|
+
* @property {string} timeModified
|
|
499
|
+
* @property {Record<string, any>} config
|
|
500
|
+
* @property {string[]} maintainers
|
|
501
|
+
* @property {VocabItem[]} [items]
|
|
502
|
+
*/
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* @typedef {{id: string, name: string, project: string, config: Record<string, any>}} TextLayer
|
|
506
|
+
* @typedef {{id: string, name: string, textLayer: string, project: string, overlapMode: string,
|
|
507
|
+
* parentTokenLayer: string | null, config: Record<string, any>,
|
|
508
|
+
* constraints: Record<string, LayerConstraint[]>}} TokenLayer
|
|
509
|
+
* @typedef {{id: string, name: string, tokenLayer: string, project: string, config: Record<string, any>,
|
|
510
|
+
* constraints: Record<string, LayerConstraint[]>}} SpanLayer
|
|
511
|
+
* @typedef {{id: string, name: string, spanLayer: string, project: string, config: Record<string, any>,
|
|
512
|
+
* constraints: Record<string, LayerConstraint[]>}} RelationLayer
|
|
513
|
+
*/
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* The records with metadata, by the path segment of their routes.
|
|
517
|
+
* @typedef {{documents: PlaidDocument, texts: PlaidText, tokens: Token, spans: Span,
|
|
518
|
+
* relations: Relation, "vocab-items": VocabItem, "vocab-links": VocabLink}} MetadataRecords
|
|
519
|
+
*/
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* The four layer kinds, by the path segment of their routes.
|
|
523
|
+
* @typedef {{"text-layers": TextLayer, "token-layers": TokenLayer, "span-layers": SpanLayer,
|
|
524
|
+
* "relation-layers": RelationLayer}} LayerRecords
|
|
525
|
+
*/
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* @typedef {object} User
|
|
529
|
+
* @property {string} id
|
|
530
|
+
* @property {string} displayName
|
|
531
|
+
* @property {boolean} isAdmin
|
|
532
|
+
* @property {string | null} deactivatedAt
|
|
533
|
+
* @property {string | null} avatarHash
|
|
534
|
+
*/
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* A project as the project list gives it: the project, with how many
|
|
538
|
+
* documents it has and when the newest of them last changed.
|
|
539
|
+
* @typedef {Project & {documentCount: number, lastModified: string | null}} ProjectListEntry
|
|
540
|
+
*/
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* A document as a project's document list gives it.
|
|
544
|
+
* @typedef {object} DocumentListEntry
|
|
545
|
+
* @property {string} id
|
|
546
|
+
* @property {string} name
|
|
547
|
+
* @property {number} version
|
|
548
|
+
* @property {string} timeCreated
|
|
549
|
+
* @property {string} timeModified
|
|
550
|
+
*/
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* A named API token, without the signed token itself, which only `create`
|
|
554
|
+
* returns.
|
|
555
|
+
* @typedef {object} ApiToken
|
|
556
|
+
* @property {string} id
|
|
557
|
+
* @property {string} userId
|
|
558
|
+
* @property {string} name
|
|
559
|
+
* @property {string} createdAt
|
|
560
|
+
* @property {string | null} lastUsedAt
|
|
561
|
+
* @property {string | null} revokedAt
|
|
562
|
+
*/
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Who made an operation, as the audit log names them.
|
|
566
|
+
* @typedef {{id: string, displayName: string, avatarHash: string | null}} AuditUser
|
|
567
|
+
*/
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* A project or a document an audit entry names, while it exists.
|
|
571
|
+
* @typedef {{id: string, name: string}} AuditTarget
|
|
572
|
+
*/
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* One operation of an audit entry.
|
|
576
|
+
* @typedef {object} AuditOp
|
|
577
|
+
* @property {string} id
|
|
578
|
+
* @property {string} type The kind of write, such as "document/update".
|
|
579
|
+
* @property {string} description
|
|
580
|
+
* @property {string} time
|
|
581
|
+
* @property {string} endTime The time to read at to see the operation done.
|
|
582
|
+
* @property {AuditUser | null} user
|
|
583
|
+
* @property {string} [credential]
|
|
584
|
+
* @property {AuditTarget} [project]
|
|
585
|
+
* @property {AuditTarget} [document]
|
|
586
|
+
* @property {string} [batchId]
|
|
587
|
+
*/
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* One entry of an audit log: a logical operation, an atomic batch or a lone
|
|
591
|
+
* write, with its operations oldest first (`ops`, cut to `opsLimit` when one
|
|
592
|
+
* was asked for, while `opCount` counts them all).
|
|
593
|
+
* @typedef {object} AuditEntry
|
|
594
|
+
* @property {string} id
|
|
595
|
+
* @property {string} time
|
|
596
|
+
* @property {string} endTime
|
|
597
|
+
* @property {AuditUser | null} user
|
|
598
|
+
* @property {AuditTarget[]} projects
|
|
599
|
+
* @property {AuditTarget[]} documents
|
|
600
|
+
* @property {AuditOp[]} ops
|
|
601
|
+
* @property {number} opCount
|
|
602
|
+
* @property {string} [groupId]
|
|
603
|
+
* @property {string} [message]
|
|
604
|
+
* @property {OperationKind} [kind]
|
|
605
|
+
* @property {string} [ref]
|
|
606
|
+
* @property {string} [batchId]
|
|
607
|
+
* @property {{id: string, name: string}} [apiToken]
|
|
608
|
+
* @property {string} [credential]
|
|
609
|
+
*/
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* A document lock as its holder sees it. `expiresAt` is in epoch
|
|
613
|
+
* milliseconds.
|
|
614
|
+
* @typedef {{lockId: string, userId: string, expiresAt: number}} LockGrant
|
|
615
|
+
*/
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* What `documents.restore` did, or with `dryRun` would do: per kind of
|
|
619
|
+
* record, how many come back, are set back and are removed (per layer for
|
|
620
|
+
* the layered kinds), and what could not come back, with why.
|
|
621
|
+
* @typedef {object} DocumentRestoreSummary
|
|
622
|
+
* @property {boolean} name
|
|
623
|
+
* @property {boolean} documentMetadata
|
|
624
|
+
* @property {RestoreCounts} texts
|
|
625
|
+
* @property {RestoreCounts & {byLayer: Array<RestoreCounts & {layerId: string}>}} tokens
|
|
626
|
+
* @property {RestoreCounts & {byLayer: Array<RestoreCounts & {layerId: string}>}} spans
|
|
627
|
+
* @property {RestoreCounts & {byLayer: Array<RestoreCounts & {layerId: string}>}} relations
|
|
628
|
+
* @property {RestoreCounts} vocabLinks
|
|
629
|
+
* @property {Array<{kind: string, count: number, reason: string}>} skipped
|
|
630
|
+
* @property {{name: string, taken: string}} [nameKept] When the name the
|
|
631
|
+
* document had then belongs to another document now: the name it keeps,
|
|
632
|
+
* and that other document's name.
|
|
633
|
+
* @property {number} total 0 when nothing changes.
|
|
634
|
+
*/
|
|
635
|
+
|
|
636
|
+
/** @typedef {{inserted: number, updated: number, deleted: number}} RestoreCounts */
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* A logical-operation group: its label, who made it and when, and the kind
|
|
640
|
+
* and reference of the operation when it has them.
|
|
641
|
+
* @typedef {object} OperationGroup
|
|
642
|
+
* @property {string} id
|
|
643
|
+
* @property {string | null} message
|
|
644
|
+
* @property {string} user
|
|
645
|
+
* @property {string} createdAt
|
|
646
|
+
* @property {string} [kind]
|
|
647
|
+
* @property {string} [ref]
|
|
648
|
+
*/
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* A query's answer. For "ids" and "entities", one row of `results` per
|
|
652
|
+
* match, a cell per `columns` entry: an id, or the entity as its GET
|
|
653
|
+
* answers it. For "count", only the count. `truncated`: the rows or the
|
|
654
|
+
* count stopped at the server's cap.
|
|
655
|
+
* @typedef {object} QueryResult
|
|
656
|
+
* @property {string} return
|
|
657
|
+
* @property {number} count
|
|
658
|
+
* @property {boolean} truncated
|
|
659
|
+
* @property {string[]} [columns]
|
|
660
|
+
* @property {any[][]} [results]
|
|
661
|
+
*/
|
|
662
|
+
|
|
663
|
+
export {};
|