@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.
Files changed (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +164 -0
  3. package/dist/compute/index.d.ts +17 -0
  4. package/dist/compute/index.js +33 -0
  5. package/dist/compute/index.js.map +1 -0
  6. package/dist/connect/index.d.ts +25 -0
  7. package/dist/connect/index.js +27 -0
  8. package/dist/connect/index.js.map +1 -0
  9. package/dist/context/index.d.ts +38 -0
  10. package/dist/context/index.js +58 -0
  11. package/dist/context/index.js.map +1 -0
  12. package/dist/feeds/index.d.ts +60 -0
  13. package/dist/feeds/index.js +101 -0
  14. package/dist/feeds/index.js.map +1 -0
  15. package/dist/files/index.d.ts +179 -0
  16. package/dist/files/index.js +562 -0
  17. package/dist/files/index.js.map +1 -0
  18. package/dist/files/pacs_content.d.ts +29 -0
  19. package/dist/files/pacs_content.js +121 -0
  20. package/dist/files/pacs_content.js.map +1 -0
  21. package/dist/files/pipeline_content.d.ts +22 -0
  22. package/dist/files/pipeline_content.js +31 -0
  23. package/dist/files/pipeline_content.js.map +1 -0
  24. package/dist/files/regular_content.d.ts +33 -0
  25. package/dist/files/regular_content.js +177 -0
  26. package/dist/files/regular_content.js.map +1 -0
  27. package/dist/groups/index.d.ts +21 -0
  28. package/dist/groups/index.js +37 -0
  29. package/dist/groups/index.js.map +1 -0
  30. package/dist/index.d.ts +21 -0
  31. package/dist/index.js +42 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/jobs/index.d.ts +6 -0
  34. package/dist/jobs/index.js +17 -0
  35. package/dist/jobs/index.js.map +1 -0
  36. package/dist/jobs/jobOps.d.ts +108 -0
  37. package/dist/jobs/jobOps.js +307 -0
  38. package/dist/jobs/jobOps.js.map +1 -0
  39. package/dist/pacs/index.d.ts +64 -0
  40. package/dist/pacs/index.js +91 -0
  41. package/dist/pacs/index.js.map +1 -0
  42. package/dist/pacs/resultDecode.d.ts +13 -0
  43. package/dist/pacs/resultDecode.js +19 -0
  44. package/dist/pacs/resultDecode.js.map +1 -0
  45. package/dist/pipelines/index.d.ts +58 -0
  46. package/dist/pipelines/index.js +194 -0
  47. package/dist/pipelines/index.js.map +1 -0
  48. package/dist/plugininstances/index.d.ts +15 -0
  49. package/dist/plugininstances/index.js +27 -0
  50. package/dist/plugininstances/index.js.map +1 -0
  51. package/dist/pluginmetas/index.d.ts +21 -0
  52. package/dist/pluginmetas/index.js +37 -0
  53. package/dist/pluginmetas/index.js.map +1 -0
  54. package/dist/plugins/index.d.ts +118 -0
  55. package/dist/plugins/index.js +247 -0
  56. package/dist/plugins/index.js.map +1 -0
  57. package/dist/plugins/internal/plugin_executeContinueFeed.d.ts +17 -0
  58. package/dist/plugins/internal/plugin_executeContinueFeed.js +65 -0
  59. package/dist/plugins/internal/plugin_executeContinueFeed.js.map +1 -0
  60. package/dist/plugins/internal/plugin_executeNewFeed.d.ts +32 -0
  61. package/dist/plugins/internal/plugin_executeNewFeed.js +97 -0
  62. package/dist/plugins/internal/plugin_executeNewFeed.js.map +1 -0
  63. package/dist/plugins/peer_search.d.ts +65 -0
  64. package/dist/plugins/peer_search.js +94 -0
  65. package/dist/plugins/peer_search.js.map +1 -0
  66. package/dist/plugins/plugin_executeInPlace.d.ts +69 -0
  67. package/dist/plugins/plugin_executeInPlace.js +66 -0
  68. package/dist/plugins/plugin_executeInPlace.js.map +1 -0
  69. package/dist/plugins/plugin_register.d.ts +64 -0
  70. package/dist/plugins/plugin_register.js +121 -0
  71. package/dist/plugins/plugin_register.js.map +1 -0
  72. package/dist/plugins/store_import.d.ts +64 -0
  73. package/dist/plugins/store_import.js +196 -0
  74. package/dist/plugins/store_import.js.map +1 -0
  75. package/dist/store/index.d.ts +15 -0
  76. package/dist/store/index.js +37 -0
  77. package/dist/store/index.js.map +1 -0
  78. package/dist/tags/index.d.ts +21 -0
  79. package/dist/tags/index.js +37 -0
  80. package/dist/tags/index.js.map +1 -0
  81. package/dist/vfs/dispatcher.d.ts +83 -0
  82. package/dist/vfs/dispatcher.js +192 -0
  83. package/dist/vfs/dispatcher.js.map +1 -0
  84. package/dist/vfs/index.d.ts +9 -0
  85. package/dist/vfs/index.js +26 -0
  86. package/dist/vfs/index.js.map +1 -0
  87. package/dist/vfs/provider.d.ts +80 -0
  88. package/dist/vfs/provider.js +11 -0
  89. package/dist/vfs/provider.js.map +1 -0
  90. package/dist/vfs/providers/etc.d.ts +44 -0
  91. package/dist/vfs/providers/etc.js +119 -0
  92. package/dist/vfs/providers/etc.js.map +1 -0
  93. package/dist/vfs/providers/native.d.ts +34 -0
  94. package/dist/vfs/providers/native.js +168 -0
  95. package/dist/vfs/providers/native.js.map +1 -0
  96. package/dist/vfs/providers/pacs.d.ts +56 -0
  97. package/dist/vfs/providers/pacs.js +413 -0
  98. package/dist/vfs/providers/pacs.js.map +1 -0
  99. package/dist/vfs/providers/pacsHelpers.d.ts +27 -0
  100. package/dist/vfs/providers/pacsHelpers.js +108 -0
  101. package/dist/vfs/providers/pacsHelpers.js.map +1 -0
  102. package/dist/vfs/providers/pacs_content.d.ts +27 -0
  103. package/dist/vfs/providers/pacs_content.js +137 -0
  104. package/dist/vfs/providers/pacs_content.js.map +1 -0
  105. package/dist/vfs/providers/proc.d.ts +62 -0
  106. package/dist/vfs/providers/proc.js +478 -0
  107. package/dist/vfs/providers/proc.js.map +1 -0
  108. package/dist/workflows/index.d.ts +21 -0
  109. package/dist/workflows/index.js +37 -0
  110. package/dist/workflows/index.js.map +1 -0
  111. package/package.json +57 -0
@@ -0,0 +1,247 @@
1
+ "use strict";
2
+ /**
3
+ * @file Plugin management operations.
4
+ * @module
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
+ };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.plugins_list = plugins_list;
25
+ exports.plugins_listAll = plugins_listAll;
26
+ exports.pluginFields_get = pluginFields_get;
27
+ exports.pluginInstances_list = pluginInstances_list;
28
+ exports.dictionary_toCLI = dictionary_toCLI;
29
+ exports.plugin_run = plugin_run;
30
+ exports.plugins_searchableToIDs = plugins_searchableToIDs;
31
+ exports.pluginMeta_readmeContentFetch = pluginMeta_readmeContentFetch;
32
+ exports.pluginMeta_documentationUrlGet = pluginMeta_documentationUrlGet;
33
+ exports.pluginMeta_pluginIDFromSearch = pluginMeta_pluginIDFromSearch;
34
+ exports.plugin_delete = plugin_delete;
35
+ exports.plugins_overview = plugins_overview;
36
+ exports.plugin_readme = plugin_readme;
37
+ const cumin_1 = require("@fnndsc/cumin");
38
+ const axios_1 = __importDefault(require("axios"));
39
+ // ... existing interfaces ...
40
+ /**
41
+ * List plugins based on options.
42
+ *
43
+ * @param options - Search and pagination options.
44
+ * @returns A Promise resolving to FilteredResourceData or null.
45
+ */
46
+ async function plugins_list(options) {
47
+ const pluginGroup = new cumin_1.ChRISPluginGroup();
48
+ if (!pluginGroup) {
49
+ return null;
50
+ }
51
+ return await pluginGroup.asset.resources_listAndFilterByOptions(options);
52
+ }
53
+ /**
54
+ * List *all* plugins by automatically handling pagination.
55
+ *
56
+ * @param options - Search options (limit and offset will be overridden/managed internally).
57
+ * @returns A Promise resolving to FilteredResourceData containing all matching plugins, or null.
58
+ */
59
+ async function plugins_listAll(options = {}) {
60
+ const pluginGroup = new cumin_1.ChRISPluginGroup();
61
+ if (!pluginGroup)
62
+ return null;
63
+ return await pluginGroup.asset.resources_getAll(options);
64
+ }
65
+ /**
66
+ * Get the list of available fields for plugins.
67
+ *
68
+ * @returns A Promise resolving to an array of field names or null.
69
+ */
70
+ async function pluginFields_get() {
71
+ const pluginGroup = new cumin_1.ChRISPluginGroup();
72
+ if (!pluginGroup) {
73
+ return null;
74
+ }
75
+ const results = await pluginGroup.asset.resourceFields_get();
76
+ return results ? results.fields : null;
77
+ }
78
+ /**
79
+ * List plugin instances based on options.
80
+ *
81
+ * @param options - Search and pagination options (e.g., { id: 123 }).
82
+ * @returns A Promise resolving to FilteredResourceData or null.
83
+ */
84
+ async function pluginInstances_list(options) {
85
+ const pluginInstanceGroup = new cumin_1.ChRISPluginInstanceGroup();
86
+ if (!pluginInstanceGroup) {
87
+ return null;
88
+ }
89
+ return await pluginInstanceGroup.asset.resources_listAndFilterByOptions(options);
90
+ }
91
+ /**
92
+ * Converts a Dictionary to CLI-style parameter string.
93
+ *
94
+ * @param params - Dictionary of parameters.
95
+ * @returns CLI-style string (e.g., "--key1 value1 --key2 value2").
96
+ */
97
+ function dictionary_toCLI(params) {
98
+ const parts = [];
99
+ for (const [key, value] of Object.entries(params)) {
100
+ if (value !== undefined && value !== null) {
101
+ parts.push(`--${key} ${value}`);
102
+ }
103
+ }
104
+ return parts.join(' ');
105
+ }
106
+ /**
107
+ * Run a plugin instance.
108
+ *
109
+ * This function orchestrates the execution of a ChRIS plugin with specified parameters.
110
+ *
111
+ * @param searchable - A string that identifies the plugin (e.g., name, ID, or a partial match).
112
+ * @param parameters - An object containing the parameters for the plugin execution.
113
+ * @returns A Promise resolving to a Dictionary representing the created plugin instance, or null if execution failed.
114
+ */
115
+ async function plugin_run(searchable, parameters) {
116
+ const chrisPlugin = new cumin_1.ChRISPlugin();
117
+ // Convert Dictionary to CLI-style string format expected by cumin
118
+ const paramsString = dictionary_toCLI(parameters);
119
+ return await chrisPlugin.plugin_run(searchable, paramsString);
120
+ }
121
+ /**
122
+ * Resolve a searchable plugin string to a list of plugin IDs.
123
+ *
124
+ * @param searchable - A string or Searchable object that identifies the plugin (e.g., name, ID, or a partial match).
125
+ * @returns A Promise resolving to an array of plugin IDs, or null if no plugins match.
126
+ */
127
+ async function plugins_searchableToIDs(searchable) {
128
+ const chrisPlugin = new cumin_1.ChRISPlugin();
129
+ const queryHits = await chrisPlugin.pluginIDs_resolve(searchable);
130
+ if (!queryHits) {
131
+ return null;
132
+ }
133
+ return queryHits.hits;
134
+ }
135
+ /**
136
+ * Fetch the raw README content from a plugin's repository URL.
137
+ *
138
+ * This function attempts to retrieve README files (Markdown or reStructuredText)
139
+ * from common locations within a given repository URL.
140
+ *
141
+ * @param repoUrl - The base URL of the plugin's Git repository.
142
+ * @returns A Promise resolving to the README content as a string, or null if no README is found or accessible.
143
+ */
144
+ async function pluginMeta_readmeContentFetch(repoUrl) {
145
+ const readmeUrls = [
146
+ `${repoUrl}/raw/master/README.md`,
147
+ `${repoUrl}/raw/master/README.rst`,
148
+ `${repoUrl}/raw/main/README.md`,
149
+ `${repoUrl}/raw/main/README.rst`,
150
+ ];
151
+ for (const url of readmeUrls) {
152
+ try {
153
+ const response = await axios_1.default.get(url);
154
+ if (response.status === 200) {
155
+ return response.data;
156
+ }
157
+ }
158
+ catch (error) {
159
+ // Continue to next URL
160
+ }
161
+ }
162
+ return null;
163
+ }
164
+ /**
165
+ * Retrieve the documentation URL for a specific plugin ID.
166
+ *
167
+ * @param pluginId - The ID of the plugin.
168
+ * @returns A Promise resolving to the documentation URL as a string, or null if not found.
169
+ */
170
+ async function pluginMeta_documentationUrlGet(pluginId) {
171
+ const chrisPlugin = new cumin_1.ChRISPlugin(); // Re-instantiate as it might not be shared
172
+ const query = await chrisPlugin.pluginData_getFromSearch({ search: `id: ${pluginId}` }, // Assuming cumin can parse this search string
173
+ 'documentation');
174
+ if (!query || !query.hits.length) {
175
+ return null;
176
+ }
177
+ return query.hits[0];
178
+ }
179
+ /**
180
+ * Retrieve a single plugin ID based on search options.
181
+ *
182
+ * This function performs a search for plugins using the provided criteria and
183
+ * returns the ID of the first matching plugin.
184
+ *
185
+ * @param options - An object containing search parameters (e.g., name, id).
186
+ * @returns A Promise resolving to a plugin ID string, or null if no plugin is found or if the search is ambiguous (multiple results).
187
+ */
188
+ async function pluginMeta_pluginIDFromSearch(options) {
189
+ const chrisPlugin = new cumin_1.ChRISPlugin(); // Re-instantiate
190
+ const queryHits = await chrisPlugin.pluginData_getFromSearch(options, ['id', 'name', 'version']);
191
+ if (queryHits && queryHits.hits.length === 1) { // Assuming we want a single, unambiguous result
192
+ return queryHits.hits[0].id;
193
+ }
194
+ else if (queryHits && queryHits.hits.length > 1) {
195
+ // Optionally log a warning about ambiguity, but for library, just return null or throw.
196
+ const found = queryHits.hits.map(h => {
197
+ const plugin = h;
198
+ const byId = `"id:${plugin.id}"`;
199
+ const byNameAndVersion = `"name_exact:${plugin.name},version:${plugin.version}"`;
200
+ return `- ${byNameAndVersion} -OR- ${byId}`;
201
+ }).join('\n');
202
+ cumin_1.errorStack.stack_push('warning', `Multiple plugins found for search "${options.search}" -- try:\n${found}\nPlease be more specific.`);
203
+ return null; // Return null for ambiguous search results
204
+ }
205
+ return null;
206
+ }
207
+ /**
208
+ * Delete a plugin by its ID.
209
+ *
210
+ * @param id - The ID of the plugin to delete.
211
+ * @returns A Promise resolving to true on success, false on failure.
212
+ */
213
+ async function plugin_delete(id) {
214
+ const pluginGroup = new cumin_1.ChRISPluginGroup();
215
+ if (!pluginGroup) {
216
+ return false;
217
+ }
218
+ return await pluginGroup.asset.resourceItem_delete(id);
219
+ }
220
+ /**
221
+ * Provides an overview of plugin operations.
222
+ * Currently a placeholder.
223
+ *
224
+ * @returns A Promise resolving to void.
225
+ */
226
+ async function plugins_overview() {
227
+ return Promise.resolve();
228
+ }
229
+ /**
230
+ * Fetch the README for a plugin given its ID.
231
+ *
232
+ * @param pluginId - The ID of the plugin.
233
+ * @returns A Promise resolving to the README content or null.
234
+ */
235
+ async function plugin_readme(pluginId) {
236
+ const docUrl = await pluginMeta_documentationUrlGet(pluginId);
237
+ if (!docUrl) {
238
+ return null;
239
+ }
240
+ return await pluginMeta_readmeContentFetch(docUrl);
241
+ }
242
+ // Re-export other utility functions or classes if needed, following the RPN style.
243
+ __exportStar(require("./plugin_register.js"), exports);
244
+ __exportStar(require("./peer_search.js"), exports);
245
+ __exportStar(require("./store_import.js"), exports);
246
+ __exportStar(require("./plugin_executeInPlace.js"), exports);
247
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;AAyBH,oCAQC;AAQD,0CAIC;AAOD,4CASC;AAQD,oDAQC;AAoBD,4CAQC;AAWD,gCAKC;AAQD,0DAOC;AAWD,sEAmBC;AAQD,wEAUC;AAWD,sEAiBC;AAQD,sCAQC;AAQD,4CAEC;AAQD,sCAMC;AA1PD,yCAYuB;AACvB,kDAA0B;AAE1B,8BAA8B;AAE9B;;;;;GAKG;AACI,KAAK,UAAU,YAAY,CAAC,OAAoB;IACrD,MAAM,WAAW,GAAqB,IAAI,wBAAgB,EAAE,CAAC;IAE7D,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,MAAM,WAAW,CAAC,KAAK,CAAC,gCAAgC,CAAC,OAAO,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,eAAe,CAAC,UAAuB,EAAE;IAC7D,MAAM,WAAW,GAAqB,IAAI,wBAAgB,EAAE,CAAC;IAC7D,IAAI,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC;IAC9B,OAAO,MAAM,WAAW,CAAC,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAC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KAAK,UAAU,aAAa,CAAC,EAAU;IAC5C,MAAM,WAAW,GAAqB,IAAI,wBAAgB,EAAE,CAAC;IAE7D,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,MAAM,WAAW,CAAC,KAAK,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC;AACzD,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,gBAAgB;IACpC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AAC3B,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,aAAa,CAAC,QAAgB;IAClD,MAAM,MAAM,GAAkB,MAAM,8BAA8B,CAAC,QAAQ,CAAC,CAAC;IAC7E,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,MAAM,6BAA6B,CAAC,MAAM,CAAC,CAAC;AACrD,CAAC;AAED,mFAAmF;AACnF,uDAAqC;AACrC,mDAAiC;AACjC,oDAAkC;AAClC,6DAA2C"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @file Handle plugin execution for continuing an existing feed
3
+ * @module
4
+ */
5
+ import { Dictionary } from '@fnndsc/cumin';
6
+ import { PluginExecutionResult } from '../plugin_executeInPlace.js';
7
+ /**
8
+ * Handles the "continue feed" execution path.
9
+ * Runs a plugin within an existing feed.
10
+ *
11
+ * @param pluginName - The plugin to run.
12
+ * @param pluginParams - Parameters for the plugin.
13
+ * @param contextParams - Context parameters (e.g., instance_title).
14
+ * @param cwd - Current working directory.
15
+ * @returns The execution result or null on failure.
16
+ */
17
+ export declare function plugin_executeContinueFeed(pluginName: string, pluginParams: Dictionary, contextParams: Dictionary, cwd: string): Promise<PluginExecutionResult | null>;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.plugin_executeContinueFeed = plugin_executeContinueFeed;
4
+ /**
5
+ * @file Handle plugin execution for continuing an existing feed
6
+ * @module
7
+ */
8
+ const cumin_1 = require("@fnndsc/cumin");
9
+ const index_js_1 = require("../index.js");
10
+ /**
11
+ * Handles the "continue feed" execution path.
12
+ * Runs a plugin within an existing feed.
13
+ *
14
+ * @param pluginName - The plugin to run.
15
+ * @param pluginParams - Parameters for the plugin.
16
+ * @param contextParams - Context parameters (e.g., instance_title).
17
+ * @param cwd - Current working directory.
18
+ * @returns The execution result or null on failure.
19
+ */
20
+ async function plugin_executeContinueFeed(pluginName, pluginParams, contextParams, cwd) {
21
+ const previousID = (0, cumin_1.path_extractPluginInstanceID)(cwd);
22
+ if (previousID === null) {
23
+ cumin_1.errorStack.stack_push('error', 'Could not extract plugin instance ID from current directory path');
24
+ return null;
25
+ }
26
+ const feedID = (0, cumin_1.path_extractFeedID)(cwd);
27
+ if (feedID === null) {
28
+ cumin_1.errorStack.stack_push('error', 'Could not extract feed ID from current directory path');
29
+ return null;
30
+ }
31
+ const combinedParams = {
32
+ ...pluginParams,
33
+ previous_id: previousID,
34
+ };
35
+ if (contextParams.instance_title) {
36
+ combinedParams.title = contextParams.instance_title;
37
+ }
38
+ const pluginResult = await (0, index_js_1.plugin_run)(pluginName, combinedParams);
39
+ if (!pluginResult) {
40
+ cumin_1.errorStack.stack_push('error', 'Failed to run plugin');
41
+ return null;
42
+ }
43
+ const pluginInstanceID = pluginResult.id;
44
+ const actualPluginName = pluginResult.plugin_name;
45
+ const pathParts = cwd.split('/');
46
+ let previousPluginPath = '';
47
+ for (let i = 0; i < pathParts.length; i++) {
48
+ if (pathParts[i].endsWith(`_${previousID}`)) {
49
+ previousPluginPath = pathParts.slice(0, i + 1).join('/');
50
+ break;
51
+ }
52
+ }
53
+ if (!previousPluginPath) {
54
+ const username = cwd.split('/')[2];
55
+ previousPluginPath = `/home/${username}/feeds/feed_${feedID}/previous_${previousID}`;
56
+ }
57
+ const outputPath = `${previousPluginPath}/${actualPluginName}_${pluginInstanceID}/data/`;
58
+ return {
59
+ pluginInstanceID,
60
+ pluginName: actualPluginName,
61
+ outputPath,
62
+ parentID: previousID,
63
+ };
64
+ }
65
+ //# sourceMappingURL=plugin_executeContinueFeed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin_executeContinueFeed.js","sourceRoot":"","sources":["../../../src/plugins/internal/plugin_executeContinueFeed.ts"],"names":[],"mappings":";;AAuBA,gEA+DC;AAtFD;;;GAGG;AACH,yCAKuB;AACvB,0CAAyC;AAGzC;;;;;;;;;GASG;AACI,KAAK,UAAU,0BAA0B,CAC9C,UAAkB,EAClB,YAAwB,EACxB,aAAyB,EACzB,GAAW;IAEX,MAAM,UAAU,GAAkB,IAAA,oCAA4B,EAAC,GAAG,CAAC,CAAC;IACpE,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACxB,kBAAU,CAAC,UAAU,CACnB,OAAO,EACP,kEAAkE,CACnE,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,MAAM,GAAkB,IAAA,0BAAkB,EAAC,GAAG,CAAC,CAAC;IACtD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,kBAAU,CAAC,UAAU,CAAC,OAAO,EAAE,uDAAuD,CAAC,CAAC;QACxF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,cAAc,GAAe;QACjC,GAAG,YAAY;QACf,WAAW,EAAE,UAAU;KACxB,CAAC;IAEF,IAAI,aAAa,CAAC,cAAc,EAAE,CAAC;QACjC,cAAc,CAAC,KAAK,GAAG,aAAa,CAAC,cAAc,CAAC;IACtD,CAAC;IAED,MAAM,YAAY,GAAsB,MAAM,IAAA,qBAAU,EAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAErF,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,kBAAU,CAAC,UAAU,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,gBAAgB,GAAW,YAAY,CAAC,EAAY,CAAC;IAC3D,MAAM,gBAAgB,GAAW,YAAY,CAAC,WAAqB,CAAC;IAEpE,MAAM,SAAS,GAAa,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,kBAAkB,GAAW,EAAE,CAAC;IAEpC,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClD,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,UAAU,EAAE,CAAC,EAAE,CAAC;YAC5C,kBAAkB,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACzD,MAAM;QACR,CAAC;IACH,CAAC;IAED,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,MAAM,QAAQ,GAAW,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,kBAAkB,GAAG,SAAS,QAAQ,eAAe,MAAM,aAAa,UAAU,EAAE,CAAC;IACvF,CAAC;IAED,MAAM,UAAU,GAAW,GAAG,kBAAkB,IAAI,gBAAgB,IAAI,gBAAgB,QAAQ,CAAC;IAEjG,OAAO;QACL,gBAAgB;QAChB,UAAU,EAAE,gBAAgB;QAC5B,UAAU;QACV,QAAQ,EAAE,UAAU;KACrB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @file Handle plugin execution for new feed creation
3
+ * @module
4
+ */
5
+ import { Dictionary } from '@fnndsc/cumin';
6
+ import { PluginExecutionResult } from '../plugin_executeInPlace.js';
7
+ /**
8
+ * Result of creating a new feed by executing a plugin.
9
+ */
10
+ export interface FeedCreationResult {
11
+ id: number;
12
+ name: string;
13
+ owner_username: string;
14
+ pluginInstance: {
15
+ data: {
16
+ id: number;
17
+ [key: string]: unknown;
18
+ };
19
+ };
20
+ }
21
+ /**
22
+ * Handles the "new feed" execution path.
23
+ * Creates a feed, runs dircopy, then runs the target plugin.
24
+ *
25
+ * @param pluginName - The plugin to run.
26
+ * @param pluginParams - Parameters for the plugin.
27
+ * @param contextParams - Context parameters (e.g., feed_title).
28
+ * @param cwd - Current working directory.
29
+ * @param binListing - Listing of available plugins in /bin.
30
+ * @returns The execution result or null on failure.
31
+ */
32
+ export declare function plugin_executeNewFeed(pluginName: string, pluginParams: Dictionary, contextParams: Dictionary, cwd: string, binListing: string[]): Promise<PluginExecutionResult | null>;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.plugin_executeNewFeed = plugin_executeNewFeed;
37
+ /**
38
+ * @file Handle plugin execution for new feed creation
39
+ * @module
40
+ */
41
+ const cumin_1 = require("@fnndsc/cumin");
42
+ const index_js_1 = require("../../feeds/index.js");
43
+ const index_js_2 = require("../index.js");
44
+ const path = __importStar(require("path"));
45
+ /**
46
+ * Handles the "new feed" execution path.
47
+ * Creates a feed, runs dircopy, then runs the target plugin.
48
+ *
49
+ * @param pluginName - The plugin to run.
50
+ * @param pluginParams - Parameters for the plugin.
51
+ * @param contextParams - Context parameters (e.g., feed_title).
52
+ * @param cwd - Current working directory.
53
+ * @param binListing - Listing of available plugins in /bin.
54
+ * @returns The execution result or null on failure.
55
+ */
56
+ async function plugin_executeNewFeed(pluginName, pluginParams, contextParams, cwd, binListing) {
57
+ const feedTitle = contextParams.feed_title || path.basename(cwd);
58
+ const dircopyPlugin = (0, cumin_1.path_findLatestDircopy)(binListing);
59
+ if (!dircopyPlugin) {
60
+ cumin_1.errorStack.stack_push('error', 'pl-dircopy not found. Cannot create feeds.');
61
+ return null;
62
+ }
63
+ const feedResult = (await (0, index_js_1.feed_create)([cwd], {
64
+ params: `title:${feedTitle}`,
65
+ }));
66
+ if (!feedResult) {
67
+ cumin_1.errorStack.stack_push('error', 'Failed to create feed');
68
+ return null;
69
+ }
70
+ const feedID = feedResult.id;
71
+ const dircopyInstanceID = feedResult.pluginInstance.data.id;
72
+ const combinedParams = {
73
+ ...pluginParams,
74
+ previous_id: dircopyInstanceID,
75
+ };
76
+ if (contextParams.instance_title) {
77
+ combinedParams.title = contextParams.instance_title;
78
+ }
79
+ const pluginResult = await (0, index_js_2.plugin_run)(pluginName, combinedParams);
80
+ if (!pluginResult) {
81
+ cumin_1.errorStack.stack_push('error', 'Failed to run plugin');
82
+ return null;
83
+ }
84
+ const pluginInstanceID = pluginResult.id;
85
+ const actualPluginName = pluginResult.plugin_name;
86
+ const username = cwd.split('/')[2];
87
+ const outputPath = `/home/${username}/feeds/feed_${feedID}/pl-dircopy_${dircopyInstanceID}/${actualPluginName}_${pluginInstanceID}/data/`;
88
+ return {
89
+ feedID,
90
+ dircopyInstanceID,
91
+ pluginInstanceID,
92
+ pluginName: actualPluginName,
93
+ outputPath,
94
+ parentID: dircopyInstanceID,
95
+ };
96
+ }
97
+ //# sourceMappingURL=plugin_executeNewFeed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin_executeNewFeed.js","sourceRoot":"","sources":["../../../src/plugins/internal/plugin_executeNewFeed.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,sDAwDC;AAhGD;;;GAGG;AACH,yCAIuB;AACvB,mDAAmD;AACnD,0CAAyC;AACzC,2CAA6B;AAkB7B;;;;;;;;;;GAUG;AACI,KAAK,UAAU,qBAAqB,CACzC,UAAkB,EAClB,YAAwB,EACxB,aAAyB,EACzB,GAAW,EACX,UAAoB;IAEpB,MAAM,SAAS,GAAY,aAAa,CAAC,UAAqB,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACrF,MAAM,aAAa,GAAkB,IAAA,8BAAsB,EAAC,UAAU,CAAC,CAAC;IAExE,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,kBAAU,CAAC,UAAU,CAAC,OAAO,EAAE,4CAA4C,CAAC,CAAC;QAC7E,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,UAAU,GAA8B,CAAC,MAAM,IAAA,sBAAW,EAAC,CAAC,GAAG,CAAC,EAAE;QACtE,MAAM,EAAE,SAAS,SAAS,EAAE;KAC7B,CAAC,CAA8B,CAAC;IAEjC,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,kBAAU,CAAC,UAAU,CAAC,OAAO,EAAE,uBAAuB,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,MAAM,GAAW,UAAU,CAAC,EAAE,CAAC;IACrC,MAAM,iBAAiB,GAAW,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;IAEpE,MAAM,cAAc,GAAe;QACjC,GAAG,YAAY;QACf,WAAW,EAAE,iBAAiB;KAC/B,CAAC;IAEF,IAAI,aAAa,CAAC,cAAc,EAAE,CAAC;QACjC,cAAc,CAAC,KAAK,GAAG,aAAa,CAAC,cAAc,CAAC;IACtD,CAAC;IAED,MAAM,YAAY,GAAsB,MAAM,IAAA,qBAAU,EAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAErF,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,kBAAU,CAAC,UAAU,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,gBAAgB,GAAW,YAAY,CAAC,EAAY,CAAC;IAC3D,MAAM,gBAAgB,GAAW,YAAY,CAAC,WAAqB,CAAC;IACpE,MAAM,QAAQ,GAAW,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,MAAM,UAAU,GAAW,SAAS,QAAQ,eAAe,MAAM,eAAe,iBAAiB,IAAI,gBAAgB,IAAI,gBAAgB,QAAQ,CAAC;IAElJ,OAAO;QACL,MAAM;QACN,iBAAiB;QACjB,gBAAgB;QAChB,UAAU,EAAE,gBAAgB;QAC5B,UAAU;QACV,QAAQ,EAAE,iBAAiB;KAC5B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @file Peer Store Plugin Search
3
+ *
4
+ * This module provides functionality to search for plugins in peer ChRIS stores
5
+ * (public plugin repositories). Used during plugin registration to check if a
6
+ * plugin already exists in public stores before attempting Docker extraction.
7
+ *
8
+ * @module
9
+ */
10
+ /**
11
+ * Interface representing a plugin found in a peer store.
12
+ */
13
+ export interface PeerStorePlugin {
14
+ plugin: Record<string, unknown>;
15
+ storeUrl: string;
16
+ storeName: string;
17
+ }
18
+ /**
19
+ * Searches for a plugin across multiple peer ChRIS stores.
20
+ *
21
+ * Queries each peer store in order until a match is found. Returns the first
22
+ * matching plugin along with its store URL.
23
+ *
24
+ * @param pluginName - Name of the plugin to search for.
25
+ * @param version - Optional version of the plugin to search for.
26
+ * @param peerStoreUrls - Array of peer store URLs to search (default: cube.chrisproject.org).
27
+ * @returns Promise resolving to plugin data and store URL, or null if not found.
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * const result = await plugins_searchPeers('pl-dircopy');
32
+ * if (result) {
33
+ * console.log(`Found plugin at ${result.storeUrl}`);
34
+ * }
35
+ * ```
36
+ */
37
+ export declare function plugins_searchPeers(pluginName: string, version?: string, peerStoreUrls?: string[]): Promise<PeerStorePlugin | null>;
38
+ /**
39
+ * Extracts a human-readable store name from a store URL.
40
+ *
41
+ * @param url - The peer store URL.
42
+ * @returns A short name for the store.
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * storeName_extractFromUrl('https://cube.chrisproject.org/api/v1/')
47
+ * // Returns: 'cube.chrisproject.org'
48
+ * ```
49
+ */
50
+ export declare function storeName_extractFromUrl(url: string): string;
51
+ /**
52
+ * Searches for a plugin by Docker image name in peer stores.
53
+ *
54
+ * Extracts the plugin name from the Docker image and searches peer stores.
55
+ *
56
+ * @param dockerImage - Docker image string (e.g., 'fnndsc/pl-dircopy:2.1.1').
57
+ * @param peerStoreUrls - Array of peer store URLs to search.
58
+ * @returns Promise resolving to plugin data or null if not found.
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const result = await plugin_searchPeersByImage('fnndsc/pl-dircopy:2.1.1');
63
+ * ```
64
+ */
65
+ export declare function plugin_searchPeersByImage(dockerImage: string, peerStoreUrls?: string[]): Promise<PeerStorePlugin | null>;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ /**
3
+ * @file Peer Store Plugin Search
4
+ *
5
+ * This module provides functionality to search for plugins in peer ChRIS stores
6
+ * (public plugin repositories). Used during plugin registration to check if a
7
+ * plugin already exists in public stores before attempting Docker extraction.
8
+ *
9
+ * @module
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.plugins_searchPeers = plugins_searchPeers;
13
+ exports.storeName_extractFromUrl = storeName_extractFromUrl;
14
+ exports.plugin_searchPeersByImage = plugin_searchPeersByImage;
15
+ const cumin_1 = require("@fnndsc/cumin");
16
+ /**
17
+ * Searches for a plugin across multiple peer ChRIS stores.
18
+ *
19
+ * Queries each peer store in order until a match is found. Returns the first
20
+ * matching plugin along with its store URL.
21
+ *
22
+ * @param pluginName - Name of the plugin to search for.
23
+ * @param version - Optional version of the plugin to search for.
24
+ * @param peerStoreUrls - Array of peer store URLs to search (default: cube.chrisproject.org).
25
+ * @returns Promise resolving to plugin data and store URL, or null if not found.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const result = await plugins_searchPeers('pl-dircopy');
30
+ * if (result) {
31
+ * console.log(`Found plugin at ${result.storeUrl}`);
32
+ * }
33
+ * ```
34
+ */
35
+ async function plugins_searchPeers(pluginName, version, peerStoreUrls = ['https://cube.chrisproject.org/api/v1/']) {
36
+ const chrisPlugin = new cumin_1.ChRISPlugin();
37
+ for (const peerStoreUrl of peerStoreUrls) {
38
+ const result = await chrisPlugin.plugin_searchPeerStore(pluginName, version, peerStoreUrl);
39
+ if (result) {
40
+ return {
41
+ plugin: result.plugin,
42
+ storeUrl: result.storeUrl,
43
+ storeName: storeName_extractFromUrl(peerStoreUrl)
44
+ };
45
+ }
46
+ }
47
+ return null;
48
+ }
49
+ /**
50
+ * Extracts a human-readable store name from a store URL.
51
+ *
52
+ * @param url - The peer store URL.
53
+ * @returns A short name for the store.
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * storeName_extractFromUrl('https://cube.chrisproject.org/api/v1/')
58
+ * // Returns: 'cube.chrisproject.org'
59
+ * ```
60
+ */
61
+ function storeName_extractFromUrl(url) {
62
+ try {
63
+ const urlObj = new URL(url);
64
+ return urlObj.hostname;
65
+ }
66
+ catch {
67
+ return url;
68
+ }
69
+ }
70
+ /**
71
+ * Searches for a plugin by Docker image name in peer stores.
72
+ *
73
+ * Extracts the plugin name from the Docker image and searches peer stores.
74
+ *
75
+ * @param dockerImage - Docker image string (e.g., 'fnndsc/pl-dircopy:2.1.1').
76
+ * @param peerStoreUrls - Array of peer store URLs to search.
77
+ * @returns Promise resolving to plugin data or null if not found.
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * const result = await plugin_searchPeersByImage('fnndsc/pl-dircopy:2.1.1');
82
+ * ```
83
+ */
84
+ async function plugin_searchPeersByImage(dockerImage, peerStoreUrls) {
85
+ // Examples:
86
+ // 'fnndsc/pl-dircopy:2.1.1' -> 'pl-dircopy'
87
+ // 'pl-dircopy:latest' -> 'pl-dircopy'
88
+ // 'localhost:5000/pl-custom' -> 'pl-custom'
89
+ const imageParts = dockerImage.split('/');
90
+ const lastPart = imageParts[imageParts.length - 1];
91
+ const pluginName = lastPart.split(':')[0];
92
+ return await plugins_searchPeers(pluginName, undefined, peerStoreUrls);
93
+ }
94
+ //# sourceMappingURL=peer_search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"peer_search.js","sourceRoot":"","sources":["../../src/plugins/peer_search.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAgCH,kDAmBC;AAcD,4DAOC;AAgBD,8DAaC;AAnGD,yCAA4C;AAW5C;;;;;;;;;;;;;;;;;;GAkBG;AACI,KAAK,UAAU,mBAAmB,CACvC,UAAkB,EAClB,OAAgB,EAChB,gBAA0B,CAAC,uCAAuC,CAAC;IAEnE,MAAM,WAAW,GAAgB,IAAI,mBAAW,EAAE,CAAC;IAEnD,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;QACzC,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAAC,UAAU,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QAC3F,IAAI,MAAM,EAAE,CAAC;YACX,OAAO;gBACL,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;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