@cyberismo/data-handler 0.0.14 → 0.0.16

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 (280) hide show
  1. package/dist/card-metadata-updater.js +8 -4
  2. package/dist/card-metadata-updater.js.map +1 -1
  3. package/dist/command-handler.d.ts +4 -0
  4. package/dist/command-handler.js +29 -19
  5. package/dist/command-handler.js.map +1 -1
  6. package/dist/command-manager.d.ts +25 -2
  7. package/dist/command-manager.js +30 -5
  8. package/dist/command-manager.js.map +1 -1
  9. package/dist/commands/create.d.ts +1 -1
  10. package/dist/commands/create.js +45 -93
  11. package/dist/commands/create.js.map +1 -1
  12. package/dist/commands/edit.d.ts +1 -15
  13. package/dist/commands/edit.js +15 -89
  14. package/dist/commands/edit.js.map +1 -1
  15. package/dist/commands/export.d.ts +11 -2
  16. package/dist/commands/export.js +58 -58
  17. package/dist/commands/export.js.map +1 -1
  18. package/dist/commands/import.d.ts +9 -1
  19. package/dist/commands/import.js +17 -11
  20. package/dist/commands/import.js.map +1 -1
  21. package/dist/commands/move.d.ts +1 -2
  22. package/dist/commands/move.js +107 -146
  23. package/dist/commands/move.js.map +1 -1
  24. package/dist/commands/remove.d.ts +8 -1
  25. package/dist/commands/remove.js +17 -48
  26. package/dist/commands/remove.js.map +1 -1
  27. package/dist/commands/rename.d.ts +4 -9
  28. package/dist/commands/rename.js +34 -108
  29. package/dist/commands/rename.js.map +1 -1
  30. package/dist/commands/show.d.ts +22 -34
  31. package/dist/commands/show.js +103 -151
  32. package/dist/commands/show.js.map +1 -1
  33. package/dist/commands/transition.d.ts +9 -2
  34. package/dist/commands/transition.js +49 -44
  35. package/dist/commands/transition.js.map +1 -1
  36. package/dist/commands/update.d.ts +18 -12
  37. package/dist/commands/update.js +34 -18
  38. package/dist/commands/update.js.map +1 -1
  39. package/dist/commands/validate.d.ts +18 -10
  40. package/dist/commands/validate.js +101 -47
  41. package/dist/commands/validate.js.map +1 -1
  42. package/dist/containers/card-container.d.ts +87 -24
  43. package/dist/containers/card-container.js +183 -279
  44. package/dist/containers/card-container.js.map +1 -1
  45. package/dist/containers/project/calculation-engine.d.ts +13 -4
  46. package/dist/containers/project/calculation-engine.js +79 -77
  47. package/dist/containers/project/calculation-engine.js.map +1 -1
  48. package/dist/containers/project/card-cache.d.ts +146 -0
  49. package/dist/containers/project/card-cache.js +411 -0
  50. package/dist/containers/project/card-cache.js.map +1 -0
  51. package/dist/containers/project/project-paths.d.ts +5 -4
  52. package/dist/containers/project/project-paths.js +16 -12
  53. package/dist/containers/project/project-paths.js.map +1 -1
  54. package/dist/containers/project/resource-cache.d.ts +169 -0
  55. package/dist/containers/project/resource-cache.js +507 -0
  56. package/dist/containers/project/resource-cache.js.map +1 -0
  57. package/dist/containers/project/resource-handler.d.ts +129 -0
  58. package/dist/containers/project/resource-handler.js +206 -0
  59. package/dist/containers/project/resource-handler.js.map +1 -0
  60. package/dist/containers/project.d.ts +114 -195
  61. package/dist/containers/project.js +425 -535
  62. package/dist/containers/project.js.map +1 -1
  63. package/dist/containers/template.d.ts +22 -32
  64. package/dist/containers/template.js +113 -115
  65. package/dist/containers/template.js.map +1 -1
  66. package/dist/index.d.ts +1 -0
  67. package/dist/index.js +1 -0
  68. package/dist/index.js.map +1 -1
  69. package/dist/interfaces/folder-content-interfaces.d.ts +7 -4
  70. package/dist/interfaces/folder-content-interfaces.js +3 -3
  71. package/dist/interfaces/folder-content-interfaces.js.map +1 -1
  72. package/dist/interfaces/macros.d.ts +1 -0
  73. package/dist/interfaces/macros.js +1 -1
  74. package/dist/interfaces/macros.js.map +1 -1
  75. package/dist/interfaces/project-interfaces.d.ts +7 -5
  76. package/dist/interfaces/project-interfaces.js.map +1 -1
  77. package/dist/interfaces/resource-interfaces.d.ts +25 -22
  78. package/dist/interfaces/resource-interfaces.js +3 -0
  79. package/dist/interfaces/resource-interfaces.js.map +1 -1
  80. package/dist/macros/common.d.ts +10 -10
  81. package/dist/macros/createCards/index.d.ts +0 -13
  82. package/dist/macros/createCards/index.js.map +1 -1
  83. package/dist/macros/createCards/types.d.ts +44 -0
  84. package/dist/macros/createCards/types.js +15 -0
  85. package/dist/macros/createCards/types.js.map +1 -0
  86. package/dist/macros/graph/index.d.ts +2 -6
  87. package/dist/macros/graph/index.js +14 -28
  88. package/dist/macros/graph/index.js.map +1 -1
  89. package/dist/macros/graph/types.d.ts +23 -0
  90. package/dist/macros/graph/types.js +15 -0
  91. package/dist/macros/graph/types.js.map +1 -0
  92. package/dist/macros/image/index.d.ts +8 -16
  93. package/dist/macros/image/index.js +36 -33
  94. package/dist/macros/image/index.js.map +1 -1
  95. package/dist/macros/image/types.d.ts +38 -0
  96. package/dist/macros/image/types.js +15 -0
  97. package/dist/macros/image/types.js.map +1 -0
  98. package/dist/macros/include/index.d.ts +1 -6
  99. package/dist/macros/include/index.js +4 -7
  100. package/dist/macros/include/index.js.map +1 -1
  101. package/dist/macros/include/types.d.ts +31 -0
  102. package/dist/macros/include/types.js +15 -0
  103. package/dist/macros/include/types.js.map +1 -0
  104. package/dist/macros/index.d.ts +1 -1
  105. package/dist/macros/index.js +2 -2
  106. package/dist/macros/index.js.map +1 -1
  107. package/dist/macros/percentage/index.d.ts +0 -6
  108. package/dist/macros/percentage/index.js.map +1 -1
  109. package/dist/macros/percentage/types.d.ts +31 -0
  110. package/dist/macros/percentage/types.js +15 -0
  111. package/dist/macros/percentage/types.js.map +1 -0
  112. package/dist/macros/report/index.d.ts +0 -3
  113. package/dist/macros/report/index.js +3 -6
  114. package/dist/macros/report/index.js.map +1 -1
  115. package/dist/macros/report/types.d.ts +19 -0
  116. package/dist/macros/report/types.js +15 -0
  117. package/dist/macros/report/types.js.map +1 -0
  118. package/dist/macros/scoreCard/index.d.ts +0 -6
  119. package/dist/macros/scoreCard/index.js.map +1 -1
  120. package/dist/macros/scoreCard/types.d.ts +31 -0
  121. package/dist/macros/scoreCard/types.js +15 -0
  122. package/dist/macros/scoreCard/types.js.map +1 -0
  123. package/dist/macros/types.d.ts +25 -0
  124. package/dist/macros/types.js +2 -0
  125. package/dist/macros/types.js.map +1 -0
  126. package/dist/macros/vega/index.d.ts +0 -4
  127. package/dist/macros/vega/index.js.map +1 -1
  128. package/dist/macros/vega/types.d.ts +20 -0
  129. package/dist/macros/vega/types.js +2 -0
  130. package/dist/macros/vega/types.js.map +1 -0
  131. package/dist/macros/vegalite/index.d.ts +0 -4
  132. package/dist/macros/vegalite/index.js.map +1 -1
  133. package/dist/macros/vegalite/types.d.ts +20 -0
  134. package/dist/macros/vegalite/types.js +15 -0
  135. package/dist/macros/vegalite/types.js.map +1 -0
  136. package/dist/macros/xref/index.d.ts +0 -3
  137. package/dist/macros/xref/index.js +5 -14
  138. package/dist/macros/xref/index.js.map +1 -1
  139. package/dist/macros/xref/types.d.ts +19 -0
  140. package/dist/macros/xref/types.js +15 -0
  141. package/dist/macros/xref/types.js.map +1 -0
  142. package/dist/module-manager.d.ts +16 -3
  143. package/dist/module-manager.js +55 -23
  144. package/dist/module-manager.js.map +1 -1
  145. package/dist/project-settings.d.ts +16 -3
  146. package/dist/project-settings.js +79 -14
  147. package/dist/project-settings.js.map +1 -1
  148. package/dist/resources/calculation-resource.d.ts +6 -33
  149. package/dist/resources/calculation-resource.js +11 -60
  150. package/dist/resources/calculation-resource.js.map +1 -1
  151. package/dist/resources/card-type-resource.d.ts +10 -22
  152. package/dist/resources/card-type-resource.js +46 -66
  153. package/dist/resources/card-type-resource.js.map +1 -1
  154. package/dist/resources/create-defaults.d.ts +3 -2
  155. package/dist/resources/create-defaults.js +3 -2
  156. package/dist/resources/create-defaults.js.map +1 -1
  157. package/dist/resources/field-type-resource.d.ts +8 -22
  158. package/dist/resources/field-type-resource.js +35 -60
  159. package/dist/resources/field-type-resource.js.map +1 -1
  160. package/dist/resources/file-resource.d.ts +14 -35
  161. package/dist/resources/file-resource.js +22 -301
  162. package/dist/resources/file-resource.js.map +1 -1
  163. package/dist/resources/folder-resource.d.ts +44 -66
  164. package/dist/resources/folder-resource.js +102 -149
  165. package/dist/resources/folder-resource.js.map +1 -1
  166. package/dist/resources/graph-model-resource.d.ts +9 -34
  167. package/dist/resources/graph-model-resource.js +18 -64
  168. package/dist/resources/graph-model-resource.js.map +1 -1
  169. package/dist/resources/graph-view-resource.d.ts +9 -29
  170. package/dist/resources/graph-view-resource.js +13 -48
  171. package/dist/resources/graph-view-resource.js.map +1 -1
  172. package/dist/resources/link-type-resource.d.ts +9 -23
  173. package/dist/resources/link-type-resource.js +11 -33
  174. package/dist/resources/link-type-resource.js.map +1 -1
  175. package/dist/resources/report-resource.d.ts +10 -23
  176. package/dist/resources/report-resource.js +20 -67
  177. package/dist/resources/report-resource.js.map +1 -1
  178. package/dist/resources/resource-object.d.ts +143 -23
  179. package/dist/resources/resource-object.js +369 -48
  180. package/dist/resources/resource-object.js.map +1 -1
  181. package/dist/resources/template-resource.d.ts +10 -17
  182. package/dist/resources/template-resource.js +19 -27
  183. package/dist/resources/template-resource.js.map +1 -1
  184. package/dist/resources/workflow-resource.d.ts +9 -25
  185. package/dist/resources/workflow-resource.js +25 -55
  186. package/dist/resources/workflow-resource.js.map +1 -1
  187. package/dist/utils/card-utils.d.ts +69 -19
  188. package/dist/utils/card-utils.js +179 -30
  189. package/dist/utils/card-utils.js.map +1 -1
  190. package/dist/utils/clingo-fact-builder.d.ts +25 -14
  191. package/dist/utils/clingo-fact-builder.js +27 -5
  192. package/dist/utils/clingo-fact-builder.js.map +1 -1
  193. package/dist/utils/clingo-facts.js +14 -7
  194. package/dist/utils/clingo-facts.js.map +1 -1
  195. package/dist/utils/clingo-parser.js +1 -1
  196. package/dist/utils/clingo-parser.js.map +1 -1
  197. package/dist/utils/constants.d.ts +2 -0
  198. package/dist/utils/constants.js +4 -0
  199. package/dist/utils/constants.js.map +1 -1
  200. package/dist/utils/csv.js +1 -1
  201. package/dist/utils/csv.js.map +1 -1
  202. package/dist/utils/resource-utils.d.ts +1 -0
  203. package/dist/utils/resource-utils.js +2 -1
  204. package/dist/utils/resource-utils.js.map +1 -1
  205. package/package.json +11 -11
  206. package/src/card-metadata-updater.ts +9 -7
  207. package/src/command-handler.ts +35 -23
  208. package/src/command-manager.ts +32 -19
  209. package/src/commands/create.ts +59 -160
  210. package/src/commands/edit.ts +16 -132
  211. package/src/commands/export.ts +71 -81
  212. package/src/commands/import.ts +26 -18
  213. package/src/commands/move.ts +143 -179
  214. package/src/commands/remove.ts +20 -59
  215. package/src/commands/rename.ts +45 -156
  216. package/src/commands/show.ts +153 -211
  217. package/src/commands/transition.ts +53 -58
  218. package/src/commands/update.ts +44 -23
  219. package/src/commands/validate.ts +108 -82
  220. package/src/containers/card-container.ts +200 -360
  221. package/src/containers/project/calculation-engine.ts +81 -105
  222. package/src/containers/project/card-cache.ts +497 -0
  223. package/src/containers/project/project-paths.ts +21 -13
  224. package/src/containers/project/resource-cache.ts +648 -0
  225. package/src/containers/project/resource-handler.ts +265 -0
  226. package/src/containers/project.ts +551 -693
  227. package/src/containers/template.ts +129 -142
  228. package/src/index.ts +1 -0
  229. package/src/interfaces/folder-content-interfaces.ts +14 -7
  230. package/src/interfaces/macros.ts +2 -0
  231. package/src/interfaces/project-interfaces.ts +14 -7
  232. package/src/interfaces/resource-interfaces.ts +30 -27
  233. package/src/macros/createCards/index.ts +1 -12
  234. package/src/macros/createCards/types.ts +46 -0
  235. package/src/macros/graph/index.ts +27 -52
  236. package/src/macros/graph/types.ts +24 -0
  237. package/src/macros/image/index.ts +50 -61
  238. package/src/macros/image/types.ts +39 -0
  239. package/src/macros/include/index.ts +6 -15
  240. package/src/macros/include/types.ts +32 -0
  241. package/src/macros/index.ts +2 -2
  242. package/src/macros/percentage/index.ts +1 -7
  243. package/src/macros/percentage/types.ts +32 -0
  244. package/src/macros/report/index.ts +4 -13
  245. package/src/macros/report/types.ts +20 -0
  246. package/src/macros/scoreCard/index.ts +1 -7
  247. package/src/macros/scoreCard/types.ts +32 -0
  248. package/src/macros/types.ts +48 -0
  249. package/src/macros/vega/index.ts +1 -4
  250. package/src/macros/vega/types.ts +21 -0
  251. package/src/macros/vegalite/index.ts +1 -4
  252. package/src/macros/vegalite/types.ts +22 -0
  253. package/src/macros/xref/index.ts +6 -20
  254. package/src/macros/xref/types.ts +20 -0
  255. package/src/module-manager.ts +79 -22
  256. package/src/project-settings.ts +84 -15
  257. package/src/resources/calculation-resource.ts +21 -91
  258. package/src/resources/card-type-resource.ts +74 -109
  259. package/src/resources/create-defaults.ts +3 -2
  260. package/src/resources/field-type-resource.ts +61 -104
  261. package/src/resources/file-resource.ts +33 -441
  262. package/src/resources/folder-resource.ts +130 -207
  263. package/src/resources/graph-model-resource.ts +36 -95
  264. package/src/resources/graph-view-resource.ts +28 -70
  265. package/src/resources/link-type-resource.ts +23 -53
  266. package/src/resources/report-resource.ts +34 -96
  267. package/src/resources/resource-object.ts +511 -66
  268. package/src/resources/template-resource.ts +32 -44
  269. package/src/resources/workflow-resource.ts +42 -85
  270. package/src/utils/card-utils.ts +217 -31
  271. package/src/utils/clingo-fact-builder.ts +28 -16
  272. package/src/utils/clingo-facts.ts +16 -7
  273. package/src/utils/clingo-parser.ts +1 -1
  274. package/src/utils/constants.ts +6 -0
  275. package/src/utils/csv.ts +1 -1
  276. package/src/utils/resource-utils.ts +2 -1
  277. package/dist/containers/project/resource-collector.d.ts +0 -87
  278. package/dist/containers/project/resource-collector.js +0 -337
  279. package/dist/containers/project/resource-collector.js.map +0 -1
  280. package/src/containers/project/resource-collector.ts +0 -396
@@ -20,17 +20,6 @@ import type { Card } from '../interfaces/project-interfaces.js';
20
20
  import { isTemplateCard } from '../utils/card-utils.js';
21
21
  import { type Project, ResourcesFrom } from '../containers/project.js';
22
22
  import { resourceName } from '../utils/resource-utils.js';
23
- import { Template } from '../containers/template.js';
24
-
25
- import { CalculationResource } from '../resources/calculation-resource.js';
26
- import { CardTypeResource } from '../resources/card-type-resource.js';
27
- import { FieldTypeResource } from '../resources/field-type-resource.js';
28
- import { GraphModelResource } from '../resources/graph-model-resource.js';
29
- import { GraphViewResource } from '../resources/graph-view-resource.js';
30
- import { LinkTypeResource } from '../resources/link-type-resource.js';
31
- import { ReportResource } from '../resources/report-resource.js';
32
- import { TemplateResource } from '../resources/template-resource.js';
33
- import { WorkflowResource } from '../resources/workflow-resource.js';
34
23
 
35
24
  const FILE_TYPES_WITH_PREFIX_REFERENCES = ['adoc', 'hbs', 'json', 'lp'];
36
25
 
@@ -41,6 +30,10 @@ export class Rename {
41
30
  private from: string = '';
42
31
  private to: string = '';
43
32
 
33
+ /**
34
+ * Creates an instance of Rename command.
35
+ * @param project Project instance to use.
36
+ */
44
37
  constructor(private project: Project) {}
45
38
 
46
39
  // Renames a card and all of its attachments (if it is a project card).
@@ -183,93 +176,6 @@ export class Rename {
183
176
  : name;
184
177
  }
185
178
 
186
- // @todo: merge all update-functions
187
- // Updates card type's metadata.
188
- private async updateCardTypeMetadata(cardTypeName: string) {
189
- const cardType = new CardTypeResource(
190
- this.project,
191
- resourceName(cardTypeName),
192
- );
193
- return cardType.rename(resourceName(this.updateResourceName(cardTypeName)));
194
- }
195
-
196
- // Rename calculations.
197
- private async updateCalculation(calculationName: string) {
198
- const calculation = new CalculationResource(
199
- this.project,
200
- resourceName(calculationName),
201
- );
202
- return calculation.rename(
203
- resourceName(this.updateResourceName(calculationName)),
204
- );
205
- }
206
-
207
- // Updates field type's metadata.
208
- private async updateFieldTypeMetadata(fieldTypeName: string) {
209
- const fieldType = new FieldTypeResource(
210
- this.project,
211
- resourceName(fieldTypeName),
212
- );
213
- return fieldType.rename(
214
- resourceName(this.updateResourceName(fieldTypeName)),
215
- );
216
- }
217
-
218
- // Updates graph model's metadata.
219
- private async updateGraphModelMetadata(graphModelName: string) {
220
- const graphModel = new GraphModelResource(
221
- this.project,
222
- resourceName(graphModelName),
223
- );
224
- return graphModel.rename(
225
- resourceName(this.updateResourceName(graphModelName)),
226
- );
227
- }
228
-
229
- // Updates graph view's metadata.
230
- private async updateGraphViewMetadata(graphViewName: string) {
231
- const graphView = new GraphViewResource(
232
- this.project,
233
- resourceName(graphViewName),
234
- );
235
- return graphView.rename(
236
- resourceName(this.updateResourceName(graphViewName)),
237
- );
238
- }
239
-
240
- // Updates link type's metadata.
241
- private async updateLinkTypeMetadata(linkTypeName: string) {
242
- const linkType = new LinkTypeResource(
243
- this.project,
244
- resourceName(linkTypeName),
245
- );
246
- return linkType.rename(resourceName(this.updateResourceName(linkTypeName)));
247
- }
248
-
249
- // Updates reports' metadata.
250
- private async updateReport(reportName: string) {
251
- const report = new ReportResource(this.project, resourceName(reportName));
252
- return report.rename(resourceName(this.updateResourceName(reportName)));
253
- }
254
-
255
- // Rename templates.
256
- private async updateTemplate(templateName: string) {
257
- const template = new TemplateResource(
258
- this.project,
259
- resourceName(templateName),
260
- );
261
- return template.rename(resourceName(this.updateResourceName(templateName)));
262
- }
263
-
264
- // Rename workflows.
265
- private async updateWorkflowMetadata(workflowName: string) {
266
- const workflow = new WorkflowResource(
267
- this.project,
268
- resourceName(workflowName),
269
- );
270
- return workflow.rename(resourceName(this.updateResourceName(workflowName)));
271
- }
272
-
273
179
  /**
274
180
  * Renames project prefix.
275
181
  * @throws if trying to use empty 'to'
@@ -280,11 +186,6 @@ export class Rename {
280
186
  if (!to) {
281
187
  throw new Error(`Input validation error: empty 'to' is not allowed`);
282
188
  }
283
- const cardContent = {
284
- metadata: true,
285
- attachments: true,
286
- content: true,
287
- };
288
189
 
289
190
  this.from = this.project.configuration.cardKeyPrefix;
290
191
  this.to = to;
@@ -299,79 +200,67 @@ export class Rename {
299
200
  await this.project.configuration.setCardPrefix(to);
300
201
  console.info(`Rename: New prefix: '${this.project.projectPrefix}'`);
301
202
  // Update the resources collection, since project prefix has changed.
302
- this.project.collectLocalResources();
203
+ this.project.resources.changed();
303
204
 
304
205
  // Rename local resources.
305
- // It is better to rename the resources in this order: card types, field types, then others
206
+ // It is better to rename the resources in this order: card types, workflows, field types, then the rest
306
207
 
307
208
  // Rename all card types and custom fields in them.
308
- const cardTypes = await this.project.cardTypes(ResourcesFrom.localOnly);
309
- for (const cardType of cardTypes) {
310
- await this.updateCardTypeMetadata(cardType.name);
209
+ for (const cardType of this.project.resources.cardTypes(
210
+ ResourcesFrom.localOnly,
211
+ )) {
212
+ const name = this.updateResourceName(cardType.data?.name || '');
213
+ await cardType.rename(resourceName(name));
311
214
  }
312
215
  console.info('Updated card types');
313
216
 
314
- const workflows = await this.project.workflows(ResourcesFrom.localOnly);
315
- for (const workflow of workflows) {
316
- await this.updateWorkflowMetadata(workflow.name);
217
+ for (const workflow of this.project.resources.workflows(
218
+ ResourcesFrom.localOnly,
219
+ )) {
220
+ const name = this.updateResourceName(workflow.data?.name || '');
221
+ await workflow.rename(resourceName(name));
317
222
  }
318
223
  console.info('Updated workflows');
319
224
 
320
- const fieldTypes = await this.project.fieldTypes(ResourcesFrom.localOnly);
321
- for (const fieldType of fieldTypes) {
322
- await this.updateFieldTypeMetadata(fieldType.name);
225
+ for (const fieldType of this.project.resources.fieldTypes(
226
+ ResourcesFrom.localOnly,
227
+ )) {
228
+ const name = this.updateResourceName(fieldType.data?.name || '');
229
+ await fieldType.rename(resourceName(name));
323
230
  }
324
231
  console.info('Updated field types');
325
232
 
326
- const graphModels = await this.project.graphModels(ResourcesFrom.localOnly);
327
- for (const graphModel of graphModels) {
328
- await this.updateGraphModelMetadata(graphModel.name);
329
- }
330
- console.info('Updated graph models');
331
-
332
- const graphViews = await this.project.graphViews(ResourcesFrom.localOnly);
333
- for (const graphView of graphViews) {
334
- await this.updateGraphViewMetadata(graphView.name);
335
- }
336
- console.info('Updated graph views');
337
-
338
- const linkTypes = await this.project.linkTypes(ResourcesFrom.localOnly);
339
- for (const linkType of linkTypes) {
340
- await this.updateLinkTypeMetadata(linkType.name);
341
- }
342
- console.info('Updated link types');
343
-
344
- const reports = await this.project.reports(ResourcesFrom.localOnly);
345
- for (const report of reports) {
346
- await this.updateReport(report.name);
347
- }
348
- console.info('Updated reports');
349
-
350
- let templates = await this.project.templates(ResourcesFrom.localOnly);
351
- for (const template of templates) {
352
- await this.updateTemplate(template.name);
233
+ const restOfResourceTypes = [
234
+ 'graphModels',
235
+ 'graphViews',
236
+ 'linkTypes',
237
+ 'reports',
238
+ 'templates',
239
+ 'calculations',
240
+ ] as const;
241
+
242
+ for (const resourceType of restOfResourceTypes) {
243
+ for (const resource of this.project.resources.resourceTypes(
244
+ resourceType,
245
+ ResourcesFrom.localOnly,
246
+ )) {
247
+ const name = this.updateResourceName(resource.data?.name || '');
248
+ await resource.rename(resourceName(name));
249
+ }
353
250
  }
354
- console.info('Updated templates');
355
251
 
356
- const calculations = await this.project.calculations(
252
+ // Rename all local template cards. This must be done after calculations have been renamed.
253
+ for (const template of this.project.resources.templates(
357
254
  ResourcesFrom.localOnly,
358
- );
359
- for (const calculation of calculations) {
360
- await this.updateCalculation(calculation.name);
361
- }
362
- console.info('Updated calculations');
363
-
364
- // Rename all local template cards.
365
- templates = await this.project.templates(ResourcesFrom.localOnly);
366
- for (const template of templates) {
367
- const templateObject = new Template(this.project, template);
368
- await this.renameCards(await templateObject.cards('', cardContent));
255
+ )) {
256
+ const templateObject = template.templateObject();
257
+ await this.renameCards(templateObject.cards());
369
258
  }
370
259
  console.info('Renamed template cards and updated the content');
371
260
 
372
261
  // Rename all project cards.
373
262
  await this.renameCards(
374
- await this.project.cards(this.project.paths.cardRootFolder, cardContent),
263
+ this.project.cards(this.project.paths.cardRootFolder),
375
264
  );
376
265
  console.info('Renamed project cards and updated the content');
377
266
 
@@ -381,7 +270,7 @@ export class Rename {
381
270
  console.info('Renamed all remaining references in .cards folder');
382
271
 
383
272
  // It is best that the resources are re-collected after all the renaming has occurred.
384
- this.project.collectLocalResources();
273
+ this.project.resources.changed();
385
274
  console.info('Collected renamed resources');
386
275
 
387
276
  return this.project.calculationEngine.generate();