not-node 6.5.26 → 6.5.28
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/package.json +1 -1
- package/src/exceptions/action.js +12 -0
- package/src/init/lib/app.js +12 -2
- package/src/manifest/batchRunner.js +2 -2
- package/src/manifest/initializator/forms.js +2 -5
- package/src/manifest/initializator/manifests.js +1 -4
- package/src/manifest/initializator/models.js +2 -4
- package/src/manifest/manifest.js +3 -4
- package/src/manifest/registrator/fields.js +40 -11
- package/src/manifest/registrator/fields.postponed.js +133 -0
- package/src/manifest/registrator/forms.js +3 -7
- package/src/manifest/registrator/locales.js +1 -5
- package/src/manifest/registrator/logics.js +4 -8
- package/src/manifest/registrator/models.js +4 -7
- package/src/manifest/registrator/routes.js +8 -12
- package/src/manifest/registrator/routes.ws.js +12 -15
- package/src/types.js +1 -0
- package/test/module/fields.js +8 -23
- package/test/module/locales.js +34 -38
- package/test/module/logics.js +209 -194
- package/test/module/models.js +143 -138
- package/test/module/routes.js +11 -35
- package/test/module/routes.ws.js +255 -240
package/package.json
CHANGED
package/src/exceptions/action.js
CHANGED
|
@@ -20,6 +20,18 @@ class ActionExceptionPipeExecutionError extends notRequestError {
|
|
|
20
20
|
module.exports.ActionExceptionPipeExecutionError =
|
|
21
21
|
ActionExceptionPipeExecutionError;
|
|
22
22
|
|
|
23
|
+
class ActionExceptionIdentitySessionIsNotDefined extends notRequestError {
|
|
24
|
+
constructor(actionName, identity) {
|
|
25
|
+
super(
|
|
26
|
+
"User identity `sid` is not defined",
|
|
27
|
+
{ code: 505, params: { actionName, identity } },
|
|
28
|
+
null
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
module.exports.ActionExceptionIdentitySessionIsNotDefined =
|
|
33
|
+
ActionExceptionIdentitySessionIsNotDefined;
|
|
34
|
+
|
|
23
35
|
class OwnageExceptionIdentityUserIdIsNotDefined extends notRequestError {
|
|
24
36
|
constructor(actionName, identity) {
|
|
25
37
|
super(
|
package/src/init/lib/app.js
CHANGED
|
@@ -5,6 +5,8 @@ const logger = require("not-log");
|
|
|
5
5
|
const log = logger(module, "not-node//init//app");
|
|
6
6
|
const { notErrorReporter } = require("not-error/src/index.cjs");
|
|
7
7
|
|
|
8
|
+
const notAppPostponedFieldsRegistrator = require("../../manifest/registrator/fields.postponed.js");
|
|
9
|
+
|
|
8
10
|
const CONST_CORE_PATH = path.join(__dirname, "../../core");
|
|
9
11
|
|
|
10
12
|
module.exports = class InitApp {
|
|
@@ -57,7 +59,7 @@ module.exports = class InitApp {
|
|
|
57
59
|
});
|
|
58
60
|
master.getApp().logger = logger(module, "notApplication");
|
|
59
61
|
} catch (e) {
|
|
60
|
-
log
|
|
62
|
+
log?.error(e);
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
|
|
@@ -70,9 +72,17 @@ module.exports = class InitApp {
|
|
|
70
72
|
await InitApp.initCore({ config, options, master, emit });
|
|
71
73
|
await InitApp.importModules({ config, options, master, emit });
|
|
72
74
|
await InitApp.createReporter({ config, master });
|
|
75
|
+
this.printReportByPostponedFieldsRegistrator();
|
|
73
76
|
await emit("app.post", { config, options, master });
|
|
74
77
|
} catch (e) {
|
|
75
|
-
|
|
78
|
+
log?.error(e);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
printReportByPostponedFieldsRegistrator() {
|
|
83
|
+
const report = notAppPostponedFieldsRegistrator.report();
|
|
84
|
+
if (Object.keys(report).length) {
|
|
85
|
+
log?.error(report);
|
|
76
86
|
}
|
|
77
87
|
}
|
|
78
88
|
};
|
|
@@ -24,7 +24,7 @@ module.exports = class BatchRunner {
|
|
|
24
24
|
* Searching for content of module and registering it.
|
|
25
25
|
* @static
|
|
26
26
|
* @param {Object} input
|
|
27
|
-
* @param {
|
|
27
|
+
* @param {import('./module')} input.nModule
|
|
28
28
|
* @return {boolean} true - executed, false - no paths
|
|
29
29
|
**/
|
|
30
30
|
exec({ nModule }) {
|
|
@@ -32,7 +32,7 @@ module.exports = class BatchRunner {
|
|
|
32
32
|
return false;
|
|
33
33
|
}
|
|
34
34
|
//starting from simpliest forms and moving upwards
|
|
35
|
-
this.#processors.forEach((processor) =>
|
|
35
|
+
this.#processors.forEach((processor) => processor.run({ nModule }));
|
|
36
36
|
return true;
|
|
37
37
|
}
|
|
38
38
|
};
|
|
@@ -4,11 +4,8 @@ const { error } = require("not-log")(module, "initializator");
|
|
|
4
4
|
module.exports = class notModuleInitializatorForms {
|
|
5
5
|
static openFile = require;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
run({ app, nModule }) {
|
|
7
|
+
static run({ nModule }) {
|
|
8
|
+
const app = nModule.getApp();
|
|
12
9
|
const moduleName = nModule.getName();
|
|
13
10
|
for (let formName in nModule.getFormsConstructors()) {
|
|
14
11
|
try {
|
|
@@ -9,11 +9,8 @@ const extractPrivateFields = (mod) =>
|
|
|
9
9
|
|
|
10
10
|
module.exports = class notModuleInitializatorManifests {
|
|
11
11
|
static openFile = require;
|
|
12
|
-
constructor({ nModule }) {
|
|
13
|
-
this.run({ nModule });
|
|
14
|
-
}
|
|
15
12
|
|
|
16
|
-
run({ nModule }) {
|
|
13
|
+
static run({ nModule }) {
|
|
17
14
|
const moduleName = nModule.getName();
|
|
18
15
|
for (let routeName in nModule.getRoutesManifests()) {
|
|
19
16
|
try {
|
|
@@ -5,11 +5,9 @@ const { notError } = require("not-error");
|
|
|
5
5
|
|
|
6
6
|
module.exports = class notModuleInitializatorModels {
|
|
7
7
|
static openFile = require;
|
|
8
|
-
constructor({ nModule }) {
|
|
9
|
-
this.run({ nModule, app: nModule.getApp() });
|
|
10
|
-
}
|
|
11
8
|
|
|
12
|
-
run({
|
|
9
|
+
static run({ nModule }) {
|
|
10
|
+
const app = nModule.getApp();
|
|
13
11
|
const moduleName = nModule.getName();
|
|
14
12
|
for (let modelName in nModule.getModels()) {
|
|
15
13
|
try {
|
package/src/manifest/manifest.js
CHANGED
|
@@ -8,8 +8,8 @@ const notManifestFilter = require("./manifest.filter.js");
|
|
|
8
8
|
/**
|
|
9
9
|
* API manifest
|
|
10
10
|
* @class
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
11
|
+
* @param {import('express').Application} app express application instance
|
|
12
|
+
* @param {import('../app.js')} notApp notApplication instance
|
|
13
13
|
* @param {string} moduleName name of owner module
|
|
14
14
|
**/
|
|
15
15
|
class notManifest {
|
|
@@ -80,8 +80,7 @@ class notManifest {
|
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* Check if manifest file has url and actions, so we could register routes
|
|
83
|
-
* @param {object}
|
|
84
|
-
* @param {string} routeName name of
|
|
83
|
+
* @param {object} route library of .manifest.js files
|
|
85
84
|
**/
|
|
86
85
|
registerRoute(route) {
|
|
87
86
|
if (!this.routeHasRoutes(route)) {
|
|
@@ -3,15 +3,18 @@ const fs = require("fs");
|
|
|
3
3
|
const { tryFile, objHas } = require("../../common");
|
|
4
4
|
const Fields = require("../../fields");
|
|
5
5
|
const { log } = require("not-log")(module, "register//fields");
|
|
6
|
+
const notAppPostponedFieldsRegistrator = require("./fields.postponed");
|
|
7
|
+
|
|
6
8
|
module.exports = class notModuleRegistratorFields {
|
|
7
9
|
static openFile = require;
|
|
8
10
|
static fieldsManager = Fields;
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
this.
|
|
12
|
+
static reopenCached(pathToModule) {
|
|
13
|
+
delete this.openFile.cache[this.openFile.resolve(pathToModule)];
|
|
14
|
+
return this.openFile(pathToModule);
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
run({ nModule }) {
|
|
17
|
+
static run({ nModule }) {
|
|
15
18
|
const srcDir = notModuleRegistratorFields.getPath(nModule);
|
|
16
19
|
if (!srcDir) {
|
|
17
20
|
return false;
|
|
@@ -27,7 +30,7 @@ module.exports = class notModuleRegistratorFields {
|
|
|
27
30
|
return nModule.module.paths.fields;
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
registerFields({ nModule, lib, fromPath }) {
|
|
33
|
+
static registerFields({ nModule, lib, fromPath }) {
|
|
31
34
|
for (let t in lib) {
|
|
32
35
|
this.registerField({
|
|
33
36
|
nModule,
|
|
@@ -38,18 +41,44 @@ module.exports = class notModuleRegistratorFields {
|
|
|
38
41
|
}
|
|
39
42
|
}
|
|
40
43
|
|
|
41
|
-
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
*
|
|
47
|
+
* @param {object} param { nModule, name, field, fromPath }
|
|
48
|
+
* @param {import('../module')} param.nModule
|
|
49
|
+
* @param {string} param.name
|
|
50
|
+
* @param {object} param.field
|
|
51
|
+
* @param {string} param.fromPath
|
|
52
|
+
*/
|
|
53
|
+
static registerField({ nModule, name, field, fromPath }) {
|
|
54
|
+
const MODULE_NAME = nModule.getName();
|
|
55
|
+
if (notAppPostponedFieldsRegistrator.fieldShouldBePostponed(field)) {
|
|
56
|
+
notAppPostponedFieldsRegistrator.add(
|
|
57
|
+
field.parent,
|
|
58
|
+
MODULE_NAME,
|
|
59
|
+
fromPath
|
|
60
|
+
);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
42
63
|
const fieldValidatorsCount = this.extendByFrontValidators({
|
|
43
64
|
name,
|
|
44
65
|
field,
|
|
45
66
|
fromPath: path.dirname(fromPath),
|
|
46
67
|
});
|
|
47
68
|
nModule.setField(name, field);
|
|
48
|
-
const MODULE_NAME = nModule.getName();
|
|
49
69
|
log(`${MODULE_NAME}//${name} with ${fieldValidatorsCount} validators`);
|
|
70
|
+
notAppPostponedFieldsRegistrator.registerPostponedChildren(
|
|
71
|
+
this,
|
|
72
|
+
MODULE_NAME,
|
|
73
|
+
`${MODULE_NAME}//${name}`
|
|
74
|
+
);
|
|
50
75
|
}
|
|
51
76
|
|
|
52
|
-
findValidatorsFile(
|
|
77
|
+
static findValidatorsFile(
|
|
78
|
+
name,
|
|
79
|
+
fromPath,
|
|
80
|
+
possible_extensions = [".js", ".cjs", ".mjs"]
|
|
81
|
+
) {
|
|
53
82
|
for (let ext of possible_extensions) {
|
|
54
83
|
const validatorName = path.join(fromPath, "validators", name + ext);
|
|
55
84
|
if (tryFile(validatorName)) {
|
|
@@ -62,14 +91,14 @@ module.exports = class notModuleRegistratorFields {
|
|
|
62
91
|
/**
|
|
63
92
|
*
|
|
64
93
|
**/
|
|
65
|
-
extendByFrontValidators({ name, field, fromPath }) {
|
|
94
|
+
static extendByFrontValidators({ name, field, fromPath }) {
|
|
66
95
|
if (!(field && objHas(field, "model"))) {
|
|
67
96
|
return;
|
|
68
97
|
}
|
|
69
98
|
//load validators
|
|
70
99
|
const validatorName = this.findValidatorsFile(name, fromPath);
|
|
71
100
|
if (!validatorName) {
|
|
72
|
-
return;
|
|
101
|
+
return field?.model?.validate?.length;
|
|
73
102
|
}
|
|
74
103
|
const validators = notModuleRegistratorFields.openFile(validatorName);
|
|
75
104
|
//inject into field.model
|
|
@@ -86,7 +115,7 @@ module.exports = class notModuleRegistratorFields {
|
|
|
86
115
|
* @param {import('../module')} input.nModule
|
|
87
116
|
* @param {string} input.srcDir
|
|
88
117
|
**/
|
|
89
|
-
findAll({ nModule, srcDir }) {
|
|
118
|
+
static findAll({ nModule, srcDir }) {
|
|
90
119
|
fs.readdirSync(srcDir).forEach((file) => {
|
|
91
120
|
let fromPath = path.join(srcDir, file);
|
|
92
121
|
if (!tryFile(fromPath)) {
|
|
@@ -103,7 +132,7 @@ module.exports = class notModuleRegistratorFields {
|
|
|
103
132
|
* @param {import('../module')} input.nModule
|
|
104
133
|
* @param {string} input.fromPath
|
|
105
134
|
*/
|
|
106
|
-
register({ nModule, fromPath }) {
|
|
135
|
+
static register({ nModule, fromPath }) {
|
|
107
136
|
let file = notModuleRegistratorFields.openFile(fromPath);
|
|
108
137
|
if (file && objHas(file, "FIELDS")) {
|
|
109
138
|
//collection
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const getApp = require("../../getApp");
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {object} WaitingField
|
|
6
|
+
* @property {string} moduleName
|
|
7
|
+
* @property {string} pathToField
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
class notAppPostponedFieldsRegistrator {
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @static
|
|
14
|
+
* @property {Object<strin, WaitingField>}
|
|
15
|
+
* @memberof notModuleRegistratorFields
|
|
16
|
+
*/
|
|
17
|
+
static #waitingList = {};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
*
|
|
22
|
+
* @static
|
|
23
|
+
* @param {string} parentFieldName full path to field not-module-name//not-field-name
|
|
24
|
+
* @param {string} moduleName not-module-name
|
|
25
|
+
* @param {string} pathToField path to field file
|
|
26
|
+
* @memberof notModuleRegistratorFields
|
|
27
|
+
*/
|
|
28
|
+
static add(parentFieldName, moduleName, pathToField) {
|
|
29
|
+
if (!Object.hasOwn(this.#waitingList, parentFieldName)) {
|
|
30
|
+
this.#waitingList[parentFieldName] = [];
|
|
31
|
+
}
|
|
32
|
+
this.#waitingList[parentFieldName].push({
|
|
33
|
+
moduleName,
|
|
34
|
+
pathToField,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
*
|
|
41
|
+
* @static
|
|
42
|
+
* @param {string} parentFieldName full path to field not-module-name//not-field-name
|
|
43
|
+
* @return {Array<WaitingField>}
|
|
44
|
+
* @memberof notModuleRegistratorFields
|
|
45
|
+
*/
|
|
46
|
+
static getChildren(parentFieldName) {
|
|
47
|
+
if (Object.hasOwn(this.#waitingList, parentFieldName)) {
|
|
48
|
+
return this.#waitingList[parentFieldName];
|
|
49
|
+
} else {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Removes all records of waiting registration fields
|
|
56
|
+
* @static
|
|
57
|
+
* @param {string} parentFieldName full path to field not-module-name//not-field-name
|
|
58
|
+
* @memberof notAppPostponedFieldsRegistrator
|
|
59
|
+
*/
|
|
60
|
+
static clearList(parentFieldName) {
|
|
61
|
+
if (Object.hasOwn(this.#waitingList, parentFieldName)) {
|
|
62
|
+
delete this.#waitingList[parentFieldName];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* If parent fields exists in childField description and
|
|
68
|
+
* parent field is not registered yet - returns true
|
|
69
|
+
*
|
|
70
|
+
* @static
|
|
71
|
+
* @param {import('../../types').notField} childField
|
|
72
|
+
* @return {boolean}
|
|
73
|
+
* @memberof notAppPostponedFieldsRegistrator
|
|
74
|
+
*/
|
|
75
|
+
static fieldShouldBePostponed(childField) {
|
|
76
|
+
if (Object.hasOwn(childField, "parent")) {
|
|
77
|
+
if (
|
|
78
|
+
childField.parent &&
|
|
79
|
+
typeof childField.parent === "string" &&
|
|
80
|
+
childField.parent.length > 4 &&
|
|
81
|
+
childField.parent.indexOf("//") > 0
|
|
82
|
+
) {
|
|
83
|
+
const parentField = getApp().getField(childField.parent);
|
|
84
|
+
return !parentField;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Returns lib of parent fields and depending fields paths that wasnt resolved
|
|
92
|
+
*
|
|
93
|
+
* @static
|
|
94
|
+
* @return {Object<[string], Array<string>>}
|
|
95
|
+
* @memberof notAppPostponedFieldsRegistrator
|
|
96
|
+
*/
|
|
97
|
+
static state() {
|
|
98
|
+
const result = {};
|
|
99
|
+
Object.keys(this.#waitingList).forEach((parentField) => {
|
|
100
|
+
result[parentField] = this.#waitingList.map(
|
|
101
|
+
(itm) => itm.pathToField
|
|
102
|
+
);
|
|
103
|
+
});
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
*
|
|
109
|
+
*
|
|
110
|
+
* @static
|
|
111
|
+
* @param {import('./fields')} registrator
|
|
112
|
+
* @param {string} MODULE_NAME
|
|
113
|
+
* @param {string} fullFieldName
|
|
114
|
+
* @memberof notAppPostponedFieldsRegistrator
|
|
115
|
+
*/
|
|
116
|
+
static registerPostponedChildren(registrator, MODULE_NAME, fullFieldName) {
|
|
117
|
+
const list = this.getChildren(fullFieldName);
|
|
118
|
+
list.forEach((childField) => {
|
|
119
|
+
const nModule = getApp().getModule(MODULE_NAME);
|
|
120
|
+
const fieldFile = registrator.reopenCached(childField.pathToField);
|
|
121
|
+
const parts = path.parse(childField.pathToField);
|
|
122
|
+
registrator.registerField({
|
|
123
|
+
nModule,
|
|
124
|
+
name: parts.name, //fields name
|
|
125
|
+
field: fieldFile, //field description
|
|
126
|
+
fromPath: childField.pathToField,
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
this.clearList(fullFieldName);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
module.exports = notAppPostponedFieldsRegistrator;
|
|
@@ -5,11 +5,7 @@ const { tryFile } = require("../../common");
|
|
|
5
5
|
module.exports = class notModuleRegistratorForms {
|
|
6
6
|
static openFile = require;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
this.run({ nModule });
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
run({ nModule }) {
|
|
8
|
+
static run({ nModule }) {
|
|
13
9
|
const srcDir = notModuleRegistratorForms.getPath(nModule);
|
|
14
10
|
if (!srcDir) {
|
|
15
11
|
return false;
|
|
@@ -31,7 +27,7 @@ module.exports = class notModuleRegistratorForms {
|
|
|
31
27
|
* @param {string} input.srcDir
|
|
32
28
|
* @param {import('../module')} input.nModule
|
|
33
29
|
**/
|
|
34
|
-
findAll({ nModule, srcDir }) {
|
|
30
|
+
static findAll({ nModule, srcDir }) {
|
|
35
31
|
fs.readdirSync(srcDir).forEach((file) => {
|
|
36
32
|
let fromPath = path.join(srcDir, file);
|
|
37
33
|
if (!tryFile(fromPath)) {
|
|
@@ -41,7 +37,7 @@ module.exports = class notModuleRegistratorForms {
|
|
|
41
37
|
});
|
|
42
38
|
}
|
|
43
39
|
|
|
44
|
-
register({ nModule, fromPath }) {
|
|
40
|
+
static register({ nModule, fromPath }) {
|
|
45
41
|
const Form = notModuleRegistratorForms.openFile(fromPath);
|
|
46
42
|
const parts = path.parse(fromPath);
|
|
47
43
|
nModule.setFormConstructor(parts.name, Form);
|
|
@@ -2,17 +2,13 @@ const log = require("not-log")(module, "registrator");
|
|
|
2
2
|
const notLocale = require("not-locale");
|
|
3
3
|
|
|
4
4
|
module.exports = class notModuleRegistratorLocales {
|
|
5
|
-
constructor({ nModule }) {
|
|
6
|
-
this.run({ nModule });
|
|
7
|
-
}
|
|
8
|
-
|
|
9
5
|
/**
|
|
10
6
|
*
|
|
11
7
|
* @param {object} input
|
|
12
8
|
* @param {import('../module')} input.nModule
|
|
13
9
|
* @return {boolean}
|
|
14
10
|
*/
|
|
15
|
-
run({ nModule }) {
|
|
11
|
+
static run({ nModule }) {
|
|
16
12
|
const srcDir = notModuleRegistratorLocales.getPath(nModule);
|
|
17
13
|
if (!srcDir) {
|
|
18
14
|
return false;
|
|
@@ -20,11 +20,7 @@ const LOGIC_BINDINGS_LIST = [
|
|
|
20
20
|
module.exports = class notModuleRegistratorLogics {
|
|
21
21
|
static openFile = require;
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
this.run({ nModule });
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
run({ nModule }) {
|
|
23
|
+
static run({ nModule }) {
|
|
28
24
|
const srcDir = notModuleRegistratorLogics.getPath(nModule);
|
|
29
25
|
if (!srcDir) {
|
|
30
26
|
return false;
|
|
@@ -47,7 +43,7 @@ module.exports = class notModuleRegistratorLogics {
|
|
|
47
43
|
* @param {import('../module')} input.nModule
|
|
48
44
|
* @param {string} input.srcDir
|
|
49
45
|
**/
|
|
50
|
-
findAll({ nModule, srcDir }) {
|
|
46
|
+
static findAll({ nModule, srcDir }) {
|
|
51
47
|
fs.readdirSync(srcDir).forEach((file) => {
|
|
52
48
|
let fromPath = path.join(srcDir, file);
|
|
53
49
|
//log.info(`Checking logic in ${fromPath}`);
|
|
@@ -58,7 +54,7 @@ module.exports = class notModuleRegistratorLogics {
|
|
|
58
54
|
});
|
|
59
55
|
}
|
|
60
56
|
|
|
61
|
-
register({ nModule, fromPath, file }) {
|
|
57
|
+
static register({ nModule, fromPath, file }) {
|
|
62
58
|
const logic = notModuleRegistratorLogics.openFile(fromPath);
|
|
63
59
|
const logicName = notModuleRegistratorLogics.getName({ logic, file });
|
|
64
60
|
this.extend({ nModule, logic, logicName, fromPath });
|
|
@@ -66,7 +62,7 @@ module.exports = class notModuleRegistratorLogics {
|
|
|
66
62
|
//log.info(`${logicName}`);
|
|
67
63
|
}
|
|
68
64
|
|
|
69
|
-
extend({ nModule, logic, logicName, fromPath }) {
|
|
65
|
+
static extend({ nModule, logic, logicName, fromPath }) {
|
|
70
66
|
logic.filename = fromPath;
|
|
71
67
|
if (nModule.appIsSet()) {
|
|
72
68
|
mapBind(nModule.getApp(), logic, LOGIC_BINDINGS_LIST);
|
|
@@ -17,11 +17,8 @@ const MODEL_BINDINGS_LIST = [
|
|
|
17
17
|
|
|
18
18
|
module.exports = class notModuleRegistratorModels {
|
|
19
19
|
static openFile = require;
|
|
20
|
-
constructor({ nModule }) {
|
|
21
|
-
this.run({ nModule });
|
|
22
|
-
}
|
|
23
20
|
|
|
24
|
-
run({ nModule }) {
|
|
21
|
+
static run({ nModule }) {
|
|
25
22
|
const srcDir = notModuleRegistratorModels.getPath(nModule);
|
|
26
23
|
if (!srcDir) {
|
|
27
24
|
return false;
|
|
@@ -44,7 +41,7 @@ module.exports = class notModuleRegistratorModels {
|
|
|
44
41
|
* @param {import('../module')} input.nModule
|
|
45
42
|
* @param {string} input.srcDir
|
|
46
43
|
**/
|
|
47
|
-
findAll({ nModule, srcDir }) {
|
|
44
|
+
static findAll({ nModule, srcDir }) {
|
|
48
45
|
fs.readdirSync(srcDir).forEach((file) => {
|
|
49
46
|
let fromPath = path.join(srcDir, file);
|
|
50
47
|
//log.info(`Checking model in ${fromPath}`);
|
|
@@ -55,7 +52,7 @@ module.exports = class notModuleRegistratorModels {
|
|
|
55
52
|
});
|
|
56
53
|
}
|
|
57
54
|
|
|
58
|
-
register({ nModule, fromPath, file }) {
|
|
55
|
+
static register({ nModule, fromPath, file }) {
|
|
59
56
|
const model = notModuleRegistratorModels.openFile(fromPath);
|
|
60
57
|
const modelName = notModuleRegistratorModels.getName({ model, file });
|
|
61
58
|
this.extend({ nModule, model, modelName, fromPath });
|
|
@@ -63,7 +60,7 @@ module.exports = class notModuleRegistratorModels {
|
|
|
63
60
|
//log.info(`${modelName}`);
|
|
64
61
|
}
|
|
65
62
|
|
|
66
|
-
extend({ nModule, model, modelName, fromPath }) {
|
|
63
|
+
static extend({ nModule, model, modelName, fromPath }) {
|
|
67
64
|
model.filename = fromPath;
|
|
68
65
|
if (nModule.appIsSet()) {
|
|
69
66
|
mapBind(nModule.getApp(), model, MODEL_BINDINGS_LIST);
|
|
@@ -45,11 +45,7 @@ const ROUTE_BINDINGS_LIST = [
|
|
|
45
45
|
module.exports = class notModuleRegistratorRoutes {
|
|
46
46
|
static openFile = require;
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
this.run({ nModule });
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
run({ nModule }) {
|
|
48
|
+
static run({ nModule }) {
|
|
53
49
|
const srcDir = notModuleRegistratorRoutes.getPath(nModule);
|
|
54
50
|
if (!srcDir) {
|
|
55
51
|
return false;
|
|
@@ -72,13 +68,13 @@ module.exports = class notModuleRegistratorRoutes {
|
|
|
72
68
|
* @param {import('../module')} input.nModule
|
|
73
69
|
* @param {string} input.srcDir
|
|
74
70
|
**/
|
|
75
|
-
findAll({ nModule, srcDir }) {
|
|
71
|
+
static findAll({ nModule, srcDir }) {
|
|
76
72
|
fs.readdirSync(srcDir).forEach((file) =>
|
|
77
73
|
this.findOne({ nModule, file, srcDir })
|
|
78
74
|
);
|
|
79
75
|
}
|
|
80
76
|
|
|
81
|
-
getFileBasename(file, possible_extensions = []) {
|
|
77
|
+
static getFileBasename(file, possible_extensions = []) {
|
|
82
78
|
for (let ext of possible_extensions) {
|
|
83
79
|
if (file.indexOf(ext) !== -1) {
|
|
84
80
|
return file.substr(0, file.indexOf(ext));
|
|
@@ -87,7 +83,7 @@ module.exports = class notModuleRegistratorRoutes {
|
|
|
87
83
|
return false;
|
|
88
84
|
}
|
|
89
85
|
|
|
90
|
-
findOne({ nModule, srcDir, file }) {
|
|
86
|
+
static findOne({ nModule, srcDir, file }) {
|
|
91
87
|
try {
|
|
92
88
|
//если имя похоже на название манифеста
|
|
93
89
|
const routeBasename = this.getFileBasename(
|
|
@@ -171,7 +167,7 @@ module.exports = class notModuleRegistratorRoutes {
|
|
|
171
167
|
return false;
|
|
172
168
|
}
|
|
173
169
|
|
|
174
|
-
registerManifestAndRoutes({
|
|
170
|
+
static registerManifestAndRoutes({
|
|
175
171
|
nModule,
|
|
176
172
|
routeName,
|
|
177
173
|
routeManifest,
|
|
@@ -195,7 +191,7 @@ module.exports = class notModuleRegistratorRoutes {
|
|
|
195
191
|
}
|
|
196
192
|
}
|
|
197
193
|
|
|
198
|
-
registerRoute({ nModule, route, routeName }) {
|
|
194
|
+
static registerRoute({ nModule, route, routeName }) {
|
|
199
195
|
nModule.setRoute(route.thisRouteName, route);
|
|
200
196
|
if (nModule.appIsSet()) {
|
|
201
197
|
mapBind(nModule.getApp(), route, ROUTE_BINDINGS_LIST);
|
|
@@ -204,8 +200,8 @@ module.exports = class notModuleRegistratorRoutes {
|
|
|
204
200
|
route.getThisModule = () => nModule;
|
|
205
201
|
}
|
|
206
202
|
|
|
207
|
-
registerWSRoute({ nModule, wsRoute }) {
|
|
208
|
-
|
|
203
|
+
static registerWSRoute({ nModule, wsRoute }) {
|
|
204
|
+
notModuleRegistratorRoutesWS.run({
|
|
209
205
|
nModule,
|
|
210
206
|
wsRoute: wsRoute,
|
|
211
207
|
wsRouteName: wsRoute.thisRouteName,
|
|
@@ -3,7 +3,7 @@ const { mapBind, objHas } = require("../../common");
|
|
|
3
3
|
/**
|
|
4
4
|
* List of methods to be binded from notApp to routes and WS end-points
|
|
5
5
|
* @constant
|
|
6
|
-
* @type {string}
|
|
6
|
+
* @type {Array<string>}
|
|
7
7
|
*/
|
|
8
8
|
const WS_ROUTE_BINDINGS_LIST = [
|
|
9
9
|
"getLogic",
|
|
@@ -15,15 +15,7 @@ const WS_ROUTE_BINDINGS_LIST = [
|
|
|
15
15
|
];
|
|
16
16
|
|
|
17
17
|
module.exports = class notModuleRegistratorRoutesWS {
|
|
18
|
-
|
|
19
|
-
this.run({
|
|
20
|
-
nModule,
|
|
21
|
-
wsRoute,
|
|
22
|
-
wsRouteName,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
run({ nModule, wsRoute, wsRouteName }) {
|
|
18
|
+
static run({ nModule, wsRoute, wsRouteName }) {
|
|
27
19
|
if (nModule.appIsSet()) {
|
|
28
20
|
const input = {
|
|
29
21
|
nModule,
|
|
@@ -35,21 +27,26 @@ module.exports = class notModuleRegistratorRoutesWS {
|
|
|
35
27
|
}
|
|
36
28
|
}
|
|
37
29
|
|
|
38
|
-
registerServers(input) {
|
|
30
|
+
static registerServers(input) {
|
|
39
31
|
this.registerCollectionType({
|
|
40
32
|
...input,
|
|
41
33
|
collectionType: "servers",
|
|
42
34
|
});
|
|
43
35
|
}
|
|
44
36
|
|
|
45
|
-
registerClients(input) {
|
|
37
|
+
static registerClients(input) {
|
|
46
38
|
this.registerCollectionType({
|
|
47
39
|
...input,
|
|
48
40
|
collectionType: "clients",
|
|
49
41
|
});
|
|
50
42
|
}
|
|
51
43
|
|
|
52
|
-
registerCollectionType({
|
|
44
|
+
static registerCollectionType({
|
|
45
|
+
nModule,
|
|
46
|
+
wsRoute,
|
|
47
|
+
wsRouteName,
|
|
48
|
+
collectionType,
|
|
49
|
+
}) {
|
|
53
50
|
if (!objHas(wsRoute, collectionType)) {
|
|
54
51
|
return false;
|
|
55
52
|
}
|
|
@@ -65,7 +62,7 @@ module.exports = class notModuleRegistratorRoutesWS {
|
|
|
65
62
|
return true;
|
|
66
63
|
}
|
|
67
64
|
|
|
68
|
-
registerCollectionItem({
|
|
65
|
+
static registerCollectionItem({
|
|
69
66
|
nModule,
|
|
70
67
|
wsRoute,
|
|
71
68
|
wsRouteName,
|
|
@@ -84,7 +81,7 @@ module.exports = class notModuleRegistratorRoutesWS {
|
|
|
84
81
|
});
|
|
85
82
|
}
|
|
86
83
|
|
|
87
|
-
registerEndPoints({
|
|
84
|
+
static registerEndPoints({
|
|
88
85
|
nModule,
|
|
89
86
|
wsRouteName,
|
|
90
87
|
collectionType,
|