@cyberismo/data-handler 0.0.15 → 0.0.17

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 (191) hide show
  1. package/dist/card-metadata-updater.js +7 -1
  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 +22 -8
  5. package/dist/command-handler.js.map +1 -1
  6. package/dist/command-manager.d.ts +24 -1
  7. package/dist/command-manager.js +31 -7
  8. package/dist/command-manager.js.map +1 -1
  9. package/dist/commands/create.d.ts +1 -1
  10. package/dist/commands/create.js +34 -36
  11. package/dist/commands/create.js.map +1 -1
  12. package/dist/commands/export.d.ts +11 -2
  13. package/dist/commands/export.js +54 -41
  14. package/dist/commands/export.js.map +1 -1
  15. package/dist/commands/fetch.d.ts +8 -0
  16. package/dist/commands/fetch.js +101 -23
  17. package/dist/commands/fetch.js.map +1 -1
  18. package/dist/commands/import.d.ts +14 -3
  19. package/dist/commands/import.js +27 -10
  20. package/dist/commands/import.js.map +1 -1
  21. package/dist/commands/move.js +0 -1
  22. package/dist/commands/move.js.map +1 -1
  23. package/dist/commands/remove.d.ts +11 -2
  24. package/dist/commands/remove.js +15 -5
  25. package/dist/commands/remove.js.map +1 -1
  26. package/dist/commands/rename.d.ts +4 -9
  27. package/dist/commands/rename.js +37 -101
  28. package/dist/commands/rename.js.map +1 -1
  29. package/dist/commands/show.d.ts +20 -12
  30. package/dist/commands/show.js +79 -57
  31. package/dist/commands/show.js.map +1 -1
  32. package/dist/commands/transition.d.ts +9 -2
  33. package/dist/commands/transition.js +25 -17
  34. package/dist/commands/transition.js.map +1 -1
  35. package/dist/commands/update.d.ts +16 -12
  36. package/dist/commands/update.js +19 -17
  37. package/dist/commands/update.js.map +1 -1
  38. package/dist/commands/validate.d.ts +17 -9
  39. package/dist/commands/validate.js +94 -35
  40. package/dist/commands/validate.js.map +1 -1
  41. package/dist/containers/card-container.d.ts +7 -5
  42. package/dist/containers/card-container.js +30 -5
  43. package/dist/containers/card-container.js.map +1 -1
  44. package/dist/containers/project/calculation-engine.d.ts +7 -4
  45. package/dist/containers/project/calculation-engine.js +61 -66
  46. package/dist/containers/project/calculation-engine.js.map +1 -1
  47. package/dist/containers/project/project-paths.d.ts +7 -4
  48. package/dist/containers/project/project-paths.js +22 -12
  49. package/dist/containers/project/project-paths.js.map +1 -1
  50. package/dist/containers/project/resource-cache.d.ts +169 -0
  51. package/dist/containers/project/resource-cache.js +509 -0
  52. package/dist/containers/project/resource-cache.js.map +1 -0
  53. package/dist/containers/project/resource-handler.d.ts +129 -0
  54. package/dist/containers/project/resource-handler.js +206 -0
  55. package/dist/containers/project/resource-handler.js.map +1 -0
  56. package/dist/containers/project.d.ts +46 -152
  57. package/dist/containers/project.js +179 -409
  58. package/dist/containers/project.js.map +1 -1
  59. package/dist/containers/template.d.ts +8 -2
  60. package/dist/containers/template.js +24 -19
  61. package/dist/containers/template.js.map +1 -1
  62. package/dist/interfaces/command-options.d.ts +3 -1
  63. package/dist/interfaces/folder-content-interfaces.d.ts +5 -3
  64. package/dist/interfaces/folder-content-interfaces.js +3 -3
  65. package/dist/interfaces/folder-content-interfaces.js.map +1 -1
  66. package/dist/interfaces/project-interfaces.d.ts +7 -9
  67. package/dist/interfaces/project-interfaces.js.map +1 -1
  68. package/dist/interfaces/resource-interfaces.d.ts +14 -1
  69. package/dist/interfaces/resource-interfaces.js.map +1 -1
  70. package/dist/macros/graph/index.js +12 -26
  71. package/dist/macros/graph/index.js.map +1 -1
  72. package/dist/macros/index.d.ts +1 -1
  73. package/dist/macros/index.js +2 -2
  74. package/dist/macros/index.js.map +1 -1
  75. package/dist/macros/report/index.js +3 -6
  76. package/dist/macros/report/index.js.map +1 -1
  77. package/dist/module-manager.d.ts +16 -3
  78. package/dist/module-manager.js +51 -19
  79. package/dist/module-manager.js.map +1 -1
  80. package/dist/project-settings.d.ts +21 -3
  81. package/dist/project-settings.js +91 -14
  82. package/dist/project-settings.js.map +1 -1
  83. package/dist/resources/calculation-resource.d.ts +4 -3
  84. package/dist/resources/calculation-resource.js +11 -5
  85. package/dist/resources/calculation-resource.js.map +1 -1
  86. package/dist/resources/card-type-resource.d.ts +6 -1
  87. package/dist/resources/card-type-resource.js +34 -23
  88. package/dist/resources/card-type-resource.js.map +1 -1
  89. package/dist/resources/create-defaults.d.ts +3 -2
  90. package/dist/resources/create-defaults.js +3 -2
  91. package/dist/resources/create-defaults.js.map +1 -1
  92. package/dist/resources/field-type-resource.d.ts +4 -1
  93. package/dist/resources/field-type-resource.js +22 -23
  94. package/dist/resources/field-type-resource.js.map +1 -1
  95. package/dist/resources/file-resource.d.ts +5 -9
  96. package/dist/resources/file-resource.js +6 -11
  97. package/dist/resources/file-resource.js.map +1 -1
  98. package/dist/resources/folder-resource.d.ts +29 -32
  99. package/dist/resources/folder-resource.js +59 -78
  100. package/dist/resources/folder-resource.js.map +1 -1
  101. package/dist/resources/graph-model-resource.d.ts +4 -1
  102. package/dist/resources/graph-model-resource.js +11 -4
  103. package/dist/resources/graph-model-resource.js.map +1 -1
  104. package/dist/resources/graph-view-resource.d.ts +5 -2
  105. package/dist/resources/graph-view-resource.js +7 -3
  106. package/dist/resources/graph-view-resource.js.map +1 -1
  107. package/dist/resources/link-type-resource.d.ts +5 -2
  108. package/dist/resources/link-type-resource.js +5 -2
  109. package/dist/resources/link-type-resource.js.map +1 -1
  110. package/dist/resources/report-resource.d.ts +6 -7
  111. package/dist/resources/report-resource.js +14 -23
  112. package/dist/resources/report-resource.js.map +1 -1
  113. package/dist/resources/resource-object.d.ts +94 -8
  114. package/dist/resources/resource-object.js +212 -109
  115. package/dist/resources/resource-object.js.map +1 -1
  116. package/dist/resources/template-resource.d.ts +7 -3
  117. package/dist/resources/template-resource.js +10 -3
  118. package/dist/resources/template-resource.js.map +1 -1
  119. package/dist/resources/workflow-resource.d.ts +5 -2
  120. package/dist/resources/workflow-resource.js +18 -22
  121. package/dist/resources/workflow-resource.js.map +1 -1
  122. package/dist/utils/card-utils.d.ts +2 -2
  123. package/dist/utils/card-utils.js +1 -1
  124. package/dist/utils/clingo-fact-builder.d.ts +25 -14
  125. package/dist/utils/clingo-fact-builder.js +27 -5
  126. package/dist/utils/clingo-fact-builder.js.map +1 -1
  127. package/dist/utils/clingo-facts.js +3 -4
  128. package/dist/utils/clingo-facts.js.map +1 -1
  129. package/dist/utils/configuration-logger.d.ts +91 -0
  130. package/dist/utils/configuration-logger.js +151 -0
  131. package/dist/utils/configuration-logger.js.map +1 -0
  132. package/dist/utils/constants.d.ts +1 -1
  133. package/dist/utils/constants.js +5 -3
  134. package/dist/utils/constants.js.map +1 -1
  135. package/dist/utils/resource-utils.d.ts +1 -0
  136. package/dist/utils/resource-utils.js +2 -1
  137. package/dist/utils/resource-utils.js.map +1 -1
  138. package/package.json +9 -9
  139. package/src/card-metadata-updater.ts +6 -2
  140. package/src/command-handler.ts +39 -12
  141. package/src/command-manager.ts +33 -21
  142. package/src/commands/create.ts +43 -78
  143. package/src/commands/export.ts +63 -52
  144. package/src/commands/fetch.ts +143 -34
  145. package/src/commands/import.ts +37 -15
  146. package/src/commands/move.ts +0 -1
  147. package/src/commands/remove.ts +20 -7
  148. package/src/commands/rename.ts +58 -149
  149. package/src/commands/show.ts +123 -80
  150. package/src/commands/transition.ts +26 -28
  151. package/src/commands/update.ts +25 -22
  152. package/src/commands/validate.ts +104 -67
  153. package/src/containers/card-container.ts +37 -5
  154. package/src/containers/project/calculation-engine.ts +61 -93
  155. package/src/containers/project/project-paths.ts +29 -13
  156. package/src/containers/project/resource-cache.ts +651 -0
  157. package/src/containers/project/resource-handler.ts +265 -0
  158. package/src/containers/project.ts +250 -527
  159. package/src/containers/template.ts +28 -23
  160. package/src/interfaces/command-options.ts +3 -1
  161. package/src/interfaces/folder-content-interfaces.ts +7 -6
  162. package/src/interfaces/project-interfaces.ts +12 -11
  163. package/src/interfaces/resource-interfaces.ts +18 -3
  164. package/src/macros/graph/index.ts +26 -47
  165. package/src/macros/index.ts +2 -2
  166. package/src/macros/report/index.ts +3 -9
  167. package/src/module-manager.ts +74 -17
  168. package/src/project-settings.ts +96 -14
  169. package/src/resources/calculation-resource.ts +18 -18
  170. package/src/resources/card-type-resource.ts +50 -50
  171. package/src/resources/create-defaults.ts +3 -2
  172. package/src/resources/field-type-resource.ts +41 -55
  173. package/src/resources/file-resource.ts +10 -36
  174. package/src/resources/folder-resource.ts +69 -120
  175. package/src/resources/graph-model-resource.ts +20 -22
  176. package/src/resources/graph-view-resource.ts +15 -17
  177. package/src/resources/link-type-resource.ts +10 -13
  178. package/src/resources/report-resource.ts +21 -43
  179. package/src/resources/resource-object.ts +263 -149
  180. package/src/resources/template-resource.ts +17 -16
  181. package/src/resources/workflow-resource.ts +25 -44
  182. package/src/utils/card-utils.ts +2 -2
  183. package/src/utils/clingo-fact-builder.ts +28 -16
  184. package/src/utils/clingo-facts.ts +3 -4
  185. package/src/utils/configuration-logger.ts +206 -0
  186. package/src/utils/constants.ts +5 -3
  187. package/src/utils/resource-utils.ts +2 -1
  188. package/dist/containers/project/resource-collector.d.ts +0 -110
  189. package/dist/containers/project/resource-collector.js +0 -344
  190. package/dist/containers/project/resource-collector.js.map +0 -1
  191. package/src/containers/project/resource-collector.ts +0 -404
@@ -0,0 +1,206 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU Affero General Public License version 3 as published by
7
+ the Free Software Foundation. This program is distributed in the hope that it
8
+ will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
+ See the GNU Affero General Public License for more details.
11
+ You should have received a copy of the GNU Affero General Public
12
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
13
+ */
14
+ import { ResourceCache, ResourcesFrom, } from './resource-cache.js';
15
+ import { resourceName } from '../../utils/resource-utils.js';
16
+ // Convert singular forms to plural. Uses real type, so cannot be general.
17
+ export const singularToPluralResourceType = {
18
+ template: 'templates',
19
+ workflow: 'workflows',
20
+ report: 'reports',
21
+ calculation: 'calculations',
22
+ cardType: 'cardTypes',
23
+ fieldType: 'fieldTypes',
24
+ graphModel: 'graphModels',
25
+ graphView: 'graphViews',
26
+ linkType: 'linkTypes',
27
+ };
28
+ /**
29
+ * ResourceHandler manages resource access for a project.
30
+ * It owns the ResourceCache and provides APIs for accessing resources.
31
+ */
32
+ export class ResourceHandler {
33
+ cache;
34
+ /**
35
+ * Creates instance of ResourceHandler.
36
+ * @param project Project to use in cache
37
+ */
38
+ constructor(project) {
39
+ this.cache = ResourceCache.create(project);
40
+ }
41
+ /**
42
+ * Add a resource to the cache.
43
+ * @param name Name of the resource to add
44
+ * @param instance Resource instance
45
+ */
46
+ add(name, instance) {
47
+ this.cache.addResource(name, instance);
48
+ }
49
+ /**
50
+ * Returns type of resource.
51
+ * @param nameOrResourceName Name of resource
52
+ * @param type Name of resource as string matching Resource map element.
53
+ * @template T Resource type as part of ResourceMap
54
+ * @returns resource with inferred actual type.
55
+ */
56
+ byType(nameOrResourceName, type) {
57
+ if (typeof nameOrResourceName === 'string') {
58
+ if (!type) {
59
+ throw new Error('Type parameter required when using string name');
60
+ }
61
+ return this.cache.resourceByType(nameOrResourceName, type);
62
+ }
63
+ else {
64
+ return this.cache.resourceByName(nameOrResourceName);
65
+ }
66
+ }
67
+ /**
68
+ * Get resource by ResourceName object.
69
+ * @param name Resource name
70
+ * @template T Resource type
71
+ * @returns Typed resource that matches the name
72
+ */
73
+ byName(name) {
74
+ return this.cache.resourceByName(name);
75
+ }
76
+ /**
77
+ * Refresh local resources in the cache.
78
+ */
79
+ changed() {
80
+ this.cache.changed();
81
+ }
82
+ /**
83
+ * Refresh module resources in the cache.
84
+ * @param moduleName Name of the module. If given, will only update this module's resources.
85
+ */
86
+ changedModules(moduleName) {
87
+ this.cache.changedModules(moduleName);
88
+ }
89
+ /**
90
+ * Check if a resource exists.
91
+ * @param name Resource name to check
92
+ * @returns true if resource exists, false otherwise
93
+ */
94
+ exists(name) {
95
+ return this.cache.has(name);
96
+ }
97
+ /**
98
+ * Get module names.
99
+ * @returns Array of module names
100
+ */
101
+ moduleNames() {
102
+ return this.cache.moduleNames();
103
+ }
104
+ /**
105
+ * Get certain types of resources from a specific module.
106
+ * @param type Type of resource to fetch
107
+ * @param moduleName Name of the module
108
+ * @returns Resource names from a specific module
109
+ */
110
+ moduleResourceNames(type, moduleName) {
111
+ return this.cache.moduleResourceNames(type, moduleName);
112
+ }
113
+ /**
114
+ * Remove a resource from cache.
115
+ * @param name Resource to remove
116
+ */
117
+ remove(name) {
118
+ this.cache.removeResource(name);
119
+ }
120
+ /**
121
+ * Removes all resources from a specific module.
122
+ * @param moduleName Name of the module
123
+ */
124
+ removeModule(moduleName) {
125
+ this.cache.removeModule(moduleName);
126
+ }
127
+ /**
128
+ * Change resource name in cache, but keep instance information.
129
+ * @param oldName Old name of the resource
130
+ * @param newName New name of the resource
131
+ */
132
+ rename(oldName, newName) {
133
+ this.cache.changeResourceName(oldName, newName);
134
+ }
135
+ /**
136
+ * Get resources of a specific type.
137
+ * @param type Type of resources to get
138
+ * @param from Where to return resources from (all, local, imported modules)
139
+ * @template T Resource type
140
+ * @returns Array of resources
141
+ */
142
+ resourceTypes(type, from = ResourcesFrom.all) {
143
+ return this.cache.resources(type, from);
144
+ }
145
+ // The following are just helpers to get specific resource types
146
+ calculations(from = ResourcesFrom.all) {
147
+ return this.cache.resources('calculations', from);
148
+ }
149
+ cardTypes(from = ResourcesFrom.all) {
150
+ return this.cache.resources('cardTypes', from);
151
+ }
152
+ fieldTypes(from = ResourcesFrom.all) {
153
+ return this.cache.resources('fieldTypes', from);
154
+ }
155
+ graphViews(from = ResourcesFrom.all) {
156
+ return this.cache.resources('graphViews', from);
157
+ }
158
+ graphModels(from = ResourcesFrom.all) {
159
+ return this.cache.resources('graphModels', from);
160
+ }
161
+ linkTypes(from = ResourcesFrom.all) {
162
+ return this.cache.resources('linkTypes', from);
163
+ }
164
+ reports(from = ResourcesFrom.all) {
165
+ return this.cache.resources('reports', from);
166
+ }
167
+ templates(from = ResourcesFrom.all) {
168
+ return this.cache.resources('templates', from);
169
+ }
170
+ workflows(from = ResourcesFrom.all) {
171
+ return this.cache.resources('workflows', from);
172
+ }
173
+ /**
174
+ * Extract resource type from a resource name string.
175
+ * @param name Resource name
176
+ * @returns Resource type
177
+ * @throws when resource type is invalid
178
+ */
179
+ extractType(name) {
180
+ const type = resourceName(name).type;
181
+ if (!type) {
182
+ throw new Error(`Invalid resource type: ${type}`);
183
+ }
184
+ return type;
185
+ }
186
+ /**
187
+ * Handle file system changes.
188
+ * @param fileName A changed file in the file system
189
+ */
190
+ handleFileSystemChange(fileName) {
191
+ this.cache.handleFileSystemChange(fileName);
192
+ }
193
+ /**
194
+ * Get plural resource type name from singular type name.
195
+ * @param singular Resource type as singular name
196
+ * @returns Resource type as plural name
197
+ */
198
+ resourceTypeFromSingularType(singular) {
199
+ const plural = singularToPluralResourceType[singular];
200
+ if (!plural) {
201
+ throw new Error(`Unknown singular resource type: ${singular}`);
202
+ }
203
+ return plural;
204
+ }
205
+ }
206
+ //# sourceMappingURL=resource-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-handler.js","sourceRoot":"","sources":["../../../src/containers/project/resource-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;EAYE;AAEF,OAAO,EACL,aAAa,EACb,aAAa,GAEd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAK7D,0EAA0E;AAC1E,MAAM,CAAC,MAAM,4BAA4B,GAAsC;IAC7E,QAAQ,EAAE,WAAW;IACrB,QAAQ,EAAE,WAAW;IACrB,MAAM,EAAE,SAAS;IACjB,WAAW,EAAE,cAAc;IAC3B,QAAQ,EAAE,WAAW;IACrB,SAAS,EAAE,YAAY;IACvB,UAAU,EAAE,aAA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,IAAI,KAAK,CAAC,mCAAmC,QAAQ,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -13,44 +13,44 @@
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 createdResources;
39
38
  private logger;
40
39
  private projectPaths;
41
- private resources;
40
+ private resourceHandler;
42
41
  private resourceWatcher;
43
42
  private settings;
44
43
  private validator;
45
- constructor(path: string, watchResourceChanges?: boolean | undefined);
44
+ private cachedAllModulePrefixes;
45
+ constructor(path: string, options?: ProjectOptions);
46
46
  private changeParent;
47
47
  private findModule;
48
48
  private handleAttachmentChange;
49
49
  private parentFromPath;
50
50
  private removeCachedChildren;
51
- private replaceCacheValue;
52
- private resourcesOfType;
53
51
  private updateCachedChildren;
52
+ private refreshAllModulePrefixes;
53
+ private validateCard;
54
54
  /**
55
55
  * Populate template cards into the card cache.
56
56
  */
@@ -59,12 +59,6 @@ export declare class Project extends CardContainer {
59
59
  * Populate both the project cards, and all template cards into card cache.
60
60
  */
61
61
  protected populateCardsCache(): Promise<void>;
62
- /**
63
- * Add a given 'resource' to the local resource arrays.
64
- * @param resource Resource to add.
65
- * @param data JSON data for the resource.
66
- */
67
- addResource(resource: Resource, data: JSON): void;
68
62
  /**
69
63
  * Returns all template cards from the project. This includes all module templates' cards.
70
64
  * @returns all the template cards from the project
@@ -82,17 +76,6 @@ export declare class Project extends CardContainer {
82
76
  * @returns Array of attachments from cards at the specified path
83
77
  */
84
78
  attachmentsByPath(path: string): CardAttachment[];
85
- /**
86
- * Returns all the attachments in the template cards.
87
- * @returns all the attachments in the template cards.
88
- */
89
- attachmentsFromTemplates(): Promise<CardAttachment[]>;
90
- /**
91
- * Returns an array of all the calculation files (*.lp) in the project.
92
- * @param from Defines where resources are collected from.
93
- * @returns array of all calculation files in the project.
94
- */
95
- calculations(from?: ResourcesFrom): Promise<Resource[]>;
96
79
  /**
97
80
  * Returns path to a card's attachment folder.
98
81
  * @param cardKey card key
@@ -107,13 +90,6 @@ export declare class Project extends CardContainer {
107
90
  * @throws If trying to add attachment to module card, or if attachment is not found
108
91
  */
109
92
  createCardAttachment(cardKey: string, attachmentName: string, attachmentData: string | Buffer): Promise<void>;
110
- /**
111
- * Removes an attachment from a card.
112
- * @param cardKey The card to remove attachment from
113
- * @param fileName The name of the attachment file to remove
114
- * @throws if trying to remove module card attachment, or the attachment was not found.
115
- */
116
- removeCardAttachment(cardKey: string, fileName: string): Promise<void>;
117
93
  /**
118
94
  * Returns path to a card's folder.
119
95
  * @param cardKey card key
@@ -126,12 +102,6 @@ export declare class Project extends CardContainer {
126
102
  * @returns Card data to the given card keys
127
103
  */
128
104
  cardKeysToCards(cardIds: string[]): Card[];
129
- /**
130
- * Accessor for cards cache.
131
- * Used by template container (it needs to access project's cache, not their own instance).
132
- * @note Should not be used directly (other than Template).
133
- */
134
- get cardsCache(): import("./project/card-cache.js").CardCache;
135
105
  /**
136
106
  * Returns an array of all the cards in the project.
137
107
  * @note These are project cards only, by default (unless path dictates otherwise).
@@ -141,25 +111,17 @@ export declare class Project extends CardContainer {
141
111
  */
142
112
  cards(path?: string, details?: FetchCardDetails): Card[];
143
113
  /**
144
- * Returns an array of all the card types in the project.
145
- * @param from Defines where resources are collected from.
146
- * @returns array of all card types in the project.
114
+ * Accessor for cards cache.
115
+ * Used by template container (it needs to access project's cache, not their own instance).
116
+ * @note Should not be used directly (other than Template).
147
117
  */
148
- cardTypes(from?: ResourcesFrom): Promise<Resource[]>;
118
+ get cardsCache(): import("./project/card-cache.js").CardCache;
149
119
  /**
150
120
  * Returns children of a given card; as Card array
151
121
  * @param card Parent card to fetch children from
152
122
  * @returns children of a given card; as Card array
153
123
  */
154
124
  childrenCards(card: Card): Card[];
155
- /**
156
- * Updates all local resources.
157
- */
158
- collectLocalResources(): void;
159
- /**
160
- * Updates all imported module resources.
161
- */
162
- collectModuleResources(): void;
163
125
  /**
164
126
  * Returns project configuration.
165
127
  * @returns project configuration.
@@ -175,18 +137,6 @@ export declare class Project extends CardContainer {
175
137
  * Cleanups project when it is being closed.
176
138
  */
177
139
  dispose(): void;
178
- /**
179
- * Returns an array of all the field types in the project.
180
- * @param from Defines where resources are collected from.
181
- * @returns array of all field types in the project.
182
- */
183
- fieldTypes(from?: ResourcesFrom): Promise<Resource[]>;
184
- /**
185
- * Finds root of a project
186
- * @param path Path where to start looking for the project root.
187
- * @returns path to a project root, or empty string.
188
- */
189
- static findProjectRoot(path: string): Promise<string>;
190
140
  /**
191
141
  * Returns specific card.
192
142
  * @param cardToFind Card key to find
@@ -195,17 +145,11 @@ export declare class Project extends CardContainer {
195
145
  */
196
146
  findCard(cardToFind: string, details?: ProjectFetchCardDetails): Card;
197
147
  /**
198
- * Returns an array of all the graph models in the project.
199
- * @param from Defines where resources are collected from.
200
- * @returns array of all the graph models in the project.
201
- */
202
- graphModels(from?: ResourcesFrom): Promise<Resource[]>;
203
- /**
204
- * Returns an array of all the graph views in the project.
205
- * @param from Defines where resources are collected from.
206
- * @returns array of all the graph views in the project.
148
+ * Finds root of a project
149
+ * @param path Path where to start looking for the project root.
150
+ * @returns path to a project root, or empty string.
207
151
  */
208
- graphViews(from?: ResourcesFrom): Promise<Resource[]>;
152
+ static findProjectRoot(path: string): Promise<string>;
209
153
  /**
210
154
  * When card changes.
211
155
  * @param changedCard Card that was changed.
@@ -231,20 +175,15 @@ export declare class Project extends CardContainer {
231
175
  /**
232
176
  * Adds a module from project.
233
177
  * @param module Module to add
178
+ * @param skipMigrationLog If true, skip logging to migration log. Used during project creation.
234
179
  */
235
- importModule(module: ModuleSetting): Promise<void>;
180
+ importModule(module: ModuleSetting, skipMigrationLog?: boolean): Promise<void>;
236
181
  /**
237
182
  * Checks if a given path is a project.
238
183
  * @param path Path to a project
239
184
  * @returns true, if in the given path there is a project; false otherwise
240
185
  */
241
186
  static isCreated(path: string): boolean;
242
- /**
243
- * Returns an array of all the link types in the project.
244
- * @param from Defines where resources are collected from.
245
- * @returns array of all link types in the project.
246
- */
247
- linkTypes(from?: ResourcesFrom): Promise<Resource[]>;
248
187
  /**
249
188
  * Returns an array of cards in the project, in the templates or both.
250
189
  * Cards don't have content and nor metadata.
@@ -265,11 +204,6 @@ export declare class Project extends CardContainer {
265
204
  * @returns module details, or undefined if module cannot be found.
266
205
  */
267
206
  module(moduleName: string): Promise<ModuleContent | undefined>;
268
- /**
269
- * Returns list of modules in the project.
270
- * @returns list of modules in the project.
271
- */
272
- modules(): Promise<Resource[]>;
273
207
  /**
274
208
  * Returns a new unique card key with project prefix (e.g. test_x649it4x).
275
209
  * Random part of string will be always 8 characters in base-36 (0-9a-z)
@@ -304,61 +238,34 @@ export declare class Project extends CardContainer {
304
238
  */
305
239
  get projectPrefix(): string;
306
240
  /**
307
- * Collects all prefixes used in the project (project's own plus all from modules).
241
+ * Returns all prefixes used in the project.
242
+ * This includes both direct dependencies and transient dependencies.
308
243
  * @returns all prefixes used in the project.
309
- * @todo - move the module prefix fetch to resource-collector.
310
- * Make it use cached value that is only changed when module is removed/imported.
311
- */
312
- projectPrefixes(): Promise<string[]>;
313
- /**
314
- * Removes a module from the project
315
- * @param module Module (name) to remove.
316
- */
317
- removeModule(moduleName: string): Promise<void>;
318
- /**
319
- * Removes a resource from Project.
320
- * @param resource Resource to remove.
321
244
  */
322
- removeResource(resource: Resource): void;
245
+ allModulePrefixes(): string[];
323
246
  /**
324
- * Array of reports in the project.
325
- * @param from Defines where resources are collected from.
326
- * @returns array of all reports in the project.
247
+ * Returns prefixes for direct module dependencies only (from cardsConfig.json).
248
+ * @returns prefixes for direct module dependencies.
327
249
  */
328
- reports(from?: ResourcesFrom): Promise<Resource[]>;
250
+ projectPrefixes(): string[];
329
251
  /**
330
- * Returns handlebar files from reports.
331
- * @param from Defines where report handlebar files are collected from.
332
- * @returns handlebar files from reports.
333
- */
334
- reportHandlerBarFiles(from?: ResourcesFrom): Promise<string[]>;
335
- /**
336
- * Returns metadata from a given resource
337
- * @param name Name of a resource
338
- * @returns Metadata from the resource.
339
- */
340
- resource<Type>(name: string): Type | undefined;
341
- /**
342
- * Returns resource cache.
252
+ * Removes an attachment from a card.
253
+ * @param cardKey The card to remove attachment from
254
+ * @param fileName The name of the attachment file to remove
255
+ * @throws if trying to remove module card attachment, or the attachment was not found.
343
256
  */
344
- get resourceCache(): Map<string, JSON>;
257
+ removeCardAttachment(cardKey: string, fileName: string): Promise<void>;
345
258
  /**
346
- * Checks if a given resource exists in the project already.
347
- * @param resourceType Type of resource as a string.
348
- * @param name Valid name of resource.
349
- * @returns boolean, true if resource exists; false otherwise.
259
+ * Removes a module from the project cache and configuration.
260
+ * @note that ModuleManager removes the actual files.
261
+ * @param moduleName Module name to remove.
350
262
  */
351
- resourceExists(resourceType: ResourceFolderType, name: string): Promise<boolean>;
263
+ removeModule(moduleName: string): Promise<void>;
352
264
  /**
353
- * Instantiates resource object from project with a resource name.
354
- * @note that this is memory based object only.
355
- * To manipulate the resource (create files, delete files etc), use the resource object's API.
356
- * @param project Project from which resources are created from.
357
- * @param name Resource name
358
- * @throws if called with unsupported resource type.
359
- * @returns Created resource.
265
+ * Accessor for resource handler.
266
+ * @returns Resource handler instance.
360
267
  */
361
- static resourceObject(project: Project, name: ResourceName): CalculationResource | CardTypeResource | FieldTypeResource | GraphModelResource | GraphViewResource | LinkTypeResource | ReportResource | TemplateResource | WorkflowResource;
268
+ get resources(): ResourceHandler;
362
269
  /**
363
270
  * Shows details of a project.
364
271
  * @returns details of a project.
@@ -375,12 +282,6 @@ export declare class Project extends CardContainer {
375
282
  * @returns List of cards from template.
376
283
  */
377
284
  templateCards(templateName: string): Card[];
378
- /**
379
- * Array of templates in the project.
380
- * @param from Defines where resources are collected from.
381
- * @returns array of all templates in the project.
382
- */
383
- templates(from?: ResourcesFrom): Promise<Resource[]>;
384
285
  /**
385
286
  * Update a card's content.
386
287
  * @param cardKey card key to update.
@@ -406,11 +307,4 @@ export declare class Project extends CardContainer {
406
307
  * @param changedMetadata changed content for the card
407
308
  */
408
309
  updateCardMetadata(card: Card, changedMetadata: CardMetadata): Promise<void>;
409
- private validateCard;
410
- /**
411
- * Array of workflows in the project.
412
- * @param from Defines where resources are collected from.
413
- * @returns array of all workflows in the project.
414
- */
415
- workflows(from?: ResourcesFrom): Promise<Resource[]>;
416
310
  }