@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
@@ -0,0 +1,414 @@
1
+ "use strict";
2
+ /**
3
+ * @file Which identity a piece of work was begun under, and whether it is
4
+ * still the one connected.
5
+ *
6
+ * A session has one identity at a time: a user on a CUBE. The caches that
7
+ * hold what that identity sees (listings, folder records, the proc tree,
8
+ * tags, PACS facts, the query index) are emptied when it changes. Emptying
9
+ * is not enough by itself: a lookup begun as the first identity may finish
10
+ * after the second has connected, and would put the first's answer into the
11
+ * second's cache. So the identity is numbered (an epoch, raised at each
12
+ * change), work is begun in a scope that remembers the epoch it began
13
+ * under, and a cache takes a fill only from a scope whose epoch is the
14
+ * current one.
15
+ *
16
+ * A `sudo` scope is not a change of identity: it is one piece of work done
17
+ * with another user's client while the session's identity stands. What it
18
+ * reads is neither taken from the session's caches nor put into them.
19
+ *
20
+ * Key components:
21
+ * - {@link identityEpoch_get}, {@link identityEpoch_raise}: the number, and
22
+ * the one way it moves.
23
+ * - {@link identityScope_run}: begins work under the current epoch.
24
+ * - {@link identityElevated_run}: runs work as another user, with their client.
25
+ * - {@link identityCache_usable}: what a cache asks before a read or a fill.
26
+ * - {@link identityChange_listen}: what a cache does when the identity changes.
27
+ * - {@link identityPartition_make}: a cache that other work sees a spare of.
28
+ * - {@link identityOwned_make}: the same, for bookkeeping that is not a cache.
29
+ * - {@link identityScope_fork}: begins work that goes on beside its beginner.
30
+ *
31
+ * Typical usage:
32
+ * ```typescript
33
+ * identityChange_listen((): void => { cache.clear(); });
34
+ * await identityScope_run(async (): Promise<void> => {
35
+ * const rows = await fetch_rows();
36
+ * if (identityCache_usable()) cache.set(key, rows);
37
+ * });
38
+ * ```
39
+ *
40
+ * Dependencies: `node:async_hooks` only. It imports nothing of cumin, so
41
+ * every cache and the connection can import it. It keeps one store, which
42
+ * the connection's `sudo` scope uses too.
43
+ *
44
+ * @module
45
+ */
46
+ Object.defineProperty(exports, "__esModule", { value: true });
47
+ exports.identityEpoch_get = identityEpoch_get;
48
+ exports.identityScopeEpoch_get = identityScopeEpoch_get;
49
+ exports.identityEpoch_raise = identityEpoch_raise;
50
+ exports.identityName_spell = identityName_spell;
51
+ exports.identityName_get = identityName_get;
52
+ exports.identityChange_listen = identityChange_listen;
53
+ exports.identityScope_run = identityScope_run;
54
+ exports.identityScope_turn = identityScope_turn;
55
+ exports.identityScope_hold = identityScope_hold;
56
+ exports.identityScope_fork = identityScope_fork;
57
+ exports.identityElevated_run = identityElevated_run;
58
+ exports.identityElevatedClient_get = identityElevatedClient_get;
59
+ exports.identityElevated_is = identityElevated_is;
60
+ exports.identityCache_usable = identityCache_usable;
61
+ exports.identityPartition_make = identityPartition_make;
62
+ exports.identityOwned_make = identityOwned_make;
63
+ const node_async_hooks_1 = require("node:async_hooks");
64
+ /** The current epoch. */
65
+ let current = 0;
66
+ /** What is called at each change, with the name of who is connected after it, or null when nobody is. */
67
+ const listeners = new Set();
68
+ /** The name of who is connected now (`user@url`), or null. */
69
+ let named = null;
70
+ /** The scope a piece of work runs in: the one store this module keeps. */
71
+ const scopes = new node_async_hooks_1.AsyncLocalStorage();
72
+ /**
73
+ * The scope the work now running is in.
74
+ *
75
+ * @returns The scope, or undefined for work begun in none.
76
+ */
77
+ function scope_get() {
78
+ return scopes.getStore();
79
+ }
80
+ /**
81
+ * Runs work in a scope.
82
+ *
83
+ * @param scope - The scope.
84
+ * @param work - The work.
85
+ * @returns What the work returns.
86
+ */
87
+ function scope_run(scope, work) {
88
+ const returned = scopes.run(scope, work);
89
+ return returned;
90
+ }
91
+ /**
92
+ * The current epoch.
93
+ *
94
+ * @returns The number of changes of identity so far.
95
+ *
96
+ * @example
97
+ * const began: number = identityEpoch_get();
98
+ */
99
+ function identityEpoch_get() {
100
+ return current;
101
+ }
102
+ /**
103
+ * The epoch the work now running was begun under.
104
+ *
105
+ * @returns Its scope's epoch; the current one for work begun in no scope.
106
+ *
107
+ * @example
108
+ * const entry = { epoch: identityScopeEpoch_get(), value };
109
+ */
110
+ function identityScopeEpoch_get() {
111
+ return scope_get()?.epoch ?? current;
112
+ }
113
+ /**
114
+ * Says that the identity has changed: someone connected, the context was
115
+ * moved to another user or CUBE, or the session logged out. Every listener
116
+ * is called, at once and in turn, with the name of who is connected now.
117
+ * Every piece of work already begun, the one that made the change
118
+ * included, stays under the epoch it began under: a scope is never moved
119
+ * to a later epoch, since work it started before the change shares it.
120
+ * The work that made the change, and whatever began it in turn, are told
121
+ * the new epoch, and the next step each begins (see
122
+ * {@link identityScope_turn}) is the new identity's.
123
+ *
124
+ * @param now - The name of who is connected after the change (`user@url`), or null when nobody is.
125
+ *
126
+ * @example
127
+ * this.authToken = token;
128
+ * identityEpoch_raise('chris@https://cube/api/v1/');
129
+ */
130
+ function identityEpoch_raise(now = null) {
131
+ current += 1;
132
+ named = now;
133
+ for (let scope = scope_get() ?? null; scope !== null; scope = scope.parent)
134
+ scope.handed = current;
135
+ for (const change_tell of [...listeners])
136
+ change_tell(now);
137
+ }
138
+ /**
139
+ * Spells an identity's name the one way it is spelt everywhere: the
140
+ * user exactly as given, the address with its scheme and host in lower
141
+ * case and its path as written. The daemon's berth, the checkpoints and
142
+ * the change of identity all use this spelling, so one user at one CUBE
143
+ * is one name however the address was typed.
144
+ *
145
+ * @param user - The CUBE user name.
146
+ * @param cubeUrl - The CUBE address.
147
+ * @returns `user@address`.
148
+ *
149
+ * @example
150
+ * identityName_spell('chris', 'HTTPS://Cube.Example/api/v1/'); // 'chris@https://cube.example/api/v1/'
151
+ */
152
+ function identityName_spell(user, cubeUrl) {
153
+ const schemeSplit = cubeUrl.indexOf('://');
154
+ if (schemeSplit === -1)
155
+ return `${user}@${cubeUrl}`;
156
+ const rest = cubeUrl.slice(schemeSplit + 3);
157
+ const pathStart = rest.indexOf('/');
158
+ const authority = pathStart === -1 ? rest : rest.slice(0, pathStart);
159
+ const path = pathStart === -1 ? '' : rest.slice(pathStart);
160
+ return `${user}@${cubeUrl.slice(0, schemeSplit).toLowerCase()}://${authority.toLowerCase()}${path}`;
161
+ }
162
+ /**
163
+ * The name of who is connected now.
164
+ *
165
+ * @returns `user@url`, or null when nobody is connected (or nobody has said).
166
+ *
167
+ * @example
168
+ * const identity: string | null = identityName_get();
169
+ */
170
+ function identityName_get() {
171
+ return named;
172
+ }
173
+ /**
174
+ * Registers what to do when the identity changes (a cache empties itself).
175
+ *
176
+ * @param listener - Called at each change, after the epoch has moved, with the name of who is connected now.
177
+ * @returns A function that removes the listener.
178
+ *
179
+ * @example
180
+ * const stop = identityChange_listen((): void => { cache.clear(); });
181
+ */
182
+ function identityChange_listen(listener) {
183
+ listeners.add(listener);
184
+ return () => { listeners.delete(listener); };
185
+ }
186
+ /**
187
+ * Runs a piece of work in a scope, begun under the current epoch.
188
+ * Everything it awaits, and every timer it starts, is in that scope. A
189
+ * command, a request to the daemon, a warm-up and a watcher are each begun
190
+ * this way.
191
+ *
192
+ * Work already in a scope stays in it (a command run by a command is part
193
+ * of the same work): so work begun under an identity since replaced cannot
194
+ * make itself current by starting something. Steps that go in turn are
195
+ * begun with {@link identityScope_turn}.
196
+ *
197
+ * @param work - The work.
198
+ * @returns What the work returns.
199
+ *
200
+ * @example
201
+ * await identityScope_run((): Promise<void> => command_run(line));
202
+ */
203
+ function identityScope_run(work) {
204
+ const scope = scope_get();
205
+ if (scope === undefined)
206
+ return scope_run({ epoch: current, elevatedWith: null, parent: null, key: {}, handed: null }, work);
207
+ return work();
208
+ }
209
+ /**
210
+ * Runs the next step of work that goes in turn: a command of a line, a
211
+ * line of a script.
212
+ *
213
+ * A step is begun as its beginner was, unless a step before it changed
214
+ * who is connected: then it is begun under the identity that step
215
+ * connected, so `connect other; ls` lists as the other. Only a step begun
216
+ * here is handed on to. What a step started and left running, and anything
217
+ * that merely calls {@link identityScope_run} later, stays what it was
218
+ * begun as; and a change made by unrelated work (another line, another
219
+ * surface) is handed to nobody here.
220
+ *
221
+ * @param work - The step.
222
+ * @returns Whatever the step returns.
223
+ *
224
+ * @example
225
+ * await identityScope_turn((): Promise<void> => command_run('connect other'));
226
+ * await identityScope_turn((): Promise<void> => command_run('ls'));
227
+ */
228
+ function identityScope_turn(work) {
229
+ const scope = scope_get();
230
+ if (scope === undefined)
231
+ return scope_run({ epoch: current, elevatedWith: null, parent: null, key: {}, handed: null }, work);
232
+ const epoch = scope.handed ?? scope.epoch;
233
+ return scope_run({ epoch, elevatedWith: scope.elevatedWith, parent: scope, key: epoch === scope.epoch ? scope.key : {}, handed: null }, work);
234
+ }
235
+ /**
236
+ * Takes hold of a place for work that goes on beside its beginner and
237
+ * comes back to itself later: a watch and its timers.
238
+ *
239
+ * The place is begun under the identity current to the caller, as
240
+ * {@link identityScope_fork} begins one, and never as another user: what
241
+ * outlives a `sudo` is not the other user's. Every piece of work run
242
+ * through what is returned runs in that same place, whoever's work calls
243
+ * it.
244
+ *
245
+ * @returns A runner: it runs the work it is given in the held place.
246
+ *
247
+ * @example
248
+ * const within = identityScope_hold();
249
+ * setTimeout((): void => { within((): void => { tick(); }); }, 1000);
250
+ */
251
+ function identityScope_hold() {
252
+ const held = { epoch: scope_get()?.epoch ?? current, elevatedWith: null, parent: null, key: {}, handed: null };
253
+ return (work) => scope_run(held, work);
254
+ }
255
+ /**
256
+ * Runs a piece of work that goes on by itself beside the work that began
257
+ * it (a job left in the background, a watch, a timer's tick): in a scope
258
+ * of its own, under the epoch its beginner is under. It is stale when its
259
+ * beginner is, and it is never handed on to a later identity: if the line
260
+ * that began it goes on to connect as someone else, this is still the
261
+ * first identity's work.
262
+ *
263
+ * @param work - The work.
264
+ * @returns What the work returns.
265
+ *
266
+ * @example
267
+ * void identityScope_fork((): Promise<void> => watch_tick(feedID));
268
+ */
269
+ function identityScope_fork(work) {
270
+ const scope = scope_get();
271
+ return scope_run({ epoch: scope?.epoch ?? current, elevatedWith: scope?.elevatedWith ?? null, parent: null, key: {}, handed: null }, work);
272
+ }
273
+ /**
274
+ * Runs a piece of work as another user (a `sudo`): with their client, for
275
+ * the length of that work and for nothing else. The epoch it runs under is
276
+ * the one it was begun under.
277
+ *
278
+ * @param client - The other user's client.
279
+ * @param work - The work.
280
+ * @returns What the work returns.
281
+ *
282
+ * @example
283
+ * return identityElevated_run(elevatedClient, operation);
284
+ */
285
+ function identityElevated_run(client, work) {
286
+ return scope_run({ epoch: identityScopeEpoch_get(), elevatedWith: client, parent: scope_get() ?? null, key: {}, handed: null }, work);
287
+ }
288
+ /**
289
+ * The client of the other user the work now running is being done as.
290
+ *
291
+ * @returns Their client, or null when the work is the session's own.
292
+ *
293
+ * @example
294
+ * const elevated: object | null = identityElevatedClient_get();
295
+ */
296
+ function identityElevatedClient_get() {
297
+ return scope_get()?.elevatedWith ?? null;
298
+ }
299
+ /**
300
+ * Whether the work now running is done under another user's client.
301
+ *
302
+ * @returns True inside a `sudo` scope.
303
+ *
304
+ * @example
305
+ * if (identityElevated_is()) return null;
306
+ */
307
+ function identityElevated_is() {
308
+ return identityElevatedClient_get() !== null;
309
+ }
310
+ /**
311
+ * Whether the work now running may read from, and fill, the caches of the
312
+ * session's identity: it was begun under the identity that is connected
313
+ * now, and it is not being done as another user.
314
+ *
315
+ * @returns False for work begun before the last change of identity, and
316
+ * for work in a `sudo` scope.
317
+ *
318
+ * @example
319
+ * if (identityCache_usable()) cache.set(key, rows);
320
+ */
321
+ function identityCache_usable() {
322
+ return !identityElevated_is() && identityScopeEpoch_get() === current;
323
+ }
324
+ /**
325
+ * A cache as each piece of work is to see it: the session's own, for work
326
+ * begun under the identity now connected and done as that identity; and
327
+ * for any other work (begun before the identity changed, or done as
328
+ * another user under `sudo`) a spare of its own, empty at first and thrown
329
+ * away with the work. So such work can go on building and reading what it
330
+ * needs (a `sudo ls /proc` builds a tree and lists it) without seeing a
331
+ * thing the session's identity was shown, and without leaving a thing
332
+ * behind for it. Which of the two is used is decided at each call, from
333
+ * the work that makes the call: a reference taken before a change of
334
+ * identity does not go on reaching the session's own after it.
335
+ *
336
+ * @param own - The session's cache.
337
+ * @param spareMake - Makes an empty one for a piece of other work.
338
+ * @returns The cache to hand out: it looks like `own`, and is.
339
+ *
340
+ * @example
341
+ * const shared: ProcCache = identityPartition_make(new ProcCache(), (): ProcCache => new ProcCache());
342
+ */
343
+ function identityPartition_make(own, spareMake) {
344
+ const spares = new WeakMap();
345
+ const recipient_get = () => {
346
+ const scope = scope_get();
347
+ if (scope === undefined || identityCache_usable())
348
+ return own;
349
+ let spare = spares.get(scope.key);
350
+ if (spare === undefined) {
351
+ spare = spareMake();
352
+ spares.set(scope.key, spare);
353
+ }
354
+ return spare;
355
+ };
356
+ return new Proxy(own, {
357
+ // (The trap's name is the language's, written as a key so that it is not read as one of this code's.)
358
+ ['get']: (...trap) => {
359
+ const property = trap[1];
360
+ const recipient = recipient_get();
361
+ const member = Reflect.get(recipient, property, recipient);
362
+ if (typeof member !== 'function')
363
+ return member;
364
+ // A function put on the cache itself (a stand-in a test put in a method's place) is handed out as it is.
365
+ if (Object.prototype.hasOwnProperty.call(recipient, property))
366
+ return member;
367
+ // Decided again when it is called: a method taken now and called after a change is the caller's then.
368
+ return (...given) => {
369
+ const called = recipient_get();
370
+ // The member as it was when taken, unless the call is another piece of work's: then that one's.
371
+ const method = called === recipient ? member : Reflect.get(called, property, called);
372
+ return method.apply(called, given);
373
+ };
374
+ },
375
+ });
376
+ }
377
+ /**
378
+ * State that belongs to one identity, as each piece of work is to see it:
379
+ * a plain object of bookkeeping (what has been visited, what is in flight)
380
+ * that the session's own current work shares, that is made anew at each
381
+ * change of identity, and of which any other work (begun before the
382
+ * change, or done as another user) has a copy of its own. The same rule as
383
+ * {@link identityPartition_make}, for state that is not a cache.
384
+ *
385
+ * @param make - Makes the state, empty.
386
+ * @returns A function that answers the state for the work that calls it.
387
+ *
388
+ * @example
389
+ * const visits_get = identityOwned_make((): Visits => ({ byFeed: new Map(), inflight: new Map() }));
390
+ * visits_get().byFeed.set(feedID, visit);
391
+ */
392
+ function identityOwned_make(make) {
393
+ let own = make();
394
+ let ownEpoch = current;
395
+ const spares = new WeakMap();
396
+ return () => {
397
+ const scope = scope_get();
398
+ if (scope === undefined || identityCache_usable()) {
399
+ // Made anew for each identity, the first time that identity's work asks.
400
+ if (ownEpoch !== current) {
401
+ own = make();
402
+ ownEpoch = current;
403
+ }
404
+ return own;
405
+ }
406
+ let spare = spares.get(scope.key);
407
+ if (spare === undefined) {
408
+ spare = make();
409
+ spares.set(scope.key, spare);
410
+ }
411
+ return spare;
412
+ };
413
+ }
414
+ //# sourceMappingURL=identityEpoch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identityEpoch.js","sourceRoot":"","sources":["../../src/connect/identityEpoch.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;;AA2DH,8CAEC;AAUD,wDAEC;AAmBD,kDAKC;AAgBD,gDAQC;AAUD,4CAEC;AAWD,sDAGC;AAmBD,8CAIC;AAqBD,gDAKC;AAkBD,gDAGC;AAgBD,gDAGC;AAcD,oDAEC;AAUD,gEAEC;AAUD,kDAEC;AAaD,oDAEC;AAqBD,wDA8BC;AAiBD,gDAqBC;AA1XD,uDAAqD;AAgBrD,yBAAyB;AACzB,IAAI,OAAO,GAAW,CAAC,CAAC;AAExB,yGAAyG;AACzG,MAAM,SAAS,GAAsC,IAAI,GAAG,EAAgC,CAAC;AAE7F,8DAA8D;AAC9D,IAAI,KAAK,GAAkB,IAAI,CAAC;AAEhC,0EAA0E;AAC1E,MAAM,MAAM,GAAqC,IAAI,oCAAiB,EAAiB,CAAC;AAExF;;;;GAIG;AACH,SAAS,SAAS;IAChB,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC3B,CAAC;AAED;;;;;;GAMG;AACH,SAAS,SAAS,CAAI,KAAoB,EAAE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AAK,GAAG,IAAI,EAAE,CAAC;YACf,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC"}
@@ -98,36 +98,53 @@ function kind_findByCode(code) {
98
98
  return null;
99
99
  }
100
100
  /**
101
- * Classifies a login error from what it carries: CUBE's status (400 or 401
102
- * on `auth-token/`, 401 or 403 on a token), or a TLS or network code found
103
- * anywhere down its `cause` chain. Nothing found is `other`.
101
+ * Records what one object link of a cause chain says, where the chain has
102
+ * not already said it: an earlier link always wins.
103
+ *
104
+ * @param node - The link.
105
+ * @param facts - What the links before it found; filled in place.
106
+ */
107
+ function causeNode_read(node, facts) {
108
+ const found = node.response?.status ?? node.status;
109
+ if (facts.status === undefined && typeof found === 'number')
110
+ facts.status = found;
111
+ if (facts.code === undefined && typeof node.code === 'string' && kind_findByCode(node.code) !== null)
112
+ facts.code = node.code;
113
+ if (facts.message === undefined && typeof node.message === 'string' && !GENERIC_MESSAGES.has(node.message))
114
+ facts.message = node.message;
115
+ }
116
+ /**
117
+ * Walks an error's `cause` chain, six links at most, stopping at the first
118
+ * link that is not an object (a string there is taken as the message).
104
119
  *
105
120
  * @param error - What the login threw.
106
- * @returns The failure.
121
+ * @returns The first status, code and message found.
107
122
  */
108
- function loginFailure_classify(error) {
109
- let status;
110
- let code;
111
- let message;
123
+ function causeChain_read(error) {
124
+ const facts = {};
112
125
  let at = error;
113
126
  for (let depth = 0; depth < 6 && at !== null && at !== undefined; depth++) {
114
- if (typeof at === 'object') {
115
- const node = at;
116
- const found = node.response?.status ?? node.status;
117
- if (status === undefined && typeof found === 'number')
118
- status = found;
119
- if (code === undefined && typeof node.code === 'string' && kind_findByCode(node.code) !== null)
120
- code = node.code;
121
- if (message === undefined && typeof node.message === 'string' && !GENERIC_MESSAGES.has(node.message))
122
- message = node.message;
123
- at = node.cause;
124
- }
125
- else {
126
- if (message === undefined && typeof at === 'string')
127
- message = at;
127
+ if (typeof at !== 'object') {
128
+ if (facts.message === undefined && typeof at === 'string')
129
+ facts.message = at;
128
130
  break;
129
131
  }
132
+ const node = at;
133
+ causeNode_read(node, facts);
134
+ at = node.cause;
130
135
  }
136
+ return facts;
137
+ }
138
+ /**
139
+ * Classifies a login error from what it carries: CUBE's status (400 or 401
140
+ * on `auth-token/`, 401 or 403 on a token), or a TLS or network code found
141
+ * anywhere down its `cause` chain. Nothing found is `other`.
142
+ *
143
+ * @param error - What the login threw.
144
+ * @returns The failure.
145
+ */
146
+ function loginFailure_classify(error) {
147
+ const { status, code, message } = causeChain_read(error);
131
148
  const said = message ?? (error instanceof Error ? error.message : String(error));
132
149
  if (status !== undefined && [400, 401, 403].includes(status))
133
150
  return { kind: 'credentials', status, message: said };
@@ -1 +1 @@
1
- {"version":3,"file":"loginFailure.js","sourceRoot":"","sources":["../../src/connect/loginFailure.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFA,sDAsBC;AAUD,8BAcC;AAWD,sDAMC;AAoBD,gDAqBC;AA7LD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,gDAAkC;AAClC,kDAAoC;AAgBpC,8EAA8E;AAC9E,MAAM,SAAS,GAAwB,IAAI,GAAG,CAAC;IAC7C,2BAA2B;IAC3B,6BAA6B;IAC7B,iCAAiC;IACjC,2BAA2B;IAC3B,mCAAmC;IACnC,kBAAkB;IAClB,oBAAoB;IACpB,gBAAgB;IAChB,cAAc;IACd,wBAAwB;IACxB,8BAA8B;CAC/B,CAAC,CAAC;AAEH,6DAA6D;AAC7D,MAAM,aAAa,GAAwB,IAAI,GAAG,CAAC;IACjD,WAAW;IACX,WAAW;IACX,cAAc;IACd,YAAY;IACZ,WAAW;IACX,cAAc;IACd,aAAa;IACb,yBAAyB;IACzB,gBAAgB;CACjB,CAAC,CAAC;AAEH,iEAAiE;AACjE,MAAM,gBAAgB,GAAwB,IAAI,GA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EAAE,CAAC;QACrB,KAAK,KAAK;YACR,OAAO;gBACL,uBAAuB,GAAG,4BAA4B,aAAa,CAAC,GAAG,CAAC,oBAAoB,OAAO,CAAC,IAAI,IAAI;gBAC5G,kEAAkE;gBAClE,uCAAuC;aACxC,CAAC;QACJ,KAAK,SAAS;YACZ,OAAO;gBACL,mBAAmB,GAAG,KAAK,OAAO,CAAC,IAAI,IAAI;gBAC3C,qEAAqE;aACtE,CAAC;QACJ,KAAK,aAAa;YAChB,OAAO;gBACL,GAAG,GAAG,4BAA4B,OAAO,CAAC,MAAM,2CAA2C;gBAC3F,oFAAoF;aACrF,CAAC;QACJ,KAAK,OAAO;YACV,OAAO,CAAC,uBAAuB,GAAG,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC"}
@@ -89,26 +89,44 @@ async function chrisContextURL_parse(url) {
89
89
  result.URL = urlMatch[1];
90
90
  }
91
91
  const queryString = url.split("?")[1];
92
- if (queryString) {
93
- const queryParams = new URLSearchParams(queryString);
94
- result.folder = queryParams.get("folder");
95
- result.feed = queryParams.get("feed");
96
- // Handle 'plugin' matches with an "includes" vs "equals"
97
- for (const [key, value] of queryParams.entries()) {
98
- if (key.includes("plugin")) {
99
- if (value.includes(":")) {
100
- result.plugin = await searchable_resolveID(value);
101
- }
102
- else {
103
- result.plugin = value;
104
- }
105
- break; // Stop after finding the first match
106
- }
92
+ // Note: token is not present in the URL, so it remains null
93
+ if (!queryString)
94
+ return result;
95
+ const queryParams = new URLSearchParams(queryString);
96
+ result.folder = queryParams.get("folder");
97
+ result.feed = queryParams.get("feed");
98
+ // Handle 'plugin' matches with an "includes" vs "equals"
99
+ for (const [key, value] of queryParams.entries()) {
100
+ if (!key.includes("plugin"))
101
+ continue;
102
+ if (value.includes(":")) {
103
+ result.plugin = await searchable_resolveID(value);
104
+ }
105
+ else {
106
+ result.plugin = value;
107
107
  }
108
- // Note: token is not present in the URL, so it remains null
108
+ break; // Stop after finding the first match
109
109
  }
110
110
  return result;
111
111
  }
112
+ /**
113
+ * The names of the directories directly under a directory, in the order
114
+ * storage lists them.
115
+ *
116
+ * @param storage - The storage to ask.
117
+ * @param dir - The directory.
118
+ * @returns The subdirectories' names.
119
+ */
120
+ async function subdirectories_list(storage, dir) {
121
+ const files = await storage.readdir(dir);
122
+ const subdirectories = [];
123
+ for (const file of files) {
124
+ if (await storage.isDirectory(path.join(dir, file))) {
125
+ subdirectories.push(file);
126
+ }
127
+ }
128
+ return subdirectories;
129
+ }
112
130
  /**
113
131
  * Helper to get plugin ID from a searchable string.
114
132
  *
@@ -166,13 +184,7 @@ class ChrisContext {
166
184
  if (!(await storage.exists(configDir))) {
167
185
  return;
168
186
  }
169
- const files = await storage.readdir(configDir);
170
- const users = [];
171
- for (const file of files) {
172
- if (await storage.isDirectory(path.join(configDir, file))) {
173
- users.push(file);
174
- }
175
- }
187
+ const users = await subdirectories_list(storage, configDir);
176
188
  this.fullContext.currentUser = await config_js_1.sessionConfig.connection.lastUser_load();
177
189
  const currentURL = await config_js_1.sessionConfig.connection.chrisURL_load();
178
190
  this.fullContext.currentURL = currentURL;
@@ -185,13 +197,7 @@ class ChrisContext {
185
197
  }
186
198
  if (!(await storage.exists(userDir)))
187
199
  continue;
188
- const userFiles = await storage.readdir(userDir);
189
- const urlDirs = [];
190
- for (const file of userFiles) {
191
- if (await storage.isDirectory(path.join(userDir, file))) {
192
- urlDirs.push(file);
193
- }
194
- }
200
+ const urlDirs = await subdirectories_list(storage, userDir);
195
201
  for (const urlDir of urlDirs) {
196
202
  let url = config_js_1.sessionConfig.connection.dir_convertToUri(urlDir);
197
203
  this.fullContext.users[user].urls[url] = {