@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.
- package/dist/card-metadata-updater.js +1 -3
- package/dist/card-metadata-updater.js.map +1 -1
- package/dist/command-handler.js +10 -16
- package/dist/command-handler.js.map +1 -1
- package/dist/command-manager.d.ts +1 -1
- package/dist/command-manager.js +4 -3
- package/dist/command-manager.js.map +1 -1
- package/dist/commands/create.js +13 -59
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/edit.d.ts +1 -15
- package/dist/commands/edit.js +15 -89
- package/dist/commands/edit.js.map +1 -1
- package/dist/commands/export.js +4 -17
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/import.js +3 -5
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/move.d.ts +1 -2
- package/dist/commands/move.js +108 -146
- package/dist/commands/move.js.map +1 -1
- package/dist/commands/remove.js +9 -44
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/rename.js +2 -7
- package/dist/commands/rename.js.map +1 -1
- package/dist/commands/show.d.ts +7 -25
- package/dist/commands/show.js +38 -102
- package/dist/commands/show.js.map +1 -1
- package/dist/commands/transition.js +27 -30
- package/dist/commands/transition.js.map +1 -1
- package/dist/commands/update.d.ts +5 -3
- package/dist/commands/update.js +19 -5
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/validate.d.ts +3 -3
- package/dist/commands/validate.js +19 -26
- package/dist/commands/validate.js.map +1 -1
- package/dist/containers/card-container.d.ts +87 -24
- package/dist/containers/card-container.js +183 -279
- package/dist/containers/card-container.js.map +1 -1
- package/dist/containers/project/calculation-engine.d.ts +6 -0
- package/dist/containers/project/calculation-engine.js +19 -12
- package/dist/containers/project/calculation-engine.js.map +1 -1
- package/dist/containers/project/card-cache.d.ts +146 -0
- package/dist/containers/project/card-cache.js +411 -0
- package/dist/containers/project/card-cache.js.map +1 -0
- package/dist/containers/project/resource-collector.d.ts +24 -1
- package/dist/containers/project/resource-collector.js +8 -1
- package/dist/containers/project/resource-collector.js.map +1 -1
- package/dist/containers/project.d.ts +117 -83
- package/dist/containers/project.js +418 -252
- package/dist/containers/project.js.map +1 -1
- package/dist/containers/template.d.ts +15 -31
- package/dist/containers/template.js +97 -104
- package/dist/containers/template.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/folder-content-interfaces.d.ts +2 -1
- package/dist/interfaces/folder-content-interfaces.js.map +1 -1
- package/dist/interfaces/macros.d.ts +1 -0
- package/dist/interfaces/macros.js +1 -1
- package/dist/interfaces/macros.js.map +1 -1
- package/dist/interfaces/project-interfaces.d.ts +5 -1
- package/dist/interfaces/project-interfaces.js.map +1 -1
- package/dist/interfaces/resource-interfaces.d.ts +11 -21
- package/dist/interfaces/resource-interfaces.js +3 -0
- package/dist/interfaces/resource-interfaces.js.map +1 -1
- package/dist/macros/common.d.ts +10 -10
- package/dist/macros/createCards/index.d.ts +0 -13
- package/dist/macros/createCards/index.js.map +1 -1
- package/dist/macros/createCards/types.d.ts +44 -0
- package/dist/macros/createCards/types.js +15 -0
- package/dist/macros/createCards/types.js.map +1 -0
- package/dist/macros/graph/index.d.ts +2 -6
- package/dist/macros/graph/index.js +2 -2
- package/dist/macros/graph/index.js.map +1 -1
- package/dist/macros/graph/types.d.ts +23 -0
- package/dist/macros/graph/types.js +15 -0
- package/dist/macros/graph/types.js.map +1 -0
- package/dist/macros/image/index.d.ts +8 -16
- package/dist/macros/image/index.js +36 -33
- package/dist/macros/image/index.js.map +1 -1
- package/dist/macros/image/types.d.ts +38 -0
- package/dist/macros/image/types.js +15 -0
- package/dist/macros/image/types.js.map +1 -0
- package/dist/macros/include/index.d.ts +1 -6
- package/dist/macros/include/index.js +4 -7
- package/dist/macros/include/index.js.map +1 -1
- package/dist/macros/include/types.d.ts +31 -0
- package/dist/macros/include/types.js +15 -0
- package/dist/macros/include/types.js.map +1 -0
- package/dist/macros/percentage/index.d.ts +0 -6
- package/dist/macros/percentage/index.js.map +1 -1
- package/dist/macros/percentage/types.d.ts +31 -0
- package/dist/macros/percentage/types.js +15 -0
- package/dist/macros/percentage/types.js.map +1 -0
- package/dist/macros/report/index.d.ts +0 -3
- package/dist/macros/report/index.js.map +1 -1
- package/dist/macros/report/types.d.ts +19 -0
- package/dist/macros/report/types.js +15 -0
- package/dist/macros/report/types.js.map +1 -0
- package/dist/macros/scoreCard/index.d.ts +0 -6
- package/dist/macros/scoreCard/index.js.map +1 -1
- package/dist/macros/scoreCard/types.d.ts +31 -0
- package/dist/macros/scoreCard/types.js +15 -0
- package/dist/macros/scoreCard/types.js.map +1 -0
- package/dist/macros/types.d.ts +25 -0
- package/dist/macros/types.js +2 -0
- package/dist/macros/types.js.map +1 -0
- package/dist/macros/vega/index.d.ts +0 -4
- package/dist/macros/vega/index.js.map +1 -1
- package/dist/macros/vega/types.d.ts +20 -0
- package/dist/macros/vega/types.js +2 -0
- package/dist/macros/vega/types.js.map +1 -0
- package/dist/macros/vegalite/index.d.ts +0 -4
- package/dist/macros/vegalite/index.js.map +1 -1
- package/dist/macros/vegalite/types.d.ts +20 -0
- package/dist/macros/vegalite/types.js +15 -0
- package/dist/macros/vegalite/types.js.map +1 -0
- package/dist/macros/xref/index.d.ts +0 -3
- package/dist/macros/xref/index.js +5 -14
- package/dist/macros/xref/index.js.map +1 -1
- package/dist/macros/xref/types.d.ts +19 -0
- package/dist/macros/xref/types.js +15 -0
- package/dist/macros/xref/types.js.map +1 -0
- package/dist/module-manager.js +4 -4
- package/dist/module-manager.js.map +1 -1
- package/dist/project-settings.js.map +1 -1
- package/dist/resources/calculation-resource.d.ts +4 -32
- package/dist/resources/calculation-resource.js +0 -55
- package/dist/resources/calculation-resource.js.map +1 -1
- package/dist/resources/card-type-resource.d.ts +4 -21
- package/dist/resources/card-type-resource.js +13 -44
- package/dist/resources/card-type-resource.js.map +1 -1
- package/dist/resources/field-type-resource.d.ts +4 -21
- package/dist/resources/field-type-resource.js +14 -38
- package/dist/resources/field-type-resource.js.map +1 -1
- package/dist/resources/file-resource.d.ts +12 -29
- package/dist/resources/file-resource.js +19 -293
- package/dist/resources/file-resource.js.map +1 -1
- package/dist/resources/folder-resource.d.ts +31 -50
- package/dist/resources/folder-resource.js +68 -96
- package/dist/resources/folder-resource.js.map +1 -1
- package/dist/resources/graph-model-resource.d.ts +5 -33
- package/dist/resources/graph-model-resource.js +8 -61
- package/dist/resources/graph-model-resource.js.map +1 -1
- package/dist/resources/graph-view-resource.d.ts +5 -28
- package/dist/resources/graph-view-resource.js +6 -45
- package/dist/resources/graph-view-resource.js.map +1 -1
- package/dist/resources/link-type-resource.d.ts +4 -21
- package/dist/resources/link-type-resource.js +6 -31
- package/dist/resources/link-type-resource.js.map +1 -1
- package/dist/resources/report-resource.d.ts +5 -17
- package/dist/resources/report-resource.js +6 -44
- package/dist/resources/report-resource.js.map +1 -1
- package/dist/resources/resource-object.d.ts +58 -23
- package/dist/resources/resource-object.js +293 -24
- package/dist/resources/resource-object.js.map +1 -1
- package/dist/resources/template-resource.d.ts +4 -15
- package/dist/resources/template-resource.js +10 -25
- package/dist/resources/template-resource.js.map +1 -1
- package/dist/resources/workflow-resource.d.ts +4 -23
- package/dist/resources/workflow-resource.js +12 -38
- package/dist/resources/workflow-resource.js.map +1 -1
- package/dist/utils/card-utils.d.ts +69 -19
- package/dist/utils/card-utils.js +179 -30
- package/dist/utils/card-utils.js.map +1 -1
- package/dist/utils/clingo-facts.js +11 -3
- package/dist/utils/clingo-facts.js.map +1 -1
- package/dist/utils/clingo-parser.js +1 -1
- package/dist/utils/clingo-parser.js.map +1 -1
- package/dist/utils/constants.d.ts +2 -0
- package/dist/utils/constants.js +4 -0
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/csv.js +1 -1
- package/dist/utils/csv.js.map +1 -1
- package/package.json +5 -5
- package/src/card-metadata-updater.ts +3 -5
- package/src/command-handler.ts +11 -18
- package/src/command-manager.ts +4 -3
- package/src/commands/create.ts +17 -83
- package/src/commands/edit.ts +16 -132
- package/src/commands/export.ts +8 -29
- package/src/commands/import.ts +4 -6
- package/src/commands/move.ts +144 -179
- package/src/commands/remove.ts +9 -52
- package/src/commands/rename.ts +2 -7
- package/src/commands/show.ts +50 -143
- package/src/commands/transition.ts +30 -33
- package/src/commands/update.ts +27 -9
- package/src/commands/validate.ts +21 -36
- package/src/containers/card-container.ts +200 -360
- package/src/containers/project/calculation-engine.ts +21 -13
- package/src/containers/project/card-cache.ts +497 -0
- package/src/containers/project/resource-collector.ts +9 -1
- package/src/containers/project.ts +529 -327
- package/src/containers/template.ts +109 -127
- package/src/index.ts +1 -0
- package/src/interfaces/folder-content-interfaces.ts +7 -1
- package/src/interfaces/macros.ts +2 -0
- package/src/interfaces/project-interfaces.ts +7 -1
- package/src/interfaces/resource-interfaces.ts +12 -24
- package/src/macros/createCards/index.ts +1 -12
- package/src/macros/createCards/types.ts +46 -0
- package/src/macros/graph/index.ts +3 -7
- package/src/macros/graph/types.ts +24 -0
- package/src/macros/image/index.ts +50 -61
- package/src/macros/image/types.ts +39 -0
- package/src/macros/include/index.ts +6 -15
- package/src/macros/include/types.ts +32 -0
- package/src/macros/percentage/index.ts +1 -7
- package/src/macros/percentage/types.ts +32 -0
- package/src/macros/report/index.ts +1 -4
- package/src/macros/report/types.ts +20 -0
- package/src/macros/scoreCard/index.ts +1 -7
- package/src/macros/scoreCard/types.ts +32 -0
- package/src/macros/types.ts +48 -0
- package/src/macros/vega/index.ts +1 -4
- package/src/macros/vega/types.ts +21 -0
- package/src/macros/vegalite/index.ts +1 -4
- package/src/macros/vegalite/types.ts +22 -0
- package/src/macros/xref/index.ts +6 -20
- package/src/macros/xref/types.ts +20 -0
- package/src/module-manager.ts +5 -5
- package/src/project-settings.ts +1 -1
- package/src/resources/calculation-resource.ts +6 -76
- package/src/resources/card-type-resource.ts +24 -59
- package/src/resources/field-type-resource.ts +22 -51
- package/src/resources/file-resource.ts +27 -409
- package/src/resources/folder-resource.ts +98 -124
- package/src/resources/graph-model-resource.ts +17 -74
- package/src/resources/graph-view-resource.ts +14 -54
- package/src/resources/link-type-resource.ts +13 -40
- package/src/resources/report-resource.ts +17 -57
- package/src/resources/resource-object.ts +435 -32
- package/src/resources/template-resource.ts +16 -29
- package/src/resources/workflow-resource.ts +26 -50
- package/src/utils/card-utils.ts +217 -31
- package/src/utils/clingo-facts.ts +13 -3
- package/src/utils/clingo-parser.ts +1 -1
- package/src/utils/constants.ts +6 -0
- package/src/utils/csv.ts +1 -1
package/src/commands/edit.ts
CHANGED
|
@@ -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 {
|
|
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
|
|
90
|
-
|
|
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
|
|
103
|
-
const
|
|
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*\}\}/,
|
|
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
|
-
|
|
139
|
-
if (isTemplateCard) {
|
|
80
|
+
if (this.project.hasTemplateCard(cardKey)) {
|
|
140
81
|
return this.project.updateCardContent(cardKey, changedContent);
|
|
141
82
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
-
|
|
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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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
|
}
|
package/src/commands/export.ts
CHANGED
|
@@ -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(
|
|
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,
|
package/src/commands/import.ts
CHANGED
|
@@ -62,7 +62,7 @@ export class Import {
|
|
|
62
62
|
throw new Error(`Template '${template}' not found`);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
const templateCards =
|
|
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 =
|
|
81
|
-
|
|
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) {
|