nodefony 6.11.0 → 6.12.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/README.md CHANGED
@@ -134,9 +134,9 @@ You can follow Nodefony build with github actions at **<https://github.com/nodef
134
134
 
135
135
  To install or update nvm, you can use the install script:
136
136
  ```sh
137
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
137
+ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
138
138
  # or
139
- wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
139
+ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
140
140
 
141
141
  $ source ~/.bashrc # or source ~/.bash_profile
142
142
  $ nvm ls-remote # show all remote versions
@@ -44,7 +44,7 @@ class userEntity extends nodefony.Entity {
44
44
  allowNull: false,
45
45
  validate: {
46
46
  is: {
47
- args: /[^\w]|_|-|./g,
47
+ args: /^[\w-_.]+$/,
48
48
  msg: `username allow alphanumeric and ( _ | - | . ) characters`
49
49
  }
50
50
  /*notIn: {
@@ -100,7 +100,7 @@ class userEntity extends nodefony.Entity {
100
100
  allowNull: true,
101
101
  validate: {
102
102
  is: {
103
- args: /[^\w]|_|-|.|'/g,
103
+ args: /^[\w-_.]*$/,
104
104
  msg: `name allow alphanumeric characters`
105
105
  }
106
106
  }
@@ -110,7 +110,7 @@ class userEntity extends nodefony.Entity {
110
110
  allowNull: true,
111
111
  validate: {
112
112
  is: {
113
- args: /[^\w]|_|-|.|''/g,
113
+ args: /^[\w-_.]*$/,
114
114
  msg: `surname allow alphanumeric characters`
115
115
  }
116
116
  }
@@ -157,7 +157,19 @@ class userEntity extends nodefony.Entity {
157
157
  }
158
158
 
159
159
  registerModel(db) {
160
- class MyModel extends Model {}
160
+ class MyModel extends Model {
161
+ hasRole(name){
162
+ for (let role in this.roles) {
163
+ if (this.roles[role] === name) {
164
+ return true;
165
+ }
166
+ }
167
+ return false;
168
+ }
169
+ isGranted(role){
170
+ return this.hasRole(role);
171
+ }
172
+ }
161
173
  MyModel.init(this.getSchema(), {
162
174
  sequelize: db,
163
175
  modelName: this.name,
@@ -44,9 +44,13 @@ module.exports = merge(config, {
44
44
  externals: {},
45
45
  resolve: {
46
46
  extensions: ['.js', '.json', '.jsx', '.css', '.mjs'],
47
+ alias: {
48
+ "@modules": path.join(__dirname, "..", "..", "node_modules")
49
+ },
47
50
  fallback: {
48
51
  "path": false,
49
- "assert": false
52
+ "assert": false,
53
+ buffer: require.resolve('buffer/')
50
54
  }
51
55
  },
52
56
  module: {
@@ -122,6 +126,9 @@ module.exports = merge(config, {
122
126
  ]
123
127
  },
124
128
  plugins: [
129
+ new webpack.ProvidePlugin({
130
+ Buffer: ['buffer', 'Buffer'],
131
+ }),
125
132
  new MiniCssExtractPlugin({
126
133
  filename: "./css/[name].css"
127
134
  }),
@@ -1,5 +1,5 @@
1
1
  module.exports = {
2
- projectName: "Nodefony User",
2
+ projectName: "Nodefony API",
3
3
  logo: "/app/images/app-logo.png",
4
4
  urls: [{
5
5
  url: "/api/users/documentation",
@@ -9,4 +9,4 @@ module.exports = {
9
9
  name: "login"
10
10
  }],
11
11
  primaryName: "login"
12
- };
12
+ };
@@ -4,7 +4,7 @@ import {
4
4
  SwaggerUIStandalonePreset
5
5
  } from "swagger-ui-dist";
6
6
 
7
- import "swagger-ui/dist/swagger-ui.css";
7
+ import "@modules/swagger-ui/dist/swagger-ui.css";
8
8
  import "./swagger.css";
9
9
 
10
10
  const configSwagger = process.env.SWAGGER;
@@ -26,6 +26,11 @@ class Swagger {
26
26
  // Section 02 - Set logo
27
27
  logo[0].children[0].alt = this.config.projectName;
28
28
  logo[0].children[0].src = this.config.logo;
29
+
30
+ const newDiv = document.createElement("div");
31
+ const newContent = document.createTextNode(this.config.projectName);
32
+ newDiv.appendChild(newContent);
33
+ logo[0].append(newDiv)
29
34
  });
30
35
  });
31
36
  }
@@ -16,45 +16,46 @@
16
16
  ],
17
17
  "repository": {},
18
18
  "dependencies": {
19
- "@babel/core": "7.17.5",
19
+ "@babel/core": "7.17.7",
20
20
  "@babel/plugin-proposal-class-properties": "^7.16.7",
21
21
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
22
22
  "@babel/preset-env": "^7.16.11",
23
23
  "@babel/preset-react": "^7.16.7",
24
- "@popperjs/core": "^2.11.2",
25
- "@withshepherd/faker": "^5.5.5",
24
+ "@popperjs/core": "2.11.4",
25
+ "@withshepherd/faker": "5.5.5",
26
26
  "babel-loader": "^8.2.3",
27
27
  "babel-register": "^6.26.0",
28
28
  "bootstrap": "^5.1.3",
29
29
  "clean-webpack-plugin": "^4.0.0",
30
30
  "css-hot-loader": "^1.4.4",
31
- "css-loader": "6.6.0",
31
+ "css-loader": "6.7.1",
32
32
  "expose-loader": "^3.1.0",
33
33
  "font-awesome": "^4.7.0",
34
- "graphiql": "1.6.0",
34
+ "graphiql": "1.7.1",
35
35
  "graphql": "16.3.0",
36
- "graphql-ws": "5.6.2",
36
+ "graphql-ws": "5.6.3",
37
37
  "html-webpack-plugin": "^5.5.0",
38
38
  "imports-loader": "^3.1.1",
39
39
  "jquery": "^3.6.0",
40
- "mini-css-extract-plugin": "^2.5.3",
41
- "mongoose-paginate-v2": "1.6.2",
40
+ "mini-css-extract-plugin": "2.6.0",
41
+ "mongoose-paginate-v2": "1.6.3",
42
42
  "node-sass": "^7.0.1",
43
43
  "react": "^17.0.2",
44
44
  "react-dom": "^17.0.2",
45
45
  "sass-loader": "12.6.0",
46
46
  "style-loader": "^3.3.1",
47
47
  "svg-inline-loader": "^0.8.2",
48
- "swagger-ui": "4.5.2",
49
- "swagger-ui-dist": "4.5.2",
48
+ "swagger-ui": "4.6.2",
49
+ "swagger-ui-dist": "4.6.2",
50
50
  "terser-webpack-plugin": "5.3.1",
51
- "webpack": "5.69.1",
51
+ "webpack": "5.70.0",
52
52
  "webpack-merge": "^5.8.0"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@mapbox/node-pre-gyp": "^1.0.8",
56
- "node-gyp": "^8.4.1",
57
- "sequelize-cli": "^6.4.1"
56
+ "node-gyp": "9.0.0",
57
+ "sequelize-cli": "^6.4.1",
58
+ "stream": "0.0.2"
58
59
  },
59
60
  "license": "CECILL-B",
60
61
  "readmeFilename": "README.md",
@@ -134,9 +134,9 @@ You can follow Nodefony build with github actions at **<https://github.com/nodef
134
134
 
135
135
  To install or update nvm, you can use the install script:
136
136
  ```sh
137
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
137
+ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
138
138
  # or
139
- wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
139
+ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
140
140
 
141
141
  $ source ~/.bashrc # or source ~/.bash_profile
142
142
  $ nvm ls-remote # show all remote versions
@@ -34,17 +34,17 @@
34
34
  "node": ">=12"
35
35
  },
36
36
  "dependencies": {
37
- "mongoose": "6.1.10",
37
+ "mongoose": "6.2.7",
38
38
  "nodefony": "^{{version}}",
39
- "pm2": "^5.1.2",
39
+ "pm2": "5.2.0",
40
40
  "pm2-logrotate": "^2.7.0",
41
- "sequelize": "6.15.0",
42
- "webpack": "5.68.0",
41
+ "sequelize": "6.17.0",
42
+ "webpack": "5.70.0",
43
43
  "webpack-dev-server": "4.7.4"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@mapbox/node-pre-gyp": "^1.0.8",
47
- "node-gyp": "^8.4.1"
47
+ "node-gyp": "9.0.0"
48
48
  },
49
49
  "author": "{{authorFullName}} <{{authorMail}}>",
50
50
  "readmeFilename": "README.md",
@@ -146,7 +146,7 @@ class React extends nodefony.builders.sandbox {
146
146
  let gitP, cwd, gitS, gitC;
147
147
  try {
148
148
  cwd = path.resolve(this.response.path);
149
- gitP = require('simple-git/promise');
149
+ gitP = require('simple-git');
150
150
  gitS = gitP(cwd);
151
151
  gitC = gitP(this.location);
152
152
  } catch (e) {
@@ -183,7 +183,7 @@ class React extends nodefony.builders.sandbox {
183
183
  let gitP, cwd, git;
184
184
  try {
185
185
  cwd = path.resolve(this.response.path);
186
- gitP = require('simple-git/promise');
186
+ gitP = require('simple-git');
187
187
  git = gitP(cwd);
188
188
  } catch (e) {
189
189
  throw e;
@@ -18,33 +18,33 @@
18
18
  "repository": {},
19
19
  "dependencies": {
20
20
  {% if addons.workbox %}
21
- "workbox-webpack-plugin": "^6.4.2",
21
+ "workbox-webpack-plugin": "6.5.1",
22
22
  {% endif %}
23
23
  {% if addons.bootstrap %}
24
- "@popperjs/core": "^2.11.2",
24
+ "@popperjs/core": "2.11.4",
25
25
  "bootstrap": "^5.1.3",
26
26
  "jquery": "^3.6.0",
27
27
  "font-awesome": "^4.7.0",
28
28
  {% endif %}
29
29
  {% if addons.webpack %}
30
- "@babel/core": "^7.16.12",
30
+ "@babel/core": "7.17.7",
31
31
  "@babel/preset-env": "^7.16.11",
32
32
  "babel-loader": "^8.2.3",
33
33
  "clean-webpack-plugin": "^4.0.0",
34
34
  "css-hot-loader": "^1.4.4",
35
- "css-loader": "6.6.0",
35
+ "css-loader": "6.7.1",
36
36
  "expose-loader": "^3.1.0",
37
- "favicons": "^6.2.2",
37
+ "favicons": "6.2.2",
38
38
  "favicons-webpack-plugin": "^5.0.2",
39
39
  "html-webpack-plugin": "^5.5.0",
40
40
  "imports-loader": "^3.1.1",
41
- "mini-css-extract-plugin": "^2.5.3",
41
+ "mini-css-extract-plugin": "2.6.0",
42
42
  "node-sass": "^7.0.1",
43
- "sass-loader": "^12.4.0",
43
+ "sass-loader": "12.6.0",
44
44
  "sitemap-webpack-plugin": "^1.1.1",
45
45
  "style-loader": "^3.3.1",
46
46
  "terser-webpack-plugin": "5.3.1",
47
- "webpack": "5.68.0",
47
+ "webpack": "5.70.0",
48
48
  "webpack-merge": "^5.8.0"
49
49
  {% endif %}
50
50
  },
@@ -53,7 +53,7 @@
53
53
  "webpack-dev-server": "4.7.4",
54
54
  {% endif %}
55
55
  "@mapbox/node-pre-gyp": "^1.0.8",
56
- "node-gyp": "^8.4.1"
56
+ "node-gyp": "9.0.0"
57
57
  },
58
58
  "license": "",
59
59
  "readmeFilename": "README.md",
@@ -147,7 +147,9 @@ class Vue extends nodefony.builders.sandbox {
147
147
  stdio: "inherit"
148
148
  }, (code) => {
149
149
  if (code === 1) {
150
- return reject(new Error("install Vue cli new error : " + code));
150
+ this.log( new Error(`install Vue cli new error : ${code} ${args}`) ,"ERROR")
151
+ //return reject(new Error("install Vue cli new error : " + code));
152
+ return resolve(cmd);
151
153
  }
152
154
  return resolve(cmd);
153
155
  });
package/cli/start.js CHANGED
@@ -492,7 +492,7 @@ module.exports = class cliStart extends nodefony.cliKernel {
492
492
  let gitP, cwd, git;
493
493
  try {
494
494
  cwd = path.resolve(project.location, project.name);
495
- gitP = require('simple-git/promise');
495
+ gitP = require('simple-git');
496
496
  git = gitP(cwd);
497
497
  } catch (e) {
498
498
  throw e;
package/cli.es6 CHANGED
@@ -2,7 +2,10 @@ const Table = require('cli-table3');
2
2
  const asciify = require('asciify');
3
3
  //const inquirer = require('inquirer');
4
4
  //const commander = require('commander');
5
- const { program, command } = require('commander');
5
+ const {
6
+ program,
7
+ command
8
+ } = require('commander');
6
9
  const spawn = require('child_process').spawn;
7
10
  const spawnSync = require('child_process').spawnSync;
8
11
  const moment = require("moment");
@@ -222,7 +225,20 @@ class CLI extends nodefony.Service {
222
225
  }
223
226
 
224
227
  idle() {
225
- return this.idle = setInterval(() => {}, 0);
228
+ let resolve = null
229
+ let reject = null
230
+ const promise = new Promise((res, rej) => {
231
+ resolve = res
232
+ reject = rej
233
+ })
234
+ return function () {
235
+ return {
236
+ resolve,
237
+ promise,
238
+ reject
239
+ }
240
+ }()
241
+ //return this.idleId = setInterval(() => {}, 0);
226
242
  }
227
243
 
228
244
  checkVersion(version = null) {
@@ -440,13 +456,13 @@ class CLI extends nodefony.Service {
440
456
  return false;
441
457
  }
442
458
 
443
- displayTable(datas, options= defaultTableCli, syslog=null) {
444
- if( !datas || ! datas.length){
445
- return new Table(nodefony.extend({}, defaultTableCli, options ));
459
+ displayTable(datas, options = defaultTableCli, syslog = null) {
460
+ if (!datas || !datas.length) {
461
+ return new Table(nodefony.extend({}, defaultTableCli, options));
446
462
  }
447
463
  let table = null;
448
464
  try {
449
- table = new Table(nodefony.extend({}, defaultTableCli, options ));
465
+ table = new Table(nodefony.extend({}, defaultTableCli, options));
450
466
  if (datas) {
451
467
  for (let i = 0; i < datas.length; i++) {
452
468
  table.push(datas[i]);
@@ -39,6 +39,19 @@ class User {
39
39
  return this.roles;
40
40
  }
41
41
 
42
+ hasRole(name){
43
+ for (let role in this.roles) {
44
+ if (this.roles[role] === name) {
45
+ return true;
46
+ }
47
+ }
48
+ return false;
49
+ }
50
+
51
+ isGranted(role){
52
+ return this.hasRole(role);
53
+ }
54
+
42
55
  getPassword() {
43
56
  return this.password;
44
57
  }
@@ -90,4 +103,4 @@ class User {
90
103
  }
91
104
 
92
105
  nodefony.User = User;
93
- module.exports = User;
106
+ module.exports = User;
@@ -1,6 +1,7 @@
1
1
  const cron = require('node-cron');
2
2
  const defaultOptions = {
3
3
  scheduled: true,
4
+ recoverMissedExecutions: false,
4
5
  timezone: "Europe/Paris"
5
6
  };
6
7
 
@@ -17,13 +18,13 @@ class Cron extends nodefony.Service {
17
18
  this.cronTab = {};
18
19
  }
19
20
 
20
- showTasks() {
21
-
21
+ getTasks() {
22
+ return this.cron.getTasks()
22
23
  }
23
24
 
24
25
  getTask(name) {
25
26
  if (!name) {
26
- return this.cronTab;
27
+ throw new Error(`Task : ${name} not exist in cron tab`);
27
28
  }
28
29
  if (name in this.cronTab) {
29
30
  return this.cronTab[name];
@@ -56,38 +57,15 @@ class Cron extends nodefony.Service {
56
57
  if (name in this.cronTab) {
57
58
  throw new Error(`Task name : ${name} already exist in cron tab`);
58
59
  }
59
-
60
60
  try {
61
+ options.name = name ;
61
62
  this.cronTab[name] = this.cron.schedule(param, callback, options);
62
- const status = this.getStatus( name );
63
- switch(status){
64
- case "scheduled":
65
- this.log(`Start Task : ${name} status : ${status}`,"INFO", "CRONTAB");
66
- break;
67
- default:
68
- this.log(`Create Task : ${name} Start task to begin ! `,"INFO", "CRONTAB");
69
- }
70
63
  return this.cronTab[name];
71
64
  } catch (e) {
72
65
  throw e;
73
66
  }
74
67
  }
75
68
 
76
- getStatus(name){
77
- if (!name) {
78
- throw new Error("Cron getStatus bad parameters name ");
79
- }
80
- if (name in this.cronTab) {
81
- try {
82
- return this.cronTab[name].getStatus();
83
- } catch (e) {
84
- throw e;
85
- }
86
- }
87
- throw new Error(`Cron getStatus name: ${name} not found in cron tab !`);
88
- }
89
-
90
-
91
69
  startTask(name) {
92
70
  if (!name) {
93
71
  throw new Error("Cron startTask bad parameters name ");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodefony",
3
- "version": "6.11.0",
3
+ "version": "6.12.0",
4
4
  "main": "autoloader.es6",
5
5
  "description": "Nodefony Framework Core",
6
6
  "contributors": [],
@@ -32,23 +32,23 @@
32
32
  "nodefony": "bin/nodefony"
33
33
  },
34
34
  "dependencies": {
35
- "@babel/core": "7.17.5",
36
- "@babel/parser": "7.17.3",
35
+ "@babel/core": "7.17.7",
36
+ "@babel/parser": "7.17.7",
37
37
  "@babel/preset-env": "^7.16.10",
38
- "@nodefony/documentation-bundle": "6.11.0",
39
- "@nodefony/elastic-bundle": "6.11.0",
40
- "@nodefony/framework-bundle": "6.11.0",
41
- "@nodefony/http-bundle": "6.11.0",
42
- "@nodefony/mail-bundle": "6.11.0",
43
- "@nodefony/mongoose-bundle": "6.11.0",
44
- "@nodefony/monitoring-bundle": "6.11.0",
45
- "@nodefony/realtime-bundle": "6.11.0",
46
- "@nodefony/redis-bundle": "6.11.0",
47
- "@nodefony/security-bundle": "6.11.0",
48
- "@nodefony/sequelize-bundle": "6.11.0",
49
- "@nodefony/unittests-bundle": "6.11.0",
50
- "@vue/cli": "5.0.1",
51
- "@vue/cli-service-global": "^4.5.15",
38
+ "@nodefony/documentation-bundle": "6.12.0",
39
+ "@nodefony/elastic-bundle": "6.12.0",
40
+ "@nodefony/framework-bundle": "6.12.0",
41
+ "@nodefony/http-bundle": "6.12.0",
42
+ "@nodefony/mail-bundle": "6.12.0",
43
+ "@nodefony/mongoose-bundle": "6.12.0",
44
+ "@nodefony/monitoring-bundle": "6.12.0",
45
+ "@nodefony/realtime-bundle": "6.12.0",
46
+ "@nodefony/redis-bundle": "6.12.0",
47
+ "@nodefony/security-bundle": "6.12.0",
48
+ "@nodefony/sequelize-bundle": "6.12.0",
49
+ "@nodefony/unittests-bundle": "6.12.0",
50
+ "@vue/cli": "5.0.3",
51
+ "@vue/cli-service-global": "4.5.16",
52
52
  "asciify": "^1.3.5",
53
53
  "bluebird": "^3.7.2",
54
54
  "chai": "4.3.6",
@@ -56,11 +56,11 @@
56
56
  "cli-color": "^2.0.1",
57
57
  "cli-table3": "^0.6.1",
58
58
  "clui": "^0.3.6",
59
- "commander": "9.0.0",
59
+ "commander": "9.1.0",
60
60
  "core-js": "3.21.1",
61
61
  "create-react-app": "^5.0.0",
62
62
  "graphql": "16.3.0",
63
- "inquirer": "^8.2.0",
63
+ "inquirer": "8.2.1",
64
64
  "js-yaml": "^4.1.0",
65
65
  "lodash": "^4.17.21",
66
66
  "lodash.isregexp": "^4.0.1",
@@ -69,19 +69,19 @@
69
69
  "moment": "^2.29.1",
70
70
  "node-cron": "^3.0.0",
71
71
  "node-emoji": "^1.11.0",
72
- "npm": "8.5.2",
72
+ "npm": "8.5.5",
73
73
  "pm2": "5.2.0",
74
74
  "promise": "^8.1.0",
75
75
  "request": "^2.88.2",
76
76
  "semver": "^7.3.5",
77
77
  "shelljs": "^0.8.5",
78
78
  "shortid": "^2.2.16",
79
- "simple-git": "3.2.6",
79
+ "simple-git": "3.3.0",
80
80
  "spdx": "^0.5.2",
81
81
  "terser-webpack-plugin": "5.3.1",
82
82
  "twig": "^1.15.4",
83
83
  "uuid": "^8.3.2",
84
- "webpack": "5.69.1",
84
+ "webpack": "5.70.0",
85
85
  "xml2js": "^0.4.23",
86
86
  "yarn": "^1.22.17"
87
87
  },
package/syslog/syslog.es6 CHANGED
@@ -673,6 +673,9 @@ class Syslog extends nodefony.Events {
673
673
  }
674
674
 
675
675
  static wrapper(pdu) {
676
+ if (!pdu) {
677
+ throw new Error('Syslog pdu not defined')
678
+ }
676
679
  const date = new Date(pdu.timeStamp);
677
680
  switch (pdu.severity) {
678
681
  case 0: