@cyberismo/data-handler 0.0.14 → 0.0.15

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 (240) hide show
  1. package/dist/card-metadata-updater.js +1 -3
  2. package/dist/card-metadata-updater.js.map +1 -1
  3. package/dist/command-handler.js +10 -16
  4. package/dist/command-handler.js.map +1 -1
  5. package/dist/command-manager.d.ts +1 -1
  6. package/dist/command-manager.js +4 -3
  7. package/dist/command-manager.js.map +1 -1
  8. package/dist/commands/create.js +13 -59
  9. package/dist/commands/create.js.map +1 -1
  10. package/dist/commands/edit.d.ts +1 -15
  11. package/dist/commands/edit.js +15 -89
  12. package/dist/commands/edit.js.map +1 -1
  13. package/dist/commands/export.js +4 -17
  14. package/dist/commands/export.js.map +1 -1
  15. package/dist/commands/import.js +3 -5
  16. package/dist/commands/import.js.map +1 -1
  17. package/dist/commands/move.d.ts +1 -2
  18. package/dist/commands/move.js +108 -146
  19. package/dist/commands/move.js.map +1 -1
  20. package/dist/commands/remove.js +9 -44
  21. package/dist/commands/remove.js.map +1 -1
  22. package/dist/commands/rename.js +2 -7
  23. package/dist/commands/rename.js.map +1 -1
  24. package/dist/commands/show.d.ts +7 -25
  25. package/dist/commands/show.js +38 -102
  26. package/dist/commands/show.js.map +1 -1
  27. package/dist/commands/transition.js +27 -30
  28. package/dist/commands/transition.js.map +1 -1
  29. package/dist/commands/update.d.ts +5 -3
  30. package/dist/commands/update.js +19 -5
  31. package/dist/commands/update.js.map +1 -1
  32. package/dist/commands/validate.d.ts +3 -3
  33. package/dist/commands/validate.js +19 -26
  34. package/dist/commands/validate.js.map +1 -1
  35. package/dist/containers/card-container.d.ts +87 -24
  36. package/dist/containers/card-container.js +183 -279
  37. package/dist/containers/card-container.js.map +1 -1
  38. package/dist/containers/project/calculation-engine.d.ts +6 -0
  39. package/dist/containers/project/calculation-engine.js +19 -12
  40. package/dist/containers/project/calculation-engine.js.map +1 -1
  41. package/dist/containers/project/card-cache.d.ts +146 -0
  42. package/dist/containers/project/card-cache.js +411 -0
  43. package/dist/containers/project/card-cache.js.map +1 -0
  44. package/dist/containers/project/resource-collector.d.ts +24 -1
  45. package/dist/containers/project/resource-collector.js +8 -1
  46. package/dist/containers/project/resource-collector.js.map +1 -1
  47. package/dist/containers/project.d.ts +117 -83
  48. package/dist/containers/project.js +418 -252
  49. package/dist/containers/project.js.map +1 -1
  50. package/dist/containers/template.d.ts +15 -31
  51. package/dist/containers/template.js +97 -104
  52. package/dist/containers/template.js.map +1 -1
  53. package/dist/index.d.ts +1 -0
  54. package/dist/index.js +1 -0
  55. package/dist/index.js.map +1 -1
  56. package/dist/interfaces/folder-content-interfaces.d.ts +2 -1
  57. package/dist/interfaces/folder-content-interfaces.js.map +1 -1
  58. package/dist/interfaces/macros.d.ts +1 -0
  59. package/dist/interfaces/macros.js +1 -1
  60. package/dist/interfaces/macros.js.map +1 -1
  61. package/dist/interfaces/project-interfaces.d.ts +5 -1
  62. package/dist/interfaces/project-interfaces.js.map +1 -1
  63. package/dist/interfaces/resource-interfaces.d.ts +11 -21
  64. package/dist/interfaces/resource-interfaces.js +3 -0
  65. package/dist/interfaces/resource-interfaces.js.map +1 -1
  66. package/dist/macros/common.d.ts +10 -10
  67. package/dist/macros/createCards/index.d.ts +0 -13
  68. package/dist/macros/createCards/index.js.map +1 -1
  69. package/dist/macros/createCards/types.d.ts +44 -0
  70. package/dist/macros/createCards/types.js +15 -0
  71. package/dist/macros/createCards/types.js.map +1 -0
  72. package/dist/macros/graph/index.d.ts +2 -6
  73. package/dist/macros/graph/index.js +2 -2
  74. package/dist/macros/graph/index.js.map +1 -1
  75. package/dist/macros/graph/types.d.ts +23 -0
  76. package/dist/macros/graph/types.js +15 -0
  77. package/dist/macros/graph/types.js.map +1 -0
  78. package/dist/macros/image/index.d.ts +8 -16
  79. package/dist/macros/image/index.js +36 -33
  80. package/dist/macros/image/index.js.map +1 -1
  81. package/dist/macros/image/types.d.ts +38 -0
  82. package/dist/macros/image/types.js +15 -0
  83. package/dist/macros/image/types.js.map +1 -0
  84. package/dist/macros/include/index.d.ts +1 -6
  85. package/dist/macros/include/index.js +4 -7
  86. package/dist/macros/include/index.js.map +1 -1
  87. package/dist/macros/include/types.d.ts +31 -0
  88. package/dist/macros/include/types.js +15 -0
  89. package/dist/macros/include/types.js.map +1 -0
  90. package/dist/macros/percentage/index.d.ts +0 -6
  91. package/dist/macros/percentage/index.js.map +1 -1
  92. package/dist/macros/percentage/types.d.ts +31 -0
  93. package/dist/macros/percentage/types.js +15 -0
  94. package/dist/macros/percentage/types.js.map +1 -0
  95. package/dist/macros/report/index.d.ts +0 -3
  96. package/dist/macros/report/index.js.map +1 -1
  97. package/dist/macros/report/types.d.ts +19 -0
  98. package/dist/macros/report/types.js +15 -0
  99. package/dist/macros/report/types.js.map +1 -0
  100. package/dist/macros/scoreCard/index.d.ts +0 -6
  101. package/dist/macros/scoreCard/index.js.map +1 -1
  102. package/dist/macros/scoreCard/types.d.ts +31 -0
  103. package/dist/macros/scoreCard/types.js +15 -0
  104. package/dist/macros/scoreCard/types.js.map +1 -0
  105. package/dist/macros/types.d.ts +25 -0
  106. package/dist/macros/types.js +2 -0
  107. package/dist/macros/types.js.map +1 -0
  108. package/dist/macros/vega/index.d.ts +0 -4
  109. package/dist/macros/vega/index.js.map +1 -1
  110. package/dist/macros/vega/types.d.ts +20 -0
  111. package/dist/macros/vega/types.js +2 -0
  112. package/dist/macros/vega/types.js.map +1 -0
  113. package/dist/macros/vegalite/index.d.ts +0 -4
  114. package/dist/macros/vegalite/index.js.map +1 -1
  115. package/dist/macros/vegalite/types.d.ts +20 -0
  116. package/dist/macros/vegalite/types.js +15 -0
  117. package/dist/macros/vegalite/types.js.map +1 -0
  118. package/dist/macros/xref/index.d.ts +0 -3
  119. package/dist/macros/xref/index.js +5 -14
  120. package/dist/macros/xref/index.js.map +1 -1
  121. package/dist/macros/xref/types.d.ts +19 -0
  122. package/dist/macros/xref/types.js +15 -0
  123. package/dist/macros/xref/types.js.map +1 -0
  124. package/dist/module-manager.js +4 -4
  125. package/dist/module-manager.js.map +1 -1
  126. package/dist/project-settings.js.map +1 -1
  127. package/dist/resources/calculation-resource.d.ts +4 -32
  128. package/dist/resources/calculation-resource.js +0 -55
  129. package/dist/resources/calculation-resource.js.map +1 -1
  130. package/dist/resources/card-type-resource.d.ts +4 -21
  131. package/dist/resources/card-type-resource.js +13 -44
  132. package/dist/resources/card-type-resource.js.map +1 -1
  133. package/dist/resources/field-type-resource.d.ts +4 -21
  134. package/dist/resources/field-type-resource.js +14 -38
  135. package/dist/resources/field-type-resource.js.map +1 -1
  136. package/dist/resources/file-resource.d.ts +12 -29
  137. package/dist/resources/file-resource.js +19 -293
  138. package/dist/resources/file-resource.js.map +1 -1
  139. package/dist/resources/folder-resource.d.ts +31 -50
  140. package/dist/resources/folder-resource.js +68 -96
  141. package/dist/resources/folder-resource.js.map +1 -1
  142. package/dist/resources/graph-model-resource.d.ts +5 -33
  143. package/dist/resources/graph-model-resource.js +8 -61
  144. package/dist/resources/graph-model-resource.js.map +1 -1
  145. package/dist/resources/graph-view-resource.d.ts +5 -28
  146. package/dist/resources/graph-view-resource.js +6 -45
  147. package/dist/resources/graph-view-resource.js.map +1 -1
  148. package/dist/resources/link-type-resource.d.ts +4 -21
  149. package/dist/resources/link-type-resource.js +6 -31
  150. package/dist/resources/link-type-resource.js.map +1 -1
  151. package/dist/resources/report-resource.d.ts +5 -17
  152. package/dist/resources/report-resource.js +6 -44
  153. package/dist/resources/report-resource.js.map +1 -1
  154. package/dist/resources/resource-object.d.ts +58 -23
  155. package/dist/resources/resource-object.js +293 -24
  156. package/dist/resources/resource-object.js.map +1 -1
  157. package/dist/resources/template-resource.d.ts +4 -15
  158. package/dist/resources/template-resource.js +10 -25
  159. package/dist/resources/template-resource.js.map +1 -1
  160. package/dist/resources/workflow-resource.d.ts +4 -23
  161. package/dist/resources/workflow-resource.js +12 -38
  162. package/dist/resources/workflow-resource.js.map +1 -1
  163. package/dist/utils/card-utils.d.ts +69 -19
  164. package/dist/utils/card-utils.js +179 -30
  165. package/dist/utils/card-utils.js.map +1 -1
  166. package/dist/utils/clingo-facts.js +11 -3
  167. package/dist/utils/clingo-facts.js.map +1 -1
  168. package/dist/utils/clingo-parser.js +1 -1
  169. package/dist/utils/clingo-parser.js.map +1 -1
  170. package/dist/utils/constants.d.ts +2 -0
  171. package/dist/utils/constants.js +4 -0
  172. package/dist/utils/constants.js.map +1 -1
  173. package/dist/utils/csv.js +1 -1
  174. package/dist/utils/csv.js.map +1 -1
  175. package/package.json +5 -5
  176. package/src/card-metadata-updater.ts +3 -5
  177. package/src/command-handler.ts +11 -18
  178. package/src/command-manager.ts +4 -3
  179. package/src/commands/create.ts +17 -83
  180. package/src/commands/edit.ts +16 -132
  181. package/src/commands/export.ts +8 -29
  182. package/src/commands/import.ts +4 -6
  183. package/src/commands/move.ts +144 -179
  184. package/src/commands/remove.ts +9 -52
  185. package/src/commands/rename.ts +2 -7
  186. package/src/commands/show.ts +50 -143
  187. package/src/commands/transition.ts +30 -33
  188. package/src/commands/update.ts +27 -9
  189. package/src/commands/validate.ts +21 -36
  190. package/src/containers/card-container.ts +200 -360
  191. package/src/containers/project/calculation-engine.ts +21 -13
  192. package/src/containers/project/card-cache.ts +497 -0
  193. package/src/containers/project/resource-collector.ts +9 -1
  194. package/src/containers/project.ts +529 -327
  195. package/src/containers/template.ts +109 -127
  196. package/src/index.ts +1 -0
  197. package/src/interfaces/folder-content-interfaces.ts +7 -1
  198. package/src/interfaces/macros.ts +2 -0
  199. package/src/interfaces/project-interfaces.ts +7 -1
  200. package/src/interfaces/resource-interfaces.ts +12 -24
  201. package/src/macros/createCards/index.ts +1 -12
  202. package/src/macros/createCards/types.ts +46 -0
  203. package/src/macros/graph/index.ts +3 -7
  204. package/src/macros/graph/types.ts +24 -0
  205. package/src/macros/image/index.ts +50 -61
  206. package/src/macros/image/types.ts +39 -0
  207. package/src/macros/include/index.ts +6 -15
  208. package/src/macros/include/types.ts +32 -0
  209. package/src/macros/percentage/index.ts +1 -7
  210. package/src/macros/percentage/types.ts +32 -0
  211. package/src/macros/report/index.ts +1 -4
  212. package/src/macros/report/types.ts +20 -0
  213. package/src/macros/scoreCard/index.ts +1 -7
  214. package/src/macros/scoreCard/types.ts +32 -0
  215. package/src/macros/types.ts +48 -0
  216. package/src/macros/vega/index.ts +1 -4
  217. package/src/macros/vega/types.ts +21 -0
  218. package/src/macros/vegalite/index.ts +1 -4
  219. package/src/macros/vegalite/types.ts +22 -0
  220. package/src/macros/xref/index.ts +6 -20
  221. package/src/macros/xref/types.ts +20 -0
  222. package/src/module-manager.ts +5 -5
  223. package/src/project-settings.ts +1 -1
  224. package/src/resources/calculation-resource.ts +6 -76
  225. package/src/resources/card-type-resource.ts +24 -59
  226. package/src/resources/field-type-resource.ts +22 -51
  227. package/src/resources/file-resource.ts +27 -409
  228. package/src/resources/folder-resource.ts +98 -124
  229. package/src/resources/graph-model-resource.ts +17 -74
  230. package/src/resources/graph-view-resource.ts +14 -54
  231. package/src/resources/link-type-resource.ts +13 -40
  232. package/src/resources/report-resource.ts +17 -57
  233. package/src/resources/resource-object.ts +435 -32
  234. package/src/resources/template-resource.ts +16 -29
  235. package/src/resources/workflow-resource.ts +26 -50
  236. package/src/utils/card-utils.ts +217 -31
  237. package/src/utils/clingo-facts.ts +13 -3
  238. package/src/utils/clingo-parser.ts +1 -1
  239. package/src/utils/constants.ts +6 -0
  240. package/src/utils/csv.ts +1 -1
@@ -17,19 +17,10 @@ import { homedir } from 'node:os';
17
17
  import { spawnSync } from 'node:child_process';
18
18
 
19
19
  import { ActionGuard } from '../permissions/action-guard.js';
20
- import { CalculationResource } from '../resources/calculation-resource.js';
21
- import { FolderResource } from '../resources/folder-resource.js';
22
20
  import { Project } from '../containers/project.js';
23
- import { propertyName } from '../interfaces/folder-content-interfaces.js';
24
- import { resourceNameToString } from '../utils/resource-utils.js';
25
21
  import { UserPreferences } from '../utils/user-preferences.js';
26
22
 
27
- import type { ContentPropertyName } from '../interfaces/folder-content-interfaces.js';
28
- import type {
29
- MetadataContent,
30
- ResourceFolderType,
31
- } from '../interfaces/project-interfaces.js';
32
- import type { ResourceName } from '../utils/resource-utils.js';
23
+ import type { MetadataContent } from '../interfaces/project-interfaces.js';
33
24
 
34
25
  export class Edit {
35
26
  private project: Project;
@@ -38,60 +29,12 @@ export class Edit {
38
29
  this.project = project;
39
30
  }
40
31
 
41
- /**
42
- * Updates a calculation file.
43
- * @param resourceName The name of the resource to update.
44
- * @param changedContent The new content for the calculation.
45
- */
46
- public async editCalculation(
47
- resourceName: ResourceName,
48
- changedContent: string,
49
- ) {
50
- if (resourceName.prefix !== this.project.projectPrefix) {
51
- throw new Error(
52
- `Resource '${resourceName.identifier}' is not a local resource`,
53
- );
54
- }
55
- const resourceNameString = resourceNameToString(resourceName);
56
- if (
57
- !(await this.project.resourceExists(
58
- resourceName.type as ResourceFolderType,
59
- resourceNameString,
60
- ))
61
- ) {
62
- throw new Error(
63
- `Resource '${resourceNameString}' does not exist in the project`,
64
- );
65
- }
66
- const calculationResource = new CalculationResource(
67
- this.project,
68
- resourceName,
69
- );
70
- const contentUpdateKey = {
71
- key: 'content',
72
- subKey: 'calculation',
73
- };
74
- await calculationResource.update(
75
- // TODO: Let's fix this while we get rid of updating filenames directly a bit later.
76
- contentUpdateKey as unknown as ContentPropertyName,
77
- {
78
- name: 'change',
79
- target: resourceNameString,
80
- to: changedContent,
81
- },
82
- );
83
- }
84
-
85
32
  /**
86
33
  * Opens the content and metadata files for a card in the code editor
87
34
  * @param cardKey - The key of the card to open. Required.
88
35
  */
89
- public async editCard(cardKey: string) {
90
- // Determine the card path
91
- const cardPath = this.project.pathToCard(cardKey);
92
- if (!cardPath) {
93
- throw new Error(`Card '${cardKey}' does not exist in the project`);
94
- }
36
+ public editCard(cardKey: string) {
37
+ const card = this.project.findCard(cardKey);
95
38
 
96
39
  // Read the user preferences
97
40
  const prefs = new UserPreferences(
@@ -99,9 +42,8 @@ export class Edit {
99
42
  ).getPreferences();
100
43
 
101
44
  // Construct paths for the card components (json and adoc)
102
- const cardDirPath = join(this.project.paths.cardRootFolder, cardPath);
103
- const cardContentPath = join(cardDirPath, Project.cardContentFile);
104
- const cardJsonPath = join(cardDirPath, Project.cardMetadataFile);
45
+ const cardContentPath = join(card.path, Project.cardContentFile);
46
+ const cardJsonPath = join(card.path, Project.cardMetadataFile);
105
47
 
106
48
  // Extract the editor settings from the preferences.
107
49
  const editorPrefs = prefs.editCommand[process.platform];
@@ -112,7 +54,7 @@ export class Edit {
112
54
  const editorArgs = editorArgPrefs.map((arg) => {
113
55
  arg = arg.replace(/\{\{\s*cardContentPath\s*\}\}/, cardContentPath);
114
56
  arg = arg.replace(/\{\{\s*cardJsonPath\s*\}\}/, cardJsonPath);
115
- arg = arg.replace(/\{\{\s*cardDirPath\s*\}\}/, cardDirPath);
57
+ arg = arg.replace(/\{\{\s*cardDirPath\s*\}\}/, card.path);
116
58
 
117
59
  return arg;
118
60
  });
@@ -135,19 +77,14 @@ export class Edit {
135
77
  * @param changedContent New content for the card.
136
78
  */
137
79
  public async editCardContent(cardKey: string, changedContent: string) {
138
- const isTemplateCard = await this.project.isTemplateCard(cardKey);
139
- if (isTemplateCard) {
80
+ if (this.project.hasTemplateCard(cardKey)) {
140
81
  return this.project.updateCardContent(cardKey, changedContent);
141
82
  }
142
- const cardPath = this.project.pathToCard(cardKey);
143
- if (!cardPath) {
144
- throw new Error(`Card '${cardKey}' does not exist in the project`);
83
+ if (this.project.findCard(cardKey)) {
84
+ const actionGuard = new ActionGuard(this.project.calculationEngine);
85
+ await actionGuard.checkPermission('editContent', cardKey);
86
+ await this.project.updateCardContent(cardKey, changedContent);
145
87
  }
146
-
147
- const actionGuard = new ActionGuard(this.project.calculationEngine);
148
- await actionGuard.checkPermission('editContent', cardKey);
149
-
150
- await this.project.updateCardContent(cardKey, changedContent);
151
88
  }
152
89
 
153
90
  /**
@@ -164,68 +101,15 @@ export class Edit {
164
101
  if (!changedKey) {
165
102
  throw new Error(`Changed key cannot be empty`);
166
103
  }
167
- const isTemplateCard = await this.project.isTemplateCard(cardKey);
168
- if (isTemplateCard) {
104
+ if (this.project.hasTemplateCard(cardKey)) {
169
105
  return this.project.updateCardMetadataKey(cardKey, changedKey, newValue);
170
106
  }
171
107
 
172
- // Determine the card path
173
- const cardPath = this.project.pathToCard(cardKey);
174
- if (!cardPath) {
175
- throw new Error(`Card '${cardKey}' does not exist in the project`);
176
- }
177
-
178
108
  // check for editing rights
179
- const actionGuard = new ActionGuard(this.project.calculationEngine);
180
- await actionGuard.checkPermission('editField', cardKey, changedKey);
181
- await this.project.updateCardMetadataKey(cardKey, changedKey, newValue);
182
- }
183
-
184
- /**
185
- * Update a file of a folder resource. Cannot be used to create a new file.
186
- * @param resourceName The name of the resource to update.
187
- * @param fileName The name of the file to update.
188
- * @param changedContent The new content for the file.
189
- */
190
- public async editResourceContent(
191
- resourceName: ResourceName,
192
- fileName: string,
193
- changedContent: string,
194
- ) {
195
- const resourceNameString = resourceNameToString(resourceName);
196
- if (
197
- !(await this.project.resourceExists(
198
- resourceName.type as ResourceFolderType,
199
- resourceNameString,
200
- ))
201
- ) {
202
- throw new Error(
203
- `Resource '${resourceNameString}' does not exist in the project`,
204
- );
109
+ if (this.project.findCard(cardKey)) {
110
+ const actionGuard = new ActionGuard(this.project.calculationEngine);
111
+ await actionGuard.checkPermission('editField', cardKey, changedKey);
112
+ await this.project.updateCardMetadataKey(cardKey, changedKey, newValue);
205
113
  }
206
- const resource = Project.resourceObject(this.project, resourceName);
207
- if (!(resource instanceof FolderResource)) {
208
- throw new Error(
209
- `Resource '${resourceNameString}' is not a folder resource`,
210
- );
211
- }
212
-
213
- // TODO: The caller should not pass filename, but content type
214
- // Once that is in place, this check can be removed
215
- const propName: ContentPropertyName | undefined = propertyName(fileName);
216
- if (!propName) {
217
- throw new Error(`File '${fileName}' is not allowed`);
218
- }
219
-
220
- const contentUpdateKey = {
221
- key: 'content',
222
- subKey: propName,
223
- };
224
- // TODO: Let's fix this while we get rid of updating filenames directly a bit later.
225
- return resource.update(contentUpdateKey as unknown as ContentPropertyName, {
226
- name: 'change',
227
- target: '',
228
- to: changedContent,
229
- });
230
114
  }
231
115
  }
@@ -23,10 +23,7 @@ import {
23
23
  import { dirname, join } from 'node:path';
24
24
  import { spawn } from 'node:child_process';
25
25
 
26
- import type {
27
- Card,
28
- FetchCardDetails,
29
- } from '../interfaces/project-interfaces.js';
26
+ import type { Card } from '../interfaces/project-interfaces.js';
30
27
  import type { CardType } from '../interfaces/resource-interfaces.js';
31
28
  import { evaluateMacros } from '../macros/index.js';
32
29
  import type { ExportPdfOptions } from '../interfaces/project-interfaces.js';
@@ -144,7 +141,10 @@ export class Export {
144
141
  }
145
142
 
146
143
  if (card.children) {
147
- await this.toAdocFileAsContent(path, card.children);
144
+ await this.toAdocFileAsContent(
145
+ path,
146
+ this.project.cardKeysToCards(card.children),
147
+ );
148
148
  }
149
149
  }
150
150
  }
@@ -187,22 +187,7 @@ export class Export {
187
187
  children: [],
188
188
  attachments: [],
189
189
  };
190
-
191
- // Get content and attachments separately, not included in queries
192
- const fetchCardDetails: FetchCardDetails = {
193
- attachments: true,
194
- children: false,
195
- content: true,
196
- contentType: 'adoc',
197
- metadata: true,
198
- parent: false,
199
- };
200
-
201
- const cardDetailsResponse = await this.showCmd.showCardDetails(
202
- fetchCardDetails,
203
- card.key,
204
- );
205
-
190
+ const cardDetailsResponse = this.showCmd.showCardDetails(card.key, 'adoc');
206
191
  let asciiDocContent = '';
207
192
  const project = this.project;
208
193
  try {
@@ -227,7 +212,7 @@ export class Export {
227
212
  card.attachments = cardDetailsResponse.attachments;
228
213
 
229
214
  for (const result of treeQueryResult.children ?? []) {
230
- card.children!.push(await this.treeQueryResultToCard(result));
215
+ card.children!.push((await this.treeQueryResultToCard(result)).key);
231
216
  }
232
217
 
233
218
  return card;
@@ -332,13 +317,7 @@ export class Export {
332
317
  let cards: Card[] = [];
333
318
 
334
319
  // If doing a partial tree export, put the parent information as it would have already been gathered.
335
- if (cardKey) {
336
- const card = await this.project.findSpecificCard(cardKey);
337
- if (!card) {
338
- throw new Error(
339
- `Input validation error: cannot find card '${cardKey}'`,
340
- );
341
- }
320
+ if (cardKey && this.project.findCard(cardKey)) {
342
321
  cards.push({
343
322
  key: cardKey,
344
323
  path: sourcePath,
@@ -62,7 +62,7 @@ export class Import {
62
62
  throw new Error(`Template '${template}' not found`);
63
63
  }
64
64
 
65
- const templateCards = await templateObject.cards();
65
+ const templateCards = templateObject.cards();
66
66
  if (templateCards.length !== 1) {
67
67
  console.warn(
68
68
  `Template '${template}' for card '${title}' does not have exactly one card. Skipping row.`,
@@ -77,11 +77,9 @@ export class Import {
77
77
  throw new Error('Card not created');
78
78
  }
79
79
  const cardKey = cards[0].key;
80
- const card = await this.project.findSpecificCard(cardKey, {
81
- metadata: true,
82
- });
83
- const cardType = await this.project.resource<CardType>(
84
- card?.metadata?.cardType || '',
80
+ const card = this.project.findCard(cardKey);
81
+ const cardType = this.project.resource<CardType>(
82
+ card.metadata?.cardType || '',
85
83
  );
86
84
 
87
85
  if (!cardType) {