@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 FNNDSC / BCH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
```
|
|
2
|
+
____ _
|
|
3
|
+
/ ___| __ _| |___ __ _
|
|
4
|
+
\___ \ / _` | / __|/ _` |
|
|
5
|
+
___) | (_| | \__ \ (_| |
|
|
6
|
+
|____/ \__,_|_|___/\__,_|
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
**Salsa Abstracts Logic Service Assets**
|
|
10
|
+
|
|
11
|
+
`salsa` is the logic layer of the ChRIS interface ecosystem. It encapsulates high-level business intents and operational logic, serving as the bridge between user-facing interfaces (`chell`, `chili`) and the underlying infrastructure (`cumin` and `chrisapi`).
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @fnndsc/salsa
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Requires Node.js ≥ 20.12. Ships with TypeScript type definitions. Depends on [`@fnndsc/cumin`](https://github.com/FNNDSC/cumin).
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { files_listAll, fileContent_get, vfsDispatcher } from "@fnndsc/salsa";
|
|
25
|
+
|
|
26
|
+
// Salsa returns pure data / typed objects — no CLI dependencies
|
|
27
|
+
const listing = await files_listAll({ limit: 1000, offset: 0 }, "files", "/home/chris");
|
|
28
|
+
const content = await fileContent_get("/home/chris/uploads/notes.txt");
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
See [Key Modules](#key-modules) for the full intent catalogue.
|
|
32
|
+
|
|
33
|
+
## Purpose
|
|
34
|
+
|
|
35
|
+
- **Consolidate Business Logic**: Centralises intents such as "list directory", "upload file", "register plugin", "fetch feed note". All frontends share identical behaviour.
|
|
36
|
+
- **Frontend Agnostic**: No CLI-specific dependencies (`commander`, `process.stdout`). Returns pure data or typed objects.
|
|
37
|
+
- **Virtual Filesystem**: Owns the VFS dispatcher that maps ChRIS API resources onto Unix-style paths — see [VFS](#virtual-filesystem-vfs) below.
|
|
38
|
+
|
|
39
|
+
## Architecture: The Sandwich Model
|
|
40
|
+
|
|
41
|
+
```text
|
|
42
|
+
[ ChELL (REPL) ] [ Chili (CLI) ] [ Web App ] [ Mobile App ]
|
|
43
|
+
| | | |
|
|
44
|
+
+-----------------+---------------+ |
|
|
45
|
+
| |
|
|
46
|
+
v v
|
|
47
|
+
[ Salsa (Logic / Intents) ] <-- YOU ARE HERE
|
|
48
|
+
|
|
|
49
|
+
v
|
|
50
|
+
[ Cumin (State / Infrastructure) ]
|
|
51
|
+
|
|
|
52
|
+
v
|
|
53
|
+
[ @fnndsc/chrisapi (Client) ]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Key Modules
|
|
57
|
+
|
|
58
|
+
### Filesystem
|
|
59
|
+
|
|
60
|
+
| Function | Description |
|
|
61
|
+
|----------|-------------|
|
|
62
|
+
| `vfsDispatcher` | Routes `list`/`read` calls to the correct VFS provider by path prefix |
|
|
63
|
+
| `files_list` | List a directory (paginated) |
|
|
64
|
+
| `files_listAll` | Full directory listing (all pages) |
|
|
65
|
+
| `fileContent_get` | Read remote file content |
|
|
66
|
+
| `files_uploadPath` | Upload a local file or directory tree to ChRIS |
|
|
67
|
+
| `files_touch` | Create an empty file |
|
|
68
|
+
| `files_mkdir` | Create a directory |
|
|
69
|
+
| `files_rm` | Delete a file or directory |
|
|
70
|
+
| `files_cp` / `files_mv` | Copy / move |
|
|
71
|
+
|
|
72
|
+
### Plugins & Store
|
|
73
|
+
|
|
74
|
+
| Function | Description |
|
|
75
|
+
|----------|-------------|
|
|
76
|
+
| `plugins_list` / `plugins_listAll` | Fetch plugin list |
|
|
77
|
+
| `plugin_checkExists` | Check if a plugin is already registered |
|
|
78
|
+
| `plugin_registerWithAdmin` | Register a plugin via the admin endpoint |
|
|
79
|
+
| `plugin_assignToComputeResources` | Assign plugin to compute environments |
|
|
80
|
+
| `plugins_searchPeers` | Search peer ChRIS stores (e.g. cube.chrisproject.org) |
|
|
81
|
+
| `plugin_importFromStore` | Import a plugin from peer store data |
|
|
82
|
+
| `plugin_searchPeersByImage` | Resolve a Docker image to a peer-store plugin |
|
|
83
|
+
|
|
84
|
+
### Feeds & Sub-resources
|
|
85
|
+
|
|
86
|
+
| Function | Description |
|
|
87
|
+
|----------|-------------|
|
|
88
|
+
| `feeds_list` / `feeds_listAll` | Fetch feeds |
|
|
89
|
+
| `feedNote_get` / `feedNote_update` | Read or update the singleton note on a feed |
|
|
90
|
+
| `feedComments_list` | List comments on a feed |
|
|
91
|
+
| `feedComment_create` / `feedComment_update` / `feedComment_delete` | Comment CRUD |
|
|
92
|
+
|
|
93
|
+
### Pipelines & Workflows
|
|
94
|
+
|
|
95
|
+
| Function | Description |
|
|
96
|
+
|----------|-------------|
|
|
97
|
+
| `pipelines_list` | List registered pipelines |
|
|
98
|
+
| `workflow_create` | Instantiate a pipeline as a workflow on a feed |
|
|
99
|
+
|
|
100
|
+
### Jobs (Plugin Instance Operations)
|
|
101
|
+
|
|
102
|
+
| Function | Description |
|
|
103
|
+
|----------|-------------|
|
|
104
|
+
| `job_cancel(id)` | Cancel a running/scheduled instance (`PUT {status: cancelled}`) |
|
|
105
|
+
| `job_delete(id)` | Delete a terminal instance record |
|
|
106
|
+
| `job_statusFetch(id)` | Live-fetch current status from API (bypasses cache) |
|
|
107
|
+
| `job_logFetch(id)` | Fetch stdout/stderr log for an instance |
|
|
108
|
+
| `procCache_refresh([feedID])` | Rebuild the `/proc` job cache, optionally scoped to one feed |
|
|
109
|
+
|
|
110
|
+
## Virtual Filesystem (VFS)
|
|
111
|
+
|
|
112
|
+
`vfsDispatcher` translates a ChRIS path into a provider call. Each provider handles a path prefix and maps API resources onto filesystem semantics:
|
|
113
|
+
|
|
114
|
+
| Path prefix | Provider | Backed by |
|
|
115
|
+
|-------------|----------|-----------|
|
|
116
|
+
| `/home/<user>/` | `HomeVfsProvider` | ChRIS user-file API |
|
|
117
|
+
| `/home/<user>/feeds/` | `FeedVfsProvider` | Feed resources |
|
|
118
|
+
| `/bin` | `BinVfsProvider` | Registered plugins (virtual executables) |
|
|
119
|
+
| `/usr/bin` | `UsrBinVfsProvider` | Built-in shell commands (`whoami`, `whereami`) |
|
|
120
|
+
| `/etc` | `EtcVfsProvider` | Config files (`compute.yaml`, `group`, `passwd`, `cube`) |
|
|
121
|
+
| `/net/pacs/queries/` | `PacsVfsProvider` | PACS query results |
|
|
122
|
+
| `/proc/feeds/` | `ProcVfsProvider` | Job monitoring DAG (backed by `ProcCache` in cumin) |
|
|
123
|
+
| `*.chrislink` | resolved by dispatcher | Symlinks to other ChRIS paths |
|
|
124
|
+
|
|
125
|
+
Providers implement a common interface: `list(path)` → `Result<VFSItem[]>` and `read(path)` → `Result<string>`.
|
|
126
|
+
|
|
127
|
+
### `/proc/feeds/` — Job Monitoring
|
|
128
|
+
|
|
129
|
+
`ProcVfsProvider` mirrors the computation DAG of every visible feed. Each plugin instance is a directory; virtual files inside expose live status, params, and log:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
/proc/feeds/feed_123/
|
|
133
|
+
├── status ← aggregate: running | finishedSuccessfully | finishedWithError
|
|
134
|
+
├── title
|
|
135
|
+
└── pl-dircopy_456/ ← type=job in VFSItem; ls -l shows colour-coded status
|
|
136
|
+
├── status ← live API fetch if non-terminal
|
|
137
|
+
├── params ← key=value, cached permanently
|
|
138
|
+
├── log ← never cached, always live
|
|
139
|
+
└── pl-fshack_789/
|
|
140
|
+
└── …
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The cache (`ProcCache` in cumin) holds two flat maps (`instances`, `children`/`feedRoots`) for O(1) lookup and O(depth) path reconstruction. Structure is permanent; only status of non-terminal nodes is refreshed on read.
|
|
144
|
+
|
|
145
|
+
## Development
|
|
146
|
+
|
|
147
|
+
### Build
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
npm run build
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Test
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
npm run test
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## License
|
|
160
|
+
|
|
161
|
+
MIT — part of the [ChRIS Project](https://chrisproject.org).
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
_-30-_
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Compute resource operations.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
import { FilteredResourceData, ListOptions } from '@fnndsc/cumin';
|
|
6
|
+
/**
|
|
7
|
+
* Lists compute resources (single page).
|
|
8
|
+
*/
|
|
9
|
+
export declare function computeResources_list(options: ListOptions): Promise<FilteredResourceData | null>;
|
|
10
|
+
/**
|
|
11
|
+
* Lists all compute resources across all pages.
|
|
12
|
+
*/
|
|
13
|
+
export declare function computeResources_listAll(options?: Partial<ListOptions>): Promise<FilteredResourceData | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Returns available field names for compute resources.
|
|
16
|
+
*/
|
|
17
|
+
export declare function computeResourceFields_get(): Promise<string[] | null>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Compute resource operations.
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.computeResources_list = computeResources_list;
|
|
8
|
+
exports.computeResources_listAll = computeResources_listAll;
|
|
9
|
+
exports.computeResourceFields_get = computeResourceFields_get;
|
|
10
|
+
const cumin_1 = require("@fnndsc/cumin");
|
|
11
|
+
/**
|
|
12
|
+
* Lists compute resources (single page).
|
|
13
|
+
*/
|
|
14
|
+
async function computeResources_list(options) {
|
|
15
|
+
const group = new cumin_1.ChRISComputeResourceGroup();
|
|
16
|
+
return await group.asset.resources_listAndFilterByOptions(options);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Lists all compute resources across all pages.
|
|
20
|
+
*/
|
|
21
|
+
async function computeResources_listAll(options = {}) {
|
|
22
|
+
const group = new cumin_1.ChRISComputeResourceGroup();
|
|
23
|
+
return await group.asset.resources_getAll(options);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns available field names for compute resources.
|
|
27
|
+
*/
|
|
28
|
+
async function computeResourceFields_get() {
|
|
29
|
+
const group = new cumin_1.ChRISComputeResourceGroup();
|
|
30
|
+
const result = await group.asset.resourceFields_get();
|
|
31
|
+
return result ? result.fields : null;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/compute/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAOH,sDAGC;AAKD,4DAGC;AAKD,8DAIC;AAzBD,yCAA6F;AAE7F;;GAEG;AACI,KAAK,UAAU,qBAAqB,CAAC,OAAoB;IAC9D,MAAM,KAAK,GAA8B,IAAI,iCAAyB,EAAE,CAAC;IACzE,OAAO,MAAM,KAAK,CAAC,KAAK,CAAC,gCAAgC,CAAC,OAAO,CAAC,CAAC;AACrE,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,wBAAwB,CAAC,UAAgC,EAAE;IAC/E,MAAM,KAAK,GAA8B,IAAI,iCAAyB,EAAE,CAAC;IACzE,OAAO,MAAM,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AACrD,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,yBAAyB;IAC7C,MAAM,KAAK,GAA8B,IAAI,iCAAyB,EAAE,CAAC;IACzE,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,kBAAkB,EAAE,CAAC;IACtD,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Connect/login and logout operations against a ChRIS backend.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Options for connecting to a ChRIS backend (url, username, password).
|
|
8
|
+
*/
|
|
9
|
+
export interface ConnectOptions {
|
|
10
|
+
user: string;
|
|
11
|
+
password: string;
|
|
12
|
+
debug: boolean;
|
|
13
|
+
url: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Connects and authenticates against a ChRIS backend.
|
|
17
|
+
*
|
|
18
|
+
* @param options - Connection options.
|
|
19
|
+
* @returns True on success, false otherwise.
|
|
20
|
+
*/
|
|
21
|
+
export declare function connect_do(options: ConnectOptions): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* Logs out of the current ChRIS session, clearing stored credentials.
|
|
24
|
+
*/
|
|
25
|
+
export declare function logout_do(): Promise<void>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Connect/login and logout operations against a ChRIS backend.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.connect_do = connect_do;
|
|
9
|
+
exports.logout_do = logout_do;
|
|
10
|
+
const cumin_1 = require("@fnndsc/cumin");
|
|
11
|
+
/**
|
|
12
|
+
* Connects and authenticates against a ChRIS backend.
|
|
13
|
+
*
|
|
14
|
+
* @param options - Connection options.
|
|
15
|
+
* @returns True on success, false otherwise.
|
|
16
|
+
*/
|
|
17
|
+
async function connect_do(options) {
|
|
18
|
+
const token = await cumin_1.chrisConnection.connection_connect(options);
|
|
19
|
+
return token !== null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Logs out of the current ChRIS session, clearing stored credentials.
|
|
23
|
+
*/
|
|
24
|
+
async function logout_do() {
|
|
25
|
+
await cumin_1.chrisConnection.connection_logout();
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connect/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAoBH,gCAGC;AAKD,8BAEC;AA5BD,yCAAgD;AAYhD;;;;;GAKG;AACI,KAAK,UAAU,UAAU,CAAC,OAAuB;IACtD,MAAM,KAAK,GAAkB,MAAM,uBAAe,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC/E,OAAO,KAAK,KAAK,IAAI,CAAC;AACxB,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,SAAS;IAC7B,MAAM,uBAAe,CAAC,iBAAiB,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Context read/write operations (full and single context) for salsa.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { FullContext, SingleContext, Result } from "@fnndsc/cumin";
|
|
7
|
+
/**
|
|
8
|
+
* Options describing a context mutation (URL, user, feed, folder, etc.).
|
|
9
|
+
*/
|
|
10
|
+
export interface ContextOptions {
|
|
11
|
+
ChRISurl?: string;
|
|
12
|
+
ChRISuser?: string;
|
|
13
|
+
ChRISfolder?: string;
|
|
14
|
+
ChRISfeed?: string;
|
|
15
|
+
ChRISplugin?: string;
|
|
16
|
+
pacsserver?: string;
|
|
17
|
+
full?: boolean;
|
|
18
|
+
all?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns the full current context.
|
|
22
|
+
*
|
|
23
|
+
* @returns The full context object.
|
|
24
|
+
*/
|
|
25
|
+
export declare function context_getFull(): FullContext;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the single (resolved) current context.
|
|
28
|
+
*
|
|
29
|
+
* @returns Promise resolving to the single context.
|
|
30
|
+
*/
|
|
31
|
+
export declare function context_getSingle(): Promise<SingleContext>;
|
|
32
|
+
/**
|
|
33
|
+
* Applies one or more context mutations.
|
|
34
|
+
*
|
|
35
|
+
* @param options - The context fields to set.
|
|
36
|
+
* @returns Result wrapping the list of applied keys.
|
|
37
|
+
*/
|
|
38
|
+
export declare function context_set(options: ContextOptions): Promise<Result<string[]>>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Context read/write operations (full and single context) for salsa.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.context_getFull = context_getFull;
|
|
9
|
+
exports.context_getSingle = context_getSingle;
|
|
10
|
+
exports.context_set = context_set;
|
|
11
|
+
const cumin_1 = require("@fnndsc/cumin");
|
|
12
|
+
/**
|
|
13
|
+
* Returns the full current context.
|
|
14
|
+
*
|
|
15
|
+
* @returns The full context object.
|
|
16
|
+
*/
|
|
17
|
+
function context_getFull() {
|
|
18
|
+
return cumin_1.chrisContext.fullContext_get();
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns the single (resolved) current context.
|
|
22
|
+
*
|
|
23
|
+
* @returns Promise resolving to the single context.
|
|
24
|
+
*/
|
|
25
|
+
async function context_getSingle() {
|
|
26
|
+
await cumin_1.chrisContext.currentContext_update();
|
|
27
|
+
return cumin_1.chrisContext.singleContext;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Applies one or more context mutations.
|
|
31
|
+
*
|
|
32
|
+
* @param options - The context fields to set.
|
|
33
|
+
* @returns Result wrapping the list of applied keys.
|
|
34
|
+
*/
|
|
35
|
+
async function context_set(options) {
|
|
36
|
+
const results = [];
|
|
37
|
+
const setters = [
|
|
38
|
+
{ key: 'ChRISuser', context: cumin_1.Context.ChRISuser },
|
|
39
|
+
{ key: 'ChRISurl', context: cumin_1.Context.ChRISURL },
|
|
40
|
+
{ key: 'ChRISfolder', context: cumin_1.Context.ChRISfolder },
|
|
41
|
+
{ key: 'ChRISfeed', context: cumin_1.Context.ChRISfeed },
|
|
42
|
+
{ key: 'ChRISplugin', context: cumin_1.Context.ChRISplugin },
|
|
43
|
+
{ key: 'pacsserver', context: cumin_1.Context.PACSserver },
|
|
44
|
+
];
|
|
45
|
+
for (const { key, context } of setters) {
|
|
46
|
+
const value = options[key];
|
|
47
|
+
if (value !== undefined && typeof value === 'string') {
|
|
48
|
+
const success = await cumin_1.chrisContext.current_set(context, value);
|
|
49
|
+
if (!success) {
|
|
50
|
+
cumin_1.errorStack.stack_push('error', cumin_1.errorStack.allOfType_get('error').join('\n'));
|
|
51
|
+
return (0, cumin_1.Err)();
|
|
52
|
+
}
|
|
53
|
+
results.push(`${context} set to ${value}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return (0, cumin_1.Ok)(results);
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAgCH,0CAEC;AAOD,8CAGC;AAQD,kCAyBC;AA3ED,yCASuB;AAgBvB;;;;GAIG;AACH,SAAgB,eAAe;IAC7B,OAAO,oBAAY,CAAC,eAAe,EAAE,CAAC;AACxC,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,iBAAiB;IACrC,MAAM,oBAAY,CAAC,qBAAqB,EAAE,CAAC;IAC3C,OAAO,oBAAY,CAAC,aAAa,CAAC;AACpC,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,WAAW,CAAC,OAAuB;IACvD,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,MAAM,OAAO,GAAsD;QACjE,EAAE,GAAG,EAAE,WAAW,EAAI,OAAO,EAAE,eAAO,CAAC,SAAS,EAAI;QACpD,EAAE,GAAG,EAAE,UAAU,EAAK,OAAO,EAAE,eAAO,CAAC,QAAQ,EAAM;QACrD,EAAE,GAAG,EAAE,aAAa,EAAE,OAAO,EAAE,eAAO,CAAC,WAAW,EAAG;QACrD,EAAE,GAAG,EAAE,WAAW,EAAI,OAAO,EAAE,eAAO,CAAC,SAAS,EAAK;QACrD,EAAE,GAAG,EAAE,aAAa,EAAE,OAAO,EAAE,eAAO,CAAC,WAAW,EAAG;QACrD,EAAE,GAAG,EAAE,YAAY,EAAG,OAAO,EAAE,eAAO,CAAC,UAAU,EAAI;KACtD,CAAC;IAEF,KAAK,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,OAAO,EAAE,CAAC;QACvC,MAAM,KAAK,GAAiC,OAAO,CAAC,GAAG,CAAC,CAAC;QACzD,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACrD,MAAM,OAAO,GAAY,MAAM,oBAAY,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YACxE,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,kBAAU,CAAC,UAAU,CAAC,OAAO,EAAE,kBAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC7E,OAAO,IAAA,WAAG,GAAE,CAAC;YACf,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,WAAW,KAAK,EAAE,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,OAAO,IAAA,UAAE,EAAC,OAAO,CAAC,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Feed management operations.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
import { SimpleRecord, ChRISObjectParams, FilteredResourceData, ListOptions } from '@fnndsc/cumin';
|
|
6
|
+
export { feedNote_get, feedNote_update, feedComments_list, feedComment_create, feedComment_delete, feedComment_update, } from '@fnndsc/cumin';
|
|
7
|
+
export type { FeedNote, FeedComment } from '@fnndsc/cumin';
|
|
8
|
+
/**
|
|
9
|
+
* List feeds based on options.
|
|
10
|
+
*
|
|
11
|
+
* @param options - Search and pagination options.
|
|
12
|
+
* @returns A Promise resolving to FilteredResourceData or null.
|
|
13
|
+
*/
|
|
14
|
+
export declare function feeds_list(options: ListOptions): Promise<FilteredResourceData | null>;
|
|
15
|
+
/**
|
|
16
|
+
* Fetches all feeds across all pages.
|
|
17
|
+
*
|
|
18
|
+
* @param options - Filter options (limit/offset managed internally).
|
|
19
|
+
* @returns A Promise resolving to FilteredResourceData or null.
|
|
20
|
+
*/
|
|
21
|
+
export declare function feeds_listAll(options?: Partial<ListOptions>): Promise<FilteredResourceData | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Get the list of available fields for feeds.
|
|
24
|
+
*
|
|
25
|
+
* @returns A Promise resolving to an array of field names or null.
|
|
26
|
+
*/
|
|
27
|
+
export declare function feedFields_get(): Promise<string[] | null>;
|
|
28
|
+
/**
|
|
29
|
+
* Create a new feed from a set of directories.
|
|
30
|
+
*
|
|
31
|
+
* This function orchestrates the creation of a new feed by uploading data
|
|
32
|
+
* from local directories to the ChRIS system.
|
|
33
|
+
*
|
|
34
|
+
* @param dirs - An array of local directory paths to upload.
|
|
35
|
+
* @param params - Optional parameters for the feed (e.g., name, tags).
|
|
36
|
+
* @returns A Promise resolving to the created feed record, or null if creation failed.
|
|
37
|
+
*/
|
|
38
|
+
export declare function feed_create(dirs: string[], params?: ChRISObjectParams): Promise<SimpleRecord | null>;
|
|
39
|
+
/**
|
|
40
|
+
* Interface for feed sharing options.
|
|
41
|
+
*/
|
|
42
|
+
export interface FeedShareOptions {
|
|
43
|
+
is_public?: boolean;
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Shares a feed with specified ID and options.
|
|
48
|
+
*
|
|
49
|
+
* @param feedId - The ID of the feed to share.
|
|
50
|
+
* @param options - Sharing options, e.g., { is_public: true } to make public.
|
|
51
|
+
* @returns A Promise resolving to true on successful sharing, false otherwise.
|
|
52
|
+
*/
|
|
53
|
+
export declare function feeds_share(feedId: number, options: FeedShareOptions): Promise<boolean>;
|
|
54
|
+
/**
|
|
55
|
+
* Deletes a feed by its ID.
|
|
56
|
+
*
|
|
57
|
+
* @param id - The ID of the feed to delete.
|
|
58
|
+
* @returns A Promise resolving to true on success, false on failure.
|
|
59
|
+
*/
|
|
60
|
+
export declare function feed_delete(id: number): Promise<boolean>;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Feed management operations.
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.feedComment_update = exports.feedComment_delete = exports.feedComment_create = exports.feedComments_list = exports.feedNote_update = exports.feedNote_get = void 0;
|
|
8
|
+
exports.feeds_list = feeds_list;
|
|
9
|
+
exports.feeds_listAll = feeds_listAll;
|
|
10
|
+
exports.feedFields_get = feedFields_get;
|
|
11
|
+
exports.feed_create = feed_create;
|
|
12
|
+
exports.feeds_share = feeds_share;
|
|
13
|
+
exports.feed_delete = feed_delete;
|
|
14
|
+
const cumin_1 = require("@fnndsc/cumin");
|
|
15
|
+
var cumin_2 = require("@fnndsc/cumin");
|
|
16
|
+
Object.defineProperty(exports, "feedNote_get", { enumerable: true, get: function () { return cumin_2.feedNote_get; } });
|
|
17
|
+
Object.defineProperty(exports, "feedNote_update", { enumerable: true, get: function () { return cumin_2.feedNote_update; } });
|
|
18
|
+
Object.defineProperty(exports, "feedComments_list", { enumerable: true, get: function () { return cumin_2.feedComments_list; } });
|
|
19
|
+
Object.defineProperty(exports, "feedComment_create", { enumerable: true, get: function () { return cumin_2.feedComment_create; } });
|
|
20
|
+
Object.defineProperty(exports, "feedComment_delete", { enumerable: true, get: function () { return cumin_2.feedComment_delete; } });
|
|
21
|
+
Object.defineProperty(exports, "feedComment_update", { enumerable: true, get: function () { return cumin_2.feedComment_update; } });
|
|
22
|
+
/**
|
|
23
|
+
* List feeds based on options.
|
|
24
|
+
*
|
|
25
|
+
* @param options - Search and pagination options.
|
|
26
|
+
* @returns A Promise resolving to FilteredResourceData or null.
|
|
27
|
+
*/
|
|
28
|
+
async function feeds_list(options) {
|
|
29
|
+
const feedGroup = new cumin_1.ChRISFeedGroup();
|
|
30
|
+
return await feedGroup.asset.resources_listAndFilterByOptions(options);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Fetches all feeds across all pages.
|
|
34
|
+
*
|
|
35
|
+
* @param options - Filter options (limit/offset managed internally).
|
|
36
|
+
* @returns A Promise resolving to FilteredResourceData or null.
|
|
37
|
+
*/
|
|
38
|
+
async function feeds_listAll(options) {
|
|
39
|
+
const feedGroup = new cumin_1.ChRISFeedGroup();
|
|
40
|
+
return await feedGroup.asset.resources_getAll(options);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get the list of available fields for feeds.
|
|
44
|
+
*
|
|
45
|
+
* @returns A Promise resolving to an array of field names or null.
|
|
46
|
+
*/
|
|
47
|
+
async function feedFields_get() {
|
|
48
|
+
const feedGroup = new cumin_1.ChRISFeedGroup(); // Instantiate directly
|
|
49
|
+
if (!feedGroup) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const results = await feedGroup.asset.resourceFields_get();
|
|
53
|
+
return results ? results.fields : null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Create a new feed from a set of directories.
|
|
57
|
+
*
|
|
58
|
+
* This function orchestrates the creation of a new feed by uploading data
|
|
59
|
+
* from local directories to the ChRIS system.
|
|
60
|
+
*
|
|
61
|
+
* @param dirs - An array of local directory paths to upload.
|
|
62
|
+
* @param params - Optional parameters for the feed (e.g., name, tags).
|
|
63
|
+
* @returns A Promise resolving to the created feed record, or null if creation failed.
|
|
64
|
+
*/
|
|
65
|
+
async function feed_create(dirs, params = {}) {
|
|
66
|
+
const chrisFeed = new cumin_1.ChRISFeed();
|
|
67
|
+
// For now, assuming dirs is passed as is or joined.
|
|
68
|
+
const dirsArg = Array.isArray(dirs) ? dirs.join(',') : dirs;
|
|
69
|
+
return await chrisFeed.createFromDirs(dirsArg, params);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Shares a feed with specified ID and options.
|
|
73
|
+
*
|
|
74
|
+
* @param feedId - The ID of the feed to share.
|
|
75
|
+
* @param options - Sharing options, e.g., { is_public: true } to make public.
|
|
76
|
+
* @returns A Promise resolving to true on successful sharing, false otherwise.
|
|
77
|
+
*/
|
|
78
|
+
async function feeds_share(feedId, options) {
|
|
79
|
+
if (options.is_public === true) {
|
|
80
|
+
const result = await (0, cumin_1.feed_makePublic)(feedId);
|
|
81
|
+
return result.ok && result.value;
|
|
82
|
+
}
|
|
83
|
+
else if (options.is_public === false) {
|
|
84
|
+
const result = await (0, cumin_1.feed_makePrivate)(feedId);
|
|
85
|
+
return result.ok && result.value;
|
|
86
|
+
}
|
|
87
|
+
// Implement other sharing mechanisms (user/group) if needed based on options
|
|
88
|
+
cumin_1.errorStack.stack_push("error", "No valid sharing option specified (e.g., --is_public).");
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Deletes a feed by its ID.
|
|
93
|
+
*
|
|
94
|
+
* @param id - The ID of the feed to delete.
|
|
95
|
+
* @returns A Promise resolving to true on success, false on failure.
|
|
96
|
+
*/
|
|
97
|
+
async function feed_delete(id) {
|
|
98
|
+
const result = await (0, cumin_1.feed_delete)(id);
|
|
99
|
+
return result.ok && result.value;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/feeds/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgCH,gCAGC;AAQD,sCAGC;AAOD,wCASC;AAYD,kCAMC;AAiBD,kCAYC;AAQD,kCAGC;AAtHD,yCAYuB;AAEvB,uCAOuB;AANrB,qGAAA,YAAY,OAAA;AACZ,wGAAA,eAAe,OAAA;AACf,0GAAA,iBAAiB,OAAA;AACjB,2GAAA,kBAAkB,OAAA;AAClB,2GAAA,kBAAkB,OAAA;AAClB,2GAAA,kBAAkB,OAAA;AAIpB;;;;;GAKG;AACI,KAAK,UAAU,UAAU,CAAC,OAAoB;IACnD,MAAM,SAAS,GAAmB,IAAI,sBAAc,EAAE,CAAC;IACvD,OAAO,MAAM,SAAS,CAAC,KAAK,CAAC,gCAAgC,CAAC,OAAO,CAAC,CAAC;AACzE,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,aAAa,CAAC,OAA8B;IAChE,MAAM,SAAS,GAAmB,IAAI,sBAAc,EAAE,CAAC;IACvD,OAAO,MAAM,SAAS,CAAC,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AACzD,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,cAAc;IAClC,MAAM,SAAS,GAAmB,IAAI,sBAAc,EAAE,CAAC,CAAC,uBAAuB;IAE/E,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,kBAAkB,EAAE,CAAC;IAC3D,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACzC,CAAC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,WAAW,CAAC,IAAc,EAAE,SAA4B,EAAE;IAC9E,MAAM,SAAS,GAAc,IAAI,iBAAS,EAAE,CAAC;IAC7C,oDAAoD;IACpD,MAAM,OAAO,GAAW,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAEpE,OAAO,MAAM,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACzD,CAAC;AAUD;;;;;;GAMG;AACI,KAAK,UAAU,WAAW,CAAC,MAAc,EAAE,OAAyB;IACzE,IAAI,OAAO,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;QAC/B,MAAM,MAAM,GAAoB,MAAM,IAAA,uBAAe,EAAC,MAAM,CAAC,CAAC;QAC9D,OAAO,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,KAAK,CAAC;IACnC,CAAC;SAAM,IAAI,OAAO,CAAC,SAAS,KAAK,KAAK,EAAE,CAAC;QACvC,MAAM,MAAM,GAAoB,MAAM,IAAA,wBAAgB,EAAC,MAAM,CAAC,CAAC;QAC/D,OAAO,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,KAAK,CAAC;IACnC,CAAC;IAED,6EAA6E;IAC7E,kBAAU,CAAC,UAAU,CAAC,OAAO,EAAE,wDAAwD,CAAC,CAAC;IACzF,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,WAAW,CAAC,EAAU;IAC1C,MAAM,MAAM,GAAoB,MAAM,IAAA,mBAAiB,EAAC,EAAE,CAAC,CAAC;IAC5D,OAAO,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,KAAK,CAAC;AACnC,CAAC"}
|