@fnndsc/chili 3.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +113 -0
  3. package/dist/chefs/chefs.d.ts +15 -0
  4. package/dist/chefs/chefs.js +195 -0
  5. package/dist/commands/compute/fields.d.ts +6 -0
  6. package/dist/commands/compute/fields.js +13 -0
  7. package/dist/commands/compute/list.d.ts +19 -0
  8. package/dist/commands/compute/list.js +20 -0
  9. package/dist/commands/connect/login.d.ts +16 -0
  10. package/dist/commands/connect/login.js +18 -0
  11. package/dist/commands/connect/logout.d.ts +6 -0
  12. package/dist/commands/connect/logout.js +16 -0
  13. package/dist/commands/feed/comments.d.ts +41 -0
  14. package/dist/commands/feed/comments.js +45 -0
  15. package/dist/commands/feed/create.d.ts +13 -0
  16. package/dist/commands/feed/create.js +40 -0
  17. package/dist/commands/feed/note.d.ts +21 -0
  18. package/dist/commands/feed/note.js +24 -0
  19. package/dist/commands/feeds/delete.d.ts +14 -0
  20. package/dist/commands/feeds/delete.js +34 -0
  21. package/dist/commands/feeds/fields.d.ts +6 -0
  22. package/dist/commands/feeds/fields.js +17 -0
  23. package/dist/commands/feeds/list.d.ts +17 -0
  24. package/dist/commands/feeds/list.js +38 -0
  25. package/dist/commands/feeds/share.d.ts +17 -0
  26. package/dist/commands/feeds/share.js +19 -0
  27. package/dist/commands/file/view.d.ts +8 -0
  28. package/dist/commands/file/view.js +25 -0
  29. package/dist/commands/files/delete.d.ts +16 -0
  30. package/dist/commands/files/delete.js +36 -0
  31. package/dist/commands/files/fields.d.ts +7 -0
  32. package/dist/commands/files/fields.js +18 -0
  33. package/dist/commands/files/list.d.ts +11 -0
  34. package/dist/commands/files/list.js +23 -0
  35. package/dist/commands/fs/cat.d.ts +15 -0
  36. package/dist/commands/fs/cat.js +26 -0
  37. package/dist/commands/fs/cp.d.ts +17 -0
  38. package/dist/commands/fs/cp.js +26 -0
  39. package/dist/commands/fs/create.d.ts +15 -0
  40. package/dist/commands/fs/create.js +83 -0
  41. package/dist/commands/fs/download.d.ts +25 -0
  42. package/dist/commands/fs/download.js +235 -0
  43. package/dist/commands/fs/edit.d.ts +16 -0
  44. package/dist/commands/fs/edit.js +25 -0
  45. package/dist/commands/fs/ls.d.ts +18 -0
  46. package/dist/commands/fs/ls.js +142 -0
  47. package/dist/commands/fs/mkdir.d.ts +8 -0
  48. package/dist/commands/fs/mkdir.js +21 -0
  49. package/dist/commands/fs/mv.d.ts +13 -0
  50. package/dist/commands/fs/mv.js +73 -0
  51. package/dist/commands/fs/rm.d.ts +24 -0
  52. package/dist/commands/fs/rm.js +108 -0
  53. package/dist/commands/fs/touch.d.ts +16 -0
  54. package/dist/commands/fs/touch.js +62 -0
  55. package/dist/commands/fs/upload.d.ts +55 -0
  56. package/dist/commands/fs/upload.js +221 -0
  57. package/dist/commands/groups/fields.d.ts +6 -0
  58. package/dist/commands/groups/fields.js +13 -0
  59. package/dist/commands/groups/list.d.ts +16 -0
  60. package/dist/commands/groups/list.js +26 -0
  61. package/dist/commands/man/doc.d.ts +16 -0
  62. package/dist/commands/man/doc.js +32 -0
  63. package/dist/commands/man/topics.d.ts +6 -0
  64. package/dist/commands/man/topics.js +27 -0
  65. package/dist/commands/pipeline/fields.d.ts +6 -0
  66. package/dist/commands/pipeline/fields.js +13 -0
  67. package/dist/commands/pipeline/run.d.ts +18 -0
  68. package/dist/commands/pipeline/run.js +33 -0
  69. package/dist/commands/plugin/readme.d.ts +14 -0
  70. package/dist/commands/plugin/readme.js +49 -0
  71. package/dist/commands/plugin/run.d.ts +10 -0
  72. package/dist/commands/plugin/run.js +29 -0
  73. package/dist/commands/plugin/search.d.ts +7 -0
  74. package/dist/commands/plugin/search.js +18 -0
  75. package/dist/commands/plugininstances/fields.d.ts +6 -0
  76. package/dist/commands/plugininstances/fields.js +13 -0
  77. package/dist/commands/plugininstances/list.d.ts +16 -0
  78. package/dist/commands/plugininstances/list.js +26 -0
  79. package/dist/commands/pluginmetas/fields.d.ts +6 -0
  80. package/dist/commands/pluginmetas/fields.js +13 -0
  81. package/dist/commands/pluginmetas/list.d.ts +16 -0
  82. package/dist/commands/pluginmetas/list.js +26 -0
  83. package/dist/commands/plugins/add.d.ts +34 -0
  84. package/dist/commands/plugins/add.js +374 -0
  85. package/dist/commands/plugins/delete.d.ts +14 -0
  86. package/dist/commands/plugins/delete.js +34 -0
  87. package/dist/commands/plugins/fields.d.ts +6 -0
  88. package/dist/commands/plugins/fields.js +17 -0
  89. package/dist/commands/plugins/list.d.ts +17 -0
  90. package/dist/commands/plugins/list.js +40 -0
  91. package/dist/commands/plugins/overview.d.ts +6 -0
  92. package/dist/commands/plugins/overview.js +17 -0
  93. package/dist/commands/store/list.d.ts +23 -0
  94. package/dist/commands/store/list.js +48 -0
  95. package/dist/commands/tags/fields.d.ts +6 -0
  96. package/dist/commands/tags/fields.js +13 -0
  97. package/dist/commands/tags/list.d.ts +16 -0
  98. package/dist/commands/tags/list.js +26 -0
  99. package/dist/commands/workflows/fields.d.ts +6 -0
  100. package/dist/commands/workflows/fields.js +13 -0
  101. package/dist/commands/workflows/list.d.ts +16 -0
  102. package/dist/commands/workflows/list.js +26 -0
  103. package/dist/config/colorConfig.d.ts +56 -0
  104. package/dist/config/colorConfig.js +161 -0
  105. package/dist/connect/connectHandler.d.ts +15 -0
  106. package/dist/connect/connectHandler.js +48 -0
  107. package/dist/context/contextCommand.d.ts +13 -0
  108. package/dist/context/contextCommand.js +193 -0
  109. package/dist/controllers/baseController.d.ts +43 -0
  110. package/dist/controllers/baseController.js +67 -0
  111. package/dist/controllers/feedController.d.ts +35 -0
  112. package/dist/controllers/feedController.js +53 -0
  113. package/dist/controllers/fileController.d.ts +56 -0
  114. package/dist/controllers/fileController.js +93 -0
  115. package/dist/controllers/pluginContextController.d.ts +24 -0
  116. package/dist/controllers/pluginContextController.js +49 -0
  117. package/dist/controllers/pluginController.d.ts +70 -0
  118. package/dist/controllers/pluginController.js +98 -0
  119. package/dist/controllers/pluginMetaController.d.ts +41 -0
  120. package/dist/controllers/pluginMetaController.js +52 -0
  121. package/dist/feeds/feedHandler.d.ts +64 -0
  122. package/dist/feeds/feedHandler.js +203 -0
  123. package/dist/filesystem/fileGroupHandler.d.ts +92 -0
  124. package/dist/filesystem/fileGroupHandler.js +318 -0
  125. package/dist/filesystem/filesystemHandler.d.ts +12 -0
  126. package/dist/filesystem/filesystemHandler.js +135 -0
  127. package/dist/filesystem/inodeCommand.d.ts +12 -0
  128. package/dist/filesystem/inodeCommand.js +37 -0
  129. package/dist/handlers/baseGroupHandler.d.ts +103 -0
  130. package/dist/handlers/baseGroupHandler.js +342 -0
  131. package/dist/index.d.ts +7 -0
  132. package/dist/index.js +239 -0
  133. package/dist/lfs/lfs.d.ts +25 -0
  134. package/dist/lfs/lfs.js +74 -0
  135. package/dist/man/man.d.ts +15 -0
  136. package/dist/man/man.js +31 -0
  137. package/dist/man/renderer.d.ts +26 -0
  138. package/dist/man/renderer.js +187 -0
  139. package/dist/models/feed.d.ts +18 -0
  140. package/dist/models/feed.js +8 -0
  141. package/dist/models/listing.d.ts +33 -0
  142. package/dist/models/listing.js +9 -0
  143. package/dist/models/plugin.d.ts +27 -0
  144. package/dist/models/plugin.js +1 -0
  145. package/dist/models/resource.d.ts +39 -0
  146. package/dist/models/resource.js +9 -0
  147. package/dist/pacs/pacsQueryHandler.d.ts +55 -0
  148. package/dist/pacs/pacsQueryHandler.js +196 -0
  149. package/dist/pacs/pacsQueryPayload.d.ts +19 -0
  150. package/dist/pacs/pacsQueryPayload.js +44 -0
  151. package/dist/pacs/pacsResultRender.d.ts +20 -0
  152. package/dist/pacs/pacsResultRender.js +141 -0
  153. package/dist/pacs/pacsRetrieveHandler.d.ts +87 -0
  154. package/dist/pacs/pacsRetrieveHandler.js +272 -0
  155. package/dist/pacs/pacsServerHandler.d.ts +15 -0
  156. package/dist/pacs/pacsServerHandler.js +32 -0
  157. package/dist/path/pathCommand.d.ts +64 -0
  158. package/dist/path/pathCommand.js +805 -0
  159. package/dist/path/pathMapper.d.ts +189 -0
  160. package/dist/path/pathMapper.js +382 -0
  161. package/dist/plugins/pluginGroupHandler.d.ts +42 -0
  162. package/dist/plugins/pluginGroupHandler.js +90 -0
  163. package/dist/plugins/pluginHandler.d.ts +87 -0
  164. package/dist/plugins/pluginHandler.js +303 -0
  165. package/dist/plugins/pluginMetaHandler.d.ts +21 -0
  166. package/dist/plugins/pluginMetaHandler.js +27 -0
  167. package/dist/screen/screen.d.ts +214 -0
  168. package/dist/screen/screen.js +478 -0
  169. package/dist/utils/admin_prompt.d.ts +42 -0
  170. package/dist/utils/admin_prompt.js +105 -0
  171. package/dist/utils/cli.d.ts +67 -0
  172. package/dist/utils/cli.js +112 -0
  173. package/dist/utils/docker.d.ts +74 -0
  174. package/dist/utils/docker.js +155 -0
  175. package/dist/utils/input_format.d.ts +77 -0
  176. package/dist/utils/input_format.js +135 -0
  177. package/dist/utils/sort.d.ts +29 -0
  178. package/dist/utils/sort.js +63 -0
  179. package/dist/utils/ui.d.ts +7 -0
  180. package/dist/utils/ui.js +26 -0
  181. package/dist/utils.d.ts +15 -0
  182. package/dist/utils.js +14 -0
  183. package/dist/views/compute.d.ts +17 -0
  184. package/dist/views/compute.js +40 -0
  185. package/dist/views/connect.d.ts +13 -0
  186. package/dist/views/connect.js +35 -0
  187. package/dist/views/feed.d.ts +44 -0
  188. package/dist/views/feed.js +110 -0
  189. package/dist/views/file.d.ts +25 -0
  190. package/dist/views/file.js +71 -0
  191. package/dist/views/fs.d.ts +51 -0
  192. package/dist/views/fs.js +105 -0
  193. package/dist/views/ls.d.ts +37 -0
  194. package/dist/views/ls.js +190 -0
  195. package/dist/views/plugin.d.ts +28 -0
  196. package/dist/views/plugin.js +71 -0
  197. package/dist/views/pluginParameters.d.ts +17 -0
  198. package/dist/views/pluginParameters.js +79 -0
  199. package/docs/00_intro.adoc +25 -0
  200. package/docs/01_setup.adoc +63 -0
  201. package/docs/02_context.adoc +128 -0
  202. package/docs/03_searchable.adoc +134 -0
  203. package/docs/10_everyday_examples.adoc +9 -0
  204. package/docs/11_upload_data.adoc +146 -0
  205. package/docs/12_create_a_feed.adoc +9 -0
  206. package/docs/13_run_a_plugin.adoc +271 -0
  207. package/docs/20_plugins.adoc +16 -0
  208. package/docs/21_pluginReadme.adoc +123 -0
  209. package/docs/30_filesystem.adoc +93 -0
  210. package/docs/31_fileops.adoc +51 -0
  211. package/docs/32_file_content.adoc +471 -0
  212. package/docs/_architecture.adoc +48 -0
  213. package/docs/_deepContext.adoc +84 -0
  214. package/docs/_roadmap.adoc +42 -0
  215. package/docs/_searchable.adoc +187 -0
  216. package/docs/_state.adoc +68 -0
  217. package/docs/pacs.adoc +101 -0
  218. package/docs/pathMapper.md +246 -0
  219. package/package.json +92 -0
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @file Implements the logic for searching and deleting ChRIS feeds.
3
+ *
4
+ * This module provides functionality to search for feeds by term
5
+ * and delete them by ID using the `@fnndsc/salsa` library.
6
+ *
7
+ * @module
8
+ */
9
+ import { feeds_list as salsaFeeds_list, feed_delete as salsaFeed_delete } from "@fnndsc/salsa";
10
+ import { options_toParams } from "../../utils/cli.js";
11
+ /**
12
+ * Resolves search terms to a list of feed items.
13
+ *
14
+ * @param searchable - The search string.
15
+ * @returns A Promise resolving to an array of feed items (table data).
16
+ */
17
+ export async function feeds_searchByTerm(searchable) {
18
+ const options = { search: searchable };
19
+ const params = options_toParams(options);
20
+ const results = await salsaFeeds_list(params);
21
+ if (!results || !results.tableData) {
22
+ return [];
23
+ }
24
+ return results.tableData;
25
+ }
26
+ /**
27
+ * Deletes a feed by its ID.
28
+ *
29
+ * @param id - The ID of the feed to delete.
30
+ * @returns A Promise resolving to `true` on success, `false` otherwise.
31
+ */
32
+ export async function feed_deleteById(id) {
33
+ return await salsaFeed_delete(id);
34
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Fetches the list of available fields for feeds.
3
+ *
4
+ * @returns A Promise resolving to an array of field names, or `null` if retrieval fails.
5
+ */
6
+ export declare function feedFields_fetch(): Promise<string[] | null>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @file Implements the logic for retrieving available fields for ChRIS feeds.
3
+ *
4
+ * This module provides functionality to fetch the list of valid fields
5
+ * that can be displayed or queried for feeds.
6
+ *
7
+ * @module
8
+ */
9
+ import { feedFields_get as salsaFeedFields_get } from "@fnndsc/salsa";
10
+ /**
11
+ * Fetches the list of available fields for feeds.
12
+ *
13
+ * @returns A Promise resolving to an array of field names, or `null` if retrieval fails.
14
+ */
15
+ export async function feedFields_fetch() {
16
+ return await salsaFeedFields_get();
17
+ }
@@ -0,0 +1,17 @@
1
+ import { CLIoptions } from "../../utils/cli.js";
2
+ import { Feed } from "../../models/feed.js";
3
+ /**
4
+ * Result structure for feed listing.
5
+ */
6
+ export interface FeedListResult {
7
+ feeds: Feed[];
8
+ selectedFields: string[];
9
+ totalCount?: number;
10
+ }
11
+ /**
12
+ * Fetches a list of ChRIS feeds based on options.
13
+ *
14
+ * @param options - CLI options containing filtering/pagination parameters.
15
+ * @returns A Promise resolving to a `FeedListResult` object.
16
+ */
17
+ export declare function feeds_fetchList(options: CLIoptions): Promise<FeedListResult>;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @file Implements the logic for listing ChRIS feeds.
3
+ *
4
+ * This module provides functionality to fetch lists of feeds
5
+ * from ChRIS using the `@fnndsc/salsa` library.
6
+ *
7
+ * @module
8
+ */
9
+ import { feeds_list as salsaFeeds_list, feeds_listAll as salsaFeeds_listAll } from "@fnndsc/salsa";
10
+ import { options_toParams } from "../../utils/cli.js";
11
+ import { list_applySort } from "../../utils/sort.js";
12
+ /**
13
+ * Fetches a list of ChRIS feeds based on options.
14
+ *
15
+ * @param options - CLI options containing filtering/pagination parameters.
16
+ * @returns A Promise resolving to a `FeedListResult` object.
17
+ */
18
+ export async function feeds_fetchList(options) {
19
+ const params = options_toParams(options);
20
+ if (options.user)
21
+ params.owner_username = options.user;
22
+ const result = options.all
23
+ ? await salsaFeeds_listAll(params)
24
+ : await salsaFeeds_list(params);
25
+ if (result && result.tableData) {
26
+ let feeds = result.tableData;
27
+ // Apply sorting if specified
28
+ if (options.sort) {
29
+ feeds = list_applySort(feeds, options.sort, options.reverse);
30
+ }
31
+ return {
32
+ feeds,
33
+ selectedFields: result.selectedFields || [],
34
+ totalCount: result.totalCount,
35
+ };
36
+ }
37
+ return { feeds: [], selectedFields: [] };
38
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @file Implements the logic for sharing ChRIS feeds.
3
+ *
4
+ * This module provides functionality to share a specific feed
5
+ * with other users using the `@fnndsc/salsa` library.
6
+ *
7
+ * @module
8
+ */
9
+ import { FeedShareOptions } from "@fnndsc/salsa";
10
+ /**
11
+ * Shares a feed with other users.
12
+ *
13
+ * @param feedId - The ID of the feed to share.
14
+ * @param options - Sharing options (e.g., list of users).
15
+ * @returns A Promise resolving to `true` on success, `false` otherwise.
16
+ */
17
+ export declare function feed_shareById(feedId: number, options: FeedShareOptions): Promise<boolean>;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @file Implements the logic for sharing ChRIS feeds.
3
+ *
4
+ * This module provides functionality to share a specific feed
5
+ * with other users using the `@fnndsc/salsa` library.
6
+ *
7
+ * @module
8
+ */
9
+ import { feeds_share as salsaFeeds_share } from "@fnndsc/salsa";
10
+ /**
11
+ * Shares a feed with other users.
12
+ *
13
+ * @param feedId - The ID of the feed to share.
14
+ * @param options - Sharing options (e.g., list of users).
15
+ * @returns A Promise resolving to `true` on success, `false` otherwise.
16
+ */
17
+ export async function feed_shareById(feedId, options) {
18
+ return await salsaFeeds_share(feedId, options);
19
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Fetches the content of a ChRIS file as a UTF-8 string.
3
+ *
4
+ * @param fileIdentifier - The path of the file to view.
5
+ * @returns A Promise resolving to the file content as a string, or `null` if empty/not found.
6
+ * @throws {Error} If the operation fails and an error is pushed to the stack.
7
+ */
8
+ export declare function files_viewContent(fileIdentifier: string): Promise<string | null>;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @file Implements the logic for viewing the content of ChRIS files.
3
+ *
4
+ * This module provides functionality to retrieve the content of a file
5
+ * either by its direct ID or by resolving a name/path search term.
6
+ *
7
+ * @module
8
+ */
9
+ import { fileContent_get } from "@fnndsc/salsa";
10
+ /**
11
+ * Fetches the content of a ChRIS file as a UTF-8 string.
12
+ *
13
+ * @param fileIdentifier - The path of the file to view.
14
+ * @returns A Promise resolving to the file content as a string, or `null` if empty/not found.
15
+ * @throws {Error} If the operation fails and an error is pushed to the stack.
16
+ */
17
+ export async function files_viewContent(fileIdentifier) {
18
+ const result = await fileContent_get(fileIdentifier);
19
+ if (!result.ok) {
20
+ // Errors are pushed to the stack within salsa, so we can just throw a generic error here
21
+ // or let the controller handle it by checking the error stack. For now, let's throw.
22
+ throw new Error(`Failed to view content for: ${fileIdentifier}`);
23
+ }
24
+ return result.value;
25
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Resolves search terms to a list of file items.
3
+ *
4
+ * @param searchable - The search string.
5
+ * @param assetName - The asset name ('files', 'links', 'dirs').
6
+ * @returns A Promise resolving to an array of file items (table data).
7
+ */
8
+ export declare function files_searchByTerm(searchable: string, assetName: string): Promise<Record<string, unknown>[]>;
9
+ /**
10
+ * Deletes a file resource by its ID.
11
+ *
12
+ * @param id - The ID of the file/resource to delete.
13
+ * @param assetName - The asset name ('files', 'links', 'dirs').
14
+ * @returns A Promise resolving to `true` on success, `false` otherwise.
15
+ */
16
+ export declare function files_deleteById(id: number, assetName: string): Promise<boolean>;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @file Implements the logic for searching and deleting ChRIS file resources.
3
+ *
4
+ * This module provides functionality to search for files by term and delete them
5
+ * by ID, utilizing the `@fnndsc/salsa` library.
6
+ *
7
+ * @module
8
+ */
9
+ import { files_list as salsaFiles_list, files_delete as salsaFiles_delete } from "@fnndsc/salsa";
10
+ import { options_toParams } from "../../utils/cli.js";
11
+ /**
12
+ * Resolves search terms to a list of file items.
13
+ *
14
+ * @param searchable - The search string.
15
+ * @param assetName - The asset name ('files', 'links', 'dirs').
16
+ * @returns A Promise resolving to an array of file items (table data).
17
+ */
18
+ export async function files_searchByTerm(searchable, assetName) {
19
+ const options = { search: searchable };
20
+ const params = options_toParams(options);
21
+ const results = await salsaFiles_list(params, assetName);
22
+ if (!results || !results.tableData) {
23
+ return [];
24
+ }
25
+ return results.tableData;
26
+ }
27
+ /**
28
+ * Deletes a file resource by its ID.
29
+ *
30
+ * @param id - The ID of the file/resource to delete.
31
+ * @param assetName - The asset name ('files', 'links', 'dirs').
32
+ * @returns A Promise resolving to `true` on success, `false` otherwise.
33
+ */
34
+ export async function files_deleteById(id, assetName) {
35
+ return await salsaFiles_delete(id, assetName);
36
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Fetches the list of available fields for a given asset type.
3
+ *
4
+ * @param assetName - The asset name ('files', 'links', 'dirs'). Defaults to 'files'.
5
+ * @returns A Promise resolving to an array of field names, or `null` if retrieval fails.
6
+ */
7
+ export declare function fileFields_fetch(assetName?: string): Promise<string[] | null>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @file Implements the logic for retrieving available fields for ChRIS file resources.
3
+ *
4
+ * This module provides functionality to fetch the list of valid fields
5
+ * that can be displayed or queried for files, directories, or links.
6
+ *
7
+ * @module
8
+ */
9
+ import { fileFields_get as salsaFileFields_get } from "@fnndsc/salsa";
10
+ /**
11
+ * Fetches the list of available fields for a given asset type.
12
+ *
13
+ * @param assetName - The asset name ('files', 'links', 'dirs'). Defaults to 'files'.
14
+ * @returns A Promise resolving to an array of field names, or `null` if retrieval fails.
15
+ */
16
+ export async function fileFields_fetch(assetName = "files") {
17
+ return await salsaFileFields_get(assetName);
18
+ }
@@ -0,0 +1,11 @@
1
+ import { FilteredResourceData } from "@fnndsc/cumin";
2
+ import { CLIoptions } from "../../utils/cli.js";
3
+ /**
4
+ * Fetches a list of ChRIS resources (files, links, or dirs) based on options.
5
+ *
6
+ * @param options - CLI options containing filtering/pagination parameters.
7
+ * @param assetName - The type of asset to list ('files', 'links', 'dirs'). Defaults to 'files'.
8
+ * @param path - Optional ChRIS path to list resources from.
9
+ * @returns A Promise resolving to `FilteredResourceData` or `null` if the request fails/returns nothing.
10
+ */
11
+ export declare function files_fetchList(options: CLIoptions, assetName?: string, path?: string): Promise<FilteredResourceData | null>;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @file Implements the logic for listing ChRIS file resources.
3
+ *
4
+ * This module provides functionality to fetch lists of files, directories, or links
5
+ * from ChRIS using the `@fnndsc/salsa` library. It handles option parsing
6
+ * and delegates the actual API call.
7
+ *
8
+ * @module
9
+ */
10
+ import { files_list as salsaFiles_list } from "@fnndsc/salsa";
11
+ import { options_toParams } from "../../utils/cli.js";
12
+ /**
13
+ * Fetches a list of ChRIS resources (files, links, or dirs) based on options.
14
+ *
15
+ * @param options - CLI options containing filtering/pagination parameters.
16
+ * @param assetName - The type of asset to list ('files', 'links', 'dirs'). Defaults to 'files'.
17
+ * @param path - Optional ChRIS path to list resources from.
18
+ * @returns A Promise resolving to `FilteredResourceData` or `null` if the request fails/returns nothing.
19
+ */
20
+ export async function files_fetchList(options, assetName = "files", path) {
21
+ const params = options_toParams(options);
22
+ return await salsaFiles_list(params, assetName, path);
23
+ }
@@ -0,0 +1,15 @@
1
+ import { Result } from "@fnndsc/cumin";
2
+ /**
3
+ * Retrieves the content of a file.
4
+ *
5
+ * @param filePath - The path to the file.
6
+ * @returns Promise resolving to content string or null.
7
+ */
8
+ export declare function files_cat(filePath: string): Promise<Result<string>>;
9
+ /**
10
+ * Retrieves the binary content of a file.
11
+ *
12
+ * @param filePath - The path to the file.
13
+ * @returns Promise resolving to content Buffer or error.
14
+ */
15
+ export declare function files_catBinary(filePath: string): Promise<Result<Buffer>>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @file Implements the core logic for the `cat` command.
3
+ * @module
4
+ */
5
+ import { fileContent_get, fileContent_getBinary } from "@fnndsc/salsa";
6
+ import { path_resolveChrisFs } from "../../utils/cli.js";
7
+ /**
8
+ * Retrieves the content of a file.
9
+ *
10
+ * @param filePath - The path to the file.
11
+ * @returns Promise resolving to content string or null.
12
+ */
13
+ export async function files_cat(filePath) {
14
+ const resolved = await path_resolveChrisFs(filePath, {});
15
+ return await fileContent_get(resolved);
16
+ }
17
+ /**
18
+ * Retrieves the binary content of a file.
19
+ *
20
+ * @param filePath - The path to the file.
21
+ * @returns Promise resolving to content Buffer or error.
22
+ */
23
+ export async function files_catBinary(filePath) {
24
+ const resolved = await path_resolveChrisFs(filePath, {});
25
+ return await fileContent_getBinary(resolved);
26
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Options for the copy operation.
3
+ */
4
+ export interface CpOptions {
5
+ /** Recursively copy directories. */
6
+ recursive?: boolean;
7
+ }
8
+ /**
9
+ * Copies a file or directory.
10
+ * Delegates the operation directly to the centralized vfsDispatcher.
11
+ *
12
+ * @param src - Source path.
13
+ * @param dest - Destination path.
14
+ * @param options - Copy options (recursive).
15
+ * @returns Promise<boolean> success.
16
+ */
17
+ export declare function files_cp(src: string, dest: string, options: CpOptions): Promise<boolean>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @file Copy command logic.
3
+ *
4
+ * @module
5
+ */
6
+ import { vfsDispatcher } from "@fnndsc/salsa";
7
+ import { errorStack } from "@fnndsc/cumin";
8
+ /**
9
+ * Copies a file or directory.
10
+ * Delegates the operation directly to the centralized vfsDispatcher.
11
+ *
12
+ * @param src - Source path.
13
+ * @param dest - Destination path.
14
+ * @param options - Copy options (recursive).
15
+ * @returns Promise<boolean> success.
16
+ */
17
+ export async function files_cp(src, dest, options) {
18
+ try {
19
+ return await vfsDispatcher.cp(src, dest, options);
20
+ }
21
+ catch (error) {
22
+ const msg = error instanceof Error ? error.message : String(error);
23
+ errorStack.stack_push("error", `cp command failed: ${msg}`);
24
+ return false;
25
+ }
26
+ }
@@ -0,0 +1,15 @@
1
+ import { CLIoptions } from "../../utils/cli.js";
2
+ /**
3
+ * Core logic for the 'file create' command.
4
+ *
5
+ * This function handles the creation of a new file in the ChRIS file system.
6
+ * It resolves the target path, retrieves the content, and calls the
7
+ * underlying file creation service. It also includes robust error handling
8
+ * and provides informative error messages.
9
+ *
10
+ * @param fileIdentifier - The primary argument for the file (name or path). Can be undefined if options.name is provided.
11
+ * @param options - CLI options including `--content`, `--from-file`, `--path`, `--name`.
12
+ * @returns A Promise resolving to `true` on successful file creation, `false` otherwise.
13
+ * @throws {Error} On invalid input (e.g., missing filename), issues with content retrieval, or if underlying file creation operations fail.
14
+ */
15
+ export declare function files_create(fileIdentifier: string | undefined, options: CLIoptions): Promise<boolean>;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @file Implements the core logic for the `create` command in the ChRIS CLI.
3
+ *
4
+ * This module provides functionality to create new files within the ChRIS
5
+ * file system, allowing content to be specified directly or read from a local file.
6
+ * It interacts with `@fnndsc/salsa` for file creation and `@fnndsc/cumin`
7
+ * for error handling.
8
+ *
9
+ * @module
10
+ */
11
+ import { files_create as salsaFiles_create } from "@fnndsc/salsa";
12
+ import { path_resolveChrisFs } from "../../utils/cli.js";
13
+ import * as fs from "fs";
14
+ import { errorStack_getAllOfType } from "@fnndsc/cumin";
15
+ /**
16
+ * Retrieves the content for a new file based on provided CLI options.
17
+ *
18
+ * This function handles content specified directly via `--content` or
19
+ * read from a local file path via `--from-file`. It ensures that only one
20
+ * content source is used and validates the existence of local files.
21
+ *
22
+ * @param options - CLI options, which may include `content` (string) or `fromFile` (path to a local file).
23
+ * @returns The file content as a `string` or `Buffer`.
24
+ * @throws {Error} If both `--content` and `--from-file` are used, or if the local file specified by `--from-file` is not found.
25
+ */
26
+ function content_get(options) {
27
+ if (options.content && options.fromFile) {
28
+ throw new Error('Cannot use both --content and --from-file. Please choose one.');
29
+ }
30
+ if (options.content) {
31
+ return options.content;
32
+ }
33
+ if (options.fromFile) {
34
+ if (!fs.existsSync(options.fromFile)) {
35
+ throw new Error(`Local file not found at ${options.fromFile}`);
36
+ }
37
+ return fs.readFileSync(options.fromFile);
38
+ }
39
+ // Default to empty content if no source is specified
40
+ return "";
41
+ }
42
+ /**
43
+ * Core logic for the 'file create' command.
44
+ *
45
+ * This function handles the creation of a new file in the ChRIS file system.
46
+ * It resolves the target path, retrieves the content, and calls the
47
+ * underlying file creation service. It also includes robust error handling
48
+ * and provides informative error messages.
49
+ *
50
+ * @param fileIdentifier - The primary argument for the file (name or path). Can be undefined if options.name is provided.
51
+ * @param options - CLI options including `--content`, `--from-file`, `--path`, `--name`.
52
+ * @returns A Promise resolving to `true` on successful file creation, `false` otherwise.
53
+ * @throws {Error} On invalid input (e.g., missing filename), issues with content retrieval, or if underlying file creation operations fail.
54
+ */
55
+ export async function files_create(fileIdentifier, options) {
56
+ if (!fileIdentifier && !options.name) {
57
+ throw new Error('Filename or path is required.');
58
+ }
59
+ try {
60
+ const content = content_get(options);
61
+ const resolvedChRISPath = await path_resolveChrisFs(fileIdentifier, options);
62
+ const success = await salsaFiles_create(content, resolvedChRISPath);
63
+ if (!success) {
64
+ const errorStackItems = errorStack_getAllOfType("error");
65
+ if (errorStackItems.length > 0) {
66
+ // We throw here so that the calling handler can decide how to display the error.
67
+ throw new Error(errorStackItems.join(', '));
68
+ }
69
+ else {
70
+ throw new Error(`An unknown error occurred while creating the file at ${resolvedChRISPath}.`);
71
+ }
72
+ }
73
+ return success;
74
+ }
75
+ catch (error) {
76
+ if (error instanceof Error) {
77
+ // Re-throw with a more specific prefix to aid debugging
78
+ throw new Error(`Error creating file: ${error.message}`);
79
+ }
80
+ // Re-throw anything else
81
+ throw error;
82
+ }
83
+ }
@@ -0,0 +1,25 @@
1
+ import { bytes_format } from "./upload.js";
2
+ export { bytes_format };
3
+ /**
4
+ * Download summary statistics.
5
+ */
6
+ export interface DownloadSummary {
7
+ startTime: number;
8
+ endTime: number;
9
+ totalFiles: number;
10
+ transferredCount: number;
11
+ failedCount: number;
12
+ transferSize: number;
13
+ duration: number;
14
+ speed: number;
15
+ }
16
+ /**
17
+ * Downloads files from ChRIS with a progress bar display.
18
+ * @param chrisPath - Remote ChRIS path (file or directory).
19
+ * @param localPath - Local filesystem path.
20
+ * @param options - Download options.
21
+ * @returns Promise<DownloadSummary> with download statistics.
22
+ */
23
+ export declare function files_downloadWithProgress(chrisPath: string, localPath: string, options?: {
24
+ force?: boolean;
25
+ }): Promise<DownloadSummary>;