@fnndsc/cumin 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 +78 -0
- package/dist/activities/chrisActivity.d.ts +19 -0
- package/dist/activities/chrisActivity.js +29 -0
- package/dist/activities/chrisActivity.js.map +1 -0
- package/dist/cache/index.d.ts +9 -0
- package/dist/cache/index.js +15 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/listCache.d.ts +182 -0
- package/dist/cache/listCache.js +266 -0
- package/dist/cache/listCache.js.map +1 -0
- package/dist/cache/procCache.d.ts +150 -0
- package/dist/cache/procCache.js +257 -0
- package/dist/cache/procCache.js.map +1 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.js +43 -0
- package/dist/cli.js.map +1 -0
- package/dist/compute/computeResources.d.ts +65 -0
- package/dist/compute/computeResources.js +113 -0
- package/dist/compute/computeResources.js.map +1 -0
- package/dist/config/config.d.ts +221 -0
- package/dist/config/config.js +350 -0
- package/dist/config/config.js.map +1 -0
- package/dist/connect/chrisConnection.d.ts +121 -0
- package/dist/connect/chrisConnection.js +303 -0
- package/dist/connect/chrisConnection.js.map +1 -0
- package/dist/context/chrisContext.d.ts +110 -0
- package/dist/context/chrisContext.js +324 -0
- package/dist/context/chrisContext.js.map +1 -0
- package/dist/error/errorStack.d.ts +115 -0
- package/dist/error/errorStack.js +175 -0
- package/dist/error/errorStack.js.map +1 -0
- package/dist/feeds/chrisFeed.d.ts +188 -0
- package/dist/feeds/chrisFeed.js +432 -0
- package/dist/feeds/chrisFeed.js.map +1 -0
- package/dist/filebrowser/chrisFileBrowser.d.ts +77 -0
- package/dist/filebrowser/chrisFileBrowser.js +134 -0
- package/dist/filebrowser/chrisFileBrowser.js.map +1 -0
- package/dist/filebrowser/chrisFiles.d.ts +67 -0
- package/dist/filebrowser/chrisFiles.js +130 -0
- package/dist/filebrowser/chrisFiles.js.map +1 -0
- package/dist/filebrowser/chrisPACS.d.ts +43 -0
- package/dist/filebrowser/chrisPACS.js +103 -0
- package/dist/filebrowser/chrisPACS.js.map +1 -0
- package/dist/filebrowser/chrisPipeline.d.ts +47 -0
- package/dist/filebrowser/chrisPipeline.js +118 -0
- package/dist/filebrowser/chrisPipeline.js.map +1 -0
- package/dist/groups/chrisGroups.d.ts +11 -0
- package/dist/groups/chrisGroups.js +18 -0
- package/dist/groups/chrisGroups.js.map +1 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.js +86 -0
- package/dist/index.js.map +1 -0
- package/dist/io/browser_io.d.ts +97 -0
- package/dist/io/browser_io.js +149 -0
- package/dist/io/browser_io.js.map +1 -0
- package/dist/io/chrisIO.d.ts +110 -0
- package/dist/io/chrisIO.js +415 -0
- package/dist/io/chrisIO.js.map +1 -0
- package/dist/io/io.d.ts +21 -0
- package/dist/io/io.js +6 -0
- package/dist/io/io.js.map +1 -0
- package/dist/io/node_io.d.ts +30 -0
- package/dist/io/node_io.js +188 -0
- package/dist/io/node_io.js.map +1 -0
- package/dist/jobs/chrisJob.d.ts +43 -0
- package/dist/jobs/chrisJob.js +169 -0
- package/dist/jobs/chrisJob.js.map +1 -0
- package/dist/jobs/index.d.ts +7 -0
- package/dist/jobs/index.js +24 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/jobMonitor.d.ts +46 -0
- package/dist/jobs/jobMonitor.js +102 -0
- package/dist/jobs/jobMonitor.js.map +1 -0
- package/dist/pacs/chrisPACS.d.ts +200 -0
- package/dist/pacs/chrisPACS.js +562 -0
- package/dist/pacs/chrisPACS.js.map +1 -0
- package/dist/path/chrisPath.d.ts +78 -0
- package/dist/path/chrisPath.js +190 -0
- package/dist/path/chrisPath.js.map +1 -0
- package/dist/pipelines/chrisPipeline.d.ts +86 -0
- package/dist/pipelines/chrisPipeline.js +180 -0
- package/dist/pipelines/chrisPipeline.js.map +1 -0
- package/dist/pluginmetas/chrisPluginMetas.d.ts +11 -0
- package/dist/pluginmetas/chrisPluginMetas.js +18 -0
- package/dist/pluginmetas/chrisPluginMetas.js.map +1 -0
- package/dist/plugins/chrisPluginMetaPlugins.d.ts +12 -0
- package/dist/plugins/chrisPluginMetaPlugins.js +19 -0
- package/dist/plugins/chrisPluginMetaPlugins.js.map +1 -0
- package/dist/plugins/chrisPlugins.d.ts +127 -0
- package/dist/plugins/chrisPlugins.js +528 -0
- package/dist/plugins/chrisPlugins.js.map +1 -0
- package/dist/resources/chrisEmbeddedResourceGroup.d.ts +73 -0
- package/dist/resources/chrisEmbeddedResourceGroup.js +148 -0
- package/dist/resources/chrisEmbeddedResourceGroup.js.map +1 -0
- package/dist/resources/chrisObjContext.d.ts +16 -0
- package/dist/resources/chrisObjContext.js +109 -0
- package/dist/resources/chrisObjContext.js.map +1 -0
- package/dist/resources/chrisResourceGroup.d.ts +30 -0
- package/dist/resources/chrisResourceGroup.js +47 -0
- package/dist/resources/chrisResourceGroup.js.map +1 -0
- package/dist/resources/chrisResources.d.ts +163 -0
- package/dist/resources/chrisResources.js +415 -0
- package/dist/resources/chrisResources.js.map +1 -0
- package/dist/tags/chrisTags.d.ts +11 -0
- package/dist/tags/chrisTags.js +18 -0
- package/dist/tags/chrisTags.js.map +1 -0
- package/dist/users/chrisUsers.d.ts +34 -0
- package/dist/users/chrisUsers.js +57 -0
- package/dist/users/chrisUsers.js.map +1 -0
- package/dist/utils/keypair.d.ts +77 -0
- package/dist/utils/keypair.js +144 -0
- package/dist/utils/keypair.js.map +1 -0
- package/dist/utils/result.d.ts +77 -0
- package/dist/utils/result.js +58 -0
- package/dist/utils/result.js.map +1 -0
- package/dist/utils/searchable.d.ts +143 -0
- package/dist/utils/searchable.js +212 -0
- package/dist/utils/searchable.js.map +1 -0
- package/dist/workflows/chrisWorkflows.d.ts +11 -0
- package/dist/workflows/chrisWorkflows.js +18 -0
- package/dist/workflows/chrisWorkflows.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file ChRIS Context Management
|
|
4
|
+
*
|
|
5
|
+
* This module manages the context of the ChRIS session, including the current user,
|
|
6
|
+
* URL, feed, folder, and plugin. It interacts with the session configuration to
|
|
7
|
+
* persist and retrieve context information.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(o, k2, desc);
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
+
}) : function(o, v) {
|
|
25
|
+
o["default"] = v;
|
|
26
|
+
});
|
|
27
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
28
|
+
var ownKeys = function(o) {
|
|
29
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
30
|
+
var ar = [];
|
|
31
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
32
|
+
return ar;
|
|
33
|
+
};
|
|
34
|
+
return ownKeys(o);
|
|
35
|
+
};
|
|
36
|
+
return function (mod) {
|
|
37
|
+
if (mod && mod.__esModule) return mod;
|
|
38
|
+
var result = {};
|
|
39
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
40
|
+
__setModuleDefault(result, mod);
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
})();
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.chrisContext = exports.ChrisContext = exports.Context = void 0;
|
|
46
|
+
exports.chrisContextURL_parse = chrisContextURL_parse;
|
|
47
|
+
const config_js_1 = require("../config/config.js");
|
|
48
|
+
const path = __importStar(require("path"));
|
|
49
|
+
const searchable_js_1 = require("../utils/searchable.js");
|
|
50
|
+
const chrisPlugins_js_1 = require("../plugins/chrisPlugins.js");
|
|
51
|
+
const index_js_1 = require("../cache/index.js");
|
|
52
|
+
const errorStack_js_1 = require("../error/errorStack.js");
|
|
53
|
+
/**
|
|
54
|
+
* Enum defining the types of context available in ChRIS.
|
|
55
|
+
*/
|
|
56
|
+
var Context;
|
|
57
|
+
(function (Context) {
|
|
58
|
+
Context["ChRISURL"] = "URL";
|
|
59
|
+
Context["ChRISuser"] = "user";
|
|
60
|
+
Context["ChRISfolder"] = "folder";
|
|
61
|
+
Context["ChRISfeed"] = "feed";
|
|
62
|
+
Context["ChRISplugin"] = "plugin";
|
|
63
|
+
Context["PACSserver"] = "pacsserver";
|
|
64
|
+
})(Context || (exports.Context = Context = {}));
|
|
65
|
+
/**
|
|
66
|
+
* Parses a ChRIS context URL string into a SingleContext object.
|
|
67
|
+
*
|
|
68
|
+
* @param url - The context URL string to parse.
|
|
69
|
+
* @returns A Promise resolving to a SingleContext object.
|
|
70
|
+
*/
|
|
71
|
+
async function chrisContextURL_parse(url) {
|
|
72
|
+
const result = {
|
|
73
|
+
URL: null,
|
|
74
|
+
user: null,
|
|
75
|
+
folder: null,
|
|
76
|
+
feed: null,
|
|
77
|
+
plugin: null,
|
|
78
|
+
pacsserver: null,
|
|
79
|
+
token: null,
|
|
80
|
+
};
|
|
81
|
+
// Split the URL at the @ symbol
|
|
82
|
+
const parts = url.split("@");
|
|
83
|
+
if (parts.length > 1) {
|
|
84
|
+
result.user = parts[0];
|
|
85
|
+
url = parts[1];
|
|
86
|
+
}
|
|
87
|
+
const urlMatch = url.match(/(https?:\/\/[^?]+)/);
|
|
88
|
+
if (urlMatch) {
|
|
89
|
+
result.URL = urlMatch[1];
|
|
90
|
+
}
|
|
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_toID(value);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
result.plugin = value;
|
|
104
|
+
}
|
|
105
|
+
break; // Stop after finding the first match
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Note: token is not present in the URL, so it remains null
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Helper to get plugin ID from a searchable string.
|
|
114
|
+
*
|
|
115
|
+
* @param searchable - The searchable string or object to search for.
|
|
116
|
+
* @returns A Promise resolving to the plugin ID or null.
|
|
117
|
+
*/
|
|
118
|
+
async function searchable_toID(searchable) {
|
|
119
|
+
const searchableObj = typeof searchable === 'string'
|
|
120
|
+
? searchable_js_1.Searchable.from(searchable)
|
|
121
|
+
: searchable;
|
|
122
|
+
const plugin = new chrisPlugins_js_1.ChRISPlugin();
|
|
123
|
+
const ids = await plugin.pluginIDs_getFromSearchable(searchableObj);
|
|
124
|
+
if (ids && ids.hits.length > 0) {
|
|
125
|
+
const id = ids.hits[0];
|
|
126
|
+
const ID = id.toString();
|
|
127
|
+
return ID;
|
|
128
|
+
}
|
|
129
|
+
errorStack_js_1.errorStack.stack_push('error', `Could not resolve searchable "${searchable}" to a plugin ID.`);
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Manages the ChRIS session context.
|
|
134
|
+
*/
|
|
135
|
+
class ChrisContext {
|
|
136
|
+
get singleContext() {
|
|
137
|
+
return this._singleContext;
|
|
138
|
+
}
|
|
139
|
+
constructor() {
|
|
140
|
+
this.fullContext = {
|
|
141
|
+
users: {},
|
|
142
|
+
currentUser: null,
|
|
143
|
+
currentURL: null,
|
|
144
|
+
};
|
|
145
|
+
this._singleContext = {
|
|
146
|
+
URL: null,
|
|
147
|
+
user: null,
|
|
148
|
+
folder: null,
|
|
149
|
+
feed: null,
|
|
150
|
+
plugin: null,
|
|
151
|
+
pacsserver: null,
|
|
152
|
+
token: null,
|
|
153
|
+
};
|
|
154
|
+
// Initialize is async, so we can't await it in constructor.
|
|
155
|
+
// Consumers should rely on the state being eventually consistent or call methods that ensure initialization.
|
|
156
|
+
// this.init(); // Removed to avoid accessing uninitialized sessionConfig
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Initializes the context by loading data from the configuration directory.
|
|
160
|
+
*/
|
|
161
|
+
async init() {
|
|
162
|
+
const configDir = config_js_1.sessionConfig.connection.configDir;
|
|
163
|
+
const storage = config_js_1.sessionConfig.connection.storage;
|
|
164
|
+
if (!(await storage.exists(configDir))) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const files = await storage.readdir(configDir);
|
|
168
|
+
const users = [];
|
|
169
|
+
for (const file of files) {
|
|
170
|
+
if (await storage.isDirectory(path.join(configDir, file))) {
|
|
171
|
+
users.push(file);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
this.fullContext.currentUser = await config_js_1.sessionConfig.connection.lastUser_load();
|
|
175
|
+
const currentURL = await config_js_1.sessionConfig.connection.chrisURL_load();
|
|
176
|
+
this.fullContext.currentURL = currentURL;
|
|
177
|
+
for (const user of users) {
|
|
178
|
+
this.fullContext.users[user] = { urls: {}, currentURL: null };
|
|
179
|
+
const userDir = path.join(configDir, user);
|
|
180
|
+
const chrisURLFile = path.join(userDir, config_js_1.sessionConfig.connection.chrisURLfile);
|
|
181
|
+
if (await storage.exists(chrisURLFile)) {
|
|
182
|
+
this.fullContext.users[user].currentURL = await storage.read(chrisURLFile);
|
|
183
|
+
}
|
|
184
|
+
if (!(await storage.exists(userDir)))
|
|
185
|
+
continue;
|
|
186
|
+
const userFiles = await storage.readdir(userDir);
|
|
187
|
+
const urlDirs = [];
|
|
188
|
+
for (const file of userFiles) {
|
|
189
|
+
if (await storage.isDirectory(path.join(userDir, file))) {
|
|
190
|
+
urlDirs.push(file);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
for (const urlDir of urlDirs) {
|
|
194
|
+
let url = config_js_1.sessionConfig.connection.dir_toUri(urlDir);
|
|
195
|
+
this.fullContext.users[user].urls[url] = {
|
|
196
|
+
folder: await storage.read(path.join(userDir, urlDir, config_js_1.sessionConfig.cwdFile)),
|
|
197
|
+
feed: await storage.read(path.join(userDir, urlDir, config_js_1.sessionConfig.feedFile)),
|
|
198
|
+
plugin: await storage.read(path.join(userDir, urlDir, config_js_1.sessionConfig.pluginFile)),
|
|
199
|
+
pacsserver: await storage.read(path.join(userDir, urlDir, config_js_1.sessionConfig.pacsserverFile)),
|
|
200
|
+
token: await storage.read(path.join(userDir, urlDir, config_js_1.sessionConfig.connection.tokenFile)),
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Get the full context object.
|
|
207
|
+
* @returns The full context.
|
|
208
|
+
*/
|
|
209
|
+
fullContext_get() {
|
|
210
|
+
return this.fullContext;
|
|
211
|
+
}
|
|
212
|
+
async ChRISURL_get() {
|
|
213
|
+
return config_js_1.sessionConfig.connection.chrisURL_load();
|
|
214
|
+
}
|
|
215
|
+
async ChRISuser_get() {
|
|
216
|
+
return config_js_1.sessionConfig.connection.lastUser_load();
|
|
217
|
+
}
|
|
218
|
+
async ChRISfolder_get() {
|
|
219
|
+
return config_js_1.sessionConfig.pathContext_get();
|
|
220
|
+
}
|
|
221
|
+
async ChRISfeed_get() {
|
|
222
|
+
return config_js_1.sessionConfig.feedContext_get();
|
|
223
|
+
}
|
|
224
|
+
async ChRISfolder_set(path) {
|
|
225
|
+
return config_js_1.sessionConfig.pathContext_set(path);
|
|
226
|
+
}
|
|
227
|
+
async ChRISfeed_set(feedID) {
|
|
228
|
+
return config_js_1.sessionConfig.feedContext_set(feedID);
|
|
229
|
+
}
|
|
230
|
+
async ChRISplugin_set(pluginID) {
|
|
231
|
+
return config_js_1.sessionConfig.pluginContext_set(pluginID);
|
|
232
|
+
}
|
|
233
|
+
async ChRISplugin_get() {
|
|
234
|
+
return config_js_1.sessionConfig.pluginContext_get();
|
|
235
|
+
}
|
|
236
|
+
async PACSserver_set(server) {
|
|
237
|
+
return config_js_1.sessionConfig.pacsserverContext_set(server);
|
|
238
|
+
}
|
|
239
|
+
async PACSserver_get() {
|
|
240
|
+
return config_js_1.sessionConfig.pacsserverContext_get();
|
|
241
|
+
}
|
|
242
|
+
async folderpath_get() {
|
|
243
|
+
return config_js_1.sessionConfig.pathContext_get();
|
|
244
|
+
}
|
|
245
|
+
async currentContext_update() {
|
|
246
|
+
this._singleContext.URL = await this.ChRISURL_get();
|
|
247
|
+
this._singleContext.user = await this.ChRISuser_get();
|
|
248
|
+
this._singleContext.folder = await this.ChRISfolder_get();
|
|
249
|
+
this._singleContext.feed = await this.ChRISfeed_get();
|
|
250
|
+
this._singleContext.plugin = await this.ChRISplugin_get();
|
|
251
|
+
this._singleContext.pacsserver = await this.PACSserver_get();
|
|
252
|
+
return this._singleContext;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Get the current value for a specific context type.
|
|
256
|
+
* @param context - The context type to retrieve.
|
|
257
|
+
* @returns The current context value or null.
|
|
258
|
+
*/
|
|
259
|
+
async current_get(context) {
|
|
260
|
+
await this.currentContext_update();
|
|
261
|
+
switch (context) {
|
|
262
|
+
case Context.ChRISURL:
|
|
263
|
+
return this._singleContext.URL;
|
|
264
|
+
case Context.ChRISuser:
|
|
265
|
+
return this._singleContext.user;
|
|
266
|
+
case Context.ChRISfolder:
|
|
267
|
+
return this._singleContext.folder;
|
|
268
|
+
case Context.ChRISfeed:
|
|
269
|
+
return this._singleContext.feed;
|
|
270
|
+
case Context.ChRISplugin:
|
|
271
|
+
return this._singleContext.plugin;
|
|
272
|
+
case Context.PACSserver:
|
|
273
|
+
return this._singleContext.pacsserver;
|
|
274
|
+
}
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Set the value for a specific context type.
|
|
279
|
+
* @param context - The context type to set.
|
|
280
|
+
* @param value - The value to set.
|
|
281
|
+
* @returns True on success, false on failure.
|
|
282
|
+
*/
|
|
283
|
+
async current_set(context, value) {
|
|
284
|
+
let status = false;
|
|
285
|
+
switch (context) {
|
|
286
|
+
case Context.ChRISuser:
|
|
287
|
+
this._singleContext.user = value;
|
|
288
|
+
status = await config_js_1.sessionConfig.connection.lastUser_save(value);
|
|
289
|
+
break;
|
|
290
|
+
case Context.ChRISURL:
|
|
291
|
+
this._singleContext.URL = value;
|
|
292
|
+
status = await config_js_1.sessionConfig.connection.chrisURL_save(value);
|
|
293
|
+
break;
|
|
294
|
+
case Context.ChRISfolder:
|
|
295
|
+
this._singleContext.folder = value;
|
|
296
|
+
status = await this.ChRISfolder_set(value);
|
|
297
|
+
// Invalidate listing cache on CWD change
|
|
298
|
+
const listCache = (0, index_js_1.listCache_get)();
|
|
299
|
+
listCache.cwd_update(value);
|
|
300
|
+
break;
|
|
301
|
+
case Context.ChRISfeed:
|
|
302
|
+
this._singleContext.feed = value;
|
|
303
|
+
status = await this.ChRISfeed_set(value);
|
|
304
|
+
break;
|
|
305
|
+
case Context.ChRISplugin:
|
|
306
|
+
this._singleContext.plugin = value;
|
|
307
|
+
status = await this.ChRISplugin_set(value);
|
|
308
|
+
break;
|
|
309
|
+
case Context.PACSserver:
|
|
310
|
+
this._singleContext.pacsserver = value;
|
|
311
|
+
status = await this.PACSserver_set(value);
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
await config_js_1.sessionConfig.connection.init();
|
|
315
|
+
await config_js_1.sessionConfig.init();
|
|
316
|
+
return status;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
exports.ChrisContext = ChrisContext;
|
|
320
|
+
/**
|
|
321
|
+
* Global ChRIS context instance.
|
|
322
|
+
*/
|
|
323
|
+
exports.chrisContext = new ChrisContext();
|
|
324
|
+
//# sourceMappingURL=chrisContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chrisContext.js","sourceRoot":"","sources":["../../src/context/chrisContext.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEH,sDA+CC;AAjHD,mDAAmF;AACnF,2CAA6B;AAE7B,0DAAoD;AACpD,gEAAyD;AACzD,gDAAkD;AAClD,0DAAoD;AAEpD;;GAEG;AACH,IAAY,OAOX;AAPD,WAAY,OAAO;IACjB,2BAAgB,CAAA;IAChB,6BAAkB,CAAA;IAClB,iCAAsB,CAAA;IACtB,6BAAkB,CAAA;IAClB,iCAAsB,CAAA;IACtB,oCAAyB,CAAA;AAC3B,CAAC,EAPW,OAAO,uBAAP,OAAO,QAOlB;AA0CD;;;;;GAKG;AACI,KAAK,UAAU,qBAAqB,CACzC,GAAW;IAEX,MAAM,MAAM,GAAkB;QAC5B,GAAG,EAAE,IAAI;QACT,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,IAAI;QACZ,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,IAAI;QACZ,UAAU,EAAE,IAAI;QAChB,KAAK,EAAE,IAAI;KACZ,CAAC;IAEF,gCAAgC;IAChC,MAAM,KAAK,GAAa,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACvC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CA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;QAC3B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA9ND,oCA8NC;AAED;;GAEG;AACU,QAAA,YAAY,GAAiB,IAAI,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Process-wide error/message stack for deferred, structured reporting.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
type MessageType = "error" | "warning";
|
|
7
|
+
/**
|
|
8
|
+
* Represents a single message in the error stack.
|
|
9
|
+
*/
|
|
10
|
+
export interface StackMessage {
|
|
11
|
+
type: MessageType;
|
|
12
|
+
message: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Options for configuring the ErrorStack.
|
|
16
|
+
*/
|
|
17
|
+
interface ErrorStackOptions {
|
|
18
|
+
functionNamePadWidth?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Singleton class for managing a stack of error and warning messages.
|
|
22
|
+
* Provides methods to push, pop, search, and filter messages.
|
|
23
|
+
*/
|
|
24
|
+
declare class ErrorStack {
|
|
25
|
+
private static instance;
|
|
26
|
+
private stack;
|
|
27
|
+
private functionNamePadWidth;
|
|
28
|
+
private constructor();
|
|
29
|
+
/**
|
|
30
|
+
* Get the singleton instance of the ErrorStack.
|
|
31
|
+
*
|
|
32
|
+
* @param options - Optional configuration options for the stack.
|
|
33
|
+
* @returns The singleton ErrorStack instance.
|
|
34
|
+
*/
|
|
35
|
+
static instance_get(options?: ErrorStackOptions): ErrorStack;
|
|
36
|
+
/**
|
|
37
|
+
* Push a new message onto the stack.
|
|
38
|
+
*
|
|
39
|
+
* Captures the calling function name and formats the message.
|
|
40
|
+
*
|
|
41
|
+
* @param type - The type of message ("error" or "warning").
|
|
42
|
+
* @param message - The message string.
|
|
43
|
+
*/
|
|
44
|
+
stack_push(type: MessageType, message: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* Pop the last message from the stack.
|
|
47
|
+
*
|
|
48
|
+
* @returns The last message object or undefined if the stack is empty.
|
|
49
|
+
*/
|
|
50
|
+
stack_pop(): StackMessage | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Search the stack for messages containing a substring.
|
|
53
|
+
*
|
|
54
|
+
* @param substring - The string to search for (case-insensitive).
|
|
55
|
+
* @returns An array of formatted strings matching the search.
|
|
56
|
+
*/
|
|
57
|
+
stack_getAll(): StackMessage[];
|
|
58
|
+
stack_search(substring: string): string[];
|
|
59
|
+
/**
|
|
60
|
+
* Get all messages of a specific type.
|
|
61
|
+
*
|
|
62
|
+
* @param type - The message type to filter by.
|
|
63
|
+
* @returns An array of message strings.
|
|
64
|
+
*/
|
|
65
|
+
allOfType_get(type: MessageType): string[];
|
|
66
|
+
/**
|
|
67
|
+
* Search for messages of a specific type containing a substring.
|
|
68
|
+
*
|
|
69
|
+
* @param type - The message type to filter by.
|
|
70
|
+
* @param substring - The string to search for (case-insensitive).
|
|
71
|
+
* @returns An array of matching message strings.
|
|
72
|
+
*/
|
|
73
|
+
messagesOfType_search(type: MessageType, substring: string): string[];
|
|
74
|
+
/**
|
|
75
|
+
* Clear all messages from the stack.
|
|
76
|
+
*/
|
|
77
|
+
stack_clear(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Clear all messages of a specific type from the stack.
|
|
80
|
+
*
|
|
81
|
+
* @param type - The message type to clear.
|
|
82
|
+
*/
|
|
83
|
+
type_clear(type: MessageType): void;
|
|
84
|
+
/**
|
|
85
|
+
* Check if the stack contains any messages.
|
|
86
|
+
*
|
|
87
|
+
* @returns True if the stack is not empty, false otherwise.
|
|
88
|
+
*/
|
|
89
|
+
messages_has(): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Check if the stack contains any messages of a specific type.
|
|
92
|
+
*
|
|
93
|
+
* @param type - The message type to check for.
|
|
94
|
+
* @returns True if messages of the given type exist, false otherwise.
|
|
95
|
+
*/
|
|
96
|
+
messagesOfType_has(type: MessageType): boolean;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The global singleton instance of the ErrorStack.
|
|
100
|
+
*/
|
|
101
|
+
export declare const errorStack: ErrorStack;
|
|
102
|
+
/**
|
|
103
|
+
* Reconfigures the error stack with new options.
|
|
104
|
+
*
|
|
105
|
+
* @param options - The new configuration options.
|
|
106
|
+
*/
|
|
107
|
+
export declare function errorStack_configure(options: ErrorStackOptions): void;
|
|
108
|
+
/**
|
|
109
|
+
* Get all messages of a specific type from the global error stack.
|
|
110
|
+
*
|
|
111
|
+
* @param type - The message type to filter by.
|
|
112
|
+
* @returns An array of message strings.
|
|
113
|
+
*/
|
|
114
|
+
export declare function errorStack_getAllOfType(type: MessageType): string[];
|
|
115
|
+
export {};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Process-wide error/message stack for deferred, structured reporting.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.errorStack = void 0;
|
|
9
|
+
exports.errorStack_configure = errorStack_configure;
|
|
10
|
+
exports.errorStack_getAllOfType = errorStack_getAllOfType;
|
|
11
|
+
/**
|
|
12
|
+
* Pads a string to the right with spaces to a specified length.
|
|
13
|
+
* If the string is longer than the length, it is truncated with ellipses.
|
|
14
|
+
*
|
|
15
|
+
* @param str - The string to pad.
|
|
16
|
+
* @param length - The target length.
|
|
17
|
+
* @returns The padded or truncated string.
|
|
18
|
+
*/
|
|
19
|
+
function str_padRight(str, length) {
|
|
20
|
+
if (str.length > length) {
|
|
21
|
+
return str.substring(0, length - 3) + "...";
|
|
22
|
+
}
|
|
23
|
+
return str.padEnd(length);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves the name of the function that called the current function.
|
|
27
|
+
* Uses the error stack trace to parse the caller's name.
|
|
28
|
+
*
|
|
29
|
+
* @returns The name of the calling function, or a default string if not found.
|
|
30
|
+
*/
|
|
31
|
+
function functionName_getCurrent() {
|
|
32
|
+
const error = new Error();
|
|
33
|
+
const stack = error.stack?.split("\n");
|
|
34
|
+
if (!stack || stack.length < 4) {
|
|
35
|
+
return "Unknown Function";
|
|
36
|
+
}
|
|
37
|
+
const callerLine = stack[3];
|
|
38
|
+
const functionNameMatch = callerLine.match(/at\s+([\w\.<>]+)\s*\(/);
|
|
39
|
+
return functionNameMatch ? functionNameMatch[1] : "Anonymous Function";
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Singleton class for managing a stack of error and warning messages.
|
|
43
|
+
* Provides methods to push, pop, search, and filter messages.
|
|
44
|
+
*/
|
|
45
|
+
class ErrorStack {
|
|
46
|
+
constructor(options = {}) {
|
|
47
|
+
this.stack = [];
|
|
48
|
+
this.functionNamePadWidth = options.functionNamePadWidth || 45; // Default to 45 if not specified
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get the singleton instance of the ErrorStack.
|
|
52
|
+
*
|
|
53
|
+
* @param options - Optional configuration options for the stack.
|
|
54
|
+
* @returns The singleton ErrorStack instance.
|
|
55
|
+
*/
|
|
56
|
+
static instance_get(options) {
|
|
57
|
+
if (!ErrorStack.instance) {
|
|
58
|
+
ErrorStack.instance = new ErrorStack(options);
|
|
59
|
+
}
|
|
60
|
+
return ErrorStack.instance;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Push a new message onto the stack.
|
|
64
|
+
*
|
|
65
|
+
* Captures the calling function name and formats the message.
|
|
66
|
+
*
|
|
67
|
+
* @param type - The type of message ("error" or "warning").
|
|
68
|
+
* @param message - The message string.
|
|
69
|
+
*/
|
|
70
|
+
stack_push(type, message) {
|
|
71
|
+
const functionName = functionName_getCurrent();
|
|
72
|
+
const paddedFunctionName = str_padRight(functionName, this.functionNamePadWidth);
|
|
73
|
+
const enhancedMessage = `[${paddedFunctionName}] | ${message}`;
|
|
74
|
+
this.stack.push({ type, message: enhancedMessage });
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Pop the last message from the stack.
|
|
78
|
+
*
|
|
79
|
+
* @returns The last message object or undefined if the stack is empty.
|
|
80
|
+
*/
|
|
81
|
+
stack_pop() {
|
|
82
|
+
return this.stack.pop();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Search the stack for messages containing a substring.
|
|
86
|
+
*
|
|
87
|
+
* @param substring - The string to search for (case-insensitive).
|
|
88
|
+
* @returns An array of formatted strings matching the search.
|
|
89
|
+
*/
|
|
90
|
+
stack_getAll() {
|
|
91
|
+
return [...this.stack];
|
|
92
|
+
}
|
|
93
|
+
stack_search(substring) {
|
|
94
|
+
return this.stack
|
|
95
|
+
.filter((item) => item.message.toLowerCase().includes(substring.toLowerCase()))
|
|
96
|
+
.map((item) => `${item.type}: ${item.message}`);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Get all messages of a specific type.
|
|
100
|
+
*
|
|
101
|
+
* @param type - The message type to filter by.
|
|
102
|
+
* @returns An array of message strings.
|
|
103
|
+
*/
|
|
104
|
+
allOfType_get(type) {
|
|
105
|
+
return this.stack
|
|
106
|
+
.filter((item) => item.type === type)
|
|
107
|
+
.map((item) => item.message);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Search for messages of a specific type containing a substring.
|
|
111
|
+
*
|
|
112
|
+
* @param type - The message type to filter by.
|
|
113
|
+
* @param substring - The string to search for (case-insensitive).
|
|
114
|
+
* @returns An array of matching message strings.
|
|
115
|
+
*/
|
|
116
|
+
messagesOfType_search(type, substring) {
|
|
117
|
+
return this.stack
|
|
118
|
+
.filter((item) => item.type === type &&
|
|
119
|
+
item.message.toLowerCase().includes(substring.toLowerCase()))
|
|
120
|
+
.map((item) => item.message);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Clear all messages from the stack.
|
|
124
|
+
*/
|
|
125
|
+
stack_clear() {
|
|
126
|
+
this.stack = [];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Clear all messages of a specific type from the stack.
|
|
130
|
+
*
|
|
131
|
+
* @param type - The message type to clear.
|
|
132
|
+
*/
|
|
133
|
+
type_clear(type) {
|
|
134
|
+
this.stack = this.stack.filter((item) => item.type !== type);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Check if the stack contains any messages.
|
|
138
|
+
*
|
|
139
|
+
* @returns True if the stack is not empty, false otherwise.
|
|
140
|
+
*/
|
|
141
|
+
messages_has() {
|
|
142
|
+
return this.stack.length > 0;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Check if the stack contains any messages of a specific type.
|
|
146
|
+
*
|
|
147
|
+
* @param type - The message type to check for.
|
|
148
|
+
* @returns True if messages of the given type exist, false otherwise.
|
|
149
|
+
*/
|
|
150
|
+
messagesOfType_has(type) {
|
|
151
|
+
return this.stack.some((item) => item.type === type);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The global singleton instance of the ErrorStack.
|
|
156
|
+
*/
|
|
157
|
+
exports.errorStack = ErrorStack.instance_get({ functionNamePadWidth: 40 });
|
|
158
|
+
/**
|
|
159
|
+
* Reconfigures the error stack with new options.
|
|
160
|
+
*
|
|
161
|
+
* @param options - The new configuration options.
|
|
162
|
+
*/
|
|
163
|
+
function errorStack_configure(options) {
|
|
164
|
+
ErrorStack.instance_get(options);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Get all messages of a specific type from the global error stack.
|
|
168
|
+
*
|
|
169
|
+
* @param type - The message type to filter by.
|
|
170
|
+
* @returns An array of message strings.
|
|
171
|
+
*/
|
|
172
|
+
function errorStack_getAllOfType(type) {
|
|
173
|
+
return exports.errorStack.allOfType_get(type);
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=errorStack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorStack.js","sourceRoot":"","sources":["../../src/error/errorStack.ts"],"names":[],"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