@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.
- package/dist/card-metadata-updater.js +7 -1
- package/dist/card-metadata-updater.js.map +1 -1
- package/dist/command-handler.d.ts +4 -0
- package/dist/command-handler.js +22 -8
- package/dist/command-handler.js.map +1 -1
- package/dist/command-manager.d.ts +24 -1
- package/dist/command-manager.js +31 -7
- package/dist/command-manager.js.map +1 -1
- package/dist/commands/create.d.ts +1 -1
- package/dist/commands/create.js +34 -36
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/export.d.ts +11 -2
- package/dist/commands/export.js +54 -41
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/fetch.d.ts +8 -0
- package/dist/commands/fetch.js +101 -23
- package/dist/commands/fetch.js.map +1 -1
- package/dist/commands/import.d.ts +14 -3
- package/dist/commands/import.js +27 -10
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/move.js +0 -1
- package/dist/commands/move.js.map +1 -1
- package/dist/commands/remove.d.ts +11 -2
- package/dist/commands/remove.js +15 -5
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/rename.d.ts +4 -9
- package/dist/commands/rename.js +37 -101
- package/dist/commands/rename.js.map +1 -1
- package/dist/commands/show.d.ts +20 -12
- package/dist/commands/show.js +79 -57
- package/dist/commands/show.js.map +1 -1
- package/dist/commands/transition.d.ts +9 -2
- package/dist/commands/transition.js +25 -17
- package/dist/commands/transition.js.map +1 -1
- package/dist/commands/update.d.ts +16 -12
- package/dist/commands/update.js +19 -17
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/validate.d.ts +17 -9
- package/dist/commands/validate.js +94 -35
- package/dist/commands/validate.js.map +1 -1
- package/dist/containers/card-container.d.ts +7 -5
- package/dist/containers/card-container.js +30 -5
- package/dist/containers/card-container.js.map +1 -1
- package/dist/containers/project/calculation-engine.d.ts +7 -4
- package/dist/containers/project/calculation-engine.js +61 -66
- package/dist/containers/project/calculation-engine.js.map +1 -1
- package/dist/containers/project/project-paths.d.ts +7 -4
- package/dist/containers/project/project-paths.js +22 -12
- package/dist/containers/project/project-paths.js.map +1 -1
- package/dist/containers/project/resource-cache.d.ts +169 -0
- package/dist/containers/project/resource-cache.js +509 -0
- package/dist/containers/project/resource-cache.js.map +1 -0
- package/dist/containers/project/resource-handler.d.ts +129 -0
- package/dist/containers/project/resource-handler.js +206 -0
- package/dist/containers/project/resource-handler.js.map +1 -0
- package/dist/containers/project.d.ts +46 -152
- package/dist/containers/project.js +179 -409
- package/dist/containers/project.js.map +1 -1
- package/dist/containers/template.d.ts +8 -2
- package/dist/containers/template.js +24 -19
- package/dist/containers/template.js.map +1 -1
- package/dist/interfaces/command-options.d.ts +3 -1
- package/dist/interfaces/folder-content-interfaces.d.ts +5 -3
- package/dist/interfaces/folder-content-interfaces.js +3 -3
- package/dist/interfaces/folder-content-interfaces.js.map +1 -1
- package/dist/interfaces/project-interfaces.d.ts +7 -9
- package/dist/interfaces/project-interfaces.js.map +1 -1
- package/dist/interfaces/resource-interfaces.d.ts +14 -1
- package/dist/interfaces/resource-interfaces.js.map +1 -1
- package/dist/macros/graph/index.js +12 -26
- package/dist/macros/graph/index.js.map +1 -1
- package/dist/macros/index.d.ts +1 -1
- package/dist/macros/index.js +2 -2
- package/dist/macros/index.js.map +1 -1
- package/dist/macros/report/index.js +3 -6
- package/dist/macros/report/index.js.map +1 -1
- package/dist/module-manager.d.ts +16 -3
- package/dist/module-manager.js +51 -19
- package/dist/module-manager.js.map +1 -1
- package/dist/project-settings.d.ts +21 -3
- package/dist/project-settings.js +91 -14
- package/dist/project-settings.js.map +1 -1
- package/dist/resources/calculation-resource.d.ts +4 -3
- package/dist/resources/calculation-resource.js +11 -5
- package/dist/resources/calculation-resource.js.map +1 -1
- package/dist/resources/card-type-resource.d.ts +6 -1
- package/dist/resources/card-type-resource.js +34 -23
- package/dist/resources/card-type-resource.js.map +1 -1
- package/dist/resources/create-defaults.d.ts +3 -2
- package/dist/resources/create-defaults.js +3 -2
- package/dist/resources/create-defaults.js.map +1 -1
- package/dist/resources/field-type-resource.d.ts +4 -1
- package/dist/resources/field-type-resource.js +22 -23
- package/dist/resources/field-type-resource.js.map +1 -1
- package/dist/resources/file-resource.d.ts +5 -9
- package/dist/resources/file-resource.js +6 -11
- package/dist/resources/file-resource.js.map +1 -1
- package/dist/resources/folder-resource.d.ts +29 -32
- package/dist/resources/folder-resource.js +59 -78
- package/dist/resources/folder-resource.js.map +1 -1
- package/dist/resources/graph-model-resource.d.ts +4 -1
- package/dist/resources/graph-model-resource.js +11 -4
- package/dist/resources/graph-model-resource.js.map +1 -1
- package/dist/resources/graph-view-resource.d.ts +5 -2
- package/dist/resources/graph-view-resource.js +7 -3
- package/dist/resources/graph-view-resource.js.map +1 -1
- package/dist/resources/link-type-resource.d.ts +5 -2
- package/dist/resources/link-type-resource.js +5 -2
- package/dist/resources/link-type-resource.js.map +1 -1
- package/dist/resources/report-resource.d.ts +6 -7
- package/dist/resources/report-resource.js +14 -23
- package/dist/resources/report-resource.js.map +1 -1
- package/dist/resources/resource-object.d.ts +94 -8
- package/dist/resources/resource-object.js +212 -109
- package/dist/resources/resource-object.js.map +1 -1
- package/dist/resources/template-resource.d.ts +7 -3
- package/dist/resources/template-resource.js +10 -3
- package/dist/resources/template-resource.js.map +1 -1
- package/dist/resources/workflow-resource.d.ts +5 -2
- package/dist/resources/workflow-resource.js +18 -22
- package/dist/resources/workflow-resource.js.map +1 -1
- package/dist/utils/card-utils.d.ts +2 -2
- package/dist/utils/card-utils.js +1 -1
- package/dist/utils/clingo-fact-builder.d.ts +25 -14
- package/dist/utils/clingo-fact-builder.js +27 -5
- package/dist/utils/clingo-fact-builder.js.map +1 -1
- package/dist/utils/clingo-facts.js +3 -4
- package/dist/utils/clingo-facts.js.map +1 -1
- package/dist/utils/configuration-logger.d.ts +91 -0
- package/dist/utils/configuration-logger.js +151 -0
- package/dist/utils/configuration-logger.js.map +1 -0
- package/dist/utils/constants.d.ts +1 -1
- package/dist/utils/constants.js +5 -3
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/resource-utils.d.ts +1 -0
- package/dist/utils/resource-utils.js +2 -1
- package/dist/utils/resource-utils.js.map +1 -1
- package/package.json +9 -9
- package/src/card-metadata-updater.ts +6 -2
- package/src/command-handler.ts +39 -12
- package/src/command-manager.ts +33 -21
- package/src/commands/create.ts +43 -78
- package/src/commands/export.ts +63 -52
- package/src/commands/fetch.ts +143 -34
- package/src/commands/import.ts +37 -15
- package/src/commands/move.ts +0 -1
- package/src/commands/remove.ts +20 -7
- package/src/commands/rename.ts +58 -149
- package/src/commands/show.ts +123 -80
- package/src/commands/transition.ts +26 -28
- package/src/commands/update.ts +25 -22
- package/src/commands/validate.ts +104 -67
- package/src/containers/card-container.ts +37 -5
- package/src/containers/project/calculation-engine.ts +61 -93
- package/src/containers/project/project-paths.ts +29 -13
- package/src/containers/project/resource-cache.ts +651 -0
- package/src/containers/project/resource-handler.ts +265 -0
- package/src/containers/project.ts +250 -527
- package/src/containers/template.ts +28 -23
- package/src/interfaces/command-options.ts +3 -1
- package/src/interfaces/folder-content-interfaces.ts +7 -6
- package/src/interfaces/project-interfaces.ts +12 -11
- package/src/interfaces/resource-interfaces.ts +18 -3
- package/src/macros/graph/index.ts +26 -47
- package/src/macros/index.ts +2 -2
- package/src/macros/report/index.ts +3 -9
- package/src/module-manager.ts +74 -17
- package/src/project-settings.ts +96 -14
- package/src/resources/calculation-resource.ts +18 -18
- package/src/resources/card-type-resource.ts +50 -50
- package/src/resources/create-defaults.ts +3 -2
- package/src/resources/field-type-resource.ts +41 -55
- package/src/resources/file-resource.ts +10 -36
- package/src/resources/folder-resource.ts +69 -120
- package/src/resources/graph-model-resource.ts +20 -22
- package/src/resources/graph-view-resource.ts +15 -17
- package/src/resources/link-type-resource.ts +10 -13
- package/src/resources/report-resource.ts +21 -43
- package/src/resources/resource-object.ts +263 -149
- package/src/resources/template-resource.ts +17 -16
- package/src/resources/workflow-resource.ts +25 -44
- package/src/utils/card-utils.ts +2 -2
- package/src/utils/clingo-fact-builder.ts +28 -16
- package/src/utils/clingo-facts.ts +3 -4
- package/src/utils/configuration-logger.ts +206 -0
- package/src/utils/constants.ts +5 -3
- package/src/utils/resource-utils.ts +2 -1
- package/dist/containers/project/resource-collector.d.ts +0 -110
- package/dist/containers/project/resource-collector.js +0 -344
- package/dist/containers/project/resource-collector.js.map +0 -1
- package/src/containers/project/resource-collector.ts +0 -404
package/src/commands/import.ts
CHANGED
|
@@ -11,23 +11,33 @@
|
|
|
11
11
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import type { CardType } from '../interfaces/resource-interfaces.js';
|
|
15
|
-
import { type Create, Validate } from './index.js';
|
|
16
14
|
import { ModuleManager } from '../module-manager.js';
|
|
15
|
+
import { readCsvFile } from '../utils/csv.js';
|
|
16
|
+
import { Validate } from './validate.js';
|
|
17
|
+
|
|
18
|
+
import type { Create } from './create.js';
|
|
17
19
|
import type {
|
|
18
20
|
Credentials,
|
|
19
21
|
ModuleSettingOptions,
|
|
20
22
|
} from '../interfaces/project-interfaces.js';
|
|
23
|
+
import type { Fetch } from './fetch.js';
|
|
21
24
|
import type { Project } from '../containers/project.js';
|
|
22
|
-
import { readCsvFile } from '../utils/csv.js';
|
|
23
|
-
import { resourceName } from '../utils/resource-utils.js';
|
|
24
|
-
import { TemplateResource } from '../resources/template-resource.js';
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Handles all import commands.
|
|
28
|
+
*/
|
|
26
29
|
export class Import {
|
|
27
30
|
private moduleManager: ModuleManager;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Creates an instance of Import.
|
|
34
|
+
* @param project Project to use.
|
|
35
|
+
* @param createCmd Instance of Create to use.
|
|
36
|
+
*/
|
|
28
37
|
constructor(
|
|
29
38
|
private project: Project,
|
|
30
39
|
private createCmd: Create,
|
|
40
|
+
private fetchCmd: Fetch,
|
|
31
41
|
) {
|
|
32
42
|
this.moduleManager = new ModuleManager(this.project);
|
|
33
43
|
}
|
|
@@ -53,9 +63,9 @@ export class Import {
|
|
|
53
63
|
|
|
54
64
|
for (const row of csv) {
|
|
55
65
|
const { title, template, description, labels, ...customFields } = row;
|
|
56
|
-
const templateResource =
|
|
57
|
-
|
|
58
|
-
|
|
66
|
+
const templateResource = this.project.resources.byType(
|
|
67
|
+
template,
|
|
68
|
+
'templates',
|
|
59
69
|
);
|
|
60
70
|
const templateObject = templateResource.templateObject();
|
|
61
71
|
if (!templateObject) {
|
|
@@ -78,13 +88,12 @@ export class Import {
|
|
|
78
88
|
}
|
|
79
89
|
const cardKey = cards[0].key;
|
|
80
90
|
const card = this.project.findCard(cardKey);
|
|
81
|
-
|
|
82
|
-
card.metadata?.cardType || '',
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
if (!cardType) {
|
|
91
|
+
if (!card.metadata?.cardType) {
|
|
86
92
|
throw new Error(`Card type not found for card ${cardKey}`);
|
|
87
93
|
}
|
|
94
|
+
const cardType = this.project.resources
|
|
95
|
+
.byType(card.metadata?.cardType, 'cardTypes')
|
|
96
|
+
.show();
|
|
88
97
|
|
|
89
98
|
if (description) {
|
|
90
99
|
await this.project.updateCardContent(cardKey, description);
|
|
@@ -126,12 +135,17 @@ export class Import {
|
|
|
126
135
|
* @param options Additional options for module import. Optional.
|
|
127
136
|
* branch: Git branch for module from Git.
|
|
128
137
|
* private: If true, uses credentials to clone the repository
|
|
138
|
+
* @param skipMigrationLog If true, skip logging to migration log (used during project creation)
|
|
129
139
|
*/
|
|
130
140
|
public async importModule(
|
|
131
141
|
source: string,
|
|
132
142
|
destination?: string,
|
|
133
143
|
options?: ModuleSettingOptions,
|
|
144
|
+
skipMigrationLog = false,
|
|
134
145
|
) {
|
|
146
|
+
// Ensure module list is up to date before importing
|
|
147
|
+
await this.fetchCmd.ensureModuleListUpToDate();
|
|
148
|
+
|
|
135
149
|
const beforeImportValidateErrors = await Validate.getInstance().validate(
|
|
136
150
|
this.project.basePath,
|
|
137
151
|
() => this.project,
|
|
@@ -155,10 +169,13 @@ export class Import {
|
|
|
155
169
|
};
|
|
156
170
|
|
|
157
171
|
// Fetch module dependencies.
|
|
158
|
-
await this.moduleManager.
|
|
172
|
+
await this.moduleManager.updateDependencies(
|
|
173
|
+
moduleSettings,
|
|
174
|
+
options?.credentials,
|
|
175
|
+
);
|
|
159
176
|
|
|
160
177
|
// Add module as a dependency.
|
|
161
|
-
await this.project.importModule(moduleSettings);
|
|
178
|
+
await this.project.importModule(moduleSettings, skipMigrationLog);
|
|
162
179
|
|
|
163
180
|
// Validate the project after module has been imported
|
|
164
181
|
const afterImportValidateErrors = await Validate.getInstance().validate(
|
|
@@ -179,6 +196,9 @@ export class Import {
|
|
|
179
196
|
* @throws if module is not part of the project
|
|
180
197
|
*/
|
|
181
198
|
public async updateModule(moduleName: string, credentials?: Credentials) {
|
|
199
|
+
// Ensure module list is up to date before updating
|
|
200
|
+
await this.fetchCmd.ensureModuleListUpToDate();
|
|
201
|
+
|
|
182
202
|
const module = this.project.configuration.modules.find(
|
|
183
203
|
(item) => item.name === moduleName,
|
|
184
204
|
);
|
|
@@ -193,6 +213,8 @@ export class Import {
|
|
|
193
213
|
* @param credentials Optional credentials for private modules.
|
|
194
214
|
*/
|
|
195
215
|
public async updateAllModules(credentials?: Credentials) {
|
|
216
|
+
// Ensure module list is up to date before updating all modules
|
|
217
|
+
await this.fetchCmd.ensureModuleListUpToDate();
|
|
196
218
|
return this.moduleManager.updateModules(credentials);
|
|
197
219
|
}
|
|
198
220
|
}
|
package/src/commands/move.ts
CHANGED
|
@@ -197,7 +197,6 @@ export class Move {
|
|
|
197
197
|
sourceCard.parent = movingToRoot ? ROOT : destination;
|
|
198
198
|
if (sourceCard.metadata) {
|
|
199
199
|
sourceCard.metadata.rank = rank;
|
|
200
|
-
sourceCard.metadata.parent = movingToRoot ? ROOT : destination;
|
|
201
200
|
}
|
|
202
201
|
|
|
203
202
|
// Handle cache update and persistence
|
package/src/commands/remove.ts
CHANGED
|
@@ -14,16 +14,23 @@
|
|
|
14
14
|
import { ActionGuard } from '../permissions/action-guard.js';
|
|
15
15
|
import { isModuleCard } from '../utils/card-utils.js';
|
|
16
16
|
import { ModuleManager } from '../module-manager.js';
|
|
17
|
-
import {
|
|
17
|
+
import type { Fetch } from './fetch.js';
|
|
18
|
+
import type { Project } from '../containers/project.js';
|
|
18
19
|
import type { RemovableResourceTypes } from '../interfaces/project-interfaces.js';
|
|
19
|
-
import { resourceName } from '../utils/resource-utils.js';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Remove command.
|
|
23
23
|
*/
|
|
24
24
|
export class Remove {
|
|
25
25
|
private moduleManager: ModuleManager;
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new instance of Remove command.
|
|
28
|
+
* @param project Project instance to use
|
|
29
|
+
*/
|
|
30
|
+
constructor(
|
|
31
|
+
private project: Project,
|
|
32
|
+
private fetchCmd: Fetch,
|
|
33
|
+
) {
|
|
27
34
|
this.moduleManager = new ModuleManager(this.project);
|
|
28
35
|
}
|
|
29
36
|
|
|
@@ -152,13 +159,19 @@ export class Remove {
|
|
|
152
159
|
* @param rest Additional arguments
|
|
153
160
|
* @note removing attachment requires card id and attachment filename
|
|
154
161
|
* @note removing link requires card ids of source card, and optionally link type and link description
|
|
162
|
+
* @throws when removing an attachment, but attachment parameter is missing, or
|
|
163
|
+
* when removing link, some of the mandatory parameters are missing, or
|
|
164
|
+
* when trying to remove unknown type
|
|
155
165
|
*/
|
|
156
166
|
public async remove(
|
|
157
167
|
type: RemovableResourceTypes,
|
|
158
168
|
targetName: string,
|
|
159
169
|
...rest: any[] // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
160
170
|
) {
|
|
161
|
-
|
|
171
|
+
// Ensure module list is up to date when removing modules
|
|
172
|
+
if (type === 'module') {
|
|
173
|
+
await this.fetchCmd.ensureModuleListUpToDate();
|
|
174
|
+
}
|
|
162
175
|
|
|
163
176
|
if (type === 'attachment' && rest.length !== 1 && !rest[0]) {
|
|
164
177
|
throw new Error(
|
|
@@ -177,9 +190,9 @@ export class Remove {
|
|
|
177
190
|
);
|
|
178
191
|
}
|
|
179
192
|
if (this.projectResource(type)) {
|
|
180
|
-
const resource =
|
|
181
|
-
|
|
182
|
-
|
|
193
|
+
const resource = this.project.resources.byType(
|
|
194
|
+
targetName,
|
|
195
|
+
this.project.resources.resourceTypeFromSingularType(type),
|
|
183
196
|
);
|
|
184
197
|
return resource?.delete();
|
|
185
198
|
} else {
|
package/src/commands/rename.ts
CHANGED
|
@@ -17,20 +17,13 @@ import { join } from 'node:path';
|
|
|
17
17
|
import { rename, readdir, readFile, writeFile } from 'node:fs/promises';
|
|
18
18
|
|
|
19
19
|
import type { Card } from '../interfaces/project-interfaces.js';
|
|
20
|
+
import {
|
|
21
|
+
ConfigurationLogger,
|
|
22
|
+
ConfigurationOperation,
|
|
23
|
+
} from '../utils/configuration-logger.js';
|
|
20
24
|
import { isTemplateCard } from '../utils/card-utils.js';
|
|
21
25
|
import { type Project, ResourcesFrom } from '../containers/project.js';
|
|
22
26
|
import { resourceName } from '../utils/resource-utils.js';
|
|
23
|
-
import { Template } from '../containers/template.js';
|
|
24
|
-
|
|
25
|
-
import { CalculationResource } from '../resources/calculation-resource.js';
|
|
26
|
-
import { CardTypeResource } from '../resources/card-type-resource.js';
|
|
27
|
-
import { FieldTypeResource } from '../resources/field-type-resource.js';
|
|
28
|
-
import { GraphModelResource } from '../resources/graph-model-resource.js';
|
|
29
|
-
import { GraphViewResource } from '../resources/graph-view-resource.js';
|
|
30
|
-
import { LinkTypeResource } from '../resources/link-type-resource.js';
|
|
31
|
-
import { ReportResource } from '../resources/report-resource.js';
|
|
32
|
-
import { TemplateResource } from '../resources/template-resource.js';
|
|
33
|
-
import { WorkflowResource } from '../resources/workflow-resource.js';
|
|
34
27
|
|
|
35
28
|
const FILE_TYPES_WITH_PREFIX_REFERENCES = ['adoc', 'hbs', 'json', 'lp'];
|
|
36
29
|
|
|
@@ -41,6 +34,10 @@ export class Rename {
|
|
|
41
34
|
private from: string = '';
|
|
42
35
|
private to: string = '';
|
|
43
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Creates an instance of Rename command.
|
|
39
|
+
* @param project Project instance to use.
|
|
40
|
+
*/
|
|
44
41
|
constructor(private project: Project) {}
|
|
45
42
|
|
|
46
43
|
// Renames a card and all of its attachments (if it is a project card).
|
|
@@ -183,93 +180,6 @@ export class Rename {
|
|
|
183
180
|
: name;
|
|
184
181
|
}
|
|
185
182
|
|
|
186
|
-
// @todo: merge all update-functions
|
|
187
|
-
// Updates card type's metadata.
|
|
188
|
-
private async updateCardTypeMetadata(cardTypeName: string) {
|
|
189
|
-
const cardType = new CardTypeResource(
|
|
190
|
-
this.project,
|
|
191
|
-
resourceName(cardTypeName),
|
|
192
|
-
);
|
|
193
|
-
return cardType.rename(resourceName(this.updateResourceName(cardTypeName)));
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Rename calculations.
|
|
197
|
-
private async updateCalculation(calculationName: string) {
|
|
198
|
-
const calculation = new CalculationResource(
|
|
199
|
-
this.project,
|
|
200
|
-
resourceName(calculationName),
|
|
201
|
-
);
|
|
202
|
-
return calculation.rename(
|
|
203
|
-
resourceName(this.updateResourceName(calculationName)),
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Updates field type's metadata.
|
|
208
|
-
private async updateFieldTypeMetadata(fieldTypeName: string) {
|
|
209
|
-
const fieldType = new FieldTypeResource(
|
|
210
|
-
this.project,
|
|
211
|
-
resourceName(fieldTypeName),
|
|
212
|
-
);
|
|
213
|
-
return fieldType.rename(
|
|
214
|
-
resourceName(this.updateResourceName(fieldTypeName)),
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// Updates graph model's metadata.
|
|
219
|
-
private async updateGraphModelMetadata(graphModelName: string) {
|
|
220
|
-
const graphModel = new GraphModelResource(
|
|
221
|
-
this.project,
|
|
222
|
-
resourceName(graphModelName),
|
|
223
|
-
);
|
|
224
|
-
return graphModel.rename(
|
|
225
|
-
resourceName(this.updateResourceName(graphModelName)),
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// Updates graph view's metadata.
|
|
230
|
-
private async updateGraphViewMetadata(graphViewName: string) {
|
|
231
|
-
const graphView = new GraphViewResource(
|
|
232
|
-
this.project,
|
|
233
|
-
resourceName(graphViewName),
|
|
234
|
-
);
|
|
235
|
-
return graphView.rename(
|
|
236
|
-
resourceName(this.updateResourceName(graphViewName)),
|
|
237
|
-
);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// Updates link type's metadata.
|
|
241
|
-
private async updateLinkTypeMetadata(linkTypeName: string) {
|
|
242
|
-
const linkType = new LinkTypeResource(
|
|
243
|
-
this.project,
|
|
244
|
-
resourceName(linkTypeName),
|
|
245
|
-
);
|
|
246
|
-
return linkType.rename(resourceName(this.updateResourceName(linkTypeName)));
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// Updates reports' metadata.
|
|
250
|
-
private async updateReport(reportName: string) {
|
|
251
|
-
const report = new ReportResource(this.project, resourceName(reportName));
|
|
252
|
-
return report.rename(resourceName(this.updateResourceName(reportName)));
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// Rename templates.
|
|
256
|
-
private async updateTemplate(templateName: string) {
|
|
257
|
-
const template = new TemplateResource(
|
|
258
|
-
this.project,
|
|
259
|
-
resourceName(templateName),
|
|
260
|
-
);
|
|
261
|
-
return template.rename(resourceName(this.updateResourceName(templateName)));
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// Rename workflows.
|
|
265
|
-
private async updateWorkflowMetadata(workflowName: string) {
|
|
266
|
-
const workflow = new WorkflowResource(
|
|
267
|
-
this.project,
|
|
268
|
-
resourceName(workflowName),
|
|
269
|
-
);
|
|
270
|
-
return workflow.rename(resourceName(this.updateResourceName(workflowName)));
|
|
271
|
-
}
|
|
272
|
-
|
|
273
183
|
/**
|
|
274
184
|
* Renames project prefix.
|
|
275
185
|
* @throws if trying to use empty 'to'
|
|
@@ -294,72 +204,60 @@ export class Rename {
|
|
|
294
204
|
await this.project.configuration.setCardPrefix(to);
|
|
295
205
|
console.info(`Rename: New prefix: '${this.project.projectPrefix}'`);
|
|
296
206
|
// Update the resources collection, since project prefix has changed.
|
|
297
|
-
this.project.
|
|
207
|
+
this.project.resources.changed();
|
|
298
208
|
|
|
299
209
|
// Rename local resources.
|
|
300
|
-
// It is better to rename the resources in this order: card types, field types, then
|
|
210
|
+
// It is better to rename the resources in this order: card types, workflows, field types, then the rest
|
|
301
211
|
|
|
302
212
|
// Rename all card types and custom fields in them.
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
213
|
+
for (const cardType of this.project.resources.cardTypes(
|
|
214
|
+
ResourcesFrom.localOnly,
|
|
215
|
+
)) {
|
|
216
|
+
const name = this.updateResourceName(cardType.data?.name || '');
|
|
217
|
+
await cardType.rename(resourceName(name));
|
|
306
218
|
}
|
|
307
219
|
console.info('Updated card types');
|
|
308
220
|
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
|
|
221
|
+
for (const workflow of this.project.resources.workflows(
|
|
222
|
+
ResourcesFrom.localOnly,
|
|
223
|
+
)) {
|
|
224
|
+
const name = this.updateResourceName(workflow.data?.name || '');
|
|
225
|
+
await workflow.rename(resourceName(name));
|
|
312
226
|
}
|
|
313
227
|
console.info('Updated workflows');
|
|
314
228
|
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
229
|
+
for (const fieldType of this.project.resources.fieldTypes(
|
|
230
|
+
ResourcesFrom.localOnly,
|
|
231
|
+
)) {
|
|
232
|
+
const name = this.updateResourceName(fieldType.data?.name || '');
|
|
233
|
+
await fieldType.rename(resourceName(name));
|
|
318
234
|
}
|
|
319
235
|
console.info('Updated field types');
|
|
320
236
|
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
const reports = await this.project.reports(ResourcesFrom.localOnly);
|
|
340
|
-
for (const report of reports) {
|
|
341
|
-
await this.updateReport(report.name);
|
|
342
|
-
}
|
|
343
|
-
console.info('Updated reports');
|
|
344
|
-
|
|
345
|
-
let templates = await this.project.templates(ResourcesFrom.localOnly);
|
|
346
|
-
for (const template of templates) {
|
|
347
|
-
await this.updateTemplate(template.name);
|
|
237
|
+
const restOfResourceTypes = [
|
|
238
|
+
'graphModels',
|
|
239
|
+
'graphViews',
|
|
240
|
+
'linkTypes',
|
|
241
|
+
'reports',
|
|
242
|
+
'templates',
|
|
243
|
+
'calculations',
|
|
244
|
+
] as const;
|
|
245
|
+
|
|
246
|
+
for (const resourceType of restOfResourceTypes) {
|
|
247
|
+
for (const resource of this.project.resources.resourceTypes(
|
|
248
|
+
resourceType,
|
|
249
|
+
ResourcesFrom.localOnly,
|
|
250
|
+
)) {
|
|
251
|
+
const name = this.updateResourceName(resource.data?.name || '');
|
|
252
|
+
await resource.rename(resourceName(name));
|
|
253
|
+
}
|
|
348
254
|
}
|
|
349
|
-
console.info('Updated templates');
|
|
350
255
|
|
|
351
|
-
|
|
256
|
+
// Rename all local template cards. This must be done after calculations have been renamed.
|
|
257
|
+
for (const template of this.project.resources.templates(
|
|
352
258
|
ResourcesFrom.localOnly,
|
|
353
|
-
)
|
|
354
|
-
|
|
355
|
-
await this.updateCalculation(calculation.name);
|
|
356
|
-
}
|
|
357
|
-
console.info('Updated calculations');
|
|
358
|
-
|
|
359
|
-
// Rename all local template cards.
|
|
360
|
-
templates = await this.project.templates(ResourcesFrom.localOnly);
|
|
361
|
-
for (const template of templates) {
|
|
362
|
-
const templateObject = new Template(this.project, template);
|
|
259
|
+
)) {
|
|
260
|
+
const templateObject = template.templateObject();
|
|
363
261
|
await this.renameCards(templateObject.cards());
|
|
364
262
|
}
|
|
365
263
|
console.info('Renamed template cards and updated the content');
|
|
@@ -376,9 +274,20 @@ export class Rename {
|
|
|
376
274
|
console.info('Renamed all remaining references in .cards folder');
|
|
377
275
|
|
|
378
276
|
// It is best that the resources are re-collected after all the renaming has occurred.
|
|
379
|
-
this.project.
|
|
277
|
+
this.project.resources.changed();
|
|
380
278
|
console.info('Collected renamed resources');
|
|
381
279
|
|
|
280
|
+
// Remove these when operations properly update card cache
|
|
281
|
+
this.project.cardsCache.clear();
|
|
282
|
+
await this.project.populateCaches();
|
|
283
|
+
|
|
284
|
+
await ConfigurationLogger.log(
|
|
285
|
+
this.project.basePath,
|
|
286
|
+
ConfigurationOperation.PROJECT_RENAME,
|
|
287
|
+
this.to,
|
|
288
|
+
{},
|
|
289
|
+
);
|
|
290
|
+
|
|
382
291
|
return this.project.calculationEngine.generate();
|
|
383
292
|
}
|
|
384
293
|
}
|