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
package/notificationsCenter.es6
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
const events = require(
|
|
1
|
+
const events = require("events");
|
|
2
2
|
const regListenOn = /^on(.*)$/;
|
|
3
3
|
const defaultNbListeners = 20;
|
|
4
|
-
const _ = require(
|
|
4
|
+
const _ = require("lodash");
|
|
5
5
|
|
|
6
6
|
class Events extends events.EventEmitter {
|
|
7
|
-
|
|
8
|
-
constructor(settings, context, options = {}) {
|
|
7
|
+
constructor (settings, context, options = {}) {
|
|
9
8
|
super(options);
|
|
10
9
|
if (options.nbListeners) {
|
|
11
10
|
this.setMaxListeners(options.nbListeners || defaultNbListeners);
|
|
@@ -14,28 +13,32 @@ class Events extends events.EventEmitter {
|
|
|
14
13
|
this.settingsToListen(settings, context);
|
|
15
14
|
}
|
|
16
15
|
}
|
|
16
|
+
|
|
17
|
+
|
|
17
18
|
/**
|
|
18
19
|
*
|
|
19
20
|
* @method listen
|
|
20
21
|
*
|
|
21
22
|
*/
|
|
22
|
-
listen(context, eventName, callback) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (typeof
|
|
23
|
+
listen (context, eventName, callback) {
|
|
24
|
+
const event = arguments[1];
|
|
25
|
+
const ContextClosure = this;
|
|
26
|
+
if (typeof callback === "function" || callback instanceof Function) {
|
|
26
27
|
this.addListener(eventName, callback.bind(context));
|
|
27
28
|
}
|
|
28
|
-
return function() {
|
|
29
|
+
return function () {
|
|
29
30
|
Array.prototype.unshift.call(arguments, event);
|
|
30
31
|
return ContextClosure.fire.apply(ContextClosure, arguments);
|
|
31
32
|
};
|
|
32
33
|
}
|
|
34
|
+
|
|
35
|
+
|
|
33
36
|
/**
|
|
34
37
|
*
|
|
35
38
|
* @method fire
|
|
36
39
|
*
|
|
37
40
|
*/
|
|
38
|
-
fire(...args) {
|
|
41
|
+
fire (...args) {
|
|
39
42
|
try {
|
|
40
43
|
return super.emit(...args);
|
|
41
44
|
} catch (e) {
|
|
@@ -43,13 +46,13 @@ class Events extends events.EventEmitter {
|
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
48
|
|
|
46
|
-
async emitAsync(type, ...args) {
|
|
49
|
+
async emitAsync (type, ...args) {
|
|
47
50
|
const handler = _.get(this._events, type);
|
|
48
51
|
if (_.isEmpty(handler) && !_.isFunction(handler)) {
|
|
49
52
|
return false;
|
|
50
53
|
}
|
|
51
|
-
|
|
52
|
-
if (typeof handler ===
|
|
54
|
+
const tab = [];
|
|
55
|
+
if (typeof handler === "function") {
|
|
53
56
|
tab.push(await Reflect.apply(handler, this, args));
|
|
54
57
|
} else {
|
|
55
58
|
let size = handler.length;
|
|
@@ -62,24 +65,27 @@ class Events extends events.EventEmitter {
|
|
|
62
65
|
size--;
|
|
63
66
|
}
|
|
64
67
|
}
|
|
65
|
-
|
|
68
|
+
|
|
69
|
+
/* for await (const func of handler) {
|
|
66
70
|
tab.push(await Reflect.apply(func, this, args));
|
|
67
71
|
}*/
|
|
68
72
|
}
|
|
69
73
|
return tab;
|
|
70
74
|
}
|
|
71
75
|
|
|
72
|
-
async fireAsync(...args) {
|
|
76
|
+
async fireAsync (...args) {
|
|
73
77
|
return this.emitAsync(...args);
|
|
74
78
|
}
|
|
79
|
+
|
|
80
|
+
|
|
75
81
|
/**
|
|
76
82
|
*
|
|
77
83
|
* @method settingsToListen
|
|
78
84
|
*
|
|
79
85
|
*/
|
|
80
|
-
settingsToListen(localSettings, context) {
|
|
81
|
-
for (
|
|
82
|
-
|
|
86
|
+
settingsToListen (localSettings, context) {
|
|
87
|
+
for (const i in localSettings) {
|
|
88
|
+
const res = regListenOn.exec(i);
|
|
83
89
|
if (!res) {
|
|
84
90
|
continue;
|
|
85
91
|
}
|
|
@@ -90,12 +96,14 @@ class Events extends events.EventEmitter {
|
|
|
90
96
|
this.on(res[0], localSettings[i]);
|
|
91
97
|
}
|
|
92
98
|
}
|
|
99
|
+
|
|
100
|
+
|
|
93
101
|
/**
|
|
94
102
|
*
|
|
95
103
|
* @method unListen
|
|
96
104
|
*
|
|
97
105
|
*/
|
|
98
|
-
unListen(...args) {
|
|
106
|
+
unListen (...args) {
|
|
99
107
|
return this.removeListener(...args);
|
|
100
108
|
}
|
|
101
109
|
}
|
|
@@ -103,7 +111,7 @@ class Events extends events.EventEmitter {
|
|
|
103
111
|
nodefony.Events = Events;
|
|
104
112
|
nodefony.notificationsCenter = {
|
|
105
113
|
notification: Events,
|
|
106
|
-
create
|
|
114
|
+
create (settings, context, nbListener) {
|
|
107
115
|
return new Events(settings, context, nbListener);
|
|
108
116
|
}
|
|
109
117
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodefony",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.21",
|
|
4
4
|
"main": "autoloader.es6",
|
|
5
5
|
"description": "Nodefony Framework Core",
|
|
6
6
|
"contributors": [],
|
|
7
7
|
"scripts": {
|
|
8
|
-
"nodefony": "./bin/nodefony",
|
|
9
|
-
"start": "./bin/nodefony"
|
|
8
|
+
"nodefony": "node ./bin/nodefony",
|
|
9
|
+
"start": "node ./bin/nodefony"
|
|
10
10
|
},
|
|
11
11
|
"private": false,
|
|
12
12
|
"keywords": [
|
|
@@ -32,66 +32,66 @@
|
|
|
32
32
|
"nodefony": "bin/nodefony"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@babel/core": "7.
|
|
36
|
-
"@babel/parser": "7.
|
|
37
|
-
"@graphql-tools/merge": "
|
|
38
|
-
"@graphql-tools/schema": "
|
|
39
|
-
"@graphql-tools/utils": "
|
|
40
|
-
"@nodefony/elastic-bundle": "7.0.0-beta.
|
|
41
|
-
"@nodefony/framework-bundle": "7.0.0-beta.
|
|
42
|
-
"@nodefony/http-bundle": "7.0.0-beta.
|
|
43
|
-
"@nodefony/mail-bundle": "7.0.0-beta.
|
|
44
|
-
"@nodefony/mongoose-bundle": "7.0.0-beta.
|
|
45
|
-
"@nodefony/monitoring-bundle": "7.0.0-beta.
|
|
46
|
-
"@nodefony/realtime-bundle": "7.0.0-beta.
|
|
47
|
-
"@nodefony/redis-bundle": "7.0.0-beta.
|
|
48
|
-
"@nodefony/security-bundle": "7.0.0-beta.
|
|
49
|
-
"@nodefony/sequelize-bundle": "7.0.0-beta.
|
|
50
|
-
"@nodefony/unittests-bundle": "7.0.0-beta.
|
|
35
|
+
"@babel/core": "7.23.2",
|
|
36
|
+
"@babel/parser": "7.23.0",
|
|
37
|
+
"@graphql-tools/merge": "9.0.0",
|
|
38
|
+
"@graphql-tools/schema": "10.0.0",
|
|
39
|
+
"@graphql-tools/utils": "10.0.7",
|
|
40
|
+
"@nodefony/elastic-bundle": "7.0.0-beta.21",
|
|
41
|
+
"@nodefony/framework-bundle": "7.0.0-beta.21",
|
|
42
|
+
"@nodefony/http-bundle": "7.0.0-beta.21",
|
|
43
|
+
"@nodefony/mail-bundle": "7.0.0-beta.21",
|
|
44
|
+
"@nodefony/mongoose-bundle": "7.0.0-beta.21",
|
|
45
|
+
"@nodefony/monitoring-bundle": "7.0.0-beta.21",
|
|
46
|
+
"@nodefony/realtime-bundle": "7.0.0-beta.21",
|
|
47
|
+
"@nodefony/redis-bundle": "7.0.0-beta.21",
|
|
48
|
+
"@nodefony/security-bundle": "7.0.0-beta.21",
|
|
49
|
+
"@nodefony/sequelize-bundle": "7.0.0-beta.21",
|
|
50
|
+
"@nodefony/unittests-bundle": "7.0.0-beta.21",
|
|
51
51
|
"@vue/cli": "5.0.8",
|
|
52
52
|
"@vue/cli-service": "5.0.8",
|
|
53
53
|
"@vue/cli-service-global": "4.5.19",
|
|
54
54
|
"asciify": "^1.3.5",
|
|
55
55
|
"bluebird": "^3.7.2",
|
|
56
|
-
"chai": "4.3.
|
|
56
|
+
"chai": "4.3.10",
|
|
57
57
|
"chokidar": "^3.5.3",
|
|
58
58
|
"cli-color": "2.0.3",
|
|
59
|
-
"cli-table3": "0.6.
|
|
59
|
+
"cli-table3": "0.6.3",
|
|
60
60
|
"clui": "^0.3.6",
|
|
61
|
-
"commander": "
|
|
62
|
-
"core-js": "3.
|
|
61
|
+
"commander": "11.1.0",
|
|
62
|
+
"core-js": "3.33.0",
|
|
63
63
|
"create-react-app": "5.0.1",
|
|
64
|
-
"graphql": "16.
|
|
65
|
-
"inquirer": "9.
|
|
64
|
+
"graphql": "16.8.1",
|
|
65
|
+
"inquirer": "9.2.11",
|
|
66
66
|
"js-yaml": "^4.1.0",
|
|
67
67
|
"lodash": "^4.17.21",
|
|
68
68
|
"lodash.isregexp": "^4.0.1",
|
|
69
|
-
"markdown-it": "13.0.
|
|
69
|
+
"markdown-it": "13.0.2",
|
|
70
70
|
"mime": "^3.0.0",
|
|
71
71
|
"moment": "2.29.4",
|
|
72
72
|
"node-cron": "3.0.2",
|
|
73
|
-
"node-emoji": "
|
|
74
|
-
"npm": "
|
|
75
|
-
"pm2": "5.
|
|
76
|
-
"promise": "8.
|
|
73
|
+
"node-emoji": "2.1.0",
|
|
74
|
+
"npm": "10.2.0",
|
|
75
|
+
"pm2": "5.3.0",
|
|
76
|
+
"promise": "^8.3.0",
|
|
77
77
|
"request": "^2.88.2",
|
|
78
|
-
"semver": "7.
|
|
78
|
+
"semver": "7.5.4",
|
|
79
79
|
"shelljs": "^0.8.5",
|
|
80
80
|
"shortid": "^2.2.16",
|
|
81
|
-
"simple-git": "3.
|
|
81
|
+
"simple-git": "3.20.0",
|
|
82
82
|
"spdx": "^0.5.2",
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"xml2js": "^0.4.23",
|
|
83
|
+
"twig": "1.16.0",
|
|
84
|
+
"uuid": "9.0.1",
|
|
85
|
+
"webpack": "5.89.0",
|
|
86
|
+
"xml2js": "0.6.2",
|
|
88
87
|
"yarn": "1.22.19"
|
|
89
88
|
},
|
|
90
89
|
"devDependencies": {
|
|
91
|
-
"babel-loader": "
|
|
90
|
+
"babel-loader": "9.1.3",
|
|
92
91
|
"babel-polyfill": "^6.26.0",
|
|
93
|
-
"
|
|
94
|
-
"webpack-
|
|
92
|
+
"eslint": "8.51.0",
|
|
93
|
+
"webpack-cli": "5.1.4",
|
|
94
|
+
"webpack-merge": "5.10.0"
|
|
95
95
|
},
|
|
96
96
|
"repository": {
|
|
97
97
|
"type": "git",
|
package/protocol.es6
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const xml = require(
|
|
1
|
+
const xml = require("xml2js");
|
|
2
2
|
|
|
3
3
|
const parser = function (type, settings) {
|
|
4
4
|
let Parser = null;
|
|
@@ -10,7 +10,7 @@ const parser = function (type, settings) {
|
|
|
10
10
|
};
|
|
11
11
|
case "json":
|
|
12
12
|
Parser = JSON.parse;
|
|
13
|
-
|
|
13
|
+
const context = this;
|
|
14
14
|
if (context.root) {
|
|
15
15
|
return function (value, callback) {
|
|
16
16
|
try {
|
|
@@ -19,15 +19,14 @@ const parser = function (type, settings) {
|
|
|
19
19
|
return callback(e, null);
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
} else {
|
|
23
|
-
return function (value, callback) {
|
|
24
|
-
try {
|
|
25
|
-
return callback(null, Parser(value));
|
|
26
|
-
} catch (e) {
|
|
27
|
-
return callback(e, null);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
22
|
}
|
|
23
|
+
return function (value, callback) {
|
|
24
|
+
try {
|
|
25
|
+
return callback(null, Parser(value));
|
|
26
|
+
} catch (e) {
|
|
27
|
+
return callback(e, null);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
31
30
|
}
|
|
32
31
|
};
|
|
33
32
|
|
|
@@ -43,21 +42,21 @@ const builder = function (method, type) {
|
|
|
43
42
|
};
|
|
44
43
|
case "json":
|
|
45
44
|
Builder = JSON.stringify;
|
|
46
|
-
|
|
45
|
+
const context = this;
|
|
47
46
|
if (context.root) {
|
|
48
47
|
return function (obj) {
|
|
49
|
-
|
|
48
|
+
const base = {};
|
|
50
49
|
base[context.root] = nodefony.extend({}, context[method]);
|
|
51
50
|
nodefony.extend(true, base[context.root], obj);
|
|
52
51
|
return Builder(base);
|
|
53
52
|
};
|
|
54
|
-
} else {
|
|
55
|
-
return function (obj) {
|
|
56
|
-
let base = nodefony.extend({}, context[method]);
|
|
57
|
-
nodefony.extend(true, base, obj);
|
|
58
|
-
return Builder(base);
|
|
59
|
-
};
|
|
60
53
|
}
|
|
54
|
+
return function (obj) {
|
|
55
|
+
const base = nodefony.extend({}, context[method]);
|
|
56
|
+
nodefony.extend(true, base, obj);
|
|
57
|
+
return Builder(base);
|
|
58
|
+
};
|
|
59
|
+
|
|
61
60
|
break;
|
|
62
61
|
}
|
|
63
62
|
return null;
|
|
@@ -69,8 +68,7 @@ const defaultSettingsProtocol = {
|
|
|
69
68
|
};
|
|
70
69
|
|
|
71
70
|
class Protocol {
|
|
72
|
-
|
|
73
|
-
constructor(rootName, settings) {
|
|
71
|
+
constructor (rootName, settings) {
|
|
74
72
|
this.settings = nodefony.extend(true, {}, defaultSettingsProtocol, settings);
|
|
75
73
|
this.root = rootName;
|
|
76
74
|
this.extention = this.settings.extention;
|
|
@@ -85,4 +83,4 @@ class Protocol {
|
|
|
85
83
|
nodefony.io.protocol = {
|
|
86
84
|
reader: Protocol
|
|
87
85
|
};
|
|
88
|
-
module.exports = nodefony.io.protocol;
|
|
86
|
+
module.exports = nodefony.io.protocol;
|
package/protocols/bayeux.es6
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
const shortId = require(
|
|
2
|
-
|
|
3
|
-
module.exports = nodefony.register.call(nodefony.io.protocol, "bayeux", function () {
|
|
1
|
+
const shortId = require("shortid");
|
|
4
2
|
|
|
3
|
+
module.exports = nodefony.register.call(nodefony.io.protocol, "bayeux", () => {
|
|
5
4
|
const defaultSettings = {
|
|
6
5
|
timestamp: true
|
|
7
6
|
};
|
|
8
7
|
|
|
9
8
|
class Bayeux extends nodefony.io.protocol.reader {
|
|
10
|
-
constructor(rootName, settings) {
|
|
11
|
-
|
|
9
|
+
constructor (rootName, settings) {
|
|
12
10
|
super(null, {
|
|
13
11
|
extention: "json"
|
|
14
12
|
});
|
|
@@ -18,34 +16,33 @@ module.exports = nodefony.register.call(nodefony.io.protocol, "bayeux", function
|
|
|
18
16
|
this.supportedConnectionTypes = [];
|
|
19
17
|
|
|
20
18
|
this.response = {
|
|
21
|
-
version: "1.0"
|
|
19
|
+
version: "1.0"
|
|
22
20
|
};
|
|
23
|
-
|
|
24
21
|
}
|
|
25
22
|
|
|
26
|
-
generateClientId() {
|
|
23
|
+
generateClientId () {
|
|
27
24
|
return shortId.generate();
|
|
28
25
|
}
|
|
29
26
|
|
|
30
|
-
generateTimestamp() {
|
|
27
|
+
generateTimestamp () {
|
|
31
28
|
return new Date().toUTCString();
|
|
32
29
|
}
|
|
33
30
|
|
|
34
|
-
handshakeResponse(message, advice, ext) {
|
|
31
|
+
handshakeResponse (message, advice, ext) {
|
|
35
32
|
let reconnect = null;
|
|
36
33
|
if (advice) {
|
|
37
34
|
reconnect = "retry";
|
|
38
35
|
} else {
|
|
39
36
|
reconnect = "none";
|
|
40
37
|
}
|
|
41
|
-
|
|
38
|
+
const ele = nodefony.extend({}, this.response, {
|
|
42
39
|
channel: "/meta/handshake",
|
|
43
|
-
//clientId:this.generateClientId(),
|
|
40
|
+
// clientId:this.generateClientId(),
|
|
44
41
|
supportedConnectionTypes: ["websocket"],
|
|
45
|
-
successful:true,
|
|
42
|
+
successful: true,
|
|
46
43
|
authSuccessful: true,
|
|
47
44
|
advice: {
|
|
48
|
-
reconnect
|
|
45
|
+
reconnect
|
|
49
46
|
},
|
|
50
47
|
ext: ext || {}
|
|
51
48
|
});
|
|
@@ -55,29 +52,29 @@ module.exports = nodefony.register.call(nodefony.io.protocol, "bayeux", function
|
|
|
55
52
|
return ele;
|
|
56
53
|
}
|
|
57
54
|
|
|
58
|
-
connectResponse(message, advice, ext) {
|
|
55
|
+
connectResponse (message, advice, ext) {
|
|
59
56
|
let reconnect = null;
|
|
60
57
|
if (advice) {
|
|
61
58
|
reconnect = "retry";
|
|
62
59
|
} else {
|
|
63
60
|
reconnect = "none";
|
|
64
61
|
}
|
|
65
|
-
|
|
62
|
+
const ele = nodefony.extend({}, this.response, {
|
|
66
63
|
channel: "/meta/connect",
|
|
67
64
|
successful: true,
|
|
68
65
|
error: "",
|
|
69
66
|
clientId: message.clientId,
|
|
70
67
|
timestamp: new Date(),
|
|
71
68
|
advice: {
|
|
72
|
-
reconnect
|
|
69
|
+
reconnect
|
|
73
70
|
},
|
|
74
71
|
ext: ext || {}
|
|
75
72
|
});
|
|
76
73
|
return ele;
|
|
77
74
|
}
|
|
78
75
|
|
|
79
|
-
disconnectResponse(message) {
|
|
80
|
-
|
|
76
|
+
disconnectResponse (message) {
|
|
77
|
+
const ele = nodefony.extend({}, this.response, {
|
|
81
78
|
channel: "/meta/disconnect",
|
|
82
79
|
clientId: message.clientId,
|
|
83
80
|
successful: true
|
|
@@ -85,8 +82,8 @@ module.exports = nodefony.register.call(nodefony.io.protocol, "bayeux", function
|
|
|
85
82
|
return ele;
|
|
86
83
|
}
|
|
87
84
|
|
|
88
|
-
subscribeResponse(message) {
|
|
89
|
-
|
|
85
|
+
subscribeResponse (message) {
|
|
86
|
+
const ele = nodefony.extend({}, this.response, {
|
|
90
87
|
channel: "/meta/subscribe",
|
|
91
88
|
clientId: message.clientId,
|
|
92
89
|
subscription: message.subscription,
|
|
@@ -95,8 +92,8 @@ module.exports = nodefony.register.call(nodefony.io.protocol, "bayeux", function
|
|
|
95
92
|
return ele;
|
|
96
93
|
}
|
|
97
94
|
|
|
98
|
-
unsubscribeResponse(message) {
|
|
99
|
-
|
|
95
|
+
unsubscribeResponse (message) {
|
|
96
|
+
const ele = nodefony.extend({}, this.response, {
|
|
100
97
|
channel: "/meta/unsubscribe",
|
|
101
98
|
clientId: message.clientId,
|
|
102
99
|
subscription: message.subscription,
|
|
@@ -106,36 +103,36 @@ module.exports = nodefony.register.call(nodefony.io.protocol, "bayeux", function
|
|
|
106
103
|
return ele;
|
|
107
104
|
}
|
|
108
105
|
|
|
109
|
-
publishResponse(channel, id, error) {
|
|
106
|
+
publishResponse (channel, id, error) {
|
|
110
107
|
return this.send(nodefony.extend({}, this.response, {
|
|
111
|
-
channel
|
|
112
|
-
successful: error
|
|
113
|
-
error
|
|
114
|
-
id
|
|
108
|
+
channel,
|
|
109
|
+
successful: !error,
|
|
110
|
+
error,
|
|
111
|
+
id
|
|
115
112
|
}));
|
|
116
113
|
}
|
|
117
114
|
|
|
118
|
-
publishMessage(channel, data, clientId) {
|
|
115
|
+
publishMessage (channel, data, clientId) {
|
|
119
116
|
return this.send(nodefony.extend({}, this.response, {
|
|
120
|
-
channel
|
|
121
|
-
data
|
|
122
|
-
clientId
|
|
117
|
+
channel,
|
|
118
|
+
data,
|
|
119
|
+
clientId
|
|
123
120
|
}));
|
|
124
121
|
}
|
|
125
122
|
|
|
126
|
-
errorResponse(code, channel, message) {
|
|
123
|
+
errorResponse (code, channel, message) {
|
|
127
124
|
return {
|
|
128
|
-
error: code
|
|
125
|
+
error: `${code}:${channel}:${message}`
|
|
129
126
|
};
|
|
130
127
|
}
|
|
131
128
|
|
|
132
|
-
onMessage(message) {
|
|
129
|
+
onMessage (message) {
|
|
133
130
|
switch (nodefony.typeOf(message)) {
|
|
134
131
|
case "string":
|
|
135
132
|
var ret = null;
|
|
136
133
|
this.parser(message, (err, mess) => {
|
|
137
134
|
if (err) {
|
|
138
|
-
//console.log(err)
|
|
135
|
+
// console.log(err)
|
|
139
136
|
throw err;
|
|
140
137
|
}
|
|
141
138
|
ret = this.onMessage(mess);
|
|
@@ -160,7 +157,7 @@ module.exports = nodefony.register.call(nodefony.io.protocol, "bayeux", function
|
|
|
160
157
|
break;
|
|
161
158
|
case "array":
|
|
162
159
|
var tab = [];
|
|
163
|
-
for (
|
|
160
|
+
for (let i = 0; i < message.length; i++) {
|
|
164
161
|
tab.push(this.onMessage(message[i]));
|
|
165
162
|
}
|
|
166
163
|
return this.send(tab);
|
|
@@ -169,7 +166,7 @@ module.exports = nodefony.register.call(nodefony.io.protocol, "bayeux", function
|
|
|
169
166
|
}
|
|
170
167
|
}
|
|
171
168
|
|
|
172
|
-
send(message) {
|
|
169
|
+
send (message) {
|
|
173
170
|
return this.builderResponse(message);
|
|
174
171
|
}
|
|
175
172
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
module.exports = nodefony.register.call(nodefony.io.protocol, "json-rpc",
|
|
2
|
-
|
|
1
|
+
module.exports = nodefony.register.call(nodefony.io.protocol, "json-rpc", () => {
|
|
3
2
|
class Jsonrpc extends nodefony.io.protocol.reader {
|
|
4
|
-
|
|
5
|
-
constructor( /*rootName, settings*/ ) {
|
|
3
|
+
constructor (/* rootName, settings*/) {
|
|
6
4
|
super(null, {
|
|
7
5
|
extention: "json"
|
|
8
6
|
});
|
|
@@ -20,23 +18,23 @@ module.exports = nodefony.register.call(nodefony.io.protocol, "json-rpc", functi
|
|
|
20
18
|
};
|
|
21
19
|
}
|
|
22
20
|
|
|
23
|
-
methodError(error, id) {
|
|
24
|
-
|
|
25
|
-
error
|
|
26
|
-
id
|
|
21
|
+
methodError (error, id) {
|
|
22
|
+
const ele = nodefony.extend({}, this.response, {
|
|
23
|
+
error,
|
|
24
|
+
id
|
|
27
25
|
});
|
|
28
26
|
return this.builderResponse(ele);
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
methodSuccees(result, id) {
|
|
32
|
-
|
|
33
|
-
result
|
|
34
|
-
id
|
|
29
|
+
methodSuccees (result, id) {
|
|
30
|
+
const ele = nodefony.extend({}, this.response, {
|
|
31
|
+
result,
|
|
32
|
+
id
|
|
35
33
|
});
|
|
36
34
|
return this.builderResponse(ele);
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
onMessage(message) {
|
|
37
|
+
onMessage (message) {
|
|
40
38
|
switch (nodefony.typeOf(message)) {
|
|
41
39
|
case "string":
|
|
42
40
|
var ret = null;
|
|
@@ -55,4 +53,4 @@ module.exports = nodefony.register.call(nodefony.io.protocol, "json-rpc", functi
|
|
|
55
53
|
}
|
|
56
54
|
}
|
|
57
55
|
return Jsonrpc;
|
|
58
|
-
});
|
|
56
|
+
});
|
package/result.es6
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
class Result extends Array {
|
|
2
|
-
|
|
3
|
-
constructor(res) {
|
|
2
|
+
constructor (res) {
|
|
4
3
|
if (res) {
|
|
5
4
|
if (res instanceof Array) {
|
|
6
5
|
super();
|
|
@@ -8,7 +7,7 @@ class Result extends Array {
|
|
|
8
7
|
this.push(res[i]);
|
|
9
8
|
}
|
|
10
9
|
if (res instanceof Result) {
|
|
11
|
-
//this.concat(res);
|
|
10
|
+
// this.concat(res);
|
|
12
11
|
res.clean();
|
|
13
12
|
}
|
|
14
13
|
} else {
|
|
@@ -19,9 +18,9 @@ class Result extends Array {
|
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
toJson(json = []) {
|
|
21
|
+
toJson (json = []) {
|
|
23
22
|
for (let index = 0; index < this.length; index++) {
|
|
24
|
-
|
|
23
|
+
const ele = this[index];
|
|
25
24
|
json.push(ele);
|
|
26
25
|
}
|
|
27
26
|
try {
|
|
@@ -31,9 +30,9 @@ class Result extends Array {
|
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
toString(json = []) {
|
|
33
|
+
toString (json = []) {
|
|
35
34
|
for (let index = 0; index < this.length; index++) {
|
|
36
|
-
|
|
35
|
+
const ele = this[index];
|
|
37
36
|
json.push(ele);
|
|
38
37
|
}
|
|
39
38
|
try {
|
|
@@ -43,7 +42,7 @@ class Result extends Array {
|
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
clean(callback) {
|
|
45
|
+
clean (callback) {
|
|
47
46
|
if (callback) {
|
|
48
47
|
Array.prototype.forEach.call(this, (ele) => {
|
|
49
48
|
try {
|
|
@@ -56,11 +55,11 @@ class Result extends Array {
|
|
|
56
55
|
this.length = 0;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
query(query, logger = false, options = {}, sevrity =
|
|
58
|
+
query (query, logger = false, options = {}, sevrity = "INFO", clean = false) {
|
|
60
59
|
try {
|
|
61
60
|
const res = new Result(this.filter((data) => {
|
|
62
61
|
try {
|
|
63
|
-
|
|
62
|
+
const res = data.query(query, logger, options, sevrity);
|
|
64
63
|
if (res) {
|
|
65
64
|
return data;
|
|
66
65
|
}
|
|
@@ -78,10 +77,10 @@ class Result extends Array {
|
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
79
|
|
|
81
|
-
queryGrep(query, grep, clean = false) {
|
|
80
|
+
queryGrep (query, grep, clean = false) {
|
|
82
81
|
try {
|
|
83
82
|
const res = new Result(this.filter((data) => {
|
|
84
|
-
|
|
83
|
+
const res = data.queryGrep(query, grep);
|
|
85
84
|
if (res) {
|
|
86
85
|
return data;
|
|
87
86
|
}
|