@cyberismo/data-handler 0.0.20 → 0.0.22
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.js +13 -24
- package/dist/command-handler.js.map +1 -1
- package/dist/command-manager.d.ts +21 -6
- package/dist/command-manager.js +34 -32
- package/dist/command-manager.js.map +1 -1
- package/dist/commands/calculate.js +101 -46
- package/dist/commands/calculate.js.map +1 -1
- package/dist/commands/create.js +420 -320
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/edit.js +117 -68
- package/dist/commands/edit.js.map +1 -1
- package/dist/commands/export.js +301 -252
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/fetch.js +205 -156
- package/dist/commands/fetch.js.map +1 -1
- package/dist/commands/import.js +189 -134
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/migrate.js +91 -45
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/move.js +347 -267
- package/dist/commands/move.js.map +1 -1
- package/dist/commands/remove.d.ts +1 -0
- package/dist/commands/remove.js +202 -135
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/rename.js +233 -187
- package/dist/commands/rename.js.map +1 -1
- package/dist/commands/show.d.ts +8 -8
- package/dist/commands/show.js +477 -372
- package/dist/commands/show.js.map +1 -1
- package/dist/commands/transition.js +119 -73
- package/dist/commands/transition.js.map +1 -1
- package/dist/commands/update.js +8 -3
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/validate.js +1 -1
- package/dist/commands/validate.js.map +1 -1
- package/dist/containers/project/calculation-engine.js +0 -1
- package/dist/containers/project/calculation-engine.js.map +1 -1
- package/dist/containers/project/card-cache.js +1 -1
- package/dist/containers/project/card-cache.js.map +1 -1
- package/dist/containers/project.d.ts +16 -0
- package/dist/containers/project.js +59 -1
- package/dist/containers/project.js.map +1 -1
- package/dist/containers/template.js +1 -1
- package/dist/containers/template.js.map +1 -1
- package/dist/interfaces/command-options.d.ts +1 -0
- package/dist/interfaces/resource-interfaces.d.ts +5 -12
- package/dist/interfaces/resource-interfaces.js.map +1 -1
- package/dist/macros/base-macro.js +1 -1
- package/dist/macros/base-macro.js.map +1 -1
- package/dist/macros/graph/index.js +3 -1
- package/dist/macros/graph/index.js.map +1 -1
- package/dist/macros/include/index.js +16 -1
- package/dist/macros/include/index.js.map +1 -1
- package/dist/macros/include/types.d.ts +15 -12
- package/dist/macros/index.js +4 -1
- package/dist/macros/index.js.map +1 -1
- package/dist/macros/report/index.js +1 -1
- package/dist/macros/report/index.js.map +1 -1
- package/dist/module-manager.js +5 -3
- package/dist/module-manager.js.map +1 -1
- package/dist/project-settings.js +2 -2
- package/dist/project-settings.js.map +1 -1
- package/dist/resources/card-type-resource.js +1 -1
- package/dist/resources/card-type-resource.js.map +1 -1
- package/dist/resources/create-defaults.js +0 -1
- package/dist/resources/create-defaults.js.map +1 -1
- package/dist/resources/field-type-resource.js +2 -5
- package/dist/resources/field-type-resource.js.map +1 -1
- package/dist/resources/file-resource.js +4 -1
- package/dist/resources/file-resource.js.map +1 -1
- package/dist/resources/folder-resource.d.ts +1 -1
- package/dist/resources/folder-resource.js +4 -1
- package/dist/resources/folder-resource.js.map +1 -1
- package/dist/resources/graph-model-resource.d.ts +1 -8
- package/dist/resources/graph-model-resource.js +0 -14
- package/dist/resources/graph-model-resource.js.map +1 -1
- package/dist/resources/graph-view-resource.d.ts +1 -8
- package/dist/resources/graph-view-resource.js +0 -14
- package/dist/resources/graph-view-resource.js.map +1 -1
- package/dist/resources/link-type-resource.js +1 -1
- package/dist/resources/link-type-resource.js.map +1 -1
- package/dist/resources/report-resource.d.ts +1 -8
- package/dist/resources/report-resource.js +0 -14
- package/dist/resources/report-resource.js.map +1 -1
- package/dist/resources/resource-object.d.ts +11 -1
- package/dist/resources/resource-object.js +19 -2
- package/dist/resources/resource-object.js.map +1 -1
- package/dist/resources/template-resource.d.ts +1 -9
- package/dist/resources/template-resource.js +0 -15
- package/dist/resources/template-resource.js.map +1 -1
- package/dist/resources/workflow-resource.d.ts +6 -0
- package/dist/resources/workflow-resource.js +29 -13
- package/dist/resources/workflow-resource.js.map +1 -1
- package/dist/utils/card-utils.js +1 -1
- package/dist/utils/card-utils.js.map +1 -1
- package/dist/utils/commit-context.d.ts +23 -0
- package/dist/utils/commit-context.js +30 -0
- package/dist/utils/commit-context.js.map +1 -0
- package/dist/utils/csv.d.ts +8 -0
- package/dist/utils/csv.js +11 -0
- package/dist/utils/csv.js.map +1 -1
- package/dist/utils/file-utils.js +3 -1
- package/dist/utils/file-utils.js.map +1 -1
- package/dist/utils/git-manager.d.ts +29 -0
- package/dist/utils/git-manager.js +76 -0
- package/dist/utils/git-manager.js.map +1 -0
- package/dist/utils/handlebars-helpers.d.ts +22 -0
- package/dist/utils/handlebars-helpers.js +78 -0
- package/dist/utils/handlebars-helpers.js.map +1 -0
- package/dist/utils/json.d.ts +17 -10
- package/dist/utils/json.js +27 -14
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/log-utils.d.ts +7 -2
- package/dist/utils/log-utils.js +28 -3
- package/dist/utils/log-utils.js.map +1 -1
- package/dist/utils/report.d.ts +0 -19
- package/dist/utils/report.js +4 -63
- package/dist/utils/report.js.map +1 -1
- package/dist/utils/rw-lock.d.ts +71 -0
- package/dist/utils/rw-lock.js +220 -0
- package/dist/utils/rw-lock.js.map +1 -0
- package/dist/utils/user-preferences.js +3 -3
- package/dist/utils/user-preferences.js.map +1 -1
- package/package.json +10 -10
- package/src/command-handler.ts +14 -22
- package/src/command-manager.ts +43 -37
- package/src/commands/calculate.ts +8 -1
- package/src/commands/create.ts +39 -6
- package/src/commands/edit.ts +3 -0
- package/src/commands/export.ts +8 -2
- package/src/commands/fetch.ts +3 -0
- package/src/commands/import.ts +5 -0
- package/src/commands/migrate.ts +2 -0
- package/src/commands/move.ts +34 -0
- package/src/commands/remove.ts +24 -2
- package/src/commands/rename.ts +2 -0
- package/src/commands/show.ts +63 -34
- package/src/commands/transition.ts +2 -0
- package/src/commands/update.ts +9 -3
- package/src/commands/validate.ts +1 -1
- package/src/containers/project/calculation-engine.ts +0 -1
- package/src/containers/project/card-cache.ts +1 -0
- package/src/containers/project.ts +75 -1
- package/src/containers/template.ts +1 -1
- package/src/interfaces/command-options.ts +1 -0
- package/src/interfaces/resource-interfaces.ts +5 -12
- package/src/macros/base-macro.ts +1 -1
- package/src/macros/graph/index.ts +3 -0
- package/src/macros/include/index.ts +19 -1
- package/src/macros/include/types.ts +15 -12
- package/src/macros/index.ts +4 -1
- package/src/macros/report/index.ts +1 -0
- package/src/module-manager.ts +5 -2
- package/src/project-settings.ts +2 -1
- package/src/resources/card-type-resource.ts +1 -1
- package/src/resources/create-defaults.ts +0 -1
- package/src/resources/field-type-resource.ts +2 -4
- package/src/resources/file-resource.ts +3 -1
- package/src/resources/folder-resource.ts +7 -2
- package/src/resources/graph-model-resource.ts +1 -25
- package/src/resources/graph-view-resource.ts +1 -25
- package/src/resources/link-type-resource.ts +1 -1
- package/src/resources/report-resource.ts +1 -25
- package/src/resources/resource-object.ts +22 -1
- package/src/resources/template-resource.ts +0 -23
- package/src/resources/workflow-resource.ts +45 -16
- package/src/utils/card-utils.ts +1 -1
- package/src/utils/commit-context.ts +45 -0
- package/src/utils/csv.ts +12 -0
- package/src/utils/file-utils.ts +3 -1
- package/src/utils/git-manager.ts +87 -0
- package/src/utils/handlebars-helpers.ts +95 -0
- package/src/utils/json.ts +29 -15
- package/src/utils/log-utils.ts +33 -4
- package/src/utils/report.ts +8 -74
- package/src/utils/rw-lock.ts +279 -0
- package/src/utils/user-preferences.ts +3 -0
package/dist/utils/csv.d.ts
CHANGED
|
@@ -10,6 +10,14 @@
|
|
|
10
10
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
11
11
|
*/
|
|
12
12
|
import type { CSVRowRaw } from '../interfaces/project-interfaces.js';
|
|
13
|
+
/**
|
|
14
|
+
* Escapes a string for use as a CSV field.
|
|
15
|
+
* Escapes double quotes by doubling them. The caller is responsible for
|
|
16
|
+
* wrapping the result in quotes.
|
|
17
|
+
* @param str The string to escape
|
|
18
|
+
* @returns The escaped string (without surrounding quotes)
|
|
19
|
+
*/
|
|
20
|
+
export declare function escapeCsvField(str: string): string;
|
|
13
21
|
/**
|
|
14
22
|
* Reads a CSV file and returns its content as an array of objects.
|
|
15
23
|
* @param file Path to the CSV file.
|
package/dist/utils/csv.js
CHANGED
|
@@ -11,6 +11,17 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { readFile } from 'node:fs/promises';
|
|
13
13
|
import { parse } from 'csv-parse/sync';
|
|
14
|
+
/**
|
|
15
|
+
* Escapes a string for use as a CSV field.
|
|
16
|
+
* Escapes double quotes by doubling them. The caller is responsible for
|
|
17
|
+
* wrapping the result in quotes.
|
|
18
|
+
* @param str The string to escape
|
|
19
|
+
* @returns The escaped string (without surrounding quotes)
|
|
20
|
+
*/
|
|
21
|
+
export function escapeCsvField(str) {
|
|
22
|
+
// Escape double quotes by doubling them
|
|
23
|
+
return str.replace(/"/g, '""');
|
|
24
|
+
}
|
|
14
25
|
/**
|
|
15
26
|
* Reads a CSV file and returns its content as an array of objects.
|
|
16
27
|
* @param file Path to the CSV file.
|
package/dist/utils/csv.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csv.js","sourceRoot":"","sources":["../../src/utils/csv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAY;IAC5C,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE;QACnC,QAAQ,EAAE,OAAO;KAClB,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE;QAC7B,GAAG,EAAE,IAAI;KACV,CAAC,CAAC;IAEH,IAAI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
|
return stats.bavail * stats.bsize;
|
|
27
27
|
}
|
|
28
28
|
catch (error) {
|
|
29
|
-
throw new Error(`Failed to check available disk space: ${error}
|
|
29
|
+
throw new Error(`Failed to check available disk space: ${error}`, {
|
|
30
|
+
cause: error,
|
|
31
|
+
});
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-utils.js","sourceRoot":"","sources":["../../src/utils/file-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;EAYE;AAEF,OAAO,EACL,QAAQ,EACR,KAAK,EACL,OAAO,EACP,EAAE,EACF,IAAI,EACJ,MAAM,EACN,MAAM,EACN,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAY;IAC/C,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;QACjC,OAAO,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,yCAAyC,KAAK,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"file-utils.js","sourceRoot":"","sources":["../../src/utils/file-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;EAYE;AAEF,OAAO,EACL,QAAQ,EACR,KAAK,EACL,OAAO,EACP,EAAE,EACF,IAAI,EACJ,MAAM,EACN,MAAM,EACN,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,WAAW,EAA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,IAAqC,EACrC,OAAyC;IAEzC,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9B,MAAM,KAAK,CAAC,GAAG,EAAE;QACf,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;IACH,OAAO,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2026
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU Affero General Public License version 3 as published by
|
|
6
|
+
the Free Software Foundation. This program is distributed in the hope that it
|
|
7
|
+
will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
8
|
+
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
9
|
+
See the GNU Affero General Public License for more details.
|
|
10
|
+
You should have received a copy of the GNU Affero General Public
|
|
11
|
+
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
|
+
*/
|
|
13
|
+
export declare class GitManager {
|
|
14
|
+
private git;
|
|
15
|
+
private logger;
|
|
16
|
+
constructor(projectPath: string);
|
|
17
|
+
/** Ensure the project is a git repo. Idempotent. */
|
|
18
|
+
initialize(author?: {
|
|
19
|
+
name: string;
|
|
20
|
+
email: string;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
/** Commit current changes (cardRoot + .cards). */
|
|
23
|
+
commit(message?: string, author?: {
|
|
24
|
+
name: string;
|
|
25
|
+
email: string;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
/** Rollback: restore cardRoot and .cards to last committed state. */
|
|
28
|
+
rollback(): Promise<void>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2026
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU Affero General Public License version 3 as published by
|
|
6
|
+
the Free Software Foundation. This program is distributed in the hope that it
|
|
7
|
+
will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
8
|
+
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
9
|
+
See the GNU Affero General Public License for more details.
|
|
10
|
+
You should have received a copy of the GNU Affero General Public
|
|
11
|
+
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
|
+
*/
|
|
13
|
+
import { simpleGit } from 'simple-git';
|
|
14
|
+
import { getChildLogger } from './log-utils.js';
|
|
15
|
+
export class GitManager {
|
|
16
|
+
git;
|
|
17
|
+
logger = getChildLogger({ module: 'GitManager' });
|
|
18
|
+
constructor(projectPath) {
|
|
19
|
+
this.git = simpleGit(projectPath, {
|
|
20
|
+
config: ['user.name=Cyberismo Bot', 'user.email=bot@cyberismo.com'],
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/** Ensure the project is a git repo. Idempotent. */
|
|
24
|
+
async initialize(author) {
|
|
25
|
+
const isRepo = await this.git.checkIsRepo();
|
|
26
|
+
if (!isRepo) {
|
|
27
|
+
await this.git.init();
|
|
28
|
+
// Initial commit so rollback has a baseline
|
|
29
|
+
await this.git.add('.');
|
|
30
|
+
const commitOpts = {
|
|
31
|
+
'--allow-empty': null,
|
|
32
|
+
};
|
|
33
|
+
if (author) {
|
|
34
|
+
commitOpts['--author'] = `${author.name} <${author.email}>`;
|
|
35
|
+
}
|
|
36
|
+
await this.git.commit('Initial commit', undefined, commitOpts);
|
|
37
|
+
this.logger.info('New repo created with baseline commit');
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.logger.debug('Repo already exists');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Commit current changes (cardRoot + .cards). */
|
|
44
|
+
async commit(message = 'Autocommit', author) {
|
|
45
|
+
// Stage only the directories we care about
|
|
46
|
+
this.logger.debug('Staging changes');
|
|
47
|
+
await this.git.add(['cardRoot', '.cards']);
|
|
48
|
+
// Check if there's anything to commit
|
|
49
|
+
const status = await this.git.status();
|
|
50
|
+
if (status.staged.length === 0) {
|
|
51
|
+
this.logger.debug('Nothing to commit, skipping');
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
this.logger.info({ message, stagedFiles: status.staged.length }, 'Committing changes');
|
|
55
|
+
const commitOpts = {};
|
|
56
|
+
if (author) {
|
|
57
|
+
commitOpts['--author'] = `${author.name} <${author.email}>`;
|
|
58
|
+
}
|
|
59
|
+
await this.git.commit(message, undefined, commitOpts);
|
|
60
|
+
}
|
|
61
|
+
/** Rollback: restore cardRoot and .cards to last committed state. */
|
|
62
|
+
async rollback() {
|
|
63
|
+
this.logger.info('Rollback starting');
|
|
64
|
+
// Restore modified tracked files (ignore errors if paths have no tracked content)
|
|
65
|
+
try {
|
|
66
|
+
await this.git.checkout(['--', 'cardRoot', '.cards']);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
this.logger.debug('No tracked files to restore');
|
|
70
|
+
}
|
|
71
|
+
// Remove new untracked files created during the failed write
|
|
72
|
+
await this.git.clean('f', ['-d', 'cardRoot', '.cards']);
|
|
73
|
+
this.logger.info('Rollback completed');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=git-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-manager.js","sourceRoot":"","sources":["../../src/utils/git-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,OAAO,EAAE,SAAS,EAAkB,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,OAAO,UAAU;IACb,GAAG,CAAY;IACf,MAAM,GAAG,cAAc,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IAE1D,YAAY,WAAmB;QAC7B,I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free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
|
|
6
|
+
|
|
7
|
+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
8
|
+
|
|
9
|
+
You should have received a copy of the GNU Affero General Public
|
|
10
|
+
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
11
|
+
*/
|
|
12
|
+
import type Handlebars from 'handlebars';
|
|
13
|
+
/**
|
|
14
|
+
* Registers comparison helpers (eq and ne) with a Handlebars instance
|
|
15
|
+
* @param instance handlebars instance
|
|
16
|
+
*/
|
|
17
|
+
export declare function registerComparisonHelpers(instance: typeof Handlebars): void;
|
|
18
|
+
/**
|
|
19
|
+
* Registers report-specific helpers with a Handlebars instance
|
|
20
|
+
* @param instance handlebars instance
|
|
21
|
+
*/
|
|
22
|
+
export declare function registerReportHelpers(instance: typeof Handlebars): void;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { escapeJsonString } from './json.js';
|
|
2
|
+
import { escapeCsvField } from './csv.js';
|
|
3
|
+
import { resourceName } from './resource-utils.js';
|
|
4
|
+
/**
|
|
5
|
+
* Formats a value from a logic program for use in graphviz
|
|
6
|
+
* @param value - The value to format
|
|
7
|
+
* @returns The formatted value
|
|
8
|
+
*/
|
|
9
|
+
function formatAttributeValue(value) {
|
|
10
|
+
if (!value) {
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
// value is an html-like string
|
|
14
|
+
if (value.length > 1 && value.startsWith('<') && value.endsWith('>')) {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
// value is a normal string and needs to be wrapped in quotes
|
|
18
|
+
return `"${value}"`;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Checks if a field is a custom field
|
|
22
|
+
* @param field - The field to check
|
|
23
|
+
* @returns True if the field is a custom field, false otherwise
|
|
24
|
+
*/
|
|
25
|
+
function isCustomField(field) {
|
|
26
|
+
try {
|
|
27
|
+
const { type } = resourceName(field, true);
|
|
28
|
+
return type === 'fieldTypes';
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Formats a value for display in a report
|
|
36
|
+
* @param value - The value to format
|
|
37
|
+
* @returns The formatted value
|
|
38
|
+
*/
|
|
39
|
+
function formatValue(value) {
|
|
40
|
+
if (typeof value === 'object') {
|
|
41
|
+
if (Array.isArray(value)) {
|
|
42
|
+
return value.map((v) => formatValue(v)).join(', ');
|
|
43
|
+
}
|
|
44
|
+
if (value != null &&
|
|
45
|
+
'displayValue' in value &&
|
|
46
|
+
typeof value.displayValue === 'string') {
|
|
47
|
+
return value.displayValue;
|
|
48
|
+
}
|
|
49
|
+
if (value != null && 'value' in value && typeof value.value === 'string') {
|
|
50
|
+
return formatValue(value.value);
|
|
51
|
+
}
|
|
52
|
+
return JSON.stringify(value, null, 2);
|
|
53
|
+
}
|
|
54
|
+
if (typeof value === 'boolean') {
|
|
55
|
+
return value ? 'Yes' : 'No';
|
|
56
|
+
}
|
|
57
|
+
return value?.toString() ?? '';
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Registers comparison helpers (eq and ne) with a Handlebars instance
|
|
61
|
+
* @param instance handlebars instance
|
|
62
|
+
*/
|
|
63
|
+
export function registerComparisonHelpers(instance) {
|
|
64
|
+
instance.registerHelper('eq', (a, b) => a === b);
|
|
65
|
+
instance.registerHelper('ne', (a, b) => a !== b);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Registers report-specific helpers with a Handlebars instance
|
|
69
|
+
* @param instance handlebars instance
|
|
70
|
+
*/
|
|
71
|
+
export function registerReportHelpers(instance) {
|
|
72
|
+
instance.registerHelper('formatAttributeValue', formatAttributeValue);
|
|
73
|
+
instance.registerHelper('isCustomField', isCustomField);
|
|
74
|
+
instance.registerHelper('formatValue', formatValue);
|
|
75
|
+
instance.registerHelper('jsonEscape', escapeJsonString);
|
|
76
|
+
instance.registerHelper('csvEscape', escapeCsvField);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=handlebars-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlebars-helpers.js","sourceRoot":"","sources":["../../src/utils/handlebars-helpers.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD;;;;GAIG;AACH,SAAS,oBAAoB,CAAC,KAAc;IAC1C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,+BAA+B;IAC/B,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACrE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,6DAA6D;IAC7D,OAAO,IAAI,KAAK,GAAG,CAAC;AACtB,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa,CAAC,KAAa;IAClC,IAAI,CAAC;QACH,MAAM,EAAE,IAAI,EAAE,GAAG,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC3C,OAAO,IAAI,KAAK,YAAY,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAA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,QAAQ,CAAC,cAAc,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IACpD,QAAQ,CAAC,cAAc,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IACxD,QAAQ,CAAC,cAAc,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;AACvD,CAAC"}
|
package/dist/utils/json.d.ts
CHANGED
|
@@ -12,6 +12,23 @@
|
|
|
12
12
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
13
13
|
*/
|
|
14
14
|
import { type FileHandle } from 'node:fs/promises';
|
|
15
|
+
/**
|
|
16
|
+
* Escapes a string for use as a JSON string value.
|
|
17
|
+
* Escapes double quotes, backslashes, and control characters.
|
|
18
|
+
* @param content The string to escape
|
|
19
|
+
* @returns The escaped string suitable for use in JSON
|
|
20
|
+
*/
|
|
21
|
+
export declare function escapeJsonString(content: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Format an object with JSON.stringify
|
|
24
|
+
*
|
|
25
|
+
* The purpose of this function is to format the JSON output in a centralised function
|
|
26
|
+
* so that the format can be controlled in a single location.
|
|
27
|
+
*
|
|
28
|
+
* @param json JSON object to format.
|
|
29
|
+
* @returns Formatted JSON string
|
|
30
|
+
*/
|
|
31
|
+
export declare function formatJson(json: object): string;
|
|
15
32
|
/**
|
|
16
33
|
* Handles reading of a JSON file.
|
|
17
34
|
* @param file file name (and path) to read.
|
|
@@ -41,16 +58,6 @@ export declare function readADocFileSync(file: string): string;
|
|
|
41
58
|
* @returns JSON object with values trimmed for leading or trailing white space.
|
|
42
59
|
*/
|
|
43
60
|
export declare function trimReplacer(_: string, value: unknown): unknown;
|
|
44
|
-
/**
|
|
45
|
-
* Format an object with JSON.stringify
|
|
46
|
-
*
|
|
47
|
-
* The purpose of this function is to format the JSON output in a centralised function
|
|
48
|
-
* so that the format can be controlled in a single location.
|
|
49
|
-
*
|
|
50
|
-
* @param json JSON object to format.
|
|
51
|
-
* @returns Formatted JSON string
|
|
52
|
-
*/
|
|
53
|
-
export declare function formatJson(json: object): string;
|
|
54
61
|
/**
|
|
55
62
|
* Writes and formats a JSON file.
|
|
56
63
|
* @param filename file name (and path) to write.
|
package/dist/utils/json.js
CHANGED
|
@@ -13,6 +13,27 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { readFileSync } from 'node:fs';
|
|
15
15
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
16
|
+
/**
|
|
17
|
+
* Escapes a string for use as a JSON string value.
|
|
18
|
+
* Escapes double quotes, backslashes, and control characters.
|
|
19
|
+
* @param content The string to escape
|
|
20
|
+
* @returns The escaped string suitable for use in JSON
|
|
21
|
+
*/
|
|
22
|
+
export function escapeJsonString(content) {
|
|
23
|
+
return JSON.stringify(content).slice(1, -1);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Format an object with JSON.stringify
|
|
27
|
+
*
|
|
28
|
+
* The purpose of this function is to format the JSON output in a centralised function
|
|
29
|
+
* so that the format can be controlled in a single location.
|
|
30
|
+
*
|
|
31
|
+
* @param json JSON object to format.
|
|
32
|
+
* @returns Formatted JSON string
|
|
33
|
+
*/
|
|
34
|
+
export function formatJson(json) {
|
|
35
|
+
return JSON.stringify(json, trimReplacer, 4);
|
|
36
|
+
}
|
|
16
37
|
/**
|
|
17
38
|
* Handles reading of a JSON file.
|
|
18
39
|
* @param file file name (and path) to read.
|
|
@@ -27,7 +48,9 @@ export function readJsonFileSync(file) {
|
|
|
27
48
|
}
|
|
28
49
|
catch (error) {
|
|
29
50
|
if (error instanceof Error) {
|
|
30
|
-
throw new Error(`Invalid JSON in file '${file}': ${error.message}
|
|
51
|
+
throw new Error(`Invalid JSON in file '${file}': ${error.message}`, {
|
|
52
|
+
cause: error,
|
|
53
|
+
});
|
|
31
54
|
}
|
|
32
55
|
}
|
|
33
56
|
}
|
|
@@ -44,7 +67,9 @@ export async function readJsonFile(file) {
|
|
|
44
67
|
}
|
|
45
68
|
catch (error) {
|
|
46
69
|
if (error instanceof Error) {
|
|
47
|
-
throw new Error(`Invalid JSON in file '${file}': ${error.message}
|
|
70
|
+
throw new Error(`Invalid JSON in file '${file}': ${error.message}`, {
|
|
71
|
+
cause: error,
|
|
72
|
+
});
|
|
48
73
|
}
|
|
49
74
|
}
|
|
50
75
|
}
|
|
@@ -76,18 +101,6 @@ export function trimReplacer(_, value) {
|
|
|
76
101
|
}
|
|
77
102
|
return value;
|
|
78
103
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Format an object with JSON.stringify
|
|
81
|
-
*
|
|
82
|
-
* The purpose of this function is to format the JSON output in a centralised function
|
|
83
|
-
* so that the format can be controlled in a single location.
|
|
84
|
-
*
|
|
85
|
-
* @param json JSON object to format.
|
|
86
|
-
* @returns Formatted JSON string
|
|
87
|
-
*/
|
|
88
|
-
export function formatJson(json) {
|
|
89
|
-
return JSON.stringify(json, trimReplacer, 4);
|
|
90
|
-
}
|
|
91
104
|
/**
|
|
92
105
|
* Writes and formats a JSON file.
|
|
93
106
|
* @param filename file name (and path) to write.
|
package/dist/utils/json.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/utils/json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;EAYE;AAEF,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAmB,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAExE;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;QAClE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACpC,OAAO,WAAW,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAA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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 { type ChildLoggerOptions, type Logger } from 'pino';
|
|
13
|
-
|
|
12
|
+
import { type Level, type ChildLoggerOptions, type Logger } from 'pino';
|
|
13
|
+
/**
|
|
14
|
+
* Initialize the logger
|
|
15
|
+
* @param level Log level for stdout output.
|
|
16
|
+
* @param logPath Optional file path for full trace logging.
|
|
17
|
+
*/
|
|
18
|
+
export declare function initLogger(level: Level, logPath?: string): void;
|
|
14
19
|
/**
|
|
15
20
|
* Returns the logger instance.
|
|
16
21
|
*/
|
package/dist/utils/log-utils.js
CHANGED
|
@@ -10,11 +10,36 @@
|
|
|
10
10
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
11
11
|
*/
|
|
12
12
|
import pino from 'pino';
|
|
13
|
+
import { mkdirSync } from 'node:fs';
|
|
14
|
+
import { dirname } from 'node:path';
|
|
13
15
|
// This could be also a more generic interface, but since we use pino and this is an internal package, let's keep it simple
|
|
14
|
-
//
|
|
16
|
+
// Silent logger as default.
|
|
15
17
|
let _logger = pino({ level: 'silent' });
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
let initialized = false;
|
|
19
|
+
/**
|
|
20
|
+
* Initialize the logger
|
|
21
|
+
* @param level Log level for stdout output.
|
|
22
|
+
* @param logPath Optional file path for full trace logging.
|
|
23
|
+
*/
|
|
24
|
+
export function initLogger(level, logPath) {
|
|
25
|
+
if (initialized)
|
|
26
|
+
return;
|
|
27
|
+
initialized = true;
|
|
28
|
+
if (logPath) {
|
|
29
|
+
try {
|
|
30
|
+
mkdirSync(dirname(logPath), { recursive: true });
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
throw new Error(`Failed to create log directory '${dirname(logPath)}': ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
34
|
+
}
|
|
35
|
+
_logger = pino({ level: 'trace' }, pino.multistream([
|
|
36
|
+
{ stream: pino.destination(logPath), level: 'trace' },
|
|
37
|
+
{ stream: pino.destination(1), level },
|
|
38
|
+
]));
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
_logger = pino({ level }, pino.destination(1));
|
|
42
|
+
}
|
|
18
43
|
}
|
|
19
44
|
/**
|
|
20
45
|
* Returns the logger instance.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-utils.js","sourceRoot":"","sources":["../../src/utils/log-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,
|
|
1
|
+
{"version":3,"file":"log-utils.js","sourceRoot":"","sources":["../../src/utils/log-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,IAA0D,MAAM,MAAM,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,2HAA2H;AAC3H,4BAA4B;AAC5B,IAAI,OAAO,GAAW,IAAI,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;AAChD,IAAI,WAAW,GAAG,KAAK,CAAC;AAExB;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,KAAY,EAAE,OAAgB;IACvD,IAAI,WAAW;QAAE,OAAO;IACxB,WAAW,GAAG,IAAI,CAAC;IACnB,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,CAAC;YACH,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CACb,mCAAmC,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EACjH,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,IAAI,CACZ,EAAE,KAAK,EAAE,OAAO,EAAE,EAClB,IAAI,CAAC,WAAW,CAAC;YACf,EAAE,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE;YACrD,EAAE,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE;SACvC,CAAC,CACH,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,OAAO,CAAC;AACjB,CAAC;AACD;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAqD,EACrD,OAA4B;IAE5B,OAAO,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC"}
|
package/dist/utils/report.d.ts
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
import type { CalculationEngine } from '../containers/project/calculation-engine.js';
|
|
2
2
|
import type { Context } from '../interfaces/project-interfaces.js';
|
|
3
|
-
/**
|
|
4
|
-
* Formats a value from a logic program for use to graphviz
|
|
5
|
-
* @param value - The value to format
|
|
6
|
-
* @returns The formatted value
|
|
7
|
-
*/
|
|
8
|
-
export declare function formatAttributeValue(value?: string): string;
|
|
9
|
-
/**
|
|
10
|
-
* Checks if a field is a custom field
|
|
11
|
-
* @param field - The field to check
|
|
12
|
-
* @returns True if the field is a custom field, false otherwise
|
|
13
|
-
*/
|
|
14
|
-
export declare function isCustomField(field: string): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Formats a value for display in a report
|
|
17
|
-
* @param value - The value to format
|
|
18
|
-
* @returns The formatted value
|
|
19
|
-
*/
|
|
20
|
-
export declare function formatValue(value: unknown): string;
|
|
21
3
|
/**
|
|
22
4
|
* Parameters for the core generation function
|
|
23
5
|
*/
|
|
@@ -26,7 +8,6 @@ interface GenerateReportContentParams {
|
|
|
26
8
|
contentTemplate: string;
|
|
27
9
|
queryTemplate: string;
|
|
28
10
|
options: Record<string, string | undefined | boolean>;
|
|
29
|
-
graph?: boolean;
|
|
30
11
|
context: Context;
|
|
31
12
|
}
|
|
32
13
|
/**
|
package/dist/utils/report.js
CHANGED
|
@@ -11,62 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import Handlebars from 'handlebars';
|
|
13
13
|
import { registerEmptyMacros } from '../macros/index.js';
|
|
14
|
-
import {
|
|
15
|
-
/**
|
|
16
|
-
* Formats a value from a logic program for use to graphviz
|
|
17
|
-
* @param value - The value to format
|
|
18
|
-
* @returns The formatted value
|
|
19
|
-
*/
|
|
20
|
-
export function formatAttributeValue(value) {
|
|
21
|
-
if (!value) {
|
|
22
|
-
return '';
|
|
23
|
-
}
|
|
24
|
-
// value is an html-like string
|
|
25
|
-
if (value.length > 1 && value.startsWith('<') && value.endsWith('>')) {
|
|
26
|
-
return value;
|
|
27
|
-
}
|
|
28
|
-
// value is a normal string and needs to be wrapped in quotes
|
|
29
|
-
return `"${value}"`;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Checks if a field is a custom field
|
|
33
|
-
* @param field - The field to check
|
|
34
|
-
* @returns True if the field is a custom field, false otherwise
|
|
35
|
-
*/
|
|
36
|
-
export function isCustomField(field) {
|
|
37
|
-
try {
|
|
38
|
-
const { type } = resourceName(field, true);
|
|
39
|
-
return type === 'fieldTypes';
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Formats a value for display in a report
|
|
47
|
-
* @param value - The value to format
|
|
48
|
-
* @returns The formatted value
|
|
49
|
-
*/
|
|
50
|
-
export function formatValue(value) {
|
|
51
|
-
if (typeof value === 'object') {
|
|
52
|
-
if (Array.isArray(value)) {
|
|
53
|
-
return value.map((v) => formatValue(v)).join(', ');
|
|
54
|
-
}
|
|
55
|
-
if (value != null &&
|
|
56
|
-
'displayValue' in value &&
|
|
57
|
-
typeof value.displayValue === 'string') {
|
|
58
|
-
return value.displayValue;
|
|
59
|
-
}
|
|
60
|
-
if (value != null && 'value' in value && typeof value.value === 'string') {
|
|
61
|
-
return formatValue(value.value);
|
|
62
|
-
}
|
|
63
|
-
return JSON.stringify(value, null, 2);
|
|
64
|
-
}
|
|
65
|
-
if (typeof value === 'boolean') {
|
|
66
|
-
return value ? 'Yes' : 'No';
|
|
67
|
-
}
|
|
68
|
-
return value?.toString() ?? '';
|
|
69
|
-
}
|
|
14
|
+
import { registerComparisonHelpers, registerReportHelpers, } from './handlebars-helpers.js';
|
|
70
15
|
/**
|
|
71
16
|
* Generates report content based on a report definition, project context, and options,
|
|
72
17
|
* by utilizing the ReportRunner class.
|
|
@@ -76,9 +21,9 @@ export function formatValue(value) {
|
|
|
76
21
|
* @throws Error if the report definition is invalid, schema validation fails, or logic program execution fails.
|
|
77
22
|
*/
|
|
78
23
|
export async function generateReportContent(params) {
|
|
79
|
-
const { calculate, contentTemplate, queryTemplate,
|
|
80
|
-
context, } = params;
|
|
24
|
+
const { calculate, contentTemplate, queryTemplate, options, context } = params;
|
|
81
25
|
const handlebars = Handlebars.create();
|
|
26
|
+
registerComparisonHelpers(handlebars);
|
|
82
27
|
// Compile and execute the query template
|
|
83
28
|
const template = handlebars.compile(queryTemplate, {
|
|
84
29
|
strict: true,
|
|
@@ -89,11 +34,7 @@ export async function generateReportContent(params) {
|
|
|
89
34
|
}
|
|
90
35
|
// register empty macros so that other macros aren't touched yet
|
|
91
36
|
registerEmptyMacros(handlebars);
|
|
92
|
-
|
|
93
|
-
handlebars.registerHelper('formatAttributeValue', formatAttributeValue);
|
|
94
|
-
}
|
|
95
|
-
handlebars.registerHelper('isCustomField', isCustomField);
|
|
96
|
-
handlebars.registerHelper('formatValue', formatValue);
|
|
37
|
+
registerReportHelpers(handlebars);
|
|
97
38
|
return handlebars.compile(contentTemplate)({
|
|
98
39
|
...options,
|
|
99
40
|
...result,
|
package/dist/utils/report.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../src/utils/report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../src/utils/report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EACL,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AAajC;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAAmC;IAEnC,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,GACnE,MAAM,CAAC;IAET,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC;IACvC,yBAAyB,CAAC,UAAU,CAAC,CAAC;IAEtC,yCAAyC;IACzC,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,aAAa,EAAE;QACjD,MAAM,EAAE,IAAI;KACb,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IAE3E,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IACD,gEAAgE;IAChE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAChC,qBAAqB,CAAC,UAAU,CAAC,CAAC;IAElC,OAAO,UAAU,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QACzC,GAAG,OAAO;QACV,GAAG,MAAM;KACV,CAAC,CAAC;AACL,CAAC"}
|