@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
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("./types.js").TextEditOp} TextEditOp
|
|
3
|
+
* @typedef {import("./types.js").TextGap} TextGap
|
|
4
|
+
* @typedef {import("./types.js").MetadataOp} MetadataOp
|
|
5
|
+
* @typedef {import("./types.js").LayerConstraint} LayerConstraint
|
|
6
|
+
* @typedef {import("./types.js").ConstraintWriteOptions} ConstraintWriteOptions
|
|
7
|
+
* @typedef {import("./types.js").ConstraintViolation} ConstraintViolation
|
|
8
|
+
* @typedef {import("./types.js").Requester} Requester
|
|
9
|
+
* @typedef {import("./types.js").BatchRef} BatchRef
|
|
10
|
+
* @typedef {import("./types.js").ServiceParam} ServiceParam
|
|
11
|
+
* @typedef {import("./types.js").ServiceInfo} ServiceInfo
|
|
12
|
+
* @typedef {import("./types.js").DiscoveredService} DiscoveredService
|
|
13
|
+
* @typedef {import("./types.js").ResponseHelper} ResponseHelper
|
|
14
|
+
* @typedef {import("./types.js").ServiceRegistration} ServiceRegistration
|
|
15
|
+
* @typedef {import("./types.js").ServiceStatusEvent} ServiceStatusEvent
|
|
16
|
+
* @typedef {import("./types.js").OperationGroupsBundle} OperationGroupsBundle
|
|
17
|
+
* @typedef {import("./types.js").PlaidClientOptions} PlaidClientOptions
|
|
18
|
+
* @typedef {import("./types.js").OperationKind} OperationKind
|
|
19
|
+
* @typedef {import("./types.js").KeySeed} KeySeed
|
|
20
|
+
* @typedef {import("./types.js").PlaidBatch} PlaidBatch
|
|
21
|
+
* @typedef {import("./types.js").AuditPageOptions} AuditPageOptions
|
|
22
|
+
* @typedef {import("./types.js").VocabItemRestoreSummary} VocabItemRestoreSummary
|
|
23
|
+
* @typedef {import("./types.js").UserDataEntry} UserDataEntry
|
|
24
|
+
* @typedef {import("./types.js").AdminUserDataEntry} AdminUserDataEntry
|
|
25
|
+
* @typedef {import("./types.js").ActivityTallyRow} ActivityTallyRow
|
|
26
|
+
* @typedef {import("./types.js").ConstraintRepair} ConstraintRepair
|
|
27
|
+
* @typedef {import("./types.js").ValueSetRule} ValueSetRule
|
|
28
|
+
* @typedef {import("./types.js").RefusedValues} RefusedValues
|
|
29
|
+
* @typedef {import("./types.js").CommentableType} CommentableType
|
|
30
|
+
* @typedef {import("./types.js").Comment} Comment
|
|
31
|
+
* @typedef {import("./types.js").Guideline} Guideline
|
|
32
|
+
* @typedef {import("./types.js").ClientEventType} ClientEventType
|
|
33
|
+
* @typedef {import("./types.js").ClientEvent} ClientEvent
|
|
34
|
+
* @typedef {import("./types.js").Invite} Invite
|
|
35
|
+
* @typedef {import("./types.js").ServerLimits} ServerLimits
|
|
36
|
+
* @typedef {import("./types.js").ServerHealth} ServerHealth
|
|
37
|
+
* @typedef {import("./types.js").RateLimitBucket} RateLimitBucket
|
|
38
|
+
* @typedef {import("./types.js").RateLimitSnapshot} RateLimitSnapshot
|
|
39
|
+
* @typedef {import("./types.js").BackupStatus} BackupStatus
|
|
40
|
+
* @typedef {import("./types.js").ServerReport} ServerReport
|
|
41
|
+
* @typedef {import("./types.js").LiveLog} LiveLog
|
|
42
|
+
* @typedef {import("./types.js").SSEConnection} SSEConnection
|
|
43
|
+
* @typedef {import("./types.js").SSEStats} SSEStats
|
|
44
|
+
* @typedef {import("./types.js").AtomicValue} AtomicValue
|
|
45
|
+
* @typedef {import("./types.js").Created} Created
|
|
46
|
+
* @typedef {import("./types.js").Project} Project
|
|
47
|
+
* @typedef {import("./types.js").ProjectTextLayer} ProjectTextLayer
|
|
48
|
+
* @typedef {import("./types.js").ProjectTokenLayer} ProjectTokenLayer
|
|
49
|
+
* @typedef {import("./types.js").ProjectSpanLayer} ProjectSpanLayer
|
|
50
|
+
* @typedef {import("./types.js").ProjectRelationLayer} ProjectRelationLayer
|
|
51
|
+
* @typedef {import("./types.js").ProjectVocab} ProjectVocab
|
|
52
|
+
* @typedef {import("./types.js").PlaidDocument} PlaidDocument
|
|
53
|
+
* @typedef {import("./types.js").DocumentTextLayer} DocumentTextLayer
|
|
54
|
+
* @typedef {import("./types.js").DocumentTokenLayer} DocumentTokenLayer
|
|
55
|
+
* @typedef {import("./types.js").DocumentSpanLayer} DocumentSpanLayer
|
|
56
|
+
* @typedef {import("./types.js").PlaidText} PlaidText
|
|
57
|
+
* @typedef {import("./types.js").TextReshape} TextReshape
|
|
58
|
+
* @typedef {import("./types.js").Token} Token
|
|
59
|
+
* @typedef {import("./types.js").Span} Span
|
|
60
|
+
* @typedef {import("./types.js").Relation} Relation
|
|
61
|
+
* @typedef {import("./types.js").VocabItem} VocabItem
|
|
62
|
+
* @typedef {import("./types.js").VocabLink} VocabLink
|
|
63
|
+
* @typedef {import("./types.js").VocabLayer} VocabLayer
|
|
64
|
+
* @typedef {import("./types.js").TextLayer} TextLayer
|
|
65
|
+
* @typedef {import("./types.js").TokenLayer} TokenLayer
|
|
66
|
+
* @typedef {import("./types.js").SpanLayer} SpanLayer
|
|
67
|
+
* @typedef {import("./types.js").RelationLayer} RelationLayer
|
|
68
|
+
* @typedef {import("./types.js").MetadataRecords} MetadataRecords
|
|
69
|
+
* @typedef {import("./types.js").LayerRecords} LayerRecords
|
|
70
|
+
* @typedef {import("./types.js").User} User
|
|
71
|
+
* @typedef {import("./types.js").ProjectListEntry} ProjectListEntry
|
|
72
|
+
* @typedef {import("./types.js").DocumentListEntry} DocumentListEntry
|
|
73
|
+
* @typedef {import("./types.js").ApiToken} ApiToken
|
|
74
|
+
* @typedef {import("./types.js").AuditUser} AuditUser
|
|
75
|
+
* @typedef {import("./types.js").AuditTarget} AuditTarget
|
|
76
|
+
* @typedef {import("./types.js").AuditOp} AuditOp
|
|
77
|
+
* @typedef {import("./types.js").AuditEntry} AuditEntry
|
|
78
|
+
* @typedef {import("./types.js").LockGrant} LockGrant
|
|
79
|
+
* @typedef {import("./types.js").DocumentRestoreSummary} DocumentRestoreSummary
|
|
80
|
+
* @typedef {import("./types.js").RestoreCounts} RestoreCounts
|
|
81
|
+
* @typedef {import("./types.js").OperationGroup} OperationGroup
|
|
82
|
+
* @typedef {import("./types.js").QueryResult} QueryResult
|
|
83
|
+
*/
|
|
84
|
+
/**
|
|
85
|
+
* @template [T=any]
|
|
86
|
+
* @typedef {import("./types.js").Page<T>} Page
|
|
87
|
+
*/
|
|
88
|
+
/** @param {import("./client.js").PlaidClient} client */
|
|
89
|
+
export function messagesApi(client: import("./client.js").PlaidClient): {
|
|
90
|
+
/**
|
|
91
|
+
* Open a Server-Sent Events stream for a project.
|
|
92
|
+
* @param {string} projectId - The UUID of the project to listen to
|
|
93
|
+
* @param {(eventType: string, data: any) => void | boolean} onEvent - Callback function that receives (eventType, data). If it returns true, listening will stop.
|
|
94
|
+
* @param {string} [path] - Stream path under baseUrl (defaults to the project /listen bus; service channels pass their own).
|
|
95
|
+
* @returns {SSEConnection} SSE connection object with .close() and .getStats() methods
|
|
96
|
+
*/
|
|
97
|
+
listen: (projectId: string, onEvent: (eventType: string, data: any) => void | boolean, path?: string) => SSEConnection;
|
|
98
|
+
/**
|
|
99
|
+
* Send a message to project listeners.
|
|
100
|
+
*
|
|
101
|
+
* `data` may be any JSON value and is sent VERBATIM (`rawBody`): a
|
|
102
|
+
* message payload is opaque application data, like `metadata` and
|
|
103
|
+
* `config`, so its keys must not be re-cased on the way out. Without
|
|
104
|
+
* this a key such as `case-marker` would reach listeners as
|
|
105
|
+
* `caseMarker` in JS and `case_marker` in Python. `listen` restores it
|
|
106
|
+
* verbatim on the way in.
|
|
107
|
+
*
|
|
108
|
+
* A message is not saved and writes nothing to History, so it never
|
|
109
|
+
* joins an open operation (`withOperation`). Made on a batch it still
|
|
110
|
+
* queues, so a message queued after the writes goes out after them.
|
|
111
|
+
* @param {string} projectId - The UUID of the project to send to
|
|
112
|
+
* @param {any} data - The message data to send
|
|
113
|
+
* @returns {Promise<{success: boolean, message: string}>}
|
|
114
|
+
*/
|
|
115
|
+
sendMessage: (projectId: string, data: any) => Promise<{
|
|
116
|
+
success: boolean;
|
|
117
|
+
message: string;
|
|
118
|
+
}>;
|
|
119
|
+
/**
|
|
120
|
+
* Discover the services seen on a project (synchronous GET). Currently
|
|
121
|
+
* connected services carry `online: true`; previously-seen offline ones
|
|
122
|
+
* carry `online: false` plus a `lastSeenAt` stamp.
|
|
123
|
+
* @param {string} projectId - The UUID of the project to query
|
|
124
|
+
* @returns {Promise<DiscoveredService[]>} Array of discovered service information
|
|
125
|
+
*/
|
|
126
|
+
discoverServices: (projectId: string) => Promise<DiscoveredService[]>;
|
|
127
|
+
/**
|
|
128
|
+
* Forget a previously-seen (offline) service. Maintainer-only; 409 if
|
|
129
|
+
* the service is currently connected.
|
|
130
|
+
* @param {string} projectId - The UUID of the project
|
|
131
|
+
* @param {string} serviceId - The ID of the service to forget
|
|
132
|
+
* @returns {Promise<void>}
|
|
133
|
+
*/
|
|
134
|
+
discardService: (projectId: string, serviceId: string) => Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Release a service id from the account that first registered it on
|
|
137
|
+
* the project, so the next account to register it claims it.
|
|
138
|
+
* Admin-only; 409 while the service is connected, 404 when no account
|
|
139
|
+
* holds it.
|
|
140
|
+
* @param {string} projectId - The UUID of the project
|
|
141
|
+
* @param {string} serviceId - The ID of the service to release
|
|
142
|
+
* @returns {Promise<void>}
|
|
143
|
+
*/
|
|
144
|
+
releaseService: (projectId: string, serviceId: string) => Promise<void>;
|
|
145
|
+
/**
|
|
146
|
+
* Register as a service and handle incoming work requests.
|
|
147
|
+
*
|
|
148
|
+
* The registration reopens its channel whenever it drops, so a server
|
|
149
|
+
* restart needs no service restart.
|
|
150
|
+
* @param {string} projectId - The UUID of the project to serve
|
|
151
|
+
* @param {ServiceInfo} serviceInfo - Service information {serviceId, serviceName, description}
|
|
152
|
+
* @param {(data: any, responseHelper: ResponseHelper) => void} onServiceRequest - Callback (data, responseHelper)
|
|
153
|
+
* @param {Object} [extras] - Optional additional service metadata
|
|
154
|
+
* @param {(event: ServiceStatusEvent, projectId: string, detail?: string) => void} [onStatus] - Optional callback (event, projectId, detail) for
|
|
155
|
+
* connection transitions: 'registered', 'reconnected', 'disconnected',
|
|
156
|
+
* and 'stopped' when the server refuses the channel for good, which
|
|
157
|
+
* ends the registration
|
|
158
|
+
* @returns {ServiceRegistration} Service registration with .stop(), .isRunning(), .isConnected()
|
|
159
|
+
*/
|
|
160
|
+
serve: (projectId: string, serviceInfo: ServiceInfo, onServiceRequest: (data: any, responseHelper: ResponseHelper) => void, extras?: any, onStatus?: (event: ServiceStatusEvent, projectId: string, detail?: string) => void) => ServiceRegistration;
|
|
161
|
+
/**
|
|
162
|
+
* Request a service to perform work and await its result.
|
|
163
|
+
*
|
|
164
|
+
* The request outlives this call: after a timeout, an abort, or a
|
|
165
|
+
* dropped connection the service goes on, and `attachServiceRequest`
|
|
166
|
+
* collects the result given the request id, which `opts.onAccepted`
|
|
167
|
+
* receives as soon as the server has taken the request. Pass
|
|
168
|
+
* `opts.requestId` (a UUID you mint) to know the id before submitting;
|
|
169
|
+
* submitting an id that names a request you already made rejoins it
|
|
170
|
+
* instead of starting another.
|
|
171
|
+
* @param {string} projectId - The UUID of the project
|
|
172
|
+
* @param {string} serviceId - The ID of the service to request
|
|
173
|
+
* @param {any} data - The request data
|
|
174
|
+
* @param {number} [timeout=10000] - Timeout in ms
|
|
175
|
+
* @param {function} [onProgress] - Called with each progress payload {percent, message}
|
|
176
|
+
* @param {AbortSignal} [signal] - Abort to stop waiting; rejects with an AbortError
|
|
177
|
+
* @param {{requestId?: string, onAccepted?: (requestId: string) => void, projectIds?: string[], noOperation?: boolean}} [opts] - {requestId, onAccepted, projectIds, noOperation}
|
|
178
|
+
* @returns {Promise<any>} The service's result
|
|
179
|
+
*/
|
|
180
|
+
requestService: (projectId: string, serviceId: string, data: any, timeout?: number, onProgress?: Function, signal?: AbortSignal, opts?: {
|
|
181
|
+
requestId?: string;
|
|
182
|
+
onAccepted?: (requestId: string) => void;
|
|
183
|
+
projectIds?: string[];
|
|
184
|
+
noOperation?: boolean;
|
|
185
|
+
}) => Promise<any>;
|
|
186
|
+
/**
|
|
187
|
+
* Rejoin a service request made earlier and await its result: the
|
|
188
|
+
* latest progress is replayed, then the result comes, or at once if the
|
|
189
|
+
* request already finished. Only the user who submitted it (or an
|
|
190
|
+
* admin). Rejects with an error whose `status` is 404 when the request
|
|
191
|
+
* is unknown or expired (a finished request's result is kept for a
|
|
192
|
+
* while, not forever).
|
|
193
|
+
* @param {string} projectId - The UUID of the project
|
|
194
|
+
* @param {string} requestId - The request id
|
|
195
|
+
* @param {number} [timeout=10000] - Timeout in ms
|
|
196
|
+
* @param {function} [onProgress] - Called with each progress payload
|
|
197
|
+
* @param {AbortSignal} [signal] - Abort to stop waiting
|
|
198
|
+
* @returns {Promise<any>} The service's result
|
|
199
|
+
*/
|
|
200
|
+
attachServiceRequest: (projectId: string, requestId: string, timeout?: number, onProgress?: Function, signal?: AbortSignal) => Promise<any>;
|
|
201
|
+
/**
|
|
202
|
+
* Ask the service to stop a request made earlier. The request still
|
|
203
|
+
* ends with whatever the service then reports, on the stream of whoever
|
|
204
|
+
* is awaiting it. Rejects with 404 if unknown or expired, 409 once
|
|
205
|
+
* finished.
|
|
206
|
+
* @param {string} projectId - The UUID of the project
|
|
207
|
+
* @param {string} requestId - The request id
|
|
208
|
+
* @returns {Promise<void>}
|
|
209
|
+
*/
|
|
210
|
+
cancelServiceRequest: (projectId: string, requestId: string) => Promise<void>;
|
|
211
|
+
};
|
|
212
|
+
export type TextEditOp = import("./types.js").TextEditOp;
|
|
213
|
+
export type TextGap = import("./types.js").TextGap;
|
|
214
|
+
export type MetadataOp = import("./types.js").MetadataOp;
|
|
215
|
+
export type LayerConstraint = import("./types.js").LayerConstraint;
|
|
216
|
+
export type ConstraintWriteOptions = import("./types.js").ConstraintWriteOptions;
|
|
217
|
+
export type ConstraintViolation = import("./types.js").ConstraintViolation;
|
|
218
|
+
export type Requester = import("./types.js").Requester;
|
|
219
|
+
export type BatchRef = import("./types.js").BatchRef;
|
|
220
|
+
export type ServiceParam = import("./types.js").ServiceParam;
|
|
221
|
+
export type ServiceInfo = import("./types.js").ServiceInfo;
|
|
222
|
+
export type DiscoveredService = import("./types.js").DiscoveredService;
|
|
223
|
+
export type ResponseHelper = import("./types.js").ResponseHelper;
|
|
224
|
+
export type ServiceRegistration = import("./types.js").ServiceRegistration;
|
|
225
|
+
export type ServiceStatusEvent = import("./types.js").ServiceStatusEvent;
|
|
226
|
+
export type OperationGroupsBundle = import("./types.js").OperationGroupsBundle;
|
|
227
|
+
export type PlaidClientOptions = import("./types.js").PlaidClientOptions;
|
|
228
|
+
export type OperationKind = import("./types.js").OperationKind;
|
|
229
|
+
export type KeySeed = import("./types.js").KeySeed;
|
|
230
|
+
export type PlaidBatch = import("./types.js").PlaidBatch;
|
|
231
|
+
export type AuditPageOptions = import("./types.js").AuditPageOptions;
|
|
232
|
+
export type VocabItemRestoreSummary = import("./types.js").VocabItemRestoreSummary;
|
|
233
|
+
export type UserDataEntry = import("./types.js").UserDataEntry;
|
|
234
|
+
export type AdminUserDataEntry = import("./types.js").AdminUserDataEntry;
|
|
235
|
+
export type ActivityTallyRow = import("./types.js").ActivityTallyRow;
|
|
236
|
+
export type ConstraintRepair = import("./types.js").ConstraintRepair;
|
|
237
|
+
export type ValueSetRule = import("./types.js").ValueSetRule;
|
|
238
|
+
export type RefusedValues = import("./types.js").RefusedValues;
|
|
239
|
+
export type CommentableType = import("./types.js").CommentableType;
|
|
240
|
+
export type Comment = import("./types.js").Comment;
|
|
241
|
+
export type Guideline = import("./types.js").Guideline;
|
|
242
|
+
export type ClientEventType = import("./types.js").ClientEventType;
|
|
243
|
+
export type ClientEvent = import("./types.js").ClientEvent;
|
|
244
|
+
export type Invite = import("./types.js").Invite;
|
|
245
|
+
export type ServerLimits = import("./types.js").ServerLimits;
|
|
246
|
+
export type ServerHealth = import("./types.js").ServerHealth;
|
|
247
|
+
export type RateLimitBucket = import("./types.js").RateLimitBucket;
|
|
248
|
+
export type RateLimitSnapshot = import("./types.js").RateLimitSnapshot;
|
|
249
|
+
export type BackupStatus = import("./types.js").BackupStatus;
|
|
250
|
+
export type ServerReport = import("./types.js").ServerReport;
|
|
251
|
+
export type LiveLog = import("./types.js").LiveLog;
|
|
252
|
+
export type SSEConnection = import("./types.js").SSEConnection;
|
|
253
|
+
export type SSEStats = import("./types.js").SSEStats;
|
|
254
|
+
export type AtomicValue = import("./types.js").AtomicValue;
|
|
255
|
+
export type Created = import("./types.js").Created;
|
|
256
|
+
export type Project = import("./types.js").Project;
|
|
257
|
+
export type ProjectTextLayer = import("./types.js").ProjectTextLayer;
|
|
258
|
+
export type ProjectTokenLayer = import("./types.js").ProjectTokenLayer;
|
|
259
|
+
export type ProjectSpanLayer = import("./types.js").ProjectSpanLayer;
|
|
260
|
+
export type ProjectRelationLayer = import("./types.js").ProjectRelationLayer;
|
|
261
|
+
export type ProjectVocab = import("./types.js").ProjectVocab;
|
|
262
|
+
export type PlaidDocument = import("./types.js").PlaidDocument;
|
|
263
|
+
export type DocumentTextLayer = import("./types.js").DocumentTextLayer;
|
|
264
|
+
export type DocumentTokenLayer = import("./types.js").DocumentTokenLayer;
|
|
265
|
+
export type DocumentSpanLayer = import("./types.js").DocumentSpanLayer;
|
|
266
|
+
export type PlaidText = import("./types.js").PlaidText;
|
|
267
|
+
export type TextReshape = import("./types.js").TextReshape;
|
|
268
|
+
export type Token = import("./types.js").Token;
|
|
269
|
+
export type Span = import("./types.js").Span;
|
|
270
|
+
export type Relation = import("./types.js").Relation;
|
|
271
|
+
export type VocabItem = import("./types.js").VocabItem;
|
|
272
|
+
export type VocabLink = import("./types.js").VocabLink;
|
|
273
|
+
export type VocabLayer = import("./types.js").VocabLayer;
|
|
274
|
+
export type TextLayer = import("./types.js").TextLayer;
|
|
275
|
+
export type TokenLayer = import("./types.js").TokenLayer;
|
|
276
|
+
export type SpanLayer = import("./types.js").SpanLayer;
|
|
277
|
+
export type RelationLayer = import("./types.js").RelationLayer;
|
|
278
|
+
export type MetadataRecords = import("./types.js").MetadataRecords;
|
|
279
|
+
export type LayerRecords = import("./types.js").LayerRecords;
|
|
280
|
+
export type User = import("./types.js").User;
|
|
281
|
+
export type ProjectListEntry = import("./types.js").ProjectListEntry;
|
|
282
|
+
export type DocumentListEntry = import("./types.js").DocumentListEntry;
|
|
283
|
+
export type ApiToken = import("./types.js").ApiToken;
|
|
284
|
+
export type AuditUser = import("./types.js").AuditUser;
|
|
285
|
+
export type AuditTarget = import("./types.js").AuditTarget;
|
|
286
|
+
export type AuditOp = import("./types.js").AuditOp;
|
|
287
|
+
export type AuditEntry = import("./types.js").AuditEntry;
|
|
288
|
+
export type LockGrant = import("./types.js").LockGrant;
|
|
289
|
+
export type DocumentRestoreSummary = import("./types.js").DocumentRestoreSummary;
|
|
290
|
+
export type RestoreCounts = import("./types.js").RestoreCounts;
|
|
291
|
+
export type OperationGroup = import("./types.js").OperationGroup;
|
|
292
|
+
export type QueryResult = import("./types.js").QueryResult;
|
|
293
|
+
export type Page<T = any> = import("./types.js").Page<T>;
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The messages bundle: the project event stream, broadcast messages and the
|
|
3
|
+
* service calls it delegates to services.js and sse.js, a factory of the
|
|
4
|
+
* client (client.js installs it).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { attachServiceRequest, cancelServiceRequest, discardService, discoverServices, releaseService, requestService, serve } from "./services.js";
|
|
8
|
+
import { createSSEConnection } from "./sse.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {import("./types.js").TextEditOp} TextEditOp
|
|
12
|
+
* @typedef {import("./types.js").TextGap} TextGap
|
|
13
|
+
* @typedef {import("./types.js").MetadataOp} MetadataOp
|
|
14
|
+
* @typedef {import("./types.js").LayerConstraint} LayerConstraint
|
|
15
|
+
* @typedef {import("./types.js").ConstraintWriteOptions} ConstraintWriteOptions
|
|
16
|
+
* @typedef {import("./types.js").ConstraintViolation} ConstraintViolation
|
|
17
|
+
* @typedef {import("./types.js").Requester} Requester
|
|
18
|
+
* @typedef {import("./types.js").BatchRef} BatchRef
|
|
19
|
+
* @typedef {import("./types.js").ServiceParam} ServiceParam
|
|
20
|
+
* @typedef {import("./types.js").ServiceInfo} ServiceInfo
|
|
21
|
+
* @typedef {import("./types.js").DiscoveredService} DiscoveredService
|
|
22
|
+
* @typedef {import("./types.js").ResponseHelper} ResponseHelper
|
|
23
|
+
* @typedef {import("./types.js").ServiceRegistration} ServiceRegistration
|
|
24
|
+
* @typedef {import("./types.js").ServiceStatusEvent} ServiceStatusEvent
|
|
25
|
+
* @typedef {import("./types.js").OperationGroupsBundle} OperationGroupsBundle
|
|
26
|
+
* @typedef {import("./types.js").PlaidClientOptions} PlaidClientOptions
|
|
27
|
+
* @typedef {import("./types.js").OperationKind} OperationKind
|
|
28
|
+
* @typedef {import("./types.js").KeySeed} KeySeed
|
|
29
|
+
* @typedef {import("./types.js").PlaidBatch} PlaidBatch
|
|
30
|
+
* @typedef {import("./types.js").AuditPageOptions} AuditPageOptions
|
|
31
|
+
* @typedef {import("./types.js").VocabItemRestoreSummary} VocabItemRestoreSummary
|
|
32
|
+
* @typedef {import("./types.js").UserDataEntry} UserDataEntry
|
|
33
|
+
* @typedef {import("./types.js").AdminUserDataEntry} AdminUserDataEntry
|
|
34
|
+
* @typedef {import("./types.js").ActivityTallyRow} ActivityTallyRow
|
|
35
|
+
* @typedef {import("./types.js").ConstraintRepair} ConstraintRepair
|
|
36
|
+
* @typedef {import("./types.js").ValueSetRule} ValueSetRule
|
|
37
|
+
* @typedef {import("./types.js").RefusedValues} RefusedValues
|
|
38
|
+
* @typedef {import("./types.js").CommentableType} CommentableType
|
|
39
|
+
* @typedef {import("./types.js").Comment} Comment
|
|
40
|
+
* @typedef {import("./types.js").Guideline} Guideline
|
|
41
|
+
* @typedef {import("./types.js").ClientEventType} ClientEventType
|
|
42
|
+
* @typedef {import("./types.js").ClientEvent} ClientEvent
|
|
43
|
+
* @typedef {import("./types.js").Invite} Invite
|
|
44
|
+
* @typedef {import("./types.js").ServerLimits} ServerLimits
|
|
45
|
+
* @typedef {import("./types.js").ServerHealth} ServerHealth
|
|
46
|
+
* @typedef {import("./types.js").RateLimitBucket} RateLimitBucket
|
|
47
|
+
* @typedef {import("./types.js").RateLimitSnapshot} RateLimitSnapshot
|
|
48
|
+
* @typedef {import("./types.js").BackupStatus} BackupStatus
|
|
49
|
+
* @typedef {import("./types.js").ServerReport} ServerReport
|
|
50
|
+
* @typedef {import("./types.js").LiveLog} LiveLog
|
|
51
|
+
* @typedef {import("./types.js").SSEConnection} SSEConnection
|
|
52
|
+
* @typedef {import("./types.js").SSEStats} SSEStats
|
|
53
|
+
* @typedef {import("./types.js").AtomicValue} AtomicValue
|
|
54
|
+
* @typedef {import("./types.js").Created} Created
|
|
55
|
+
* @typedef {import("./types.js").Project} Project
|
|
56
|
+
* @typedef {import("./types.js").ProjectTextLayer} ProjectTextLayer
|
|
57
|
+
* @typedef {import("./types.js").ProjectTokenLayer} ProjectTokenLayer
|
|
58
|
+
* @typedef {import("./types.js").ProjectSpanLayer} ProjectSpanLayer
|
|
59
|
+
* @typedef {import("./types.js").ProjectRelationLayer} ProjectRelationLayer
|
|
60
|
+
* @typedef {import("./types.js").ProjectVocab} ProjectVocab
|
|
61
|
+
* @typedef {import("./types.js").PlaidDocument} PlaidDocument
|
|
62
|
+
* @typedef {import("./types.js").DocumentTextLayer} DocumentTextLayer
|
|
63
|
+
* @typedef {import("./types.js").DocumentTokenLayer} DocumentTokenLayer
|
|
64
|
+
* @typedef {import("./types.js").DocumentSpanLayer} DocumentSpanLayer
|
|
65
|
+
* @typedef {import("./types.js").PlaidText} PlaidText
|
|
66
|
+
* @typedef {import("./types.js").TextReshape} TextReshape
|
|
67
|
+
* @typedef {import("./types.js").Token} Token
|
|
68
|
+
* @typedef {import("./types.js").Span} Span
|
|
69
|
+
* @typedef {import("./types.js").Relation} Relation
|
|
70
|
+
* @typedef {import("./types.js").VocabItem} VocabItem
|
|
71
|
+
* @typedef {import("./types.js").VocabLink} VocabLink
|
|
72
|
+
* @typedef {import("./types.js").VocabLayer} VocabLayer
|
|
73
|
+
* @typedef {import("./types.js").TextLayer} TextLayer
|
|
74
|
+
* @typedef {import("./types.js").TokenLayer} TokenLayer
|
|
75
|
+
* @typedef {import("./types.js").SpanLayer} SpanLayer
|
|
76
|
+
* @typedef {import("./types.js").RelationLayer} RelationLayer
|
|
77
|
+
* @typedef {import("./types.js").MetadataRecords} MetadataRecords
|
|
78
|
+
* @typedef {import("./types.js").LayerRecords} LayerRecords
|
|
79
|
+
* @typedef {import("./types.js").User} User
|
|
80
|
+
* @typedef {import("./types.js").ProjectListEntry} ProjectListEntry
|
|
81
|
+
* @typedef {import("./types.js").DocumentListEntry} DocumentListEntry
|
|
82
|
+
* @typedef {import("./types.js").ApiToken} ApiToken
|
|
83
|
+
* @typedef {import("./types.js").AuditUser} AuditUser
|
|
84
|
+
* @typedef {import("./types.js").AuditTarget} AuditTarget
|
|
85
|
+
* @typedef {import("./types.js").AuditOp} AuditOp
|
|
86
|
+
* @typedef {import("./types.js").AuditEntry} AuditEntry
|
|
87
|
+
* @typedef {import("./types.js").LockGrant} LockGrant
|
|
88
|
+
* @typedef {import("./types.js").DocumentRestoreSummary} DocumentRestoreSummary
|
|
89
|
+
* @typedef {import("./types.js").RestoreCounts} RestoreCounts
|
|
90
|
+
* @typedef {import("./types.js").OperationGroup} OperationGroup
|
|
91
|
+
* @typedef {import("./types.js").QueryResult} QueryResult
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @template [T=any]
|
|
96
|
+
* @typedef {import("./types.js").Page<T>} Page
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
/** @param {import("./client.js").PlaidClient} client */
|
|
100
|
+
export function messagesApi(client) {
|
|
101
|
+
return {
|
|
102
|
+
/**
|
|
103
|
+
* Open a Server-Sent Events stream for a project.
|
|
104
|
+
* @param {string} projectId - The UUID of the project to listen to
|
|
105
|
+
* @param {(eventType: string, data: any) => void | boolean} onEvent - Callback function that receives (eventType, data). If it returns true, listening will stop.
|
|
106
|
+
* @param {string} [path] - Stream path under baseUrl (defaults to the project /listen bus; service channels pass their own).
|
|
107
|
+
* @returns {SSEConnection} SSE connection object with .close() and .getStats() methods
|
|
108
|
+
*/
|
|
109
|
+
listen: (projectId, onEvent, path) =>
|
|
110
|
+
createSSEConnection(client, projectId, onEvent, path),
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Send a message to project listeners.
|
|
114
|
+
*
|
|
115
|
+
* `data` may be any JSON value and is sent VERBATIM (`rawBody`): a
|
|
116
|
+
* message payload is opaque application data, like `metadata` and
|
|
117
|
+
* `config`, so its keys must not be re-cased on the way out. Without
|
|
118
|
+
* this a key such as `case-marker` would reach listeners as
|
|
119
|
+
* `caseMarker` in JS and `case_marker` in Python. `listen` restores it
|
|
120
|
+
* verbatim on the way in.
|
|
121
|
+
*
|
|
122
|
+
* A message is not saved and writes nothing to History, so it never
|
|
123
|
+
* joins an open operation (`withOperation`). Made on a batch it still
|
|
124
|
+
* queues, so a message queued after the writes goes out after them.
|
|
125
|
+
* @param {string} projectId - The UUID of the project to send to
|
|
126
|
+
* @param {any} data - The message data to send
|
|
127
|
+
* @returns {Promise<{success: boolean, message: string}>}
|
|
128
|
+
*/
|
|
129
|
+
sendMessage: (projectId, data) =>
|
|
130
|
+
client._request("POST", `/api/v1/projects/${projectId}/message`, {
|
|
131
|
+
noOperation: true,
|
|
132
|
+
rawBody: { body: data },
|
|
133
|
+
}),
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Discover the services seen on a project (synchronous GET). Currently
|
|
137
|
+
* connected services carry `online: true`; previously-seen offline ones
|
|
138
|
+
* carry `online: false` plus a `lastSeenAt` stamp.
|
|
139
|
+
* @param {string} projectId - The UUID of the project to query
|
|
140
|
+
* @returns {Promise<DiscoveredService[]>} Array of discovered service information
|
|
141
|
+
*/
|
|
142
|
+
discoverServices: (projectId) => discoverServices(client, projectId),
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Forget a previously-seen (offline) service. Maintainer-only; 409 if
|
|
146
|
+
* the service is currently connected.
|
|
147
|
+
* @param {string} projectId - The UUID of the project
|
|
148
|
+
* @param {string} serviceId - The ID of the service to forget
|
|
149
|
+
* @returns {Promise<void>}
|
|
150
|
+
*/
|
|
151
|
+
discardService: (projectId, serviceId) =>
|
|
152
|
+
discardService(client, projectId, serviceId),
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Release a service id from the account that first registered it on
|
|
156
|
+
* the project, so the next account to register it claims it.
|
|
157
|
+
* Admin-only; 409 while the service is connected, 404 when no account
|
|
158
|
+
* holds it.
|
|
159
|
+
* @param {string} projectId - The UUID of the project
|
|
160
|
+
* @param {string} serviceId - The ID of the service to release
|
|
161
|
+
* @returns {Promise<void>}
|
|
162
|
+
*/
|
|
163
|
+
releaseService: (projectId, serviceId) =>
|
|
164
|
+
releaseService(client, projectId, serviceId),
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Register as a service and handle incoming work requests.
|
|
168
|
+
*
|
|
169
|
+
* The registration reopens its channel whenever it drops, so a server
|
|
170
|
+
* restart needs no service restart.
|
|
171
|
+
* @param {string} projectId - The UUID of the project to serve
|
|
172
|
+
* @param {ServiceInfo} serviceInfo - Service information {serviceId, serviceName, description}
|
|
173
|
+
* @param {(data: any, responseHelper: ResponseHelper) => void} onServiceRequest - Callback (data, responseHelper)
|
|
174
|
+
* @param {Object} [extras] - Optional additional service metadata
|
|
175
|
+
* @param {(event: ServiceStatusEvent, projectId: string, detail?: string) => void} [onStatus] - Optional callback (event, projectId, detail) for
|
|
176
|
+
* connection transitions: 'registered', 'reconnected', 'disconnected',
|
|
177
|
+
* and 'stopped' when the server refuses the channel for good, which
|
|
178
|
+
* ends the registration
|
|
179
|
+
* @returns {ServiceRegistration} Service registration with .stop(), .isRunning(), .isConnected()
|
|
180
|
+
*/
|
|
181
|
+
serve: (projectId, serviceInfo, onServiceRequest, extras, onStatus) =>
|
|
182
|
+
serve(client, projectId, serviceInfo, onServiceRequest, extras, onStatus),
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Request a service to perform work and await its result.
|
|
186
|
+
*
|
|
187
|
+
* The request outlives this call: after a timeout, an abort, or a
|
|
188
|
+
* dropped connection the service goes on, and `attachServiceRequest`
|
|
189
|
+
* collects the result given the request id, which `opts.onAccepted`
|
|
190
|
+
* receives as soon as the server has taken the request. Pass
|
|
191
|
+
* `opts.requestId` (a UUID you mint) to know the id before submitting;
|
|
192
|
+
* submitting an id that names a request you already made rejoins it
|
|
193
|
+
* instead of starting another.
|
|
194
|
+
* @param {string} projectId - The UUID of the project
|
|
195
|
+
* @param {string} serviceId - The ID of the service to request
|
|
196
|
+
* @param {any} data - The request data
|
|
197
|
+
* @param {number} [timeout=10000] - Timeout in ms
|
|
198
|
+
* @param {function} [onProgress] - Called with each progress payload {percent, message}
|
|
199
|
+
* @param {AbortSignal} [signal] - Abort to stop waiting; rejects with an AbortError
|
|
200
|
+
* @param {{requestId?: string, onAccepted?: (requestId: string) => void, projectIds?: string[], noOperation?: boolean}} [opts] - {requestId, onAccepted, projectIds, noOperation}
|
|
201
|
+
* @returns {Promise<any>} The service's result
|
|
202
|
+
*/
|
|
203
|
+
requestService: (
|
|
204
|
+
projectId,
|
|
205
|
+
serviceId,
|
|
206
|
+
data,
|
|
207
|
+
timeout,
|
|
208
|
+
onProgress,
|
|
209
|
+
signal,
|
|
210
|
+
opts,
|
|
211
|
+
) =>
|
|
212
|
+
requestService(
|
|
213
|
+
client,
|
|
214
|
+
projectId,
|
|
215
|
+
serviceId,
|
|
216
|
+
data,
|
|
217
|
+
timeout,
|
|
218
|
+
onProgress,
|
|
219
|
+
signal,
|
|
220
|
+
opts,
|
|
221
|
+
),
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Rejoin a service request made earlier and await its result: the
|
|
225
|
+
* latest progress is replayed, then the result comes, or at once if the
|
|
226
|
+
* request already finished. Only the user who submitted it (or an
|
|
227
|
+
* admin). Rejects with an error whose `status` is 404 when the request
|
|
228
|
+
* is unknown or expired (a finished request's result is kept for a
|
|
229
|
+
* while, not forever).
|
|
230
|
+
* @param {string} projectId - The UUID of the project
|
|
231
|
+
* @param {string} requestId - The request id
|
|
232
|
+
* @param {number} [timeout=10000] - Timeout in ms
|
|
233
|
+
* @param {function} [onProgress] - Called with each progress payload
|
|
234
|
+
* @param {AbortSignal} [signal] - Abort to stop waiting
|
|
235
|
+
* @returns {Promise<any>} The service's result
|
|
236
|
+
*/
|
|
237
|
+
attachServiceRequest: (
|
|
238
|
+
projectId,
|
|
239
|
+
requestId,
|
|
240
|
+
timeout,
|
|
241
|
+
onProgress,
|
|
242
|
+
signal,
|
|
243
|
+
) =>
|
|
244
|
+
attachServiceRequest(
|
|
245
|
+
client,
|
|
246
|
+
projectId,
|
|
247
|
+
requestId,
|
|
248
|
+
timeout,
|
|
249
|
+
onProgress,
|
|
250
|
+
signal,
|
|
251
|
+
),
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Ask the service to stop a request made earlier. The request still
|
|
255
|
+
* ends with whatever the service then reports, on the stream of whoever
|
|
256
|
+
* is awaiting it. Rejects with 404 if unknown or expired, 409 once
|
|
257
|
+
* finished.
|
|
258
|
+
* @param {string} projectId - The UUID of the project
|
|
259
|
+
* @param {string} requestId - The request id
|
|
260
|
+
* @returns {Promise<void>}
|
|
261
|
+
*/
|
|
262
|
+
cancelServiceRequest: (projectId, requestId) =>
|
|
263
|
+
cancelServiceRequest(client, projectId, requestId),
|
|
264
|
+
};
|
|
265
|
+
}
|