@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
@@ -13,110 +13,113 @@
13
13
  */
14
14
  import { CardContainer } from './card-container.js';
15
15
  import { CalculationEngine } from './project/calculation-engine.js';
16
- import { type Card, type CardAttachment, CardLocation, type CardListContainer, type CardMetadata, type FetchCardDetails, type MetadataContent, type ModuleContent, type ModuleSetting, type ProjectFetchCardDetails, type ProjectMetadata, type Resource, type ResourceFolderType } from '../interfaces/project-interfaces.js';
16
+ import { type Card, type CardAttachment, CardLocation, type CardListContainer, type CardMetadata, type FetchCardDetails, type MetadataContent, type ModuleContent, type ModuleSetting, type ProjectFetchCardDetails, type ProjectMetadata } from '../interfaces/project-interfaces.js';
17
17
  import { ProjectConfiguration } from '../project-settings.js';
18
18
  import { ProjectPaths } from './project/project-paths.js';
19
- import { type ResourceName } from '../utils/resource-utils.js';
20
- import { ResourcesFrom } from './project/resource-collector.js';
19
+ import { ResourcesFrom } from './project/resource-cache.js';
20
+ import { ResourceHandler } from './project/resource-handler.js';
21
21
  import type { Template } from './template.js';
22
- import { CalculationResource } from '../resources/calculation-resource.js';
23
- import { CardTypeResource } from '../resources/card-type-resource.js';
24
- import { FieldTypeResource } from '../resources/field-type-resource.js';
25
- import { GraphModelResource } from '../resources/graph-model-resource.js';
26
- import { GraphViewResource } from '../resources/graph-view-resource.js';
27
- import { LinkTypeResource } from '../resources/link-type-resource.js';
28
- import { ReportResource } from '../resources/report-resource.js';
29
- import { TemplateResource } from '../resources/template-resource.js';
30
- import { WorkflowResource } from '../resources/workflow-resource.js';
31
22
  export { ResourcesFrom };
23
+ /**
24
+ * Options for Project initialization.
25
+ * autoSave - If project configuration changes are saved automatically. Default true.
26
+ * watchResourceChanges - If project refresh automatically to filesystem changes. Default false.
27
+ */
28
+ export interface ProjectOptions {
29
+ autoSave?: boolean;
30
+ watchResourceChanges?: boolean;
31
+ }
32
32
  /**
33
33
  * Represents project folder.
34
34
  */
35
35
  export declare class Project extends CardContainer {
36
- private watchResourceChanges?;
36
+ private options;
37
37
  calculationEngine: CalculationEngine;
38
- private resources;
38
+ private logger;
39
39
  private projectPaths;
40
+ private resourceHandler;
41
+ private resourceWatcher;
40
42
  private settings;
41
43
  private validator;
42
- private resourceWatcher;
43
- private createdResources;
44
- constructor(path: string, watchResourceChanges?: boolean | undefined);
45
- private replaceCacheValue;
44
+ constructor(path: string, options?: ProjectOptions);
45
+ private changeParent;
46
46
  private findModule;
47
- private resourcesOfType;
47
+ private handleAttachmentChange;
48
+ private parentFromPath;
49
+ private removeCachedChildren;
50
+ private updateCachedChildren;
51
+ private validateCard;
52
+ /**
53
+ * Populate template cards into the card cache.
54
+ */
55
+ protected populateTemplateCards(): Promise<void>;
48
56
  /**
49
- * Add a given 'resource' to the local resource arrays.
50
- * @param resource Resource to add.
51
- * @param data JSON data for the resource.
57
+ * Populate both the project cards, and all template cards into card cache.
52
58
  */
53
- addResource(resource: Resource, data: JSON): void;
59
+ protected populateCardsCache(): Promise<void>;
60
+ /**
61
+ * Returns all template cards from the project. This includes all module templates' cards.
62
+ * @returns all the template cards from the project
63
+ */
64
+ allTemplateCards(): Card[];
54
65
  /**
55
66
  * Returns an array of all the attachments in the project card's (excluding ones in templates).
56
67
  * @returns all attachments in the project.
57
68
  */
58
- attachments(): Promise<CardAttachment[]>;
69
+ attachments(): CardAttachment[];
59
70
  /**
60
- * Returns an array of all the calculation files (*.lp) in the project.
61
- * @param from Defines where resources are collected from.
62
- * @returns array of all calculation files in the project.
71
+ * Returns attachments from cards at a specific path using the card cache.
72
+ * This method allows templates to access attachments from the shared cache.
73
+ * @param path The path to get attachments from
74
+ * @returns Array of attachments from cards at the specified path
63
75
  */
64
- calculations(from?: ResourcesFrom): Promise<Resource[]>;
76
+ attachmentsByPath(path: string): CardAttachment[];
65
77
  /**
66
- * Returns path to card's attachment folder.
78
+ * Returns path to a card's attachment folder.
67
79
  * @param cardKey card key
68
- * @returns path to card's attachment folder.
69
- * @throws if card path cannot be found
80
+ * @returns path to a card's attachment folder.
70
81
  */
71
- cardAttachmentFolder(cardKey: string): Promise<string>;
82
+ cardAttachmentFolder(cardKey: string): string;
72
83
  /**
73
- * Returns details (as defined by cardDetails) of a card.
74
- * @param cardKey card key (project prefix and a number, e.g. test_1)
75
- * @param cardDetails which card details are returned.
76
- * @returns Card details, or undefined if the card cannot be found.
84
+ * Creates an attachment for a card.
85
+ * @param cardKey The card to add attachment to
86
+ * @param attachmentName The name for the attachment file
87
+ * @param attachmentData The attachment data (file path or buffer)
88
+ * @throws If trying to add attachment to module card, or if attachment is not found
77
89
  */
78
- cardDetailsById(cardKey: string, cardDetails: ProjectFetchCardDetails): Promise<Card | undefined>;
90
+ createCardAttachment(cardKey: string, attachmentName: string, attachmentData: string | Buffer): Promise<void>;
79
91
  /**
80
- * Returns path to card's folder.
92
+ * Returns path to a card's folder.
81
93
  * @param cardKey card key
82
- * @returns path to card's folder.
94
+ * @returns path to a card's folder.
83
95
  */
84
96
  cardFolder(cardKey: string): Promise<string>;
85
97
  /**
86
- * Splits card path to parts. Returns the parts.
87
- * Returned parts are: prefix, card key, array of parents and template name. Template name is returned only for template cards.
88
- * @param cardPath path to a card
89
- * @returns card path logical parts
90
- * @throws when called with wrong path, or wrong card owner
91
- * todo: if prefix would be parameter; this could be static, or util method
92
- */
93
- cardPathParts(cardPath: string): {
94
- cardKey: string | undefined;
95
- parents: (string | undefined)[];
96
- prefix: string;
97
- template: string;
98
- };
99
- /**
100
- * Returns an array of all the cards in the project. Cards have content and metadata
101
- * @param path Optional path from which to fetch the cards. Generally it is best to fetch from Project root, e.g. Project.cardRootFolder
102
- * @param details Which details to include in the cards; by default only "content" and "metadata" are included.
103
- * @returns all cards from the given path in the project.
98
+ * Fetches full Card data for given card keys
99
+ * @param cardIds array of card keys to fetch
100
+ * @returns Card data to the given card keys
104
101
  */
105
- cards(path?: string, details?: FetchCardDetails): Promise<Card[]>;
102
+ cardKeysToCards(cardIds: string[]): Card[];
106
103
  /**
107
- * Returns an array of all the card types in the project.
108
- * @param from Defines where resources are collected from.
109
- * @returns array of all card types in the project.
104
+ * Returns an array of all the cards in the project.
105
+ * @note These are project cards only, by default (unless path dictates otherwise).
106
+ * @param path Path from which to fetch the cards. Generally it is best to fetch from Project root, e.g. Project.cardRootFolder
107
+ * @param details Which details to include in the cards; by default all details are included.
108
+ * @returns all cards from the given path in the project.
110
109
  */
111
- cardTypes(from?: ResourcesFrom): Promise<Resource[]>;
110
+ cards(path?: string, details?: FetchCardDetails): Card[];
112
111
  /**
113
- * Updates all local resources.
112
+ * Accessor for cards cache.
113
+ * Used by template container (it needs to access project's cache, not their own instance).
114
+ * @note Should not be used directly (other than Template).
114
115
  */
115
- collectLocalResources(): void;
116
+ get cardsCache(): import("./project/card-cache.js").CardCache;
116
117
  /**
117
- * Updates all imported module resources.
118
+ * Returns children of a given card; as Card array
119
+ * @param card Parent card to fetch children from
120
+ * @returns children of a given card; as Card array
118
121
  */
119
- collectModuleResources(): Promise<void>;
122
+ childrenCards(card: Card): Card[];
120
123
  /**
121
124
  * Returns project configuration.
122
125
  * @returns project configuration.
@@ -132,37 +135,19 @@ export declare class Project extends CardContainer {
132
135
  * Cleanups project when it is being closed.
133
136
  */
134
137
  dispose(): void;
135
- /**
136
- * Returns an array of all the field types in the project.
137
- * @param from Defines where resources are collected from.
138
- * @returns array of all field types in the project.
139
- */
140
- fieldTypes(from?: ResourcesFrom): Promise<Resource[]>;
141
- /**
142
- * Finds root of a project
143
- * @param path Path where to start looking for the project root.
144
- * @returns path to a project root, or empty string.
145
- */
146
- static findProjectRoot(path: string): Promise<string>;
147
138
  /**
148
139
  * Returns specific card.
149
140
  * @param cardToFind Card key to find
150
141
  * @param details Defines which card details are included in the return values.
151
142
  * @returns specific card details, or undefined if card is not part of the project.
152
143
  */
153
- findSpecificCard(cardToFind: string, details?: ProjectFetchCardDetails): Promise<Card | undefined>;
154
- /**
155
- * Returns an array of all the graph models in the project.
156
- * @param from Defines where resources are collected from.
157
- * @returns array of all the graph models in the project.
158
- */
159
- graphModels(from?: ResourcesFrom): Promise<Resource[]>;
144
+ findCard(cardToFind: string, details?: ProjectFetchCardDetails): Card;
160
145
  /**
161
- * Returns an array of all the graph views in the project.
162
- * @param from Defines where resources are collected from.
163
- * @returns array of all the graph views in the project.
146
+ * Finds root of a project
147
+ * @param path Path where to start looking for the project root.
148
+ * @returns path to a project root, or empty string.
164
149
  */
165
- graphViews(from?: ResourcesFrom): Promise<Resource[]>;
150
+ static findProjectRoot(path: string): Promise<string>;
166
151
  /**
167
152
  * When card changes.
168
153
  * @param changedCard Card that was changed.
@@ -172,47 +157,35 @@ export declare class Project extends CardContainer {
172
157
  * When cards are removed.
173
158
  * @param deletedCard Card that is to be removed.
174
159
  */
175
- handleDeleteCard(deletedCard: Card): Promise<void>;
160
+ handleCardDeleted(deletedCard: Card): Promise<void>;
161
+ /**
162
+ * When card is moved.
163
+ * @param movedCard Card that moved
164
+ * @param newParentCard New parent for the 'movedCard'
165
+ * @param oldParentCard Previous parent of the 'movedCard'
166
+ */
167
+ handleCardMoved(movedCard: Card, newParentCard?: Card, oldParentCard?: Card): Promise<void>;
176
168
  /**
177
169
  * When new cards are added.
178
170
  * @param cards Added cards.
179
171
  */
180
172
  handleNewCards(cards: Card[]): Promise<void>;
181
- /**
182
- * Checks if a given card is part of this project.
183
- * @param cardKey card to check.
184
- * @returns true if a given card is found from project, false otherwise.
185
- */
186
- hasCard(cardKey: string): boolean;
187
173
  /**
188
174
  * Adds a module from project.
189
- * @param module Name of the module
175
+ * @param module Module to add
190
176
  */
191
177
  importModule(module: ModuleSetting): Promise<void>;
192
178
  /**
193
- * Checks if given path is a project.
179
+ * Checks if a given path is a project.
194
180
  * @param path Path to a project
195
181
  * @returns true, if in the given path there is a project; false otherwise
196
182
  */
197
183
  static isCreated(path: string): boolean;
198
- /**
199
- * Returns whether card is a template card or not
200
- * @param cardKey card to check.
201
- * @todo: This is only used from 'remove'. Could it use the static checker?
202
- * @returns true, if card is template card; false otherwise
203
- */
204
- isTemplateCard(cardKey: string): Promise<boolean>;
205
- /**
206
- * Returns an array of all the link types in the project.
207
- * @param from Defines where resources are collected from.
208
- * @returns array of all link types in the project.
209
- */
210
- linkTypes(from?: ResourcesFrom): Promise<Resource[]>;
211
184
  /**
212
185
  * Returns an array of cards in the project, in the templates or both.
213
186
  * Cards don't have content and nor metadata.
214
187
  * @param cardsFrom Where to return cards from (project, templates, or both)
215
- * @returns all cards in the project.
188
+ * @returns all cards in the project per container.
216
189
  */
217
190
  listCards(cardsFrom?: CardLocation): Promise<CardListContainer[]>;
218
191
  /**
@@ -225,14 +198,9 @@ export declare class Project extends CardContainer {
225
198
  /**
226
199
  * Returns details of a certain module.
227
200
  * @param moduleName Name of the module.
228
- * @returns module details, or undefined if workflow cannot be found.
201
+ * @returns module details, or undefined if module cannot be found.
229
202
  */
230
203
  module(moduleName: string): Promise<ModuleContent | undefined>;
231
- /**
232
- * Returns list of modules in the project.
233
- * @returns list of modules in the project.
234
- */
235
- modules(): Promise<Resource[]>;
236
204
  /**
237
205
  * Returns a new unique card key with project prefix (e.g. test_x649it4x).
238
206
  * Random part of string will be always 8 characters in base-36 (0-9a-z)
@@ -255,11 +223,9 @@ export declare class Project extends CardContainer {
255
223
  */
256
224
  get paths(): ProjectPaths;
257
225
  /**
258
- * Returns full path to a given card.
259
- * @param cardKey card to check path for.
260
- * @returns path to a given card.
226
+ * Populates the card cache, if it has not been populated.
261
227
  */
262
- pathToCard(cardKey: string): string;
228
+ populateCaches(): Promise<void>;
263
229
  /**
264
230
  * Returns project name.
265
231
  */
@@ -269,56 +235,28 @@ export declare class Project extends CardContainer {
269
235
  */
270
236
  get projectPrefix(): string;
271
237
  /**
272
- * Collects all prefixes used in the project (project's own plus all from modules).
238
+ * Returns all prefixes used in the project (project's own plus all from imported modules).
273
239
  * @returns all prefixes used in the project.
274
- * @todo - move the module prefix fetch to resource-collector.
275
- * Make it use cached value that is only changed when module is removed/imported.
276
- */
277
- projectPrefixes(): Promise<string[]>;
278
- /**
279
- * Array of reports in the project.
280
- * @param from Defines where resources are collected from.
281
- * @returns array of all reports in the project.
282
- */
283
- reports(from?: ResourcesFrom): Promise<Resource[]>;
284
- /**
285
- * Returns handlebar files from reports.
286
- * @param from Defines where report handlebar files are collected from.
287
- * @returns handlebar files from reports.
288
- */
289
- reportHandlerBarFiles(from?: ResourcesFrom): Promise<string[]>;
290
- /**
291
- * Removes a resource from Project.
292
- * @param resource Resource to remove.
293
240
  */
294
- removeResource(resource: Resource): void;
241
+ projectPrefixes(): string[];
295
242
  /**
296
- * Returns metadata from a given resource
297
- * @param name Name of a resource
298
- * @returns Metadata from the resource.
243
+ * Removes an attachment from a card.
244
+ * @param cardKey The card to remove attachment from
245
+ * @param fileName The name of the attachment file to remove
246
+ * @throws if trying to remove module card attachment, or the attachment was not found.
299
247
  */
300
- resource<Type>(name: string): Promise<Type | undefined>;
248
+ removeCardAttachment(cardKey: string, fileName: string): Promise<void>;
301
249
  /**
302
- * Returns resource cache.
250
+ * Removes a module from the project cache and configuration.
251
+ * @note that ModuleManager removes the actual files.
252
+ * @param moduleName Module name to remove.
303
253
  */
304
- get resourceCache(): Map<string, JSON>;
254
+ removeModule(moduleName: string): Promise<void>;
305
255
  /**
306
- * Checks if a given resource exists in the project already.
307
- * @param resourceType Type of resource as a string.
308
- * @param name Valid name of resource.
309
- * @returns boolean, true if resource exists; false otherwise.
256
+ * Accessor for resource handler.
257
+ * @returns Resource handler instance.
310
258
  */
311
- resourceExists(resourceType: ResourceFolderType, name: string): Promise<boolean>;
312
- /**
313
- * Instantiates resource object from project with a resource name.
314
- * @note that this is memory based object only.
315
- * To manipulate the resource (create files, delete files etc), use the resource object's API.
316
- * @param project Project from which resources are created from.
317
- * @param name Resource name
318
- * @throws if called with unsupported resource type.
319
- * @returns Created resource.
320
- */
321
- static resourceObject(project: Project, name: ResourceName): CalculationResource | CardTypeResource | FieldTypeResource | GraphModelResource | GraphViewResource | LinkTypeResource | ReportResource | TemplateResource | WorkflowResource;
259
+ get resources(): ResourceHandler;
322
260
  /**
323
261
  * Shows details of a project.
324
262
  * @returns details of a project.
@@ -328,29 +266,16 @@ export declare class Project extends CardContainer {
328
266
  * Show cards of a project.
329
267
  * @returns an array of all project cards in the project.
330
268
  */
331
- showProjectCards(): Promise<Card[]>;
332
- /**
333
- * Returns all template cards from the project. This includes all module templates' cards.
334
- * @param cardDetails which details to fetch. Optional.
335
- * @returns all the template cards from the project
336
- */
337
- allTemplateCards(cardDetails?: FetchCardDetails): Promise<Card[]>;
269
+ showProjectCards(): Card[];
338
270
  /**
339
271
  * Returns cards from single template.
340
- * @param templateName Name of the template
341
- * @param cardDetails Card information
272
+ * @param templateName Name of the template (supports both full names like 'decision/templates/decision' and short names like 'decision')
342
273
  * @returns List of cards from template.
343
274
  */
344
- templateCards(templateName: string, cardDetails?: FetchCardDetails): Promise<Card[]>;
345
- /**
346
- * Array of templates in the project.
347
- * @param from Defines where resources are collected from.
348
- * @returns array of all templates in the project.
349
- */
350
- templates(from?: ResourcesFrom): Promise<Resource[]>;
275
+ templateCards(templateName: string): Card[];
351
276
  /**
352
- * Update card content.
353
- * @param cardKey card's ID that is updated.
277
+ * Update a card's content.
278
+ * @param cardKey card key to update.
354
279
  * @param content changed content
355
280
  */
356
281
  updateCardContent(cardKey: string, content: string): Promise<void>;
@@ -362,21 +287,15 @@ export declare class Project extends CardContainer {
362
287
  */
363
288
  updateCardMetadataKey(cardKey: string, changedKey: string, newValue: MetadataContent): Promise<void>;
364
289
  /**
365
- * Updates card metadata.
290
+ * Updates the entire card in the card cache and handles any path/parent changes.
291
+ * Also persists changes to content and metadata files.
292
+ * @param card The card with updated information (path, parent, metadata, etc.)
293
+ */
294
+ updateCard(card: Card): Promise<void>;
295
+ /**
296
+ * Updates a card's metadata.
366
297
  * @param card affected card
367
298
  * @param changedMetadata changed content for the card
368
299
  */
369
300
  updateCardMetadata(card: Card, changedMetadata: CardMetadata): Promise<void>;
370
- /**
371
- * Validates that card's data is valid.
372
- * @param card Card to validate.
373
- * @returns validation errors, if any
374
- */
375
- validateCard(card: Card): Promise<string>;
376
- /**
377
- * Array of workflows in the project.
378
- * @param from Defines where resources are collected from.
379
- * @returns array of all workflows in the project.
380
- */
381
- workflows(from?: ResourcesFrom): Promise<Resource[]>;
382
301
  }