@scifeon/sdk 0.99.0 → 0.101.0

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.
Files changed (102) hide show
  1. package/dist/{sdk/src/action-target.d.ts → action-target.d.ts} +6 -6
  2. package/dist/{sdk/src/action-target.js → action-target.js} +10 -10
  3. package/dist/{sdk/src/app → app}/app-generator.d.ts +34 -34
  4. package/dist/{sdk/src/app → app}/app-generator.js +460 -460
  5. package/dist/{sdk/src/app → app}/app-persist.d.ts +18 -18
  6. package/dist/{sdk/src/app → app}/app-persist.js +193 -193
  7. package/dist/{sdk/src/app → app}/app-validator.d.ts +8 -8
  8. package/dist/{sdk/src/app → app}/app-validator.js +145 -145
  9. package/dist/{sdk/src/app → app}/interfaces/app-json.interface.d.ts +4 -4
  10. package/dist/{sdk/src/app → app}/interfaces/app-json.interface.js +2 -2
  11. package/dist/{sdk/src/app → app}/interfaces/app-type.enum.d.ts +5 -5
  12. package/dist/{sdk/src/app → app}/interfaces/app-type.enum.js +9 -9
  13. package/dist/{sdk/src/app → app}/interfaces/contributions/contributions-json.interface.d.ts +55 -55
  14. package/dist/{sdk/src/app → app}/interfaces/contributions/contributions-json.interface.js +2 -2
  15. package/dist/{sdk/src/app → app}/interfaces/contributions/main-menu.interface.d.ts +12 -12
  16. package/dist/{sdk/src/app → app}/interfaces/contributions/main-menu.interface.js +2 -2
  17. package/dist/{sdk/src/app → app}/interfaces/contributions/menu-item.interface.d.ts +5 -5
  18. package/dist/{sdk/src/app → app}/interfaces/contributions/menu-item.interface.js +2 -2
  19. package/dist/{sdk/src/app → app}/interfaces/contributions/page-menu-item.interface.d.ts +10 -10
  20. package/dist/{sdk/src/app → app}/interfaces/contributions/page-menu-item.interface.js +2 -2
  21. package/dist/{sdk/src/app → app}/interfaces/contributions/page-menu.interface.d.ts +9 -9
  22. package/dist/{sdk/src/app → app}/interfaces/contributions/page-menu.interface.js +2 -2
  23. package/dist/{sdk/src/app → app}/interfaces/package-json.interface.d.ts +14 -14
  24. package/dist/{sdk/src/app → app}/interfaces/package-json.interface.js +2 -2
  25. package/dist/{sdk/src/app → app}/interfaces/webpack-config.interface.d.ts +5 -5
  26. package/dist/{sdk/src/app → app}/interfaces/webpack-config.interface.js +2 -2
  27. package/dist/{sdk/src/cli → cli}/commands/app/build.d.ts +4 -4
  28. package/dist/{sdk/src/cli → cli}/commands/app/build.js +43 -43
  29. package/dist/{sdk/src/cli → cli}/commands/app/clean.d.ts +3 -3
  30. package/dist/{sdk/src/cli → cli}/commands/app/clean.js +15 -15
  31. package/dist/{sdk/src/cli → cli}/commands/app/debug.d.ts +3 -3
  32. package/dist/{sdk/src/cli → cli}/commands/app/debug.js +22 -22
  33. package/dist/{sdk/src/cli → cli}/commands/app/e2e-test.d.ts +3 -3
  34. package/dist/{sdk/src/cli → cli}/commands/app/e2e-test.js +23 -23
  35. package/dist/{sdk/src/cli → cli}/commands/app/new.d.ts +6 -6
  36. package/dist/{sdk/src/cli → cli}/commands/app/new.js +190 -190
  37. package/dist/{sdk/src/cli → cli}/commands/app/package.d.ts +3 -3
  38. package/dist/{sdk/src/cli → cli}/commands/app/package.js +10 -10
  39. package/dist/{sdk/src/cli → cli}/commands/app/post-process.d.ts +8 -8
  40. package/dist/{sdk/src/cli → cli}/commands/app/post-process.js +122 -122
  41. package/dist/{sdk/src/cli → cli}/commands/app/scaffold.d.ts +4 -4
  42. package/dist/{sdk/src/cli → cli}/commands/app/scaffold.js +19 -19
  43. package/dist/{sdk/src/cli → cli}/commands/app/unit-test.d.ts +3 -3
  44. package/dist/{sdk/src/cli → cli}/commands/app/unit-test.js +11 -11
  45. package/dist/{sdk/src/cli → cli}/commands/app/validate.d.ts +3 -3
  46. package/dist/{sdk/src/cli → cli}/commands/app/validate.js +20 -20
  47. package/dist/{sdk/src/cli → cli}/commands/app/version.d.ts +3 -3
  48. package/dist/{sdk/src/cli → cli}/commands/app/version.js +17 -17
  49. package/dist/{sdk/src/cli → cli}/commands/app/watch.d.ts +3 -3
  50. package/dist/{sdk/src/cli → cli}/commands/app/watch.js +48 -48
  51. package/dist/{sdk/src/cli → cli}/commands/scifeon/download.d.ts +3 -3
  52. package/dist/{sdk/src/cli → cli}/commands/scifeon/download.js +48 -48
  53. package/dist/{sdk/src/cli → cli}/commands/scifeon/run.d.ts +3 -3
  54. package/dist/{sdk/src/cli → cli}/commands/scifeon/run.js +41 -41
  55. package/dist/{sdk/src/cli → cli}/config.d.ts +11 -11
  56. package/dist/{sdk/src/cli → cli}/config.js +23 -23
  57. package/dist/{sdk/src/cli → cli}/index.d.ts +9 -9
  58. package/dist/{sdk/src/cli → cli}/index.js +159 -159
  59. package/dist/{sdk/src/cli → cli}/webpack-runner.d.ts +1 -1
  60. package/dist/{sdk/src/cli → cli}/webpack-runner.js +26 -26
  61. package/dist/{sdk/src/download-utils.d.ts → download-utils.d.ts} +3 -3
  62. package/dist/{sdk/src/download-utils.js → download-utils.js} +50 -50
  63. package/dist/{sdk/src/file-utils.d.ts → file-utils.d.ts} +5 -5
  64. package/dist/{sdk/src/file-utils.js → file-utils.js} +41 -41
  65. package/dist/{sdk/src/html-report.d.ts → html-report.d.ts} +15 -15
  66. package/dist/{sdk/src/html-report.js → html-report.js} +212 -212
  67. package/dist/{sdk/src/index.d.ts → index.d.ts} +2 -2
  68. package/dist/{sdk/src/index.js → index.js} +23 -23
  69. package/dist/{sdk/src/logger.d.ts → logger.d.ts} +14 -14
  70. package/dist/{sdk/src/logger.js → logger.js} +52 -52
  71. package/dist/{sdk/src/measurement-units.d.ts → measurement-units.d.ts} +5 -5
  72. package/dist/{sdk/src/measurement-units.js → measurement-units.js} +9 -9
  73. package/dist/{sdk/src/page-types.d.ts → page-types.d.ts} +6 -6
  74. package/dist/{sdk/src/page-types.js → page-types.js} +10 -10
  75. package/dist/{sdk/src/plugin-types.d.ts → plugin-types.d.ts} +43 -42
  76. package/dist/{sdk/src/plugin-types.js → plugin-types.js} +47 -46
  77. package/dist/{sdk/src/unit-test-runner.d.ts → unit-test-runner.d.ts} +1 -1
  78. package/dist/{sdk/src/unit-test-runner.js → unit-test-runner.js} +82 -82
  79. package/dist/utils/test-helper.d.ts +4 -0
  80. package/dist/{sdk/src/utils → utils}/test-helper.js +46 -46
  81. package/dist/{sdk/src/webpack-app-config.d.ts → webpack-app-config.d.ts} +2 -2
  82. package/dist/{sdk/src/webpack-app-config.js → webpack-app-config.js} +248 -248
  83. package/dist/{sdk/src/webpack-utils.d.ts → webpack-utils.d.ts} +8 -8
  84. package/dist/{sdk/src/webpack-utils.js → webpack-utils.js} +91 -91
  85. package/package.json +72 -72
  86. package/resources/new-app/README.md +12 -12
  87. package/resources/new-app/editor/.vscode/launch.json +40 -40
  88. package/resources/new-app/gitignore.txt +6 -6
  89. package/resources/new-app/typescript/src/index.html +14 -14
  90. package/resources/new-app/typescript/src/index.ts +32 -32
  91. package/resources/new-app/typescript/test/e2e/frontpage.test.ts +16 -16
  92. package/resources/new-app/typescript/test/e2e-config.ts +14 -14
  93. package/resources/new-app/typescript/test/unit/index.test.ts +7 -7
  94. package/resources/new-app/typescript/tsconfig.json +39 -39
  95. package/resources/scaffold-templates/scaffold-e2e-test.ts +19 -19
  96. package/resources/test/chai.js +10706 -10706
  97. package/resources/test/mocha.css +326 -326
  98. package/resources/test/mocha.js +16590 -16590
  99. package/resources/test/tests.html +26 -26
  100. package/dist/plugins/src/xlsx-types.d.ts +0 -281
  101. package/dist/plugins/src/xlsx-types.js +0 -2
  102. package/dist/sdk/src/utils/test-helper.d.ts +0 -5
@@ -1,18 +1,18 @@
1
- import { IAppJson } from "./interfaces/app-json.interface";
2
- import { IWebpackConfig } from "./interfaces/webpack-config.interface";
3
- export declare class AppPersist {
4
- private config;
5
- private javascript;
6
- private jsonDir;
7
- private app;
8
- private fileCounter;
9
- constructor(config: IWebpackConfig, javascript: string[], jsonDir: string, app: IAppJson);
10
- save(force?: boolean): void;
11
- private copyEntities;
12
- private copyDashboards;
13
- private copyDatabase;
14
- private copyFiles;
15
- private copyScheduledNotifications;
16
- private transformCsvToJson;
17
- private transformTsvToJson;
18
- }
1
+ import { IAppJson } from "./interfaces/app-json.interface";
2
+ import { IWebpackConfig } from "./interfaces/webpack-config.interface";
3
+ export declare class AppPersist {
4
+ private config;
5
+ private javascript;
6
+ private jsonDir;
7
+ private app;
8
+ private fileCounter;
9
+ constructor(config: IWebpackConfig, javascript: string[], jsonDir: string, app: IAppJson);
10
+ save(force?: boolean): void;
11
+ private copyEntities;
12
+ private copyDashboards;
13
+ private copyDatabase;
14
+ private copyFiles;
15
+ private copyScheduledNotifications;
16
+ private transformCsvToJson;
17
+ private transformTsvToJson;
18
+ }
@@ -1,193 +1,193 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppPersist = void 0;
4
- const fs = require("fs");
5
- const path = require("path");
6
- const file_utils_1 = require("../file-utils");
7
- class AppPersist {
8
- constructor(config, javascript, jsonDir, app) {
9
- this.config = config;
10
- this.javascript = javascript;
11
- this.jsonDir = jsonDir;
12
- this.app = app;
13
- this.fileCounter = 0;
14
- }
15
- save(force = false) {
16
- const genAppJsFile = path.resolve(this.config.tempDir, "gen-app.js");
17
- const currentGenAppJs = this.javascript.join("\n");
18
- if (force || !fs.existsSync(genAppJsFile) || fs.readFileSync(genAppJsFile).toString() !== currentGenAppJs) {
19
- fs.writeFileSync(genAppJsFile, currentGenAppJs);
20
- }
21
- file_utils_1.FileUtils.createDirRecurSync(this.jsonDir);
22
- this.copyScheduledNotifications();
23
- const genAppJsonFile = path.resolve(this.jsonDir, "gen-app.json");
24
- const currentGenAppJson = JSON.stringify(this.app, null, 2);
25
- if (!force
26
- && fs.existsSync(genAppJsonFile)
27
- && fs.readFileSync(genAppJsonFile).toString() === currentGenAppJson) {
28
- return;
29
- }
30
- fs.writeFileSync(genAppJsonFile, currentGenAppJson);
31
- this.copyEntities();
32
- this.copyDashboards();
33
- this.copyDatabase();
34
- this.copyFiles();
35
- }
36
- copyEntities() {
37
- if (!this.app.scifeon.contributions.entities
38
- || !Array.isArray(this.app.scifeon.contributions.entities))
39
- return;
40
- let entities = [];
41
- for (const filename of this.app.scifeon.contributions.entities) {
42
- let content = fs.readFileSync(path.resolve(this.config.appPath, filename)).toString();
43
- if (filename.toLowerCase().endsWith(".csv")) {
44
- content = this.transformCsvToJson(content);
45
- }
46
- if (filename.toLowerCase().endsWith(".tsv")) {
47
- content = this.transformTsvToJson(content);
48
- }
49
- entities = entities.concat(JSON.parse(content));
50
- }
51
- fs.writeFileSync(path.resolve(this.jsonDir, "entities.json"), JSON.stringify(entities, null, 2));
52
- }
53
- copyDashboards() {
54
- if (this.app.scifeon.contributions.dashboards && Array.isArray(this.app.scifeon.contributions.dashboards)) {
55
- const dashboards = [];
56
- let dashboardCounter = 0;
57
- for (const filename of this.app.scifeon.contributions.dashboards) {
58
- const dashboard = JSON.parse(fs.readFileSync(path.resolve(this.config.appPath, filename)).toString());
59
- dashboard.id = `${this.app.namespace}.${this.app.name}.${dashboardCounter++}`;
60
- dashboards.push(dashboard);
61
- }
62
- fs.writeFileSync(path.resolve(this.jsonDir, "dashboards.json"), JSON.stringify(dashboards, null, 2));
63
- }
64
- }
65
- copyDatabase() {
66
- this.fileCounter = 0;
67
- if (this.app.scifeon.contributions.database) {
68
- const database = JSON.parse(JSON.stringify(this.app.scifeon.contributions.database));
69
- file_utils_1.FileUtils.createDirRecurSync(path.resolve(this.jsonDir, "database"));
70
- if (database.seed && Array.isArray(database.seed)) {
71
- const seeds = [];
72
- for (const seed of database.seed) {
73
- let content = fs.readFileSync(path.resolve(this.config.appPath, seed)).toString();
74
- if (seed.toLowerCase().endsWith(".csv")) {
75
- content = this.transformCsvToJson(content);
76
- }
77
- if (seed.toLowerCase().endsWith(".tsv")) {
78
- content = this.transformTsvToJson(content);
79
- }
80
- const filename = `seed_${this.fileCounter++}.json`;
81
- fs.writeFileSync(path.resolve(this.jsonDir, "database", filename), content);
82
- seeds.push(filename);
83
- }
84
- database.seed = seeds;
85
- }
86
- if (database.views && Array.isArray(database.views)) {
87
- for (const view of database.views) {
88
- const filename = `view_${this.fileCounter++}.`;
89
- const sqlFilename = `${filename}sql`;
90
- fs.writeFileSync(path.resolve(this.jsonDir, "database", sqlFilename), fs.readFileSync(path.resolve(this.config.appPath, view.sql)).toString());
91
- view.sql = sqlFilename;
92
- if (view.fields) {
93
- const fieldsFilename = `${filename}fields.datamodel`;
94
- fs.writeFileSync(path.resolve(this.jsonDir, "database", fieldsFilename), fs.readFileSync(path.resolve(this.config.appPath, view.fields)).toString());
95
- view.fields = fieldsFilename;
96
- }
97
- }
98
- }
99
- if (database.datamodel) {
100
- fs.writeFileSync(path.resolve(this.jsonDir, "database", "datamodel.scifeon"), fs.readFileSync(path.resolve(this.config.appPath, database.datamodel)).toString());
101
- }
102
- if (database.extendTables) {
103
- fs.writeFileSync(path.resolve(this.jsonDir, "database", "extendTables.scifeon"), fs.readFileSync(path.resolve(this.config.appPath, database.extendTables)).toString());
104
- }
105
- if (database.sequences) {
106
- for (const seq of database.sequences) {
107
- if (!seq.type) {
108
- seq.type = "Custom";
109
- }
110
- }
111
- }
112
- fs.writeFileSync(path.resolve(this.jsonDir, "database.json"), JSON.stringify(database, null, 2));
113
- delete this.app.scifeon.contributions.database;
114
- }
115
- }
116
- copyFiles() {
117
- const filePath = path.resolve(this.jsonDir, "files");
118
- if (this.app.scifeon.contributions.menu && this.app.scifeon.contributions.menu.main) {
119
- for (const item of this.app.scifeon.contributions.menu.main.filter(m => m.iconSrc)) {
120
- const iconSrc = path.resolve(this.config.appPath, item.iconSrc);
121
- const filename = path.basename(iconSrc);
122
- const newPath = path.resolve(filePath, item.iconSrc);
123
- file_utils_1.FileUtils.createDirRecurSync(newPath.replace(filename, ""));
124
- fs.copyFileSync(iconSrc, newPath);
125
- item.iconSrc = `/api/app/files/${this.app.namespace}/${this.app.name}/${item.iconSrc}`;
126
- }
127
- }
128
- if (this.app.scifeon.contributions.files) {
129
- for (const file of this.app.scifeon.contributions.files) {
130
- const fileSrc = path.resolve(this.config.appPath, file);
131
- const filename = path.basename(fileSrc);
132
- const newPath = path.resolve(filePath, file);
133
- file_utils_1.FileUtils.createDirRecurSync(newPath.replace(filename, ""));
134
- fs.copyFileSync(fileSrc, newPath);
135
- }
136
- delete this.app.scifeon.contributions.files;
137
- }
138
- }
139
- copyScheduledNotifications() {
140
- const scheduledNotifications = this.app.scifeon.contributions.scheduledNotifications;
141
- if (!scheduledNotifications || !Array.isArray(scheduledNotifications))
142
- return;
143
- file_utils_1.FileUtils.createDirRecurSync(path.resolve(this.jsonDir, "scheduledNotifications"));
144
- for (const sn of scheduledNotifications) {
145
- const filename = `sn_${this.fileCounter++}.`;
146
- const sqlFilename = `${filename}sql`;
147
- fs.writeFileSync(path.resolve(this.jsonDir, "scheduledNotifications", sqlFilename), fs.readFileSync(path.resolve(this.config.appPath, sn.query)).toString());
148
- sn.query = sqlFilename;
149
- const templateFilename = `${filename}html`;
150
- fs.writeFileSync(path.resolve(this.jsonDir, "scheduledNotifications", templateFilename), fs.readFileSync(path.resolve(this.config.appPath, sn.emailTemplate)).toString());
151
- sn.emailTemplate = templateFilename;
152
- }
153
- }
154
- transformCsvToJson(content) {
155
- const lines = content.split("\n").map(l => l.split(";"));
156
- const columns = lines[0].map(c => c && c.trim());
157
- const objects = [];
158
- for (let i = 1; i < lines.length; i++) {
159
- const object = {};
160
- for (let c = 0; c < columns.length; c++) {
161
- let value = lines[i][c];
162
- value = value && value.trim();
163
- if (value) {
164
- object[columns[c]] = value;
165
- }
166
- }
167
- if (Object.keys(object).length) {
168
- objects.push(object);
169
- }
170
- }
171
- return JSON.stringify(objects, null, 2);
172
- }
173
- transformTsvToJson(content) {
174
- const lines = content.split("\n").map(l => l.split("\t"));
175
- const columns = lines[0].map(c => c && c.trim());
176
- const objects = [];
177
- for (let i = 1; i < lines.length; i++) {
178
- const object = {};
179
- for (let c = 0; c < columns.length; c++) {
180
- let value = lines[i][c];
181
- value = value && value.trim();
182
- if (value) {
183
- object[columns[c]] = value;
184
- }
185
- }
186
- if (Object.keys(object).length) {
187
- objects.push(object);
188
- }
189
- }
190
- return JSON.stringify(objects, null, 2);
191
- }
192
- }
193
- exports.AppPersist = AppPersist;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppPersist = void 0;
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const file_utils_1 = require("../file-utils");
7
+ class AppPersist {
8
+ constructor(config, javascript, jsonDir, app) {
9
+ this.config = config;
10
+ this.javascript = javascript;
11
+ this.jsonDir = jsonDir;
12
+ this.app = app;
13
+ this.fileCounter = 0;
14
+ }
15
+ save(force = false) {
16
+ const genAppJsFile = path.resolve(this.config.tempDir, "gen-app.js");
17
+ const currentGenAppJs = this.javascript.join("\n");
18
+ if (force || !fs.existsSync(genAppJsFile) || fs.readFileSync(genAppJsFile).toString() !== currentGenAppJs) {
19
+ fs.writeFileSync(genAppJsFile, currentGenAppJs);
20
+ }
21
+ file_utils_1.FileUtils.createDirRecurSync(this.jsonDir);
22
+ this.copyScheduledNotifications();
23
+ const genAppJsonFile = path.resolve(this.jsonDir, "gen-app.json");
24
+ const currentGenAppJson = JSON.stringify(this.app, null, 2);
25
+ if (!force
26
+ && fs.existsSync(genAppJsonFile)
27
+ && fs.readFileSync(genAppJsonFile).toString() === currentGenAppJson) {
28
+ return;
29
+ }
30
+ fs.writeFileSync(genAppJsonFile, currentGenAppJson);
31
+ this.copyEntities();
32
+ this.copyDashboards();
33
+ this.copyDatabase();
34
+ this.copyFiles();
35
+ }
36
+ copyEntities() {
37
+ if (!this.app.scifeon.contributions.entities
38
+ || !Array.isArray(this.app.scifeon.contributions.entities))
39
+ return;
40
+ let entities = [];
41
+ for (const filename of this.app.scifeon.contributions.entities) {
42
+ let content = fs.readFileSync(path.resolve(this.config.appPath, filename)).toString();
43
+ if (filename.toLowerCase().endsWith(".csv")) {
44
+ content = this.transformCsvToJson(content);
45
+ }
46
+ if (filename.toLowerCase().endsWith(".tsv")) {
47
+ content = this.transformTsvToJson(content);
48
+ }
49
+ entities = entities.concat(JSON.parse(content));
50
+ }
51
+ fs.writeFileSync(path.resolve(this.jsonDir, "entities.json"), JSON.stringify(entities, null, 2));
52
+ }
53
+ copyDashboards() {
54
+ if (this.app.scifeon.contributions.dashboards && Array.isArray(this.app.scifeon.contributions.dashboards)) {
55
+ const dashboards = [];
56
+ let dashboardCounter = 0;
57
+ for (const filename of this.app.scifeon.contributions.dashboards) {
58
+ const dashboard = JSON.parse(fs.readFileSync(path.resolve(this.config.appPath, filename)).toString());
59
+ dashboard.id = `${this.app.namespace}.${this.app.name}.${dashboardCounter++}`;
60
+ dashboards.push(dashboard);
61
+ }
62
+ fs.writeFileSync(path.resolve(this.jsonDir, "dashboards.json"), JSON.stringify(dashboards, null, 2));
63
+ }
64
+ }
65
+ copyDatabase() {
66
+ this.fileCounter = 0;
67
+ if (this.app.scifeon.contributions.database) {
68
+ const database = JSON.parse(JSON.stringify(this.app.scifeon.contributions.database));
69
+ file_utils_1.FileUtils.createDirRecurSync(path.resolve(this.jsonDir, "database"));
70
+ if (database.seed && Array.isArray(database.seed)) {
71
+ const seeds = [];
72
+ for (const seed of database.seed) {
73
+ let content = fs.readFileSync(path.resolve(this.config.appPath, seed)).toString();
74
+ if (seed.toLowerCase().endsWith(".csv")) {
75
+ content = this.transformCsvToJson(content);
76
+ }
77
+ if (seed.toLowerCase().endsWith(".tsv")) {
78
+ content = this.transformTsvToJson(content);
79
+ }
80
+ const filename = `seed_${this.fileCounter++}.json`;
81
+ fs.writeFileSync(path.resolve(this.jsonDir, "database", filename), content);
82
+ seeds.push(filename);
83
+ }
84
+ database.seed = seeds;
85
+ }
86
+ if (database.views && Array.isArray(database.views)) {
87
+ for (const view of database.views) {
88
+ const filename = `view_${this.fileCounter++}.`;
89
+ const sqlFilename = `${filename}sql`;
90
+ fs.writeFileSync(path.resolve(this.jsonDir, "database", sqlFilename), fs.readFileSync(path.resolve(this.config.appPath, view.sql)).toString());
91
+ view.sql = sqlFilename;
92
+ if (view.fields) {
93
+ const fieldsFilename = `${filename}fields.datamodel`;
94
+ fs.writeFileSync(path.resolve(this.jsonDir, "database", fieldsFilename), fs.readFileSync(path.resolve(this.config.appPath, view.fields)).toString());
95
+ view.fields = fieldsFilename;
96
+ }
97
+ }
98
+ }
99
+ if (database.datamodel) {
100
+ fs.writeFileSync(path.resolve(this.jsonDir, "database", "datamodel.scifeon"), fs.readFileSync(path.resolve(this.config.appPath, database.datamodel)).toString());
101
+ }
102
+ if (database.extendTables) {
103
+ fs.writeFileSync(path.resolve(this.jsonDir, "database", "extendTables.scifeon"), fs.readFileSync(path.resolve(this.config.appPath, database.extendTables)).toString());
104
+ }
105
+ if (database.sequences) {
106
+ for (const seq of database.sequences) {
107
+ if (!seq.type) {
108
+ seq.type = "Custom";
109
+ }
110
+ }
111
+ }
112
+ fs.writeFileSync(path.resolve(this.jsonDir, "database.json"), JSON.stringify(database, null, 2));
113
+ delete this.app.scifeon.contributions.database;
114
+ }
115
+ }
116
+ copyFiles() {
117
+ const filePath = path.resolve(this.jsonDir, "files");
118
+ if (this.app.scifeon.contributions.menu && this.app.scifeon.contributions.menu.main) {
119
+ for (const item of this.app.scifeon.contributions.menu.main.filter(m => m.iconSrc)) {
120
+ const iconSrc = path.resolve(this.config.appPath, item.iconSrc);
121
+ const filename = path.basename(iconSrc);
122
+ const newPath = path.resolve(filePath, item.iconSrc);
123
+ file_utils_1.FileUtils.createDirRecurSync(newPath.replace(filename, ""));
124
+ fs.copyFileSync(iconSrc, newPath);
125
+ item.iconSrc = `/api/app/files/${this.app.namespace}/${this.app.name}/${item.iconSrc}`;
126
+ }
127
+ }
128
+ if (this.app.scifeon.contributions.files) {
129
+ for (const file of this.app.scifeon.contributions.files) {
130
+ const fileSrc = path.resolve(this.config.appPath, file);
131
+ const filename = path.basename(fileSrc);
132
+ const newPath = path.resolve(filePath, file);
133
+ file_utils_1.FileUtils.createDirRecurSync(newPath.replace(filename, ""));
134
+ fs.copyFileSync(fileSrc, newPath);
135
+ }
136
+ delete this.app.scifeon.contributions.files;
137
+ }
138
+ }
139
+ copyScheduledNotifications() {
140
+ const scheduledNotifications = this.app.scifeon.contributions.scheduledNotifications;
141
+ if (!scheduledNotifications || !Array.isArray(scheduledNotifications))
142
+ return;
143
+ file_utils_1.FileUtils.createDirRecurSync(path.resolve(this.jsonDir, "scheduledNotifications"));
144
+ for (const sn of scheduledNotifications) {
145
+ const filename = `sn_${this.fileCounter++}.`;
146
+ const sqlFilename = `${filename}sql`;
147
+ fs.writeFileSync(path.resolve(this.jsonDir, "scheduledNotifications", sqlFilename), fs.readFileSync(path.resolve(this.config.appPath, sn.query)).toString());
148
+ sn.query = sqlFilename;
149
+ const templateFilename = `${filename}html`;
150
+ fs.writeFileSync(path.resolve(this.jsonDir, "scheduledNotifications", templateFilename), fs.readFileSync(path.resolve(this.config.appPath, sn.emailTemplate)).toString());
151
+ sn.emailTemplate = templateFilename;
152
+ }
153
+ }
154
+ transformCsvToJson(content) {
155
+ const lines = content.split("\n").map(l => l.split(";"));
156
+ const columns = lines[0].map(c => c && c.trim());
157
+ const objects = [];
158
+ for (let i = 1; i < lines.length; i++) {
159
+ const object = {};
160
+ for (let c = 0; c < columns.length; c++) {
161
+ let value = lines[i][c];
162
+ value = value && value.trim();
163
+ if (value) {
164
+ object[columns[c]] = value;
165
+ }
166
+ }
167
+ if (Object.keys(object).length) {
168
+ objects.push(object);
169
+ }
170
+ }
171
+ return JSON.stringify(objects, null, 2);
172
+ }
173
+ transformTsvToJson(content) {
174
+ const lines = content.split("\n").map(l => l.split("\t"));
175
+ const columns = lines[0].map(c => c && c.trim());
176
+ const objects = [];
177
+ for (let i = 1; i < lines.length; i++) {
178
+ const object = {};
179
+ for (let c = 0; c < columns.length; c++) {
180
+ let value = lines[i][c];
181
+ value = value && value.trim();
182
+ if (value) {
183
+ object[columns[c]] = value;
184
+ }
185
+ }
186
+ if (Object.keys(object).length) {
187
+ objects.push(object);
188
+ }
189
+ }
190
+ return JSON.stringify(objects, null, 2);
191
+ }
192
+ }
193
+ exports.AppPersist = AppPersist;
@@ -1,8 +1,8 @@
1
- import { IContributionsJson } from "./interfaces/contributions/contributions-json.interface";
2
- import { IPackageJson } from "./interfaces/package-json.interface";
3
- export declare class AppValidator {
4
- private validScopeKeys;
5
- static reservedMenus: string[];
6
- validatePackageJson(packageJson: IPackageJson): void;
7
- validateContributionsJson(contributionsJson: IContributionsJson, appPath?: string): void;
8
- }
1
+ import { IContributionsJson } from "./interfaces/contributions/contributions-json.interface";
2
+ import { IPackageJson } from "./interfaces/package-json.interface";
3
+ export declare class AppValidator {
4
+ private validScopeKeys;
5
+ static reservedMenus: string[];
6
+ validatePackageJson(packageJson: IPackageJson): void;
7
+ validateContributionsJson(contributionsJson: IContributionsJson, appPath?: string): void;
8
+ }