@scifeon/sdk 0.96.0 → 0.97.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.
- package/dist/{app-generator.d.ts → app/app-generator.d.ts} +4 -2
- package/dist/{app-generator.js → app/app-generator.js} +25 -24
- package/dist/{app-persist.d.ts → app/app-persist.d.ts} +4 -1
- package/dist/{app-persist.js → app/app-persist.js} +39 -19
- package/dist/app/app-validator.d.ts +8 -0
- package/dist/{app-validator.js → app/app-validator.js} +13 -3
- package/dist/app/interfaces/app-json.interface.d.ts +4 -0
- package/dist/app/interfaces/app-json.interface.js +2 -0
- package/dist/app/interfaces/app-type.enum.d.ts +5 -0
- package/dist/app/interfaces/app-type.enum.js +9 -0
- package/dist/app/interfaces/contributions/contributions-json.interface.d.ts +55 -0
- package/dist/app/interfaces/contributions/contributions-json.interface.js +2 -0
- package/dist/app/interfaces/contributions/main-menu.interface.d.ts +12 -0
- package/dist/app/interfaces/contributions/main-menu.interface.js +2 -0
- package/dist/app/interfaces/contributions/menu-item.interface.d.ts +5 -0
- package/dist/app/interfaces/contributions/menu-item.interface.js +2 -0
- package/dist/app/interfaces/contributions/page-menu-item.interface.d.ts +10 -0
- package/dist/app/interfaces/contributions/page-menu-item.interface.js +2 -0
- package/dist/app/interfaces/contributions/page-menu.interface.d.ts +9 -0
- package/dist/app/interfaces/contributions/page-menu.interface.js +2 -0
- package/dist/app/interfaces/package-json.interface.d.ts +14 -0
- package/dist/app/interfaces/package-json.interface.js +2 -0
- package/dist/app/interfaces/webpack-config.interface.d.ts +5 -0
- package/dist/app/interfaces/webpack-config.interface.js +2 -0
- package/dist/cli/commands/app/validate.js +1 -1
- package/dist/webpack-app-config.js +1 -1
- package/dist/webpack-utils.js +2 -0
- package/package.json +1 -1
- package/dist/app-validator.d.ts +0 -6
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { IAppJson } from "./interfaces/app-json.interface";
|
|
2
|
+
import { IWebpackConfig } from "./interfaces/webpack-config.interface";
|
|
1
3
|
export declare class AppGenerator {
|
|
2
4
|
private config;
|
|
3
5
|
private appType;
|
|
@@ -10,8 +12,8 @@ export declare class AppGenerator {
|
|
|
10
12
|
private tsFiles;
|
|
11
13
|
private idCounter;
|
|
12
14
|
private validator;
|
|
13
|
-
constructor(config:
|
|
14
|
-
generate():
|
|
15
|
+
constructor(config: IWebpackConfig, appType: string);
|
|
16
|
+
generate(): IAppJson;
|
|
15
17
|
save(force?: boolean): void;
|
|
16
18
|
private transformPackageJson;
|
|
17
19
|
private transformContributionsJson;
|
|
@@ -4,12 +4,12 @@ exports.AppGenerator = void 0;
|
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const ts = require("typescript");
|
|
7
|
-
const action_target_1 = require("
|
|
7
|
+
const action_target_1 = require("../action-target");
|
|
8
|
+
const file_utils_1 = require("../file-utils");
|
|
9
|
+
const page_types_1 = require("../page-types");
|
|
10
|
+
const plugin_types_1 = require("../plugin-types");
|
|
8
11
|
const app_persist_1 = require("./app-persist");
|
|
9
12
|
const app_validator_1 = require("./app-validator");
|
|
10
|
-
const file_utils_1 = require("./file-utils");
|
|
11
|
-
const page_types_1 = require("./page-types");
|
|
12
|
-
const plugin_types_1 = require("./plugin-types");
|
|
13
13
|
class AppGenerator {
|
|
14
14
|
constructor(config, appType) {
|
|
15
15
|
this.config = config;
|
|
@@ -60,7 +60,7 @@ class AppGenerator {
|
|
|
60
60
|
transformPackageJson() {
|
|
61
61
|
this.packageJson.name = this.packageJson.name.replace(/\-/g, "_").replace(/\d/g, "_").replace(/\./g, "_");
|
|
62
62
|
this.packageJson.name = this.packageJson.name.replace("@", "").replace("/", "_");
|
|
63
|
-
this.packageJson.scifeon = this.packageJson.scifeon || {};
|
|
63
|
+
this.packageJson.scifeon = this.packageJson.scifeon || { contributions: { routes: [], plugins: [] } };
|
|
64
64
|
let versionFile = path.resolve("runtime", "scifeon", "VERSION");
|
|
65
65
|
if (fs.existsSync(versionFile)) {
|
|
66
66
|
const version = fs.readFileSync(versionFile).toString();
|
|
@@ -73,14 +73,14 @@ class AppGenerator {
|
|
|
73
73
|
this.packageJson.scifeon.runtimeVersion = version;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
const cliPackageJsonPath = path.resolve(__dirname, "..", "package.json");
|
|
76
|
+
const cliPackageJsonPath = path.resolve(__dirname, "..", "..", "package.json");
|
|
77
77
|
const cliPackageJson = require(cliPackageJsonPath);
|
|
78
78
|
this.packageJson.scifeon.cliVersion = cliPackageJson.version;
|
|
79
79
|
}
|
|
80
80
|
transformContributionsJson() {
|
|
81
81
|
if (this.contributionsJson.routes) {
|
|
82
|
-
for (const route of this.contributionsJson.routes.filter(
|
|
83
|
-
const pageId =
|
|
82
|
+
for (const route of this.contributionsJson.routes.filter(r => r.src)) {
|
|
83
|
+
const pageId = `routePage_${route.id}`;
|
|
84
84
|
this.contributionsJson.plugins.push({
|
|
85
85
|
id: pageId,
|
|
86
86
|
src: route.src,
|
|
@@ -98,7 +98,7 @@ class AppGenerator {
|
|
|
98
98
|
for (const item of this.contributionsJson.menu[menuKey].items) {
|
|
99
99
|
if (!item.src)
|
|
100
100
|
continue;
|
|
101
|
-
const pluginId =
|
|
101
|
+
const pluginId = `menuPanel_${menuKey}_${item.src}`;
|
|
102
102
|
this.contributionsJson.plugins.push({
|
|
103
103
|
id: pluginId,
|
|
104
104
|
src: item.src,
|
|
@@ -119,10 +119,11 @@ class AppGenerator {
|
|
|
119
119
|
}
|
|
120
120
|
generateScopes() {
|
|
121
121
|
const scopes = [];
|
|
122
|
-
|
|
122
|
+
const keys = Object.keys(this.contributionsJson);
|
|
123
|
+
for (const key of keys) {
|
|
123
124
|
if (key === "menu") {
|
|
124
125
|
for (const menuItem of Object.keys(this.contributionsJson.menu)) {
|
|
125
|
-
scopes.push(key
|
|
126
|
+
scopes.push(`${key}.${menuItem}`);
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
else if (key === "plugins") {
|
|
@@ -132,7 +133,7 @@ class AppGenerator {
|
|
|
132
133
|
}
|
|
133
134
|
plugin.types = plugin.types || [];
|
|
134
135
|
for (let type of plugin.types) {
|
|
135
|
-
type =
|
|
136
|
+
type = `plugins.${type.toLowerCase()}`;
|
|
136
137
|
if (scopes.indexOf(type) === -1) {
|
|
137
138
|
scopes.push(type);
|
|
138
139
|
}
|
|
@@ -155,7 +156,7 @@ class AppGenerator {
|
|
|
155
156
|
if (plugin.id) {
|
|
156
157
|
this.javascript.push(` id: '${plugin.id}',`);
|
|
157
158
|
}
|
|
158
|
-
const funcExt = fs.existsSync(path.resolve(this.config.appPath, plugin.src)
|
|
159
|
+
const funcExt = fs.existsSync(`${path.resolve(this.config.appPath, plugin.src)}.ts`) ? "t" : "j";
|
|
159
160
|
if (!plugin.chunk && plugin.types.length === 1) {
|
|
160
161
|
plugin.chunk = plugin.src;
|
|
161
162
|
}
|
|
@@ -166,7 +167,7 @@ class AppGenerator {
|
|
|
166
167
|
this.javascript.push(` func: require('../${plugin.src}.${funcExt}s'),`);
|
|
167
168
|
}
|
|
168
169
|
this.javascript.push(` types: ${JSON.stringify(plugin.types.map(p => p.toLowerCase()))},`);
|
|
169
|
-
if (fs.existsSync(path.resolve(this.config.appPath, plugin.src)
|
|
170
|
+
if (fs.existsSync(`${path.resolve(this.config.appPath, plugin.src)}.html`)) {
|
|
170
171
|
if (plugin.chunk) {
|
|
171
172
|
this.javascript.push(` view: () => import('../${plugin.src}.html' /* webpackChunkName: '${plugin.chunk}' */),`);
|
|
172
173
|
}
|
|
@@ -201,7 +202,7 @@ class AppGenerator {
|
|
|
201
202
|
const match = customElementRegex.exec(file.content);
|
|
202
203
|
const nameMatch = nameRegex.exec(match[1]);
|
|
203
204
|
this.contributionsJson.plugins.push({
|
|
204
|
-
id:
|
|
205
|
+
id: `customElement_${file.src}`,
|
|
205
206
|
src: file.src,
|
|
206
207
|
types: ["html_element"],
|
|
207
208
|
name: nameMatch[1].slice(1, -1),
|
|
@@ -214,7 +215,7 @@ class AppGenerator {
|
|
|
214
215
|
if (!this.fileIncludesDecorator(file.content, "@scifeonRoute"))
|
|
215
216
|
continue;
|
|
216
217
|
const match = routeRegex.exec(file.content);
|
|
217
|
-
const routeObject = new Function("PAGE_TYPE",
|
|
218
|
+
const routeObject = new Function("PAGE_TYPE", `return ${match[1]}`)(page_types_1.PAGE_TYPE);
|
|
218
219
|
const route = {
|
|
219
220
|
id: file.src,
|
|
220
221
|
src: file.src,
|
|
@@ -305,24 +306,24 @@ class AppGenerator {
|
|
|
305
306
|
type: plugin_types_1.PLUGIN_TYPE.ELN_STEP_BUILDER,
|
|
306
307
|
};
|
|
307
308
|
this.contributionsJson.plugins.push(builder);
|
|
308
|
-
const coreScr = file.src.replace(
|
|
309
|
+
const coreScr = file.src.replace(`/${file.name}`, "");
|
|
309
310
|
if (editMatch) {
|
|
310
311
|
const edit = JSON.parse(JSON.stringify(builder));
|
|
311
|
-
edit.src = coreScr
|
|
312
|
+
edit.src = `${coreScr}/${editMatch[1].slice(1, -1)}`;
|
|
312
313
|
edit.id += ".$EDIT";
|
|
313
314
|
edit.type += ".$EDIT";
|
|
314
315
|
this.contributionsJson.plugins.push(edit);
|
|
315
316
|
}
|
|
316
317
|
if (renderMatch) {
|
|
317
318
|
const render = JSON.parse(JSON.stringify(builder));
|
|
318
|
-
render.src = coreScr
|
|
319
|
+
render.src = `${coreScr}/${renderMatch[1].slice(1, -1)}`;
|
|
319
320
|
render.id += ".$RENDER";
|
|
320
321
|
render.type += ".$RENDER";
|
|
321
322
|
this.contributionsJson.plugins.push(render);
|
|
322
323
|
}
|
|
323
324
|
if (previewMatch) {
|
|
324
325
|
const preview = JSON.parse(JSON.stringify(builder));
|
|
325
|
-
preview.src = coreScr
|
|
326
|
+
preview.src = `${coreScr}/${previewMatch[1].slice(1, -1)}`;
|
|
326
327
|
preview.id += ".$PREVIEW";
|
|
327
328
|
preview.type += ".$PREVIEW";
|
|
328
329
|
this.contributionsJson.plugins.push(preview);
|
|
@@ -349,10 +350,10 @@ class AppGenerator {
|
|
|
349
350
|
type: plugin_types_1.PLUGIN_TYPE.DASHBOARD_WIDGET,
|
|
350
351
|
};
|
|
351
352
|
this.contributionsJson.plugins.push(dashboardWidget);
|
|
352
|
-
const configSrc = file.src
|
|
353
|
+
const configSrc = `${file.src}-config.ts`;
|
|
353
354
|
if (fs.existsSync(path.resolve(this.config.appPath, configSrc))) {
|
|
354
355
|
const config = JSON.parse(JSON.stringify(dashboardWidget));
|
|
355
|
-
config.src = file.src
|
|
356
|
+
config.src = `${file.src}-config`;
|
|
356
357
|
config.id += ".$CONFIG";
|
|
357
358
|
config.type += ".$CONFIG";
|
|
358
359
|
this.contributionsJson.plugins.push(config);
|
|
@@ -397,14 +398,14 @@ class AppGenerator {
|
|
|
397
398
|
type = pluginTypeRegex.exec(match[1]);
|
|
398
399
|
}
|
|
399
400
|
const idMatch = idRegex.exec(match[1]);
|
|
400
|
-
const id = idMatch !== null ? idMatch[1].slice(1, -1) : types.join("_")
|
|
401
|
+
const id = idMatch !== null ? idMatch[1].slice(1, -1) : `${types.join("_")}_${this.idCounter++}`;
|
|
401
402
|
const nameMatch = nameRegex.exec(match[1]);
|
|
402
403
|
const descriptionMatch = descriptionRegex.exec(match[1]);
|
|
403
404
|
const chunkMatch = chunkRegex.exec(match[1]);
|
|
404
405
|
const plugin = {
|
|
405
406
|
id,
|
|
406
407
|
src: file.src,
|
|
407
|
-
types: new Function("PLUGIN_TYPE",
|
|
408
|
+
types: new Function("PLUGIN_TYPE", `return [${types.join(", ")}]`)(plugin_types_1.PLUGIN_TYPE),
|
|
408
409
|
name: nameMatch !== null ? nameMatch[1].slice(1, -1) : file.name,
|
|
409
410
|
description: descriptionMatch !== null ? descriptionMatch[1].slice(1, -1) : null,
|
|
410
411
|
chunk: chunkMatch !== null ? chunkMatch[1].slice(1, -1) : null,
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import { IAppJson } from "./interfaces/app-json.interface";
|
|
2
|
+
import { IWebpackConfig } from "./interfaces/webpack-config.interface";
|
|
1
3
|
export declare class AppPersist {
|
|
2
4
|
private config;
|
|
3
5
|
private javascript;
|
|
4
6
|
private jsonDir;
|
|
5
7
|
private app;
|
|
6
8
|
private fileCounter;
|
|
7
|
-
constructor(config:
|
|
9
|
+
constructor(config: IWebpackConfig, javascript: string[], jsonDir: string, app: IAppJson);
|
|
8
10
|
save(force?: boolean): void;
|
|
9
11
|
private copyEntities;
|
|
10
12
|
private copyDashboards;
|
|
11
13
|
private copyDatabase;
|
|
12
14
|
private copyFiles;
|
|
15
|
+
private copyScheduledNotifications;
|
|
13
16
|
private transformCsvToJson;
|
|
14
17
|
private transformTsvToJson;
|
|
15
18
|
}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AppPersist = void 0;
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const path = require("path");
|
|
6
|
-
const file_utils_1 = require("
|
|
6
|
+
const file_utils_1 = require("../file-utils");
|
|
7
7
|
class AppPersist {
|
|
8
8
|
constructor(config, javascript, jsonDir, app) {
|
|
9
9
|
this.config = config;
|
|
@@ -19,9 +19,12 @@ class AppPersist {
|
|
|
19
19
|
fs.writeFileSync(genAppJsFile, currentGenAppJs);
|
|
20
20
|
}
|
|
21
21
|
file_utils_1.FileUtils.createDirRecurSync(this.jsonDir);
|
|
22
|
+
this.copyScheduledNotifications();
|
|
22
23
|
const genAppJsonFile = path.resolve(this.jsonDir, "gen-app.json");
|
|
23
24
|
const currentGenAppJson = JSON.stringify(this.app, null, 2);
|
|
24
|
-
if (!force
|
|
25
|
+
if (!force
|
|
26
|
+
&& fs.existsSync(genAppJsonFile)
|
|
27
|
+
&& fs.readFileSync(genAppJsonFile).toString() === currentGenAppJson) {
|
|
25
28
|
return;
|
|
26
29
|
}
|
|
27
30
|
fs.writeFileSync(genAppJsonFile, currentGenAppJson);
|
|
@@ -31,20 +34,21 @@ class AppPersist {
|
|
|
31
34
|
this.copyFiles();
|
|
32
35
|
}
|
|
33
36
|
copyEntities() {
|
|
34
|
-
if (this.app.scifeon.contributions.entities
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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);
|
|
45
48
|
}
|
|
46
|
-
|
|
49
|
+
entities = entities.concat(JSON.parse(content));
|
|
47
50
|
}
|
|
51
|
+
fs.writeFileSync(path.resolve(this.jsonDir, "entities.json"), JSON.stringify(entities, null, 2));
|
|
48
52
|
}
|
|
49
53
|
copyDashboards() {
|
|
50
54
|
if (this.app.scifeon.contributions.dashboards && Array.isArray(this.app.scifeon.contributions.dashboards)) {
|
|
@@ -52,13 +56,14 @@ class AppPersist {
|
|
|
52
56
|
let dashboardCounter = 0;
|
|
53
57
|
for (const filename of this.app.scifeon.contributions.dashboards) {
|
|
54
58
|
const dashboard = JSON.parse(fs.readFileSync(path.resolve(this.config.appPath, filename)).toString());
|
|
55
|
-
dashboard.id = this.app.namespace
|
|
59
|
+
dashboard.id = `${this.app.namespace}.${this.app.name}.${dashboardCounter++}`;
|
|
56
60
|
dashboards.push(dashboard);
|
|
57
61
|
}
|
|
58
62
|
fs.writeFileSync(path.resolve(this.jsonDir, "dashboards.json"), JSON.stringify(dashboards, null, 2));
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
65
|
copyDatabase() {
|
|
66
|
+
this.fileCounter = 0;
|
|
62
67
|
if (this.app.scifeon.contributions.database) {
|
|
63
68
|
const database = JSON.parse(JSON.stringify(this.app.scifeon.contributions.database));
|
|
64
69
|
file_utils_1.FileUtils.createDirRecurSync(path.resolve(this.jsonDir, "database"));
|
|
@@ -72,7 +77,7 @@ class AppPersist {
|
|
|
72
77
|
if (seed.toLowerCase().endsWith(".tsv")) {
|
|
73
78
|
content = this.transformTsvToJson(content);
|
|
74
79
|
}
|
|
75
|
-
const filename =
|
|
80
|
+
const filename = `seed_${this.fileCounter++}.json`;
|
|
76
81
|
fs.writeFileSync(path.resolve(this.jsonDir, "database", filename), content);
|
|
77
82
|
seeds.push(filename);
|
|
78
83
|
}
|
|
@@ -81,11 +86,11 @@ class AppPersist {
|
|
|
81
86
|
if (database.views && Array.isArray(database.views)) {
|
|
82
87
|
for (const view of database.views) {
|
|
83
88
|
const filename = `view_${this.fileCounter++}.`;
|
|
84
|
-
const sqlFilename = filename
|
|
89
|
+
const sqlFilename = `${filename}sql`;
|
|
85
90
|
fs.writeFileSync(path.resolve(this.jsonDir, "database", sqlFilename), fs.readFileSync(path.resolve(this.config.appPath, view.sql)).toString());
|
|
86
91
|
view.sql = sqlFilename;
|
|
87
92
|
if (view.fields) {
|
|
88
|
-
const fieldsFilename = filename
|
|
93
|
+
const fieldsFilename = `${filename}fields.datamodel`;
|
|
89
94
|
fs.writeFileSync(path.resolve(this.jsonDir, "database", fieldsFilename), fs.readFileSync(path.resolve(this.config.appPath, view.fields)).toString());
|
|
90
95
|
view.fields = fieldsFilename;
|
|
91
96
|
}
|
|
@@ -111,7 +116,7 @@ class AppPersist {
|
|
|
111
116
|
copyFiles() {
|
|
112
117
|
const filePath = path.resolve(this.jsonDir, "files");
|
|
113
118
|
if (this.app.scifeon.contributions.menu && this.app.scifeon.contributions.menu.main) {
|
|
114
|
-
for (const item of this.app.scifeon.contributions.menu.main.filter(
|
|
119
|
+
for (const item of this.app.scifeon.contributions.menu.main.filter(m => m.iconSrc)) {
|
|
115
120
|
const iconSrc = path.resolve(this.config.appPath, item.iconSrc);
|
|
116
121
|
const filename = path.basename(iconSrc);
|
|
117
122
|
const newPath = path.resolve(filePath, item.iconSrc);
|
|
@@ -131,6 +136,21 @@ class AppPersist {
|
|
|
131
136
|
delete this.app.scifeon.contributions.files;
|
|
132
137
|
}
|
|
133
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
|
+
}
|
|
134
154
|
transformCsvToJson(content) {
|
|
135
155
|
const lines = content.split("\n").map(l => l.split(";"));
|
|
136
156
|
const columns = lines[0].map(c => c && c.trim());
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -15,6 +15,7 @@ class AppValidator {
|
|
|
15
15
|
"database",
|
|
16
16
|
"files",
|
|
17
17
|
"previewFeatures",
|
|
18
|
+
"scheduledNotifications",
|
|
18
19
|
];
|
|
19
20
|
}
|
|
20
21
|
validatePackageJson(packageJson) {
|
|
@@ -39,13 +40,13 @@ class AppValidator {
|
|
|
39
40
|
if (!/^([a-zA-Z]\d*(\.[a-zA-Z])?)+$/i.test(packageJson.namespace)) {
|
|
40
41
|
throw new Error("Error in package.json: The namespace must be characters (a-z), numbers and dots.");
|
|
41
42
|
}
|
|
42
|
-
if (!/^([a-z]+(\_[a-z])?)+$/.test(packageJson.
|
|
43
|
+
if (!/^([a-z]+(\_[a-z])?)+$/.test(packageJson.name)) {
|
|
43
44
|
throw new Error("Error in package.json: The id must be letters, numbers, dot, dashes and underscores (_).");
|
|
44
45
|
}
|
|
45
46
|
if (packageJson.scifeon.scopes) {
|
|
46
47
|
const notValidScopes = packageJson.scifeon.scopes.filter(s => !this.validScopeKeys.some(vs => vs === s) && !s.startsWith("plugins.") && !s.startsWith("menu."));
|
|
47
48
|
if (notValidScopes.length) {
|
|
48
|
-
throw new Error(
|
|
49
|
+
throw new Error(`Error in contributions.json: The following keys are not recognized: ${notValidScopes}`);
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
}
|
|
@@ -121,7 +122,16 @@ class AppValidator {
|
|
|
121
122
|
for (const previewFeature of contributionsJson.previewFeatures) {
|
|
122
123
|
const keys = Object.keys(previewFeature);
|
|
123
124
|
if (requiredKeys.some(rk => !keys.includes(rk))) {
|
|
124
|
-
throw new Error(`Error in contributions.json: '${requiredKeys.join("' or '")}' missing in
|
|
125
|
+
throw new Error(`Error in contributions.json: '${requiredKeys.join("' or '")}' missing in previewFeature: ${JSON.stringify(previewFeature)}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (contributionsJson.scheduledNotifications) {
|
|
130
|
+
const requiredKeys = ["schedule", "query", "emailTemplate", "emailSubject"];
|
|
131
|
+
for (const scheduledNotification of contributionsJson.scheduledNotifications) {
|
|
132
|
+
const keys = Object.keys(scheduledNotification);
|
|
133
|
+
if (requiredKeys.some(rk => !keys.includes(rk))) {
|
|
134
|
+
throw new Error(`Error in contributions.json: '${requiredKeys.join("' or '")}' missing in scheduledNotifications: ${JSON.stringify(scheduledNotification)}`);
|
|
125
135
|
}
|
|
126
136
|
}
|
|
127
137
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppType = void 0;
|
|
4
|
+
var AppType;
|
|
5
|
+
(function (AppType) {
|
|
6
|
+
AppType["CORE"] = "core";
|
|
7
|
+
AppType["MODULE"] = "core";
|
|
8
|
+
AppType["DEMO"] = "demo";
|
|
9
|
+
})(AppType = exports.AppType || (exports.AppType = {}));
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { IMainMenu } from "./main-menu.interface";
|
|
2
|
+
import { IPageMenuItem } from "./page-menu-item.interface";
|
|
3
|
+
import { IPageMenu } from "./page-menu.interface";
|
|
4
|
+
export interface IContributionsJson {
|
|
5
|
+
files?: string[];
|
|
6
|
+
entities?: string[];
|
|
7
|
+
dashboards?: string[];
|
|
8
|
+
userRoles?: {
|
|
9
|
+
[roleName: string]: string;
|
|
10
|
+
};
|
|
11
|
+
scheduledNotifications?: {
|
|
12
|
+
description?: string;
|
|
13
|
+
schedule: "daily";
|
|
14
|
+
hourOfDay?: number;
|
|
15
|
+
query: string;
|
|
16
|
+
emailTemplate: string;
|
|
17
|
+
emailSubject?: string;
|
|
18
|
+
}[];
|
|
19
|
+
previewFeatures?: {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
description: string;
|
|
23
|
+
expireDate: string;
|
|
24
|
+
default?: boolean;
|
|
25
|
+
}[];
|
|
26
|
+
database?: {
|
|
27
|
+
prefix?: string;
|
|
28
|
+
views: {
|
|
29
|
+
prefix?: string;
|
|
30
|
+
name: string;
|
|
31
|
+
sql: string;
|
|
32
|
+
accessScope: "All" | "Department" | "Project" | "Admin" | "User";
|
|
33
|
+
fields?: string;
|
|
34
|
+
dbms?: ("sqlserver" | "sqlite")[];
|
|
35
|
+
}[];
|
|
36
|
+
datamodel: string;
|
|
37
|
+
sequences: {
|
|
38
|
+
id: string;
|
|
39
|
+
prefix: string;
|
|
40
|
+
minDigits: number;
|
|
41
|
+
type: string;
|
|
42
|
+
nextValue?: number;
|
|
43
|
+
env?: ("dev")[];
|
|
44
|
+
}[];
|
|
45
|
+
seed?: string[];
|
|
46
|
+
};
|
|
47
|
+
menu?: {
|
|
48
|
+
main?: IMainMenu[];
|
|
49
|
+
dev?: IPageMenu;
|
|
50
|
+
admin?: IPageMenuItem[];
|
|
51
|
+
data?: IPageMenuItem[];
|
|
52
|
+
};
|
|
53
|
+
routes: any[];
|
|
54
|
+
plugins: any[];
|
|
55
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IContributionsJson } from "./contributions/contributions-json.interface";
|
|
2
|
+
export interface IPackageJson {
|
|
3
|
+
name: string;
|
|
4
|
+
namespace: string;
|
|
5
|
+
description: string;
|
|
6
|
+
author: string;
|
|
7
|
+
version: string;
|
|
8
|
+
scifeon: {
|
|
9
|
+
cliVersion?: string;
|
|
10
|
+
runtimeVersion?: string;
|
|
11
|
+
scopes?: string[];
|
|
12
|
+
contributions: IContributionsJson;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ValidateCommand = void 0;
|
|
4
4
|
const fs = require("fs");
|
|
5
|
-
const app_validator_1 = require("../../../app-validator");
|
|
5
|
+
const app_validator_1 = require("../../../app/app-validator");
|
|
6
6
|
const logger_1 = require("../../../logger");
|
|
7
7
|
class ValidateCommand {
|
|
8
8
|
execute() {
|
|
@@ -9,7 +9,7 @@ const path = require("path");
|
|
|
9
9
|
const PostCompile = require("post-compile-webpack-plugin");
|
|
10
10
|
const tsconfig_paths_webpack_plugin_1 = require("tsconfig-paths-webpack-plugin");
|
|
11
11
|
const webpack = require("webpack");
|
|
12
|
-
const app_generator_1 = require("./app-generator");
|
|
12
|
+
const app_generator_1 = require("./app/app-generator");
|
|
13
13
|
const file_utils_1 = require("./file-utils");
|
|
14
14
|
const logger_1 = require("./logger");
|
|
15
15
|
const webpack_utils_1 = require("./webpack-utils");
|
package/dist/webpack-utils.js
CHANGED
|
@@ -43,6 +43,8 @@ class WebpackUtils {
|
|
|
43
43
|
tsConfigJson.exclude = tsConfigJson.exclude || [];
|
|
44
44
|
tsConfigJson.exclude.push("**/*.test.ts");
|
|
45
45
|
tsConfigJson.exclude.push("**/*.e2e-test.ts");
|
|
46
|
+
tsConfigJson.exclude.push("**/*.e2e-util.ts");
|
|
47
|
+
tsConfigJson.exclude.push("**/*.e2e-utils.ts");
|
|
46
48
|
const tempDir = getFileDirectory(file);
|
|
47
49
|
file_utils_1.FileUtils.createDirRecurSync(tempDir);
|
|
48
50
|
const newFile = path.join(tempDir, "tsconfig.temp.json");
|
package/package.json
CHANGED