@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.
Files changed (49) hide show
  1. package/package.json +3 -2
  2. package/src/apiAnnotations.d.ts +508 -0
  3. package/src/apiAnnotations.js +543 -0
  4. package/src/apiDocuments.d.ts +569 -0
  5. package/src/apiDocuments.js +551 -0
  6. package/src/apiLayers.d.ts +369 -0
  7. package/src/apiLayers.js +222 -0
  8. package/src/apiMessages.d.ts +293 -0
  9. package/src/apiMessages.js +265 -0
  10. package/src/apiPeople.d.ts +626 -0
  11. package/src/apiPeople.js +698 -0
  12. package/src/apiProject.d.ts +761 -0
  13. package/src/apiProject.js +774 -0
  14. package/src/apiServer.d.ts +455 -0
  15. package/src/apiServer.js +422 -0
  16. package/src/apiVocab.d.ts +456 -0
  17. package/src/apiVocab.js +425 -0
  18. package/src/batch.d.ts +54 -0
  19. package/src/batch.js +323 -0
  20. package/src/client.d.ts +1321 -0
  21. package/src/client.js +743 -0
  22. package/src/constraints.d.ts +8 -0
  23. package/src/constraints.js +14 -0
  24. package/src/documentLock.d.ts +18 -4
  25. package/src/documentLock.js +43 -9
  26. package/src/entryForms.d.ts +63 -0
  27. package/src/entryForms.js +152 -0
  28. package/src/events.js +2 -1
  29. package/src/families.d.ts +349 -0
  30. package/src/families.js +396 -0
  31. package/src/http.d.ts +39 -18
  32. package/src/http.js +127 -87
  33. package/src/index.d.ts +90 -4557
  34. package/src/index.js +113 -5172
  35. package/src/operations.d.ts +36 -0
  36. package/src/operations.js +164 -0
  37. package/src/provenance.d.ts +47 -4
  38. package/src/provenance.js +168 -12
  39. package/src/roles.d.ts +39 -0
  40. package/src/roles.js +44 -0
  41. package/src/serviceSchema.d.ts +19 -13
  42. package/src/serviceSchema.js +30 -15
  43. package/src/services.d.ts +20 -3
  44. package/src/services.js +45 -8
  45. package/src/sse.js +10 -1
  46. package/src/testing.d.ts +128 -0
  47. package/src/testing.js +379 -0
  48. package/src/types.d.ts +867 -0
  49. package/src/types.js +663 -0
@@ -0,0 +1,349 @@
1
+ /** @typedef {import("./client.js").PlaidClient} PlaidClient */
2
+ /**
3
+ * @typedef {import("./types.js").MetadataOp} MetadataOp
4
+ * @typedef {import("./types.js").LayerConstraint} LayerConstraint
5
+ * @typedef {import("./types.js").ConstraintViolation} ConstraintViolation
6
+ * @typedef {import("./types.js").OperationKind} OperationKind
7
+ * @typedef {import("./types.js").ConstraintRepair} ConstraintRepair
8
+ * @typedef {import("./types.js").ValueSetRule} ValueSetRule
9
+ * @typedef {import("./types.js").RefusedValues} RefusedValues
10
+ * @typedef {import("./types.js").MetadataRecords} MetadataRecords
11
+ * @typedef {import("./types.js").LayerRecords} LayerRecords
12
+ * @typedef {import("./types.js").AuditEntry} AuditEntry
13
+ */
14
+ /**
15
+ * @template [T=any]
16
+ * @typedef {import("./types.js").Page<T>} Page
17
+ */
18
+ export function csvParam(values: any): string;
19
+ export function bodyOf(obj: any): {};
20
+ /**
21
+ * The request options of a config write. With `options.expected` present
22
+ * (even as undefined, which means the key was absent) the write is a
23
+ * compare-and-set: `?if-unchanged=true` and the body `{expected, value}`,
24
+ * which the server refuses with a 409 when the stored value is no longer
25
+ * `expected`. Without it the body is the value itself. Config is opaque, so
26
+ * neither body is re-cased.
27
+ */
28
+ export function configRequest(auditMessage: any, value: any, options: any, isDelete?: boolean): {
29
+ auditMessage: any;
30
+ rawBody?: undefined;
31
+ queryParams?: undefined;
32
+ } | {
33
+ auditMessage: any;
34
+ rawBody: any;
35
+ queryParams?: undefined;
36
+ } | {
37
+ auditMessage: any;
38
+ queryParams: {
39
+ "if-unchanged": boolean;
40
+ };
41
+ rawBody: {
42
+ expected: any;
43
+ value?: undefined;
44
+ } | {
45
+ expected: any;
46
+ value: any;
47
+ };
48
+ };
49
+ /**
50
+ * The query of an audit read: the window, the op-type and kind filters, the
51
+ * one vocabulary entry, and for one page its order, ops limit and entry id. A
52
+ * key left undefined is not sent.
53
+ * @private
54
+ */
55
+ export function auditQuery({ startTime, endTime, opTypes, itemId, kinds, order, opsLimit, entryId }: {
56
+ startTime: any;
57
+ endTime: any;
58
+ opTypes: any;
59
+ itemId: any;
60
+ kinds: any;
61
+ order: any;
62
+ opsLimit: any;
63
+ entryId: any;
64
+ }): {
65
+ "start-time": any;
66
+ "end-time": any;
67
+ "op-types": string;
68
+ "item-id": any;
69
+ kinds: string;
70
+ order: any;
71
+ "ops-limit": any;
72
+ "entry-id": any;
73
+ };
74
+ /**
75
+ * The audit readers of a document, a project or a user, on
76
+ * `/api/v1/<kind>/<id>/audit`. A vocabulary's take an entry id as well and are
77
+ * its own, and the instance-wide log is `audit.list`.
78
+ * @param {PlaidClient} client
79
+ * @param {"documents"|"projects"|"users"} kind
80
+ */
81
+ export function auditMethods(client: PlaidClient, kind: "documents" | "projects" | "users"): {
82
+ /**
83
+ * Get the audit log of a document or a project, or of a user's actions.
84
+ * Transparently follows pagination cursors and returns the full flat
85
+ * array. Each entry, and each of its `ops`, says what kind of credential
86
+ * made it as `credential`: `login`, `named-token` or `delegated` (absent
87
+ * on older operations, `service` on some from 2026-10-06 to 2026-10-08),
88
+ * beside `apiToken` (the named token's id and name) when there was one.
89
+ * @param {string} id - The document, project or user ID
90
+ * @param {string} [startTime] - Start of time range
91
+ * @param {string} [endTime] - End of time range
92
+ * @param {string[]|string} [opTypes] - Only return operations of these
93
+ * types, spelled as in an entry's `op/type` (e.g.
94
+ * `['span-layer/create', 'span-layer/delete']`). An entry appears when
95
+ * one of its operations matches, carrying only the ones that did.
96
+ * @param {string[]|string} [kinds] - Only the entries of operations of
97
+ * these kinds (e.g. `['review', 'guess-adoption']`), each whole
98
+ * @returns {Promise<AuditEntry[]>}
99
+ */
100
+ audit: (id: string, startTime?: string, endTime?: string, opTypes?: string[] | string, kinds?: string[] | string) => Promise<AuditEntry[]>;
101
+ /**
102
+ * One page of the same log, newest-first with `order: "desc"`. Use this
103
+ * rather than audit() wherever the caller wants the recent end of a log
104
+ * that may be long: audit() walks every page before it resolves.
105
+ * @param {string} id - The document, project or user ID
106
+ * @param {object} [opts]
107
+ * @param {string} [opts.startTime] - Only entries at or after this instant
108
+ * @param {string} [opts.endTime] - Only entries at or before this instant
109
+ * @param {string[]|string} [opts.opTypes] - Only these op types
110
+ * @param {OperationKind[]|string} [opts.kinds] - Only the entries of operations of these kinds, each whole
111
+ * @param {"asc"|"desc"} [opts.order] - "desc" pages newest-first
112
+ * @param {number} [opts.limit] - Page size (1..1000; server default 100)
113
+ * @param {string} [opts.cursor] - Opaque cursor from a previous page
114
+ * @param {number} [opts.opsLimit] - Keep only each entry's oldest N
115
+ * operations in `ops` (1..1000). `opCount` on every entry says how
116
+ * many it has
117
+ * @param {string} [opts.entryId] - Read only this entry, not a page
118
+ * @returns {Promise<Page<AuditEntry>>}
119
+ */
120
+ auditPage: (id: string, { startTime, endTime, opTypes, kinds, order, limit, cursor, opsLimit, entryId }?: {
121
+ startTime?: string;
122
+ endTime?: string;
123
+ opTypes?: string[] | string;
124
+ kinds?: OperationKind[] | string;
125
+ order?: "asc" | "desc";
126
+ limit?: number;
127
+ cursor?: string;
128
+ opsLimit?: number;
129
+ entryId?: string;
130
+ }) => Promise<Page<AuditEntry>>;
131
+ };
132
+ /**
133
+ * The three metadata methods of a bundle whose entities carry metadata, on
134
+ * `/api/v1/<kind>/<id>/metadata`. Metadata is opaque, so no body is re-cased.
135
+ * Each answers the entity as its GET does.
136
+ * @template {keyof MetadataRecords} K
137
+ * @param {PlaidClient} client
138
+ * @param {K} kind
139
+ */
140
+ export function metadataMethods<K extends keyof MetadataRecords>(client: PlaidClient, kind: K): {
141
+ /**
142
+ * Replace all metadata of an entity. Keys left out of the new map are removed.
143
+ * @param {string} id - The entity's ID
144
+ * @param {object} body - The new metadata map
145
+ * @param {string} [auditMessage] - Audit message for this write
146
+ * @returns {Promise<MetadataRecords[K]>}
147
+ */
148
+ setMetadata: (id: string, body: object, auditMessage?: string) => Promise<MetadataRecords[K]>;
149
+ /**
150
+ * Remove all metadata from an entity.
151
+ * @param {string} id - The entity's ID
152
+ * @param {string} [auditMessage] - Audit message for this write
153
+ * @returns {Promise<MetadataRecords[K]>}
154
+ */
155
+ deleteMetadata: (id: string, auditMessage?: string) => Promise<MetadataRecords[K]>;
156
+ /**
157
+ * Edit an entity's metadata with a list of ops applied in order, in one operation. `{op: 'set', path, value}` writes value at path, creating missing objects along it; `{op: 'delete', path}` removes the key at path (a no-op when absent). A path is a non-empty array of keys, the first a top-level key. A path through a non-object is refused (400). See metadataOps and applyMetadataOps.
158
+ * @param {string} id - The entity's ID
159
+ * @param {MetadataOp[]} body - The metadata ops
160
+ * @param {string} [auditMessage] - Audit message for this write
161
+ * @returns {Promise<MetadataRecords[K]>}
162
+ */
163
+ patchMetadata: (id: string, body: MetadataOp[], auditMessage?: string) => Promise<MetadataRecords[K]>;
164
+ };
165
+ /**
166
+ * The two config methods of a bundle whose records carry editor config, on
167
+ * `/api/v1/<kind>/<id>/config/<namespace>/<key>`.
168
+ * @param {PlaidClient} client
169
+ * @param {string} kind
170
+ */
171
+ export function configMethods(client: PlaidClient, kind: string): {
172
+ /**
173
+ * Set a configuration value in an editor namespace.
174
+ * @param {string} id - The record's ID
175
+ * @param {string} namespace - The config namespace
176
+ * @param {string} configKey - The config key
177
+ * @param {any} configValue - Configuration value to set
178
+ * @param {string} [auditMessage] - Audit message for this write
179
+ * @param {{expected?: any}} [options] - `expected`: the value read for this key (null or undefined when it
180
+ * was absent). The write is then refused with a 409 when the stored value differs. A value the key
181
+ * already holds is not written and leaves no audit row, so the value read, expecting it, states in a
182
+ * batch that the key is unchanged.
183
+ * @returns {Promise<void>}
184
+ */
185
+ setConfig: (id: string, namespace: string, configKey: string, configValue: any, auditMessage?: string, options?: {
186
+ expected?: any;
187
+ }) => Promise<void>;
188
+ /**
189
+ * Remove a configuration value.
190
+ * @param {string} id - The record's ID
191
+ * @param {string} namespace - The config namespace
192
+ * @param {string} configKey - The config key
193
+ * @param {string} [auditMessage] - Audit message for this write
194
+ * @param {{expected?: any}} [options] - `expected`, as on setConfig. A key that is absent is not
195
+ * written, so expecting null states in a batch that it is still absent.
196
+ * @returns {Promise<void>}
197
+ */
198
+ deleteConfig: (id: string, namespace: string, configKey: string, auditMessage?: string, options?: {
199
+ expected?: any;
200
+ }) => Promise<void>;
201
+ };
202
+ /**
203
+ * The get, delete, update and shift methods of the four layer bundles, on
204
+ * `/api/v1/<kind>/<layerId>`.
205
+ * @template {keyof LayerRecords} K
206
+ * @param {PlaidClient} client
207
+ * @param {K} kind
208
+ */
209
+ export function layerMethods<K extends keyof LayerRecords>(client: PlaidClient, kind: K): {
210
+ /**
211
+ * Get a layer by ID.
212
+ * @param {string} layerId - The layer ID
213
+ * @returns {Promise<LayerRecords[K]>}
214
+ */
215
+ get: (layerId: string) => Promise<LayerRecords[K]>;
216
+ /**
217
+ * Delete a layer.
218
+ * @param {string} layerId - The layer ID
219
+ * @param {string} [auditMessage] - Audit message for this write
220
+ * @returns {Promise<void>}
221
+ */
222
+ delete: (layerId: string, auditMessage?: string) => Promise<void>;
223
+ /**
224
+ * Rename a layer.
225
+ * @param {string} layerId - The layer ID
226
+ * @param {string} name - The new name
227
+ * @param {string} [auditMessage] - Audit message for this write
228
+ * @returns {Promise<LayerRecords[K]>}
229
+ */
230
+ update: (layerId: string, name: string, auditMessage?: string) => Promise<LayerRecords[K]>;
231
+ /**
232
+ * Move a layer one place in its display order.
233
+ * @param {string} layerId - The layer ID
234
+ * @param {string} direction - The direction ("up" or "down")
235
+ * @param {string} [auditMessage] - Audit message for this write
236
+ * @returns {Promise<void>}
237
+ */
238
+ shift: (layerId: string, direction: string, auditMessage?: string) => Promise<void>;
239
+ };
240
+ /**
241
+ * The four layer-constraint methods of a layer bundle, on `/api/v1/<kind>`.
242
+ * See constraints.js and the core manual, "Layer constraints".
243
+ * @param {PlaidClient} client
244
+ * @param {string} kind
245
+ */
246
+ export function constraintMethods(client: PlaidClient, kind: string): {
247
+ /**
248
+ * Declare an app namespace's constraints on this layer, replacing that
249
+ * namespace's list. Refused with 422 and the violations when the layer's
250
+ * stored data breaks them (see violationsOf).
251
+ * @param {string} layerId - The layer ID
252
+ * @param {string} namespace - The declaring app's namespace, e.g. "igt"
253
+ * @param {LayerConstraint[]} constraints - e.g. [{type: "single-span"}, {type: "value-set", values: ["N"]}]
254
+ * @param {string} [auditMessage] - Audit message for this write
255
+ * @param {{expected?: Array<object>|null}} [options] - `expected`: the list read for this
256
+ * namespace (null when it was absent). The write is then refused with a 409 when the stored
257
+ * list differs.
258
+ * @returns {Promise<{constraints: Record<string, LayerConstraint[]>}>} the layer's whole constraint map
259
+ */
260
+ setConstraints: (layerId: string, namespace: string, constraints: LayerConstraint[], auditMessage?: string, options?: {
261
+ expected?: Array<object> | null;
262
+ }) => Promise<{
263
+ constraints: Record<string, LayerConstraint[]>;
264
+ }>;
265
+ /**
266
+ * Remove an app namespace's constraints from this layer.
267
+ * @param {string} layerId - The layer ID
268
+ * @param {string} namespace - The declaring app's namespace
269
+ * @param {string} [auditMessage] - Audit message for this write
270
+ * @param {{expected?: Array<object>|null}} [options] - `expected`, as on setConstraints.
271
+ * @returns {Promise<void>}
272
+ */
273
+ deleteConstraints: (layerId: string, namespace: string, auditMessage?: string, options?: {
274
+ expected?: Array<object> | null;
275
+ }) => Promise<void>;
276
+ /**
277
+ * The violations the given constraints would meet in this layer's stored
278
+ * data. Writes nothing.
279
+ * @param {string} layerId - The layer ID
280
+ * @param {LayerConstraint[]} constraints - The list to check
281
+ * @param {{limit?: number}} [options] - `limit`: how many violations to list (default 100)
282
+ * @returns {Promise<{violations: ConstraintViolation[], violationCount: number}>}
283
+ */
284
+ checkConstraints: (layerId: string, constraints: LayerConstraint[], options?: {
285
+ limit?: number;
286
+ }) => Promise<{
287
+ violations: ConstraintViolation[];
288
+ violationCount: number;
289
+ }>;
290
+ /**
291
+ * Apply the remedies of the given constraints' remediable types
292
+ * (coextensive, single-span, single-link, same-ancestor) to every
293
+ * violation in this layer's stored data, one operation per document.
294
+ * With `document`, only that document is repaired, and a writer may
295
+ * ask. A document another user holds the lock on is left as it is and
296
+ * listed under `locked`.
297
+ * @param {string} layerId - The layer ID
298
+ * @param {LayerConstraint[]} constraints - The list to repair for
299
+ * @param {string} [auditMessage] - Audit message for this write
300
+ * @param {{document?: string}} [options]
301
+ * @returns {Promise<{repaired: ConstraintRepair[], locked: Array<{document: string, lockedBy: string}>, violations: ConstraintViolation[], violationCount: number}>}
302
+ */
303
+ repairConstraints: (layerId: string, constraints: LayerConstraint[], auditMessage?: string, options?: {
304
+ document?: string;
305
+ }) => Promise<{
306
+ repaired: ConstraintRepair[];
307
+ locked: Array<{
308
+ document: string;
309
+ lockedBy: string;
310
+ }>;
311
+ violations: ConstraintViolation[];
312
+ violationCount: number;
313
+ }>;
314
+ };
315
+ /**
316
+ * The value-set read of a span or relation layer bundle, on
317
+ * `/api/v1/<kind>/<layerId>/constraints/refused-values`.
318
+ * @param {PlaidClient} client
319
+ * @param {string} kind
320
+ */
321
+ export function valueSetMethods(client: PlaidClient, kind: string): {
322
+ /**
323
+ * The stored values of this layer that a value-set rule would refuse,
324
+ * before it is declared: exactly what a declaration of it would meet,
325
+ * with the rule's exemptions (an unconfirmed machine value, a value an
326
+ * import, a document copy or a restore set). Writes nothing, and a
327
+ * reader may ask.
328
+ * @param {string} layerId - The layer ID
329
+ * @param {ValueSetRule} rule - The list as a value-set declaration takes it
330
+ * @param {{limit?: number}} [options] - `limit`: how many values to list, the most frequent first
331
+ * (default 20, at most 100)
332
+ * @returns {Promise<RefusedValues>}
333
+ */
334
+ refusedValues: (layerId: string, rule: ValueSetRule, options?: {
335
+ limit?: number;
336
+ }) => Promise<RefusedValues>;
337
+ };
338
+ export type PlaidClient = import("./client.js").PlaidClient;
339
+ export type MetadataOp = import("./types.js").MetadataOp;
340
+ export type LayerConstraint = import("./types.js").LayerConstraint;
341
+ export type ConstraintViolation = import("./types.js").ConstraintViolation;
342
+ export type OperationKind = import("./types.js").OperationKind;
343
+ export type ConstraintRepair = import("./types.js").ConstraintRepair;
344
+ export type ValueSetRule = import("./types.js").ValueSetRule;
345
+ export type RefusedValues = import("./types.js").RefusedValues;
346
+ export type MetadataRecords = import("./types.js").MetadataRecords;
347
+ export type LayerRecords = import("./types.js").LayerRecords;
348
+ export type AuditEntry = import("./types.js").AuditEntry;
349
+ export type Page<T = any> = import("./types.js").Page<T>;