@fnndsc/salsa 4.5.3 → 4.5.5
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.
- package/dist/files/fileLookup.d.ts +15 -1
- package/dist/files/fileLookup.js +95 -15
- package/dist/files/fileLookup.js.map +1 -1
- package/dist/files/pathMapper.d.ts +237 -0
- package/dist/files/pathMapper.js +503 -0
- package/dist/files/pathMapper.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import { Result } from '@fnndsc/cumin';
|
|
2
|
+
/**
|
|
3
|
+
* Runs work in which each folder's file ids are listed once: a transfer of
|
|
4
|
+
* many files. A scope inside a scope shares the outer one.
|
|
5
|
+
*
|
|
6
|
+
* @param operation - The work.
|
|
7
|
+
* @returns What the work returns.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const ids: number[] = await fileIds_memoRun(async () => resolveAll(paths));
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function fileIds_memoRun<T>(operation: () => Promise<T>): Promise<T>;
|
|
2
15
|
/**
|
|
3
16
|
* Resolves an absolute ChRIS file path to its numeric file id.
|
|
4
17
|
*
|
|
5
18
|
* Lists the parent directory and matches on basename, tolerating the `? <name>`
|
|
6
|
-
* placeholder form the API sometimes returns.
|
|
19
|
+
* placeholder form the API sometimes returns. Inside {@link fileIds_memoRun}
|
|
20
|
+
* the listing is the transfer's, made once per folder.
|
|
7
21
|
*
|
|
8
22
|
* @param filePath - Absolute ChRIS file path.
|
|
9
23
|
* @returns Ok(fileId), or Err (with a message pushed to errorStack) on failure.
|
package/dist/files/fileLookup.js
CHANGED
|
@@ -33,20 +33,106 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.fileIds_memoRun = fileIds_memoRun;
|
|
36
37
|
exports.pathFileId_resolve = pathFileId_resolve;
|
|
37
38
|
/**
|
|
38
39
|
* @file Resolve an absolute ChRIS file path to its numeric file id.
|
|
39
40
|
*
|
|
41
|
+
* CUBE reads a file by id, and the id comes from listing the file's folder.
|
|
42
|
+
* One file read lists its folder once; a transfer of a whole folder would
|
|
43
|
+
* list that folder again for every file in it (223 files, 223 listings of
|
|
44
|
+
* 223 rows). A transfer runs inside {@link fileIds_memoRun}, where each
|
|
45
|
+
* folder is listed once and every file in it, in flight together or one
|
|
46
|
+
* after another, takes its id from that listing. Outside a transfer nothing
|
|
47
|
+
* is kept, so a read after an edit always lists afresh.
|
|
48
|
+
*
|
|
49
|
+
* Key components:
|
|
50
|
+
* - pathFileId_resolve: a file path's id.
|
|
51
|
+
* - fileIds_memoRun: runs work in which each folder's ids are listed once.
|
|
52
|
+
*
|
|
53
|
+
* Typical usage:
|
|
54
|
+
* ```ts
|
|
55
|
+
* await fileIds_memoRun(async () => {
|
|
56
|
+
* for (const path of paths) await pathFileId_resolve(path);
|
|
57
|
+
* });
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* Dependencies: cumin's file browser groups.
|
|
61
|
+
*
|
|
40
62
|
* @module
|
|
41
63
|
*/
|
|
64
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
42
65
|
const path = __importStar(require("path"));
|
|
43
66
|
const cumin_1 = require("@fnndsc/cumin");
|
|
44
67
|
const index_js_1 = require("./index.js");
|
|
68
|
+
/** The memo of the transfer running on this async path, when one is. */
|
|
69
|
+
const memoScope = new node_async_hooks_1.AsyncLocalStorage();
|
|
70
|
+
/**
|
|
71
|
+
* Runs work in which each folder's file ids are listed once: a transfer of
|
|
72
|
+
* many files. A scope inside a scope shares the outer one.
|
|
73
|
+
*
|
|
74
|
+
* @param operation - The work.
|
|
75
|
+
* @returns What the work returns.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* const ids: number[] = await fileIds_memoRun(async () => resolveAll(paths));
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
async function fileIds_memoRun(operation) {
|
|
83
|
+
if (memoScope.getStore() !== undefined)
|
|
84
|
+
return operation();
|
|
85
|
+
return memoScope.run(new Map(), operation);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Lists one folder's files by basename.
|
|
89
|
+
*
|
|
90
|
+
* @param dir - The folder.
|
|
91
|
+
* @returns The ids by basename (null for a row with no id), or why it could not be listed.
|
|
92
|
+
*/
|
|
93
|
+
async function folderIds_list(dir) {
|
|
94
|
+
const group = await (0, index_js_1.files_getGroup)('files', dir);
|
|
95
|
+
if (!group)
|
|
96
|
+
return { refused: '' };
|
|
97
|
+
const results = await group.asset.resources_getAll();
|
|
98
|
+
if (!results || !results.tableData)
|
|
99
|
+
return { refused: `No files found in directory: ${dir}` };
|
|
100
|
+
const ids = new Map();
|
|
101
|
+
for (const row of results.tableData) {
|
|
102
|
+
const basename = path.posix.basename(row.fname || '');
|
|
103
|
+
const name = basename.startsWith('? ') ? basename.slice(2) : basename;
|
|
104
|
+
if (!ids.has(name))
|
|
105
|
+
ids.set(name, typeof row.id === 'number' ? row.id : null);
|
|
106
|
+
}
|
|
107
|
+
return { ids };
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* One folder's ids: from the transfer's memo when one runs, else listed now.
|
|
111
|
+
* A folder that could not be listed is not kept, so a retry lists again.
|
|
112
|
+
*
|
|
113
|
+
* @param dir - The folder.
|
|
114
|
+
* @returns Its ids, or why it could not be listed.
|
|
115
|
+
*/
|
|
116
|
+
async function folderIds_get(dir) {
|
|
117
|
+
const memo = memoScope.getStore();
|
|
118
|
+
if (memo === undefined)
|
|
119
|
+
return folderIds_list(dir);
|
|
120
|
+
const kept = memo.get(dir);
|
|
121
|
+
if (kept !== undefined)
|
|
122
|
+
return kept;
|
|
123
|
+
const listing = folderIds_list(dir);
|
|
124
|
+
memo.set(dir, listing);
|
|
125
|
+
const answer = await listing;
|
|
126
|
+
if ('refused' in answer)
|
|
127
|
+
memo.delete(dir);
|
|
128
|
+
return answer;
|
|
129
|
+
}
|
|
45
130
|
/**
|
|
46
131
|
* Resolves an absolute ChRIS file path to its numeric file id.
|
|
47
132
|
*
|
|
48
133
|
* Lists the parent directory and matches on basename, tolerating the `? <name>`
|
|
49
|
-
* placeholder form the API sometimes returns.
|
|
134
|
+
* placeholder form the API sometimes returns. Inside {@link fileIds_memoRun}
|
|
135
|
+
* the listing is the transfer's, made once per folder.
|
|
50
136
|
*
|
|
51
137
|
* @param filePath - Absolute ChRIS file path.
|
|
52
138
|
* @returns Ok(fileId), or Err (with a message pushed to errorStack) on failure.
|
|
@@ -54,27 +140,21 @@ const index_js_1 = require("./index.js");
|
|
|
54
140
|
async function pathFileId_resolve(filePath) {
|
|
55
141
|
const dir = path.posix.dirname(filePath);
|
|
56
142
|
const name = path.posix.basename(filePath);
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const results = await group.asset.resources_getAll();
|
|
62
|
-
if (!results || !results.tableData) {
|
|
63
|
-
cumin_1.errorStack.stack_push('error', `No files found in directory: ${dir}`);
|
|
143
|
+
const folder = await folderIds_get(dir);
|
|
144
|
+
if ('refused' in folder) {
|
|
145
|
+
if (folder.refused !== '')
|
|
146
|
+
cumin_1.errorStack.stack_push('error', folder.refused);
|
|
64
147
|
return (0, cumin_1.Err)();
|
|
65
148
|
}
|
|
66
|
-
|
|
67
|
-
const basename = path.posix.basename(f.fname || '');
|
|
68
|
-
return basename === name || basename === `? ${name}`;
|
|
69
|
-
});
|
|
70
|
-
if (!file) {
|
|
149
|
+
if (!folder.ids.has(name)) {
|
|
71
150
|
cumin_1.errorStack.stack_push('error', `File not found: ${name} in ${dir}`);
|
|
72
151
|
return (0, cumin_1.Err)();
|
|
73
152
|
}
|
|
74
|
-
|
|
153
|
+
const id = folder.ids.get(name);
|
|
154
|
+
if (typeof id !== 'number') {
|
|
75
155
|
cumin_1.errorStack.stack_push('error', `File has no valid ID: ${name}`);
|
|
76
156
|
return (0, cumin_1.Err)();
|
|
77
157
|
}
|
|
78
|
-
return (0, cumin_1.Ok)(
|
|
158
|
+
return (0, cumin_1.Ok)(id);
|
|
79
159
|
}
|
|
80
160
|
//# sourceMappingURL=fileLookup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileLookup.js","sourceRoot":"","sources":["../../src/files/fileLookup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"fileLookup.js","sourceRoot":"","sources":["../../src/files/fileLookup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,0CAGC;AAmDD,gDAsBC;AA9ID;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,uDAAqD;AACrD,2CAA6B;AAC7B,yCAQuB;AACvB,yCAA4C;AAc5C,wEAAwE;AACxE,MAAM,SAAS,GAAqC,IAAI,oCAAiB,EAAiB,CAAC;AAE3F;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,eAAe,CAAI,SAA2B;IAClE,IAAI,SAAS,CAAC,QAAQ,EAAE,KAAK,SAAS;QAAE,OAAO,SAAS,EAAE,CAAC;IAC3D,OAAO,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,cAAc,CAAC,GAAW;IACvC,MAAM,KAAK,GAAqD,MAAM,IAAA,yBAAc,EAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACnG,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACnC,MAAM,OAAO,GAAgC,MAAM,KAAK,CAAC,KAAK,CAAC,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
|
4
|
+
* Maintains a cached mapping of logical paths to physical locations,
|
|
5
|
+
* enabling incremental resolution by reusing cached path prefixes.
|
|
6
|
+
*
|
|
7
|
+
* Example:
|
|
8
|
+
* - First call: '/home/user/public/feed_4' → Full resolution, cache prefix
|
|
9
|
+
* - Second call: '/home/user/public/feed_5' → Reuse '/home/user/public', resolve only 'feed_5'
|
|
10
|
+
*
|
|
11
|
+
* This eliminates redundant tree walking and API calls for paths with common prefixes.
|
|
12
|
+
*
|
|
13
|
+
* It is CUBE's own mechanics (a `.chrislink` is a file CUBE lists among a
|
|
14
|
+
* folder's links), so it lives with the file reads. The kernel asks it
|
|
15
|
+
* through one door: the ChRIS backend's link walk, which brasa's
|
|
16
|
+
* `storePath_resolve` calls for every file command.
|
|
17
|
+
*
|
|
18
|
+
* @module
|
|
19
|
+
*/
|
|
20
|
+
import { Result } from '@fnndsc/cumin';
|
|
21
|
+
/**
|
|
22
|
+
* Statistics for cache performance monitoring.
|
|
23
|
+
*/
|
|
24
|
+
export interface CacheStats {
|
|
25
|
+
hits: number;
|
|
26
|
+
misses: number;
|
|
27
|
+
size: number;
|
|
28
|
+
hitRate: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Singleton PathMapper class for logical-to-physical path resolution.
|
|
32
|
+
*
|
|
33
|
+
* Maintains hierarchical cache of path mappings to minimize repeated
|
|
34
|
+
* link resolution operations.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const mapper = PathMapper.instance_get();
|
|
39
|
+
*
|
|
40
|
+
* // First resolution
|
|
41
|
+
* const result1 = await mapper.logicalPath_resolve('/home/user/public/feed_4');
|
|
42
|
+
* // → Resolves /home/user/public → /SHARED, then feed_4
|
|
43
|
+
* // → Caches intermediate mappings
|
|
44
|
+
*
|
|
45
|
+
* // Second resolution - prefix reuse
|
|
46
|
+
* const result2 = await mapper.logicalPath_resolve('/home/user/public/feed_5');
|
|
47
|
+
* // → Reuses cached '/home/user/public' → '/SHARED'
|
|
48
|
+
* // → Resolves only 'feed_5'
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare class PathMapper {
|
|
52
|
+
private static instance;
|
|
53
|
+
private cache;
|
|
54
|
+
private readonly defaultTTL;
|
|
55
|
+
private stats;
|
|
56
|
+
/** Walked paths whose parent could not be asked for links, by the parent. */
|
|
57
|
+
private blind;
|
|
58
|
+
/** Parents found blind by resolutions since the last {@link blindParents_take}. */
|
|
59
|
+
private blindSeen;
|
|
60
|
+
/**
|
|
61
|
+
* Private constructor enforces singleton pattern.
|
|
62
|
+
*/
|
|
63
|
+
private constructor();
|
|
64
|
+
/**
|
|
65
|
+
* Gets the singleton PathMapper instance.
|
|
66
|
+
*
|
|
67
|
+
* @returns The singleton PathMapper instance.
|
|
68
|
+
*/
|
|
69
|
+
static instance_get(): PathMapper;
|
|
70
|
+
/**
|
|
71
|
+
* Resets the singleton instance (for testing).
|
|
72
|
+
*
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
static instance_reset(): void;
|
|
76
|
+
/**
|
|
77
|
+
* Resolves a logical path to its physical location.
|
|
78
|
+
*
|
|
79
|
+
* Uses cached path prefixes when available, resolving only the
|
|
80
|
+
* uncached suffix to minimize API calls.
|
|
81
|
+
*
|
|
82
|
+
* @param logicalPath - The logical path to resolve.
|
|
83
|
+
* @returns Result containing the physical path, or Err on failure.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const mapper = PathMapper.instance_get();
|
|
88
|
+
*
|
|
89
|
+
* // First call: full resolution
|
|
90
|
+
* const result1 = await mapper.logicalPath_resolve('/home/user/public/feed_4');
|
|
91
|
+
* // → Resolves /home/user/public → /SHARED, then feed_4
|
|
92
|
+
* // → Caches: '/home/user/public' → '/SHARED'
|
|
93
|
+
* // → Caches: '/home/user/public/feed_4' → '/SHARED/feed_4'
|
|
94
|
+
*
|
|
95
|
+
* // Second call: prefix reuse
|
|
96
|
+
* const result2 = await mapper.logicalPath_resolve('/home/user/public/feed_5');
|
|
97
|
+
* // → Reuses cached '/home/user/public' → '/SHARED'
|
|
98
|
+
* // → Resolves only 'feed_5'
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
logicalPath_resolve(logicalPath: string): Promise<Result<string>>;
|
|
102
|
+
/**
|
|
103
|
+
* Finds the longest cached prefix of a logical path.
|
|
104
|
+
*
|
|
105
|
+
* Walks up the path hierarchy to find the deepest cached mapping,
|
|
106
|
+
* returning the cached physical prefix and remaining suffix.
|
|
107
|
+
*
|
|
108
|
+
* @param logicalPath - The full logical path.
|
|
109
|
+
* @returns Object with cached prefix and remaining suffix.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* // Cache contains: '/home/user/public' → '/SHARED'
|
|
114
|
+
* const result = mapper.longestCachedPrefix_find('/home/user/public/feed_4/files');
|
|
115
|
+
* // Returns:
|
|
116
|
+
* // {
|
|
117
|
+
* // prefixLogical: '/home/user/public',
|
|
118
|
+
* // prefixPhysical: '/SHARED',
|
|
119
|
+
* // suffix: 'feed_4/files'
|
|
120
|
+
* // }
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
private longestCachedPrefix_find;
|
|
124
|
+
/**
|
|
125
|
+
* Resolves a path suffix by checking each component for links.
|
|
126
|
+
*
|
|
127
|
+
* Walks the suffix path, checking each component to see if it's a link.
|
|
128
|
+
* Caches intermediate mappings along the way for future prefix reuse.
|
|
129
|
+
*
|
|
130
|
+
* @param suffix - The path suffix to resolve (e.g., 'feed_4/files').
|
|
131
|
+
* @param physicalBase - The physical base path to build upon.
|
|
132
|
+
* @param logicalBase - The logical base path (for caching intermediate results).
|
|
133
|
+
* @returns Result containing the resolved physical path.
|
|
134
|
+
*/
|
|
135
|
+
private suffix_resolve;
|
|
136
|
+
/**
|
|
137
|
+
* Checks if a path is a link and returns its target.
|
|
138
|
+
*
|
|
139
|
+
* Optimizes resolution by checking ListCache first. If the parent directory
|
|
140
|
+
* is cached, we can determine if the candidate is a link without an API call.
|
|
141
|
+
* Falls back to API (fetching all links in parent) if not cached.
|
|
142
|
+
*
|
|
143
|
+
* @param candidatePhysical - The physical path to check.
|
|
144
|
+
* @param candidateLogical - The logical path (used for cache lookup).
|
|
145
|
+
* @returns The link target if it's a link, null otherwise.
|
|
146
|
+
*/
|
|
147
|
+
private link_checkAndResolve;
|
|
148
|
+
/**
|
|
149
|
+
* Records the parents a resolution of this path walked past without
|
|
150
|
+
* seeing their links.
|
|
151
|
+
*
|
|
152
|
+
* @param logicalPath - The path just resolved.
|
|
153
|
+
*/
|
|
154
|
+
private blind_note;
|
|
155
|
+
/**
|
|
156
|
+
* The parents whose links could not be read by the resolutions since the
|
|
157
|
+
* last call, emptied by the call. A command whose answer failed reports
|
|
158
|
+
* them: a link in one of them, had it been seen, would have led elsewhere.
|
|
159
|
+
*
|
|
160
|
+
* @returns The parents, in the order first met.
|
|
161
|
+
*/
|
|
162
|
+
blindParents_take(): string[];
|
|
163
|
+
/**
|
|
164
|
+
* Gets a cached mapping if it exists and hasn't expired.
|
|
165
|
+
*
|
|
166
|
+
* @param logicalPath - The logical path to look up.
|
|
167
|
+
* @returns The cached physical path, or null if not cached or expired.
|
|
168
|
+
*/
|
|
169
|
+
private cache_get;
|
|
170
|
+
/**
|
|
171
|
+
* Caches a logical-to-physical path mapping.
|
|
172
|
+
*
|
|
173
|
+
* @param logicalPath - The logical path.
|
|
174
|
+
* @param physicalPath - The corresponding physical path.
|
|
175
|
+
* @param ttl - Optional TTL in milliseconds (defaults to 30s).
|
|
176
|
+
*/
|
|
177
|
+
private cache_set;
|
|
178
|
+
/**
|
|
179
|
+
* Invalidates all cached mappings with a given logical path prefix.
|
|
180
|
+
*
|
|
181
|
+
* Call this when links are created/deleted/modified.
|
|
182
|
+
*
|
|
183
|
+
* @param logicalPathPrefix - The logical path prefix to invalidate.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* // Link changed: /home/user/public → /SHARED becomes → /PUBLIC
|
|
188
|
+
* mapper.cache_invalidate('/home/user/public');
|
|
189
|
+
* // Invalidates:
|
|
190
|
+
* // - /home/user/public
|
|
191
|
+
* // - /home/user/public/feed_4
|
|
192
|
+
* // - /home/user/public/feed_5
|
|
193
|
+
* // - ... etc
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
cache_invalidate(logicalPathPrefix: string): void;
|
|
197
|
+
/**
|
|
198
|
+
* Clears all cached mappings.
|
|
199
|
+
*/
|
|
200
|
+
cache_clear(): void;
|
|
201
|
+
/**
|
|
202
|
+
* Gets cache statistics.
|
|
203
|
+
*
|
|
204
|
+
* @returns Cache statistics including hit rate and size.
|
|
205
|
+
*/
|
|
206
|
+
stats_get(): CacheStats;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Convenience function to get the singleton PathMapper instance.
|
|
210
|
+
*
|
|
211
|
+
* @returns The singleton PathMapper instance.
|
|
212
|
+
*/
|
|
213
|
+
export declare function pathMapper_get(): PathMapper;
|
|
214
|
+
/**
|
|
215
|
+
* Resolves a logical path to its physical path by following links.
|
|
216
|
+
*
|
|
217
|
+
* Delegates to the PathMapper singleton, which uses hierarchical caching to
|
|
218
|
+
* optimize repeated resolutions with common prefixes.
|
|
219
|
+
*
|
|
220
|
+
* @param logicalPath - The logical (apparent) path the user sees/navigates.
|
|
221
|
+
* @returns A Result containing the physical path, or Err if path is invalid.
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```ts
|
|
225
|
+
* await logicalPath_resolve('/home/user/public/data'); // Ok('/PUBLIC/data') where public -> /PUBLIC
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
export declare function logicalPath_resolve(logicalPath: string): Promise<Result<string>>;
|
|
229
|
+
/**
|
|
230
|
+
* Clears the path mapping cache. Useful when links are created/deleted.
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```ts
|
|
234
|
+
* linkCache_clear();
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
export declare function linkCache_clear(): void;
|
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Singleton path mapper for logical-to-physical ChRIS path resolution.
|
|
4
|
+
*
|
|
5
|
+
* Maintains a cached mapping of logical paths to physical locations,
|
|
6
|
+
* enabling incremental resolution by reusing cached path prefixes.
|
|
7
|
+
*
|
|
8
|
+
* Example:
|
|
9
|
+
* - First call: '/home/user/public/feed_4' → Full resolution, cache prefix
|
|
10
|
+
* - Second call: '/home/user/public/feed_5' → Reuse '/home/user/public', resolve only 'feed_5'
|
|
11
|
+
*
|
|
12
|
+
* This eliminates redundant tree walking and API calls for paths with common prefixes.
|
|
13
|
+
*
|
|
14
|
+
* It is CUBE's own mechanics (a `.chrislink` is a file CUBE lists among a
|
|
15
|
+
* folder's links), so it lives with the file reads. The kernel asks it
|
|
16
|
+
* through one door: the ChRIS backend's link walk, which brasa's
|
|
17
|
+
* `storePath_resolve` calls for every file command.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
24
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
25
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
26
|
+
}
|
|
27
|
+
Object.defineProperty(o, k2, desc);
|
|
28
|
+
}) : (function(o, m, k, k2) {
|
|
29
|
+
if (k2 === undefined) k2 = k;
|
|
30
|
+
o[k2] = m[k];
|
|
31
|
+
}));
|
|
32
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
33
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
34
|
+
}) : function(o, v) {
|
|
35
|
+
o["default"] = v;
|
|
36
|
+
});
|
|
37
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
38
|
+
var ownKeys = function(o) {
|
|
39
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
40
|
+
var ar = [];
|
|
41
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
42
|
+
return ar;
|
|
43
|
+
};
|
|
44
|
+
return ownKeys(o);
|
|
45
|
+
};
|
|
46
|
+
return function (mod) {
|
|
47
|
+
if (mod && mod.__esModule) return mod;
|
|
48
|
+
var result = {};
|
|
49
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
50
|
+
__setModuleDefault(result, mod);
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
})();
|
|
54
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
|
+
exports.PathMapper = void 0;
|
|
56
|
+
exports.pathMapper_get = pathMapper_get;
|
|
57
|
+
exports.logicalPath_resolve = logicalPath_resolve;
|
|
58
|
+
exports.linkCache_clear = linkCache_clear;
|
|
59
|
+
const cumin_1 = require("@fnndsc/cumin");
|
|
60
|
+
const index_js_1 = require("./index.js");
|
|
61
|
+
const path = __importStar(require("path"));
|
|
62
|
+
const cumin_2 = require("@fnndsc/cumin");
|
|
63
|
+
/**
|
|
64
|
+
* Singleton PathMapper class for logical-to-physical path resolution.
|
|
65
|
+
*
|
|
66
|
+
* Maintains hierarchical cache of path mappings to minimize repeated
|
|
67
|
+
* link resolution operations.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const mapper = PathMapper.instance_get();
|
|
72
|
+
*
|
|
73
|
+
* // First resolution
|
|
74
|
+
* const result1 = await mapper.logicalPath_resolve('/home/user/public/feed_4');
|
|
75
|
+
* // → Resolves /home/user/public → /SHARED, then feed_4
|
|
76
|
+
* // → Caches intermediate mappings
|
|
77
|
+
*
|
|
78
|
+
* // Second resolution - prefix reuse
|
|
79
|
+
* const result2 = await mapper.logicalPath_resolve('/home/user/public/feed_5');
|
|
80
|
+
* // → Reuses cached '/home/user/public' → '/SHARED'
|
|
81
|
+
* // → Resolves only 'feed_5'
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
class PathMapper {
|
|
85
|
+
static instance = null;
|
|
86
|
+
cache = new Map();
|
|
87
|
+
defaultTTL = 30000; // 30 seconds
|
|
88
|
+
stats = { hits: 0, misses: 0 };
|
|
89
|
+
/** Walked paths whose parent could not be asked for links, by the parent. */
|
|
90
|
+
blind = new Map();
|
|
91
|
+
/** Parents found blind by resolutions since the last {@link blindParents_take}. */
|
|
92
|
+
blindSeen = new Set();
|
|
93
|
+
/**
|
|
94
|
+
* Private constructor enforces singleton pattern.
|
|
95
|
+
*/
|
|
96
|
+
constructor() { }
|
|
97
|
+
/**
|
|
98
|
+
* Gets the singleton PathMapper instance.
|
|
99
|
+
*
|
|
100
|
+
* @returns The singleton PathMapper instance.
|
|
101
|
+
*/
|
|
102
|
+
static instance_get() {
|
|
103
|
+
if (!PathMapper.instance) {
|
|
104
|
+
PathMapper.instance = new PathMapper();
|
|
105
|
+
}
|
|
106
|
+
return PathMapper.instance;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Resets the singleton instance (for testing).
|
|
110
|
+
*
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
static instance_reset() {
|
|
114
|
+
PathMapper.instance = null;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Resolves a logical path to its physical location.
|
|
118
|
+
*
|
|
119
|
+
* Uses cached path prefixes when available, resolving only the
|
|
120
|
+
* uncached suffix to minimize API calls.
|
|
121
|
+
*
|
|
122
|
+
* @param logicalPath - The logical path to resolve.
|
|
123
|
+
* @returns Result containing the physical path, or Err on failure.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* const mapper = PathMapper.instance_get();
|
|
128
|
+
*
|
|
129
|
+
* // First call: full resolution
|
|
130
|
+
* const result1 = await mapper.logicalPath_resolve('/home/user/public/feed_4');
|
|
131
|
+
* // → Resolves /home/user/public → /SHARED, then feed_4
|
|
132
|
+
* // → Caches: '/home/user/public' → '/SHARED'
|
|
133
|
+
* // → Caches: '/home/user/public/feed_4' → '/SHARED/feed_4'
|
|
134
|
+
*
|
|
135
|
+
* // Second call: prefix reuse
|
|
136
|
+
* const result2 = await mapper.logicalPath_resolve('/home/user/public/feed_5');
|
|
137
|
+
* // → Reuses cached '/home/user/public' → '/SHARED'
|
|
138
|
+
* // → Resolves only 'feed_5'
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
async logicalPath_resolve(logicalPath) {
|
|
142
|
+
// 1. Validate input
|
|
143
|
+
if (!logicalPath || typeof logicalPath !== 'string') {
|
|
144
|
+
cumin_1.errorStack.stack_push('error', 'Invalid path: path must be a non-empty string');
|
|
145
|
+
return (0, cumin_1.Err)();
|
|
146
|
+
}
|
|
147
|
+
// 2. Normalize path
|
|
148
|
+
const normalizedPath = logicalPath.startsWith('/')
|
|
149
|
+
? logicalPath
|
|
150
|
+
: `/${logicalPath}`;
|
|
151
|
+
// 3. Check exact cache hit
|
|
152
|
+
const exactMatch = this.cache_get(normalizedPath);
|
|
153
|
+
if (exactMatch !== null) {
|
|
154
|
+
this.stats.hits++;
|
|
155
|
+
this.blind_note(normalizedPath);
|
|
156
|
+
return (0, cumin_1.Ok)(exactMatch);
|
|
157
|
+
}
|
|
158
|
+
// 4. Find longest cached prefix
|
|
159
|
+
const prefixMatch = this.longestCachedPrefix_find(normalizedPath);
|
|
160
|
+
// 5. Resolve suffix incrementally
|
|
161
|
+
const resolvedPhysical = await this.suffix_resolve(prefixMatch.suffix, prefixMatch.prefixPhysical, prefixMatch.prefixLogical);
|
|
162
|
+
this.blind_note(normalizedPath);
|
|
163
|
+
if (!resolvedPhysical.ok) {
|
|
164
|
+
this.stats.misses++;
|
|
165
|
+
return (0, cumin_1.Err)();
|
|
166
|
+
}
|
|
167
|
+
// 6. Cache the full resolution
|
|
168
|
+
this.cache_set(normalizedPath, resolvedPhysical.value);
|
|
169
|
+
this.stats.misses++;
|
|
170
|
+
return (0, cumin_1.Ok)(resolvedPhysical.value);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Finds the longest cached prefix of a logical path.
|
|
174
|
+
*
|
|
175
|
+
* Walks up the path hierarchy to find the deepest cached mapping,
|
|
176
|
+
* returning the cached physical prefix and remaining suffix.
|
|
177
|
+
*
|
|
178
|
+
* @param logicalPath - The full logical path.
|
|
179
|
+
* @returns Object with cached prefix and remaining suffix.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* // Cache contains: '/home/user/public' → '/SHARED'
|
|
184
|
+
* const result = mapper.longestCachedPrefix_find('/home/user/public/feed_4/files');
|
|
185
|
+
* // Returns:
|
|
186
|
+
* // {
|
|
187
|
+
* // prefixLogical: '/home/user/public',
|
|
188
|
+
* // prefixPhysical: '/SHARED',
|
|
189
|
+
* // suffix: 'feed_4/files'
|
|
190
|
+
* // }
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
longestCachedPrefix_find(logicalPath) {
|
|
194
|
+
const parts = logicalPath.split('/').filter((p) => p.length > 0);
|
|
195
|
+
// Walk down from full path to root
|
|
196
|
+
for (let i = parts.length; i >= 0; i--) {
|
|
197
|
+
const candidatePrefix = i === 0
|
|
198
|
+
? '/'
|
|
199
|
+
: '/' + parts.slice(0, i).join('/');
|
|
200
|
+
const cached = this.cache_get(candidatePrefix);
|
|
201
|
+
if (cached !== null) {
|
|
202
|
+
const suffixParts = parts.slice(i);
|
|
203
|
+
const suffix = suffixParts.join('/');
|
|
204
|
+
return {
|
|
205
|
+
prefixLogical: candidatePrefix,
|
|
206
|
+
prefixPhysical: cached,
|
|
207
|
+
suffix: suffix
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// No cached prefix found, start from root
|
|
212
|
+
return {
|
|
213
|
+
prefixLogical: '/',
|
|
214
|
+
prefixPhysical: '/',
|
|
215
|
+
suffix: parts.join('/')
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Resolves a path suffix by checking each component for links.
|
|
220
|
+
*
|
|
221
|
+
* Walks the suffix path, checking each component to see if it's a link.
|
|
222
|
+
* Caches intermediate mappings along the way for future prefix reuse.
|
|
223
|
+
*
|
|
224
|
+
* @param suffix - The path suffix to resolve (e.g., 'feed_4/files').
|
|
225
|
+
* @param physicalBase - The physical base path to build upon.
|
|
226
|
+
* @param logicalBase - The logical base path (for caching intermediate results).
|
|
227
|
+
* @returns Result containing the resolved physical path.
|
|
228
|
+
*/
|
|
229
|
+
async suffix_resolve(suffix, physicalBase, logicalBase) {
|
|
230
|
+
if (!suffix || suffix.length === 0) {
|
|
231
|
+
return (0, cumin_1.Ok)(physicalBase);
|
|
232
|
+
}
|
|
233
|
+
const parts = suffix.split('/').filter((p) => p.length > 0);
|
|
234
|
+
let physicalCurrent = physicalBase;
|
|
235
|
+
let logicalCurrent = logicalBase;
|
|
236
|
+
for (let i = 0; i < parts.length; i++) {
|
|
237
|
+
const part = parts[i];
|
|
238
|
+
const candidatePhysical = physicalCurrent === '/'
|
|
239
|
+
? `/${part}`
|
|
240
|
+
: `${physicalCurrent}/${part}`;
|
|
241
|
+
const candidateLogical = logicalCurrent === '/'
|
|
242
|
+
? `/${part}`
|
|
243
|
+
: `${logicalCurrent}/${part}`;
|
|
244
|
+
try {
|
|
245
|
+
const linkTarget = await this.link_checkAndResolve(candidatePhysical, candidateLogical);
|
|
246
|
+
if (linkTarget) {
|
|
247
|
+
// It's a link! Jump to target
|
|
248
|
+
physicalCurrent = linkTarget;
|
|
249
|
+
logicalCurrent = candidateLogical;
|
|
250
|
+
// Cache this intermediate mapping
|
|
251
|
+
this.cache_set(candidateLogical, linkTarget);
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
// Not a link, continue building path
|
|
255
|
+
physicalCurrent = candidatePhysical;
|
|
256
|
+
logicalCurrent = candidateLogical;
|
|
257
|
+
// Cache this intermediate mapping
|
|
258
|
+
this.cache_set(candidateLogical, candidatePhysical);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
// Link resolution failed - log warning but continue
|
|
263
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
264
|
+
cumin_1.errorStack.stack_push('warning', `Failed to check if '${candidatePhysical}' is a link: ${msg}. Treating as regular path.`);
|
|
265
|
+
// Assume it's not a link and continue
|
|
266
|
+
physicalCurrent = candidatePhysical;
|
|
267
|
+
logicalCurrent = candidateLogical;
|
|
268
|
+
this.cache_set(candidateLogical, candidatePhysical);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return (0, cumin_1.Ok)(physicalCurrent);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Checks if a path is a link and returns its target.
|
|
275
|
+
*
|
|
276
|
+
* Optimizes resolution by checking ListCache first. If the parent directory
|
|
277
|
+
* is cached, we can determine if the candidate is a link without an API call.
|
|
278
|
+
* Falls back to API (fetching all links in parent) if not cached.
|
|
279
|
+
*
|
|
280
|
+
* @param candidatePhysical - The physical path to check.
|
|
281
|
+
* @param candidateLogical - The logical path (used for cache lookup).
|
|
282
|
+
* @returns The link target if it's a link, null otherwise.
|
|
283
|
+
*/
|
|
284
|
+
async link_checkAndResolve(candidatePhysical, candidateLogical) {
|
|
285
|
+
// 1. Fast Path: Check ListCache using logical path
|
|
286
|
+
// If we have the parent directory cached, we can check if the item is a link there.
|
|
287
|
+
const logicalParent = path.dirname(candidateLogical);
|
|
288
|
+
const itemName = path.basename(candidateLogical);
|
|
289
|
+
const listCache = (0, cumin_2.listCache_get)();
|
|
290
|
+
const cached = listCache.cache_get(logicalParent);
|
|
291
|
+
if (cached && cached.data && Array.isArray(cached.data)) {
|
|
292
|
+
// Look for the item in the cached listing
|
|
293
|
+
const item = cached.data.find((i) => i.name === itemName);
|
|
294
|
+
if (item) {
|
|
295
|
+
// Item found in cache!
|
|
296
|
+
if (item.type === 'link' && item.target) {
|
|
297
|
+
return item.target;
|
|
298
|
+
}
|
|
299
|
+
// Found but not a link (or has no target) -> return null
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
// Item not found in cache.
|
|
303
|
+
// It might be hidden or newly created. Fall back to API.
|
|
304
|
+
}
|
|
305
|
+
// 2. Slow Path: Check API using physical path
|
|
306
|
+
const parts = candidatePhysical.split('/');
|
|
307
|
+
parts.pop(); // Remove filename
|
|
308
|
+
const parentDir = parts.join('/') || '/';
|
|
309
|
+
const normalizedCandidate = candidatePhysical.startsWith('/')
|
|
310
|
+
? candidatePhysical
|
|
311
|
+
: `/${candidatePhysical}`;
|
|
312
|
+
// The probe is a side question: a parent this identity may not read (a
|
|
313
|
+
// shared feed's owner's home, walked on the way to the feed) says so on
|
|
314
|
+
// the error stack, and that refusal would mark the command it serves an
|
|
315
|
+
// error though its answer came. The refusal is kept here instead: the
|
|
316
|
+
// walk goes on as written, and a command whose answer then fails can say
|
|
317
|
+
// which parent's links went unchecked (blindParents_take).
|
|
318
|
+
const probeMark = cumin_1.errorStack.checkpoint_mark();
|
|
319
|
+
const fetchOpts = { limit: 1000, offset: 0 };
|
|
320
|
+
let linksResult = null;
|
|
321
|
+
let refused = false;
|
|
322
|
+
try {
|
|
323
|
+
linksResult = await (0, index_js_1.files_listAll)(fetchOpts, 'links', parentDir);
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
refused = true;
|
|
327
|
+
}
|
|
328
|
+
const said = cumin_1.errorStack.checkpoint_drain(probeMark);
|
|
329
|
+
if (refused || (linksResult === null && said.some((message) => message.type === 'error'))) {
|
|
330
|
+
this.blind.set(candidateLogical, parentDir);
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
this.blind.delete(candidateLogical);
|
|
334
|
+
if (linksResult && linksResult.tableData) {
|
|
335
|
+
for (const linkRaw of linksResult.tableData) {
|
|
336
|
+
const linkFname = linkRaw.fname || '';
|
|
337
|
+
const linkPath = linkRaw.path || '';
|
|
338
|
+
const normalizedLinkFname = linkFname.startsWith('/')
|
|
339
|
+
? linkFname
|
|
340
|
+
: `/${linkFname}`;
|
|
341
|
+
if (normalizedLinkFname.endsWith('.chrislink')) {
|
|
342
|
+
const logicalPath = normalizedLinkFname.slice(0, -10);
|
|
343
|
+
if (logicalPath === normalizedCandidate) {
|
|
344
|
+
const target = linkPath.startsWith('/') ? linkPath : `/${linkPath}`;
|
|
345
|
+
return target;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return null;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Records the parents a resolution of this path walked past without
|
|
354
|
+
* seeing their links.
|
|
355
|
+
*
|
|
356
|
+
* @param logicalPath - The path just resolved.
|
|
357
|
+
*/
|
|
358
|
+
blind_note(logicalPath) {
|
|
359
|
+
for (const [walked, parent] of this.blind) {
|
|
360
|
+
if (logicalPath === walked || logicalPath.startsWith(walked + '/')) {
|
|
361
|
+
this.blindSeen.add(parent);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* The parents whose links could not be read by the resolutions since the
|
|
367
|
+
* last call, emptied by the call. A command whose answer failed reports
|
|
368
|
+
* them: a link in one of them, had it been seen, would have led elsewhere.
|
|
369
|
+
*
|
|
370
|
+
* @returns The parents, in the order first met.
|
|
371
|
+
*/
|
|
372
|
+
blindParents_take() {
|
|
373
|
+
const parents = [...this.blindSeen];
|
|
374
|
+
this.blindSeen.clear();
|
|
375
|
+
return parents;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Gets a cached mapping if it exists and hasn't expired.
|
|
379
|
+
*
|
|
380
|
+
* @param logicalPath - The logical path to look up.
|
|
381
|
+
* @returns The cached physical path, or null if not cached or expired.
|
|
382
|
+
*/
|
|
383
|
+
cache_get(logicalPath) {
|
|
384
|
+
const cached = this.cache.get(logicalPath);
|
|
385
|
+
if (!cached) {
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
388
|
+
const now = Date.now();
|
|
389
|
+
const age = now - cached.timestamp;
|
|
390
|
+
if (age > cached.ttl) {
|
|
391
|
+
// Expired, remove from cache
|
|
392
|
+
this.cache.delete(logicalPath);
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
return cached.physicalPath;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Caches a logical-to-physical path mapping.
|
|
399
|
+
*
|
|
400
|
+
* @param logicalPath - The logical path.
|
|
401
|
+
* @param physicalPath - The corresponding physical path.
|
|
402
|
+
* @param ttl - Optional TTL in milliseconds (defaults to 30s).
|
|
403
|
+
*/
|
|
404
|
+
cache_set(logicalPath, physicalPath, ttl = this.defaultTTL) {
|
|
405
|
+
this.cache.set(logicalPath, {
|
|
406
|
+
physicalPath,
|
|
407
|
+
timestamp: Date.now(),
|
|
408
|
+
ttl
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Invalidates all cached mappings with a given logical path prefix.
|
|
413
|
+
*
|
|
414
|
+
* Call this when links are created/deleted/modified.
|
|
415
|
+
*
|
|
416
|
+
* @param logicalPathPrefix - The logical path prefix to invalidate.
|
|
417
|
+
*
|
|
418
|
+
* @example
|
|
419
|
+
* ```typescript
|
|
420
|
+
* // Link changed: /home/user/public → /SHARED becomes → /PUBLIC
|
|
421
|
+
* mapper.cache_invalidate('/home/user/public');
|
|
422
|
+
* // Invalidates:
|
|
423
|
+
* // - /home/user/public
|
|
424
|
+
* // - /home/user/public/feed_4
|
|
425
|
+
* // - /home/user/public/feed_5
|
|
426
|
+
* // - ... etc
|
|
427
|
+
* ```
|
|
428
|
+
*/
|
|
429
|
+
cache_invalidate(logicalPathPrefix) {
|
|
430
|
+
const keysToDelete = [];
|
|
431
|
+
for (const [key] of this.cache) {
|
|
432
|
+
if (key === logicalPathPrefix || key.startsWith(logicalPathPrefix + '/')) {
|
|
433
|
+
keysToDelete.push(key);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
for (const key of keysToDelete) {
|
|
437
|
+
this.cache.delete(key);
|
|
438
|
+
this.blind.delete(key);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Clears all cached mappings.
|
|
443
|
+
*/
|
|
444
|
+
cache_clear() {
|
|
445
|
+
this.cache.clear();
|
|
446
|
+
this.blind.clear();
|
|
447
|
+
this.blindSeen.clear();
|
|
448
|
+
this.stats = { hits: 0, misses: 0 };
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Gets cache statistics.
|
|
452
|
+
*
|
|
453
|
+
* @returns Cache statistics including hit rate and size.
|
|
454
|
+
*/
|
|
455
|
+
stats_get() {
|
|
456
|
+
const total = this.stats.hits + this.stats.misses;
|
|
457
|
+
const hitRate = total === 0 ? 0 : this.stats.hits / total;
|
|
458
|
+
return {
|
|
459
|
+
hits: this.stats.hits,
|
|
460
|
+
misses: this.stats.misses,
|
|
461
|
+
size: this.cache.size,
|
|
462
|
+
hitRate
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
exports.PathMapper = PathMapper;
|
|
467
|
+
/**
|
|
468
|
+
* Convenience function to get the singleton PathMapper instance.
|
|
469
|
+
*
|
|
470
|
+
* @returns The singleton PathMapper instance.
|
|
471
|
+
*/
|
|
472
|
+
function pathMapper_get() {
|
|
473
|
+
return PathMapper.instance_get();
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Resolves a logical path to its physical path by following links.
|
|
477
|
+
*
|
|
478
|
+
* Delegates to the PathMapper singleton, which uses hierarchical caching to
|
|
479
|
+
* optimize repeated resolutions with common prefixes.
|
|
480
|
+
*
|
|
481
|
+
* @param logicalPath - The logical (apparent) path the user sees/navigates.
|
|
482
|
+
* @returns A Result containing the physical path, or Err if path is invalid.
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* ```ts
|
|
486
|
+
* await logicalPath_resolve('/home/user/public/data'); // Ok('/PUBLIC/data') where public -> /PUBLIC
|
|
487
|
+
* ```
|
|
488
|
+
*/
|
|
489
|
+
async function logicalPath_resolve(logicalPath) {
|
|
490
|
+
return pathMapper_get().logicalPath_resolve(logicalPath);
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Clears the path mapping cache. Useful when links are created/deleted.
|
|
494
|
+
*
|
|
495
|
+
* @example
|
|
496
|
+
* ```ts
|
|
497
|
+
* linkCache_clear();
|
|
498
|
+
* ```
|
|
499
|
+
*/
|
|
500
|
+
function linkCache_clear() {
|
|
501
|
+
pathMapper_get().cache_clear();
|
|
502
|
+
}
|
|
503
|
+
//# sourceMappingURL=pathMapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathMapper.js","sourceRoot":"","sources":["../../src/files/pathMapper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAugBH,wCAEC;AAgBD,kDAEC;AAUD,0CAEC;AAriBD,yCAA+E;AAC/E,yCAA2C;AAC3C,2CAA6B;AAC7B,yCAA8C;AAwC9C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,UAAU;IACb,MAAM,CAAC,QAAQ,GAAsB,IAAI,CAAC;IAC1C,KAAK,GAA+B,IAAI,GAAG,EAAE,CAAC;IACrC,UAAU,GAAW,KAAK,CAAC,CAAC,aAAa;IAClD,KAAK,GAAqC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IACzE,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,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC;QAElE,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;YACrB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;YACzB,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;YACrB,OAAO;SACR,CAAC;IACJ,CAAC;;AA7bH,gCA8bC;AAED;;;;GAIG;AACH,SAAgB,cAAc;IAC5B,OAAO,UAAU,CAAC,YAAY,EAAE,CAAC;AACnC,CAAC;AAED;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,mBAAmB,CAAC,WAAmB;IAC3D,OAAO,cAAc,EAAE,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,eAAe;IAC7B,cAAc,EAAE,CAAC,WAAW,EAAE,CAAC;AACjC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
export * from './feeds/index.js';
|
|
6
6
|
export * from './plugins/index.js';
|
|
7
7
|
export * from './files/index.js';
|
|
8
|
+
export { fileIds_memoRun } from './files/fileLookup.js';
|
|
9
|
+
export { PathMapper, pathMapper_get, logicalPath_resolve, linkCache_clear, type CacheStats } from './files/pathMapper.js';
|
|
8
10
|
export * from './connect/index.js';
|
|
9
11
|
export * from './context/index.js';
|
|
10
12
|
export * from './store/index.js';
|
package/dist/index.js
CHANGED
|
@@ -18,10 +18,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
18
18
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.DATA_FACTS_READER = exports.dataFormat_deriveFromName = exports.dataFactsIO_build = exports.sourceFeed_parse = exports.procDataFacts_settled = exports.procDataFacts_feed = exports.procDataFacts_sweep = exports.feedDataFacts_read = exports.feedGraphData_ensure = exports.nodeJoins_resolve = exports.feedJoins_ensure = exports.signature_compute = exports.feedGraph_build = exports.PROC_TAGS_PREFIX = exports.FEED_VISIT_COALESCE_MS = exports.ROSTER_DELTA_PAGE = exports.ROSTER_FULL_WALK_MS = exports.FEED_RECHECK_MS = exports.procDataFacts_start = exports.procVisitState_reset = exports.procRoster_bootSync = exports.procRoster_syncStart = exports.procRoster_sync = exports.feedCached_isSettled = exports.feedVisit_sync = exports.feedStatus_refresh = exports.procTarget_parse = exports.procTarget_locate = exports.procFeed_probe = exports.feedMeta_ensure = exports.procFeed_refreshStart = exports.feedInstances_ensureStarted = exports.feedInstances_ensureLoaded = exports.procFeed_ensureLoaded = exports.procPipelineBackfill_status = exports.procTopologyCatchup_await = exports.procTopologyCatchup_status = exports.procTopologyCatchup_enqueue = exports.procTopology_await = exports.procTopology_status = exports.procTopology_retry = exports.procTopology_reconcileFeeds = exports.procTopology_warmup = exports.procCache_refresh = void 0;
|
|
21
|
+
exports.DATA_FACTS_READER = exports.dataFormat_deriveFromName = exports.dataFactsIO_build = exports.sourceFeed_parse = exports.procDataFacts_settled = exports.procDataFacts_feed = exports.procDataFacts_sweep = exports.feedDataFacts_read = exports.feedGraphData_ensure = exports.nodeJoins_resolve = exports.feedJoins_ensure = exports.signature_compute = exports.feedGraph_build = exports.PROC_TAGS_PREFIX = exports.FEED_VISIT_COALESCE_MS = exports.ROSTER_DELTA_PAGE = exports.ROSTER_FULL_WALK_MS = exports.FEED_RECHECK_MS = exports.procDataFacts_start = exports.procVisitState_reset = exports.procRoster_bootSync = exports.procRoster_syncStart = exports.procRoster_sync = exports.feedCached_isSettled = exports.feedVisit_sync = exports.feedStatus_refresh = exports.procTarget_parse = exports.procTarget_locate = exports.procFeed_probe = exports.feedMeta_ensure = exports.procFeed_refreshStart = exports.feedInstances_ensureStarted = exports.feedInstances_ensureLoaded = exports.procFeed_ensureLoaded = exports.procPipelineBackfill_status = exports.procTopologyCatchup_await = exports.procTopologyCatchup_status = exports.procTopologyCatchup_enqueue = exports.procTopology_await = exports.procTopology_status = exports.procTopology_retry = exports.procTopology_reconcileFeeds = exports.procTopology_warmup = exports.procCache_refresh = exports.linkCache_clear = exports.logicalPath_resolve = exports.pathMapper_get = exports.PathMapper = exports.fileIds_memoRun = void 0;
|
|
22
22
|
__exportStar(require("./feeds/index.js"), exports);
|
|
23
23
|
__exportStar(require("./plugins/index.js"), exports);
|
|
24
24
|
__exportStar(require("./files/index.js"), exports);
|
|
25
|
+
var fileLookup_js_1 = require("./files/fileLookup.js");
|
|
26
|
+
Object.defineProperty(exports, "fileIds_memoRun", { enumerable: true, get: function () { return fileLookup_js_1.fileIds_memoRun; } });
|
|
27
|
+
var pathMapper_js_1 = require("./files/pathMapper.js");
|
|
28
|
+
Object.defineProperty(exports, "PathMapper", { enumerable: true, get: function () { return pathMapper_js_1.PathMapper; } });
|
|
29
|
+
Object.defineProperty(exports, "pathMapper_get", { enumerable: true, get: function () { return pathMapper_js_1.pathMapper_get; } });
|
|
30
|
+
Object.defineProperty(exports, "logicalPath_resolve", { enumerable: true, get: function () { return pathMapper_js_1.logicalPath_resolve; } });
|
|
31
|
+
Object.defineProperty(exports, "linkCache_clear", { enumerable: true, get: function () { return pathMapper_js_1.linkCache_clear; } });
|
|
25
32
|
__exportStar(require("./connect/index.js"), exports);
|
|
26
33
|
__exportStar(require("./context/index.js"), exports);
|
|
27
34
|
__exportStar(require("./store/index.js"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;AAEH,mDAAiC;AACjC,qDAAmC;AACnC,mDAAiC;AACjC,qDAAmC;AACnC,qDAAmC;AACnC,mDAAiC;AACjC,uDAAqC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GAAA,cAAc,OAAA;AAAE,4GAAA,iBAAiB,OAAA;AAAE,2GAAA,gBAAgB,OAAA;AAAqB,6GAAA,kBAAkB,OAAA;AAAE,yGAAA,cAAc,OAAA;AAAE,+GAAA,oBAAoB,OAAA;AAAE,0GAAA,eAAe,OAAA;AAAE,+GAAA,oBAAoB,OAAA;AAAE,8GAAA,mBAAmB,OAAA;AAAE,+GAAA,oBAAoB,OAAA;AAAE,8GAAA,mBAAmB,OAAA;AAAE,0GAAA,eAAe,OAAA;AAAE,8GAAA,mBAAmB,OAAA;AAAE,4GAAA,iBAAiB,OAAA;AAAE,iHAAA,sBAAsB,OAAA;AAExsB,2DAA+D;AAAtD,+GAAA,gBAAgB,OAAA;AACzB,mDAAwE;AAA/D,+GAAA,eAAe,OAAA;AAAE,iHAAA,iBAAiB,OAAA;AAE3C,mDAAyE;AAAhE,gHAAA,gBAAgB,OAAA;AAAE,iHAAA,iBAAiB,OAAA;AAC5C,iDAAyD;AAAhD,mHAAA,oBAAoB,OAAA;AAC7B,iDAA4N;AAAnN,iHAAA,kBAAkB,OAAA;AAAE,kHAAA,mBAAmB,OAAA;AAAE,iHAAA,kBAAkB,OAAA;AAAE,oHAAA,qBAAqB,OAAA;AAAE,+GAAA,gBAAgB,OAAA;AAAE,gHAAA,iBAAiB,OAAA;AAAE,wHAAA,yBAAyB,OAAA;AAAE,gHAAA,iBAAiB,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fnndsc/salsa",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.5",
|
|
4
4
|
"description": "Shared Application Logic and Service Assets for ChRIS",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"adm-zip": "npm:empty-npm-package@1.0.0"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@fnndsc/cumin": "^3.30.
|
|
64
|
-
"@fnndsc/fond": "^0.6.
|
|
63
|
+
"@fnndsc/cumin": "^3.30.6",
|
|
64
|
+
"@fnndsc/fond": "^0.6.2",
|
|
65
65
|
"ajv": "^8.17.1",
|
|
66
66
|
"axios": "^1.6.8",
|
|
67
67
|
"dcmjs": "^0.52.0",
|