@fnndsc/chili 3.2.5 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -11
- package/dist/commands/fs/download.d.ts +19 -4
- package/dist/commands/fs/download.js +71 -62
- package/dist/commands/fs/upload.d.ts +20 -4
- package/dist/commands/fs/upload.js +42 -31
- package/dist/commands/man/doc.js +1 -1
- package/dist/commands/plugin/readme.js +3 -0
- package/dist/filesystem/fileGroupHandler.d.ts +0 -5
- package/dist/filesystem/fileGroupHandler.js +2 -19
- package/dist/handlers/baseGroupHandler.d.ts +10 -8
- package/dist/handlers/baseGroupHandler.js +28 -23
- package/dist/index.d.ts +6 -1
- package/dist/index.js +13 -179
- package/dist/man/renderer.d.ts +1 -1
- package/dist/man/renderer.js +6 -8
- package/dist/path/pathCommand.js +6 -3
- package/dist/plugins/pluginGroupHandler.d.ts +18 -0
- package/dist/plugins/pluginGroupHandler.js +40 -1
- package/dist/run.d.ts +24 -0
- package/dist/run.js +192 -0
- package/dist/screen/screen.d.ts +13 -0
- package/dist/screen/screen.js +44 -0
- package/dist/utils/resourceData.d.ts +16 -0
- package/dist/utils/resourceData.js +23 -0
- package/dist/views/pluginParameters.d.ts +10 -0
- package/dist/views/pluginParameters.js +24 -17
- package/docs/pacs.adoc +3 -3
- package/package.json +6 -8
package/dist/screen/screen.js
CHANGED
|
@@ -118,6 +118,50 @@ function firstColumnSettings_apply(columns) {
|
|
|
118
118
|
* @param options - Optional table display options.
|
|
119
119
|
* @returns The `TableContent` object or null on error.
|
|
120
120
|
*/
|
|
121
|
+
/**
|
|
122
|
+
* Renders a table to a string, the string form of {@link table_display}.
|
|
123
|
+
*
|
|
124
|
+
* Envelope-returning callers use this to return their output rather than
|
|
125
|
+
* printing it; table_display remains the printing form for callers not yet
|
|
126
|
+
* converted. Returns an empty string when there is no table to render.
|
|
127
|
+
*
|
|
128
|
+
* @param tableData - The rows to render.
|
|
129
|
+
* @param headers - Column headers.
|
|
130
|
+
* @param options - Table formatting options.
|
|
131
|
+
* @returns The rendered table (with a trailing newline), or an empty string.
|
|
132
|
+
*/
|
|
133
|
+
export function table_render(tableData, headers, options = {}) {
|
|
134
|
+
const { processedTableData, processedHeaders } = tableInput_process(tableData, headers);
|
|
135
|
+
const tableObj = tableContent_pack(processedTableData, processedHeaders);
|
|
136
|
+
if (!tableObj) {
|
|
137
|
+
return "";
|
|
138
|
+
}
|
|
139
|
+
const columns = tableObj.headers.map((_, index) => {
|
|
140
|
+
const existingCol = options.columns?.[index] || {};
|
|
141
|
+
return {
|
|
142
|
+
justification: "left",
|
|
143
|
+
...existingCol,
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
const updatedColumns = firstColumnSettings_apply(columns);
|
|
147
|
+
const tableOptions = {
|
|
148
|
+
...options,
|
|
149
|
+
head: processedHeaders,
|
|
150
|
+
columns: updatedColumns,
|
|
151
|
+
typeColors: {
|
|
152
|
+
string: "green",
|
|
153
|
+
number: "yellow",
|
|
154
|
+
boolean: "cyan",
|
|
155
|
+
object: "magenta",
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
let out = `${screen.table_output(processedTableData, tableOptions)}\n`;
|
|
159
|
+
if (options.pagination && options.pagination.shown < options.pagination.total) {
|
|
160
|
+
const { shown, total } = options.pagination;
|
|
161
|
+
out += `${chalk.dim(` ↓ showing ${shown} of ${total} · --all to fetch all · --limit <n> for page size`)}\n`;
|
|
162
|
+
}
|
|
163
|
+
return out;
|
|
164
|
+
}
|
|
121
165
|
export function table_display(tableData, headers, options = {}) {
|
|
122
166
|
const { processedTableData, processedHeaders } = tableInput_process(tableData, headers);
|
|
123
167
|
const tableObj = tableContent_pack(processedTableData, processedHeaders);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Shared shaping helpers for FilteredResourceData prior to display.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { FilteredResourceData } from "@fnndsc/cumin";
|
|
7
|
+
/**
|
|
8
|
+
* Removes duplicate column headers from a FilteredResourceData result.
|
|
9
|
+
*
|
|
10
|
+
* Keeps each selected field once (preserving first-seen order) and projects
|
|
11
|
+
* every table row onto that unique header set.
|
|
12
|
+
*
|
|
13
|
+
* @param results - The resource data to de-duplicate.
|
|
14
|
+
* @returns A new FilteredResourceData with unique selectedFields and matching rows.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resourceColumns_removeDuplicates(results: FilteredResourceData): FilteredResourceData;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes duplicate column headers from a FilteredResourceData result.
|
|
3
|
+
*
|
|
4
|
+
* Keeps each selected field once (preserving first-seen order) and projects
|
|
5
|
+
* every table row onto that unique header set.
|
|
6
|
+
*
|
|
7
|
+
* @param results - The resource data to de-duplicate.
|
|
8
|
+
* @returns A new FilteredResourceData with unique selectedFields and matching rows.
|
|
9
|
+
*/
|
|
10
|
+
export function resourceColumns_removeDuplicates(results) {
|
|
11
|
+
const uniqueHeaders = Array.from(new Set(results.selectedFields));
|
|
12
|
+
const uniqueTableData = results.tableData.map((row) => uniqueHeaders.reduce((acc, header) => {
|
|
13
|
+
if (typeof header === "string" && header in row) {
|
|
14
|
+
acc[header] = row[header];
|
|
15
|
+
}
|
|
16
|
+
return acc;
|
|
17
|
+
}, {}));
|
|
18
|
+
return {
|
|
19
|
+
...results,
|
|
20
|
+
selectedFields: uniqueHeaders,
|
|
21
|
+
tableData: uniqueTableData,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -15,3 +15,13 @@ import { FilteredResourceData } from '@fnndsc/cumin';
|
|
|
15
15
|
* @param data - The filtered resource data containing plugin parameters.
|
|
16
16
|
*/
|
|
17
17
|
export declare function pluginParameters_renderMan(data: FilteredResourceData): void;
|
|
18
|
+
/**
|
|
19
|
+
* Builds the "man page" style rendering of plugin parameters as a string.
|
|
20
|
+
*
|
|
21
|
+
* Same format as {@link pluginParameters_renderMan} but returns the text
|
|
22
|
+
* instead of printing it, so hosted surfaces can carry it in an envelope.
|
|
23
|
+
*
|
|
24
|
+
* @param data - The filtered resource data containing plugin parameters.
|
|
25
|
+
* @returns The rendered parameter listing.
|
|
26
|
+
*/
|
|
27
|
+
export declare function pluginParameters_manRender(data: FilteredResourceData): string;
|
|
@@ -15,10 +15,22 @@ import chalk from 'chalk';
|
|
|
15
15
|
* @param data - The filtered resource data containing plugin parameters.
|
|
16
16
|
*/
|
|
17
17
|
export function pluginParameters_renderMan(data) {
|
|
18
|
+
console.log(pluginParameters_manRender(data));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Builds the "man page" style rendering of plugin parameters as a string.
|
|
22
|
+
*
|
|
23
|
+
* Same format as {@link pluginParameters_renderMan} but returns the text
|
|
24
|
+
* instead of printing it, so hosted surfaces can carry it in an envelope.
|
|
25
|
+
*
|
|
26
|
+
* @param data - The filtered resource data containing plugin parameters.
|
|
27
|
+
* @returns The rendered parameter listing.
|
|
28
|
+
*/
|
|
29
|
+
export function pluginParameters_manRender(data) {
|
|
18
30
|
if (!data.tableData || data.tableData.length === 0) {
|
|
19
|
-
|
|
20
|
-
return;
|
|
31
|
+
return "No parameters found.";
|
|
21
32
|
}
|
|
33
|
+
const lines = [];
|
|
22
34
|
data.tableData.forEach((param) => {
|
|
23
35
|
// 1. Construct the first line: Flags and Value
|
|
24
36
|
let line1Parts = [];
|
|
@@ -52,28 +64,23 @@ export function pluginParameters_renderMan(data) {
|
|
|
52
64
|
line1Parts.push(chalk.gray(`(default: ${param.default})`));
|
|
53
65
|
}
|
|
54
66
|
if (line1Parts.length > 0) {
|
|
55
|
-
|
|
67
|
+
lines.push(line1Parts.join(' '));
|
|
56
68
|
}
|
|
57
|
-
else {
|
|
58
|
-
// Fallback if
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
// If name is 'v', it implies it should probably have a flag '-v'.
|
|
62
|
-
// If not, we might want to show '--v' anyway despite the rule, or '-v'.
|
|
63
|
-
// For safety, if line1 is empty but we have a name, show it as long flag to avoid invisible params.
|
|
64
|
-
if (param.name) {
|
|
65
|
-
console.log(chalk.bold(`--${param.name}`) + ' ' + chalk.gray('(implicit)'));
|
|
66
|
-
}
|
|
69
|
+
else if (param.name) {
|
|
70
|
+
// Fallback: if line1 is empty but we have a name, show it as a long flag
|
|
71
|
+
// to avoid invisible params.
|
|
72
|
+
lines.push(chalk.bold(`--${param.name}`) + ' ' + chalk.gray('(implicit)'));
|
|
67
73
|
}
|
|
68
74
|
// 2. Type line
|
|
69
75
|
if (param.type) {
|
|
70
|
-
|
|
76
|
+
lines.push(`Type: ${chalk.yellow(param.type)}`);
|
|
71
77
|
}
|
|
72
78
|
// 3. Help description
|
|
73
79
|
if (param.help) {
|
|
74
|
-
|
|
80
|
+
lines.push(chalk.white(param.help));
|
|
75
81
|
}
|
|
76
|
-
// Separator (
|
|
77
|
-
|
|
82
|
+
// Separator (blank line)
|
|
83
|
+
lines.push('');
|
|
78
84
|
});
|
|
85
|
+
return lines.join('\n');
|
|
79
86
|
}
|
package/docs/pacs.adoc
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
== PACS Queries
|
|
22
22
|
|
|
23
23
|
- **Create**: `chili pacsqueries create "<query>" [--title <title>] [--description <desc>] [--pacsserver <pacs>]`
|
|
24
|
-
- `<query>` can be JSON (`{"PatientID":"12345"}`) or comma-separated `key:value` pairs (`PatientID:12345,StudyDate:
|
|
24
|
+
- `<query>` can be JSON (`{"PatientID":"12345"}`) or comma-separated `key:value` pairs (`PatientID:12345,StudyDate:20240101`).
|
|
25
25
|
- On success prints: `Created PACS query id=<ID> status=<status> pacs=<pacs> title="<title>"`.
|
|
26
26
|
- **List**: `chili pacsqueries list [--pacsserver <pacs>] [--fields ...] [--table|--csv]`
|
|
27
27
|
- Filters to current/override PACS server. Use `fieldslist` to discover columns.
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
```bash
|
|
65
65
|
chili context set --pacsserver PACSDCM
|
|
66
66
|
chili pacsservers list --table
|
|
67
|
-
chili pacsqueries create "PatientID:
|
|
67
|
+
chili pacsqueries create "PatientID:7654321" --title "PID 7654321"
|
|
68
68
|
chili pacsqueries list --fields id,title,status,pacs_id,query
|
|
69
69
|
chili pacsqueries decode <id>
|
|
70
70
|
```
|
|
@@ -76,7 +76,7 @@ chili pacsqueries decode <id>
|
|
|
76
76
|
chili context set --pacsserver PACSDCM
|
|
77
77
|
|
|
78
78
|
# 2. Create query
|
|
79
|
-
chili pacsqueries create "PatientID:
|
|
79
|
+
chili pacsqueries create "PatientID:7654321" --title "Patient scan"
|
|
80
80
|
# Returns: Created PACS query id=123
|
|
81
81
|
|
|
82
82
|
# 3. See what's available on PACS
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fnndsc/chili",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "ChILI handles Intelligent Line Interactions: A CLI and library for ChRIS, acting as the controller layer for business logic and user presentation.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "tsc && chmod +x ./dist/index.js",
|
|
27
27
|
"start": "node dist/index.js",
|
|
28
|
-
"test": "jest",
|
|
28
|
+
"test": "jest --coverage",
|
|
29
29
|
"test:coverage": "jest --coverage --coverageProvider=v8",
|
|
30
30
|
"clean": "rm -rf dist types fnndsc-chili*tgz",
|
|
31
31
|
"build:cumin": "cd ../cumin && npm run build",
|
|
@@ -47,14 +47,13 @@
|
|
|
47
47
|
"author": "FNNDSC <dev@babyMRI.org>",
|
|
48
48
|
"license": "MIT",
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@fnndsc/cumin": "^3.
|
|
51
|
-
"@fnndsc/salsa": "^3.2.
|
|
50
|
+
"@fnndsc/cumin": "^3.4.0",
|
|
51
|
+
"@fnndsc/salsa": "^3.2.5",
|
|
52
52
|
"@fortawesome/fontawesome-free": "^6.6.0",
|
|
53
53
|
"@fortawesome/fontawesome-svg-core": "^6.6.0",
|
|
54
54
|
"@fortawesome/free-solid-svg-icons": "^6.6.0",
|
|
55
|
-
"@mermaid-js/mermaid-cli": "^11.12.0",
|
|
56
55
|
"archy": "^1.0.0",
|
|
57
|
-
"asciidoctor": "^
|
|
56
|
+
"asciidoctor": "^4.0.1",
|
|
58
57
|
"axios": "^1.6.0",
|
|
59
58
|
"chalk": "^4.1.2",
|
|
60
59
|
"cli-highlight": "^2.1.11",
|
|
@@ -65,7 +64,6 @@
|
|
|
65
64
|
"js-yaml": "^4.1.0",
|
|
66
65
|
"marked": "^9.1.0",
|
|
67
66
|
"marked-terminal": "^6.1.0",
|
|
68
|
-
"node-fetch": "^3.3.2",
|
|
69
67
|
"omelette": "^0.4.17",
|
|
70
68
|
"open": "^10.1.0",
|
|
71
69
|
"table": "^6.8.1"
|
|
@@ -77,7 +75,7 @@
|
|
|
77
75
|
"@types/jest": "^30.0.0",
|
|
78
76
|
"@types/js-yaml": "^4.0.5",
|
|
79
77
|
"@types/marked-terminal": "^6.1.1",
|
|
80
|
-
"@types/node": "^
|
|
78
|
+
"@types/node": "^22.0.0",
|
|
81
79
|
"@types/node-fetch": "^2.6.11",
|
|
82
80
|
"@types/omelette": "^0.4.4",
|
|
83
81
|
"jest": "^30.2.0",
|