@fnndsc/cumin 3.30.6 → 3.31.0

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 (161) hide show
  1. package/dist/cache/checkpointWatch.d.ts +36 -0
  2. package/dist/cache/checkpointWatch.js +83 -0
  3. package/dist/cache/checkpointWatch.js.map +1 -0
  4. package/dist/cache/index.d.ts +1 -1
  5. package/dist/cache/index.js +4 -1
  6. package/dist/cache/index.js.map +1 -1
  7. package/dist/cache/listCache.d.ts +54 -2
  8. package/dist/cache/listCache.js +120 -24
  9. package/dist/cache/listCache.js.map +1 -1
  10. package/dist/cache/listCheckpoint.d.ts +5 -8
  11. package/dist/cache/listCheckpoint.js +17 -28
  12. package/dist/cache/listCheckpoint.js.map +1 -1
  13. package/dist/cache/listingInvalidation.js +11 -6
  14. package/dist/cache/listingInvalidation.js.map +1 -1
  15. package/dist/cache/procCache.d.ts +11 -0
  16. package/dist/cache/procCache.js +26 -1
  17. package/dist/cache/procCache.js.map +1 -1
  18. package/dist/cache/procCheckpoint.d.ts +11 -6
  19. package/dist/cache/procCheckpoint.js +280 -86
  20. package/dist/cache/procCheckpoint.js.map +1 -1
  21. package/dist/cache/queryIndex.d.ts +11 -0
  22. package/dist/cache/queryIndex.js +38 -2
  23. package/dist/cache/queryIndex.js.map +1 -1
  24. package/dist/cache/queryIndexCheckpoint.d.ts +32 -0
  25. package/dist/cache/queryIndexCheckpoint.js +180 -30
  26. package/dist/cache/queryIndexCheckpoint.js.map +1 -1
  27. package/dist/chrisapi/adapter.d.ts +266 -37
  28. package/dist/chrisapi/adapter.js +577 -116
  29. package/dist/chrisapi/adapter.js.map +1 -1
  30. package/dist/chrisapi/contract.d.ts +20 -20
  31. package/dist/chrisapi/contract.js +213 -60
  32. package/dist/chrisapi/contract.js.map +1 -1
  33. package/dist/chrisapi/cubeRequest.d.ts +198 -0
  34. package/dist/chrisapi/cubeRequest.js +345 -0
  35. package/dist/chrisapi/cubeRequest.js.map +1 -0
  36. package/dist/chrisapi/shape.d.ts +186 -0
  37. package/dist/chrisapi/shape.js +274 -0
  38. package/dist/chrisapi/shape.js.map +1 -0
  39. package/dist/cli.js +2 -1
  40. package/dist/cli.js.map +1 -1
  41. package/dist/compute/computeResources.d.ts +3 -0
  42. package/dist/compute/computeResources.js +5 -3
  43. package/dist/compute/computeResources.js.map +1 -1
  44. package/dist/config/config.d.ts +14 -0
  45. package/dist/config/config.js +6 -3
  46. package/dist/config/config.js.map +1 -1
  47. package/dist/connect/chrisConnection.d.ts +116 -6
  48. package/dist/connect/chrisConnection.js +418 -74
  49. package/dist/connect/chrisConnection.js.map +1 -1
  50. package/dist/connect/identityEpoch.d.ts +263 -0
  51. package/dist/connect/identityEpoch.js +414 -0
  52. package/dist/connect/identityEpoch.js.map +1 -0
  53. package/dist/connect/loginFailure.js +39 -22
  54. package/dist/connect/loginFailure.js.map +1 -1
  55. package/dist/context/chrisContext.js +36 -30
  56. package/dist/context/chrisContext.js.map +1 -1
  57. package/dist/error/errorStack.d.ts +1 -1
  58. package/dist/error/errorStack.js +1 -2
  59. package/dist/error/errorStack.js.map +1 -1
  60. package/dist/feeds/chrisAccess.d.ts +7 -2
  61. package/dist/feeds/chrisAccess.js +20 -7
  62. package/dist/feeds/chrisAccess.js.map +1 -1
  63. package/dist/feeds/chrisFeed.d.ts +8 -10
  64. package/dist/feeds/chrisFeed.js +27 -57
  65. package/dist/feeds/chrisFeed.js.map +1 -1
  66. package/dist/feeds/chrisTags.d.ts +1 -1
  67. package/dist/feeds/chrisTags.js +66 -24
  68. package/dist/feeds/chrisTags.js.map +1 -1
  69. package/dist/filebrowser/chrisFileBrowser.d.ts +0 -1
  70. package/dist/filebrowser/chrisFileBrowser.js +3 -5
  71. package/dist/filebrowser/chrisFileBrowser.js.map +1 -1
  72. package/dist/filebrowser/chrisFiles.d.ts +0 -1
  73. package/dist/filebrowser/chrisFiles.js +3 -4
  74. package/dist/filebrowser/chrisFiles.js.map +1 -1
  75. package/dist/filebrowser/chrisPACS.d.ts +4 -4
  76. package/dist/filebrowser/chrisPACS.js +10 -33
  77. package/dist/filebrowser/chrisPACS.js.map +1 -1
  78. package/dist/filebrowser/chrisPipeline.js +10 -45
  79. package/dist/filebrowser/chrisPipeline.js.map +1 -1
  80. package/dist/groups/chrisGroups.d.ts +3 -0
  81. package/dist/groups/chrisGroups.js +20 -8
  82. package/dist/groups/chrisGroups.js.map +1 -1
  83. package/dist/index.d.ts +6 -8
  84. package/dist/index.js +17 -28
  85. package/dist/index.js.map +1 -1
  86. package/dist/io/chrisIO.d.ts +81 -42
  87. package/dist/io/chrisIO.js +176 -325
  88. package/dist/io/chrisIO.js.map +1 -1
  89. package/dist/io/holderClient.d.ts +248 -0
  90. package/dist/io/holderClient.js +289 -0
  91. package/dist/io/holderClient.js.map +1 -0
  92. package/dist/io/holderFolder.d.ts +151 -0
  93. package/dist/io/holderFolder.js +311 -0
  94. package/dist/io/holderFolder.js.map +1 -0
  95. package/dist/io/holderIO.d.ts +258 -0
  96. package/dist/io/holderIO.js +557 -0
  97. package/dist/io/holderIO.js.map +1 -0
  98. package/dist/io/holderRequest.d.ts +299 -0
  99. package/dist/io/holderRequest.js +447 -0
  100. package/dist/io/holderRequest.js.map +1 -0
  101. package/dist/io/holderUpload.d.ts +62 -0
  102. package/dist/io/holderUpload.js +81 -0
  103. package/dist/io/holderUpload.js.map +1 -0
  104. package/dist/io/io.d.ts +12 -0
  105. package/dist/io/io.js.map +1 -1
  106. package/dist/io/localUpload.d.ts +59 -0
  107. package/dist/io/localUpload.js +150 -0
  108. package/dist/io/localUpload.js.map +1 -0
  109. package/dist/io/node_io.d.ts +16 -0
  110. package/dist/io/node_io.js +72 -0
  111. package/dist/io/node_io.js.map +1 -1
  112. package/dist/io/streamWatch.js +2 -2
  113. package/dist/io/streamWatch.js.map +1 -1
  114. package/dist/io/transferPool.d.ts +18 -2
  115. package/dist/io/transferPool.js +32 -7
  116. package/dist/io/transferPool.js.map +1 -1
  117. package/dist/pacs/chrisPACS.d.ts +3 -9
  118. package/dist/pacs/chrisPACS.js +102 -61
  119. package/dist/pacs/chrisPACS.js.map +1 -1
  120. package/dist/pacs/queryIndexSweep.d.ts +0 -9
  121. package/dist/pacs/queryIndexSweep.js +45 -41
  122. package/dist/pacs/queryIndexSweep.js.map +1 -1
  123. package/dist/path/chrisPath.d.ts +8 -3
  124. package/dist/path/chrisPath.js +10 -9
  125. package/dist/path/chrisPath.js.map +1 -1
  126. package/dist/pipelines/chrisPipeline.d.ts +28 -5
  127. package/dist/pipelines/chrisPipeline.js +270 -94
  128. package/dist/pipelines/chrisPipeline.js.map +1 -1
  129. package/dist/pipelines/pipelineMemo.d.ts +0 -16
  130. package/dist/pipelines/pipelineMemo.js +0 -27
  131. package/dist/pipelines/pipelineMemo.js.map +1 -1
  132. package/dist/plugins/chrisPlugins.d.ts +9 -5
  133. package/dist/plugins/chrisPlugins.js +97 -58
  134. package/dist/plugins/chrisPlugins.js.map +1 -1
  135. package/dist/resources/chrisObjContext.d.ts +7 -11
  136. package/dist/resources/chrisObjContext.js +7 -42
  137. package/dist/resources/chrisObjContext.js.map +1 -1
  138. package/dist/resources/chrisResources.d.ts +186 -74
  139. package/dist/resources/chrisResources.js +421 -117
  140. package/dist/resources/chrisResources.js.map +1 -1
  141. package/dist/resources/resourceShapes.d.ts +109 -0
  142. package/dist/resources/resourceShapes.js +22 -0
  143. package/dist/resources/resourceShapes.js.map +1 -0
  144. package/dist/users/chrisUsers.d.ts +4 -1
  145. package/dist/users/chrisUsers.js +6 -2
  146. package/dist/users/chrisUsers.js.map +1 -1
  147. package/dist/utils/keypair.js +21 -10
  148. package/dist/utils/keypair.js.map +1 -1
  149. package/package.json +10 -3
  150. package/dist/activities/chrisActivity.d.ts +0 -19
  151. package/dist/activities/chrisActivity.js +0 -29
  152. package/dist/activities/chrisActivity.js.map +0 -1
  153. package/dist/jobs/chrisJob.d.ts +0 -43
  154. package/dist/jobs/chrisJob.js +0 -174
  155. package/dist/jobs/chrisJob.js.map +0 -1
  156. package/dist/jobs/index.d.ts +0 -7
  157. package/dist/jobs/index.js +0 -24
  158. package/dist/jobs/index.js.map +0 -1
  159. package/dist/jobs/jobMonitor.d.ts +0 -46
  160. package/dist/jobs/jobMonitor.js +0 -102
  161. package/dist/jobs/jobMonitor.js.map +0 -1
@@ -18,6 +18,7 @@
18
18
  *
19
19
  * @module
20
20
  */
21
+ import { type Shape } from './shape.js';
21
22
  import Client, { ListResource } from '@fnndsc/chrisapi';
22
23
  /**
23
24
  * The chrisapi Client class, re-exported as a value.
@@ -47,10 +48,21 @@ export interface ClientAuth {
47
48
  * @param authUrl - Full URL of the CUBE `auth-token/` endpoint.
48
49
  * @param user - Username to authenticate as.
49
50
  * @param password - Password for the user.
51
+ * @param root - The API root the endpoint belongs to, parsed; the endpoint
52
+ * itself when not given. The password goes only to its origin.
50
53
  * @returns The bearer token string.
51
- * @throws {Error} Propagates chrisapi/network errors (e.g. bad credentials).
54
+ * @throws {CubeStatusError} When CUBE refuses the login (its status on the
55
+ * error; nothing CUBE answered is repeated).
56
+ * @throws {Error} When CUBE answers with a redirect (the password is never
57
+ * sent on: a 307 or 308 would resend it), gives no token, or the network
58
+ * fails (fetch's error, carrying its cause).
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * const token: string = await authToken_get('https://cube/api/v1/auth-token/', 'ada', 'pw');
63
+ * ```
52
64
  */
53
- export declare function authToken_get(authUrl: string, user: string, password: string): Promise<string>;
65
+ export declare function authToken_get(authUrl: string, user: string, password: string, root?: URL): Promise<string>;
54
66
  /**
55
67
  * Creates a chrisapi Client bound to a CUBE URL and bearer token.
56
68
  *
@@ -88,8 +100,12 @@ export declare function rootLinks_share(client: Client): Client;
88
100
  * @param url - Base URL of the CUBE API, ending in `/`.
89
101
  * @param token - The token to prove.
90
102
  * @param timeout - How long to wait for the answer.
91
- * @throws {Error} chrisapi's error: carrying CUBE's response when it
92
- * refused, "No server response!" when nothing came back.
103
+ * The check goes only to the API root's origin and follows no redirect.
104
+ *
105
+ * @throws {Error} Carrying `response` (with CUBE's status) when CUBE
106
+ * refused or redirected; "No server response!" when nothing came back in
107
+ * time; fetch's own error, its cause the network's code, when the
108
+ * connection failed.
93
109
  */
94
110
  export declare function token_verify(url: string, token: string, timeout?: number): Promise<void>;
95
111
  /**
@@ -100,14 +116,54 @@ export declare function token_verify(url: string, token: string, timeout?: numbe
100
116
  */
101
117
  export declare function client_authGet(client: Client): ClientAuth;
102
118
  /**
103
- * Resolves the admin URL of a client, populating client URLs if needed.
119
+ * Resolves the admin URL of a client: the one it holds, or the `admin` link
120
+ * its API root advertises, read through the one guarded request (held to
121
+ * the root's origin, following no redirect) rather than chrisapi's root
122
+ * read, which follows redirects with the token. The link, held or learnt, is
123
+ * held to the root's origin here as well as when a request is sent there, so
124
+ * a blank or foreign link never passes this preflight.
104
125
  *
105
126
  * Non-admin users have no admin link; for them this resolves to null.
106
127
  *
107
128
  * @param client - A connected chrisapi Client.
108
129
  * @returns The admin URL string, or null when the user has no admin access.
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * const adminUrl: string | null = await client_adminUrlEnsure(client); // 'https://cube/chris-admin/api/v1/' for an admin
134
+ * ```
109
135
  */
110
136
  export declare function client_adminUrlEnsure(client: Client): Promise<string | null>;
137
+ /**
138
+ * The API root a client was made with, as a URL: http or https, with no
139
+ * query or fragment.
140
+ *
141
+ * @param client - The client.
142
+ * @returns The root, ending in a slash; null when the client holds none usable.
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * apiRoot_read(client)?.origin; // 'https://cube'
147
+ * ```
148
+ */
149
+ export declare function apiRoot_read(client: Client): URL | null;
150
+ /**
151
+ * A CUBE API root as given (`https://cube/api/v1`, with or without its
152
+ * trailing slash), as a URL: http or https, ending in a slash, with no
153
+ * query or fragment, so that an address resolved against it stays below it
154
+ * and on its host.
155
+ *
156
+ * @param raw - The API root as given.
157
+ * @returns The root.
158
+ * @throws {Error} When it is not an http or https address; the address itself is never named.
159
+ *
160
+ * @example
161
+ * ```ts
162
+ * new URL('auth-token/', apiRoot_parse('https://cube/api/v1')).href; // 'https://cube/api/v1/auth-token/'
163
+ * apiRoot_parse('https://cube/api/v1?x=1#f').href; // 'https://cube/api/v1/'
164
+ * ```
165
+ */
166
+ export declare function apiRoot_parse(raw: string): URL;
111
167
  /**
112
168
  * Executes a collection+json request against an administrative CUBE child URL.
113
169
  *
@@ -116,7 +172,13 @@ export declare function client_adminUrlEnsure(client: Client): Promise<string |
116
172
  * @param method - Supported HTTP method.
117
173
  * @param data - Optional Collection+JSON template fields for a POST request.
118
174
  * @returns The decoded HTTP response document.
119
- * @throws {Error} When the client has no advertised administrative endpoint.
175
+ * @throws {Error} When the client has no administrative endpoint, the endpoint
176
+ * is outside the API root's origin, CUBE answers with a redirect, or refuses.
177
+ *
178
+ * @example
179
+ * ```ts
180
+ * const created: unknown = await client_adminRequest(client, 'users/', 'post', { username: 'ada', email: 'ada@x', password: 'pw' });
181
+ * ```
120
182
  */
121
183
  export declare function client_adminRequest(client: Client, path: string, method: 'get' | 'post', data?: Record<string, string>): Promise<unknown>;
122
184
  /**
@@ -129,7 +191,8 @@ export type PluginAdminSource = {
129
191
  readonly storeUrl: string;
130
192
  };
131
193
  /**
132
- * Registers one plugin through CUBE's administrative upload.
194
+ * Registers one plugin through CUBE's administrative upload, at the
195
+ * advertised endpoint held to the API root's origin, following no redirect.
133
196
  *
134
197
  * Posted as multipart directly rather than through chrisapi: on a refusal
135
198
  * whose body is not Collection+JSON (Django REST's field errors are plain
@@ -140,12 +203,40 @@ export type PluginAdminSource = {
140
203
  * @param computeNames - Compute resources to register the plugin on.
141
204
  * @param source - The descriptor text (field `fname`) or a store URL (field `plugin_store_url`).
142
205
  * @returns The registered plugin's fields, decoded from the Collection+JSON item.
143
- * @throws {Error} When the client has no administrative endpoint, or CUBE refuses (its reason in the message).
206
+ * @throws {Error} When the client has no administrative endpoint, the endpoint
207
+ * is outside the API root's origin, CUBE answers with a redirect, or CUBE
208
+ * refuses (its reason in the message).
209
+ *
210
+ * @example
211
+ * ```ts
212
+ * const plugin: Record<string, unknown> = await client_adminPluginUpload(client, ['host'], { descriptor: json });
213
+ * ```
144
214
  */
145
215
  export declare function client_adminPluginUpload(client: Client, computeNames: string[], source: PluginAdminSource): Promise<Record<string, unknown>>;
216
+ /**
217
+ * One file to post to CUBE's user files, where, and under what.
218
+ *
219
+ * @example
220
+ * ```ts
221
+ * const upload: UserFileUpload = { url: 'https://cube/api/v1/userfiles/', uploadPath: 'home/ada/x.txt', file, signal };
222
+ * ```
223
+ */
224
+ export interface UserFileUpload {
225
+ /** CUBE's own address for a new user file, built from the client's API root (cumin's `userFilesUrl_build`); null when none could be built. */
226
+ readonly url: string | null;
227
+ /** The file's full CUBE path, without a leading slash. */
228
+ readonly uploadPath: string;
229
+ /** The bytes, under the name they are sent as. */
230
+ readonly file: File;
231
+ /** Abandons the request (and its socket) when aborted; the abort's reason is what the upload rejects with. */
232
+ readonly signal: AbortSignal;
233
+ /** Asked immediately before the post, when given; false posts nothing. */
234
+ readonly stillCurrent?: () => Promise<boolean>;
235
+ }
146
236
  /**
147
237
  * Posts one file to CUBE's user files, the multipart form chrisapi's
148
- * `uploadFile` sends, over fetch.
238
+ * `uploadFile` sends, over fetch, at the address given and no other: no
239
+ * redirect is followed.
149
240
  *
150
241
  * fetch reads a form's file only as the connection takes its bytes, so a
151
242
  * file whose reads are watched (cumin's `upload_watchStalls`) shows the
@@ -153,14 +244,14 @@ export declare function client_adminPluginUpload(client: Client, computeNames: s
153
244
  * it is sent, and holds a fixed 30 s deadline over the whole request.
154
245
  *
155
246
  * @param client - Connected CUBE client whose token authorizes the upload.
156
- * @param uploadPath - The file's full CUBE path, without a leading slash.
157
- * @param file - The bytes, under the name they are sent as.
158
- * @param signal - Abandons the request (and its socket) when aborted; the
159
- * abort's reason is what the returned promise rejects with.
247
+ * @param upload - The address, the path, the bytes, the signal, and the question asked before the post.
248
+ * @param sent - Told once the post has left, when given: CUBE answered, or
249
+ * the request failed after it went out (anything but a failure to connect).
160
250
  * @returns The new file's fields (`id`, `fname`, …), decoded from the Collection+JSON item.
161
- * @throws {Error} When CUBE refuses (its reason in the message), or the signal's reason.
251
+ * @throws {Error} When no address was built, the connection changed, CUBE
252
+ * answers with a redirect or refuses (its reason in the message), or the signal's reason.
162
253
  */
163
- export declare function client_userFileUpload(client: Client, uploadPath: string, file: File, signal: AbortSignal): Promise<Record<string, unknown>>;
254
+ export declare function client_userFileUpload(client: Client, upload: UserFileUpload, sent?: () => void): Promise<Record<string, unknown>>;
164
255
  /**
165
256
  * Decodes the first item of a Collection+JSON document into its fields.
166
257
  *
@@ -185,55 +276,127 @@ export declare function refusalReason_extract(body: string): string;
185
276
  */
186
277
  export declare function resource_isList(resource: unknown): resource is ListResource;
187
278
  /**
188
- * Extracts the `data` payload of a list resource as a typed array.
279
+ * One page of a collection CUBE answered, held as the SDK holds a page it
280
+ * fetched itself, so a walk over the SDK's pages reads it unchanged.
281
+ *
282
+ * @param url - The address the page was asked at.
283
+ * @param client - The client it was asked with.
284
+ * @param collection - The answer's collection+json `collection`.
285
+ * @returns The page.
286
+ *
287
+ * @example
288
+ * ```ts
289
+ * const page: ListResource = listResource_wrap(url, client, { items: [], links: [] });
290
+ * ```
291
+ */
292
+ export declare function listResource_wrap(url: string, client: Client, collection: object): ListResource;
293
+ export { rows_check, shape_build, shape_nullable, shape_object, ShapeError, type Shape, type ShapeField } from './shape.js';
294
+ /**
295
+ * Anything that may carry a `data` payload.
296
+ *
297
+ * @example
298
+ * const logs: DataCarrier = await resource_call(resource, DATA_CARRIER_SHAPE, 'getLogs');
299
+ */
300
+ export interface DataCarrier {
301
+ /** The payload, when there is one; read through a shape of its own. */
302
+ data?: unknown;
303
+ }
304
+ /**
305
+ * A list resource, as far as its items are read.
306
+ *
307
+ * @example
308
+ * const page: ItemsCarrier = await client.getGroups();
309
+ */
310
+ export interface ItemsCarrier {
311
+ /** What is called for the items; looked at before it is called. */
312
+ getItems?: unknown;
313
+ }
314
+ /**
315
+ * Anything that may carry a `data` payload: held only to being an object,
316
+ * its `data` read through `listData_get` or `itemData_get` with a shape of
317
+ * its own.
318
+ */
319
+ export declare const DATA_CARRIER_SHAPE: Shape<DataCarrier>;
320
+ /**
321
+ * Reads the `data` of a list resource as rows of a shape.
322
+ *
323
+ * Absence and malformation are two answers. No `data` at all (or no list)
324
+ * is an empty list. `data` that is there and is not an array, or a row
325
+ * that is not what the shape says is read, is a `ShapeError`: a listing
326
+ * short by rows it does not mention is never returned.
189
327
  *
190
328
  * @param list - A chrisapi list resource (or anything carrying `data`).
191
- * @returns The `data` array as `T[]`, or an empty array when absent.
329
+ * @param shape - The shape of a row.
330
+ * @returns The rows; empty when there is no `data`.
331
+ * @throws {ShapeError} When `data` is present and is not a list of the shape.
192
332
  */
193
333
  export declare function listData_get<T>(list: {
194
334
  data?: unknown;
195
- } | null | undefined): T[];
335
+ } | null | undefined, shape: Shape<T>): T[];
196
336
  /**
197
- * Extracts the `data` payload of an item resource as a typed object.
337
+ * Reads the `data` of an item resource as a shape.
198
338
  *
199
339
  * @param item - A chrisapi item resource (or anything carrying `data`).
200
- * @returns The `data` object as `T`, or null when absent.
340
+ * @param shape - The shape of the data.
341
+ * @returns The data; null when there is none.
342
+ * @throws {ShapeError} When `data` is present and is not what the shape says is read.
201
343
  */
202
344
  export declare function itemData_get<T>(item: {
203
345
  data?: unknown;
204
- } | null | undefined): T | null;
346
+ } | null | undefined, shape: Shape<T>): T | null;
205
347
  /**
206
- * Returns the items of a list resource as a typed array.
348
+ * Reads the items of a list resource as a shape each.
207
349
  *
208
- * @param list - A chrisapi list resource exposing `getItems()`.
209
- * @returns The items as `T[]`, or an empty array when absent.
350
+ * @param list - A chrisapi list resource exposing `getItems()`; null or undefined for none.
351
+ * @param shape - The shape of an item.
352
+ * @returns The items; empty when there is no list, or it has no items.
353
+ * @throws {ShapeError} When the list has no `getItems` to call, what it returns is not a list, or an item is not what the shape says is read.
210
354
  */
211
- export declare function items_get<T>(list: {
212
- getItems(): unknown;
213
- } | null | undefined): T[];
355
+ export declare function items_get<T>(list: ItemsCarrier | null | undefined, shape: Shape<T>): T[];
214
356
  /**
215
- * Returns the collection+json items embedded in a resource as a typed array.
357
+ * Reads the collection+json items embedded in a resource as a shape each.
216
358
  *
217
359
  * @param resource - A chrisapi resource carrying a `collection` document.
218
- * @returns The collection items as `T[]`, or an empty array when absent.
360
+ * @param shape - The shape of an item.
361
+ * @returns The items; empty when there is no collection, or it has no items.
362
+ * @throws {ShapeError} When the collection is present and is not a document, or its items are present and are not a list of the shape.
219
363
  */
220
364
  export declare function collectionItems_get<T>(resource: {
221
365
  collection?: unknown;
222
- } | null | undefined): T[];
366
+ } | null | undefined, shape: Shape<T>): T[];
223
367
  /**
224
- * Invokes a method on a chrisapi object that its typings do not declare.
368
+ * Invokes a method on a chrisapi object that its typings do not declare,
369
+ * and hands back what it answered as it is: unknown.
225
370
  *
226
371
  * Used for client/resource methods that exist at runtime but are missing or
227
372
  * mistyped in `@fnndsc/chrisapi` (e.g. `createWorkflow`,
228
- * `getPipelineSourceFiles`, `_post`, `put` with a `path` body).
373
+ * `getPipelineSourceFiles`, `_post`, `put` with a `path` body). For a call
374
+ * whose answer is not read (a delete, a put), or is read only after checks
375
+ * of the caller's own. A caller that reads the answer as a type uses
376
+ * `resource_call`, which holds it to a shape.
229
377
  *
230
378
  * @param obj - The chrisapi object to dispatch on.
231
379
  * @param methodName - Name of the runtime method to invoke.
232
380
  * @param args - Arguments forwarded to the method.
233
- * @returns The method's resolved value as `T`.
381
+ * @returns The method's resolved value, unchecked and untyped.
234
382
  * @throws {Error} When the named method does not exist on the object.
235
383
  */
236
- export declare function resource_call<T>(obj: object, methodName: string, ...args: unknown[]): Promise<T>;
384
+ export declare function resource_invoke(obj: object, methodName: string, ...args: unknown[]): Promise<unknown>;
385
+ /**
386
+ * Invokes a method on a chrisapi object and holds what it answers to a shape.
387
+ *
388
+ * @param obj - The chrisapi object to dispatch on.
389
+ * @param shape - The shape of the answer.
390
+ * @param methodName - Name of the runtime method to invoke.
391
+ * @param args - Arguments forwarded to the method.
392
+ * @returns The answer, as the shape's type.
393
+ * @throws {Error} When the named method does not exist on the object.
394
+ * @throws {ShapeError} When the answer is not what the shape says is read.
395
+ *
396
+ * @example
397
+ * const logs: DataCarrier = await resource_call(resource, DATA_CARRIER_SHAPE, 'getLogs');
398
+ */
399
+ export declare function resource_call<T>(obj: object, shape: Shape<T>, methodName: string, ...args: unknown[]): Promise<T>;
237
400
  /**
238
401
  * Tests whether a chrisapi object exposes a named runtime method.
239
402
  *
@@ -262,10 +425,66 @@ export declare function pacsRetrieve_deleteByUrl(retrieveUrl: string, auth: Clie
262
425
  * @property data - The file's fields (`fname`, `fsize`, ...).
263
426
  */
264
427
  export interface FileBytesSource {
428
+ /** The file's fields. */
265
429
  data: Record<string, unknown>;
266
- getFileStream(timeout?: number): Promise<unknown>;
267
- getFileBlob(timeout?: number): Promise<unknown>;
430
+ /** The bytes as a stream; the timeout, when given and not 0, is how long CUBE may take to begin. */
431
+ getFileStream(timeout?: number): Promise<FileBytesStream>;
432
+ /** The bytes whole; the timeout, when given and not 0, is how long CUBE may take to begin. */
433
+ getFileBlob(timeout?: number): Promise<ArrayBuffer>;
268
434
  }
435
+ /**
436
+ * A file's bytes as a Node stream, and the size CUBE declared for them when it did.
437
+ *
438
+ * @example
439
+ * ```ts
440
+ * const answer: FileBytesStream = await file.getFileStream(0); // answer.headers['content-length'] === '5'
441
+ * ```
442
+ */
443
+ export interface FileBytesStream {
444
+ /** The bytes; destroying the stream abandons the request. */
445
+ readonly data: unknown;
446
+ /** `content-length`, when CUBE sent it. */
447
+ readonly headers: Record<string, string>;
448
+ }
449
+ /**
450
+ * The files CUBE lists at an address built from the client's API root (a
451
+ * user file, a PACS file, a pipeline's source file), asked through the one
452
+ * guarded request rather than chrisapi's lookups, which ask the collection
453
+ * CUBE's root advertises, wherever it points, following redirects. Each
454
+ * file's bytes are read at its `file_resource` link only once that is held
455
+ * to the root's origin.
456
+ *
457
+ * @param client - The connected client.
458
+ * @param address - The listing, relative to the API root (`userfiles/41/`).
459
+ * @param what - The listing, in an operator's words.
460
+ * @returns The files listed, in order.
461
+ * @throws {CubeStatusError} When CUBE refuses (the status on the error).
462
+ * @throws {Error} When CUBE answers with a redirect, or the client holds no usable API root.
463
+ *
464
+ * @example
465
+ * ```ts
466
+ * const files: FileBytesSource[] = await files_list(client, 'pacs/files/41/', 'the PACS file');
467
+ * ```
468
+ */
469
+ export declare function files_list(client: Client, address: string, what: string): Promise<FileBytesSource[]>;
470
+ /**
471
+ * One file of a collection of CUBE's, by id, through {@link files_list}:
472
+ * the file's own resource (`userfiles/41/`, `pacs/files/41/`), below the
473
+ * API root.
474
+ *
475
+ * @param client - The connected client.
476
+ * @param collection - The collection's path below the API root (`userfiles`, `pacs/files`).
477
+ * @param fileId - The file's id.
478
+ * @returns The file, or null when CUBE answers with some other file.
479
+ * @throws {CubeStatusError} When CUBE refuses (the status on the error).
480
+ * @throws {Error} When CUBE answers with a redirect, or the client holds no usable API root.
481
+ *
482
+ * @example
483
+ * ```ts
484
+ * const file: FileBytesSource | null = await fileById_read(client, 'userfiles', 41);
485
+ * ```
486
+ */
487
+ export declare function fileById_read(client: Client, collection: string, fileId: number): Promise<FileBytesSource | null>;
269
488
  /**
270
489
  * A file through the file browser (`/filebrowser/files/<id>/`), the
271
490
  * resource CUBE serves a feed's files under to everyone the feed is
@@ -273,9 +492,19 @@ export interface FileBytesSource {
273
492
  * but its owner, so a colleague's shared output could be listed and not
274
493
  * downloaded (ekanite, 2026-10-14: file 30916964, 200 here, 403 there).
275
494
  *
495
+ * Every request goes through the one guarded request: the listing's
496
+ * address is built from the API root, and the bytes' address the listing
497
+ * names is held to the root's origin when the bytes are asked for.
498
+ *
276
499
  * @param client - The connected client.
277
500
  * @param fileId - The file's id.
278
501
  * @returns The file, or null when the file browser does not serve it.
279
- * @throws {Error} When CUBE refuses; the caller reads the status from it.
502
+ * @throws {Error} When CUBE refuses (the status on the error), or answers with a redirect.
503
+ *
504
+ * @example
505
+ * ```ts
506
+ * const file = await filebrowserFile_get(client, 41);
507
+ * const bytes = await file?.getFileBlob();
508
+ * ```
280
509
  */
281
510
  export declare function filebrowserFile_get(client: Client, fileId: number): Promise<FileBytesSource | null>;