@cyberismo/data-handler 0.0.15 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +19 -3
- package/dist/command-handler.js.map +1 -1
- package/dist/command-manager.d.ts +24 -1
- package/dist/command-manager.js +27 -3
- 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/import.d.ts +9 -1
- package/dist/commands/import.js +15 -7
- 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 +8 -1
- package/dist/commands/remove.js +8 -4
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/rename.d.ts +4 -9
- package/dist/commands/rename.js +32 -101
- package/dist/commands/rename.js.map +1 -1
- package/dist/commands/show.d.ts +16 -10
- package/dist/commands/show.js +71 -55
- 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 +96 -35
- package/dist/commands/validate.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 +5 -4
- package/dist/containers/project/project-paths.js +16 -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 +507 -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 +38 -153
- package/dist/containers/project.js +129 -405
- package/dist/containers/project.js.map +1 -1
- package/dist/containers/template.d.ts +8 -2
- package/dist/containers/template.js +20 -15
- package/dist/containers/template.js.map +1 -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 +2 -4
- 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 +16 -3
- package/dist/project-settings.js +79 -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 +93 -8
- package/dist/resources/resource-object.js +162 -110
- 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/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 +8 -8
- package/src/card-metadata-updater.ts +6 -2
- package/src/command-handler.ts +24 -5
- package/src/command-manager.ts +29 -17
- package/src/commands/create.ts +43 -78
- package/src/commands/export.ts +63 -52
- package/src/commands/import.ts +24 -14
- package/src/commands/move.ts +0 -1
- package/src/commands/remove.ts +11 -7
- package/src/commands/rename.ts +43 -149
- package/src/commands/show.ts +113 -78
- package/src/commands/transition.ts +26 -28
- package/src/commands/update.ts +25 -22
- package/src/commands/validate.ts +108 -67
- package/src/containers/project/calculation-engine.ts +61 -93
- package/src/containers/project/project-paths.ts +21 -13
- package/src/containers/project/resource-cache.ts +648 -0
- package/src/containers/project/resource-handler.ts +265 -0
- package/src/containers/project.ts +178 -522
- package/src/containers/template.ts +24 -19
- package/src/interfaces/folder-content-interfaces.ts +7 -6
- package/src/interfaces/project-interfaces.ts +7 -6
- 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 +83 -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 +194 -152
- 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/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
|
@@ -12,11 +12,27 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { ActionGuard } from '../permissions/action-guard.js';
|
|
14
14
|
import { CardMetadataUpdater } from '../card-metadata-updater.js';
|
|
15
|
+
/**
|
|
16
|
+
* Handles transitions.
|
|
17
|
+
*/
|
|
15
18
|
export class Transition {
|
|
16
19
|
project;
|
|
20
|
+
/**
|
|
21
|
+
* Creates an instance of Transition command.
|
|
22
|
+
* @param project Project to use.
|
|
23
|
+
*/
|
|
17
24
|
constructor(project) {
|
|
18
25
|
this.project = project;
|
|
19
26
|
}
|
|
27
|
+
// Wrapper to run onTransition query.
|
|
28
|
+
async transitionChangesQuery(cardKey, transition) {
|
|
29
|
+
if (!cardKey || !transition)
|
|
30
|
+
return undefined;
|
|
31
|
+
return this.project.calculationEngine.runQuery('onTransition', 'localApp', {
|
|
32
|
+
cardKey,
|
|
33
|
+
transition,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
20
36
|
/**
|
|
21
37
|
* Transitions a card from its current state to a new state.
|
|
22
38
|
* @param cardKey card key
|
|
@@ -24,16 +40,17 @@ export class Transition {
|
|
|
24
40
|
*/
|
|
25
41
|
async cardTransition(cardKey, transition) {
|
|
26
42
|
const card = this.project.findCard(cardKey);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (cardType === undefined) {
|
|
30
|
-
throw new Error(`Card's card type '${card.metadata?.cardType}' does not exist in the project`);
|
|
43
|
+
if (!card.metadata?.cardType) {
|
|
44
|
+
throw new Error(`Card does not have card type`);
|
|
31
45
|
}
|
|
46
|
+
// Card type
|
|
47
|
+
const cardType = this.project.resources
|
|
48
|
+
.byType(card.metadata?.cardType, 'cardTypes')
|
|
49
|
+
.show();
|
|
32
50
|
// Workflow
|
|
33
|
-
const workflow =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
51
|
+
const workflow = this.project.resources
|
|
52
|
+
.byType(cardType.workflow, 'workflows')
|
|
53
|
+
.show();
|
|
37
54
|
// Check that the state transition can be made "from".
|
|
38
55
|
const foundFrom = workflow.transitions.find((item) => (card.metadata &&
|
|
39
56
|
item.fromState.includes(card.metadata?.workflowState)) ||
|
|
@@ -74,14 +91,5 @@ export class Transition {
|
|
|
74
91
|
.catch((error) => console.error(error));
|
|
75
92
|
}
|
|
76
93
|
}
|
|
77
|
-
// Wrapper to run onTransition query.
|
|
78
|
-
async transitionChangesQuery(cardKey, transition) {
|
|
79
|
-
if (!cardKey || !transition)
|
|
80
|
-
return undefined;
|
|
81
|
-
return this.project.calculationEngine.runQuery('onTransition', 'localApp', {
|
|
82
|
-
cardKey,
|
|
83
|
-
transition,
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
94
|
}
|
|
87
95
|
//# sourceMappingURL=transition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transition.js","sourceRoot":"","sources":["../../src/commands/transition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"transition.js","sourceRoot":"","sources":["../../src/commands/transition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAIlE;;GAEG;AACH,MAAM,OAAO,UAAU;IAKD;IAJpB;;;OAGG;IACH,YAAoB,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;IAAG,CAAC;IAExC,qCAAqC;IAC7B,KAAK,CAAC,sBAAsB,CAAC,OAAe,EAAE,UAAkB;QACtE,IAAI,CAAC,OAAO,IAAI,CAAC,UAAU;YAAE,OAAO,SAAS,CAAC;QAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,cAAc,EAAE,UAAU,EAAE;YACzE,OAAO;YACP,UAAU;SACX,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,cAAc,CAAC,OAAe,EAAE,UAAyB;QACpE,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAE5C,IAAI,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AAC,EAAE,CAAC,CAAC,CAAC,KAAK,SAAS;oBAC/B,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,KAAK,SAAS,EAC7C,CAAC;oBACD,OAAO;gBACT,CAAC;gBACD,MAAM,cAAc,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC,CAAE,CAAC,YAAY,CAAC;gBACvD,OAAO,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;YACjE,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;CACF"}
|
|
@@ -10,14 +10,29 @@
|
|
|
10
10
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
11
11
|
*/
|
|
12
12
|
import type { OperationFor, UpdateOperations } from '../resources/resource-object.js';
|
|
13
|
-
import { Project } from '../containers/project.js';
|
|
13
|
+
import type { Project } from '../containers/project.js';
|
|
14
14
|
import type { UpdateKey } from '../interfaces/resource-interfaces.js';
|
|
15
15
|
/**
|
|
16
16
|
* Class that handles 'update' commands.
|
|
17
17
|
*/
|
|
18
18
|
export declare class Update {
|
|
19
19
|
private project;
|
|
20
|
+
/**
|
|
21
|
+
* Creates an instance of Update command.
|
|
22
|
+
* @param project Project to use.
|
|
23
|
+
*/
|
|
20
24
|
constructor(project: Project);
|
|
25
|
+
/**
|
|
26
|
+
* Update single resource property
|
|
27
|
+
* This is similar to updateValue, but allows the operation to be fully specified
|
|
28
|
+
* @param name Name of the resource to operate on.
|
|
29
|
+
* @param updateKey Property to change in resource or in resource content.
|
|
30
|
+
* @param operation The full operation object
|
|
31
|
+
* @template Type Type of the target of the operation
|
|
32
|
+
* @template T Type of operation ('add', 'remove', 'change', 'rank')
|
|
33
|
+
* @template K Type of the key to change
|
|
34
|
+
*/
|
|
35
|
+
applyResourceOperation<Type, T extends UpdateOperations, K extends string>(name: string, updateKey: UpdateKey<K>, operation: OperationFor<Type, T>): Promise<void>;
|
|
21
36
|
/**
|
|
22
37
|
* Updates single resource property.
|
|
23
38
|
* @param name Name of the resource to operate on.
|
|
@@ -31,15 +46,4 @@ export declare class Update {
|
|
|
31
46
|
mappingTable?: {
|
|
32
47
|
stateMapping: Record<string, string>;
|
|
33
48
|
}): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Update single resource property
|
|
36
|
-
* This is similar to updateValue, but allows the operation to be fully specified
|
|
37
|
-
* @param name Name of the resource to operate on.
|
|
38
|
-
* @param updateKey Property to change in resource or in resource content.
|
|
39
|
-
* @param operation The full operation object
|
|
40
|
-
* @template Type Type of the target of the operation
|
|
41
|
-
* @template T Type of operation ('add', 'remove', 'change', 'rank')
|
|
42
|
-
* @template K Type of the key to change
|
|
43
|
-
*/
|
|
44
|
-
applyResourceOperation<Type, T extends UpdateOperations, K extends string>(name: string, updateKey: UpdateKey<K>, operation: OperationFor<Type, T>): Promise<void>;
|
|
45
49
|
}
|
package/dist/commands/update.js
CHANGED
|
@@ -9,16 +9,33 @@
|
|
|
9
9
|
You should have received a copy of the GNU Affero General Public
|
|
10
10
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
11
11
|
*/
|
|
12
|
-
import { Project } from '../containers/project.js';
|
|
13
|
-
import { resourceName } from '../utils/resource-utils.js';
|
|
14
12
|
/**
|
|
15
13
|
* Class that handles 'update' commands.
|
|
16
14
|
*/
|
|
17
15
|
export class Update {
|
|
18
16
|
project;
|
|
17
|
+
/**
|
|
18
|
+
* Creates an instance of Update command.
|
|
19
|
+
* @param project Project to use.
|
|
20
|
+
*/
|
|
19
21
|
constructor(project) {
|
|
20
22
|
this.project = project;
|
|
21
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Update single resource property
|
|
26
|
+
* This is similar to updateValue, but allows the operation to be fully specified
|
|
27
|
+
* @param name Name of the resource to operate on.
|
|
28
|
+
* @param updateKey Property to change in resource or in resource content.
|
|
29
|
+
* @param operation The full operation object
|
|
30
|
+
* @template Type Type of the target of the operation
|
|
31
|
+
* @template T Type of operation ('add', 'remove', 'change', 'rank')
|
|
32
|
+
* @template K Type of the key to change
|
|
33
|
+
*/
|
|
34
|
+
async applyResourceOperation(name, updateKey, operation) {
|
|
35
|
+
const type = this.project.resources.extractType(name);
|
|
36
|
+
const resource = this.project.resources.byType(name, type);
|
|
37
|
+
await resource?.update(updateKey, operation);
|
|
38
|
+
}
|
|
22
39
|
/**
|
|
23
40
|
* Updates single resource property.
|
|
24
41
|
* @param name Name of the resource to operate on.
|
|
@@ -77,20 +94,5 @@ export class Update {
|
|
|
77
94
|
await this.applyResourceOperation(name, { key: parsedKey }, op);
|
|
78
95
|
}
|
|
79
96
|
}
|
|
80
|
-
/**
|
|
81
|
-
* Update single resource property
|
|
82
|
-
* This is similar to updateValue, but allows the operation to be fully specified
|
|
83
|
-
* @param name Name of the resource to operate on.
|
|
84
|
-
* @param updateKey Property to change in resource or in resource content.
|
|
85
|
-
* @param operation The full operation object
|
|
86
|
-
* @template Type Type of the target of the operation
|
|
87
|
-
* @template T Type of operation ('add', 'remove', 'change', 'rank')
|
|
88
|
-
* @template K Type of the key to change
|
|
89
|
-
*/
|
|
90
|
-
async applyResourceOperation(name, updateKey, operation) {
|
|
91
|
-
const resource = Project.resourceObject(this.project, resourceName(name));
|
|
92
|
-
await resource?.update(updateKey, operation);
|
|
93
|
-
this.project.collectLocalResources();
|
|
94
|
-
}
|
|
95
97
|
}
|
|
96
98
|
//# sourceMappingURL=update.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAcF;;GAEG;AACH,MAAM,OAAO,MAAM;IAKG;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,GAAG,cAAwB,CAAC;YAC/D,EAA0B,CAAC,MAAM,GAAG,KAAK,CAAC;QAC7C,CAAC;aAAM,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;YACjC,EAA4B,CAAC,MAAM,GAAG,KAAK,CAAC;YAC5C,EAA4B,CAAC,gBAAgB,GAAG,cAAc;gBAC7D,CAAC,CAAC,cAAc;gBAChB,CAAC,CAAC,SAAS,CAAC;QAChB,CAAC;QACD,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnD,MAAM,IAAI,KAAK,CACb,uBAAuB,GAAG,2CAA2C,CACtE,CAAC;QACJ,CAAC;QAED,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;YACvD,MAAM,IAAI,KAAK,CACb,uBAAuB,GAAG,6DAA6D,CACxF,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC;QACrC,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;QAC1E,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;CACF"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import { Validator as JSONValidator } from 'jsonschema';
|
|
14
14
|
import { Validator as DirectoryValidator } from 'directory-schema-validator';
|
|
15
15
|
import type { Card, ResourceTypes } from '../interfaces/project-interfaces.js';
|
|
16
|
-
import { Project } from '../containers/project.js';
|
|
16
|
+
import type { Project } from '../containers/project.js';
|
|
17
17
|
import { type ResourceName } from '../utils/resource-utils.js';
|
|
18
18
|
export interface LengthProvider {
|
|
19
19
|
length: number;
|
|
@@ -37,12 +37,14 @@ export declare class Validate {
|
|
|
37
37
|
static cardMetadataFile: string;
|
|
38
38
|
static dotSchemaSchemaId: string;
|
|
39
39
|
static parameterSchemaFile: string;
|
|
40
|
+
/**
|
|
41
|
+
* Creates an instance of Validate command.
|
|
42
|
+
*/
|
|
40
43
|
constructor();
|
|
41
44
|
private length;
|
|
42
45
|
private addChildSchemas;
|
|
43
46
|
private checkResourceName;
|
|
44
47
|
private fullPath;
|
|
45
|
-
private getAndCacheResource;
|
|
46
48
|
private parseValidatorMessage;
|
|
47
49
|
private readAndValidateContentFiles;
|
|
48
50
|
private removeDuplicateEntries;
|
|
@@ -53,7 +55,7 @@ export declare class Validate {
|
|
|
53
55
|
private validType;
|
|
54
56
|
/**
|
|
55
57
|
* Validates that new identifier of a resource is according to naming convention.
|
|
56
|
-
* @param identifier
|
|
58
|
+
* @param identifier Resource identifier
|
|
57
59
|
* returns true if identifier is valid, and false otherwise.
|
|
58
60
|
*/
|
|
59
61
|
static isValidIdentifierName(identifier: string): boolean;
|
|
@@ -100,6 +102,9 @@ export declare class Validate {
|
|
|
100
102
|
* @param resourceType Type of resource
|
|
101
103
|
* @param name Name of resource
|
|
102
104
|
* @param prefixes currently used project prefixes
|
|
105
|
+
* @throws when resource is not from given prefixes,
|
|
106
|
+
* or when actual resource does not match the type,
|
|
107
|
+
* or when identifier name is not valid
|
|
103
108
|
* @returns resource name as valid resource name; throws in error cases.
|
|
104
109
|
*/
|
|
105
110
|
validResourceName(resourceType: ResourceTypes, name: string, prefixes: string[]): string;
|
|
@@ -113,12 +118,14 @@ export declare class Validate {
|
|
|
113
118
|
* Validates that card's custom fields are according to schema and have correct data in them.
|
|
114
119
|
* @param project currently used Project
|
|
115
120
|
* @param card specific card
|
|
116
|
-
* @
|
|
121
|
+
* @throws when card does not have metadata
|
|
122
|
+
* @returns validation errors, if any.
|
|
117
123
|
*/
|
|
118
|
-
validateCustomFields(project: Project, card: Card): Promise<string>;
|
|
124
|
+
validateCustomFields(project: Project, card: Card, prefixes: string[]): Promise<string>;
|
|
119
125
|
/**
|
|
120
126
|
* Validates the labels of a card
|
|
121
127
|
* @param card card to validate. Card must have metadata.
|
|
128
|
+
* @returns validation errors, if any.
|
|
122
129
|
*/
|
|
123
130
|
validateCardLabels(card: Card): string;
|
|
124
131
|
/**
|
|
@@ -126,13 +133,14 @@ export declare class Validate {
|
|
|
126
133
|
* Template cards are expected to have empty workflow state.
|
|
127
134
|
* @param project Project object.
|
|
128
135
|
* @param card Card object to validate
|
|
129
|
-
* @returns
|
|
136
|
+
* @returns validation errors, if any.
|
|
130
137
|
*/
|
|
131
|
-
validateWorkflowState(project: Project, card: Card): string
|
|
138
|
+
validateWorkflowState(project: Project, card: Card): Promise<string>;
|
|
132
139
|
/**
|
|
133
140
|
* Validates a single resource.
|
|
134
|
-
* @param
|
|
135
|
-
* @
|
|
141
|
+
* @param resourceName Resource to validate
|
|
142
|
+
* @param project Project instance to use.
|
|
143
|
+
* @returns validation errors, if any.
|
|
136
144
|
*/
|
|
137
145
|
validateResource(resourceName: ResourceName, project: Project): Promise<string>;
|
|
138
146
|
/**
|
|
@@ -18,15 +18,15 @@ import { Validator as DirectoryValidator } from 'directory-schema-validator';
|
|
|
18
18
|
import { parentSchema, schemas } from '@cyberismo/assets';
|
|
19
19
|
import { errorFunction } from '../utils/error-utils.js';
|
|
20
20
|
import { isTemplateCard } from '../utils/card-utils.js';
|
|
21
|
+
import { isPredefinedField } from '../utils/constants.js';
|
|
21
22
|
import { pathExists } from '../utils/file-utils.js';
|
|
22
|
-
import { Project } from '../containers/project.js';
|
|
23
23
|
import { readJsonFile } from '../utils/json.js';
|
|
24
24
|
import { resourceName } from '../utils/resource-utils.js';
|
|
25
25
|
const invalidNames = new RegExp('[<>:"/\\|?*\x00-\x1F]|^(?:aux|con|clock$|nul|prn|com[1-9]|lpt[1-9])$');
|
|
26
26
|
const SHORT_TEXT_MAX_LENGTH = 80;
|
|
27
27
|
import * as EmailValidator from 'email-validator';
|
|
28
28
|
import { evaluateMacros } from '../macros/index.js';
|
|
29
|
-
const baseDir = import.meta.dirname;
|
|
29
|
+
const baseDir = import.meta.dirname ?? new URL('.', import.meta.url).pathname;
|
|
30
30
|
const subFoldersToValidate = ['.cards', 'cardRoot'];
|
|
31
31
|
/**
|
|
32
32
|
* Validates content.
|
|
@@ -47,6 +47,9 @@ export class Validate {
|
|
|
47
47
|
static cardMetadataFile = 'index.json';
|
|
48
48
|
static dotSchemaSchemaId = '/dotSchema';
|
|
49
49
|
static parameterSchemaFile = 'parameterSchema.json';
|
|
50
|
+
/**
|
|
51
|
+
* Creates an instance of Validate command.
|
|
52
|
+
*/
|
|
50
53
|
constructor() {
|
|
51
54
|
Validate.baseFolder = pathExists(join(process.cwd(), '../../schema', 'cardTreeDirectorySchema.json'))
|
|
52
55
|
? join(process.cwd(), '../../schema')
|
|
@@ -102,15 +105,7 @@ export class Validate {
|
|
|
102
105
|
fullPath(file) {
|
|
103
106
|
return join(file.parentPath, file.name);
|
|
104
107
|
}
|
|
105
|
-
//
|
|
106
|
-
// If value is already cached, returns from cache.
|
|
107
|
-
getAndCacheResource(project, cachedValues, valueName) {
|
|
108
|
-
const resource = project.resource(valueName);
|
|
109
|
-
if (resource) {
|
|
110
|
-
cachedValues.set(valueName, resource);
|
|
111
|
-
}
|
|
112
|
-
return resource;
|
|
113
|
-
}
|
|
108
|
+
// Parses validator messages
|
|
114
109
|
parseValidatorMessage(errorObject) {
|
|
115
110
|
let parsedErrorMessage = '';
|
|
116
111
|
// todo: get schema name here?
|
|
@@ -152,7 +147,7 @@ export class Validate {
|
|
|
152
147
|
async readAndValidateContentFiles(project, path) {
|
|
153
148
|
const message = [];
|
|
154
149
|
try {
|
|
155
|
-
const prefixes =
|
|
150
|
+
const prefixes = project.projectPrefixes();
|
|
156
151
|
const files = await readdir(path, {
|
|
157
152
|
withFileTypes: true,
|
|
158
153
|
});
|
|
@@ -263,7 +258,13 @@ export class Validate {
|
|
|
263
258
|
const errors = [];
|
|
264
259
|
if (cardType && fieldArray) {
|
|
265
260
|
const validationPromises = fieldArray.map(async (field) => {
|
|
266
|
-
|
|
261
|
+
let fieldType;
|
|
262
|
+
try {
|
|
263
|
+
fieldType = project.resources.byType(field, 'fieldTypes').show();
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
fieldType = undefined;
|
|
267
|
+
}
|
|
267
268
|
if (!fieldType) {
|
|
268
269
|
return `Card type '${cardType.name}' has invalid reference to unknown ${nameOfArray} '${field}'`;
|
|
269
270
|
}
|
|
@@ -326,7 +327,7 @@ export class Validate {
|
|
|
326
327
|
}
|
|
327
328
|
/**
|
|
328
329
|
* Validates that new identifier of a resource is according to naming convention.
|
|
329
|
-
* @param identifier
|
|
330
|
+
* @param identifier Resource identifier
|
|
330
331
|
* returns true if identifier is valid, and false otherwise.
|
|
331
332
|
*/
|
|
332
333
|
static isValidIdentifierName(identifier) {
|
|
@@ -398,6 +399,7 @@ export class Validate {
|
|
|
398
399
|
const cards = project.cards();
|
|
399
400
|
cards.push(...project.allTemplateCards());
|
|
400
401
|
const cardIds = new Map();
|
|
402
|
+
const allPrefixes = await project.projectPrefixes();
|
|
401
403
|
for (const card of cards) {
|
|
402
404
|
if (cardIds.has(card.key)) {
|
|
403
405
|
cardIds.set(card.key, (cardIds.get(card.key) || 0) + 1);
|
|
@@ -407,13 +409,13 @@ export class Validate {
|
|
|
407
409
|
}
|
|
408
410
|
if (card.metadata) {
|
|
409
411
|
if (!isTemplateCard(card)) {
|
|
410
|
-
const validWorkflow = this.validateWorkflowState(project, card);
|
|
412
|
+
const validWorkflow = await this.validateWorkflowState(project, card);
|
|
411
413
|
if (validWorkflow.length !== 0) {
|
|
412
414
|
errorMsg.push(validWorkflow);
|
|
413
415
|
}
|
|
414
416
|
}
|
|
415
417
|
}
|
|
416
|
-
const validCustomFields = await this.validateCustomFields(project, card);
|
|
418
|
+
const validCustomFields = await this.validateCustomFields(project, card, allPrefixes);
|
|
417
419
|
if (validCustomFields.length !== 0) {
|
|
418
420
|
errorMsg.push(validCustomFields);
|
|
419
421
|
}
|
|
@@ -489,6 +491,9 @@ export class Validate {
|
|
|
489
491
|
* @param resourceType Type of resource
|
|
490
492
|
* @param name Name of resource
|
|
491
493
|
* @param prefixes currently used project prefixes
|
|
494
|
+
* @throws when resource is not from given prefixes,
|
|
495
|
+
* or when actual resource does not match the type,
|
|
496
|
+
* or when identifier name is not valid
|
|
492
497
|
* @returns resource name as valid resource name; throws in error cases.
|
|
493
498
|
*/
|
|
494
499
|
validResourceName(resourceType, name, prefixes) {
|
|
@@ -523,14 +528,23 @@ export class Validate {
|
|
|
523
528
|
* Validates that card's custom fields are according to schema and have correct data in them.
|
|
524
529
|
* @param project currently used Project
|
|
525
530
|
* @param card specific card
|
|
526
|
-
* @
|
|
531
|
+
* @throws when card does not have metadata
|
|
532
|
+
* @returns validation errors, if any.
|
|
527
533
|
*/
|
|
528
|
-
async validateCustomFields(project, card) {
|
|
534
|
+
async validateCustomFields(project, card, prefixes) {
|
|
529
535
|
const validationErrors = [];
|
|
530
536
|
if (!card.metadata) {
|
|
531
537
|
throw new Error(`Card '${card.key}' has no metadata. Card object needs to be instantiated with '{metadata: true}'`);
|
|
532
538
|
}
|
|
533
|
-
|
|
539
|
+
let cardType;
|
|
540
|
+
try {
|
|
541
|
+
cardType = project.resources
|
|
542
|
+
.byType(card.metadata?.cardType, 'cardTypes')
|
|
543
|
+
.show();
|
|
544
|
+
}
|
|
545
|
+
catch {
|
|
546
|
+
cardType = undefined;
|
|
547
|
+
}
|
|
534
548
|
if (!cardType) {
|
|
535
549
|
validationErrors.push(`Card '${card.key}' has invalid card type '${card.metadata?.cardType}'`);
|
|
536
550
|
return validationErrors.join('\n');
|
|
@@ -541,9 +555,18 @@ export class Validate {
|
|
|
541
555
|
fieldErrors = await this.validateArrayOfFields(project, cardType, cardType.alwaysVisibleFields, 'always visible fields');
|
|
542
556
|
validationErrors.push(...fieldErrors);
|
|
543
557
|
for (const field of cardType.customFields) {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
558
|
+
let fieldType;
|
|
559
|
+
try {
|
|
560
|
+
fieldType = await project.resources
|
|
561
|
+
.byType(field.name, 'fieldTypes')
|
|
562
|
+
.show();
|
|
563
|
+
}
|
|
564
|
+
catch {
|
|
565
|
+
fieldType = undefined;
|
|
566
|
+
}
|
|
567
|
+
if (!fieldType) {
|
|
568
|
+
validationErrors.push(`In card '${card.key}' field '${field.name}' is missing from project\n`);
|
|
569
|
+
continue;
|
|
547
570
|
}
|
|
548
571
|
if (field.isCalculated) {
|
|
549
572
|
if (card.metadata[field.name] !== undefined) {
|
|
@@ -557,11 +580,6 @@ export class Validate {
|
|
|
557
580
|
continue;
|
|
558
581
|
}
|
|
559
582
|
}
|
|
560
|
-
const fieldType = await this.getAndCacheResource(project, this.validatedFieldTypes, field.name);
|
|
561
|
-
if (!fieldType) {
|
|
562
|
-
validationErrors.push(`In card '${card.key}' field '${field.name}' is missing from project\n`);
|
|
563
|
-
continue;
|
|
564
|
-
}
|
|
565
583
|
if (!this.validType(card.metadata[field.name], fieldType)) {
|
|
566
584
|
const typeOfValue = typeof card.metadata[field.name];
|
|
567
585
|
let fieldValue = card.metadata[field.name];
|
|
@@ -582,11 +600,38 @@ export class Validate {
|
|
|
582
600
|
validationErrors.push(`In card '${card.key}' field '${field.name}' is defined as '${fieldType.dataType}', but it is '${typeOfValue}' with value of ${fieldValue}\n`);
|
|
583
601
|
}
|
|
584
602
|
}
|
|
603
|
+
// Validate that all metadata keys are either predefined fields or valid field type names
|
|
604
|
+
for (const key of Object.keys(card.metadata)) {
|
|
605
|
+
if (isPredefinedField(key) ||
|
|
606
|
+
key === 'labels' ||
|
|
607
|
+
key === 'links') {
|
|
608
|
+
continue;
|
|
609
|
+
}
|
|
610
|
+
try {
|
|
611
|
+
this.validResourceName('fieldTypes', key, prefixes);
|
|
612
|
+
}
|
|
613
|
+
catch {
|
|
614
|
+
validationErrors.push(`Card '${card.key}' has invalid metadata key '${key}'`);
|
|
615
|
+
continue;
|
|
616
|
+
}
|
|
617
|
+
// Check that the card's fieldType exists in the project
|
|
618
|
+
let fieldType;
|
|
619
|
+
try {
|
|
620
|
+
fieldType = await project.resources.byType(key, 'fieldTypes').show();
|
|
621
|
+
}
|
|
622
|
+
catch {
|
|
623
|
+
fieldType = undefined;
|
|
624
|
+
}
|
|
625
|
+
if (!fieldType) {
|
|
626
|
+
validationErrors.push(`Card '${card.key}' has field '${key}' that does not exist in the project`);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
585
629
|
return validationErrors.join('\n');
|
|
586
630
|
}
|
|
587
631
|
/**
|
|
588
632
|
* Validates the labels of a card
|
|
589
633
|
* @param card card to validate. Card must have metadata.
|
|
634
|
+
* @returns validation errors, if any.
|
|
590
635
|
*/
|
|
591
636
|
validateCardLabels(card) {
|
|
592
637
|
const validationErrors = [];
|
|
@@ -614,15 +659,22 @@ export class Validate {
|
|
|
614
659
|
* Template cards are expected to have empty workflow state.
|
|
615
660
|
* @param project Project object.
|
|
616
661
|
* @param card Card object to validate
|
|
617
|
-
* @returns
|
|
662
|
+
* @returns validation errors, if any.
|
|
618
663
|
*/
|
|
619
|
-
validateWorkflowState(project, card) {
|
|
664
|
+
async validateWorkflowState(project, card) {
|
|
620
665
|
const validationErrors = [];
|
|
621
666
|
if (!card.metadata) {
|
|
622
667
|
validationErrors.push(`Card '${card.key}' has no metadata. Card object needs to be instantiated with '{metadata: true}'`);
|
|
623
668
|
}
|
|
624
|
-
|
|
625
|
-
|
|
669
|
+
let cardType;
|
|
670
|
+
try {
|
|
671
|
+
cardType = card.metadata?.cardType
|
|
672
|
+
? project.resources.byType(card.metadata?.cardType, 'cardTypes').show()
|
|
673
|
+
: undefined;
|
|
674
|
+
}
|
|
675
|
+
catch {
|
|
676
|
+
cardType = undefined;
|
|
677
|
+
}
|
|
626
678
|
if (!cardType) {
|
|
627
679
|
validationErrors.push(`Card '${card.key}' has invalid card type '${card.metadata?.cardType}'`);
|
|
628
680
|
return validationErrors.join('\n');
|
|
@@ -631,7 +683,15 @@ export class Validate {
|
|
|
631
683
|
validationErrors.push(`Card type '${card.metadata?.cardType}' does not have 'workflow'`);
|
|
632
684
|
return validationErrors.join('\n');
|
|
633
685
|
}
|
|
634
|
-
|
|
686
|
+
let workflow;
|
|
687
|
+
try {
|
|
688
|
+
workflow = project.resources
|
|
689
|
+
.byType(cardType.workflow, 'workflows')
|
|
690
|
+
.show();
|
|
691
|
+
}
|
|
692
|
+
catch {
|
|
693
|
+
workflow = undefined;
|
|
694
|
+
}
|
|
635
695
|
if (!workflow) {
|
|
636
696
|
validationErrors.push(`Workflow of '${cardType.workflow}' card type '${card.metadata?.cardType}' does not exist in the project`);
|
|
637
697
|
return validationErrors.join('\n');
|
|
@@ -652,12 +712,13 @@ export class Validate {
|
|
|
652
712
|
}
|
|
653
713
|
/**
|
|
654
714
|
* Validates a single resource.
|
|
655
|
-
* @param
|
|
656
|
-
* @
|
|
715
|
+
* @param resourceName Resource to validate
|
|
716
|
+
* @param project Project instance to use.
|
|
717
|
+
* @returns validation errors, if any.
|
|
657
718
|
*/
|
|
658
719
|
async validateResource(resourceName, project) {
|
|
659
720
|
try {
|
|
660
|
-
const resource =
|
|
721
|
+
const resource = project.resources.byType(resourceName);
|
|
661
722
|
await resource.validate();
|
|
662
723
|
return '';
|
|
663
724
|
}
|