@cyberismo/data-handler 0.0.21 → 0.0.22

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 (166) hide show
  1. package/dist/command-handler.js +13 -24
  2. package/dist/command-handler.js.map +1 -1
  3. package/dist/command-manager.d.ts +21 -6
  4. package/dist/command-manager.js +34 -32
  5. package/dist/command-manager.js.map +1 -1
  6. package/dist/commands/calculate.js +101 -46
  7. package/dist/commands/calculate.js.map +1 -1
  8. package/dist/commands/create.js +417 -328
  9. package/dist/commands/create.js.map +1 -1
  10. package/dist/commands/edit.js +117 -68
  11. package/dist/commands/edit.js.map +1 -1
  12. package/dist/commands/export.js +301 -252
  13. package/dist/commands/export.js.map +1 -1
  14. package/dist/commands/fetch.js +205 -156
  15. package/dist/commands/fetch.js.map +1 -1
  16. package/dist/commands/import.js +189 -134
  17. package/dist/commands/import.js.map +1 -1
  18. package/dist/commands/migrate.js +91 -45
  19. package/dist/commands/migrate.js.map +1 -1
  20. package/dist/commands/move.js +347 -267
  21. package/dist/commands/move.js.map +1 -1
  22. package/dist/commands/remove.d.ts +1 -0
  23. package/dist/commands/remove.js +202 -135
  24. package/dist/commands/remove.js.map +1 -1
  25. package/dist/commands/rename.js +233 -187
  26. package/dist/commands/rename.js.map +1 -1
  27. package/dist/commands/show.d.ts +8 -8
  28. package/dist/commands/show.js +477 -372
  29. package/dist/commands/show.js.map +1 -1
  30. package/dist/commands/transition.js +119 -73
  31. package/dist/commands/transition.js.map +1 -1
  32. package/dist/commands/update.js +8 -3
  33. package/dist/commands/update.js.map +1 -1
  34. package/dist/commands/validate.js +1 -1
  35. package/dist/commands/validate.js.map +1 -1
  36. package/dist/containers/project/calculation-engine.js +0 -1
  37. package/dist/containers/project/calculation-engine.js.map +1 -1
  38. package/dist/containers/project/card-cache.js +1 -1
  39. package/dist/containers/project/card-cache.js.map +1 -1
  40. package/dist/containers/project.d.ts +16 -0
  41. package/dist/containers/project.js +59 -1
  42. package/dist/containers/project.js.map +1 -1
  43. package/dist/containers/template.js +1 -1
  44. package/dist/containers/template.js.map +1 -1
  45. package/dist/interfaces/command-options.d.ts +1 -0
  46. package/dist/interfaces/resource-interfaces.d.ts +5 -12
  47. package/dist/interfaces/resource-interfaces.js.map +1 -1
  48. package/dist/macros/base-macro.js +1 -1
  49. package/dist/macros/base-macro.js.map +1 -1
  50. package/dist/macros/graph/index.js +3 -1
  51. package/dist/macros/graph/index.js.map +1 -1
  52. package/dist/macros/index.js +3 -1
  53. package/dist/macros/index.js.map +1 -1
  54. package/dist/macros/report/index.js +1 -1
  55. package/dist/macros/report/index.js.map +1 -1
  56. package/dist/module-manager.js +5 -3
  57. package/dist/module-manager.js.map +1 -1
  58. package/dist/project-settings.js +2 -2
  59. package/dist/project-settings.js.map +1 -1
  60. package/dist/resources/card-type-resource.js +1 -1
  61. package/dist/resources/card-type-resource.js.map +1 -1
  62. package/dist/resources/create-defaults.js +0 -1
  63. package/dist/resources/create-defaults.js.map +1 -1
  64. package/dist/resources/field-type-resource.js +2 -5
  65. package/dist/resources/field-type-resource.js.map +1 -1
  66. package/dist/resources/file-resource.js +4 -1
  67. package/dist/resources/file-resource.js.map +1 -1
  68. package/dist/resources/folder-resource.d.ts +1 -1
  69. package/dist/resources/folder-resource.js +4 -1
  70. package/dist/resources/folder-resource.js.map +1 -1
  71. package/dist/resources/graph-model-resource.d.ts +1 -8
  72. package/dist/resources/graph-model-resource.js +0 -14
  73. package/dist/resources/graph-model-resource.js.map +1 -1
  74. package/dist/resources/graph-view-resource.d.ts +1 -8
  75. package/dist/resources/graph-view-resource.js +0 -14
  76. package/dist/resources/graph-view-resource.js.map +1 -1
  77. package/dist/resources/link-type-resource.js +1 -1
  78. package/dist/resources/link-type-resource.js.map +1 -1
  79. package/dist/resources/report-resource.d.ts +1 -8
  80. package/dist/resources/report-resource.js +0 -14
  81. package/dist/resources/report-resource.js.map +1 -1
  82. package/dist/resources/resource-object.d.ts +11 -1
  83. package/dist/resources/resource-object.js +19 -2
  84. package/dist/resources/resource-object.js.map +1 -1
  85. package/dist/resources/template-resource.d.ts +1 -9
  86. package/dist/resources/template-resource.js +0 -15
  87. package/dist/resources/template-resource.js.map +1 -1
  88. package/dist/resources/workflow-resource.js +1 -1
  89. package/dist/resources/workflow-resource.js.map +1 -1
  90. package/dist/utils/card-utils.js +1 -1
  91. package/dist/utils/card-utils.js.map +1 -1
  92. package/dist/utils/commit-context.d.ts +23 -0
  93. package/dist/utils/commit-context.js +30 -0
  94. package/dist/utils/commit-context.js.map +1 -0
  95. package/dist/utils/file-utils.js +3 -1
  96. package/dist/utils/file-utils.js.map +1 -1
  97. package/dist/utils/git-manager.d.ts +29 -0
  98. package/dist/utils/git-manager.js +76 -0
  99. package/dist/utils/git-manager.js.map +1 -0
  100. package/dist/utils/handlebars-helpers.d.ts +22 -0
  101. package/dist/utils/handlebars-helpers.js +78 -0
  102. package/dist/utils/handlebars-helpers.js.map +1 -0
  103. package/dist/utils/json.js +6 -2
  104. package/dist/utils/json.js.map +1 -1
  105. package/dist/utils/log-utils.d.ts +7 -2
  106. package/dist/utils/log-utils.js +28 -3
  107. package/dist/utils/log-utils.js.map +1 -1
  108. package/dist/utils/report.d.ts +0 -19
  109. package/dist/utils/report.js +4 -67
  110. package/dist/utils/report.js.map +1 -1
  111. package/dist/utils/rw-lock.d.ts +71 -0
  112. package/dist/utils/rw-lock.js +220 -0
  113. package/dist/utils/rw-lock.js.map +1 -0
  114. package/dist/utils/user-preferences.js +3 -3
  115. package/dist/utils/user-preferences.js.map +1 -1
  116. package/package.json +5 -5
  117. package/src/command-handler.ts +14 -22
  118. package/src/command-manager.ts +43 -37
  119. package/src/commands/calculate.ts +8 -1
  120. package/src/commands/create.ts +24 -1
  121. package/src/commands/edit.ts +3 -0
  122. package/src/commands/export.ts +8 -2
  123. package/src/commands/fetch.ts +3 -0
  124. package/src/commands/import.ts +5 -0
  125. package/src/commands/migrate.ts +2 -0
  126. package/src/commands/move.ts +34 -0
  127. package/src/commands/remove.ts +24 -2
  128. package/src/commands/rename.ts +2 -0
  129. package/src/commands/show.ts +63 -34
  130. package/src/commands/transition.ts +2 -0
  131. package/src/commands/update.ts +9 -3
  132. package/src/commands/validate.ts +1 -1
  133. package/src/containers/project/calculation-engine.ts +0 -1
  134. package/src/containers/project/card-cache.ts +1 -0
  135. package/src/containers/project.ts +75 -1
  136. package/src/containers/template.ts +1 -1
  137. package/src/interfaces/command-options.ts +1 -0
  138. package/src/interfaces/resource-interfaces.ts +5 -12
  139. package/src/macros/base-macro.ts +1 -1
  140. package/src/macros/graph/index.ts +3 -0
  141. package/src/macros/index.ts +3 -1
  142. package/src/macros/report/index.ts +1 -0
  143. package/src/module-manager.ts +5 -2
  144. package/src/project-settings.ts +2 -1
  145. package/src/resources/card-type-resource.ts +1 -1
  146. package/src/resources/create-defaults.ts +0 -1
  147. package/src/resources/field-type-resource.ts +2 -4
  148. package/src/resources/file-resource.ts +3 -1
  149. package/src/resources/folder-resource.ts +7 -2
  150. package/src/resources/graph-model-resource.ts +1 -25
  151. package/src/resources/graph-view-resource.ts +1 -25
  152. package/src/resources/link-type-resource.ts +1 -1
  153. package/src/resources/report-resource.ts +1 -25
  154. package/src/resources/resource-object.ts +22 -1
  155. package/src/resources/template-resource.ts +0 -23
  156. package/src/resources/workflow-resource.ts +1 -1
  157. package/src/utils/card-utils.ts +1 -1
  158. package/src/utils/commit-context.ts +45 -0
  159. package/src/utils/file-utils.ts +3 -1
  160. package/src/utils/git-manager.ts +87 -0
  161. package/src/utils/handlebars-helpers.ts +95 -0
  162. package/src/utils/json.ts +6 -2
  163. package/src/utils/log-utils.ts +33 -4
  164. package/src/utils/report.ts +8 -78
  165. package/src/utils/rw-lock.ts +279 -0
  166. package/src/utils/user-preferences.ts +3 -0
@@ -10,154 +10,209 @@
10
10
  details. You should have received a copy of the GNU Affero General Public
11
11
  License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
12
  */
13
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
14
+ var useValue = arguments.length > 2;
15
+ for (var i = 0; i < initializers.length; i++) {
16
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
17
+ }
18
+ return useValue ? value : void 0;
19
+ };
20
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
21
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
22
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
23
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
24
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
25
+ var _, done = false;
26
+ for (var i = decorators.length - 1; i >= 0; i--) {
27
+ var context = {};
28
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
29
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
30
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
31
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
32
+ if (kind === "accessor") {
33
+ if (result === void 0) continue;
34
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
35
+ if (_ = accept(result.get)) descriptor.get = _;
36
+ if (_ = accept(result.set)) descriptor.set = _;
37
+ if (_ = accept(result.init)) initializers.unshift(_);
38
+ }
39
+ else if (_ = accept(result)) {
40
+ if (kind === "field") initializers.unshift(_);
41
+ else descriptor[key] = _;
42
+ }
43
+ }
44
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
45
+ done = true;
46
+ };
13
47
  import { ModuleManager } from '../module-manager.js';
14
48
  import { readCsvFile } from '../utils/csv.js';
15
49
  import { Validate } from './validate.js';
50
+ import { write } from '../utils/rw-lock.js';
16
51
  /**
17
52
  * Handles all import commands.
18
53
  */
19
- export class Import {
20
- project;
21
- createCmd;
22
- fetchCmd;
23
- moduleManager;
24
- /**
25
- * Creates an instance of Import.
26
- * @param project Project to use.
27
- * @param createCmd Instance of Create to use.
28
- */
29
- constructor(project, createCmd, fetchCmd) {
30
- this.project = project;
31
- this.createCmd = createCmd;
32
- this.fetchCmd = fetchCmd;
33
- this.moduleManager = new ModuleManager(this.project);
34
- }
35
- /**
36
- * Imports cards based on a csv file
37
- * @param csvFilePath path to the csv file
38
- * @param parentCardKey the cards in the csv file will be created under this card
39
- * @returns card keys of the imported cards
40
- */
41
- async importCsv(csvFilePath, parentCardKey) {
42
- const csv = await readCsvFile(csvFilePath);
43
- const isValid = Validate.getInstance().validateJson(csv, 'csvSchema');
44
- if (isValid.length !== 0) {
45
- throw new Error(isValid);
54
+ let Import = (() => {
55
+ let _instanceExtraInitializers = [];
56
+ let _importCsv_decorators;
57
+ let _importModule_decorators;
58
+ let _updateModule_decorators;
59
+ let _updateAllModules_decorators;
60
+ return class Import {
61
+ static {
62
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
63
+ _importCsv_decorators = [write((csvFilePath) => `Import cards from CSV ${csvFilePath}`)];
64
+ _importModule_decorators = [write((source) => `Import module ${source}`)];
65
+ _updateModule_decorators = [write((moduleName) => `Update module ${moduleName}`)];
66
+ _updateAllModules_decorators = [write(() => 'Update all modules')];
67
+ __esDecorate(this, null, _importCsv_decorators, { kind: "method", name: "importCsv", static: false, private: false, access: { has: obj => "importCsv" in obj, get: obj => obj.importCsv }, metadata: _metadata }, null, _instanceExtraInitializers);
68
+ __esDecorate(this, null, _importModule_decorators, { kind: "method", name: "importModule", static: false, private: false, access: { has: obj => "importModule" in obj, get: obj => obj.importModule }, metadata: _metadata }, null, _instanceExtraInitializers);
69
+ __esDecorate(this, null, _updateModule_decorators, { kind: "method", name: "updateModule", static: false, private: false, access: { has: obj => "updateModule" in obj, get: obj => obj.updateModule }, metadata: _metadata }, null, _instanceExtraInitializers);
70
+ __esDecorate(this, null, _updateAllModules_decorators, { kind: "method", name: "updateAllModules", static: false, private: false, access: { has: obj => "updateAllModules" in obj, get: obj => obj.updateAllModules }, metadata: _metadata }, null, _instanceExtraInitializers);
71
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
46
72
  }
47
- const importedCards = [];
48
- for (const row of csv) {
49
- const { title, template, description, labels, ...customFields } = row;
50
- const templateResource = this.project.resources.byType(template, 'templates');
51
- const templateObject = templateResource.templateObject();
52
- if (!templateObject) {
53
- throw new Error(`Template '${template}' not found`);
54
- }
55
- const templateCards = templateObject.cards();
56
- if (templateCards.length !== 1) {
57
- console.warn(`Template '${template}' for card '${title}' does not have exactly one card. Skipping row.`);
58
- continue;
59
- }
60
- // Create card
61
- const cards = await this.createCmd.createCard(template, parentCardKey);
62
- if (cards.length !== 1) {
63
- throw new Error('Card not created');
64
- }
65
- const cardKey = cards[0].key;
66
- const card = this.project.findCard(cardKey);
67
- if (!card.metadata?.cardType) {
68
- throw new Error(`Card type not found for card ${cardKey}`);
69
- }
70
- const cardType = this.project.resources
71
- .byType(card.metadata?.cardType, 'cardTypes')
72
- .show();
73
- if (description) {
74
- await this.project.updateCardContent(cardKey, description);
73
+ project = __runInitializers(this, _instanceExtraInitializers);
74
+ createCmd;
75
+ fetchCmd;
76
+ moduleManager;
77
+ /**
78
+ * Creates an instance of Import.
79
+ * @param project Project to use.
80
+ * @param createCmd Instance of Create to use.
81
+ */
82
+ constructor(project, createCmd, fetchCmd) {
83
+ this.project = project;
84
+ this.createCmd = createCmd;
85
+ this.fetchCmd = fetchCmd;
86
+ this.moduleManager = new ModuleManager(this.project);
87
+ }
88
+ /**
89
+ * Imports cards based on a csv file
90
+ * @param csvFilePath path to the csv file
91
+ * @param parentCardKey the cards in the csv file will be created under this card
92
+ * @returns card keys of the imported cards
93
+ */
94
+ async importCsv(csvFilePath, parentCardKey) {
95
+ const csv = await readCsvFile(csvFilePath);
96
+ const isValid = Validate.getInstance().validateJson(csv, 'csvSchema');
97
+ if (isValid.length !== 0) {
98
+ throw new Error(isValid);
75
99
  }
76
- if (labels) {
77
- for (const label of labels.split(' ')) {
78
- try {
79
- await this.createCmd.createLabel(cardKey, label);
80
- }
81
- catch (e) {
82
- console.error(`Failed to create label ${label}: ${e instanceof Error ? e.message : 'Unknown error'}`);
100
+ const importedCards = [];
101
+ for (const row of csv) {
102
+ const { title, template, description, labels, ...customFields } = row;
103
+ const templateResource = this.project.resources.byType(template, 'templates');
104
+ const templateObject = templateResource.templateObject();
105
+ if (!templateObject) {
106
+ throw new Error(`Template '${template}' not found`);
107
+ }
108
+ const templateCards = templateObject.cards();
109
+ if (templateCards.length !== 1) {
110
+ console.warn(`Template '${template}' for card '${title}' does not have exactly one card. Skipping row.`);
111
+ continue;
112
+ }
113
+ // Create card
114
+ const cards = await this.createCmd.createCard(template, parentCardKey);
115
+ if (cards.length !== 1) {
116
+ throw new Error('Card not created');
117
+ }
118
+ const cardKey = cards[0].key;
119
+ const card = this.project.findCard(cardKey);
120
+ if (!card.metadata?.cardType) {
121
+ throw new Error(`Card type not found for card ${cardKey}`);
122
+ }
123
+ const cardType = this.project.resources
124
+ .byType(card.metadata?.cardType, 'cardTypes')
125
+ .show();
126
+ if (description) {
127
+ await this.project.updateCardContent(cardKey, description);
128
+ }
129
+ if (labels) {
130
+ for (const label of labels.split(' ')) {
131
+ try {
132
+ await this.createCmd.createLabel(cardKey, label);
133
+ }
134
+ catch (e) {
135
+ console.error(`Failed to create label ${label}: ${e instanceof Error ? e.message : 'Unknown error'}`);
136
+ }
83
137
  }
84
138
  }
85
- }
86
- await this.project.updateCardMetadataKey(cardKey, 'title', title);
87
- for (const [key, value] of Object.entries(customFields)) {
88
- if (cardType.customFields.find((field) => field.name === key)) {
89
- await this.project.updateCardMetadataKey(cardKey, key, value);
139
+ await this.project.updateCardMetadataKey(cardKey, 'title', title);
140
+ for (const [key, value] of Object.entries(customFields)) {
141
+ if (cardType.customFields.find((field) => field.name === key)) {
142
+ await this.project.updateCardMetadataKey(cardKey, key, value);
143
+ }
90
144
  }
145
+ importedCards.push(cardKey);
91
146
  }
92
- importedCards.push(cardKey);
147
+ return importedCards;
93
148
  }
94
- return importedCards;
95
- }
96
- /**
97
- * Imports a module to a project. Copies resources to the project.
98
- * Resources will be added to a new directory under '.cards/modules'.
99
- * The name of the new folder will be module's prefix.
100
- *
101
- * Note that file references are relative, and thus URI must be
102
- * 'file:<relative path>', instead of 'file://<relative path>'.
103
- *
104
- * @param source Path to module that will be imported
105
- * @param destination Path to project that will receive the imported module
106
- * @param options Additional options for module import. Optional.
107
- * branch: Git branch for module from Git.
108
- * private: If true, uses credentials to clone the repository
109
- * @param skipMigrationLog If true, skip logging to migration log (used during project creation)
110
- */
111
- async importModule(source, destination, options, skipMigrationLog = false) {
112
- // Ensure module list is up to date before importing
113
- await this.fetchCmd.ensureModuleListUpToDate();
114
- const beforeImportValidateErrors = await Validate.getInstance().validate(this.project.basePath, () => this.project);
115
- const gitModule = source.startsWith('https') || source.startsWith('git@');
116
- const modulePrefix = gitModule
117
- ? await this.moduleManager.importGitModule(source, options)
118
- : await this.moduleManager.importFileModule(source, destination);
119
- if (!modulePrefix) {
120
- throw new Error(`Cannot find prefix for imported module '${source}'. Import cancelled.`);
149
+ /**
150
+ * Imports a module to a project. Copies resources to the project.
151
+ * Resources will be added to a new directory under '.cards/modules'.
152
+ * The name of the new folder will be module's prefix.
153
+ *
154
+ * Note that file references are relative, and thus URI must be
155
+ * 'file:<relative path>', instead of 'file://<relative path>'.
156
+ *
157
+ * @param source Path to module that will be imported
158
+ * @param destination Path to project that will receive the imported module
159
+ * @param options Additional options for module import. Optional.
160
+ * branch: Git branch for module from Git.
161
+ * private: If true, uses credentials to clone the repository
162
+ * @param skipMigrationLog If true, skip logging to migration log (used during project creation)
163
+ */
164
+ async importModule(source, destination, options, skipMigrationLog = false) {
165
+ // Ensure module list is up to date before importing
166
+ await this.fetchCmd.ensureModuleListUpToDate();
167
+ const beforeImportValidateErrors = await Validate.getInstance().validate(this.project.basePath, () => this.project);
168
+ const gitModule = source.startsWith('https') || source.startsWith('git@');
169
+ const modulePrefix = gitModule
170
+ ? await this.moduleManager.importGitModule(source, options)
171
+ : await this.moduleManager.importFileModule(source, destination);
172
+ if (!modulePrefix) {
173
+ throw new Error(`Cannot find prefix for imported module '${source}'. Import cancelled.`);
174
+ }
175
+ const moduleSettings = {
176
+ name: modulePrefix,
177
+ branch: options ? options.branch : undefined,
178
+ private: options ? options.private : undefined,
179
+ location: gitModule ? source : `file:${source}`,
180
+ };
181
+ // Fetch module dependencies.
182
+ await this.moduleManager.updateDependencies(moduleSettings, options?.credentials);
183
+ // Add module as a dependency.
184
+ await this.project.importModule(moduleSettings, skipMigrationLog);
185
+ // Validate the project after module has been imported
186
+ const afterImportValidateErrors = await Validate.getInstance().validate(this.project.basePath, () => this.project);
187
+ if (afterImportValidateErrors.length > beforeImportValidateErrors.length) {
188
+ console.error(`There are new validations errors after importing the module. Check the project`);
189
+ }
121
190
  }
122
- const moduleSettings = {
123
- name: modulePrefix,
124
- branch: options ? options.branch : undefined,
125
- private: options ? options.private : undefined,
126
- location: gitModule ? source : `file:${source}`,
127
- };
128
- // Fetch module dependencies.
129
- await this.moduleManager.updateDependencies(moduleSettings, options?.credentials);
130
- // Add module as a dependency.
131
- await this.project.importModule(moduleSettings, skipMigrationLog);
132
- // Validate the project after module has been imported
133
- const afterImportValidateErrors = await Validate.getInstance().validate(this.project.basePath, () => this.project);
134
- if (afterImportValidateErrors.length > beforeImportValidateErrors.length) {
135
- console.error(`There are new validations errors after importing the module. Check the project`);
191
+ /**
192
+ * Updates a specific imported module.
193
+ * @param moduleName Name (prefix) of module to update.
194
+ * @param credentials Optional credentials for a private module.
195
+ * @throws if module is not part of the project
196
+ */
197
+ async updateModule(moduleName, credentials) {
198
+ // Ensure module list is up to date before updating
199
+ await this.fetchCmd.ensureModuleListUpToDate();
200
+ const module = this.project.configuration.modules.find((item) => item.name === moduleName);
201
+ if (!module) {
202
+ throw new Error(`Module '${moduleName}' is not part of the project`);
203
+ }
204
+ return this.moduleManager.updateModule(module, credentials);
136
205
  }
137
- }
138
- /**
139
- * Updates a specific imported module.
140
- * @param moduleName Name (prefix) of module to update.
141
- * @param credentials Optional credentials for a private module.
142
- * @throws if module is not part of the project
143
- */
144
- async updateModule(moduleName, credentials) {
145
- // Ensure module list is up to date before updating
146
- await this.fetchCmd.ensureModuleListUpToDate();
147
- const module = this.project.configuration.modules.find((item) => item.name === moduleName);
148
- if (!module) {
149
- throw new Error(`Module '${moduleName}' is not part of the project`);
206
+ /**
207
+ * Updates all imported modules.
208
+ * @param credentials Optional credentials for private modules.
209
+ */
210
+ async updateAllModules(credentials) {
211
+ // Ensure module list is up to date before updating all modules
212
+ await this.fetchCmd.ensureModuleListUpToDate();
213
+ return this.moduleManager.updateModules(credentials);
150
214
  }
151
- return this.moduleManager.updateModule(module, credentials);
152
- }
153
- /**
154
- * Updates all imported modules.
155
- * @param credentials Optional credentials for private modules.
156
- */
157
- async updateAllModules(credentials) {
158
- // Ensure module list is up to date before updating all modules
159
- await this.fetchCmd.ensureModuleListUpToDate();
160
- return this.moduleManager.updateModules(credentials);
161
- }
162
- }
215
+ };
216
+ })();
217
+ export { Import };
163
218
  //# sourceMappingURL=import.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"import.js","sourceRoot":"","sources":["../../src/commands/import.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAUzC;;GAEG;AACH,MAAM,OAAO,MAAM;IASP;IACA;IACA;IAVF,aAAa,CAAgB;IAErC;;;;OAIG;IACH,YACU,OAAgB,EAChB,SAAiB,EACjB,QAAe;QAFf,YAAO,GAAP,OAAO,CAAS;QAChB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AAE,CAAC;gBACZ,MAAM,IAAI,KAAK,CAAC,WAAW,UAAU,8BAA8B,CAAC,CAAC;YACvE,CAAC;YACD,OAAO,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAC9D,CAAC;QAED;;;WAGG;QAEI,KAAK,CAAC,gBAAgB,CAAC,WAAyB;YACrD,+DAA+D;YAC/D,MAAM,IAAI,CAAC,QAAQ,CAAC,wBAAwB,EAAE,CAAC;YAC/C,OAAO,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QACvD,CAAC;;;SAlMU,MAAM"}
@@ -10,57 +10,103 @@
10
10
  details. You should have received a copy of the GNU Affero General Public
11
11
  License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
12
  */
13
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
14
+ var useValue = arguments.length > 2;
15
+ for (var i = 0; i < initializers.length; i++) {
16
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
17
+ }
18
+ return useValue ? value : void 0;
19
+ };
20
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
21
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
22
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
23
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
24
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
25
+ var _, done = false;
26
+ for (var i = decorators.length - 1; i >= 0; i--) {
27
+ var context = {};
28
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
29
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
30
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
31
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
32
+ if (kind === "accessor") {
33
+ if (result === void 0) continue;
34
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
35
+ if (_ = accept(result.get)) descriptor.get = _;
36
+ if (_ = accept(result.set)) descriptor.set = _;
37
+ if (_ = accept(result.init)) initializers.unshift(_);
38
+ }
39
+ else if (_ = accept(result)) {
40
+ if (kind === "field") initializers.unshift(_);
41
+ else descriptor[key] = _;
42
+ }
43
+ }
44
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
45
+ done = true;
46
+ };
13
47
  import { SCHEMA_VERSION } from '@cyberismo/assets';
48
+ import { write } from '../utils/rw-lock.js';
14
49
  /**
15
50
  * Command that handles schema migration operations.
16
51
  */
17
- export class Migrate {
18
- project;
19
- /**
20
- * Constructs instance of Migrate command.
21
- * @param project Project instance to use.
22
- */
23
- constructor(project) {
24
- this.project = project;
25
- }
26
- /**
27
- * Run migrations to bring project to target schema version.
28
- * @param toVersion Target version (defaults to latest)
29
- * @param backupDir Optional directory for backups
30
- * @param timeoutMilliSeconds Optional timeout in milliseconds (defaults to 2 minutes)
31
- * @returns Migration result
32
- */
33
- async migrate(toVersion, backupDir, timeoutMilliSeconds) {
34
- const currentVersion = this.project.configuration.schemaVersion;
35
- if (currentVersion === undefined) {
36
- throw new Error('Project has no schema version set');
37
- }
38
- const targetVersion = toVersion ?? SCHEMA_VERSION;
39
- // Prevent downgrading
40
- if (targetVersion < currentVersion) {
41
- throw new Error(`Cannot downgrade from version ${currentVersion} to ${targetVersion}. Downgrading is not supported.`);
52
+ let Migrate = (() => {
53
+ let _instanceExtraInitializers = [];
54
+ let _migrate_decorators;
55
+ return class Migrate {
56
+ static {
57
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
58
+ _migrate_decorators = [write(() => 'Migrate project')];
59
+ __esDecorate(this, null, _migrate_decorators, { kind: "method", name: "migrate", static: false, private: false, access: { has: obj => "migrate" in obj, get: obj => obj.migrate }, metadata: _metadata }, null, _instanceExtraInitializers);
60
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
42
61
  }
43
- // Cannot migrate beyond current application schema
44
- if (targetVersion > SCHEMA_VERSION) {
45
- throw new Error(`Cannot migrate to version ${targetVersion}. Current application supports up to version ${SCHEMA_VERSION}.`);
62
+ project = __runInitializers(this, _instanceExtraInitializers);
63
+ /**
64
+ * Constructs instance of Migrate command.
65
+ * @param project Project instance to use.
66
+ */
67
+ constructor(project) {
68
+ this.project = project;
46
69
  }
47
- // No migration needed
48
- if (currentVersion === targetVersion) {
49
- return {
50
- success: true,
51
- message: `Project is already at version ${currentVersion}. No migration needed.`,
52
- stepsExecuted: [],
53
- };
54
- }
55
- // Prevent skipping migrations when a specific target version is provided
56
- // If no version specified, migrate to the latest
57
- if (toVersion !== undefined && toVersion !== SCHEMA_VERSION) {
58
- // Only allow next sequential version
59
- if (targetVersion !== currentVersion + 1) {
60
- throw new Error(`Cannot skip to version ${targetVersion}. Project is at version ${currentVersion}, next version is ${currentVersion + 1}. Migrate one version at a time with 'cyberismo migrate ${currentVersion + 1}', or use 'cyberismo migrate' (without a version) to migrate to the latest version.`);
70
+ /**
71
+ * Run migrations to bring project to target schema version.
72
+ * @param toVersion Target version (defaults to latest)
73
+ * @param backupDir Optional directory for backups
74
+ * @param timeoutMilliSeconds Optional timeout in milliseconds (defaults to 2 minutes)
75
+ * @returns Migration result
76
+ */
77
+ async migrate(toVersion, backupDir, timeoutMilliSeconds) {
78
+ const currentVersion = this.project.configuration.schemaVersion;
79
+ if (currentVersion === undefined) {
80
+ throw new Error('Project has no schema version set');
81
+ }
82
+ const targetVersion = toVersion ?? SCHEMA_VERSION;
83
+ // Prevent downgrading
84
+ if (targetVersion < currentVersion) {
85
+ throw new Error(`Cannot downgrade from version ${currentVersion} to ${targetVersion}. Downgrading is not supported.`);
86
+ }
87
+ // Cannot migrate beyond current application schema
88
+ if (targetVersion > SCHEMA_VERSION) {
89
+ throw new Error(`Cannot migrate to version ${targetVersion}. Current application supports up to version ${SCHEMA_VERSION}.`);
61
90
  }
91
+ // No migration needed
92
+ if (currentVersion === targetVersion) {
93
+ return {
94
+ success: true,
95
+ message: `Project is already at version ${currentVersion}. No migration needed.`,
96
+ stepsExecuted: [],
97
+ };
98
+ }
99
+ // Prevent skipping migrations when a specific target version is provided
100
+ // If no version specified, migrate to the latest
101
+ if (toVersion !== undefined && toVersion !== SCHEMA_VERSION) {
102
+ // Only allow next sequential version
103
+ if (targetVersion !== currentVersion + 1) {
104
+ throw new Error(`Cannot skip to version ${targetVersion}. Project is at version ${currentVersion}, next version is ${currentVersion + 1}. Migrate one version at a time with 'cyberismo migrate ${currentVersion + 1}', or use 'cyberismo migrate' (without a version) to migrate to the latest version.`);
105
+ }
106
+ }
107
+ return await this.project.runMigrations(currentVersion, targetVersion, backupDir, timeoutMilliSeconds);
62
108
  }
63
- return await this.project.runMigrations(currentVersion, targetVersion, backupDir, timeoutMilliSeconds);
64
- }
65
- }
109
+ };
110
+ })();
111
+ export { Migrate };
66
112
  //# sourceMappingURL=migrate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAInD;;GAEG;AACH,MAAM,OAAO,OAAO;IAKE;IAJpB;;;OAGG;IACH,YAAoB,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;IAAG,CAAC;IAExC;;;;;;OAMG;IACI,KAAK,CAAC,OAAO,CAClB,SAAkB,EAClB,SAAkB,EAClB,mBAA4B;QAE5B,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC;QAChE,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,mCAA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