@fnndsc/cumin 3.30.5 → 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 +7 -8
  84. package/dist/index.js +18 -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 +150 -0
  115. package/dist/io/transferPool.js +196 -0
  116. package/dist/io/transferPool.js.map +1 -0
  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 +15 -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
@@ -0,0 +1,557 @@
1
+ "use strict";
2
+ /**
3
+ * @file Acting on one thing CUBE holds at a path, by how it was proved, never by finding it again.
4
+ *
5
+ * A destructive act is decided on a whole listing of the parent, and the row
6
+ * that listing gave is the thing acted on, by its id, at CUBE's own address
7
+ * for that id (`./holderRequest.js`): a folder at `filebrowser/<id>/`, a
8
+ * file at `userfiles/<id>/`, a link at `filebrowser/linkfiles/<id>/`, each
9
+ * below the API root the client was made with. No address a listing or a
10
+ * search gave is asked, a row whose address names anything else is refused
11
+ * unasked, and no request follows a redirect. Nothing here lists a parent,
12
+ * and nothing looks an id up in the last page of a collection.
13
+ *
14
+ * Whether an act is done is asked the same way, of the thing itself: its
15
+ * own address answering 404. A search is never the evidence, since CUBE
16
+ * filters what it finds by who may see it. A replacement at the same name
17
+ * is a different thing, and is left alone. Whether a folder is empty is
18
+ * asked of its own three collections, by its id, never of a path.
19
+ *
20
+ * An answer about an item is one item, of that id, at a usable path, or it
21
+ * is no answer. A request that changes anything and gets no reply has been
22
+ * asked and is not known: a delete says so (`unanswered`), and a move asks
23
+ * where the item is before it says anything. A 502, 503 or 504 to such a
24
+ * request leaves its outcome unknown, just as no reply does, and nothing is
25
+ * asked again; the words then say what CUBE answered.
26
+ *
27
+ * All of it is done on one client (`HolderClient`, `./holderClient.js`):
28
+ * the one the proof was made with, which is asked to be still the
29
+ * session's immediately before each request that changes anything.
30
+ *
31
+ * Key components:
32
+ * - ActGuard: the row's address, and the question asked before a change.
33
+ * - folder_deleteById, folder_pathById, folder_moveById, folder_isEmptyById: a folder, by id.
34
+ * - link_deleteById: a link, at CUBE's address for its id.
35
+ * - file_deleteById, file_locate, file_moveById: a file, by id.
36
+ * - holder_isGone: whether the thing a delete was asked of is gone.
37
+ * - DeleteAnswer: what a delete came to: accepted, unanswered, or (a folder) absent.
38
+ *
39
+ * Typical usage:
40
+ * ```ts
41
+ * const asked: Result<DeleteAnswer> = await folder_deleteById(client, 7, { current_is: async () => true });
42
+ * ```
43
+ *
44
+ * Dependencies: `./holderRequest.js` (CUBE's addresses and one request
45
+ * there) and cumin's error stack, where a failure's reason is left.
46
+ *
47
+ * @module
48
+ */
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.itemUrl_build = exports.itemStatus_probe = exports.itemHref_refusal = exports.itemHref_matches = void 0;
51
+ exports.folder_deleteById = folder_deleteById;
52
+ exports.folder_pathById = folder_pathById;
53
+ exports.folder_moveById = folder_moveById;
54
+ exports.link_deleteById = link_deleteById;
55
+ exports.file_deleteById = file_deleteById;
56
+ exports.file_locate = file_locate;
57
+ exports.file_moveById = file_moveById;
58
+ exports.holder_isGone = holder_isGone;
59
+ exports.folder_isEmptyById = folder_isEmptyById;
60
+ const holderRequest_js_1 = require("./holderRequest.js");
61
+ const errorStack_js_1 = require("../error/errorStack.js");
62
+ const result_js_1 = require("../utils/result.js");
63
+ var holderRequest_js_2 = require("./holderRequest.js");
64
+ Object.defineProperty(exports, "itemHref_matches", { enumerable: true, get: function () { return holderRequest_js_2.itemHref_matches; } });
65
+ Object.defineProperty(exports, "itemHref_refusal", { enumerable: true, get: function () { return holderRequest_js_2.itemHref_refusal; } });
66
+ Object.defineProperty(exports, "itemStatus_probe", { enumerable: true, get: function () { return holderRequest_js_2.itemStatus_probe; } });
67
+ Object.defineProperty(exports, "itemUrl_build", { enumerable: true, get: function () { return holderRequest_js_2.itemUrl_build; } });
68
+ /** The status CUBE answers for a resource that is not there. */
69
+ const HTTP_NOT_FOUND = 404;
70
+ /** The status CUBE answers for a resource that is there. */
71
+ const HTTP_OK = 200;
72
+ /** The status CUBE answers a request it read and refused for what it carried. */
73
+ const HTTP_BAD_REQUEST = 400;
74
+ /**
75
+ * The statuses a gateway in front of CUBE, or CUBE itself, answers when the
76
+ * request's own outcome did not come back (502, 503, 504). A change asked
77
+ * of CUBE and answered so may have been done: it is followed as no reply
78
+ * is, never taken for a refusal, and said as the status it was.
79
+ */
80
+ const GATEWAY_SILENCES = new Set([502, 503, 504]);
81
+ /**
82
+ * Whether an answer is CUBE accepting what was asked.
83
+ *
84
+ * @param answer - The answer, or none.
85
+ * @returns True for a 2xx.
86
+ */
87
+ function answer_accepts(answer) {
88
+ return answer !== null && answer.status >= 200 && answer.status < 300;
89
+ }
90
+ /**
91
+ * Whether an answer to a change leaves what was done unknown: none came,
92
+ * or a 502, 503 or 504 did.
93
+ *
94
+ * @param answer - The answer, or none.
95
+ * @returns True when the change may or may not have been made.
96
+ */
97
+ function answer_isUnknown(answer) {
98
+ return answer === null || GATEWAY_SILENCES.has(answer.status);
99
+ }
100
+ /**
101
+ * What CUBE answered, in words.
102
+ *
103
+ * @param answer - The answer, or none.
104
+ * @returns `CUBE answered 403: …`, or that it could not be asked.
105
+ */
106
+ function answer_say(answer) {
107
+ if (answer === null)
108
+ return "CUBE could not be asked, or did not answer in time";
109
+ const words = (0, holderRequest_js_1.refusalWords_read)(answer.body);
110
+ return words === "" ? `CUBE answered ${String(answer.status)}` : `CUBE answered ${String(answer.status)}: ${words}`;
111
+ }
112
+ /**
113
+ * A store path with a leading slash, as a proof spells it: every step a
114
+ * name, none empty, `.` or `..`.
115
+ *
116
+ * @param raw - The path as CUBE sent it.
117
+ * @returns The path, or null when CUBE sent none usable.
118
+ */
119
+ function storePath_spell(raw) {
120
+ if (typeof raw !== "string" || raw === "")
121
+ return null;
122
+ const spelled = raw.startsWith("/") ? raw : `/${raw}`;
123
+ const steps = spelled.slice(1).split("/");
124
+ return steps.every((step) => step !== "" && step !== "." && step !== "..") ? spelled : null;
125
+ }
126
+ /**
127
+ * What a delete's answer comes to.
128
+ *
129
+ * @param asked - The request, as {@link act_request} answered it.
130
+ * @param failed - The words a refusal opens with.
131
+ * @param notFound - What a 404 is: null for `absent`, else the refusal's words (the generic ones when not given).
132
+ * @returns The delete's answer; Err for a definite refusal, or when nothing was asked (the reason stacked).
133
+ */
134
+ function delete_settle(asked, failed, notFound) {
135
+ if (!asked.ok)
136
+ return (0, result_js_1.Err)();
137
+ const answer = asked.value;
138
+ if (answer === null || answer_isUnknown(answer))
139
+ return (0, result_js_1.Ok)("unanswered");
140
+ if (answer_accepts(answer))
141
+ return (0, result_js_1.Ok)("accepted");
142
+ const missing = answer.status === HTTP_NOT_FOUND;
143
+ if (missing && notFound === null)
144
+ return (0, result_js_1.Ok)("absent");
145
+ errorStack_js_1.errorStack.stack_push("error", missing && typeof notFound === "string" ? notFound : `${failed}: ${answer_say(answer)}`);
146
+ return (0, result_js_1.Err)();
147
+ }
148
+ /**
149
+ * One request that changes an item, asked only when the item's row named
150
+ * CUBE's own address for it and, immediately before, the client is still
151
+ * the session's.
152
+ *
153
+ * @param client - The client.
154
+ * @param holder - The item.
155
+ * @param act - The act, for the words (`delete`, `move`).
156
+ * @param guard - The row's address and the question before the request.
157
+ * @param asked - The method, and a PUT's fields.
158
+ * @returns What CUBE answered (null when no answer came; a 502, 503 or 504
159
+ * is returned as it came, and leaves what was done unknown,
160
+ * {@link answer_isUnknown}); Err when nothing was asked (the reason stacked).
161
+ */
162
+ async function act_request(client, holder, act, guard, asked) {
163
+ const refusal = (0, holderRequest_js_1.itemHref_refusal)(client, holder, act);
164
+ const url = (0, holderRequest_js_1.itemUrl_build)(client, holder.kind, holder.id);
165
+ if (refusal !== null || url === null) {
166
+ errorStack_js_1.errorStack.stack_push("error", refusal ?? `Did not ${act} item ID ${String(holder.id)}: nothing was asked`);
167
+ return (0, result_js_1.Err)();
168
+ }
169
+ if (guard.current_is !== undefined && !await guard.current_is()) {
170
+ errorStack_js_1.errorStack.stack_push("error", `Did not ${act} ${holder.kind === "dir" ? "folder" : holder.kind} ID ${String(holder.id)}: the connection to CUBE changed after it was proved; nothing was asked`);
171
+ return (0, result_js_1.Err)();
172
+ }
173
+ return (0, result_js_1.Ok)(await (0, holderRequest_js_1.cube_ask)(client, url, asked.method, asked.template === undefined ? {} : { template: asked.template }));
174
+ }
175
+ /**
176
+ * Asks CUBE to delete a folder, named by its id. CUBE accepts the request
177
+ * (202) and removes the folder after; whether it is gone is a later
178
+ * question ({@link holder_isGone}).
179
+ *
180
+ * @param client - The connected client.
181
+ * @param id - The folder's id.
182
+ * @param guard - Its row's address, and the question asked before the request.
183
+ * @returns `accepted`, `unanswered` (asked, no reply), or `absent` (CUBE has
184
+ * no folder of that id); Err when CUBE refused or nothing was asked (the
185
+ * reason stacked).
186
+ *
187
+ * @example
188
+ * ```ts
189
+ * const asked: Result<DeleteAnswer> = await folder_deleteById(client, 7);
190
+ * ```
191
+ */
192
+ async function folder_deleteById(client, id, guard = {}) {
193
+ const asked = await act_request(client, { kind: "dir", id, href: guard.href ?? null }, "delete", guard, { method: "DELETE" });
194
+ return delete_settle(asked, `Failed to delete folder ID ${String(id)}`, null);
195
+ }
196
+ /**
197
+ * Where an item is now, asked at its own address: the path field its
198
+ * answer names, for an answer that is one item, its id that id as a
199
+ * number, its path usable. Any other answer names no place.
200
+ *
201
+ * @param client - The connected client.
202
+ * @param kind - A folder (its `path`) or a file (its `fname`).
203
+ * @param id - Its id.
204
+ * @returns The answer, and the path it names.
205
+ */
206
+ async function itemPlace_ask(client, kind, id) {
207
+ const url = (0, holderRequest_js_1.itemUrl_build)(client, kind, id);
208
+ const answer = url === null ? null : await (0, holderRequest_js_1.cube_ask)(client, url, "GET");
209
+ const fields = answer?.status === HTTP_OK ? (0, holderRequest_js_1.answerItem_read)(answer.body) : null;
210
+ if (fields === null || fields.id !== id)
211
+ return { answer, at: null };
212
+ return { answer, at: storePath_spell(kind === "dir" ? fields.path : fields.fname) };
213
+ }
214
+ /**
215
+ * Where a folder, named by its id, is now, asked at its own address.
216
+ *
217
+ * @param client - The connected client.
218
+ * @param id - The folder's id.
219
+ * @returns Its path with a leading slash; null when no folder has the id;
220
+ * Err when CUBE could not be asked or named no path (the reason stacked).
221
+ *
222
+ * @example
223
+ * ```ts
224
+ * const at: Result<string | null> = await folder_pathById(client, 7);
225
+ * ```
226
+ */
227
+ async function folder_pathById(client, id) {
228
+ const place = await itemPlace_ask(client, "dir", id);
229
+ if (place.answer?.status === HTTP_NOT_FOUND)
230
+ return (0, result_js_1.Ok)(null);
231
+ if (place.at !== null)
232
+ return (0, result_js_1.Ok)(place.at);
233
+ errorStack_js_1.errorStack.stack_push("error", place.answer?.status === HTTP_OK ? `Could not learn where folder ID ${String(id)} is: CUBE's answer is not that one folder at a usable path` : `Could not learn where folder ID ${String(id)} is: ${answer_say(place.answer)}`);
234
+ return (0, result_js_1.Err)();
235
+ }
236
+ /**
237
+ * Moves (renames) a folder, named by its id, from the path it was proved
238
+ * at: the folder the id names now is asked where it is, and moved only
239
+ * when that is still the proved path.
240
+ *
241
+ * @param client - The connected client.
242
+ * @param id - The folder's id.
243
+ * @param places - The path it was proved at, and its new path.
244
+ * @param guard - Its row's address, and the question asked before the request.
245
+ * @returns Ok(true) when CUBE accepted the move (or gave no reply, and the
246
+ * folder is then seen at the new path), Ok(false) when no folder has that
247
+ * id (nothing was asked), Err when it is no longer at the proved path,
248
+ * CUBE refused, or a move with no reply is not seen done (what was found
249
+ * stacked).
250
+ *
251
+ * @example
252
+ * ```ts
253
+ * const moved: Result<boolean> = await folder_moveById(client, 7, { from: '/home/ada/old', to: '/home/ada/archive' });
254
+ * ```
255
+ */
256
+ async function folder_moveById(client, id, places, guard = {}) {
257
+ const at = await folder_pathById(client, id);
258
+ if (!at.ok)
259
+ return (0, result_js_1.Err)();
260
+ if (at.value === null)
261
+ return (0, result_js_1.Ok)(false);
262
+ if (at.value !== places.from) {
263
+ errorStack_js_1.errorStack.stack_push("error", `Did not move folder ID ${String(id)}: it was proved at ${places.from}, and CUBE says it is at ${at.value}`);
264
+ return (0, result_js_1.Err)();
265
+ }
266
+ const asked = await act_request(client, { kind: "dir", id, href: guard.href ?? null }, "move", guard, { method: "PUT", template: { path: places.to } });
267
+ if (!asked.ok)
268
+ return (0, result_js_1.Err)();
269
+ if (answer_isUnknown(asked.value))
270
+ return moveUnanswered_settle(client, "dir", id, places.to, asked.value);
271
+ if (answer_accepts(asked.value))
272
+ return (0, result_js_1.Ok)(true);
273
+ errorStack_js_1.errorStack.stack_push("error", `Failed to move folder ID ${String(id)} to ${places.to}: ${answer_say(asked.value)}`);
274
+ return (0, result_js_1.Err)();
275
+ }
276
+ /**
277
+ * Asks CUBE to delete a link file, at CUBE's own address for its id. A row
278
+ * whose `href` names any other address is refused, and nothing is asked.
279
+ *
280
+ * @param client - The connected client.
281
+ * @param id - The link's id.
282
+ * @param guard - Its row's address (checked, never asked), and the question asked before the request.
283
+ * @returns `accepted`, or `unanswered` (asked, no reply); Err when CUBE
284
+ * refused or nothing was asked (the reason stacked).
285
+ *
286
+ * @example
287
+ * ```ts
288
+ * const asked: Result<DeleteAnswer> = await link_deleteById(client, 5, { href: 'https://cube/api/v1/filebrowser/linkfiles/5/' });
289
+ * ```
290
+ */
291
+ async function link_deleteById(client, id, guard = {}) {
292
+ const asked = await act_request(client, { kind: "link", id, href: guard.href ?? null }, "delete", guard, { method: "DELETE" });
293
+ return delete_settle(asked, `Failed to delete link ID ${String(id)}`);
294
+ }
295
+ /**
296
+ * Deletes one file by its id, at CUBE's own address for it, without
297
+ * listing anything.
298
+ *
299
+ * @param client - The connected client.
300
+ * @param id - The file's id.
301
+ * @param guard - Its row's address, and the question asked before the request.
302
+ * @returns `accepted`, or `unanswered` (asked, no reply); Err when no file
303
+ * has the id, CUBE refused, or nothing was asked (the reason stacked).
304
+ *
305
+ * @example
306
+ * ```ts
307
+ * const asked: Result<DeleteAnswer> = await file_deleteById(client, 41);
308
+ * ```
309
+ */
310
+ async function file_deleteById(client, id, guard = {}) {
311
+ const asked = await act_request(client, { kind: "file", id, href: guard.href ?? null }, "delete", guard, { method: "DELETE" });
312
+ return delete_settle(asked, `Failed to delete file ID ${String(id)}`, `File not found with ID ${String(id)}`);
313
+ }
314
+ /**
315
+ * Where a file is now, asked of CUBE at the file's own address.
316
+ *
317
+ * @param client - The connected client.
318
+ * @param id - The file's id.
319
+ * @returns The file's path with a leading slash; null when CUBE says the
320
+ * file is not there (404); Err when CUBE could not be asked or would not
321
+ * say, which is neither (the reason stacked).
322
+ *
323
+ * @example
324
+ * ```ts
325
+ * const where: Result<string | null> = await file_locate(client, 41);
326
+ * ```
327
+ */
328
+ async function file_locate(client, id) {
329
+ const place = await itemPlace_ask(client, "file", id);
330
+ if (place.answer?.status === HTTP_NOT_FOUND)
331
+ return (0, result_js_1.Ok)(null);
332
+ if (place.at !== null)
333
+ return (0, result_js_1.Ok)(place.at);
334
+ const status = place.answer?.status;
335
+ const why = status === HTTP_OK ? ": CUBE's answer is not that one file at a usable path" : status === undefined ? "" : ` (HTTP ${String(status)})`;
336
+ errorStack_js_1.errorStack.stack_push("error", `Could not learn where file ID ${String(id)} is${why}`);
337
+ return (0, result_js_1.Err)();
338
+ }
339
+ /** The rename field current CUBEs read. */
340
+ const CURRENT_RENAME_FIELD = "upload_path";
341
+ /** The older rename field, which a CUBE that wants it names as missing. */
342
+ const LEGACY_RENAME_FIELD = "path";
343
+ /**
344
+ * What a CUBE that reads the older field says when a rename did not carry
345
+ * it. CUBE's serializers raise this, under `non_field_errors`, when an
346
+ * update names neither `public` nor the rename field they read: "At least
347
+ * one of the fields 'public' or 'path' must be provided."
348
+ */
349
+ const LEGACY_FIELD_MISSING = /At least one of the fields 'public' or 'path' must be provided/;
350
+ /**
351
+ * What CUBE's serializers say of a field they require and did not get: the
352
+ * whole message, since CUBE writes path names into its other refusals and
353
+ * a folder may be called `required`.
354
+ */
355
+ const FIELD_REQUIRED = "This field is required.";
356
+ /**
357
+ * The messages a refusal carries under one key.
358
+ *
359
+ * @param said - What the refusal says.
360
+ * @param key - The key.
361
+ * @returns Its messages as text; none when the key is absent.
362
+ */
363
+ function refusalMessages_read(said, key) {
364
+ const under = Reflect.get(said, key);
365
+ if (under === undefined || under === null)
366
+ return [];
367
+ return (Array.isArray(under) ? under : [under]).map((one) => String(one));
368
+ }
369
+ /**
370
+ * Whether a rename was refused because CUBE does not read the field it was
371
+ * spelt with.
372
+ *
373
+ * Only then is the other spelling worth a request: CUBE read this one and
374
+ * did nothing with it. Two answers are that evidence and nothing else is:
375
+ * CUBE's own sentence that neither `public` nor `path` was provided, or
376
+ * the field `path` reported as required. A 400 about the value of either
377
+ * field (a name that is not valid, a destination that is held) is CUBE
378
+ * knowing the field and refusing the move; it would refuse it again.
379
+ *
380
+ * @param answer - What CUBE answered the first request, or none.
381
+ * @returns True for an HTTP 400 that says the older field was not sent.
382
+ */
383
+ function fieldRefusal_detect(answer) {
384
+ if (answer?.status !== HTTP_BAD_REQUEST)
385
+ return false;
386
+ const said = (0, holderRequest_js_1.answerRefusal_read)(answer.body);
387
+ if (typeof said === "string")
388
+ return LEGACY_FIELD_MISSING.test(said);
389
+ if (said === null || typeof said !== "object")
390
+ return false;
391
+ if (refusalMessages_read(said, "non_field_errors").some((one) => LEGACY_FIELD_MISSING.test(one)))
392
+ return true;
393
+ return refusalMessages_read(said, LEGACY_RENAME_FIELD).some((one) => one.trim() === FIELD_REQUIRED);
394
+ }
395
+ /**
396
+ * Moves (renames) a file by its id, at CUBE's own address for it.
397
+ *
398
+ * The rename field drifted across CUBE versions: newer servers take
399
+ * `upload_path`, older ones `path` (chrisapi types neither). The current
400
+ * name is tried first. The older one is tried only when CUBE answered the
401
+ * first request and refused it as a field it does not read: a request whose
402
+ * reply was lost may have moved the file, and one refused for another
403
+ * reason will be refused again, so a second write then would be a move
404
+ * nobody checked. A request with no reply is asked where the file is, and
405
+ * that is the answer. Before the second request the caller's recheck is
406
+ * asked, and then, immediately before it, the guard's question.
407
+ *
408
+ * @param client - The connected client.
409
+ * @param id - The file's id.
410
+ * @param destPath - The target path including filename.
411
+ * @param recheck - Asked before the second spelling is tried, when given:
412
+ * whether the move may still be made. False stops the move.
413
+ * @param guard - Its row's address, and the question asked before each request.
414
+ * @returns Ok(true) when CUBE accepted the move, or gave no reply and the
415
+ * file is then seen at `destPath`; Err otherwise, which does not say the
416
+ * file stayed where it was.
417
+ *
418
+ * @example
419
+ * ```ts
420
+ * const moved: Result<boolean> = await file_moveById(client, 41, '/home/ada/b.txt');
421
+ * ```
422
+ */
423
+ async function file_moveById(client, id, destPath, recheck, guard = {}) {
424
+ const holder = { kind: "file", id, href: guard.href ?? null };
425
+ const first = await act_request(client, holder, "move", guard, { method: "PUT", template: { [CURRENT_RENAME_FIELD]: destPath } });
426
+ if (!first.ok)
427
+ return (0, result_js_1.Err)();
428
+ let last = first.value;
429
+ if (fieldRefusal_detect(first.value)) {
430
+ if (recheck !== undefined && !await recheck()) {
431
+ errorStack_js_1.errorStack.stack_push("error", `Did not move file ID ${String(id)} to ${destPath}: the place could not be shown free a second time`);
432
+ return (0, result_js_1.Err)();
433
+ }
434
+ const second = await act_request(client, holder, "move", guard, { method: "PUT", template: { [LEGACY_RENAME_FIELD]: destPath } });
435
+ if (!second.ok)
436
+ return (0, result_js_1.Err)();
437
+ last = second.value;
438
+ }
439
+ if (answer_isUnknown(last))
440
+ return moveUnanswered_settle(client, "file", id, destPath, last);
441
+ if (answer_accepts(last))
442
+ return (0, result_js_1.Ok)(true);
443
+ errorStack_js_1.errorStack.stack_push("error", `Failed to move file ID ${String(id)} to ${destPath}: ${answer_say(last)}`);
444
+ return (0, result_js_1.Err)();
445
+ }
446
+ /**
447
+ * A move that was asked and got no reply, or a 502, 503 or 504: it may have
448
+ * happened, so the item is asked where it is, and that is the answer.
449
+ *
450
+ * @param client - The connected client.
451
+ * @param kind - A folder or a file.
452
+ * @param id - Its id.
453
+ * @param to - Where it was to go.
454
+ * @param answer - What CUBE answered the move, when anything came.
455
+ * @returns Ok(true) when it is seen there; Err otherwise, naming what CUBE answered and what was found.
456
+ */
457
+ async function moveUnanswered_settle(client, kind, id, to, answer) {
458
+ const word = kind === "dir" ? "folder" : "file";
459
+ const at = kind === "dir" ? await folder_pathById(client, id) : await file_locate(client, id);
460
+ if (at.ok && at.value === to)
461
+ return (0, result_js_1.Ok)(true);
462
+ const found = !at.ok ? "where it is now could not be learned" : at.value === null ? `CUBE has no ${word} of that id now` : `CUBE says it is at ${at.value}`;
463
+ const said = answer === null ? "CUBE gave no reply" : `CUBE answered ${String(answer.status)}`;
464
+ errorStack_js_1.errorStack.stack_push("error", `The move of ${word} ID ${String(id)} to ${to} was asked and ${said}: ${found}`);
465
+ return (0, result_js_1.Err)();
466
+ }
467
+ /**
468
+ * What an item's status says of it.
469
+ *
470
+ * @param status - The status.
471
+ * @returns Ok(true) on 404, Ok(false) on 200, Err on anything else.
472
+ */
473
+ function status_settle(status) {
474
+ if (status === HTTP_NOT_FOUND)
475
+ return (0, result_js_1.Ok)(true);
476
+ return status === HTTP_OK ? (0, result_js_1.Ok)(false) : (0, result_js_1.Err)();
477
+ }
478
+ /**
479
+ * Whether the thing a delete was asked of is gone, asked of that thing
480
+ * alone: CUBE's own address for its id answering 404 is gone, 200 is
481
+ * there. A refusal, any other status, or no answer says neither; a search
482
+ * is never asked, since CUBE filters what it finds by who may see it. A
483
+ * thing whose row's address is not CUBE's is not asked.
484
+ *
485
+ * @param client - The connected client.
486
+ * @param holder - The thing deleted, as its proof named it.
487
+ * @param signal - Ends the question early, when given.
488
+ * @returns Ok(true) when it is gone, Ok(false) when it is still there, Err
489
+ * when CUBE gave no answer that says either (nothing is stacked: a caller
490
+ * that asks again decides what an unanswered question comes to).
491
+ *
492
+ * @example
493
+ * ```ts
494
+ * const gone: Result<boolean> = await holder_isGone(client, { kind: 'file', id: 41, href: null });
495
+ * ```
496
+ */
497
+ async function holder_isGone(client, holder, signal) {
498
+ if (holder.href !== null && !(0, holderRequest_js_1.itemHref_matches)(client, holder.kind, holder.id, holder.href))
499
+ return (0, result_js_1.Err)();
500
+ return status_settle(await (0, holderRequest_js_1.itemStatus_probe)(client, holder.kind, holder.id, signal));
501
+ }
502
+ /** A folder's three collections, each in an operator's word. */
503
+ const FOLDER_LISTS = [["children", "folders"], ["files", "files"], ["linkfiles", "links"]];
504
+ /**
505
+ * Why a folder's collection could not be read: an answer that was fine but
506
+ * not a list, or what CUBE answered (or that it did not).
507
+ *
508
+ * @param answer - CUBE's answer to the ask, or null when none came.
509
+ * @returns The reason, in words.
510
+ */
511
+ function folderListUnread_say(answer) {
512
+ return answer?.status === HTTP_OK ? "the answer is not a list" : answer_say(answer);
513
+ }
514
+ /**
515
+ * The count CUBE gave for a folder's collection, in words.
516
+ *
517
+ * @param total - The count, or null when CUBE gave none.
518
+ * @returns The count, or "nothing".
519
+ */
520
+ function folderListCount_say(total) {
521
+ return total === null ? "nothing" : String(total);
522
+ }
523
+ /**
524
+ * Whether a folder, named by its id, holds nothing: each of its own three
525
+ * collections, asked at its own address, must answer whole. A row in any
526
+ * is not empty; no rows with a count of zero and no next page is empty;
527
+ * anything else (a refusal, no answer, no count, a count above the rows)
528
+ * leaves the question open.
529
+ *
530
+ * @param client - The connected client.
531
+ * @param id - The folder's id.
532
+ * @returns Ok(true) empty, Ok(false) not; Err when the question stays open (the reason stacked).
533
+ *
534
+ * @example
535
+ * ```ts
536
+ * const empty: Result<boolean> = await folder_isEmptyById(client, 7);
537
+ * ```
538
+ */
539
+ async function folder_isEmptyById(client, id) {
540
+ for (const [list, word] of FOLDER_LISTS) {
541
+ const url = (0, holderRequest_js_1.folderListUrl_build)(client, id, list);
542
+ const answer = url === null ? null : await (0, holderRequest_js_1.cube_ask)(client, url, "GET");
543
+ const page = answer?.status === HTTP_OK ? (0, holderRequest_js_1.answerList_read)(answer.body) : null;
544
+ if (page === null) {
545
+ errorStack_js_1.errorStack.stack_push("error", `Cannot tell whether folder ID ${String(id)} is empty: its ${word} could not be read (${folderListUnread_say(answer)})`);
546
+ return (0, result_js_1.Err)();
547
+ }
548
+ if (page.items.length > 0)
549
+ return (0, result_js_1.Ok)(false);
550
+ if (page.more || page.total !== 0) {
551
+ errorStack_js_1.errorStack.stack_push("error", `Cannot tell whether folder ID ${String(id)} is empty: its ${word} were not all read (CUBE counts ${folderListCount_say(page.total)} and sent 0)`);
552
+ return (0, result_js_1.Err)();
553
+ }
554
+ }
555
+ return (0, result_js_1.Ok)(true);
556
+ }
557
+ //# sourceMappingURL=holderIO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"holderIO.js","sourceRoot":"","sources":["../../src/io/holderIO.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;;;AAmNH,8CAGC;AAyCD,0CAMC;AAsBD,0CAcC;AAiBD,0CAGC;AAiBD,0CAGC;AAgBD,kCAQC;AAuFD,sCAkBC;AAqDD,sCAGC;AA0CD,gDAgBC;AAlkBD,yDAe4B;AAE5B,0DAAoD;AACpD,kDAA0D;AAE1D,uDAA2I;AAAlI,oHAAA,gBAAgB,OAAA;AAAE,oHAAA,gBAAgB,OAAA;AAAE,oHAAA,gBAAgB,OAAA;AAAE,iHAAA,aAAa,OAAA;AAE5E,gEAAgE;AAChE,MAAM,cAAc,GAAW,GAAG,CAAC;AAEnC,4DAA4D;AAC5D,MAAM,OAAO,GAAW,GAAG,CAAC;AAE5B,iFAAiF;AACjF,MAAM,gBAAgB,GAAW,GAAG,CAAC;AAErC;;;;;GAKG;AACH,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAiDvE;;;;;GAKG;AACH,SAAS,cAAc,CAAC,MAAyB;IAC/C,OAAO,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC;AACxE,CAAC;AAED;;;;;;GAMG;AACH,SAAS,gBAAgB,CAAC,MAAyB;IACjD,OAAO,MAAM,KAAK,IAAI,IAAI,gBAAgB,CAAC,GAAG,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