@fnndsc/salsa 3.2.4
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/LICENSE +21 -0
- package/README.md +164 -0
- package/dist/compute/index.d.ts +17 -0
- package/dist/compute/index.js +33 -0
- package/dist/compute/index.js.map +1 -0
- package/dist/connect/index.d.ts +25 -0
- package/dist/connect/index.js +27 -0
- package/dist/connect/index.js.map +1 -0
- package/dist/context/index.d.ts +38 -0
- package/dist/context/index.js +58 -0
- package/dist/context/index.js.map +1 -0
- package/dist/feeds/index.d.ts +60 -0
- package/dist/feeds/index.js +101 -0
- package/dist/feeds/index.js.map +1 -0
- package/dist/files/index.d.ts +179 -0
- package/dist/files/index.js +562 -0
- package/dist/files/index.js.map +1 -0
- package/dist/files/pacs_content.d.ts +29 -0
- package/dist/files/pacs_content.js +121 -0
- package/dist/files/pacs_content.js.map +1 -0
- package/dist/files/pipeline_content.d.ts +22 -0
- package/dist/files/pipeline_content.js +31 -0
- package/dist/files/pipeline_content.js.map +1 -0
- package/dist/files/regular_content.d.ts +33 -0
- package/dist/files/regular_content.js +177 -0
- package/dist/files/regular_content.js.map +1 -0
- package/dist/groups/index.d.ts +21 -0
- package/dist/groups/index.js +37 -0
- package/dist/groups/index.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/jobs/index.d.ts +6 -0
- package/dist/jobs/index.js +17 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/jobOps.d.ts +108 -0
- package/dist/jobs/jobOps.js +307 -0
- package/dist/jobs/jobOps.js.map +1 -0
- package/dist/pacs/index.d.ts +64 -0
- package/dist/pacs/index.js +91 -0
- package/dist/pacs/index.js.map +1 -0
- package/dist/pacs/resultDecode.d.ts +13 -0
- package/dist/pacs/resultDecode.js +19 -0
- package/dist/pacs/resultDecode.js.map +1 -0
- package/dist/pipelines/index.d.ts +58 -0
- package/dist/pipelines/index.js +194 -0
- package/dist/pipelines/index.js.map +1 -0
- package/dist/plugininstances/index.d.ts +15 -0
- package/dist/plugininstances/index.js +27 -0
- package/dist/plugininstances/index.js.map +1 -0
- package/dist/pluginmetas/index.d.ts +21 -0
- package/dist/pluginmetas/index.js +37 -0
- package/dist/pluginmetas/index.js.map +1 -0
- package/dist/plugins/index.d.ts +118 -0
- package/dist/plugins/index.js +247 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/internal/plugin_executeContinueFeed.d.ts +17 -0
- package/dist/plugins/internal/plugin_executeContinueFeed.js +65 -0
- package/dist/plugins/internal/plugin_executeContinueFeed.js.map +1 -0
- package/dist/plugins/internal/plugin_executeNewFeed.d.ts +32 -0
- package/dist/plugins/internal/plugin_executeNewFeed.js +97 -0
- package/dist/plugins/internal/plugin_executeNewFeed.js.map +1 -0
- package/dist/plugins/peer_search.d.ts +65 -0
- package/dist/plugins/peer_search.js +94 -0
- package/dist/plugins/peer_search.js.map +1 -0
- package/dist/plugins/plugin_executeInPlace.d.ts +69 -0
- package/dist/plugins/plugin_executeInPlace.js +66 -0
- package/dist/plugins/plugin_executeInPlace.js.map +1 -0
- package/dist/plugins/plugin_register.d.ts +64 -0
- package/dist/plugins/plugin_register.js +121 -0
- package/dist/plugins/plugin_register.js.map +1 -0
- package/dist/plugins/store_import.d.ts +64 -0
- package/dist/plugins/store_import.js +196 -0
- package/dist/plugins/store_import.js.map +1 -0
- package/dist/store/index.d.ts +15 -0
- package/dist/store/index.js +37 -0
- package/dist/store/index.js.map +1 -0
- package/dist/tags/index.d.ts +21 -0
- package/dist/tags/index.js +37 -0
- package/dist/tags/index.js.map +1 -0
- package/dist/vfs/dispatcher.d.ts +83 -0
- package/dist/vfs/dispatcher.js +192 -0
- package/dist/vfs/dispatcher.js.map +1 -0
- package/dist/vfs/index.d.ts +9 -0
- package/dist/vfs/index.js +26 -0
- package/dist/vfs/index.js.map +1 -0
- package/dist/vfs/provider.d.ts +80 -0
- package/dist/vfs/provider.js +11 -0
- package/dist/vfs/provider.js.map +1 -0
- package/dist/vfs/providers/etc.d.ts +44 -0
- package/dist/vfs/providers/etc.js +119 -0
- package/dist/vfs/providers/etc.js.map +1 -0
- package/dist/vfs/providers/native.d.ts +34 -0
- package/dist/vfs/providers/native.js +168 -0
- package/dist/vfs/providers/native.js.map +1 -0
- package/dist/vfs/providers/pacs.d.ts +56 -0
- package/dist/vfs/providers/pacs.js +413 -0
- package/dist/vfs/providers/pacs.js.map +1 -0
- package/dist/vfs/providers/pacsHelpers.d.ts +27 -0
- package/dist/vfs/providers/pacsHelpers.js +108 -0
- package/dist/vfs/providers/pacsHelpers.js.map +1 -0
- package/dist/vfs/providers/pacs_content.d.ts +27 -0
- package/dist/vfs/providers/pacs_content.js +137 -0
- package/dist/vfs/providers/pacs_content.js.map +1 -0
- package/dist/vfs/providers/proc.d.ts +62 -0
- package/dist/vfs/providers/proc.js +478 -0
- package/dist/vfs/providers/proc.js.map +1 -0
- package/dist/workflows/index.d.ts +21 -0
- package/dist/workflows/index.js +37 -0
- package/dist/workflows/index.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file File group resolution and content dispatch across file source types.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.files_listRecursive = files_listRecursive;
|
|
42
|
+
exports.files_copyRecursively = files_copyRecursively;
|
|
43
|
+
exports.files_create = files_create;
|
|
44
|
+
exports.files_touch = files_touch;
|
|
45
|
+
exports.files_copy = files_copy;
|
|
46
|
+
exports.files_move = files_move;
|
|
47
|
+
exports.files_uploadPath = files_uploadPath;
|
|
48
|
+
exports.files_mkdir = files_mkdir;
|
|
49
|
+
exports.files_getGroup = files_getGroup;
|
|
50
|
+
exports.files_list = files_list;
|
|
51
|
+
exports.files_listAll = files_listAll;
|
|
52
|
+
exports.fileFields_get = fileFields_get;
|
|
53
|
+
exports.files_delete = files_delete;
|
|
54
|
+
exports.files_getSingle = files_getSingle;
|
|
55
|
+
exports.files_share = files_share;
|
|
56
|
+
exports.fileContent_get = fileContent_get;
|
|
57
|
+
exports.fileContent_getBinary = fileContent_getBinary;
|
|
58
|
+
exports.fileContent_getBinaryStream = fileContent_getBinaryStream;
|
|
59
|
+
const path = __importStar(require("path"));
|
|
60
|
+
const cumin_1 = require("@fnndsc/cumin");
|
|
61
|
+
const pipeline_content_1 = require("./pipeline_content");
|
|
62
|
+
const regular_content_1 = require("./regular_content");
|
|
63
|
+
const pacs_content_1 = require("./pacs_content");
|
|
64
|
+
const dispatcher_js_1 = require("../vfs/dispatcher.js");
|
|
65
|
+
/**
|
|
66
|
+
* Recursively lists all files and directories under a given ChRIS path.
|
|
67
|
+
*
|
|
68
|
+
* @param rootPath - The starting directory path.
|
|
69
|
+
* @returns A Promise resolving to an array of FsItem objects.
|
|
70
|
+
*/
|
|
71
|
+
async function files_listRecursive(rootPath) {
|
|
72
|
+
let items = [];
|
|
73
|
+
// 1. List files in current directory
|
|
74
|
+
const filesGroup = await files_getGroup('files', rootPath);
|
|
75
|
+
if (filesGroup) {
|
|
76
|
+
const fileResults = await filesGroup.asset.resources_getAll();
|
|
77
|
+
if (fileResults && fileResults.tableData) {
|
|
78
|
+
fileResults.tableData.forEach((f) => {
|
|
79
|
+
items.push({
|
|
80
|
+
path: f['fname'] || '', // fname is the full path
|
|
81
|
+
type: 'file',
|
|
82
|
+
size: f['fsize'] || 0
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// 2. List subdirectories
|
|
88
|
+
const dirsGroup = await files_getGroup('dirs', rootPath);
|
|
89
|
+
if (dirsGroup) {
|
|
90
|
+
const dirResults = await dirsGroup.asset.resources_getAll();
|
|
91
|
+
if (dirResults && dirResults.tableData) {
|
|
92
|
+
for (const d of dirResults.tableData) {
|
|
93
|
+
const dirPath = d.path;
|
|
94
|
+
items.push({ path: dirPath, type: 'dir' });
|
|
95
|
+
// Recurse
|
|
96
|
+
const subItems = await files_listRecursive(dirPath);
|
|
97
|
+
items = items.concat(subItems);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return items;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Recursively copies a directory from source to destination within ChRIS.
|
|
105
|
+
*
|
|
106
|
+
* @param srcPath - The source directory path.
|
|
107
|
+
* @param destPath - The destination directory path (the parent + new dir name).
|
|
108
|
+
* @returns A Promise resolving to true on success, false on failure.
|
|
109
|
+
*/
|
|
110
|
+
async function files_copyRecursively(srcPath, destPath) {
|
|
111
|
+
try {
|
|
112
|
+
// Ensure destination directory exists (mkdir -p behavior ideally, but files_mkdir is shallow?)
|
|
113
|
+
// Actually files_mkdir assumes parent exists.
|
|
114
|
+
// For a copy, we create the target root first.
|
|
115
|
+
await files_mkdir(destPath);
|
|
116
|
+
const items = await files_listRecursive(srcPath);
|
|
117
|
+
let successCount = 0;
|
|
118
|
+
let failCount = 0;
|
|
119
|
+
for (const item of items) {
|
|
120
|
+
// Normalize item.path to ensure it has a leading slash
|
|
121
|
+
const normalizedItemPath = item.path.startsWith('/') ? item.path : '/' + item.path;
|
|
122
|
+
const relativePath = normalizedItemPath.substring(srcPath.length).replace(/^\//, '');
|
|
123
|
+
const targetPath = path.posix.join(destPath, relativePath); // Use posix for ChRIS paths
|
|
124
|
+
if (item.type === 'dir') {
|
|
125
|
+
console.log(` Creating directory: ${targetPath}`);
|
|
126
|
+
const created = await files_mkdir(targetPath);
|
|
127
|
+
if (!created) {
|
|
128
|
+
console.warn(` Warning: Failed to create directory ${targetPath}`);
|
|
129
|
+
failCount++;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
successCount++;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else if (item.type === 'file') {
|
|
136
|
+
console.log(` Copying file: ${path.posix.basename(normalizedItemPath)}`);
|
|
137
|
+
const copied = await files_copy(normalizedItemPath, targetPath);
|
|
138
|
+
if (!copied) {
|
|
139
|
+
console.warn(` Warning: Failed to copy file ${normalizedItemPath}`);
|
|
140
|
+
failCount++;
|
|
141
|
+
// Continue trying to copy other files instead of aborting
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
successCount++;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
console.log(`Copied ${successCount} items, ${failCount} failed`);
|
|
149
|
+
return failCount === 0;
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
153
|
+
cumin_1.errorStack.stack_push("error", `Recursive copy failed: ${msg}`);
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Resolves a file ID from a ChRIS path.
|
|
159
|
+
*
|
|
160
|
+
* @param srcPath - The absolute ChRIS file path.
|
|
161
|
+
* @returns Result containing the file ID or Err on failure.
|
|
162
|
+
*/
|
|
163
|
+
async function fileId_resolve(srcPath) {
|
|
164
|
+
const srcDir = path.posix.dirname(srcPath);
|
|
165
|
+
const srcName = path.posix.basename(srcPath);
|
|
166
|
+
const group = await files_getGroup('files', srcDir);
|
|
167
|
+
if (!group) {
|
|
168
|
+
cumin_1.errorStack.stack_push("error", `Could not access source directory: ${srcDir}`);
|
|
169
|
+
return (0, cumin_1.Err)();
|
|
170
|
+
}
|
|
171
|
+
const results = await group.asset.resources_getAll();
|
|
172
|
+
let fileId;
|
|
173
|
+
if (results && results.tableData) {
|
|
174
|
+
const match = results.tableData.find((f) => {
|
|
175
|
+
const fname = f.fname || '';
|
|
176
|
+
return fname === srcPath || path.posix.basename(fname) === srcName;
|
|
177
|
+
});
|
|
178
|
+
if (match && match.id !== undefined) {
|
|
179
|
+
fileId = Number(match.id);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (fileId === undefined) {
|
|
183
|
+
cumin_1.errorStack.stack_push("error", `Source file not found: ${srcPath}`);
|
|
184
|
+
return (0, cumin_1.Err)();
|
|
185
|
+
}
|
|
186
|
+
return (0, cumin_1.Ok)(fileId);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Determines whether a given ChRIS path refers to a directory.
|
|
190
|
+
*
|
|
191
|
+
* @param targetPath - The absolute ChRIS path to check.
|
|
192
|
+
* @returns Promise resolving to true if the path is a directory, false otherwise.
|
|
193
|
+
*/
|
|
194
|
+
async function path_isDir(targetPath) {
|
|
195
|
+
const parent = path.posix.dirname(targetPath);
|
|
196
|
+
const name = path.posix.basename(targetPath);
|
|
197
|
+
const results = await files_listAll({ limit: 1000, offset: 0 }, "dirs", parent);
|
|
198
|
+
if (!results || !results.tableData) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
return results.tableData.some((entry) => {
|
|
202
|
+
const candidate = entry.path || entry.fname || "";
|
|
203
|
+
return candidate === targetPath || path.posix.basename(candidate) === name;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Uploads content to a specified ChRIS path, effectively creating or overwriting a file.
|
|
208
|
+
*
|
|
209
|
+
* @param content - The content to upload (string, Buffer, or Blob).
|
|
210
|
+
* @param pathStr - The ChRIS path for the new file.
|
|
211
|
+
* @returns A Promise resolving to true on success, false on failure.
|
|
212
|
+
*/
|
|
213
|
+
async function files_create(content, pathStr) {
|
|
214
|
+
try {
|
|
215
|
+
let uploadContent;
|
|
216
|
+
if (typeof content === 'string') {
|
|
217
|
+
uploadContent = new Blob([content]);
|
|
218
|
+
}
|
|
219
|
+
else if (Buffer.isBuffer(content)) {
|
|
220
|
+
uploadContent = new Blob([new Uint8Array(content)]); // Convert Buffer to Uint8Array for Blob
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
uploadContent = content; // Assume it's already a Blob
|
|
224
|
+
}
|
|
225
|
+
// Split path into directory and filename
|
|
226
|
+
const dir = path.posix.dirname(pathStr);
|
|
227
|
+
const name = path.posix.basename(pathStr);
|
|
228
|
+
const success = await cumin_1.chrisIO.file_upload(uploadContent, dir, name);
|
|
229
|
+
if (!success) {
|
|
230
|
+
cumin_1.errorStack.stack_push("error", `File upload failed for ${pathStr}.`);
|
|
231
|
+
}
|
|
232
|
+
return success;
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
236
|
+
cumin_1.errorStack.stack_push("error", `File creation failed for ${pathStr}: ${msg}`);
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Creates a new empty file at the specified path (like Unix touch).
|
|
242
|
+
* Optionally creates the file with specified content.
|
|
243
|
+
*
|
|
244
|
+
* @param path - The ChRIS path for the new file.
|
|
245
|
+
* @param content - Optional content to write to the file (string, Buffer, or Blob).
|
|
246
|
+
* @returns A Promise resolving to true on success, false on failure.
|
|
247
|
+
*/
|
|
248
|
+
async function files_touch(path, content) {
|
|
249
|
+
const fileContent = content ?? new Blob([""]);
|
|
250
|
+
return await files_create(fileContent, path);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Copies a single file from one ChRIS path to another.
|
|
254
|
+
*
|
|
255
|
+
* @param srcPath - The full path to the source file.
|
|
256
|
+
* @param destPath - The full path to the destination file (including filename).
|
|
257
|
+
* @returns A Promise resolving to true on success, false on failure.
|
|
258
|
+
*/
|
|
259
|
+
async function files_copy(srcPath, destPath) {
|
|
260
|
+
try {
|
|
261
|
+
// 1. Resolve source file to get ID (needed for download)
|
|
262
|
+
const fileIdResult = await fileId_resolve(srcPath);
|
|
263
|
+
if (!fileIdResult.ok) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
const fileId = fileIdResult.value;
|
|
267
|
+
// 2. Download content
|
|
268
|
+
const content = await cumin_1.chrisIO.file_download(fileId);
|
|
269
|
+
if (content === null) {
|
|
270
|
+
cumin_1.errorStack.stack_push("error", `Failed to download source file (ID: ${fileId}): ${srcPath}`);
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
// 3. Upload to destination
|
|
274
|
+
// files_create handles Blob/Buffer conversion and path splitting
|
|
275
|
+
const uploadSuccess = await files_create(content, destPath);
|
|
276
|
+
if (!uploadSuccess) {
|
|
277
|
+
const lastError = cumin_1.errorStack.stack_pop();
|
|
278
|
+
if (lastError) {
|
|
279
|
+
console.error(` Error: ${lastError.message}`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return uploadSuccess;
|
|
283
|
+
}
|
|
284
|
+
catch (error) {
|
|
285
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
286
|
+
cumin_1.errorStack.stack_push("error", `Copy failed from ${srcPath} to ${destPath}: ${msg}`);
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Moves a file or directory by updating its path on the server.
|
|
292
|
+
*
|
|
293
|
+
* For directories, this performs a server-side rename without data transfer.
|
|
294
|
+
* For files, the file ID is resolved and the path is updated.
|
|
295
|
+
*
|
|
296
|
+
* @param srcPath - The source file or directory path.
|
|
297
|
+
* @param destPath - The target path. If an existing directory or trailing slash is provided,
|
|
298
|
+
* the source basename is appended.
|
|
299
|
+
* @returns Promise resolving to true on success, false on failure.
|
|
300
|
+
*/
|
|
301
|
+
async function files_move(srcPath, destPath) {
|
|
302
|
+
try {
|
|
303
|
+
const srcIsDir = await path_isDir(srcPath);
|
|
304
|
+
const destIsDir = await path_isDir(destPath);
|
|
305
|
+
const destLooksDir = destPath.endsWith("/");
|
|
306
|
+
const finalDest = (destIsDir || destLooksDir)
|
|
307
|
+
? path.posix.join(destPath, path.posix.basename(srcPath))
|
|
308
|
+
: destPath;
|
|
309
|
+
if (srcIsDir) {
|
|
310
|
+
const moveResult = await cumin_1.chrisIO.folder_moveByPath(srcPath, finalDest);
|
|
311
|
+
return moveResult.ok && moveResult.value;
|
|
312
|
+
}
|
|
313
|
+
const fileIdResult = await fileId_resolve(srcPath);
|
|
314
|
+
if (!fileIdResult.ok) {
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
const moveResult = await cumin_1.chrisIO.file_moveById(fileIdResult.value, finalDest);
|
|
318
|
+
return moveResult.ok && moveResult.value;
|
|
319
|
+
}
|
|
320
|
+
catch (error) {
|
|
321
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
322
|
+
cumin_1.errorStack.stack_push("error", `Move failed from ${srcPath} to ${destPath}: ${msg}`);
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Uploads a local file or directory to ChRIS recursively.
|
|
328
|
+
*
|
|
329
|
+
* @param localPath - The local filesystem path.
|
|
330
|
+
* @param remotePath - The ChRIS destination path.
|
|
331
|
+
* @returns Promise<boolean> success.
|
|
332
|
+
*/
|
|
333
|
+
async function files_uploadPath(localPath, remotePath) {
|
|
334
|
+
return await cumin_1.chrisIO.uploadLocalPath(localPath, remotePath);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Creates a new folder (directory) at the specified ChRIS path.
|
|
338
|
+
*
|
|
339
|
+
* @param folderPath - The full ChRIS path for the new folder.
|
|
340
|
+
* @returns A Promise resolving to true on success, false on failure.
|
|
341
|
+
*/
|
|
342
|
+
async function files_mkdir(folderPath) {
|
|
343
|
+
const result = await cumin_1.chrisIO.folder_create(folderPath);
|
|
344
|
+
if (!result.ok) {
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
// result.value is true if created, false if already exists
|
|
348
|
+
// Both cases are considered success
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Creates a ChRISEmbeddedResourceGroup for a specific asset type (files, links, dirs).
|
|
353
|
+
* This function encapsulates the logic from `FileController.handler_create`.
|
|
354
|
+
*
|
|
355
|
+
* @param assetName - The type of asset ('files', 'links', 'dirs').
|
|
356
|
+
* @param path - Optional ChRIS path. Defaults to current folder context.
|
|
357
|
+
* @returns A Promise resolving to a ChRISEmbeddedResourceGroup instance, or null on error.
|
|
358
|
+
*/
|
|
359
|
+
async function files_getGroup(assetName, path) {
|
|
360
|
+
if (!path) {
|
|
361
|
+
const fileContext = await cumin_1.chrisContext.current_get(cumin_1.Context.ChRISfolder);
|
|
362
|
+
path = fileContext ? fileContext : "/";
|
|
363
|
+
}
|
|
364
|
+
let chrisFileSystemGroup = null;
|
|
365
|
+
try {
|
|
366
|
+
switch (assetName) {
|
|
367
|
+
case "files":
|
|
368
|
+
chrisFileSystemGroup = (await (0, cumin_1.objContext_create)("ChRISFilesContext", `folder:${path}`));
|
|
369
|
+
break;
|
|
370
|
+
case "links":
|
|
371
|
+
chrisFileSystemGroup = (await (0, cumin_1.objContext_create)("ChRISLinksContext", `folder:${path}`));
|
|
372
|
+
break;
|
|
373
|
+
case "dirs":
|
|
374
|
+
chrisFileSystemGroup = (await (0, cumin_1.objContext_create)("ChRISDirsContext", `folder:${path}`));
|
|
375
|
+
break;
|
|
376
|
+
default:
|
|
377
|
+
cumin_1.errorStack.stack_push("error", `Unsupported asset type: ${assetName}`);
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
if (!chrisFileSystemGroup) {
|
|
381
|
+
cumin_1.errorStack.stack_push("error", `Failed to initialize ChRIS context for ${assetName} at ${path}`);
|
|
382
|
+
return null;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
catch (error) {
|
|
386
|
+
cumin_1.errorStack.stack_push("error", `Error creating ChRISEmbeddedResourceGroup for ${assetName}: ${error}`);
|
|
387
|
+
return null;
|
|
388
|
+
}
|
|
389
|
+
return chrisFileSystemGroup;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* List files, links, or directories based on options.
|
|
393
|
+
*
|
|
394
|
+
* @param options - Search and pagination options.
|
|
395
|
+
* @param assetName - The type of asset to list ('files', 'links', 'dirs').
|
|
396
|
+
* @param path - Optional ChRIS path. Defaults to current folder context.
|
|
397
|
+
* @returns A Promise resolving to FilteredResourceData or null.
|
|
398
|
+
*/
|
|
399
|
+
async function files_list(options, assetName = "files", path) {
|
|
400
|
+
const group = await files_getGroup(assetName, path);
|
|
401
|
+
if (!group) {
|
|
402
|
+
return null;
|
|
403
|
+
}
|
|
404
|
+
return await group.asset.resources_listAndFilterByOptions(options);
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* List *all* files, links, or directories by automatically handling pagination.
|
|
408
|
+
*
|
|
409
|
+
* @param options - Search options (limit and offset will be managed internally).
|
|
410
|
+
* @param assetName - The type of asset to list ('files', 'links', 'dirs').
|
|
411
|
+
* @param path - Optional ChRIS path. Defaults to current folder context.
|
|
412
|
+
* @returns A Promise resolving to FilteredResourceData containing all matching assets, or null.
|
|
413
|
+
*/
|
|
414
|
+
async function files_listAll(options, assetName = "files", path) {
|
|
415
|
+
const group = await files_getGroup(assetName, path);
|
|
416
|
+
if (!group) {
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
return await group.asset.resources_getAll(options);
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Get the list of available fields for files, links, or directories.
|
|
423
|
+
*
|
|
424
|
+
* @param assetName - The type of asset ('files', 'links', 'dirs').
|
|
425
|
+
* @returns A Promise resolving to an array of field names or null.
|
|
426
|
+
*/
|
|
427
|
+
async function fileFields_get(assetName = "files") {
|
|
428
|
+
const group = await files_getGroup(assetName);
|
|
429
|
+
if (!group) {
|
|
430
|
+
return null;
|
|
431
|
+
}
|
|
432
|
+
const results = await group.asset.resourceFields_get();
|
|
433
|
+
return results ? results.fields : null;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Deletes a file, link, or directory by its ID.
|
|
437
|
+
*
|
|
438
|
+
* @param id - The ID of the asset to delete.
|
|
439
|
+
* @param assetName - The type of asset ('files', 'links', 'dirs').
|
|
440
|
+
* @returns A Promise resolving to true on success, false on failure.
|
|
441
|
+
*/
|
|
442
|
+
async function files_delete(id, assetName = "files") {
|
|
443
|
+
const group = await files_getGroup(assetName);
|
|
444
|
+
if (!group) {
|
|
445
|
+
return false;
|
|
446
|
+
}
|
|
447
|
+
return await group.asset.resourceItem_delete(id);
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Creates a ChRISEmbeddedResourceGroup for a single file.
|
|
451
|
+
* This function encapsulates the logic from `FileController.member_create`.
|
|
452
|
+
*
|
|
453
|
+
* @param path - The ChRIS path to the file.
|
|
454
|
+
* @returns A Promise resolving to a ChRISEmbeddedResourceGroup instance, or null on error.
|
|
455
|
+
*/
|
|
456
|
+
async function files_getSingle(path) {
|
|
457
|
+
let chrisFilesGroup = null;
|
|
458
|
+
try {
|
|
459
|
+
chrisFilesGroup = (await (0, cumin_1.objContext_create)("ChRISFilesContext", `folder:${path}`));
|
|
460
|
+
if (!chrisFilesGroup) {
|
|
461
|
+
cumin_1.errorStack.stack_push("error", `Failed to create ChRISFilesContext for path: ${path}`);
|
|
462
|
+
return null;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
catch (error) {
|
|
466
|
+
cumin_1.errorStack.stack_push("error", `Error creating ChRISFilesContext for path ${path}: ${error}`);
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
469
|
+
return chrisFilesGroup;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Shares files in ChRIS.
|
|
473
|
+
*
|
|
474
|
+
* @param fileId - The ID of the file to share.
|
|
475
|
+
* @param options - Options for sharing (e.g., user, permissions).
|
|
476
|
+
* @returns A Promise resolving to true.
|
|
477
|
+
*/
|
|
478
|
+
async function files_share(fileId, options) {
|
|
479
|
+
// Implement actual sharing logic using cumin/chrisapi
|
|
480
|
+
console.log(`Sharing file ${fileId} with options:`, options);
|
|
481
|
+
return Promise.resolve(true);
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Retrieves the content of a file by its path.
|
|
485
|
+
*
|
|
486
|
+
* Router function that delegates to specialized handlers based on path type.
|
|
487
|
+
*
|
|
488
|
+
* @param filePath - The full ChRIS path to the file.
|
|
489
|
+
* @returns A Result containing the content string or error.
|
|
490
|
+
*/
|
|
491
|
+
async function fileContent_get(filePath) {
|
|
492
|
+
const provider = dispatcher_js_1.vfsDispatcher.provider_get(filePath);
|
|
493
|
+
if (provider && provider.prefix !== '') {
|
|
494
|
+
return dispatcher_js_1.vfsDispatcher.read(filePath);
|
|
495
|
+
}
|
|
496
|
+
if (filePath.startsWith('/PIPELINES/')) {
|
|
497
|
+
return (0, pipeline_content_1.fileContent_getPipeline)(filePath);
|
|
498
|
+
}
|
|
499
|
+
if (filePath.startsWith('/SERVICES/PACS/')) {
|
|
500
|
+
return (0, pacs_content_1.fileContent_getPACS)(filePath);
|
|
501
|
+
}
|
|
502
|
+
return (0, regular_content_1.fileContent_getRegular)(filePath);
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Retrieves the binary content of a file by its path.
|
|
506
|
+
*
|
|
507
|
+
* Router function that delegates to specialized handlers based on path type.
|
|
508
|
+
* Returns raw Buffer instead of converting to UTF-8 string.
|
|
509
|
+
*
|
|
510
|
+
* @param filePath - The full ChRIS path to the file.
|
|
511
|
+
* @returns A Result containing the content Buffer or error.
|
|
512
|
+
*/
|
|
513
|
+
async function fileContent_getBinary(filePath) {
|
|
514
|
+
const provider = dispatcher_js_1.vfsDispatcher.provider_get(filePath);
|
|
515
|
+
if (provider && provider.prefix !== '') {
|
|
516
|
+
return dispatcher_js_1.vfsDispatcher.readBinary(filePath);
|
|
517
|
+
}
|
|
518
|
+
if (filePath.startsWith('/PIPELINES/')) {
|
|
519
|
+
return (0, pipeline_content_1.fileContent_getPipelineBinary)(filePath);
|
|
520
|
+
}
|
|
521
|
+
if (filePath.startsWith('/SERVICES/PACS/')) {
|
|
522
|
+
return (0, pacs_content_1.fileContent_getPACSBinary)(filePath);
|
|
523
|
+
}
|
|
524
|
+
return (0, regular_content_1.fileContent_getRegularBinary)(filePath);
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Retrieves the binary content of a file by its path as a stream/blob.
|
|
528
|
+
*
|
|
529
|
+
* Router function that delegates to specialized handlers based on path type.
|
|
530
|
+
*
|
|
531
|
+
* @param filePath - The full ChRIS path to the file.
|
|
532
|
+
* @returns A Result containing the stream/blob and metadata or error.
|
|
533
|
+
*/
|
|
534
|
+
async function fileContent_getBinaryStream(filePath) {
|
|
535
|
+
const provider = dispatcher_js_1.vfsDispatcher.provider_get(filePath);
|
|
536
|
+
if (provider && provider.prefix !== '/') {
|
|
537
|
+
return dispatcher_js_1.vfsDispatcher.readBinary(filePath).then((res) => {
|
|
538
|
+
if (res.ok) {
|
|
539
|
+
return (0, cumin_1.Ok)({ stream: res.value, size: res.value.length });
|
|
540
|
+
}
|
|
541
|
+
return (0, cumin_1.Err)();
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
if (filePath.startsWith('/PIPELINES/')) {
|
|
545
|
+
return (0, pipeline_content_1.fileContent_getPipelineBinary)(filePath).then((res) => {
|
|
546
|
+
if (res.ok) {
|
|
547
|
+
return (0, cumin_1.Ok)({ stream: res.value, size: res.value.length });
|
|
548
|
+
}
|
|
549
|
+
return (0, cumin_1.Err)();
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
if (filePath.startsWith('/SERVICES/PACS/')) {
|
|
553
|
+
return (0, pacs_content_1.fileContent_getPACSBinary)(filePath).then((res) => {
|
|
554
|
+
if (res.ok) {
|
|
555
|
+
return (0, cumin_1.Ok)({ stream: res.value, size: res.value.length });
|
|
556
|
+
}
|
|
557
|
+
return (0, cumin_1.Err)();
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
return (0, regular_content_1.fileContent_getRegularStream)(filePath);
|
|
561
|
+
}
|
|
562
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/files/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCH,kDAmCC;AASD,sDA+CC;AAmED,oCAyBC;AAUD,kCAMC;AASD,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result } from "@fnndsc/cumin";
|
|
7
|
+
/**
|
|
8
|
+
* Fetches the content of a PACS file (DICOM).
|
|
9
|
+
*
|
|
10
|
+
* Path structure: /SERVICES/PACS/<service>/<patient>/<study>/<series>/<file>.dcm
|
|
11
|
+
* Example: /SERVICES/PACS/PACSDCM/7654321-EVANS-19861111/.../0168-1.3...dcm
|
|
12
|
+
*
|
|
13
|
+
* PACS files appear in directory listings but must be downloaded through
|
|
14
|
+
* the PACSFile API instead of the regular file download endpoint.
|
|
15
|
+
*
|
|
16
|
+
* @param filePath - The full path to the PACS file.
|
|
17
|
+
* @returns A Result containing the file content as a string, or an error.
|
|
18
|
+
*/
|
|
19
|
+
export declare function fileContent_getPACS(filePath: string): Promise<Result<string>>;
|
|
20
|
+
/**
|
|
21
|
+
* Fetches the binary content of a PACS file (DICOM).
|
|
22
|
+
*
|
|
23
|
+
* Same as fileContent_getPACS but returns raw Buffer instead of string.
|
|
24
|
+
* Use this for binary files like DICOM (.dcm) that should not be converted to UTF-8.
|
|
25
|
+
*
|
|
26
|
+
* @param filePath - The full path to the PACS file.
|
|
27
|
+
* @returns A Result containing the file content as a Buffer, or an error.
|
|
28
|
+
*/
|
|
29
|
+
export declare function fileContent_getPACSBinary(filePath: string): Promise<Result<Buffer>>;
|