@cyberismo/data-handler 0.0.8 → 0.0.10
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/command-handler.d.ts +11 -2
- package/dist/command-handler.js +61 -18
- package/dist/command-handler.js.map +1 -1
- package/dist/command-manager.js +8 -8
- package/dist/command-manager.js.map +1 -1
- package/dist/commands/calculate.d.ts +7 -44
- package/dist/commands/calculate.js +8 -389
- package/dist/commands/calculate.js.map +1 -1
- package/dist/commands/create.d.ts +6 -3
- package/dist/commands/create.js +27 -5
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/edit.d.ts +15 -3
- package/dist/commands/edit.js +52 -9
- package/dist/commands/edit.js.map +1 -1
- package/dist/commands/export.d.ts +11 -9
- package/dist/commands/export.js +80 -28
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/import.d.ts +7 -0
- package/dist/commands/import.js +13 -0
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/move.d.ts +11 -12
- package/dist/commands/move.js +12 -13
- package/dist/commands/move.js.map +1 -1
- package/dist/commands/remove.d.ts +1 -3
- package/dist/commands/remove.js +4 -6
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/rename.d.ts +1 -3
- package/dist/commands/rename.js +3 -6
- package/dist/commands/rename.js.map +1 -1
- package/dist/commands/show.d.ts +37 -5
- package/dist/commands/show.js +89 -8
- package/dist/commands/show.js.map +1 -1
- package/dist/commands/transition.d.ts +1 -3
- package/dist/commands/transition.js +3 -5
- package/dist/commands/transition.js.map +1 -1
- package/dist/commands/update.d.ts +5 -1
- package/dist/commands/update.js +7 -1
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/validate.d.ts +7 -0
- package/dist/commands/validate.js +31 -4
- package/dist/commands/validate.js.map +1 -1
- package/dist/containers/card-container.d.ts +6 -0
- package/dist/containers/card-container.js +61 -0
- package/dist/containers/card-container.js.map +1 -1
- package/dist/containers/project/calculation-engine.d.ts +90 -0
- package/dist/containers/project/calculation-engine.js +402 -0
- package/dist/containers/project/calculation-engine.js.map +1 -0
- package/dist/containers/project/resource-collector.js +9 -13
- package/dist/containers/project/resource-collector.js.map +1 -1
- package/dist/containers/project.d.ts +18 -1
- package/dist/containers/project.js +28 -55
- package/dist/containers/project.js.map +1 -1
- package/dist/containers/template.d.ts +5 -0
- package/dist/containers/template.js +9 -0
- package/dist/containers/template.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces/macros.d.ts +4 -2
- package/dist/interfaces/project-interfaces.d.ts +21 -0
- package/dist/interfaces/project-interfaces.js +4 -0
- package/dist/interfaces/project-interfaces.js.map +1 -1
- package/dist/interfaces/resource-interfaces.d.ts +4 -2
- package/dist/interfaces/resource-interfaces.js.map +1 -1
- package/dist/macros/base-macro.d.ts +2 -1
- package/dist/macros/base-macro.js +14 -2
- package/dist/macros/base-macro.js.map +1 -1
- package/dist/macros/common.d.ts +16 -9
- package/dist/macros/common.js +22 -9
- package/dist/macros/common.js.map +1 -1
- package/dist/macros/createCards/index.d.ts +2 -2
- package/dist/macros/createCards/index.js +4 -0
- package/dist/macros/createCards/index.js.map +1 -1
- package/dist/macros/graph/index.d.ts +1 -3
- package/dist/macros/graph/index.js +1 -6
- package/dist/macros/graph/index.js.map +1 -1
- package/dist/macros/image/index.d.ts +39 -0
- package/dist/macros/image/index.js +82 -0
- package/dist/macros/image/index.js.map +1 -0
- package/dist/macros/image/metadata.d.ts +18 -0
- package/dist/macros/image/metadata.js +22 -0
- package/dist/macros/image/metadata.js.map +1 -0
- package/dist/macros/include/index.d.ts +31 -0
- package/dist/macros/include/index.js +94 -0
- package/dist/macros/include/index.js.map +1 -0
- package/dist/macros/include/metadata.d.ts +15 -0
- package/dist/macros/include/metadata.js +19 -0
- package/dist/macros/include/metadata.js.map +1 -0
- package/dist/macros/index.d.ts +33 -31
- package/dist/macros/index.js +142 -71
- package/dist/macros/index.js.map +1 -1
- package/dist/macros/percentage/index.d.ts +28 -0
- package/dist/macros/percentage/index.js +33 -0
- package/dist/macros/percentage/index.js.map +1 -0
- package/dist/macros/percentage/metadata.d.ts +15 -0
- package/dist/macros/percentage/metadata.js +19 -0
- package/dist/macros/percentage/metadata.js.map +1 -0
- package/dist/macros/report/index.d.ts +2 -6
- package/dist/macros/report/index.js +3 -7
- package/dist/macros/report/index.js.map +1 -1
- package/dist/macros/scoreCard/index.d.ts +14 -15
- package/dist/macros/scoreCard/index.js +14 -18
- package/dist/macros/scoreCard/index.js.map +1 -1
- package/dist/macros/vega/index.d.ts +28 -0
- package/dist/macros/vega/index.js +27 -0
- package/dist/macros/vega/index.js.map +1 -0
- package/dist/macros/vega/metadata.d.ts +15 -0
- package/dist/macros/vega/metadata.js +7 -0
- package/dist/macros/vega/metadata.js.map +1 -0
- package/dist/macros/vegalite/index.d.ts +26 -0
- package/dist/macros/vegalite/index.js +24 -0
- package/dist/macros/vegalite/index.js.map +1 -0
- package/dist/macros/vegalite/metadata.d.ts +15 -0
- package/dist/macros/vegalite/metadata.js +7 -0
- package/dist/macros/vegalite/metadata.js.map +1 -0
- package/dist/macros/xref/index.d.ts +26 -0
- package/dist/macros/xref/index.js +53 -0
- package/dist/macros/xref/index.js.map +1 -0
- package/dist/macros/xref/metadata.d.ts +15 -0
- package/dist/macros/xref/metadata.js +19 -0
- package/dist/macros/xref/metadata.js.map +1 -0
- package/dist/module-manager.d.ts +1 -0
- package/dist/module-manager.js +14 -4
- package/dist/module-manager.js.map +1 -1
- package/dist/permissions/action-guard.d.ts +2 -2
- package/dist/permissions/action-guard.js +1 -1
- package/dist/permissions/action-guard.js.map +1 -1
- package/dist/resources/card-type-resource.d.ts +2 -0
- package/dist/resources/card-type-resource.js +63 -0
- package/dist/resources/card-type-resource.js.map +1 -1
- package/dist/resources/file-resource.d.ts +2 -0
- package/dist/resources/file-resource.js +12 -4
- package/dist/resources/file-resource.js.map +1 -1
- package/dist/resources/folder-resource.d.ts +19 -0
- package/dist/resources/folder-resource.js +51 -2
- package/dist/resources/folder-resource.js.map +1 -1
- package/dist/resources/graph-model-resource.js +1 -1
- package/dist/resources/graph-model-resource.js.map +1 -1
- package/dist/resources/graph-view-resource.js +1 -1
- package/dist/resources/graph-view-resource.js.map +1 -1
- package/dist/resources/report-resource.js +1 -1
- package/dist/resources/report-resource.js.map +1 -1
- package/dist/resources/resource-object.d.ts +8 -0
- package/dist/resources/resource-object.js +10 -1
- package/dist/resources/resource-object.js.map +1 -1
- package/dist/resources/template-resource.js +1 -1
- package/dist/resources/template-resource.js.map +1 -1
- package/dist/resources/workflow-resource.d.ts +2 -0
- package/dist/resources/workflow-resource.js +53 -9
- package/dist/resources/workflow-resource.js.map +1 -1
- package/dist/svg/index.d.ts +15 -0
- package/dist/svg/index.js +16 -0
- package/dist/svg/index.js.map +1 -0
- package/dist/svg/lib.d.ts +9 -0
- package/dist/svg/lib.js +26 -0
- package/dist/svg/lib.js.map +1 -0
- package/dist/svg/percentage.d.ts +25 -0
- package/dist/svg/percentage.js +90 -0
- package/dist/svg/percentage.js.map +1 -0
- package/dist/svg/scoreCard.d.ts +19 -0
- package/dist/svg/scoreCard.js +55 -0
- package/dist/svg/scoreCard.js.map +1 -0
- package/dist/types/queries.d.ts +8 -7
- package/dist/types/queries.js.map +1 -1
- package/dist/utils/card-utils.d.ts +6 -0
- package/dist/utils/card-utils.js +12 -0
- package/dist/utils/card-utils.js.map +1 -1
- package/dist/utils/clingo-facts.d.ts +2 -1
- package/dist/utils/clingo-facts.js +19 -2
- package/dist/utils/clingo-facts.js.map +1 -1
- package/dist/utils/clingo-parser.d.ts +1 -0
- package/dist/utils/clingo-parser.js +22 -100
- package/dist/utils/clingo-parser.js.map +1 -1
- package/dist/utils/constants.d.ts +7 -0
- package/dist/utils/constants.js +14 -0
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/csv.js.map +1 -1
- package/dist/utils/report.d.ts +17 -3
- package/dist/utils/report.js +38 -2
- package/dist/utils/report.js.map +1 -1
- package/dist/utils/resource-utils.d.ts +2 -1
- package/dist/utils/resource-utils.js +12 -3
- package/dist/utils/resource-utils.js.map +1 -1
- package/dist/utils/user-preferences.d.ts +1 -11
- package/dist/utils/user-preferences.js +30 -13
- package/dist/utils/user-preferences.js.map +1 -1
- package/dist/utils/validate.d.ts +2 -3
- package/dist/utils/validate.js +2 -2
- package/dist/utils/validate.js.map +1 -1
- package/package.json +8 -6
- package/src/command-handler.ts +96 -17
- package/src/command-manager.ts +8 -8
- package/src/commands/calculate.ts +11 -525
- package/src/commands/create.ts +35 -6
- package/src/commands/edit.ts +94 -11
- package/src/commands/export.ts +104 -31
- package/src/commands/import.ts +16 -0
- package/src/commands/move.ts +12 -15
- package/src/commands/remove.ts +4 -8
- package/src/commands/rename.ts +3 -12
- package/src/commands/show.ts +126 -9
- package/src/commands/transition.ts +3 -7
- package/src/commands/update.ts +6 -0
- package/src/commands/validate.ts +41 -13
- package/src/containers/card-container.ts +74 -0
- package/src/containers/project/calculation-engine.ts +535 -0
- package/src/containers/project/resource-collector.ts +13 -15
- package/src/containers/project.ts +30 -66
- package/src/containers/template.ts +16 -0
- package/src/index.ts +13 -2
- package/src/interfaces/macros.ts +4 -1
- package/src/interfaces/project-interfaces.ts +27 -0
- package/src/interfaces/resource-interfaces.ts +5 -2
- package/src/macros/base-macro.ts +19 -4
- package/src/macros/common.ts +22 -9
- package/src/macros/createCards/index.ts +6 -2
- package/src/macros/graph/index.ts +6 -10
- package/src/macros/image/index.ts +128 -0
- package/src/macros/image/metadata.ts +25 -0
- package/src/macros/include/index.ts +143 -0
- package/src/macros/include/metadata.ts +22 -0
- package/src/macros/index.ts +150 -98
- package/src/macros/percentage/index.ts +50 -0
- package/src/macros/percentage/metadata.ts +22 -0
- package/src/macros/report/index.ts +4 -12
- package/src/macros/scoreCard/index.ts +21 -25
- package/src/macros/vega/index.ts +55 -0
- package/src/macros/vega/metadata.ts +21 -0
- package/src/macros/vegalite/index.ts +46 -0
- package/src/macros/vegalite/metadata.ts +21 -0
- package/src/macros/xref/index.ts +73 -0
- package/src/macros/xref/metadata.ts +22 -0
- package/src/module-manager.ts +15 -5
- package/src/permissions/action-guard.ts +3 -3
- package/src/resources/card-type-resource.ts +100 -0
- package/src/resources/file-resource.ts +16 -4
- package/src/resources/folder-resource.ts +59 -2
- package/src/resources/graph-model-resource.ts +1 -1
- package/src/resources/graph-view-resource.ts +1 -1
- package/src/resources/report-resource.ts +1 -1
- package/src/resources/resource-object.ts +19 -1
- package/src/resources/template-resource.ts +1 -1
- package/src/resources/workflow-resource.ts +68 -13
- package/src/svg/index.ts +15 -0
- package/src/svg/lib.ts +31 -0
- package/src/svg/percentage.ts +97 -0
- package/src/svg/scoreCard.ts +88 -0
- package/src/types/queries.ts +8 -7
- package/src/types/string-pixel-width.d.ts +23 -0
- package/src/utils/card-utils.ts +13 -0
- package/src/utils/clingo-facts.ts +65 -3
- package/src/utils/clingo-parser.ts +31 -144
- package/src/utils/constants.ts +16 -0
- package/src/utils/csv.ts +1 -1
- package/src/utils/report.ts +45 -4
- package/src/utils/resource-utils.ts +12 -2
- package/src/utils/user-preferences.ts +32 -14
- package/src/utils/validate.ts +3 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyberismo/data-handler",
|
|
3
3
|
"description": "Command handler for cards and web service",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.10",
|
|
5
5
|
"author": "sami.merila@cyberismo.com",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
7
7
|
"homepage": "https://github.com/CyberismoCom/cyberismo",
|
|
@@ -24,28 +24,30 @@
|
|
|
24
24
|
"@types/sinon": "^17.0.4",
|
|
25
25
|
"c8": "^10.1.3",
|
|
26
26
|
"pino-pretty": "^13.0.0",
|
|
27
|
-
"sinon": "^
|
|
27
|
+
"sinon": "^21.0.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@asciidoctor/core": "^3.0.4",
|
|
31
31
|
"@viz-js/viz": "^3.12.0",
|
|
32
32
|
"async-mutex": "^0.5.0",
|
|
33
|
-
"csv-parse": "^
|
|
33
|
+
"csv-parse": "^6.1.0",
|
|
34
34
|
"directory-schema-validator": "^1.0.17",
|
|
35
35
|
"dompurify": "^3.2.6",
|
|
36
36
|
"email-validator": "^2.0.4",
|
|
37
37
|
"handlebars": "^4.7.8",
|
|
38
|
-
"isomorphic-git": "^1.30.2",
|
|
39
38
|
"jsdom": "^26.1.0",
|
|
40
39
|
"json-schema": "^0.4.0",
|
|
41
40
|
"jsonschema": "^1.5.0",
|
|
42
41
|
"mime-types": "^3.0.1",
|
|
43
42
|
"pino": "^9.7.0",
|
|
44
43
|
"simple-git": "^3.2.0",
|
|
44
|
+
"string-pixel-width": "^1.11.0",
|
|
45
45
|
"tslib": "^2.6.2",
|
|
46
|
+
"vega": "^6.1.2",
|
|
47
|
+
"vega-lite": "^6.2.0",
|
|
46
48
|
"write-json-file": "^6.0.0",
|
|
47
|
-
"@cyberismo/
|
|
48
|
-
"@cyberismo/
|
|
49
|
+
"@cyberismo/assets": "0.0.10",
|
|
50
|
+
"@cyberismo/node-clingo": "1.1.5"
|
|
49
51
|
},
|
|
50
52
|
"type": "module",
|
|
51
53
|
"files": [
|
package/src/command-handler.ts
CHANGED
|
@@ -45,6 +45,7 @@ import { readJsonFile } from './utils/json.js';
|
|
|
45
45
|
import { resourceName } from './utils/resource-utils.js';
|
|
46
46
|
|
|
47
47
|
import { type Level } from 'pino';
|
|
48
|
+
import { type Context } from './interfaces/project-interfaces.js';
|
|
48
49
|
|
|
49
50
|
// Generic options interface
|
|
50
51
|
export interface CardsOptions {
|
|
@@ -55,6 +56,14 @@ export interface CardsOptions {
|
|
|
55
56
|
repeat?: number;
|
|
56
57
|
showUse?: boolean;
|
|
57
58
|
logLevel?: Level;
|
|
59
|
+
context?: Context;
|
|
60
|
+
recursive?: boolean;
|
|
61
|
+
title?: string;
|
|
62
|
+
name?: string;
|
|
63
|
+
date?: string;
|
|
64
|
+
version?: string;
|
|
65
|
+
revremark?: string;
|
|
66
|
+
mappingFile?: string;
|
|
58
67
|
}
|
|
59
68
|
|
|
60
69
|
// Commands that this class supports.
|
|
@@ -82,8 +91,8 @@ export enum Cmd {
|
|
|
82
91
|
// To what format the content can be exported to.
|
|
83
92
|
export enum ExportFormats {
|
|
84
93
|
adoc = 'adoc',
|
|
85
|
-
html = 'html',
|
|
86
94
|
site = 'site',
|
|
95
|
+
pdf = 'pdf',
|
|
87
96
|
}
|
|
88
97
|
|
|
89
98
|
export { CommandManager } from './command-manager.js';
|
|
@@ -195,10 +204,10 @@ export class Commands {
|
|
|
195
204
|
return { statusCode: 400, message: 'File path is missing' };
|
|
196
205
|
}
|
|
197
206
|
await this.generateLogicProgram();
|
|
198
|
-
return this.runLogicProgram(cardKey);
|
|
207
|
+
return this.runLogicProgram(cardKey, options.context || 'localApp');
|
|
199
208
|
}
|
|
200
209
|
if (command === 'generate') {
|
|
201
|
-
return this.generateLogicProgram(
|
|
210
|
+
return this.generateLogicProgram();
|
|
202
211
|
}
|
|
203
212
|
} else if (command === Cmd.create) {
|
|
204
213
|
const [type, ...rest] = args;
|
|
@@ -266,7 +275,12 @@ export class Commands {
|
|
|
266
275
|
await this.commands?.editCmd.editCard(cardKey);
|
|
267
276
|
} else if (command === Cmd.export) {
|
|
268
277
|
const [format, output, cardKey] = args;
|
|
269
|
-
await this.export(
|
|
278
|
+
return await this.export(
|
|
279
|
+
output,
|
|
280
|
+
format as ExportFormats,
|
|
281
|
+
cardKey,
|
|
282
|
+
options,
|
|
283
|
+
);
|
|
270
284
|
} else if (command === Cmd.import) {
|
|
271
285
|
const target = args.splice(0, 1)[0];
|
|
272
286
|
if (target === 'module') {
|
|
@@ -322,7 +336,11 @@ export class Commands {
|
|
|
322
336
|
);
|
|
323
337
|
} else if (command === Cmd.report) {
|
|
324
338
|
const [parameters, outputPath] = args;
|
|
325
|
-
return this.runReport(
|
|
339
|
+
return this.runReport(
|
|
340
|
+
parameters,
|
|
341
|
+
options.context || 'localApp',
|
|
342
|
+
outputPath,
|
|
343
|
+
);
|
|
326
344
|
} else if (command === Cmd.start) {
|
|
327
345
|
return this.startApp(options.forceStart);
|
|
328
346
|
} else if (command === Cmd.transition) {
|
|
@@ -339,15 +357,61 @@ export class Commands {
|
|
|
339
357
|
parsedValue = value;
|
|
340
358
|
}
|
|
341
359
|
|
|
360
|
+
// Handle mapping file for workflow changes
|
|
361
|
+
let mappingTable: { stateMapping: Record<string, string> } | undefined;
|
|
362
|
+
if (
|
|
363
|
+
options.mappingFile &&
|
|
364
|
+
operation === 'change' &&
|
|
365
|
+
key === 'workflow'
|
|
366
|
+
) {
|
|
367
|
+
try {
|
|
368
|
+
const mappingData = await readJsonFile(
|
|
369
|
+
resolveTilde(options.mappingFile),
|
|
370
|
+
);
|
|
371
|
+
if (
|
|
372
|
+
mappingData &&
|
|
373
|
+
typeof mappingData === 'object' &&
|
|
374
|
+
'stateMapping' in mappingData
|
|
375
|
+
) {
|
|
376
|
+
mappingTable = mappingData as {
|
|
377
|
+
stateMapping: Record<string, string>;
|
|
378
|
+
};
|
|
379
|
+
} else {
|
|
380
|
+
throw new Error(
|
|
381
|
+
'Mapping file must contain a "stateMapping" object',
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
} catch (error) {
|
|
385
|
+
throw new Error(
|
|
386
|
+
`Failed to read mapping file: ${errorFunction(error)}`,
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
let parsedNewValue = newValue;
|
|
392
|
+
if (newValue) {
|
|
393
|
+
try {
|
|
394
|
+
parsedNewValue = JSON.parse(newValue);
|
|
395
|
+
} catch {
|
|
396
|
+
parsedNewValue = newValue;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
342
400
|
await this.commands?.updateCmd.updateValue(
|
|
343
401
|
resource,
|
|
344
402
|
operation as UpdateOperations,
|
|
345
403
|
key,
|
|
346
404
|
parsedValue,
|
|
347
|
-
|
|
405
|
+
parsedNewValue,
|
|
406
|
+
mappingTable,
|
|
348
407
|
);
|
|
349
408
|
} else if (command === Cmd.updateModules) {
|
|
350
|
-
|
|
409
|
+
const [module] = args;
|
|
410
|
+
if (module) {
|
|
411
|
+
await this.commands?.importCmd.updateModule(module, credentials);
|
|
412
|
+
} else {
|
|
413
|
+
await this.commands?.importCmd.updateAllModules(credentials);
|
|
414
|
+
}
|
|
351
415
|
} else if (command === Cmd.validate) {
|
|
352
416
|
return this.validate();
|
|
353
417
|
} else {
|
|
@@ -446,31 +510,37 @@ export class Commands {
|
|
|
446
510
|
destination: string = 'output',
|
|
447
511
|
format: ExportFormats,
|
|
448
512
|
parentCardKey?: string,
|
|
513
|
+
pdfOptions?: CardsOptions,
|
|
449
514
|
): Promise<requestStatus> {
|
|
450
515
|
if (!this.commands) {
|
|
451
516
|
return { statusCode: 500 };
|
|
452
517
|
}
|
|
453
518
|
process.env.EXPORT_FORMAT = format;
|
|
454
519
|
let message = '';
|
|
455
|
-
if (format === '
|
|
520
|
+
if (format === 'pdf') {
|
|
521
|
+
const options = {
|
|
522
|
+
title: pdfOptions?.title || 'Title',
|
|
523
|
+
name: pdfOptions?.name || 'Name',
|
|
524
|
+
version: pdfOptions?.version || '1.0.0',
|
|
525
|
+
revremark: pdfOptions?.revremark || 'Initial version',
|
|
526
|
+
cardKey: parentCardKey,
|
|
527
|
+
date: pdfOptions?.date ? new Date(pdfOptions.date) : new Date(),
|
|
528
|
+
};
|
|
529
|
+
message = await this.commands?.exportCmd.exportPdf(destination, options);
|
|
530
|
+
} else {
|
|
456
531
|
message = await this.commands?.exportCmd.exportToADoc(
|
|
457
532
|
destination,
|
|
458
533
|
parentCardKey,
|
|
459
534
|
);
|
|
460
|
-
} else if (format === 'html') {
|
|
461
|
-
message = await this.commands?.exportCmd.exportToHTML(
|
|
462
|
-
destination,
|
|
463
|
-
parentCardKey,
|
|
464
|
-
);
|
|
465
535
|
}
|
|
466
536
|
process.env.EXPORT_FORMAT = '';
|
|
467
537
|
return { statusCode: 200, message: message };
|
|
468
538
|
}
|
|
469
539
|
|
|
470
540
|
// Generates logic program for a card.
|
|
471
|
-
private async generateLogicProgram(
|
|
541
|
+
private async generateLogicProgram(): Promise<requestStatus> {
|
|
472
542
|
try {
|
|
473
|
-
await this.commands?.calculateCmd.generate(
|
|
543
|
+
await this.commands?.calculateCmd.generate();
|
|
474
544
|
return { statusCode: 200 };
|
|
475
545
|
} catch (e) {
|
|
476
546
|
return { statusCode: 500, message: errorFunction(e) };
|
|
@@ -517,10 +587,14 @@ export class Commands {
|
|
|
517
587
|
}
|
|
518
588
|
|
|
519
589
|
// Runs a given logic program along with the query-language
|
|
520
|
-
private async runLogicProgram(
|
|
590
|
+
private async runLogicProgram(
|
|
591
|
+
filePath: string,
|
|
592
|
+
context: Context,
|
|
593
|
+
): Promise<requestStatus> {
|
|
521
594
|
try {
|
|
522
595
|
const res = await this.commands?.calculateCmd.runLogicProgram(
|
|
523
596
|
readFileSync(filePath, 'utf-8'),
|
|
597
|
+
context,
|
|
524
598
|
);
|
|
525
599
|
return {
|
|
526
600
|
statusCode: 200,
|
|
@@ -532,7 +606,11 @@ export class Commands {
|
|
|
532
606
|
}
|
|
533
607
|
|
|
534
608
|
// Runs a report using Handlebars and the provided parameters.
|
|
535
|
-
private async runReport(
|
|
609
|
+
private async runReport(
|
|
610
|
+
parametersPath: string,
|
|
611
|
+
context: Context,
|
|
612
|
+
outputPath?: string,
|
|
613
|
+
) {
|
|
536
614
|
const parametersFile = await readJsonFile(parametersPath);
|
|
537
615
|
|
|
538
616
|
// Validate the parameters file.
|
|
@@ -565,6 +643,7 @@ export class Commands {
|
|
|
565
643
|
name,
|
|
566
644
|
parameters.cardKey,
|
|
567
645
|
parameters,
|
|
646
|
+
context,
|
|
568
647
|
outputPath,
|
|
569
648
|
);
|
|
570
649
|
} catch (e) {
|
package/src/command-manager.ts
CHANGED
|
@@ -59,15 +59,15 @@ export class CommandManager {
|
|
|
59
59
|
this.validateCmd = Validate.getInstance();
|
|
60
60
|
|
|
61
61
|
this.calculateCmd = new Calculate(this.project);
|
|
62
|
-
this.showCmd = new Show(this.project
|
|
63
|
-
this.createCmd = new Create(this.project
|
|
64
|
-
this.editCmd = new Edit(this.project
|
|
65
|
-
this.exportCmd = new Export(this.project, this.
|
|
62
|
+
this.showCmd = new Show(this.project);
|
|
63
|
+
this.createCmd = new Create(this.project);
|
|
64
|
+
this.editCmd = new Edit(this.project);
|
|
65
|
+
this.exportCmd = new Export(this.project, this.showCmd);
|
|
66
66
|
this.importCmd = new Import(this.project, this.createCmd);
|
|
67
|
-
this.moveCmd = new Move(this.project
|
|
68
|
-
this.removeCmd = new Remove(this.project
|
|
69
|
-
this.renameCmd = new Rename(this.project
|
|
70
|
-
this.transitionCmd = new Transition(this.project
|
|
67
|
+
this.moveCmd = new Move(this.project);
|
|
68
|
+
this.removeCmd = new Remove(this.project);
|
|
69
|
+
this.renameCmd = new Rename(this.project);
|
|
70
|
+
this.transitionCmd = new Transition(this.project);
|
|
71
71
|
this.updateCmd = new Update(this.project);
|
|
72
72
|
this.pathHandler = new ProjectPaths(path);
|
|
73
73
|
}
|