@larc-iu/plaid-client 0.2.0-alpha.3 → 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.
Files changed (73) hide show
  1. package/README.md +39 -0
  2. package/package.json +13 -6
  3. package/src/apiAnnotations.d.ts +508 -0
  4. package/src/apiAnnotations.js +543 -0
  5. package/src/apiDocuments.d.ts +569 -0
  6. package/src/apiDocuments.js +551 -0
  7. package/src/apiLayers.d.ts +369 -0
  8. package/src/apiLayers.js +222 -0
  9. package/src/apiMessages.d.ts +293 -0
  10. package/src/apiMessages.js +265 -0
  11. package/src/apiPeople.d.ts +626 -0
  12. package/src/apiPeople.js +698 -0
  13. package/src/apiProject.d.ts +761 -0
  14. package/src/apiProject.js +774 -0
  15. package/src/apiServer.d.ts +455 -0
  16. package/src/apiServer.js +422 -0
  17. package/src/apiVocab.d.ts +456 -0
  18. package/src/apiVocab.js +425 -0
  19. package/src/batch.d.ts +54 -0
  20. package/src/batch.js +323 -0
  21. package/src/batchRef.d.ts +30 -0
  22. package/src/batchRef.js +128 -0
  23. package/src/client.d.ts +1321 -0
  24. package/src/client.js +743 -0
  25. package/src/codepoint.d.ts +94 -0
  26. package/src/codepoint.js +131 -1
  27. package/src/constraints.d.ts +85 -0
  28. package/src/constraints.js +112 -0
  29. package/src/created.d.ts +2 -0
  30. package/src/created.js +29 -0
  31. package/src/documentLock.d.ts +172 -0
  32. package/src/documentLock.js +384 -0
  33. package/src/entryForms.d.ts +63 -0
  34. package/src/entryForms.js +152 -0
  35. package/src/events.d.ts +60 -0
  36. package/src/events.js +271 -0
  37. package/src/families.d.ts +349 -0
  38. package/src/families.js +396 -0
  39. package/src/http.d.ts +233 -0
  40. package/src/http.js +809 -93
  41. package/src/ids.d.ts +26 -0
  42. package/src/ids.js +96 -0
  43. package/src/index.d.ts +101 -0
  44. package/src/index.js +183 -2105
  45. package/src/metadataOps.d.ts +15 -0
  46. package/src/metadataOps.js +124 -0
  47. package/src/operations.d.ts +36 -0
  48. package/src/operations.js +164 -0
  49. package/src/pagination.d.ts +49 -0
  50. package/src/pagination.js +20 -53
  51. package/src/provenance.d.ts +243 -0
  52. package/src/provenance.js +458 -36
  53. package/src/replayed.d.ts +3 -0
  54. package/src/replayed.js +31 -0
  55. package/src/requester.d.ts +60 -0
  56. package/src/requester.js +74 -0
  57. package/src/roles.d.ts +104 -0
  58. package/src/roles.js +64 -2
  59. package/src/serviceSchema.d.ts +337 -0
  60. package/src/serviceSchema.js +177 -60
  61. package/src/services.d.ts +319 -0
  62. package/src/services.js +742 -58
  63. package/src/sse.d.ts +30 -0
  64. package/src/sse.js +80 -3
  65. package/src/testing.d.ts +128 -0
  66. package/src/testing.js +379 -0
  67. package/src/textEdits.d.ts +59 -0
  68. package/src/textEdits.js +234 -0
  69. package/src/transforms.d.ts +25 -0
  70. package/src/transforms.js +11 -1
  71. package/src/types.d.ts +867 -0
  72. package/src/types.js +663 -0
  73. package/index.d.ts +0 -532
@@ -0,0 +1,569 @@
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 documentsApi(client: import("./client.js").PlaidClient): {
90
+ audit: (id: string, startTime?: string, endTime?: string, opTypes?: string[] | string, kinds?: string[] | string) => Promise<import("./families.js").AuditEntry[]>;
91
+ auditPage: (id: string, { startTime, endTime, opTypes, kinds, order, limit, cursor, opsLimit, entryId }?: {
92
+ startTime?: string;
93
+ endTime?: string;
94
+ opTypes?: string[] | string;
95
+ kinds?: import("./families.js").OperationKind[] | string;
96
+ order?: "asc" | "desc";
97
+ limit?: number;
98
+ cursor?: string;
99
+ opsLimit?: number;
100
+ entryId?: string;
101
+ }) => Promise<import("./families.js").Page<import("./families.js").AuditEntry>>;
102
+ setMetadata: (id: string, body: object, auditMessage?: string) => Promise<import("./types.js").PlaidDocument>;
103
+ deleteMetadata: (id: string, auditMessage?: string) => Promise<import("./types.js").PlaidDocument>;
104
+ patchMetadata: (id: string, body: import("./families.js").MetadataOp[], auditMessage?: string) => Promise<import("./types.js").PlaidDocument>;
105
+ /**
106
+ * Get a document. Set `includeBody` to true to include all data.
107
+ *
108
+ * A document with a recording has `mediaUrl`, and `mediaDuration`, the
109
+ * recording's length in seconds, when the server could read it from the
110
+ * file at upload (WAV, MP4, M4A, MOV, FLAC, MP3).
111
+ *
112
+ * `layers` narrows a body read to the layers you name (ids of any kind:
113
+ * text, token, span, or relation). A layer comes back when it is named
114
+ * or is an ancestor of a named layer, and carries its own
115
+ * texts/tokens/spans/relations/vocabs only when it is itself named — so
116
+ * name the text layer too if you also want the text body. An id that is
117
+ * not a layer of this document's project is an error, not a quietly
118
+ * smaller response. Requires `includeBody`.
119
+ * @param {string} documentId - The document ID
120
+ * @param {boolean} [includeBody] - Include document body data
121
+ * @param {string} [asOf] - Temporal query timestamp
122
+ * @param {string[]|string} [layers] - Layer ids to restrict a body read to
123
+ * @returns {Promise<PlaidDocument>}
124
+ */
125
+ get: (documentId: string, includeBody?: boolean, asOf?: string, layers?: string[] | string) => Promise<PlaidDocument>;
126
+ /**
127
+ * Get the media file for a document, as a Blob whose `type` is the
128
+ * served media type. Media is not versioned, so there is no as-of form:
129
+ * the route refuses the parameter. A busy core (503) is asked again, as
130
+ * for any read. To play a recording, stream it from `mediaLink` instead.
131
+ * @param {string} documentId - The document ID
132
+ * @param {object} [options]
133
+ * @param {number | null} [options.timeout] - This read's timeout in ms, in place of the client's. A
134
+ * recording can take longer than the default 30 s to come down: null or 0 waits as long as it takes.
135
+ * @param {(progress: {loaded: number, total: number | null}) => void} [options.onProgress] - Called with
136
+ * `{ loaded, total }` (bytes, total null when unknown) as the file comes down.
137
+ * @returns {Promise<Blob>}
138
+ */
139
+ getMedia: (documentId: string, { timeout, onProgress }?: {
140
+ timeout?: number | null;
141
+ onProgress?: (progress: {
142
+ loaded: number;
143
+ total: number | null;
144
+ }) => void;
145
+ }) => Promise<Blob>;
146
+ /**
147
+ * Create a new document in a project.
148
+ * @param {string} projectId - The project ID
149
+ * @param {string} name - The name
150
+ * @param {any} [metadata] - Metadata map. Omit to leave unset; pass null to send JSON null.
151
+ * @param {string} [auditMessage] - Audit message for this write
152
+ * @param {object} [opts]
153
+ * @param {string} [opts.id] - The new entity's id, minted by the caller (see uuidv7)
154
+ * @param {boolean} [opts.freeName] - A name another document of the project holds, ignoring case, becomes
155
+ * the first free "name (2)", "name (3)" and on. Without it such a name is refused with 422
156
+ * and `name-taken`.
157
+ * @returns {Promise<{id: string, name: string}>} The new id and the name stored
158
+ */
159
+ create: (projectId: string, name: string, metadata?: any, auditMessage?: string, { id, freeName }?: {
160
+ id?: string;
161
+ freeName?: boolean;
162
+ }) => Promise<{
163
+ id: string;
164
+ name: string;
165
+ }>;
166
+ /**
167
+ * Update a document's name. A name another document of the project holds,
168
+ * ignoring case,
169
+ * is refused with 422 and `name-taken`.
170
+ * @param {string} documentId - The document ID
171
+ * @param {string} name - The name
172
+ * @param {string} [auditMessage] - Audit message for this write
173
+ * @returns {Promise<PlaidDocument>}
174
+ */
175
+ update: (documentId: string, name: string, auditMessage?: string) => Promise<PlaidDocument>;
176
+ /**
177
+ * Delete a document and all data contained.
178
+ * @param {string} documentId - The document ID
179
+ * @param {string} [auditMessage] - Audit message for this write
180
+ * @returns {Promise<void>}
181
+ */
182
+ delete: (documentId: string, auditMessage?: string) => Promise<void>;
183
+ /**
184
+ * Check the lock status of a document.
185
+ * @param {string} documentId - The document ID
186
+ * @returns {Promise<{userId: string, expiresAt: number} | void>}
187
+ */
188
+ checkLock: (documentId: string) => Promise<{
189
+ userId: string;
190
+ expiresAt: number;
191
+ } | void>;
192
+ /**
193
+ * Acquire a document lock as a new holder.
194
+ *
195
+ * The answer's `lockId` names the holder: `renewLock` and `releaseLock`
196
+ * take it. While the lock is held, a second acquire is refused with
197
+ * HTTP 423, whoever makes it, this user included.
198
+ *
199
+ * `newLockId` names the holder from the client's side (a fresh UUID). An
200
+ * acquire whose answer never arrived can then be sent again, which
201
+ * answers 200 while that holder has the lock, or released. Without it
202
+ * the server mints the id, and a lost answer leaves a lock nobody can
203
+ * release until it expires.
204
+ *
205
+ * outOfBand: the lock is a signal, not project data (see the note at
206
+ * the top of http.js). Queued on a batch it would be taken only at
207
+ * submit, after every write it was meant to guard, and until then answer
208
+ * success to a caller that does not hold it and cannot see the 423
209
+ * saying somebody else does.
210
+ * @param {string} documentId - The document ID
211
+ * @param {string} [auditMessage]
212
+ * @param {string} [newLockId] - A holder id this client minted
213
+ * @returns {Promise<LockGrant>}
214
+ */
215
+ acquireLock: (documentId: string, auditMessage?: string, newLockId?: string) => Promise<LockGrant>;
216
+ /**
217
+ * Renew the lock `lockId` holds while it is live. HTTP 423 if another
218
+ * holder has it, and also once it has expired or been dropped, even when
219
+ * nobody holds the document now: a renewal never takes a free document.
220
+ * outOfBand, for the same reason as acquireLock.
221
+ * @param {string} documentId - The document ID
222
+ * @param {string} lockId - The `lockId` acquireLock answered with
223
+ * @param {string} [auditMessage] - Audit message for this write
224
+ * @returns {Promise<LockGrant>}
225
+ */
226
+ renewLock: (documentId: string, lockId: string, auditMessage?: string) => Promise<LockGrant>;
227
+ /**
228
+ * Release the lock `lockId` holds. Idempotent: a lock that holder no
229
+ * longer has is left alone. outOfBand, for the same reason as
230
+ * acquireLock: queued, the lock would be held until the batch submits,
231
+ * and not released at all if it aborts.
232
+ * @param {string} documentId - The document ID
233
+ * @param {string} lockId - The `lockId` acquireLock answered with
234
+ * @param {string} [auditMessage] - Audit message for this write
235
+ * @returns {Promise<void>}
236
+ */
237
+ releaseLock: (documentId: string, lockId: string, auditMessage?: string) => Promise<void>;
238
+ /**
239
+ * Hold this document's server-enforced lock for the length of `fn`,
240
+ * releasing it on the way out (including on error). Resolves to what
241
+ * `fn` returned.
242
+ *
243
+ * await client.documents.locked(docId, async () => {
244
+ * // delete + recreate tokens
245
+ * });
246
+ *
247
+ * Wrap any multi-step, server-side mutation of a document that must not
248
+ * interleave with a human editor or another service, e.g. a parser or
249
+ * tokenizer that deletes and recreates a document's tokens, spans and
250
+ * relations. A single atomic call does not need it. While the lock is
251
+ * held, writes to the document by ANOTHER user are refused with HTTP
252
+ * 423; the holder's own writes pass and renew it. If anyone already
253
+ * holds it, another block of this same user included, this rejects with
254
+ * a readable 423 and `fn` does not run.
255
+ *
256
+ * The lock is renewed for as long as `fn` runs, so work that computes
257
+ * for minutes before it writes holds the lock the whole time rather than
258
+ * only for its first minute. If a renewal fails the lock is gone: every
259
+ * later write from this client throws `DocumentLockLost`, and a block
260
+ * that got to the end anyway ends with that error rather than reporting
261
+ * success. `fn` receives a lock handle and may read `lock.lost` (or call
262
+ * `lock.raiseIfLost()`) to give up sooner.
263
+ *
264
+ * The lock is per HOLDER: each block is its own, named by
265
+ * `lock.lockId`, and only that id renews or releases it. NOT
266
+ * re-entrant: a nested `locked()` block on one document is a second
267
+ * holder and gets the 423. Lock at exactly one level per call path.
268
+ * The block mints its holder id and sends it with the acquire, so an
269
+ * acquire whose answer was lost is sent again (up to three tries) and,
270
+ * if none is answered, released rather than left to expire. A
271
+ * lost lock is recorded on the CLIENT, like strict mode, so it stops
272
+ * every write the client makes (on any batch of it too) and not only the
273
+ * ones this block makes.
274
+ *
275
+ * A core restart drops every lock, and until the next renewal finds it
276
+ * gone (up to half the lock window) this block's writes still pass, since
277
+ * writes carry no lock id. When a write must not land past that point,
278
+ * hold the document in strict mode too (`enterStrictMode`), so such a
279
+ * write is refused with a 409.
280
+ * @template T
281
+ * @param {string} documentId - The document ID
282
+ * @param {(lock: import("./documentLock.js").DocumentLock) => T | Promise<T>} fn - The work to run while holding it
283
+ * @param {{keepAlive?: boolean}} [options] - `{ keepAlive }`: renew on a timer (default true)
284
+ * @returns {Promise<T>}
285
+ */
286
+ locked: <T>(documentId: string, fn: (lock: import("./documentLock.js").DocumentLock) => T | Promise<T>, options?: {
287
+ keepAlive?: boolean;
288
+ }) => Promise<T>;
289
+ /**
290
+ * Get a link that plays the document's recording without an
291
+ * Authorization header, for an audio or video element's `src`, which
292
+ * cannot send one. `url` is the document's media URL with a
293
+ * `media-token` added, resolved against the client's base URL. The token
294
+ * opens only this recording, for this user, and the server refuses it on
295
+ * every other route. It expires at `expiresAt` (an ISO-8601 instant, six
296
+ * hours on by default), and sooner when the user signs out, changes
297
+ * password or loses access to the project: ask for a new link then. A
298
+ * document with no recording is a 404. Writes nothing, so it takes no
299
+ * Idempotency-Key and goes over the wire when made on a batch.
300
+ * @param {string} documentId - The document ID
301
+ * @returns {Promise<{url: string, expiresAt: string}>}
302
+ */
303
+ mediaLink: (documentId: string) => Promise<{
304
+ url: string;
305
+ expiresAt: string;
306
+ }>;
307
+ /**
308
+ * Upload a media file for a document. Uses Apache Tika for content validation.
309
+ * A document that already has a recording refuses it with a 409
310
+ * (`media-exists`, and the current `media-url`): delete that one first.
311
+ * A WAV whose samples are not PCM, 32-bit float, A-law or mu-law (IMA or
312
+ * MS ADPCM, GSM, 64-bit float and the rest), which browsers cannot play,
313
+ * is refused with a 415 whose `error` names its coding.
314
+ * @param {string} documentId - The document ID
315
+ * @param {File} file - The file to upload
316
+ * @param {string} [auditMessage] - Custom audit-log message for this write
317
+ * @param {{onProgress?: (progress: {loaded: number, total: number | null}) => void}} [options] - `{ onProgress }`: called with `{ loaded, total }` (bytes) as the file goes up. In a browser the upload then travels by XMLHttpRequest, and the request timeout only fires when the upload stalls, not on total time.
318
+ * @returns {Promise<{message: string, extension: string, contentType: string}>}
319
+ */
320
+ uploadMedia: (documentId: string, file: File, auditMessage?: string, { onProgress }?: {
321
+ onProgress?: (progress: {
322
+ loaded: number;
323
+ total: number | null;
324
+ }) => void;
325
+ }) => Promise<{
326
+ message: string;
327
+ extension: string;
328
+ contentType: string;
329
+ }>;
330
+ /**
331
+ * Delete media file for a document
332
+ * @param {string} documentId - The document ID
333
+ * @param {string} [auditMessage] - Audit message for this write
334
+ * @param {{mediaVersion?: string}} [options] - `mediaVersion`: the
335
+ * recording meant, the `?v=` of the document's `mediaUrl`. The delete
336
+ * is refused with a 409 (`media-changed`, and the current `media-url`)
337
+ * when the stored recording is another one.
338
+ * @returns {Promise<void>}
339
+ */
340
+ deleteMedia: (documentId: string, auditMessage?: string, { mediaVersion }?: {
341
+ mediaVersion?: string;
342
+ }) => Promise<void>;
343
+ /**
344
+ * Restore a document to its state at an earlier time, as one
345
+ * operation: what was deleted since then comes back under its original
346
+ * id, what was added since is removed, and what changed is set back,
347
+ * across every layer. A layer deleted since then, or a vocabulary entry
348
+ * that no longer exists, is skipped and reported under `skipped`. A name
349
+ * another document holds now stays with it, and the document keeps its
350
+ * current name, reported under `nameKept` (`{name, taken}`).
351
+ * Resolves to a summary of the changes. Maintainers only.
352
+ * @param {string} documentId - The document ID
353
+ * @param {string} asOf - The moment to go back to (ISO-8601 instant),
354
+ * typically a history entry's `endTime`
355
+ * @param {{dryRun?: boolean}} [options] - `{ dryRun }`: with `dryRun` true nothing
356
+ * is written and the summary says what would change
357
+ * @param {string} [auditMessage] - Custom audit message for this operation
358
+ * @returns {Promise<DocumentRestoreSummary>}
359
+ */
360
+ restore: (documentId: string, asOf: string, { dryRun }?: {
361
+ dryRun?: boolean;
362
+ }, auditMessage?: string) => Promise<DocumentRestoreSummary>;
363
+ /**
364
+ * Copy a document and everything in it into a new document of the same
365
+ * project, as one operation. The copy shares the source's layers and
366
+ * the vocabulary entries its links name, and holds the source's texts,
367
+ * tokens, spans, relations and vocab links under fresh ids, with their
368
+ * metadata. Comments do not travel. The media file does, unless
369
+ * `includeMedia` is false. Resolves to `{ id, name }`, plus `mediaError` when
370
+ * the source had media the copy could not take with it. A name another
371
+ * document of the project holds, ignoring case, is refused with 422 and `name-taken`,
372
+ * unless `freeName`, which takes the first free "name (2)", "name (3)"
373
+ * and on.
374
+ * @param {string} documentId - The document to copy
375
+ * @param {string} name - The new document's name
376
+ * @param {{includeMedia?: boolean, id?: string, freeName?: boolean}} [options] - `{ includeMedia }`: false leaves the media
377
+ * file behind
378
+ * @param {string} [auditMessage] - Custom audit message for this operation
379
+ * @returns {Promise<{id: string, name: string, mediaError?: string}>}
380
+ */
381
+ copy: (documentId: string, name: string, { includeMedia, id, freeName }?: {
382
+ includeMedia?: boolean;
383
+ id?: string;
384
+ freeName?: boolean;
385
+ }, auditMessage?: string) => Promise<{
386
+ id: string;
387
+ name: string;
388
+ mediaError?: string;
389
+ }>;
390
+ };
391
+ /** @param {import("./client.js").PlaidClient} client */
392
+ export function textsApi(client: import("./client.js").PlaidClient): {
393
+ setMetadata: (id: string, body: object, auditMessage?: string) => Promise<import("./types.js").PlaidText>;
394
+ deleteMetadata: (id: string, auditMessage?: string) => Promise<import("./types.js").PlaidText>;
395
+ patchMetadata: (id: string, body: import("./families.js").MetadataOp[], auditMessage?: string) => Promise<import("./types.js").PlaidText>;
396
+ /**
397
+ * Get a text.
398
+ * @param {string} textId - The text ID
399
+ * @returns {Promise<PlaidText>}
400
+ */
401
+ get: (textId: string) => Promise<PlaidText>;
402
+ /**
403
+ * Create a new text in a document's text layer. A text is a container for
404
+ * one long string in `body` for a given layer.
405
+ * @param {string} textLayerId - The text layer ID
406
+ * @param {string} documentId - The document ID
407
+ * @param {string} body - The text
408
+ * @param {any} [metadata] - Metadata map. Omit to leave unset; pass null to send JSON null.
409
+ * @param {string} [auditMessage]
410
+ * @param {{id?: string, tokenEdges?: number[], tokenizeLayer?: string}} [options] - `id`: the
411
+ * new text's id, a UUIDv7 this client minted. `tokenEdges`: the code-point offsets where
412
+ * the tokens made next on this text begin and end. The body is stored composed, except a
413
+ * character one of them falls inside, which stays as sent (see composeText).
414
+ * `tokenizeLayer`: a word layer of the text, which gets the body's words, cut by the
415
+ * server ("Tokenize new text").
416
+ * @returns {Promise<Created>}
417
+ */
418
+ create: (textLayerId: string, documentId: string, body: string, metadata?: any, auditMessage?: string, { id, tokenEdges, tokenizeLayer }?: {
419
+ id?: string;
420
+ tokenEdges?: number[];
421
+ tokenizeLayer?: string;
422
+ }) => Promise<Created>;
423
+ /**
424
+ * Update a text's body. A diff is computed and token indices are updated
425
+ * so that tokens remain intact. Alternatively, `body` can be a list of
426
+ * edit directives (code-point indices, applied in order):
427
+ * {type: 'delete', index, value: count}
428
+ * {type: 'insert', index, value: string}
429
+ * {type: 'replace', index, length, value: string} — unlike
430
+ * delete+insert, a token covering the whole range is resized to keep
431
+ * it (respell a word in place without losing its annotations).
432
+ * A list is applied exactly as sent. With `base` (the `digest` of the
433
+ * body the update was made on, as every read of a text gives it) the
434
+ * update applies only to that body, and is refused with 409 and
435
+ * `text-changed` otherwise. Strict mode then does not stamp it, unless
436
+ * `versioned` is true (a batch whose later writes are stamped needs its
437
+ * first write stamped too).
438
+ * @param {string} textId - The text ID
439
+ * @param {any} body - The new text
440
+ * @param {string} [auditMessage]
441
+ * `tokenizeLayer`: a word layer of the text, whose words the server makes for the text the
442
+ * update types, after it places the old tokens ("Tokenize new text"). They come in the
443
+ * answer's `reshape`.
444
+ * @param {{base?: string, versioned?: boolean, tokenizeLayer?: string}} [options]
445
+ * @returns {Promise<PlaidText & {reshape: TextReshape}>}
446
+ */
447
+ update: (textId: string, body: any, auditMessage?: string, { base, versioned, tokenizeLayer }?: {
448
+ base?: string;
449
+ versioned?: boolean;
450
+ tokenizeLayer?: string;
451
+ }) => Promise<PlaidText & {
452
+ reshape: TextReshape;
453
+ }>;
454
+ /**
455
+ * Delete a text and all dependent data.
456
+ * @param {string} textId - The text ID
457
+ * @param {string} [auditMessage] - Audit message for this write
458
+ * @returns {Promise<void>}
459
+ */
460
+ delete: (textId: string, auditMessage?: string) => Promise<void>;
461
+ /**
462
+ * Change a text's body by the edits made at the caret: a list of edit
463
+ * directives as `update` takes them (code-point indices, applied in
464
+ * order, each index in the body the ones before it left). Only their
465
+ * net change counts. An insert or a delete stays where it was made, and
466
+ * a stretch deleted and typed over is a delete and an insert at the same
467
+ * place, so a word all of whose letters it replaces is deleted. The
468
+ * answer is the text with its new `digest` and `reshape` (the tokens
469
+ * moved, the spans and vocab links trimmed, the rows deleted). With
470
+ * `base`, the digest of the body the edits were made on, the edit
471
+ * applies only to that body and is refused with 409 and `text-changed`
472
+ * otherwise, and strict mode does not stamp it unless `versioned` is
473
+ * true. `tokenizeLayer` is as `update` takes it. See composeTextEdits and gapsToOps.
474
+ * @param {string} textId - The text ID
475
+ * @param {Array<object>} edits - The edit directives
476
+ * @param {string} [auditMessage]
477
+ * @param {{base?: string, versioned?: boolean, tokenizeLayer?: string}} [options]
478
+ * @returns {Promise<PlaidText & {reshape: TextReshape}>}
479
+ */
480
+ edit: (textId: string, edits: Array<object>, auditMessage?: string, { base, versioned, tokenizeLayer }?: {
481
+ base?: string;
482
+ versioned?: boolean;
483
+ tokenizeLayer?: string;
484
+ }) => Promise<PlaidText & {
485
+ reshape: TextReshape;
486
+ }>;
487
+ };
488
+ export type TextEditOp = import("./types.js").TextEditOp;
489
+ export type TextGap = import("./types.js").TextGap;
490
+ export type MetadataOp = import("./types.js").MetadataOp;
491
+ export type LayerConstraint = import("./types.js").LayerConstraint;
492
+ export type ConstraintWriteOptions = import("./types.js").ConstraintWriteOptions;
493
+ export type ConstraintViolation = import("./types.js").ConstraintViolation;
494
+ export type Requester = import("./types.js").Requester;
495
+ export type BatchRef = import("./types.js").BatchRef;
496
+ export type ServiceParam = import("./types.js").ServiceParam;
497
+ export type ServiceInfo = import("./types.js").ServiceInfo;
498
+ export type DiscoveredService = import("./types.js").DiscoveredService;
499
+ export type ResponseHelper = import("./types.js").ResponseHelper;
500
+ export type ServiceRegistration = import("./types.js").ServiceRegistration;
501
+ export type ServiceStatusEvent = import("./types.js").ServiceStatusEvent;
502
+ export type OperationGroupsBundle = import("./types.js").OperationGroupsBundle;
503
+ export type PlaidClientOptions = import("./types.js").PlaidClientOptions;
504
+ export type OperationKind = import("./types.js").OperationKind;
505
+ export type KeySeed = import("./types.js").KeySeed;
506
+ export type PlaidBatch = import("./types.js").PlaidBatch;
507
+ export type AuditPageOptions = import("./types.js").AuditPageOptions;
508
+ export type VocabItemRestoreSummary = import("./types.js").VocabItemRestoreSummary;
509
+ export type UserDataEntry = import("./types.js").UserDataEntry;
510
+ export type AdminUserDataEntry = import("./types.js").AdminUserDataEntry;
511
+ export type ActivityTallyRow = import("./types.js").ActivityTallyRow;
512
+ export type ConstraintRepair = import("./types.js").ConstraintRepair;
513
+ export type ValueSetRule = import("./types.js").ValueSetRule;
514
+ export type RefusedValues = import("./types.js").RefusedValues;
515
+ export type CommentableType = import("./types.js").CommentableType;
516
+ export type Comment = import("./types.js").Comment;
517
+ export type Guideline = import("./types.js").Guideline;
518
+ export type ClientEventType = import("./types.js").ClientEventType;
519
+ export type ClientEvent = import("./types.js").ClientEvent;
520
+ export type Invite = import("./types.js").Invite;
521
+ export type ServerLimits = import("./types.js").ServerLimits;
522
+ export type ServerHealth = import("./types.js").ServerHealth;
523
+ export type RateLimitBucket = import("./types.js").RateLimitBucket;
524
+ export type RateLimitSnapshot = import("./types.js").RateLimitSnapshot;
525
+ export type BackupStatus = import("./types.js").BackupStatus;
526
+ export type ServerReport = import("./types.js").ServerReport;
527
+ export type LiveLog = import("./types.js").LiveLog;
528
+ export type SSEConnection = import("./types.js").SSEConnection;
529
+ export type SSEStats = import("./types.js").SSEStats;
530
+ export type AtomicValue = import("./types.js").AtomicValue;
531
+ export type Created = import("./types.js").Created;
532
+ export type Project = import("./types.js").Project;
533
+ export type ProjectTextLayer = import("./types.js").ProjectTextLayer;
534
+ export type ProjectTokenLayer = import("./types.js").ProjectTokenLayer;
535
+ export type ProjectSpanLayer = import("./types.js").ProjectSpanLayer;
536
+ export type ProjectRelationLayer = import("./types.js").ProjectRelationLayer;
537
+ export type ProjectVocab = import("./types.js").ProjectVocab;
538
+ export type PlaidDocument = import("./types.js").PlaidDocument;
539
+ export type DocumentTextLayer = import("./types.js").DocumentTextLayer;
540
+ export type DocumentTokenLayer = import("./types.js").DocumentTokenLayer;
541
+ export type DocumentSpanLayer = import("./types.js").DocumentSpanLayer;
542
+ export type PlaidText = import("./types.js").PlaidText;
543
+ export type TextReshape = import("./types.js").TextReshape;
544
+ export type Token = import("./types.js").Token;
545
+ export type Span = import("./types.js").Span;
546
+ export type Relation = import("./types.js").Relation;
547
+ export type VocabItem = import("./types.js").VocabItem;
548
+ export type VocabLink = import("./types.js").VocabLink;
549
+ export type VocabLayer = import("./types.js").VocabLayer;
550
+ export type TextLayer = import("./types.js").TextLayer;
551
+ export type TokenLayer = import("./types.js").TokenLayer;
552
+ export type SpanLayer = import("./types.js").SpanLayer;
553
+ export type RelationLayer = import("./types.js").RelationLayer;
554
+ export type MetadataRecords = import("./types.js").MetadataRecords;
555
+ export type LayerRecords = import("./types.js").LayerRecords;
556
+ export type User = import("./types.js").User;
557
+ export type ProjectListEntry = import("./types.js").ProjectListEntry;
558
+ export type DocumentListEntry = import("./types.js").DocumentListEntry;
559
+ export type ApiToken = import("./types.js").ApiToken;
560
+ export type AuditUser = import("./types.js").AuditUser;
561
+ export type AuditTarget = import("./types.js").AuditTarget;
562
+ export type AuditOp = import("./types.js").AuditOp;
563
+ export type AuditEntry = import("./types.js").AuditEntry;
564
+ export type LockGrant = import("./types.js").LockGrant;
565
+ export type DocumentRestoreSummary = import("./types.js").DocumentRestoreSummary;
566
+ export type RestoreCounts = import("./types.js").RestoreCounts;
567
+ export type OperationGroup = import("./types.js").OperationGroup;
568
+ export type QueryResult = import("./types.js").QueryResult;
569
+ export type Page<T = any> = import("./types.js").Page<T>;