@cyberismo/data-handler 0.0.2
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/LICENSE +702 -0
- package/dist/card-metadata-updater.d.ts +33 -0
- package/dist/card-metadata-updater.js +121 -0
- package/dist/card-metadata-updater.js.map +1 -0
- package/dist/command-handler.d.ts +96 -0
- package/dist/command-handler.js +557 -0
- package/dist/command-handler.js.map +1 -0
- package/dist/command-manager.d.ts +43 -0
- package/dist/command-manager.js +73 -0
- package/dist/command-manager.js.map +1 -0
- package/dist/commands/calculate.d.ts +86 -0
- package/dist/commands/calculate.js +444 -0
- package/dist/commands/calculate.js.map +1 -0
- package/dist/commands/create.d.ts +114 -0
- package/dist/commands/create.js +389 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/edit.d.ts +37 -0
- package/dist/commands/edit.js +99 -0
- package/dist/commands/edit.js.map +1 -0
- package/dist/commands/export-site.d.ts +45 -0
- package/dist/commands/export-site.js +301 -0
- package/dist/commands/export-site.js.map +1 -0
- package/dist/commands/export.d.ts +53 -0
- package/dist/commands/export.js +251 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/import.d.ts +53 -0
- package/dist/commands/import.js +133 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/index.d.ts +26 -0
- package/dist/commands/index.js +27 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/move.d.ts +55 -0
- package/dist/commands/move.js +341 -0
- package/dist/commands/move.js.map +1 -0
- package/dist/commands/remove.d.ts +38 -0
- package/dist/commands/remove.js +192 -0
- package/dist/commands/remove.js.map +1 -0
- package/dist/commands/rename.d.ts +46 -0
- package/dist/commands/rename.js +289 -0
- package/dist/commands/rename.js.map +1 -0
- package/dist/commands/show.d.ts +124 -0
- package/dist/commands/show.js +345 -0
- package/dist/commands/show.js.map +1 -0
- package/dist/commands/transition.d.ts +27 -0
- package/dist/commands/transition.js +92 -0
- package/dist/commands/transition.js.map +1 -0
- package/dist/commands/update.d.ts +29 -0
- package/dist/commands/update.js +64 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/validate.d.ts +143 -0
- package/dist/commands/validate.js +689 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/containers/card-container.d.ts +44 -0
- package/dist/containers/card-container.js +282 -0
- package/dist/containers/card-container.js.map +1 -0
- package/dist/containers/project/project-paths.d.ts +46 -0
- package/dist/containers/project/project-paths.js +105 -0
- package/dist/containers/project/project-paths.js.map +1 -0
- package/dist/containers/project/resource-collector.d.ts +86 -0
- package/dist/containers/project/resource-collector.js +331 -0
- package/dist/containers/project/resource-collector.js.map +1 -0
- package/dist/containers/project.d.ts +351 -0
- package/dist/containers/project.js +896 -0
- package/dist/containers/project.js.map +1 -0
- package/dist/containers/template.d.ts +108 -0
- package/dist/containers/template.js +433 -0
- package/dist/containers/template.js.map +1 -0
- package/dist/exceptions/index.d.ts +19 -0
- package/dist/exceptions/index.js +26 -0
- package/dist/exceptions/index.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/adoc.d.ts +12 -0
- package/dist/interfaces/adoc.js +13 -0
- package/dist/interfaces/adoc.js.map +1 -0
- package/dist/interfaces/macros.d.ts +45 -0
- package/dist/interfaces/macros.js +13 -0
- package/dist/interfaces/macros.js.map +1 -0
- package/dist/interfaces/project-interfaces.d.ts +121 -0
- package/dist/interfaces/project-interfaces.js +21 -0
- package/dist/interfaces/project-interfaces.js.map +1 -0
- package/dist/interfaces/request-status-interfaces.d.ts +28 -0
- package/dist/interfaces/request-status-interfaces.js +20 -0
- package/dist/interfaces/request-status-interfaces.js.map +1 -0
- package/dist/interfaces/resource-interfaces.d.ts +117 -0
- package/dist/interfaces/resource-interfaces.js +20 -0
- package/dist/interfaces/resource-interfaces.js.map +1 -0
- package/dist/macros/base-macro.d.ts +31 -0
- package/dist/macros/base-macro.js +126 -0
- package/dist/macros/base-macro.js.map +1 -0
- package/dist/macros/common.d.ts +17 -0
- package/dist/macros/common.js +23 -0
- package/dist/macros/common.js.map +1 -0
- package/dist/macros/createCards/index.d.ts +36 -0
- package/dist/macros/createCards/index.js +35 -0
- package/dist/macros/createCards/index.js.map +1 -0
- package/dist/macros/createCards/metadata.d.ts +14 -0
- package/dist/macros/createCards/metadata.js +18 -0
- package/dist/macros/createCards/metadata.js.map +1 -0
- package/dist/macros/graph/index.d.ts +29 -0
- package/dist/macros/graph/index.js +91 -0
- package/dist/macros/graph/index.js.map +1 -0
- package/dist/macros/graph/metadata.d.ts +14 -0
- package/dist/macros/graph/metadata.js +18 -0
- package/dist/macros/graph/metadata.js.map +1 -0
- package/dist/macros/index.d.ts +93 -0
- package/dist/macros/index.js +237 -0
- package/dist/macros/index.js.map +1 -0
- package/dist/macros/report/index.d.ts +26 -0
- package/dist/macros/report/index.js +70 -0
- package/dist/macros/report/index.js.map +1 -0
- package/dist/macros/report/metadata.d.ts +14 -0
- package/dist/macros/report/metadata.js +18 -0
- package/dist/macros/report/metadata.js.map +1 -0
- package/dist/macros/scoreCard/index.d.ts +30 -0
- package/dist/macros/scoreCard/index.js +38 -0
- package/dist/macros/scoreCard/index.js.map +1 -0
- package/dist/macros/scoreCard/metadata.d.ts +14 -0
- package/dist/macros/scoreCard/metadata.js +18 -0
- package/dist/macros/scoreCard/metadata.js.map +1 -0
- package/dist/macros/task-queue.d.ts +46 -0
- package/dist/macros/task-queue.js +69 -0
- package/dist/macros/task-queue.js.map +1 -0
- package/dist/module-manager.d.ts +62 -0
- package/dist/module-manager.js +350 -0
- package/dist/module-manager.js.map +1 -0
- package/dist/permissions/action-guard.d.ts +28 -0
- package/dist/permissions/action-guard.js +61 -0
- package/dist/permissions/action-guard.js.map +1 -0
- package/dist/project-settings.d.ts +42 -0
- package/dist/project-settings.js +120 -0
- package/dist/project-settings.js.map +1 -0
- package/dist/resources/array-handler.d.ts +28 -0
- package/dist/resources/array-handler.js +116 -0
- package/dist/resources/array-handler.js.map +1 -0
- package/dist/resources/card-type-resource.d.ts +72 -0
- package/dist/resources/card-type-resource.js +334 -0
- package/dist/resources/card-type-resource.js.map +1 -0
- package/dist/resources/create-defaults.d.ts +81 -0
- package/dist/resources/create-defaults.js +184 -0
- package/dist/resources/create-defaults.js.map +1 -0
- package/dist/resources/field-type-resource.d.ts +88 -0
- package/dist/resources/field-type-resource.js +411 -0
- package/dist/resources/field-type-resource.js.map +1 -0
- package/dist/resources/file-resource.d.ts +50 -0
- package/dist/resources/file-resource.js +301 -0
- package/dist/resources/file-resource.js.map +1 -0
- package/dist/resources/folder-resource.d.ts +66 -0
- package/dist/resources/folder-resource.js +100 -0
- package/dist/resources/folder-resource.js.map +1 -0
- package/dist/resources/graph-model-resource.d.ts +78 -0
- package/dist/resources/graph-model-resource.js +164 -0
- package/dist/resources/graph-model-resource.js.map +1 -0
- package/dist/resources/graph-view-resource.d.ts +78 -0
- package/dist/resources/graph-view-resource.js +163 -0
- package/dist/resources/graph-view-resource.js.map +1 -0
- package/dist/resources/link-type-resource.d.ts +62 -0
- package/dist/resources/link-type-resource.js +150 -0
- package/dist/resources/link-type-resource.js.map +1 -0
- package/dist/resources/report-resource.d.ts +77 -0
- package/dist/resources/report-resource.js +171 -0
- package/dist/resources/report-resource.js.map +1 -0
- package/dist/resources/resource-object.d.ts +108 -0
- package/dist/resources/resource-object.js +147 -0
- package/dist/resources/resource-object.js.map +1 -0
- package/dist/resources/template-resource.d.ts +82 -0
- package/dist/resources/template-resource.js +173 -0
- package/dist/resources/template-resource.js.map +1 -0
- package/dist/resources/workflow-resource.d.ts +67 -0
- package/dist/resources/workflow-resource.js +156 -0
- package/dist/resources/workflow-resource.js.map +1 -0
- package/dist/types/queries.d.ts +142 -0
- package/dist/types/queries.js +16 -0
- package/dist/types/queries.js.map +1 -0
- package/dist/utils/card-utils.d.ts +34 -0
- package/dist/utils/card-utils.js +78 -0
- package/dist/utils/card-utils.js.map +1 -0
- package/dist/utils/clingo-fact-builder.d.ts +58 -0
- package/dist/utils/clingo-fact-builder.js +126 -0
- package/dist/utils/clingo-fact-builder.js.map +1 -0
- package/dist/utils/clingo-facts.d.ts +97 -0
- package/dist/utils/clingo-facts.js +352 -0
- package/dist/utils/clingo-facts.js.map +1 -0
- package/dist/utils/clingo-parser.d.ts +59 -0
- package/dist/utils/clingo-parser.js +403 -0
- package/dist/utils/clingo-parser.js.map +1 -0
- package/dist/utils/clingo-program-builder.d.ts +39 -0
- package/dist/utils/clingo-program-builder.js +57 -0
- package/dist/utils/clingo-program-builder.js.map +1 -0
- package/dist/utils/common-utils.d.ts +24 -0
- package/dist/utils/common-utils.js +47 -0
- package/dist/utils/common-utils.js.map +1 -0
- package/dist/utils/constants.d.ts +18 -0
- package/dist/utils/constants.js +27 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/csv.d.ts +18 -0
- package/dist/utils/csv.js +45 -0
- package/dist/utils/csv.js.map +1 -0
- package/dist/utils/file-utils.d.ts +69 -0
- package/dist/utils/file-utils.js +158 -0
- package/dist/utils/file-utils.js.map +1 -0
- package/dist/utils/json.d.ts +61 -0
- package/dist/utils/json.js +108 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/lexorank.d.ts +59 -0
- package/dist/utils/lexorank.js +159 -0
- package/dist/utils/lexorank.js.map +1 -0
- package/dist/utils/log-utils.d.ts +40 -0
- package/dist/utils/log-utils.js +109 -0
- package/dist/utils/log-utils.js.map +1 -0
- package/dist/utils/random.d.ts +19 -0
- package/dist/utils/random.js +34 -0
- package/dist/utils/random.js.map +1 -0
- package/dist/utils/resource-utils.d.ts +45 -0
- package/dist/utils/resource-utils.js +137 -0
- package/dist/utils/resource-utils.js.map +1 -0
- package/dist/utils/sanitize-svg.d.ts +18 -0
- package/dist/utils/sanitize-svg.js +38 -0
- package/dist/utils/sanitize-svg.js.map +1 -0
- package/dist/utils/user-preferences.d.ts +64 -0
- package/dist/utils/user-preferences.js +106 -0
- package/dist/utils/user-preferences.js.map +1 -0
- package/dist/utils/validate.d.ts +26 -0
- package/dist/utils/validate.js +53 -0
- package/dist/utils/validate.js.map +1 -0
- package/dist/utils/value-utils.d.ts +58 -0
- package/dist/utils/value-utils.js +181 -0
- package/dist/utils/value-utils.js.map +1 -0
- package/package.json +67 -0
- package/src/card-metadata-updater.ts +182 -0
- package/src/command-handler.ts +686 -0
- package/src/command-manager.ts +99 -0
- package/src/commands/calculate.ts +591 -0
- package/src/commands/create.ts +559 -0
- package/src/commands/edit.ts +123 -0
- package/src/commands/export-site.ts +356 -0
- package/src/commands/export.ts +315 -0
- package/src/commands/import.ts +169 -0
- package/src/commands/index.ts +42 -0
- package/src/commands/move.ts +451 -0
- package/src/commands/remove.ts +244 -0
- package/src/commands/rename.ts +378 -0
- package/src/commands/show.ts +442 -0
- package/src/commands/transition.ts +127 -0
- package/src/commands/update.ts +76 -0
- package/src/commands/validate.ts +962 -0
- package/src/containers/card-container.ts +378 -0
- package/src/containers/project/project-paths.ts +127 -0
- package/src/containers/project/resource-collector.ts +379 -0
- package/src/containers/project.ts +1135 -0
- package/src/containers/template.ts +573 -0
- package/src/exceptions/index.ts +29 -0
- package/src/index.ts +33 -0
- package/src/interfaces/adoc.ts +18 -0
- package/src/interfaces/macros.ts +54 -0
- package/src/interfaces/project-interfaces.ts +208 -0
- package/src/interfaces/request-status-interfaces.ts +30 -0
- package/src/interfaces/resource-interfaces.ts +179 -0
- package/src/macros/base-macro.ts +176 -0
- package/src/macros/common.ts +24 -0
- package/src/macros/createCards/index.ts +57 -0
- package/src/macros/createCards/metadata.ts +21 -0
- package/src/macros/graph/index.ts +130 -0
- package/src/macros/graph/metadata.ts +21 -0
- package/src/macros/index.ts +321 -0
- package/src/macros/report/index.ts +88 -0
- package/src/macros/report/metadata.ts +21 -0
- package/src/macros/scoreCard/index.ts +55 -0
- package/src/macros/scoreCard/metadata.ts +21 -0
- package/src/macros/task-queue.ts +79 -0
- package/src/module-manager.ts +443 -0
- package/src/permissions/action-guard.ts +77 -0
- package/src/project-settings.ts +140 -0
- package/src/resources/array-handler.ts +141 -0
- package/src/resources/card-type-resource.ts +455 -0
- package/src/resources/create-defaults.ts +216 -0
- package/src/resources/field-type-resource.ts +533 -0
- package/src/resources/file-resource.ts +433 -0
- package/src/resources/folder-resource.ts +140 -0
- package/src/resources/graph-model-resource.ts +205 -0
- package/src/resources/graph-view-resource.ts +199 -0
- package/src/resources/link-type-resource.ts +191 -0
- package/src/resources/report-resource.ts +224 -0
- package/src/resources/resource-object.ts +246 -0
- package/src/resources/template-resource.ts +210 -0
- package/src/resources/workflow-resource.ts +205 -0
- package/src/types/queries.ts +149 -0
- package/src/utils/card-utils.ts +83 -0
- package/src/utils/clingo-fact-builder.ts +167 -0
- package/src/utils/clingo-facts.ts +550 -0
- package/src/utils/clingo-parser.ts +519 -0
- package/src/utils/clingo-program-builder.ts +71 -0
- package/src/utils/common-utils.ts +54 -0
- package/src/utils/constants.ts +32 -0
- package/src/utils/csv.ts +53 -0
- package/src/utils/file-utils.ts +182 -0
- package/src/utils/json.ts +118 -0
- package/src/utils/lexorank.ts +180 -0
- package/src/utils/log-utils.ts +127 -0
- package/src/utils/random.ts +37 -0
- package/src/utils/resource-utils.ts +180 -0
- package/src/utils/sanitize-svg.ts +46 -0
- package/src/utils/user-preferences.ts +126 -0
- package/src/utils/validate.ts +66 -0
- package/src/utils/value-utils.ts +189 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2024
|
|
4
|
+
|
|
5
|
+
This program is 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
|
+
export class DHValidationError extends Error {
|
|
13
|
+
errors;
|
|
14
|
+
constructor(message, errors) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = 'DHValidationError';
|
|
17
|
+
this.errors = errors;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export class SchemaNotFound extends Error {
|
|
21
|
+
constructor(message) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.name = 'SchemaNotFound';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exceptions/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAIF,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IACnC,MAAM,CAAqB;IAClC,YAAY,OAAe,EAAE,MAA0B;QACrD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2024
|
|
4
|
+
|
|
5
|
+
This program is 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 { CardsOptions, Cmd, Commands, CommandManager, ExportFormats } from './command-handler.js';
|
|
13
|
+
import { requestStatus } from './interfaces/request-status-interfaces.js';
|
|
14
|
+
import { UpdateOperations } from './resources/resource-object.js';
|
|
15
|
+
import { evaluateMacros } from './macros/index.js';
|
|
16
|
+
export { CardsOptions, Cmd, CommandManager, Commands, ExportFormats, requestStatus, UpdateOperations, evaluateMacros, };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2024
|
|
4
|
+
|
|
5
|
+
This program is 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 { Cmd, Commands, CommandManager, ExportFormats, } from './command-handler.js';
|
|
13
|
+
import { evaluateMacros } from './macros/index.js';
|
|
14
|
+
export { Cmd, CommandManager, Commands, ExportFormats, evaluateMacros, };
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAEL,GAAG,EACH,QAAQ,EACR,cAAc,EACd,aAAa,GACd,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAEL,GAAG,EACH,cAAc,EACd,QAAQ,EACR,aAAa,EAGb,cAAc,GACf,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2024
|
|
4
|
+
|
|
5
|
+
This program is 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
|
+
export type AdmonitionType = 'NOTE' | 'TIP' | 'IMPORTANT' | 'CAUTION' | 'WARNING';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2024
|
|
4
|
+
|
|
5
|
+
This program is 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
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=adoc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adoc.js","sourceRoot":"","sources":["../../src/interfaces/adoc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2024
|
|
4
|
+
|
|
5
|
+
This program is 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 { macroMetadata } from '../macros/common.js';
|
|
13
|
+
type Mode = 'validate' | 'static' | 'inject';
|
|
14
|
+
export interface MacroGenerationContext {
|
|
15
|
+
projectPath: string;
|
|
16
|
+
mode: Mode;
|
|
17
|
+
cardKey: string;
|
|
18
|
+
}
|
|
19
|
+
export interface MacroMetadata {
|
|
20
|
+
/**
|
|
21
|
+
* The name of the macro. This is the name that will be used in the content
|
|
22
|
+
*/
|
|
23
|
+
name: string;
|
|
24
|
+
/**
|
|
25
|
+
* The tag name of the macro. This is the name that will be used in the HTML. This is separated for clarity since tags cannot have uppercase letters
|
|
26
|
+
*/
|
|
27
|
+
tagName: string;
|
|
28
|
+
/**
|
|
29
|
+
* The schema of the macro. This is used to validate the data passed to the macro
|
|
30
|
+
*/
|
|
31
|
+
schema?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface MacroTaskState {
|
|
34
|
+
globalId: string;
|
|
35
|
+
localId: number;
|
|
36
|
+
promise: Promise<void>;
|
|
37
|
+
placeholder: string;
|
|
38
|
+
promiseResult: string | null;
|
|
39
|
+
macro: string;
|
|
40
|
+
}
|
|
41
|
+
export interface HandlebarsOptions {
|
|
42
|
+
fn: (arg0: unknown) => string;
|
|
43
|
+
}
|
|
44
|
+
export type MacroName = keyof typeof macroMetadata;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2024
|
|
4
|
+
|
|
5
|
+
This program is 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
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=macros.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"macros.js","sourceRoot":"","sources":["../../src/interfaces/macros.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2024
|
|
4
|
+
|
|
5
|
+
This program is 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 { Link, TemplateConfiguration } from './resource-interfaces.js';
|
|
13
|
+
export interface Card {
|
|
14
|
+
key: string;
|
|
15
|
+
path: string;
|
|
16
|
+
content?: string;
|
|
17
|
+
metadata?: CardMetadata;
|
|
18
|
+
parent?: string;
|
|
19
|
+
children: Card[];
|
|
20
|
+
attachments: CardAttachment[];
|
|
21
|
+
}
|
|
22
|
+
export interface CardAttachment {
|
|
23
|
+
card: string;
|
|
24
|
+
path: string;
|
|
25
|
+
fileName: string;
|
|
26
|
+
mimeType: string | null;
|
|
27
|
+
}
|
|
28
|
+
export interface CardListContainer {
|
|
29
|
+
name: string;
|
|
30
|
+
type: string;
|
|
31
|
+
cards: string[];
|
|
32
|
+
}
|
|
33
|
+
export interface PredefinedCardMetadata {
|
|
34
|
+
title: string;
|
|
35
|
+
cardType: string;
|
|
36
|
+
workflowState: string;
|
|
37
|
+
rank: string;
|
|
38
|
+
lastTransitioned?: string;
|
|
39
|
+
lastUpdated?: string;
|
|
40
|
+
templateCardKey?: string;
|
|
41
|
+
}
|
|
42
|
+
export declare enum CardLocation {
|
|
43
|
+
all = "all",
|
|
44
|
+
projectOnly = "project",
|
|
45
|
+
templatesOnly = "local"
|
|
46
|
+
}
|
|
47
|
+
export interface CardMetadata extends PredefinedCardMetadata {
|
|
48
|
+
labels?: string[];
|
|
49
|
+
links: Link[];
|
|
50
|
+
[key: string]: MetadataContent;
|
|
51
|
+
}
|
|
52
|
+
type ContentType = DotSchemaContent | ProjectSettings;
|
|
53
|
+
export type CSVRowRaw = {
|
|
54
|
+
[key: string]: string;
|
|
55
|
+
};
|
|
56
|
+
export interface DotSchemaItem {
|
|
57
|
+
id: string;
|
|
58
|
+
version: number;
|
|
59
|
+
file?: string;
|
|
60
|
+
}
|
|
61
|
+
export type DotSchemaContent = DotSchemaItem[];
|
|
62
|
+
export interface FetchCardDetails {
|
|
63
|
+
attachments?: boolean;
|
|
64
|
+
calculations?: true;
|
|
65
|
+
children?: boolean;
|
|
66
|
+
content?: boolean;
|
|
67
|
+
contentType?: FileContentType;
|
|
68
|
+
metadata?: boolean;
|
|
69
|
+
parent?: boolean;
|
|
70
|
+
}
|
|
71
|
+
export interface ProjectFetchCardDetails extends FetchCardDetails {
|
|
72
|
+
location?: CardLocation;
|
|
73
|
+
}
|
|
74
|
+
export type FileContentType = 'adoc' | 'html';
|
|
75
|
+
export type MetadataContent = bigint | number | boolean | string | string[] | Link[] | null | undefined;
|
|
76
|
+
export interface ModuleContent extends ProjectSettings {
|
|
77
|
+
path: string;
|
|
78
|
+
calculations: string[];
|
|
79
|
+
cardTypes: string[];
|
|
80
|
+
fieldTypes: string[];
|
|
81
|
+
graphModels: string[];
|
|
82
|
+
graphViews: string[];
|
|
83
|
+
linkTypes: string[];
|
|
84
|
+
reports: string[];
|
|
85
|
+
templates: string[];
|
|
86
|
+
workflows: string[];
|
|
87
|
+
}
|
|
88
|
+
export interface ProjectFile {
|
|
89
|
+
content: ContentType;
|
|
90
|
+
path: string;
|
|
91
|
+
name: string;
|
|
92
|
+
}
|
|
93
|
+
export interface ProjectMetadata {
|
|
94
|
+
name: string;
|
|
95
|
+
path: string;
|
|
96
|
+
prefix: string;
|
|
97
|
+
modules: string[];
|
|
98
|
+
numberOfCards: number;
|
|
99
|
+
}
|
|
100
|
+
export interface ProjectSettings {
|
|
101
|
+
cardKeyPrefix: string;
|
|
102
|
+
name: string;
|
|
103
|
+
modules: ModuleSetting[];
|
|
104
|
+
}
|
|
105
|
+
export interface ModuleSetting extends ModuleSettingOptions {
|
|
106
|
+
name: string;
|
|
107
|
+
location: string;
|
|
108
|
+
}
|
|
109
|
+
export interface ModuleSettingOptions {
|
|
110
|
+
branch?: string;
|
|
111
|
+
private?: boolean;
|
|
112
|
+
}
|
|
113
|
+
export type RemovableResourceTypes = 'attachment' | 'card' | 'cardType' | 'fieldType' | 'graphModel' | 'graphView' | 'link' | 'linkType' | 'module' | 'report' | 'template' | 'workflow' | 'label';
|
|
114
|
+
export interface Resource {
|
|
115
|
+
name: string;
|
|
116
|
+
path: string;
|
|
117
|
+
}
|
|
118
|
+
export type ResourceFolderType = 'calculations' | 'cardTypes' | 'fieldTypes' | 'graphModels' | 'graphViews' | 'linkTypes' | 'modules' | 'reports' | 'templates' | 'workflows';
|
|
119
|
+
export type ResourceTypes = RemovableResourceTypes | ResourceFolderType | 'attachments' | 'calculation' | 'cards' | 'label' | 'labels' | 'links' | 'modules' | 'project' | 'projects';
|
|
120
|
+
export { TemplateConfiguration };
|
|
121
|
+
export declare const CardNameRegEx: RegExp;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2024
|
|
4
|
+
|
|
5
|
+
This program is 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
|
+
// todo: do we need in the future separation between module-template-cards and local template-cards
|
|
13
|
+
export var CardLocation;
|
|
14
|
+
(function (CardLocation) {
|
|
15
|
+
CardLocation["all"] = "all";
|
|
16
|
+
CardLocation["projectOnly"] = "project";
|
|
17
|
+
CardLocation["templatesOnly"] = "local";
|
|
18
|
+
})(CardLocation || (CardLocation = {}));
|
|
19
|
+
// Name for a card (consists of prefix and a random 8-character base36 string; e.g. 'test_abcd1234')
|
|
20
|
+
export const CardNameRegEx = new RegExp(/^[a-z]+_[0-9a-z]+$/);
|
|
21
|
+
//# sourceMappingURL=project-interfaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-interfaces.js","sourceRoot":"","sources":["../../src/interfaces/project-interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAwCF,mGAAmG;AACnG,MAAM,CAAN,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,2BAAW,CAAA;IACX,uCAAuB,CAAA;IACvB,uCAAuB,CAAA;AACzB,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB;AAuJD,oGAAoG;AACpG,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC,oBAAoB,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2024
|
|
4
|
+
|
|
5
|
+
This program is 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
|
+
declare enum httpStatusCode {
|
|
13
|
+
Info = 100,
|
|
14
|
+
OK = 200,
|
|
15
|
+
BAD = 400,
|
|
16
|
+
SERVER_ERROR = 500
|
|
17
|
+
}
|
|
18
|
+
export interface requestStatus {
|
|
19
|
+
statusCode: httpStatusCode;
|
|
20
|
+
message?: string;
|
|
21
|
+
affectsCards?: string[];
|
|
22
|
+
payload?: object | attachmentPayload;
|
|
23
|
+
}
|
|
24
|
+
export interface attachmentPayload {
|
|
25
|
+
fileBuffer: Buffer;
|
|
26
|
+
mimeType: string;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2024
|
|
4
|
+
|
|
5
|
+
This program is 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
|
+
var httpStatusCode;
|
|
13
|
+
(function (httpStatusCode) {
|
|
14
|
+
httpStatusCode[httpStatusCode["Info"] = 100] = "Info";
|
|
15
|
+
httpStatusCode[httpStatusCode["OK"] = 200] = "OK";
|
|
16
|
+
httpStatusCode[httpStatusCode["BAD"] = 400] = "BAD";
|
|
17
|
+
httpStatusCode[httpStatusCode["SERVER_ERROR"] = 500] = "SERVER_ERROR";
|
|
18
|
+
})(httpStatusCode || (httpStatusCode = {}));
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=request-status-interfaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-status-interfaces.js","sourceRoot":"","sources":["../../src/interfaces/request-status-interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,IAAK,cAKJ;AALD,WAAK,cAAc;IACjB,qDAAU,CAAA;IACV,iDAAQ,CAAA;IACR,mDAAS,CAAA;IACT,qEAAkB,CAAA;AACpB,CAAC,EALI,cAAc,KAAd,cAAc,QAKlB"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2024
|
|
4
|
+
|
|
5
|
+
This program is 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 { Schema } from 'jsonschema';
|
|
13
|
+
/**
|
|
14
|
+
* Each resource represents a file (or a folder in some cases) with metadata stored
|
|
15
|
+
* in JSON file. Name of the file is the name of the resource. Each resource is expected to be
|
|
16
|
+
* in a correct place in folder structure.
|
|
17
|
+
*/
|
|
18
|
+
export type CalculationMetadata = ResourceBaseMetadata;
|
|
19
|
+
export interface CardType extends ResourceBaseMetadata {
|
|
20
|
+
workflow: string;
|
|
21
|
+
customFields: CustomField[];
|
|
22
|
+
alwaysVisibleFields: string[];
|
|
23
|
+
optionallyVisibleFields: string[];
|
|
24
|
+
}
|
|
25
|
+
export interface CustomField {
|
|
26
|
+
name: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
displayName?: string;
|
|
29
|
+
isCalculated: boolean;
|
|
30
|
+
}
|
|
31
|
+
export type DataType = 'boolean' | 'date' | 'dateTime' | 'enum' | 'integer' | 'list' | 'longText' | 'number' | 'person' | 'shortText';
|
|
32
|
+
export interface EnumDefinition {
|
|
33
|
+
enumValue: string;
|
|
34
|
+
enumDisplayValue?: string;
|
|
35
|
+
enumDescription?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface FieldType extends ResourceBaseMetadata {
|
|
38
|
+
displayName?: string;
|
|
39
|
+
fieldDescription?: string;
|
|
40
|
+
dataType: DataType;
|
|
41
|
+
enumValues?: Array<EnumDefinition>;
|
|
42
|
+
}
|
|
43
|
+
export interface GraphModelMetadata extends ResourceBaseMetadata {
|
|
44
|
+
category?: string;
|
|
45
|
+
description?: string;
|
|
46
|
+
displayName: string;
|
|
47
|
+
}
|
|
48
|
+
export interface GraphModel extends GraphModelMetadata {
|
|
49
|
+
calculationFile: string;
|
|
50
|
+
}
|
|
51
|
+
export interface GraphViewMetadata extends ResourceBaseMetadata {
|
|
52
|
+
category?: string;
|
|
53
|
+
description?: string;
|
|
54
|
+
displayName: string;
|
|
55
|
+
}
|
|
56
|
+
export interface GraphView extends GraphViewMetadata {
|
|
57
|
+
handleBarFile: string;
|
|
58
|
+
}
|
|
59
|
+
export interface Link {
|
|
60
|
+
linkType: string;
|
|
61
|
+
cardKey: string;
|
|
62
|
+
linkDescription?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface LinkType extends ResourceBaseMetadata {
|
|
65
|
+
outboundDisplayName: string;
|
|
66
|
+
inboundDisplayName: string;
|
|
67
|
+
sourceCardTypes: string[];
|
|
68
|
+
destinationCardTypes: string[];
|
|
69
|
+
enableLinkDescription: boolean;
|
|
70
|
+
}
|
|
71
|
+
export interface Report {
|
|
72
|
+
name: string;
|
|
73
|
+
metadata: ReportMetadata;
|
|
74
|
+
contentTemplate: string;
|
|
75
|
+
queryTemplate: string;
|
|
76
|
+
schema?: Schema;
|
|
77
|
+
}
|
|
78
|
+
export interface ReportMetadata extends ResourceBaseMetadata {
|
|
79
|
+
displayName: string;
|
|
80
|
+
description: string;
|
|
81
|
+
category: string;
|
|
82
|
+
}
|
|
83
|
+
export interface ResourceBaseMetadata {
|
|
84
|
+
name: string;
|
|
85
|
+
usedIn?: string[];
|
|
86
|
+
}
|
|
87
|
+
export type ResourceContent = CardType | FieldType | GraphModel | GraphView | LinkType | ReportMetadata | TemplateMetadata | Workflow;
|
|
88
|
+
export interface TemplateConfiguration {
|
|
89
|
+
name: string;
|
|
90
|
+
path: string;
|
|
91
|
+
numberOfCards: number;
|
|
92
|
+
metadata: TemplateMetadata;
|
|
93
|
+
}
|
|
94
|
+
export interface TemplateMetadata extends ResourceBaseMetadata {
|
|
95
|
+
displayName?: string;
|
|
96
|
+
description?: string;
|
|
97
|
+
category?: string;
|
|
98
|
+
}
|
|
99
|
+
export interface Workflow extends ResourceBaseMetadata {
|
|
100
|
+
states: WorkflowState[];
|
|
101
|
+
transitions: WorkflowTransition[];
|
|
102
|
+
}
|
|
103
|
+
export declare enum WorkflowCategory {
|
|
104
|
+
initial = "initial",
|
|
105
|
+
active = "active",
|
|
106
|
+
closed = "closed",
|
|
107
|
+
none = "none"
|
|
108
|
+
}
|
|
109
|
+
export interface WorkflowState {
|
|
110
|
+
name: string;
|
|
111
|
+
category?: WorkflowCategory;
|
|
112
|
+
}
|
|
113
|
+
export interface WorkflowTransition {
|
|
114
|
+
name: string;
|
|
115
|
+
fromState: string[];
|
|
116
|
+
toState: string;
|
|
117
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2024
|
|
4
|
+
|
|
5
|
+
This program is 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
|
+
// Workflow state categories.
|
|
13
|
+
export var WorkflowCategory;
|
|
14
|
+
(function (WorkflowCategory) {
|
|
15
|
+
WorkflowCategory["initial"] = "initial";
|
|
16
|
+
WorkflowCategory["active"] = "active";
|
|
17
|
+
WorkflowCategory["closed"] = "closed";
|
|
18
|
+
WorkflowCategory["none"] = "none";
|
|
19
|
+
})(WorkflowCategory || (WorkflowCategory = {}));
|
|
20
|
+
//# sourceMappingURL=resource-interfaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-interfaces.js","sourceRoot":"","sources":["../../src/interfaces/resource-interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAqJF,6BAA6B;AAC7B,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,qCAAiB,CAAA;IACjB,qCAAiB,CAAA;IACjB,iCAAa,CAAA;AACf,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2024
|
|
4
|
+
|
|
5
|
+
This program is 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 { HandlebarsOptions, MacroGenerationContext, MacroMetadata } from '../interfaces/macros.js';
|
|
13
|
+
import type TaskQueue from './task-queue.js';
|
|
14
|
+
declare abstract class BaseMacro {
|
|
15
|
+
protected macroMetadata: MacroMetadata;
|
|
16
|
+
private readonly tasks;
|
|
17
|
+
private globalId;
|
|
18
|
+
private localCounter;
|
|
19
|
+
constructor(macroMetadata: MacroMetadata, tasks: TaskQueue);
|
|
20
|
+
protected abstract handleInject(context: MacroGenerationContext, input: unknown): Promise<string>;
|
|
21
|
+
protected abstract handleStatic(context: MacroGenerationContext, input: unknown): Promise<string>;
|
|
22
|
+
protected abstract handleValidate(input: unknown): void;
|
|
23
|
+
get metadata(): MacroMetadata;
|
|
24
|
+
private findDependencies;
|
|
25
|
+
private generatePlaceholder;
|
|
26
|
+
/**
|
|
27
|
+
* Function responsible for starting the promise and storing it along with its localId.
|
|
28
|
+
*/
|
|
29
|
+
invokeMacro: (context: MacroGenerationContext, options: HandlebarsOptions) => string | undefined;
|
|
30
|
+
}
|
|
31
|
+
export default BaseMacro;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2024
|
|
4
|
+
|
|
5
|
+
This program is 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 { generateRandomString } from '../utils/random.js';
|
|
13
|
+
import { handleMacroError } from './index.js';
|
|
14
|
+
class BaseMacro {
|
|
15
|
+
macroMetadata;
|
|
16
|
+
tasks;
|
|
17
|
+
globalId;
|
|
18
|
+
localCounter = 0;
|
|
19
|
+
constructor(macroMetadata, tasks) {
|
|
20
|
+
this.macroMetadata = macroMetadata;
|
|
21
|
+
this.tasks = tasks;
|
|
22
|
+
// Set a unique global id for each instance of the macro
|
|
23
|
+
this.globalId = `${generateRandomString(36, 10)}`;
|
|
24
|
+
}
|
|
25
|
+
get metadata() {
|
|
26
|
+
return this.macroMetadata;
|
|
27
|
+
}
|
|
28
|
+
findDependencies(input) {
|
|
29
|
+
// Define a regex pattern to identify dependencies in the input string.
|
|
30
|
+
const dependencyPattern = /<<macro::([a-zA-Z0-9_-]+)::([0-9]+)>>/g;
|
|
31
|
+
const dependencies = [];
|
|
32
|
+
let match;
|
|
33
|
+
while ((match = dependencyPattern.exec(input)) !== null) {
|
|
34
|
+
const [placeholder, globalId, localId] = match;
|
|
35
|
+
// Retrieve the task corresponding to the globalId and localId
|
|
36
|
+
const task = this.tasks.find(globalId, parseInt(localId, 10));
|
|
37
|
+
if (task) {
|
|
38
|
+
dependencies.push(task);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
console.warn(`Dependency not found for placeholder: ${placeholder} (globalId: ${globalId}, localId: ${localId})`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return dependencies;
|
|
45
|
+
}
|
|
46
|
+
generatePlaceholder() {
|
|
47
|
+
const localId = this.localCounter++;
|
|
48
|
+
return {
|
|
49
|
+
localId,
|
|
50
|
+
placeholder: `<<macro::${this.globalId}::${localId}>>`,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Function responsible for starting the promise and storing it along with its localId.
|
|
55
|
+
*/
|
|
56
|
+
invokeMacro = (context, options) => {
|
|
57
|
+
// Create a unique localId for each invocation
|
|
58
|
+
const { placeholder, localId } = this.generatePlaceholder();
|
|
59
|
+
const rawInput = options.fn(this);
|
|
60
|
+
let input = '{' + rawInput + '}';
|
|
61
|
+
if (context.mode === 'validate') {
|
|
62
|
+
try {
|
|
63
|
+
this.handleValidate(JSON.parse(input));
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
if (error instanceof Error) {
|
|
67
|
+
const errorMessage = `From card '${context.cardKey}' a macro validation error:\n\n${error.message}.\n\nCard content:\n ${input}`;
|
|
68
|
+
throw new Error(errorMessage);
|
|
69
|
+
}
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
// Extract dependencies
|
|
75
|
+
const dependencies = this.findDependencies(rawInput);
|
|
76
|
+
// Create a promise to resolve dependencies, execute the macro, and handle the results
|
|
77
|
+
const promise = Promise.all(dependencies.map((dep) => dep.promise))
|
|
78
|
+
.then(() => {
|
|
79
|
+
for (const dependency of dependencies) {
|
|
80
|
+
input = input.replace(dependency.placeholder, dependency.promiseResult || '');
|
|
81
|
+
}
|
|
82
|
+
let parsed;
|
|
83
|
+
try {
|
|
84
|
+
parsed = JSON.parse(input);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return 'Invalid JSON';
|
|
88
|
+
}
|
|
89
|
+
// Select the function to execute based on context mode
|
|
90
|
+
const functionToCall = context.mode === 'inject' ? this.handleInject : this.handleStatic;
|
|
91
|
+
// Execute the function and handle its result
|
|
92
|
+
return functionToCall(context, parsed);
|
|
93
|
+
})
|
|
94
|
+
.then((result) => {
|
|
95
|
+
const task = this.tasks.find(this.globalId, localId);
|
|
96
|
+
if (task) {
|
|
97
|
+
task.promiseResult = result;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
console.error(`Task not found after execution: macro ${this.metadata.name}, local id ${localId}.`);
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
.catch((err) => {
|
|
104
|
+
const task = this.tasks.find(this.globalId, localId);
|
|
105
|
+
if (task) {
|
|
106
|
+
task.promiseResult = handleMacroError(err, this.metadata.name, context);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
console.error(`Error handling task for macro ${this.metadata.name}, local id ${localId}:`, err);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
// Store the task
|
|
113
|
+
this.tasks.push({
|
|
114
|
+
globalId: this.globalId,
|
|
115
|
+
localId,
|
|
116
|
+
promise,
|
|
117
|
+
placeholder,
|
|
118
|
+
promiseResult: null,
|
|
119
|
+
macro: this.macroMetadata.name,
|
|
120
|
+
});
|
|
121
|
+
// Return the placeholder
|
|
122
|
+
return placeholder;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
export default BaseMacro;
|
|
126
|
+
//# sourceMappingURL=base-macro.js.map
|