@fnndsc/salsa 4.5.6 → 4.6.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 (158) hide show
  1. package/README.md +0 -2
  2. package/dist/compute/index.d.ts +0 -9
  3. package/dist/compute/index.js +0 -16
  4. package/dist/compute/index.js.map +1 -1
  5. package/dist/dag/feedData.js +166 -73
  6. package/dist/dag/feedData.js.map +1 -1
  7. package/dist/dag/feedLoad.d.ts +1 -1
  8. package/dist/dag/feedLoad.js +6 -4
  9. package/dist/dag/feedLoad.js.map +1 -1
  10. package/dist/dicom/pixels.js +95 -36
  11. package/dist/dicom/pixels.js.map +1 -1
  12. package/dist/dicom/series.d.ts +4 -1
  13. package/dist/dicom/series.js +80 -31
  14. package/dist/dicom/series.js.map +1 -1
  15. package/dist/dicom/tags.d.ts +28 -0
  16. package/dist/dicom/tags.js +30 -0
  17. package/dist/dicom/tags.js.map +1 -1
  18. package/dist/files/copy.d.ts +197 -0
  19. package/dist/files/copy.js +636 -0
  20. package/dist/files/copy.js.map +1 -0
  21. package/dist/files/copyFolder.d.ts +103 -0
  22. package/dist/files/copyFolder.js +199 -0
  23. package/dist/files/copyFolder.js.map +1 -0
  24. package/dist/files/create.d.ts +178 -0
  25. package/dist/files/create.js +444 -0
  26. package/dist/files/create.js.map +1 -0
  27. package/dist/files/download.d.ts +188 -0
  28. package/dist/files/download.js +541 -0
  29. package/dist/files/download.js.map +1 -0
  30. package/dist/files/index.d.ts +69 -141
  31. package/dist/files/index.js +184 -535
  32. package/dist/files/index.js.map +1 -1
  33. package/dist/files/listing.d.ts +132 -0
  34. package/dist/files/listing.js +179 -0
  35. package/dist/files/listing.js.map +1 -0
  36. package/dist/files/move.d.ts +125 -0
  37. package/dist/files/move.js +334 -0
  38. package/dist/files/move.js.map +1 -0
  39. package/dist/files/pathMapper.d.ts +24 -1
  40. package/dist/files/pathMapper.js +108 -47
  41. package/dist/files/pathMapper.js.map +1 -1
  42. package/dist/files/proof.d.ts +315 -0
  43. package/dist/files/proof.js +574 -0
  44. package/dist/files/proof.js.map +1 -0
  45. package/dist/files/removal.d.ts +223 -0
  46. package/dist/files/removal.js +318 -0
  47. package/dist/files/removal.js.map +1 -0
  48. package/dist/files/replace.d.ts +175 -0
  49. package/dist/files/replace.js +582 -0
  50. package/dist/files/replace.js.map +1 -0
  51. package/dist/files/upload.d.ts +205 -0
  52. package/dist/files/upload.js +478 -0
  53. package/dist/files/upload.js.map +1 -0
  54. package/dist/index.d.ts +14 -2
  55. package/dist/index.js +45 -32
  56. package/dist/index.js.map +1 -1
  57. package/dist/jobs/index.d.ts +1 -1
  58. package/dist/jobs/index.js +2 -2
  59. package/dist/jobs/index.js.map +1 -1
  60. package/dist/jobs/jobOps.d.ts +20 -13
  61. package/dist/jobs/jobOps.js +41 -37
  62. package/dist/jobs/jobOps.js.map +1 -1
  63. package/dist/pacs/anonymise.d.ts +17 -36
  64. package/dist/pacs/anonymise.js +29 -67
  65. package/dist/pacs/anonymise.js.map +1 -1
  66. package/dist/pipelines/index.d.ts +1 -13
  67. package/dist/pipelines/index.js +0 -38
  68. package/dist/pipelines/index.js.map +1 -1
  69. package/dist/pipelines/invocation.js +321 -167
  70. package/dist/pipelines/invocation.js.map +1 -1
  71. package/dist/pipelines/manifest.js.map +1 -1
  72. package/dist/pipelines/packages.d.ts +11 -8
  73. package/dist/pipelines/packages.js +253 -77
  74. package/dist/pipelines/packages.js.map +1 -1
  75. package/dist/plugins/adminToken.d.ts +67 -0
  76. package/dist/plugins/adminToken.js +77 -0
  77. package/dist/plugins/adminToken.js.map +1 -0
  78. package/dist/plugins/index.d.ts +0 -7
  79. package/dist/plugins/index.js +0 -16
  80. package/dist/plugins/index.js.map +1 -1
  81. package/dist/plugins/peer_search.d.ts +0 -15
  82. package/dist/plugins/peer_search.js +0 -25
  83. package/dist/plugins/peer_search.js.map +1 -1
  84. package/dist/plugins/plugin_add.d.ts +14 -2
  85. package/dist/plugins/plugin_add.js +42 -13
  86. package/dist/plugins/plugin_add.js.map +1 -1
  87. package/dist/plugins/plugin_docker.d.ts +25 -0
  88. package/dist/plugins/plugin_docker.js +33 -0
  89. package/dist/plugins/plugin_docker.js.map +1 -1
  90. package/dist/plugins/plugin_register.d.ts +0 -10
  91. package/dist/plugins/plugin_register.js +3 -54
  92. package/dist/plugins/plugin_register.js.map +1 -1
  93. package/dist/plugins/plugin_sync.js +45 -22
  94. package/dist/plugins/plugin_sync.js.map +1 -1
  95. package/dist/plugins/plugin_validate.js +47 -13
  96. package/dist/plugins/plugin_validate.js.map +1 -1
  97. package/dist/plugins/store_import.d.ts +0 -9
  98. package/dist/plugins/store_import.js +3 -29
  99. package/dist/plugins/store_import.js.map +1 -1
  100. package/dist/retrieve/task.d.ts +137 -0
  101. package/dist/retrieve/task.js +41 -0
  102. package/dist/retrieve/task.js.map +1 -0
  103. package/dist/retrieve/watch.d.ts +2 -118
  104. package/dist/retrieve/watch.js +452 -321
  105. package/dist/retrieve/watch.js.map +1 -1
  106. package/dist/vfs/providers/etc.d.ts +6 -4
  107. package/dist/vfs/providers/etc.js +12 -4
  108. package/dist/vfs/providers/etc.js.map +1 -1
  109. package/dist/vfs/providers/native.d.ts +116 -39
  110. package/dist/vfs/providers/native.js +291 -347
  111. package/dist/vfs/providers/native.js.map +1 -1
  112. package/dist/vfs/providers/pacs.d.ts +29 -3
  113. package/dist/vfs/providers/pacs.js +303 -73
  114. package/dist/vfs/providers/pacs.js.map +1 -1
  115. package/dist/vfs/providers/pacs_content.js +22 -6
  116. package/dist/vfs/providers/pacs_content.js.map +1 -1
  117. package/dist/vfs/providers/proc/backfill.d.ts +46 -0
  118. package/dist/vfs/providers/proc/backfill.js +147 -0
  119. package/dist/vfs/providers/proc/backfill.js.map +1 -0
  120. package/dist/vfs/providers/proc/book.d.ts +176 -0
  121. package/dist/vfs/providers/proc/book.js +73 -0
  122. package/dist/vfs/providers/proc/book.js.map +1 -0
  123. package/dist/vfs/providers/proc/catchup.d.ts +69 -0
  124. package/dist/vfs/providers/proc/catchup.js +125 -0
  125. package/dist/vfs/providers/proc/catchup.js.map +1 -0
  126. package/dist/vfs/providers/proc/feedIndex.d.ts +146 -0
  127. package/dist/vfs/providers/proc/feedIndex.js +354 -0
  128. package/dist/vfs/providers/proc/feedIndex.js.map +1 -0
  129. package/dist/vfs/providers/proc/feedTopology.d.ts +85 -0
  130. package/dist/vfs/providers/proc/feedTopology.js +192 -0
  131. package/dist/vfs/providers/proc/feedTopology.js.map +1 -0
  132. package/dist/vfs/providers/proc/locate.d.ts +60 -0
  133. package/dist/vfs/providers/proc/locate.js +103 -0
  134. package/dist/vfs/providers/proc/locate.js.map +1 -0
  135. package/dist/vfs/providers/proc/path.d.ts +50 -0
  136. package/dist/vfs/providers/proc/path.js +106 -0
  137. package/dist/vfs/providers/proc/path.js.map +1 -0
  138. package/dist/vfs/providers/proc/roster.d.ts +95 -0
  139. package/dist/vfs/providers/proc/roster.js +425 -0
  140. package/dist/vfs/providers/proc/roster.js.map +1 -0
  141. package/dist/vfs/providers/proc/rows.d.ts +120 -0
  142. package/dist/vfs/providers/proc/rows.js +181 -0
  143. package/dist/vfs/providers/proc/rows.js.map +1 -0
  144. package/dist/vfs/providers/proc/subtree.d.ts +73 -0
  145. package/dist/vfs/providers/proc/subtree.js +125 -0
  146. package/dist/vfs/providers/proc/subtree.js.map +1 -0
  147. package/dist/vfs/providers/proc/sweep.d.ts +89 -0
  148. package/dist/vfs/providers/proc/sweep.js +297 -0
  149. package/dist/vfs/providers/proc/sweep.js.map +1 -0
  150. package/dist/vfs/providers/proc.d.ts +47 -346
  151. package/dist/vfs/providers/proc.js +349 -1806
  152. package/dist/vfs/providers/proc.js.map +1 -1
  153. package/dist/vfs/providers/share.js +4 -1
  154. package/dist/vfs/providers/share.js.map +1 -1
  155. package/package.json +3 -3
  156. package/dist/pacs/resultDecode.d.ts +0 -13
  157. package/dist/pacs/resultDecode.js +0 -19
  158. package/dist/pacs/resultDecode.js.map +0 -1
@@ -0,0 +1,574 @@
1
+ "use strict";
2
+ /**
3
+ * @file Proof of what holds a CUBE path, and of a folder's emptiness.
4
+ *
5
+ * A listing made for showing keeps the rows it has when part of it fails, and
6
+ * the lookups a writer uses to avoid a collision treat a parent that would
7
+ * not list as holding nothing. Both are right for their purpose and neither
8
+ * is proof. An act that destroys or overwrites (removing a folder taken to be
9
+ * empty, uploading over a place taken to be free, swapping a file into a
10
+ * name) needs proof, and this module is where proof is defined, once.
11
+ *
12
+ * A proof reads every row of the parent's three listings and trusts none it
13
+ * cannot place. A proof an act will be made on is given the client the act
14
+ * is bound to: the parent is then found fresh on that client (never
15
+ * through the session's memo of folder lookups, which may name a folder
16
+ * since replaced at the path), and its three collections are read by that
17
+ * folder's id. A proof made only for showing may use the memo: a row that is not directly inside the parent, one with no
18
+ * name, or one with no usable id fails the whole proof, since any of them
19
+ * could be the entry asked about. A row CUBE lists twice is one holder; one
20
+ * listed twice at two addresses fails the proof.
21
+ *
22
+ * Key components:
23
+ * - PathHolderRecord: one entry holding a path: its kind, CUBE id and address.
24
+ * - PathProof: what a strict lookup proved: `held`, `ambiguous` or `absent` (HeldProof, AmbiguousProof, AbsentProof).
25
+ * - PathAnswer: a proof, or the failure to make one (ProofFailure, a file on the way told apart).
26
+ * - pathHolders_answer / pathHolders_prove: prove what holds a path, or that nothing does (fresh, on a bound client, for an act).
27
+ * - holders_describe: the holders of an ambiguous path, in words.
28
+ * - folderEmptiness_prove: prove whether a proved folder holds nothing, asked of it by its id.
29
+ * - folderHolders_prove: one whole proof of every name a folder holds, for an act that writes many into it.
30
+ * - listingRows_place: one whole listing's rows placed, or nothing proved.
31
+ * - freshListingRows_place: the same, of a folder opened by its id (a copy's source walk).
32
+ * - pathProof_convertToHolderProof: a proof as a mount hands it on.
33
+ *
34
+ * Typical usage:
35
+ * ```ts
36
+ * const proof: Result<PathProof> = await pathHolders_prove('/home/ada/uploads/scan');
37
+ * if (!proof.ok) return refuse(); // could not be proved
38
+ * if (proof.value.kind === 'absent') create(); // nothing is there
39
+ * ```
40
+ *
41
+ * Dependencies: `files_listWhole` of `./index.js`, the strict listing, for
42
+ * the three listings a folder has (dirs, files, links) in a proof for
43
+ * showing; a bound `HolderClient` of cumin's, for a parent found fresh and
44
+ * its listings read by id in a proof for an act, and for a proved folder's
45
+ * own collections; `listedRow_name` of `./listing.js`, the one rule for a
46
+ * row directly inside its folder; and cumin's error stack, where the
47
+ * reason a proof failed is left. Paths are absolute CUBE paths.
48
+ *
49
+ * @module
50
+ */
51
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
52
+ if (k2 === undefined) k2 = k;
53
+ var desc = Object.getOwnPropertyDescriptor(m, k);
54
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
55
+ desc = { enumerable: true, get: function() { return m[k]; } };
56
+ }
57
+ Object.defineProperty(o, k2, desc);
58
+ }) : (function(o, m, k, k2) {
59
+ if (k2 === undefined) k2 = k;
60
+ o[k2] = m[k];
61
+ }));
62
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
63
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
64
+ }) : function(o, v) {
65
+ o["default"] = v;
66
+ });
67
+ var __importStar = (this && this.__importStar) || (function () {
68
+ var ownKeys = function(o) {
69
+ ownKeys = Object.getOwnPropertyNames || function (o) {
70
+ var ar = [];
71
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
72
+ return ar;
73
+ };
74
+ return ownKeys(o);
75
+ };
76
+ return function (mod) {
77
+ if (mod && mod.__esModule) return mod;
78
+ var result = {};
79
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
80
+ __setModuleDefault(result, mod);
81
+ return result;
82
+ };
83
+ })();
84
+ Object.defineProperty(exports, "__esModule", { value: true });
85
+ exports.pathHolders_answer = pathHolders_answer;
86
+ exports.pathHolders_prove = pathHolders_prove;
87
+ exports.listingRows_place = listingRows_place;
88
+ exports.freshListingRows_place = freshListingRows_place;
89
+ exports.folderHolders_prove = folderHolders_prove;
90
+ exports.holders_describe = holders_describe;
91
+ exports.pathProof_convertToHolderProof = pathProof_convertToHolderProof;
92
+ exports.folderEmptiness_prove = folderEmptiness_prove;
93
+ const path = __importStar(require("path"));
94
+ const cumin_1 = require("@fnndsc/cumin");
95
+ const index_js_1 = require("./index.js");
96
+ const listing_js_1 = require("./listing.js");
97
+ /** The three listings a folder has, each with the kind of holder it yields. */
98
+ const HOLDER_KINDS = [['dirs', 'dir'], ['files', 'file'], ['links', 'link']];
99
+ /** A row id written as text: decimal digits and nothing else. */
100
+ const ID_DIGITS = /^[0-9]+$/;
101
+ /** A failed lookup with no name of its own. */
102
+ const UNPROVED = { kind: 'error', notDirectory: false };
103
+ /**
104
+ * The id a listing's row carries, when it is one a delete may be given.
105
+ *
106
+ * An id is acted on, so it has to be exactly the one CUBE sent. A number
107
+ * beyond the range JavaScript holds exactly has already been rounded to a
108
+ * neighbour by the time it is read, and text such as `1e3` or ` 7 ` would
109
+ * coerce to a number nobody wrote.
110
+ *
111
+ * @param row - One row of a listing.
112
+ * @returns A positive whole number within the exact range, or null for
113
+ * anything else: missing, null, zero, negative, fractional, out of range,
114
+ * or text that is not plain digits.
115
+ */
116
+ function rowId_derive(row) {
117
+ const raw = row.id;
118
+ if (typeof raw === 'string' && !ID_DIGITS.test(raw))
119
+ return null;
120
+ if (typeof raw !== 'number' && typeof raw !== 'string')
121
+ return null;
122
+ const id = Number(raw);
123
+ return Number.isSafeInteger(id) && id > 0 ? id : null;
124
+ }
125
+ /**
126
+ * Every row of one listing placed, or none: a row not directly inside the
127
+ * folder, with no name, or with no usable id fails them all (stacked), since
128
+ * any of them could be the entry asked about.
129
+ *
130
+ * A folder row names itself by `path`, a file or link row by `fname`, each
131
+ * as a store path; the row counts only when that path is directly inside
132
+ * the folder (`listedRow_name`). A link's `fname` ends in `.chrislink`,
133
+ * CUBE's mark and no part of its name; a file or folder so named keeps it.
134
+ *
135
+ * @param rows - The listing's rows.
136
+ * @param where - The folder, which listing, and the kind it yields.
137
+ * @returns The rows placed, or null (the reason stacked).
138
+ */
139
+ function rows_place(rows, where) {
140
+ const placedRows = [];
141
+ for (const row of rows) {
142
+ const placedRow = row_place(row, where);
143
+ if (placedRow === null)
144
+ return null;
145
+ placedRows.push(placedRow);
146
+ }
147
+ return placedRows;
148
+ }
149
+ /**
150
+ * Whether a row's name field holds a name at all: text, not empty.
151
+ *
152
+ * @param raw - The field's value.
153
+ * @returns True when it is a non-empty string.
154
+ */
155
+ function rowName_isGiven(raw) {
156
+ return typeof raw === 'string' && raw !== '';
157
+ }
158
+ /**
159
+ * One row of a listing placed ({@link rows_place}): its name directly
160
+ * inside the folder and the holder it is, or the reason it cannot be
161
+ * placed stacked.
162
+ *
163
+ * @param row - The row.
164
+ * @param where - The folder, which listing, and the kind it yields.
165
+ * @returns The row placed, or null (the reason stacked).
166
+ */
167
+ function row_place(row, where) {
168
+ const { clean, parent, asset, kind } = where;
169
+ const raw = kind === 'dir' ? row.path : row.fname;
170
+ const placed = rowName_isGiven(raw) ? (0, listing_js_1.listedRow_name)(parent, raw) : null;
171
+ if (placed === null) {
172
+ const why = rowName_isGiven(raw) ? `names ${JSON.stringify(raw)}, which is not directly inside it` : 'has no name';
173
+ cumin_1.errorStack.stack_push('error', `Cannot check ${clean}: a row among the ${asset} of ${parent} ${why}`);
174
+ return null;
175
+ }
176
+ const entry = kind === 'link' ? placed.replace(/\.chrislink$/, '') : placed;
177
+ const id = rowId_derive(row);
178
+ if (id === null) {
179
+ cumin_1.errorStack.stack_push('error', entry === where.name
180
+ ? `Cannot check ${clean}: the ${kind} of that name in ${parent} has no usable id`
181
+ : `Cannot check ${clean}: a row among the ${asset} of ${parent} has no usable id`);
182
+ return null;
183
+ }
184
+ const href = typeof row.href === 'string' && row.href !== '' ? row.href : null;
185
+ return { name: entry, holder: { kind, id, href } };
186
+ }
187
+ /**
188
+ * The holders of a name among one listing's rows, every row placed first
189
+ * ({@link rows_place}). A link holding the name must carry its address.
190
+ *
191
+ * @param rows - The listing's rows.
192
+ * @param where - The clean target, its parent, its name, and which listing this is.
193
+ * @returns The holders of the name, or null when a row could not be placed (stacked).
194
+ */
195
+ function rows_read(rows, where) {
196
+ const placed = rows_place(rows, where);
197
+ if (placed === null)
198
+ return null;
199
+ const holders = placed.filter((row) => row.name === where.name).map((row) => row.holder);
200
+ if (where.kind === 'link' && holders.some((holder) => holder.href === null)) {
201
+ cumin_1.errorStack.stack_push('error', `Cannot check ${where.clean}: the link of that name in ${where.parent} carries no address to act on it by`);
202
+ return null;
203
+ }
204
+ return holders;
205
+ }
206
+ /**
207
+ * What one listing of the parent came to, read as a proof reads it.
208
+ *
209
+ * @param outcome - The listing.
210
+ * @param asset - Which listing.
211
+ * @param where - The clean target, its parent, its name, and the kind the listing yields.
212
+ * @param mark - The error stack's mark from before the listing, drained when it could not be made.
213
+ * @returns Its holders of the name, that it could not be made, or that it failed.
214
+ */
215
+ function listingOutcome_read(outcome, asset, where, mark) {
216
+ if (outcome.kind === 'refused') {
217
+ cumin_1.errorStack.stack_push('error', `Cannot check ${where.clean}: ${outcome.error.message}`);
218
+ return { kind: 'failed' };
219
+ }
220
+ if (outcome.kind === 'missing') {
221
+ // What the lookup said on the way is settled one level up.
222
+ cumin_1.errorStack.checkpoint_drain(mark);
223
+ return { kind: 'unmade' };
224
+ }
225
+ if (outcome.kind !== 'listing')
226
+ return { kind: 'read', holders: [] };
227
+ if (outcome.data.incomplete !== undefined) {
228
+ cumin_1.errorStack.stack_push('error', `Cannot check ${where.clean}: the ${asset} of ${where.parent} were not all read (${outcome.data.incomplete.reason})`);
229
+ return { kind: 'failed' };
230
+ }
231
+ const holders = rows_read(outcome.data.tableData ?? [], { ...where, asset });
232
+ return holders === null ? { kind: 'failed' } : { kind: 'read', holders };
233
+ }
234
+ /**
235
+ * One listing of a folder found fresh, read whole by its id.
236
+ *
237
+ * @param folder - The folder.
238
+ * @param asset - Which listing.
239
+ * @returns The listing, as the strict listing would answer it.
240
+ */
241
+ async function freshListing_read(folder, asset) {
242
+ try {
243
+ const data = await folder.listing_readWhole(asset);
244
+ if (data.incomplete !== undefined)
245
+ return { kind: 'listing', data };
246
+ return data.tableData.length === 0 ? { kind: 'empty' } : { kind: 'listing', data };
247
+ }
248
+ catch (error) {
249
+ return { kind: 'refused', error: error instanceof Error ? error : new Error(String(error)) };
250
+ }
251
+ }
252
+ /**
253
+ * The parent's three listings, read as a proof reads them: through the
254
+ * strict listing for a proof made for showing, or, for one an act is bound
255
+ * to, of the parent found fresh on that client and read by its id. A
256
+ * listing that fails ends the reading.
257
+ *
258
+ * @param where - The clean target, its parent and its name.
259
+ * @param acts - The client an act is bound to, for a proof an act is made on.
260
+ * @returns What each listing came to, in the order of {@link HOLDER_KINDS}.
261
+ */
262
+ async function parentListings_read(where, acts) {
263
+ let opened = null;
264
+ if (acts !== undefined) {
265
+ opened = await acts.folder_openFresh(where.parent);
266
+ if (opened.kind === 'refused') {
267
+ cumin_1.errorStack.stack_push('error', `Cannot check ${where.clean}: ${opened.reason}`);
268
+ return [{ kind: 'failed' }];
269
+ }
270
+ }
271
+ const reads = [];
272
+ for (const [asset, kind] of HOLDER_KINDS) {
273
+ const mark = cumin_1.errorStack.checkpoint_mark();
274
+ const outcome = opened === null
275
+ ? await (0, index_js_1.files_listWhole)(asset, where.parent, { hrefs: true })
276
+ : opened.kind === 'found' ? await freshListing_read(opened.folder, asset) : { kind: 'missing' };
277
+ const read = listingOutcome_read(outcome, asset, { ...where, kind }, mark);
278
+ reads.push(read);
279
+ if (read.kind === 'failed')
280
+ break;
281
+ }
282
+ return reads;
283
+ }
284
+ /**
285
+ * The distinct holders of one name. Holders are told apart by kind and id:
286
+ * CUBE lists some rows twice, and that is one holder. Two rows of one kind
287
+ * and id with different addresses are not one thing told twice, and prove
288
+ * nothing.
289
+ *
290
+ * @param found - Every holder the listings named for the name.
291
+ * @param clean - The path, for the words.
292
+ * @returns Each distinct holder, in the order first listed; null when one
293
+ * is listed at two addresses (stacked).
294
+ */
295
+ function holders_distinct(found, clean) {
296
+ const distinct = [];
297
+ for (const holder of found) {
298
+ const seen = distinct.find((one) => one.kind === holder.kind && one.id === holder.id);
299
+ if (seen === undefined)
300
+ distinct.push(holder);
301
+ else if (seen.href !== holder.href) {
302
+ cumin_1.errorStack.stack_push('error', `Cannot check ${clean}: CUBE lists the ${holder.kind} of that name (id ${String(holder.id)}) twice, at two addresses`);
303
+ return null;
304
+ }
305
+ }
306
+ return distinct;
307
+ }
308
+ /**
309
+ * Holders as a proof: one, several, or none, told apart as
310
+ * {@link holders_distinct} tells them.
311
+ *
312
+ * @param found - Every holder the listings named.
313
+ * @param clean - The path, for the words.
314
+ * @returns The proof, or the failure (stacked).
315
+ */
316
+ function proof_settle(found, clean) {
317
+ const distinct = holders_distinct(found, clean);
318
+ if (distinct === null)
319
+ return UNPROVED;
320
+ const first = distinct[0];
321
+ if (first === undefined)
322
+ return { kind: 'absent' };
323
+ return distinct.length === 1 ? { kind: 'held', holder: first } : { kind: 'ambiguous', holders: distinct };
324
+ }
325
+ /**
326
+ * Proves what holds a path, or that nothing does, and says which failure it
327
+ * met when it could not.
328
+ *
329
+ * A refused listing of the parent, or one cut short, is a failure, and so is
330
+ * a row the proof cannot place. A listing that could not be made at all
331
+ * proves absence only when the parent is itself proved absent, one level up,
332
+ * and so on to the root: a parent that is there and will not list has
333
+ * proved nothing, and one that a file holds is `notDirectory`.
334
+ *
335
+ * Given the client an act is bound to, every parent on the way is found
336
+ * fresh on it and read by its id; without one, through the strict
337
+ * listing, which may use the session's memo of folder lookups.
338
+ *
339
+ * @param target - The CUBE path; one written without its leading slash is
340
+ * read from the root.
341
+ * @param acts - The client an act on the proof is bound to; omitted for a
342
+ * proof made only for showing.
343
+ * @returns The proof, or the failure (its reason on the error stack).
344
+ *
345
+ * @example
346
+ * ```ts
347
+ * const answer: PathAnswer = await pathHolders_answer('/home/ada/report.txt/x', acts);
348
+ * const notDirectory: boolean = answer.kind === 'error' && answer.notDirectory;
349
+ * ```
350
+ */
351
+ async function pathHolders_answer(target, acts) {
352
+ // One spelling for the walk up: a path written without its leading slash
353
+ // would otherwise climb from `.` to `.` and never reach the root.
354
+ const clean = path.posix.resolve('/', target);
355
+ if (clean === '/')
356
+ return { kind: 'held', holder: { kind: 'dir', id: 0, href: null } };
357
+ const parent = path.posix.dirname(clean);
358
+ const where = { clean, parent, name: path.posix.basename(clean) };
359
+ const found = [];
360
+ let unmade = false;
361
+ for (const read of await parentListings_read(where, acts)) {
362
+ if (read.kind === 'failed')
363
+ return UNPROVED;
364
+ if (read.kind === 'unmade')
365
+ unmade = true;
366
+ else
367
+ found.push(...read.holders);
368
+ }
369
+ if (!unmade)
370
+ return proof_settle(found, clean);
371
+ const above = await pathHolders_answer(parent, acts);
372
+ if (above.kind === 'error')
373
+ return above;
374
+ if (above.kind === 'absent' && found.length === 0)
375
+ return { kind: 'absent', folderAbsent: true };
376
+ if (above.kind === 'held' && above.holder.kind === 'file') {
377
+ cumin_1.errorStack.stack_push('error', `Cannot check ${clean}: a file holds ${parent}, where a folder is needed`);
378
+ return { kind: 'error', notDirectory: true };
379
+ }
380
+ cumin_1.errorStack.stack_push('error', `Cannot check ${clean}: ${parent} is there and could not be listed`);
381
+ return UNPROVED;
382
+ }
383
+ /**
384
+ * Proves what holds a path, or that nothing does ({@link pathHolders_answer},
385
+ * its failures as one).
386
+ *
387
+ * @param target - The CUBE path; one written without its leading slash is
388
+ * read from the root.
389
+ * @param acts - The client an act on the proof is bound to; omitted for a
390
+ * proof made only for showing.
391
+ * @returns What holds it, or that nothing does; Err when neither could be
392
+ * proved, with the reason on the error stack.
393
+ *
394
+ * @example
395
+ * ```ts
396
+ * const proof: Result<PathProof> = await pathHolders_prove('/home/ada/uploads/scan', acts);
397
+ * const free: boolean = proof.ok && proof.value.kind === 'absent';
398
+ * ```
399
+ */
400
+ async function pathHolders_prove(target, acts) {
401
+ const answer = await pathHolders_answer(target, acts);
402
+ return answer.kind === 'error' ? (0, cumin_1.Err)() : (0, cumin_1.Ok)(answer);
403
+ }
404
+ /**
405
+ * Every row of one whole listing of a folder, placed: the listing must have
406
+ * answered, in full, for a folder that is there. A refused listing, one
407
+ * that could not be made, one cut short, or a row that cannot be placed
408
+ * fails it (the reason stacked).
409
+ *
410
+ * @param outcome - The listing, as the strict listing answers it.
411
+ * @param asset - Which listing.
412
+ * @param folder - The folder listed.
413
+ * @returns The rows placed; Err when the listing proves nothing.
414
+ *
415
+ * @example
416
+ * ```ts
417
+ * const files: Result<readonly PlacedRow[]> = listingRows_place(await files_listWhole('files', '/home/ada'), 'files', '/home/ada');
418
+ * ```
419
+ */
420
+ function listingRows_place(outcome, asset, folder) {
421
+ if (outcome.kind === 'refused') {
422
+ cumin_1.errorStack.stack_push('error', `Cannot read ${folder} whole: its ${asset}: ${outcome.error.message}`);
423
+ return (0, cumin_1.Err)();
424
+ }
425
+ if (outcome.kind === 'missing') {
426
+ cumin_1.errorStack.stack_push('error', `Cannot read ${folder} whole: no folder of CUBE's is there to list`);
427
+ return (0, cumin_1.Err)();
428
+ }
429
+ if (outcome.kind === 'empty')
430
+ return (0, cumin_1.Ok)([]);
431
+ if (outcome.data.incomplete !== undefined) {
432
+ cumin_1.errorStack.stack_push('error', `Cannot read ${folder} whole: its ${asset} were not all read (${outcome.data.incomplete.reason})`);
433
+ return (0, cumin_1.Err)();
434
+ }
435
+ const kind = HOLDER_KINDS.find(([one]) => one === asset)?.[1] ?? 'file';
436
+ const placed = rows_place(outcome.data.tableData ?? [], { clean: folder, parent: folder, asset, kind });
437
+ return placed === null ? (0, cumin_1.Err)() : (0, cumin_1.Ok)(placed);
438
+ }
439
+ /**
440
+ * Every row of one listing of a folder known by its id, read whole on the
441
+ * client that folder was opened on, and placed directly inside its path.
442
+ *
443
+ * @param folder - The folder, opened by its id.
444
+ * @param asset - Which listing.
445
+ * @param folderPath - The folder's path, which every row must be directly inside.
446
+ * @returns The rows placed; Err when the listing proves nothing (the reason stacked).
447
+ *
448
+ * @example
449
+ * ```ts
450
+ * const files: Result<readonly PlacedRow[]> = await freshListingRows_place(acts.folder_openById(70), 'files', '/home/ada/src/sub');
451
+ * ```
452
+ */
453
+ async function freshListingRows_place(folder, asset, folderPath) {
454
+ return listingRows_place(await freshListing_read(folder, asset), asset, folderPath);
455
+ }
456
+ /**
457
+ * What every name in a folder is held by: one whole proof of the folder,
458
+ * for an act that writes many names into it (a copy's children). The folder
459
+ * is found fresh on the act's client, never through the memo of lookups,
460
+ * and its three listings are read whole by its id; a folder that is not
461
+ * there, a listing refused or cut short, or a row that cannot be placed
462
+ * proves nothing. A name's holders are told apart as a path's proof tells
463
+ * them ({@link holders_distinct}): a row listed twice is one holder, and
464
+ * one listed at two addresses proves nothing.
465
+ *
466
+ * @param acts - The client the act is bound to.
467
+ * @param folder - The folder's absolute CUBE path.
468
+ * @returns Each name held, with its holders (a name absent is free); Err
469
+ * when the folder could not be proved whole (the reason stacked).
470
+ *
471
+ * @example
472
+ * ```ts
473
+ * const held: Result<FolderHolders> = await folderHolders_prove(acts, '/home/ada/copy');
474
+ * const free: boolean = held.ok && !held.value.has('scan.dcm');
475
+ * ```
476
+ */
477
+ async function folderHolders_prove(acts, folder) {
478
+ const opened = await acts.folder_openFresh(folder);
479
+ if (opened.kind !== 'found') {
480
+ cumin_1.errorStack.stack_push('error', `Cannot read ${folder} whole: ${opened.kind === 'refused' ? opened.reason : "no folder of CUBE's is there"}`);
481
+ return (0, cumin_1.Err)();
482
+ }
483
+ const listed = new Map();
484
+ for (const [asset] of HOLDER_KINDS) {
485
+ const placed = listingRows_place(await freshListing_read(opened.folder, asset), asset, folder);
486
+ if (!placed.ok)
487
+ return (0, cumin_1.Err)();
488
+ for (const row of placed.value)
489
+ listed.set(row.name, [...(listed.get(row.name) ?? []), row.holder]);
490
+ }
491
+ const held = new Map();
492
+ for (const [name, holders] of listed) {
493
+ const distinct = holders_distinct(holders, path.posix.join(folder, name));
494
+ if (distinct === null)
495
+ return (0, cumin_1.Err)();
496
+ held.set(name, distinct);
497
+ }
498
+ return (0, cumin_1.Ok)(held);
499
+ }
500
+ /**
501
+ * A holder's kind in an operator's word.
502
+ *
503
+ * @param kind - The kind.
504
+ * @returns `folder`, `file` or `link`.
505
+ */
506
+ function holderKind_word(kind) {
507
+ return kind === 'dir' ? 'folder' : kind;
508
+ }
509
+ /**
510
+ * The holders of an ambiguous path, in an operator's words.
511
+ *
512
+ * @param holders - The holders.
513
+ * @returns `a folder and a file`, `two links`, and the like.
514
+ *
515
+ * @example
516
+ * ```ts
517
+ * holders_describe([{ kind: 'dir', id: 1, href: null }, { kind: 'file', id: 2, href: null }]); // 'a folder and a file'
518
+ * ```
519
+ */
520
+ function holders_describe(holders) {
521
+ const kinds = new Set(holders.map((holder) => holder.kind));
522
+ const only = [...kinds][0];
523
+ if (kinds.size === 1 && only !== undefined)
524
+ return `${String(holders.length)} ${holderKind_word(only)}s`;
525
+ return [...kinds].map((kind) => `a ${holderKind_word(kind)}`).join(' and ');
526
+ }
527
+ /**
528
+ * A proof as a mount hands it on: the holders' kinds, without their ids.
529
+ *
530
+ * @param proof - The proof.
531
+ * @returns The same proof, in fond's words.
532
+ *
533
+ * @example
534
+ * ```ts
535
+ * pathProof_convertToHolderProof({ kind: 'held', holder: { kind: 'dir', id: 7, href: null } }); // { kind: 'held', holder: 'dir' }
536
+ * ```
537
+ */
538
+ function pathProof_convertToHolderProof(proof) {
539
+ if (proof.kind === 'absent')
540
+ return { kind: 'absent' };
541
+ if (proof.kind === 'held')
542
+ return { kind: 'held', holder: proof.holder.kind };
543
+ return { kind: 'ambiguous', holders: proof.holders.map((holder) => holder.kind) };
544
+ }
545
+ /**
546
+ * Proves whether a proved folder holds nothing, asked of the folder itself:
547
+ * its own three collections, by its id, on the client the proof was made
548
+ * with. A path is never listed for it: whatever a path names now may be
549
+ * another folder than the one proved.
550
+ *
551
+ * Every one of the folder's three collections must answer, in full: one
552
+ * refused, one with no count, or one cut short leaves the question open,
553
+ * and an open question is not "empty".
554
+ *
555
+ * @param acts - The client the folder was proved with.
556
+ * @param folder - The folder, as its proof named it.
557
+ * @returns True when all three answered in full and hold nothing, false
558
+ * when any holds a row; Err when the question stays open, with the
559
+ * reason on the error stack.
560
+ *
561
+ * @example
562
+ * ```ts
563
+ * const empty: Result<boolean> = await folderEmptiness_prove(acts, { kind: 'dir', id: 7, href: null });
564
+ * const removable: boolean = empty.ok && empty.value;
565
+ * ```
566
+ */
567
+ async function folderEmptiness_prove(acts, folder) {
568
+ if (folder.kind !== 'dir' || folder.id === 0) {
569
+ cumin_1.errorStack.stack_push('error', `Cannot tell whether ${folder.kind} ID ${String(folder.id)} is an empty folder: only a folder of CUBE's own is asked`);
570
+ return (0, cumin_1.Err)();
571
+ }
572
+ return acts.folder_isEmptyById(folder.id);
573
+ }
574
+ //# sourceMappingURL=proof.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proof.js","sourceRoot":"","sources":["../../src/files/proof.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmcH,gDAwBC;AAmBD,8CAGC;AAkBD,8CAiBC;AAgBD,wDAEC;AAuBD,kDAmBC;AAuBD,4CAKC;AAaD,wEAIC;AAwBD,sDAMC;AAzpBD,2CAA6B;AAE7B,yCAAqJ;AAGrJ,yCAAmF;AACnF,6CAA8C;AA6J9C,+EAA+E;AAC/E,MAAM,YAAY,GAAqE,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAE/I,iEAAiE;AACjE,MAAM,SAAS,GAAW,UAAU,CAAC;AAErC,+CAA+C;AAC/C,MAAM,QAAQ,GAAiB,EAAE,IAAI,EAA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