nodefony 7.0.0-beta.2 → 7.0.0-beta.21
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/CHANGELOG.md +534 -8028
- package/README.md +33 -30
- package/autoloader.es6 +46 -48
- package/builder.es6 +66 -76
- package/cli/builder/bundles/bundle.js +57 -63
- package/cli/builder/bundles/controller.js +34 -38
- package/cli/builder/bundles/users-bundle/Command/fixtureTask.js +11 -12
- package/cli/builder/bundles/users-bundle/Command/usersCommand.js +23 -24
- package/cli/builder/bundles/users-bundle/Entity/mongoose/userEntity.js +25 -30
- package/cli/builder/bundles/users-bundle/Entity/sequelize/userEntity.js +42 -31
- package/cli/builder/bundles/users-bundle/Fixtures/users.js +24 -26
- package/cli/builder/bundles/users-bundle/Fixtures/usersFixtures.js +28 -29
- package/cli/builder/bundles/users-bundle/Resources/config/config.js +4 -3
- package/cli/builder/bundles/users-bundle/Resources/config/routing.js +2 -2
- package/cli/builder/bundles/users-bundle/Resources/config/security.js +9 -8
- package/cli/builder/bundles/users-bundle/Resources/config/webpack/webpack.dev.config.js +3 -3
- package/cli/builder/bundles/users-bundle/Resources/config/webpack/webpack.prod.config.js +4 -3
- package/cli/builder/bundles/users-bundle/Resources/config/webpack.config.js +74 -75
- package/cli/builder/bundles/users-bundle/Resources/scss/awesome/font-awesome.config.js +9 -9
- package/cli/builder/bundles/users-bundle/Resources/swagger/openapi/login.js +13 -13
- package/cli/builder/bundles/users-bundle/Resources/swagger/openapi/users.js +14 -14
- package/cli/builder/bundles/users-bundle/controller/api/graphql/graphqlController.js +13 -15
- package/cli/builder/bundles/users-bundle/controller/api/graphql/userResolver.js +29 -29
- package/cli/builder/bundles/users-bundle/controller/api/graphql/usertype.js +2 -2
- package/cli/builder/bundles/users-bundle/controller/api/openapi/loginApiController.js +34 -36
- package/cli/builder/bundles/users-bundle/controller/api/openapi/restUserController.js +32 -36
- package/cli/builder/bundles/users-bundle/controller/loginController.js +30 -34
- package/cli/builder/bundles/users-bundle/controller/usersController.js +54 -60
- package/cli/builder/bundles/users-bundle/package.json +27 -25
- package/cli/builder/bundles/users-bundle/pnpm-lock.yaml +4262 -0
- package/cli/builder/bundles/users-bundle/readme.md +7 -7
- package/cli/builder/bundles/users-bundle/services/usersService.js +97 -102
- package/cli/builder/bundles/users-bundle/src/providers/mongoose/userProvider.js +6 -8
- package/cli/builder/bundles/users-bundle/src/providers/sequelize/userProvider.js +9 -10
- package/cli/builder/bundles/users-bundle/tests/loginTest.js +119 -70
- package/cli/builder/bundles/users-bundle/usersBundle.js +2 -3
- package/cli/builder/microService/microService.js +139 -141
- package/cli/builder/microService/skeletons/package.json +23 -22
- package/cli/builder/project/project.js +228 -181
- package/cli/builder/project/skeletons/README.md +33 -30
- package/cli/builder/project/skeletons/bin/dev-deploy.sh +5 -0
- package/cli/builder/project/skeletons/bin/prod-deploy.sh +3 -0
- package/cli/builder/project/skeletons/config/config.js.skeleton +1 -0
- package/cli/builder/project/skeletons/config/pm2.config.js.skeleton +41 -17
- package/cli/builder/project/skeletons/eslintignore.skeleton +15 -0
- package/cli/builder/project/skeletons/eslintrc.js.skeleton +97 -0
- package/cli/builder/project/skeletons/gitignore.skeleton +1 -0
- package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.37.entity-user.js +137 -0
- package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.38.entity-session.js +97 -0
- package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.39.entity-requests.js +115 -0
- package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.40.entity-jwts.js +97 -0
- package/cli/builder/project/skeletons/migrations/migrations.skeleton.js +0 -2
- package/cli/builder/project/skeletons/package.json.twig +70 -0
- package/cli/builder/react/reactBuilder.js +59 -65
- package/cli/builder/sandbox/sandBoxBuilder.js +132 -134
- package/cli/builder/skeletons/app/appKernel.js +120 -2
- package/cli/builder/skeletons/config/config.js +1 -1
- package/cli/builder/skeletons/config/nodefony/framework-bundle.js +2 -1
- package/cli/builder/skeletons/config/nodefony/http-bundle.js +1 -0
- package/cli/builder/skeletons/config/nodefony/mongoose-bundle.js +38 -12
- package/cli/builder/skeletons/config/nodefony/monitoring-bundle.js +21 -2
- package/cli/builder/skeletons/config/nodefony/sequelize-bundle.js +122 -13
- package/cli/builder/skeletons/package.json.twig +57 -0
- package/cli/builder/skeletons/unittest/testFile.js +44 -45
- package/cli/builder/vue/skeletons/vue.config.js +84 -10
- package/cli/builder/vue/vueBuilder.js +116 -114
- package/cli/generate/generate.es6 +38 -39
- package/cli/install/install.js +45 -58
- package/cli/sequelize/sequelize.js +50 -39
- package/cli/start.js +353 -347
- package/cli/tools/pm2.es6 +55 -57
- package/cli/tools/tools.es6 +36 -37
- package/cli.es6 +280 -228
- package/container.es6 +51 -59
- package/error.es6 +25 -27
- package/fileClass.es6 +53 -55
- package/finder/file.es6 +5 -4
- package/finder/fileResult.es6 +23 -22
- package/finder/finder2.es6 +46 -54
- package/finder.es6 +88 -97
- package/kernel/annotations/annotations.es6 +44 -46
- package/kernel/api/api.es6 +6 -8
- package/kernel/api/graphqlApi.es6 +21 -21
- package/kernel/api/jsonApi.es6 +40 -45
- package/kernel/api/openApi.es6 +9 -11
- package/kernel/api/schemas/openApiSchema.js +61 -32
- package/kernel/babylon.es6 +31 -38
- package/kernel/bundle.es6 +252 -220
- package/kernel/cliKernel.es6 +157 -170
- package/kernel/command.es6 +17 -20
- package/kernel/commands/nodefonyCommand.es6 +111 -58
- package/kernel/commands/tasks/bundlesTask.es6 +14 -19
- package/kernel/controllers/controller.es6 +167 -180
- package/kernel/fixture.es6 +4 -7
- package/kernel/injections/injections.es6 +97 -103
- package/kernel/kernel.es6 +476 -384
- package/kernel/kernelWatcher.es6 +64 -54
- package/kernel/orm/entity.es6 +10 -12
- package/kernel/orm/orm.es6 +68 -48
- package/kernel/reader.es6 +45 -47
- package/kernel/security/encoder.es6 +8 -6
- package/kernel/security/factories/factory.es6 +34 -37
- package/kernel/security/factories/passeportFactory.es6 +13 -14
- package/kernel/security/provider.es6 +11 -13
- package/kernel/security/providers/chainProvider.es6 +13 -28
- package/kernel/security/providers/memoryProvider.es6 +7 -11
- package/kernel/security/providers/providerManager.es6 +11 -14
- package/kernel/security/providers/userEntityProvider.es6 +7 -8
- package/kernel/security/role.es6 +3 -3
- package/kernel/security/secureArea.es6 +143 -149
- package/kernel/security/tokens/token.es6 +30 -32
- package/kernel/security/user.es6 +19 -19
- package/kernel/serviceRealTime.es6 +5 -7
- package/kernel/services/connectionsService.es6 +20 -22
- package/kernel/services/cron/cronService.es6 +14 -16
- package/kernel/task.es6 +20 -26
- package/kernel/templates.es6 +4 -5
- package/kernel/templating/twig.es6 +56 -47
- package/kernel/tests/cliTest.js +7 -11
- package/kernel/tests/containerTest.js +25 -37
- package/kernel/tests/kernelTest.js +9 -16
- package/nodefony.es6 +279 -256
- package/notificationsCenter.es6 +28 -20
- package/package.json +40 -40
- package/protocol.es6 +19 -21
- package/protocols/bayeux.es6 +35 -38
- package/protocols/jsonRpc/jsonrpc.es6 +12 -14
- package/result.es6 +11 -12
- package/service.es6 +62 -62
- package/syslog/pdu.es6 +99 -91
- package/syslog/syslog.es6 +101 -102
- package/watcher.es6 +21 -20
- package/cli/builder/project/skeletons/jshintignore.skeleton +0 -1
- package/cli/builder/project/skeletons/jshintrc.skeleton +0 -60
- package/cli/builder/project/skeletons/package.json.skeleton +0 -52
- package/cli/builder/skeletons/package.json +0 -61
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
class Token {
|
|
2
|
-
|
|
3
|
-
constructor(name, roles = []) {
|
|
2
|
+
constructor (name, roles = []) {
|
|
4
3
|
this.name = name;
|
|
5
4
|
this.roles = [];
|
|
6
5
|
this.setRoles(roles);
|
|
@@ -11,20 +10,20 @@ class Token {
|
|
|
11
10
|
this.provider = null;
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
setFactory(name) {
|
|
13
|
+
setFactory (name) {
|
|
15
14
|
this.factory = name;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
setProvider(provider) {
|
|
17
|
+
setProvider (provider) {
|
|
19
18
|
this.provider = provider;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
getRoles() {
|
|
21
|
+
getRoles () {
|
|
23
22
|
return this.roles;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
hasRole(name) {
|
|
27
|
-
for (
|
|
25
|
+
hasRole (name) {
|
|
26
|
+
for (const role in this.roles) {
|
|
28
27
|
if (this.roles[role].role === name) {
|
|
29
28
|
return true;
|
|
30
29
|
}
|
|
@@ -32,7 +31,7 @@ class Token {
|
|
|
32
31
|
return false;
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
setRoles(roles) {
|
|
34
|
+
setRoles (roles) {
|
|
36
35
|
switch (nodefony.typeOf(roles)) {
|
|
37
36
|
case "string":
|
|
38
37
|
if (!this.hasRole(roles)) {
|
|
@@ -55,14 +54,12 @@ class Token {
|
|
|
55
54
|
if (!this.hasRole(roles.role)) {
|
|
56
55
|
this.roles.push(roles);
|
|
57
56
|
}
|
|
58
|
-
} else {
|
|
59
|
-
if (roles.role) {
|
|
60
|
-
|
|
61
|
-
this.roles.push(new nodefony.Role(roles.role));
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
throw new Error("Bad typeof roles ");
|
|
57
|
+
} else if (roles.role) {
|
|
58
|
+
if (!this.hasRole(roles.role)) {
|
|
59
|
+
this.roles.push(new nodefony.Role(roles.role));
|
|
65
60
|
}
|
|
61
|
+
} else {
|
|
62
|
+
throw new Error("Bad typeof roles ");
|
|
66
63
|
}
|
|
67
64
|
break;
|
|
68
65
|
default:
|
|
@@ -70,22 +67,22 @@ class Token {
|
|
|
70
67
|
}
|
|
71
68
|
}
|
|
72
69
|
|
|
73
|
-
getCredentials() {
|
|
70
|
+
getCredentials () {
|
|
74
71
|
return this.credentials;
|
|
75
72
|
}
|
|
76
73
|
|
|
77
|
-
eraseCredentials() {
|
|
74
|
+
eraseCredentials () {
|
|
78
75
|
if (this.user instanceof nodefony.User) {
|
|
79
76
|
this.user.eraseCredentials();
|
|
80
77
|
}
|
|
81
78
|
this.credentials = "";
|
|
82
79
|
}
|
|
83
80
|
|
|
84
|
-
getUser() {
|
|
81
|
+
getUser () {
|
|
85
82
|
return this.user;
|
|
86
83
|
}
|
|
87
84
|
|
|
88
|
-
setUser(user) {
|
|
85
|
+
setUser (user) {
|
|
89
86
|
if (user instanceof nodefony.User) {
|
|
90
87
|
this.user = user;
|
|
91
88
|
this.setRoles(this.user.roles);
|
|
@@ -96,38 +93,39 @@ class Token {
|
|
|
96
93
|
return this.user;
|
|
97
94
|
}
|
|
98
95
|
|
|
99
|
-
getUsername() {
|
|
96
|
+
getUsername () {
|
|
100
97
|
if (this.user instanceof nodefony.User) {
|
|
101
98
|
return this.user.getUsername();
|
|
102
99
|
}
|
|
103
100
|
return this.user;
|
|
104
101
|
}
|
|
105
102
|
|
|
106
|
-
isAuthenticated() {
|
|
103
|
+
isAuthenticated () {
|
|
107
104
|
return this.authenticated;
|
|
108
105
|
}
|
|
109
106
|
|
|
110
|
-
setAuthenticated(val) {
|
|
107
|
+
setAuthenticated (val) {
|
|
111
108
|
this.authenticated = val;
|
|
112
109
|
}
|
|
113
110
|
|
|
114
|
-
refreshToken(context) {
|
|
111
|
+
refreshToken (context) {
|
|
115
112
|
if (this.provider) {
|
|
116
|
-
|
|
113
|
+
const {user} = context;
|
|
117
114
|
return this.provider.loadUserByUsername(user.username)
|
|
118
|
-
.then((
|
|
115
|
+
.then((User) => {
|
|
119
116
|
this.roles = [];
|
|
120
117
|
this.user = null;
|
|
121
|
-
this.setUser(
|
|
118
|
+
this.setUser(User);
|
|
122
119
|
if (context && context.session) {
|
|
123
120
|
context.session.setMetaBag("security.token", this.serialize());
|
|
124
121
|
}
|
|
125
|
-
return
|
|
122
|
+
return User;
|
|
126
123
|
});
|
|
127
124
|
}
|
|
125
|
+
return null;
|
|
128
126
|
}
|
|
129
127
|
|
|
130
|
-
serialize() {
|
|
128
|
+
serialize () {
|
|
131
129
|
let user = null;
|
|
132
130
|
if (this.user && this.user.serialize) {
|
|
133
131
|
user = this.user.serialize();
|
|
@@ -135,16 +133,16 @@ class Token {
|
|
|
135
133
|
return {
|
|
136
134
|
name: this.name,
|
|
137
135
|
roles: this.roles,
|
|
138
|
-
user
|
|
136
|
+
user,
|
|
139
137
|
authenticated: this.authenticated,
|
|
140
138
|
factory: this.factory,
|
|
141
139
|
provider: this.provider ? this.provider.name : null
|
|
142
140
|
};
|
|
143
141
|
}
|
|
144
142
|
|
|
145
|
-
unserialize(token) {
|
|
143
|
+
unserialize (token) {
|
|
146
144
|
try {
|
|
147
|
-
for (
|
|
145
|
+
for (const ele in token) {
|
|
148
146
|
switch (ele) {
|
|
149
147
|
case "name":
|
|
150
148
|
break;
|
|
@@ -170,4 +168,4 @@ class Token {
|
|
|
170
168
|
}
|
|
171
169
|
|
|
172
170
|
nodefony.Token = Token;
|
|
173
|
-
module.exports = Token;
|
|
171
|
+
module.exports = Token;
|
package/kernel/security/user.es6
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
class User {
|
|
2
|
-
|
|
3
|
-
constructor(
|
|
2
|
+
constructor (
|
|
4
3
|
username,
|
|
5
4
|
password,
|
|
6
5
|
roles = [],
|
|
@@ -16,8 +15,8 @@ class User {
|
|
|
16
15
|
url = "",
|
|
17
16
|
image = ""
|
|
18
17
|
) {
|
|
19
|
-
if (
|
|
20
|
-
throw new Error(
|
|
18
|
+
if (username === "" || username === null || undefined === username) {
|
|
19
|
+
throw new Error("The username cannot be empty.");
|
|
21
20
|
}
|
|
22
21
|
this.username = username;
|
|
23
22
|
this.password = password;
|
|
@@ -35,12 +34,12 @@ class User {
|
|
|
35
34
|
this.image = image;
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
getRoles() {
|
|
37
|
+
getRoles () {
|
|
39
38
|
return this.roles;
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
hasRole(name){
|
|
43
|
-
for (
|
|
41
|
+
hasRole (name) {
|
|
42
|
+
for (const role in this.roles) {
|
|
44
43
|
if (this.roles[role] === name) {
|
|
45
44
|
return true;
|
|
46
45
|
}
|
|
@@ -48,39 +47,39 @@ class User {
|
|
|
48
47
|
return false;
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
isGranted(role){
|
|
50
|
+
isGranted (role) {
|
|
52
51
|
return this.hasRole(role);
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
getPassword() {
|
|
54
|
+
getPassword () {
|
|
56
55
|
return this.password;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
getUsername() {
|
|
58
|
+
getUsername () {
|
|
60
59
|
return this.username;
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
displayName() {
|
|
64
|
-
return this.name
|
|
62
|
+
displayName () {
|
|
63
|
+
return `${this.name} ${this.surname}`;
|
|
65
64
|
}
|
|
66
65
|
|
|
67
|
-
isAccountNonExpired() {
|
|
66
|
+
isAccountNonExpired () {
|
|
68
67
|
return this.accountNonExpired;
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
isAccountNonLocked() {
|
|
70
|
+
isAccountNonLocked () {
|
|
72
71
|
return this.accountNonLocked;
|
|
73
72
|
}
|
|
74
73
|
|
|
75
|
-
isCredentialsNonExpired() {
|
|
74
|
+
isCredentialsNonExpired () {
|
|
76
75
|
return this.credentialsNonExpired;
|
|
77
76
|
}
|
|
78
77
|
|
|
79
|
-
isEnabled() {
|
|
78
|
+
isEnabled () {
|
|
80
79
|
return this.enabled;
|
|
81
80
|
}
|
|
82
81
|
|
|
83
|
-
serialize() {
|
|
82
|
+
serialize () {
|
|
84
83
|
return {
|
|
85
84
|
username: this.username,
|
|
86
85
|
name: this.name,
|
|
@@ -93,9 +92,10 @@ class User {
|
|
|
93
92
|
accountNonLocked: this.accountNonLocked
|
|
94
93
|
};
|
|
95
94
|
}
|
|
96
|
-
|
|
95
|
+
|
|
96
|
+
unserialize (user) {
|
|
97
97
|
if (user) {
|
|
98
|
-
for (
|
|
98
|
+
for (const ele in user) {
|
|
99
99
|
this[ele] = user[ele];
|
|
100
100
|
}
|
|
101
101
|
}
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
class Realtime extends nodefony.Service {
|
|
2
|
-
|
|
3
|
-
constructor(name, container, notificationsCenter, options) {
|
|
2
|
+
constructor (name, container, notificationsCenter, options) {
|
|
4
3
|
super(name, container, notificationsCenter, options);
|
|
5
4
|
this.realTime = this.get("realTime");
|
|
6
5
|
}
|
|
7
6
|
|
|
8
|
-
createServer() {
|
|
7
|
+
createServer () {
|
|
9
8
|
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
startServer() {
|
|
11
|
+
startServer () {
|
|
13
12
|
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
stopServer() {
|
|
15
|
+
stopServer () {
|
|
17
16
|
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
nodefony.services.realtime = Realtime;
|
|
23
|
-
module.exports = Realtime;
|
|
21
|
+
module.exports = Realtime;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
const shortId = require(
|
|
1
|
+
const shortId = require("shortid");
|
|
2
2
|
|
|
3
3
|
class Connections extends nodefony.Service {
|
|
4
|
-
|
|
5
|
-
constructor(name, container, engine, classConnection) {
|
|
4
|
+
constructor (name, container, engine, classConnection) {
|
|
6
5
|
super(name, container, container.notificationsCenter);
|
|
7
6
|
this.engine = engine;
|
|
8
7
|
this.classConnection = classConnection;
|
|
9
8
|
this.connections = {};
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
boot() {
|
|
11
|
+
boot () {
|
|
13
12
|
if (this.kernel.ready) {
|
|
14
13
|
this.readConfig();
|
|
15
14
|
} else {
|
|
@@ -19,7 +18,7 @@ class Connections extends nodefony.Service {
|
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
createConnection(name, options = {}) {
|
|
21
|
+
createConnection (name, options = {}) {
|
|
23
22
|
return new Promise((resolve, reject) => {
|
|
24
23
|
try {
|
|
25
24
|
if (!name) {
|
|
@@ -28,37 +27,36 @@ class Connections extends nodefony.Service {
|
|
|
28
27
|
if (name in this.connections) {
|
|
29
28
|
throw new Error(`${this.name} client ${name} already exit `);
|
|
30
29
|
}
|
|
31
|
-
|
|
30
|
+
const conn = new this.classConnection(name, options, this);
|
|
32
31
|
this.connections[conn.name] = conn;
|
|
33
32
|
return conn.create(options)
|
|
34
33
|
.then((client) => {
|
|
35
34
|
this.fire("connection", client, conn);
|
|
36
35
|
return resolve(conn);
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
});
|
|
36
|
+
})
|
|
37
|
+
.catch((e) => reject(e));
|
|
40
38
|
} catch (e) {
|
|
41
39
|
return reject(e);
|
|
42
40
|
}
|
|
43
41
|
});
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
getConnection(name) {
|
|
44
|
+
getConnection (name) {
|
|
47
45
|
if (name in this.connections) {
|
|
48
46
|
return this.connections[name];
|
|
49
47
|
}
|
|
50
48
|
return null;
|
|
51
49
|
}
|
|
52
50
|
|
|
53
|
-
getClient(name) {
|
|
54
|
-
|
|
51
|
+
getClient (name) {
|
|
52
|
+
const connection = this.getConnection(name);
|
|
55
53
|
if (connection) {
|
|
56
54
|
return connection.client;
|
|
57
55
|
}
|
|
58
56
|
return null;
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
removeConnection(name) {
|
|
59
|
+
removeConnection (name) {
|
|
62
60
|
if (name in this.connections) {
|
|
63
61
|
delete this.connections[name];
|
|
64
62
|
return true;
|
|
@@ -66,21 +64,21 @@ class Connections extends nodefony.Service {
|
|
|
66
64
|
throw new Error(`${this.name} removeClient ${name} not found`);
|
|
67
65
|
}
|
|
68
66
|
|
|
69
|
-
generateId() {
|
|
67
|
+
generateId () {
|
|
70
68
|
return shortId.generate();
|
|
71
69
|
}
|
|
72
70
|
|
|
73
|
-
displayTable(connection, severity = "DEBUG") {
|
|
74
|
-
|
|
71
|
+
displayTable (connection, severity = "DEBUG") {
|
|
72
|
+
const options = {
|
|
75
73
|
head: [
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
`${this.name.toUpperCase()} CONNECTIONS NAME`,
|
|
75
|
+
"HOST"
|
|
76
|
+
]
|
|
79
77
|
};
|
|
80
78
|
try {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
const table = this.kernel.cli.displayTable(null, options);
|
|
80
|
+
const data = [];
|
|
81
|
+
const hosts = JSON.stringify(connection.hosts);
|
|
84
82
|
data.push(connection.name || "");
|
|
85
83
|
data.push(hosts || "");
|
|
86
84
|
table.push(data);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const cron = require(
|
|
1
|
+
const cron = require("node-cron");
|
|
2
2
|
const defaultOptions = {
|
|
3
3
|
scheduled: true,
|
|
4
4
|
recoverMissedExecutions: false,
|
|
@@ -6,8 +6,7 @@ const defaultOptions = {
|
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
class Cron extends nodefony.Service {
|
|
9
|
-
|
|
10
|
-
constructor(container) {
|
|
9
|
+
constructor (container) {
|
|
11
10
|
if (container) {
|
|
12
11
|
super("CRON", container);
|
|
13
12
|
} else {
|
|
@@ -18,11 +17,11 @@ class Cron extends nodefony.Service {
|
|
|
18
17
|
this.cronTab = {};
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
getTasks() {
|
|
22
|
-
return this.cron.getTasks()
|
|
20
|
+
getTasks () {
|
|
21
|
+
return this.cron.getTasks();
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
getTask(name) {
|
|
24
|
+
getTask (name) {
|
|
26
25
|
if (!name) {
|
|
27
26
|
throw new Error(`Task : ${name} not exist in cron tab`);
|
|
28
27
|
}
|
|
@@ -44,7 +43,7 @@ class Cron extends nodefony.Service {
|
|
|
44
43
|
* # * * * * * *
|
|
45
44
|
*
|
|
46
45
|
**/
|
|
47
|
-
createTask(name, param, options = defaultOptions, callback = null) {
|
|
46
|
+
createTask (name, param, options = defaultOptions, callback = null) {
|
|
48
47
|
if (arguments.length !== 4) {
|
|
49
48
|
throw new Error("Cron createTask bad parameters ");
|
|
50
49
|
}
|
|
@@ -58,7 +57,7 @@ class Cron extends nodefony.Service {
|
|
|
58
57
|
throw new Error(`Task name : ${name} already exist in cron tab`);
|
|
59
58
|
}
|
|
60
59
|
try {
|
|
61
|
-
options.name = name
|
|
60
|
+
options.name = name;
|
|
62
61
|
this.cronTab[name] = this.cron.schedule(param, callback, options);
|
|
63
62
|
return this.cronTab[name];
|
|
64
63
|
} catch (e) {
|
|
@@ -66,15 +65,15 @@ class Cron extends nodefony.Service {
|
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
startTask(name) {
|
|
68
|
+
startTask (name) {
|
|
70
69
|
if (!name) {
|
|
71
70
|
throw new Error("Cron startTask bad parameters name ");
|
|
72
71
|
}
|
|
73
72
|
if (name in this.cronTab) {
|
|
74
73
|
try {
|
|
75
74
|
const res = this.cronTab[name].start();
|
|
76
|
-
this.log(`Start Task : ${name} ! `,"INFO", "CRONTAB");
|
|
77
|
-
return res
|
|
75
|
+
this.log(`Start Task : ${name} ! `, "INFO", "CRONTAB");
|
|
76
|
+
return res;
|
|
78
77
|
} catch (e) {
|
|
79
78
|
throw e;
|
|
80
79
|
}
|
|
@@ -82,7 +81,7 @@ class Cron extends nodefony.Service {
|
|
|
82
81
|
throw new Error(`Cron startTask name: ${name} not found in cron tab !`);
|
|
83
82
|
}
|
|
84
83
|
|
|
85
|
-
stopTask(name) {
|
|
84
|
+
stopTask (name) {
|
|
86
85
|
if (!name) {
|
|
87
86
|
throw new Error("Cron stopTask bad parameters name ");
|
|
88
87
|
}
|
|
@@ -96,7 +95,7 @@ class Cron extends nodefony.Service {
|
|
|
96
95
|
throw new Error(`Cron stopTask name: ${name} not found in cron tab !`);
|
|
97
96
|
}
|
|
98
97
|
|
|
99
|
-
deleteTask(name) {
|
|
98
|
+
deleteTask (name) {
|
|
100
99
|
if (!name) {
|
|
101
100
|
throw new Error("Cron deleteTask bad parameters name ");
|
|
102
101
|
}
|
|
@@ -110,7 +109,7 @@ class Cron extends nodefony.Service {
|
|
|
110
109
|
throw new Error(`Cron deleteTask name: ${name} not found in cron tab !`);
|
|
111
110
|
}
|
|
112
111
|
|
|
113
|
-
validate(param) {
|
|
112
|
+
validate (param) {
|
|
114
113
|
try {
|
|
115
114
|
return this.cron.validate(param);
|
|
116
115
|
} catch (e) {
|
|
@@ -118,8 +117,7 @@ class Cron extends nodefony.Service {
|
|
|
118
117
|
throw new Error(`Invalid Cron Expression : ${param}`);
|
|
119
118
|
}
|
|
120
119
|
}
|
|
121
|
-
|
|
122
120
|
}
|
|
123
121
|
|
|
124
|
-
nodefony.services.cron = Cron
|
|
122
|
+
nodefony.services.cron = Cron;
|
|
125
123
|
module.exports = Cron;
|
package/kernel/task.es6
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* command:task:action
|
|
4
4
|
*/
|
|
5
5
|
class Task extends nodefony.Service {
|
|
6
|
-
constructor(name, command) {
|
|
6
|
+
constructor (name, command) {
|
|
7
7
|
super(name, command.container, command.notificationsCenter);
|
|
8
8
|
this.command = command;
|
|
9
9
|
this.cli = this.command.cli;
|
|
@@ -11,51 +11,46 @@ class Task extends nodefony.Service {
|
|
|
11
11
|
this.interactive = this.command.interactive;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
showBanner() {
|
|
14
|
+
showBanner () {
|
|
15
15
|
return this.cli.asciify(` ${this.command.name} ${this.name}`)
|
|
16
16
|
.then((data) => {
|
|
17
17
|
if (this.json) {
|
|
18
18
|
return data;
|
|
19
19
|
}
|
|
20
20
|
this.cli.clear();
|
|
21
|
-
|
|
21
|
+
const color = this.cli.clc.blueBright.bold;
|
|
22
22
|
console.log(color(data));
|
|
23
23
|
this.cli.blankLine();
|
|
24
24
|
return data;
|
|
25
25
|
})
|
|
26
|
-
.catch((e) =>
|
|
27
|
-
return e;
|
|
28
|
-
});
|
|
26
|
+
.catch((e) => e);
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
run(args) {
|
|
29
|
+
run (args) {
|
|
32
30
|
if (this.interactive) {
|
|
33
31
|
return this.interaction(args)
|
|
34
|
-
.then((response) =>
|
|
35
|
-
return this.generate(args, response);
|
|
36
|
-
})
|
|
37
|
-
.catch((e) => {
|
|
38
|
-
throw e;
|
|
39
|
-
});
|
|
40
|
-
} else {
|
|
41
|
-
return this.generate(args, null)
|
|
32
|
+
.then((response) => this.generate(args, response))
|
|
42
33
|
.catch((e) => {
|
|
43
34
|
throw e;
|
|
44
35
|
});
|
|
45
36
|
}
|
|
37
|
+
return this.generate(args, null)
|
|
38
|
+
.catch((e) => {
|
|
39
|
+
throw e;
|
|
40
|
+
});
|
|
46
41
|
}
|
|
47
42
|
|
|
48
|
-
generate(args, response) {
|
|
43
|
+
generate (args, response) {
|
|
49
44
|
return Promise.resolve(response);
|
|
50
|
-
//return Promise.reject(new Error(`Run Task Class : ${this.name} error has not generate method `));
|
|
45
|
+
// return Promise.reject(new Error(`Run Task Class : ${this.name} error has not generate method `));
|
|
51
46
|
}
|
|
52
47
|
|
|
53
|
-
interaction(
|
|
48
|
+
interaction (/* args*/) {
|
|
54
49
|
return Promise.resolve();
|
|
55
|
-
//return Promise.reject(new Error(`Run Task Class : ${this.name} has not interaction method no interactive mode`));
|
|
50
|
+
// return Promise.reject(new Error(`Run Task Class : ${this.name} has not interaction method no interactive mode`));
|
|
56
51
|
}
|
|
57
52
|
|
|
58
|
-
logger(pci, severity, msgid, msg) {
|
|
53
|
+
logger (pci, severity, msgid, msg) {
|
|
59
54
|
try {
|
|
60
55
|
if (!msgid) {
|
|
61
56
|
msgid = `COMMAND ${this.command.name} TASK ${this.name}`;
|
|
@@ -66,20 +61,19 @@ class Task extends nodefony.Service {
|
|
|
66
61
|
}
|
|
67
62
|
}
|
|
68
63
|
|
|
69
|
-
showHelp(help = "") {
|
|
64
|
+
showHelp (help = "") {
|
|
70
65
|
return help;
|
|
71
66
|
}
|
|
72
67
|
|
|
73
|
-
setHelp(command, description) {
|
|
68
|
+
setHelp (command, description) {
|
|
74
69
|
this.cli.displayTable([
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
["", this.cli.clc.green(command), description]
|
|
71
|
+
], this.command.optionsTables);
|
|
77
72
|
}
|
|
78
73
|
|
|
79
|
-
terminate(code) {
|
|
74
|
+
terminate (code) {
|
|
80
75
|
return this.cli.terminate(code);
|
|
81
76
|
}
|
|
82
|
-
|
|
83
77
|
}
|
|
84
78
|
|
|
85
79
|
nodefony.Task = Task;
|
package/kernel/templates.es6
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
class Template extends nodefony.Service {
|
|
2
|
-
|
|
3
|
-
constructor(container, engine, options) {
|
|
2
|
+
constructor (container, engine, options) {
|
|
4
3
|
super("TEMPLATE", container, container.get("notificationsCenter"));
|
|
5
4
|
this.settings = options;
|
|
6
5
|
this.engine = engine;
|
|
7
6
|
}
|
|
8
7
|
|
|
9
|
-
getEngine() {
|
|
8
|
+
getEngine () {
|
|
10
9
|
return this.engine;
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
extendFunction() {
|
|
12
|
+
extendFunction () {
|
|
14
13
|
this.log("extendFunction You must redefine this function in engine templating");
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
extendFilter() {
|
|
16
|
+
extendFilter () {
|
|
18
17
|
this.log("extendFilter You must redefine this function in engine templating");
|
|
19
18
|
}
|
|
20
19
|
}
|