not-node 5.0.22 → 5.1.2

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.
Files changed (126) hide show
  1. package/.eslintrc.json +1 -1
  2. package/bin/not-deploy.js +52 -0
  3. package/index.js +21 -19
  4. package/package.json +1 -1
  5. package/src/app.js +61 -58
  6. package/src/auth/abstract.js +17 -19
  7. package/src/auth/const.js +8 -12
  8. package/src/auth/fields.js +143 -124
  9. package/src/auth/index.js +14 -14
  10. package/src/auth/roles.js +64 -63
  11. package/src/auth/routes.js +89 -54
  12. package/src/auth/rules.js +63 -63
  13. package/src/auth/session.js +60 -62
  14. package/src/bootstrap/form.js +13 -13
  15. package/src/bootstrap/logic.js +45 -41
  16. package/src/bootstrap/model.js +14 -17
  17. package/src/bootstrap/route.js +132 -53
  18. package/src/common.js +86 -79
  19. package/src/core/fields/ID.js +6 -6
  20. package/src/core/fields/__closed.js +3 -3
  21. package/src/core/fields/__latest.js +3 -3
  22. package/src/core/fields/__version.js +3 -3
  23. package/src/core/fields/__versions.js +3 -3
  24. package/src/core/fields/_id.js +6 -6
  25. package/src/core/fields/active.js +9 -9
  26. package/src/core/fields/codeName.js +9 -9
  27. package/src/core/fields/createdAt.js +17 -17
  28. package/src/core/fields/default.js +9 -9
  29. package/src/core/fields/description.js +11 -11
  30. package/src/core/fields/email.js +9 -9
  31. package/src/core/fields/enabled.js +9 -9
  32. package/src/core/fields/expiredAt.js +16 -16
  33. package/src/core/fields/height.js +11 -11
  34. package/src/core/fields/ip.js +10 -10
  35. package/src/core/fields/objectId.js +10 -10
  36. package/src/core/fields/owner.js +13 -13
  37. package/src/core/fields/ownerModel.js +11 -11
  38. package/src/core/fields/price.js +11 -11
  39. package/src/core/fields/requiredObject.js +10 -10
  40. package/src/core/fields/session.js +10 -10
  41. package/src/core/fields/size.js +11 -11
  42. package/src/core/fields/telephone.js +9 -9
  43. package/src/core/fields/title.js +15 -15
  44. package/src/core/fields/updatedAt.js +17 -17
  45. package/src/core/fields/userId.js +11 -12
  46. package/src/core/fields/uuid.js +11 -11
  47. package/src/core/fields/validators/email.js +6 -4
  48. package/src/core/fields/validators/owner.js +6 -4
  49. package/src/core/fields/width.js +11 -11
  50. package/src/domain.js +435 -431
  51. package/src/env.js +23 -23
  52. package/src/error.js +20 -23
  53. package/src/exceptions/db.js +23 -0
  54. package/src/exceptions/http.js +43 -0
  55. package/src/fields/index.js +106 -111
  56. package/src/form/fabric.js +19 -24
  57. package/src/form/form.js +195 -186
  58. package/src/form/index.js +2 -2
  59. package/src/generic/index.js +2 -0
  60. package/src/generic/logic.js +595 -0
  61. package/src/generic/route.js +76 -0
  62. package/src/init/additional.js +7 -7
  63. package/src/init/app.js +75 -68
  64. package/src/init/bodyparser.js +14 -14
  65. package/src/init/compression.js +6 -7
  66. package/src/init/core.js +12 -12
  67. package/src/init/cors.js +22 -24
  68. package/src/init/db/index.js +41 -43
  69. package/src/init/db/ioredis.js +28 -20
  70. package/src/init/db/mongoose.js +42 -32
  71. package/src/init/db/redis.js +59 -48
  72. package/src/init/env.js +44 -36
  73. package/src/init/express.js +18 -21
  74. package/src/init/fileupload.js +8 -10
  75. package/src/init/http.js +65 -47
  76. package/src/init/index.js +141 -148
  77. package/src/init/informer.js +7 -9
  78. package/src/init/methodoverride.js +4 -6
  79. package/src/init/middleware.js +23 -26
  80. package/src/init/modules.js +4 -4
  81. package/src/init/monitoring.js +8 -8
  82. package/src/init/rateLimiter.js +53 -45
  83. package/src/init/routes.js +67 -69
  84. package/src/init/security.js +37 -33
  85. package/src/init/sequence.js +111 -107
  86. package/src/init/sequence.standart.js +54 -56
  87. package/src/init/sessions/index.js +21 -21
  88. package/src/init/sessions/mongoose.js +49 -36
  89. package/src/init/sessions/redis.js +28 -27
  90. package/src/init/static.js +53 -40
  91. package/src/init/template.js +17 -17
  92. package/src/lib.js +230 -200
  93. package/src/manifest/batchRunner.js +26 -25
  94. package/src/manifest/initializator/forms.js +24 -24
  95. package/src/manifest/initializator/index.js +8 -10
  96. package/src/manifest/initializator/manifests.js +45 -42
  97. package/src/manifest/initializator/models.js +37 -34
  98. package/src/manifest/manifest.filter.js +130 -97
  99. package/src/manifest/manifest.js +103 -77
  100. package/src/manifest/module.js +350 -360
  101. package/src/manifest/registrator/fields.js +90 -85
  102. package/src/manifest/registrator/forms.js +47 -47
  103. package/src/manifest/registrator/index.js +14 -16
  104. package/src/manifest/registrator/locales.js +17 -16
  105. package/src/manifest/registrator/logics.js +66 -64
  106. package/src/manifest/registrator/models.js +64 -62
  107. package/src/manifest/registrator/routes.js +171 -132
  108. package/src/manifest/registrator/routes.ws.js +109 -103
  109. package/src/manifest/route.js +216 -161
  110. package/src/model/buildValidator.js +53 -42
  111. package/src/model/default.js +304 -286
  112. package/src/model/enrich.js +69 -61
  113. package/src/model/increment.js +124 -137
  114. package/src/model/proto.js +179 -148
  115. package/src/model/routine.js +85 -76
  116. package/src/model/utils.js +33 -0
  117. package/src/model/versioning.js +148 -130
  118. package/src/obsolete.js +12 -8
  119. package/src/parser.js +29 -22
  120. package/src/repos.js +29 -31
  121. package/src/rollup.js +75 -65
  122. package/src/shell.helpers.js +28 -28
  123. package/static.js +31 -0
  124. package/src/generic/router.js +0 -16
  125. package/src/manifest/module.models.js +0 -0
  126. package/src/manifest/module.status.js +0 -0
@@ -1,47 +1,50 @@
1
- const {notError} = require('not-error');
2
- const {log,error} = require('not-log')(module, 'initializator');
3
- const {initManifestFields} = require('../../fields');
4
- const {firstLetterToUpper} = require('../../common');
1
+ const { notError } = require("not-error");
2
+ const { error } = require("not-log")(module, "initializator");
3
+ const { initManifestFields } = require("../../fields");
4
+ const { firstLetterToUpper } = require("../../common");
5
5
 
6
- module.exports = class notModuleInitializatorManifests{
7
- static openFile = require;
8
- constructor({nModule}){
9
- this.run({nModule});
10
- }
11
-
12
- run({nModule}) {
13
- const moduleName = nModule.getName();
14
- for(let routeName in nModule.getRoutesManifests()) {
15
- try{
16
- const mod = nModule.getRouteManifest(routeName);
17
- if(mod && Array.isArray(mod.fields)){
18
- const rawMutationsList = [...mod.fields];
19
- const ModelName = firstLetterToUpper(mod.model);
20
- const schema = nModule.getModelSchema(ModelName);
21
- let privateFields = [];
22
- if (mod.privateFields){
23
- privateFields = Array.isArray(mod.privateFields)?[...mod.privateFields]:[];
24
- delete mod.privateFields;
25
- }
26
- mod.fields = initManifestFields(
27
- nModule.getApp(),
28
- schema,
29
- rawMutationsList,
30
- privateFields,
31
- moduleName,
32
- );
33
- }
34
- }catch(e){
35
- error(`Error while initialization of route: ${moduleName}//${routeName}`);
36
- if(e instanceof notError){
37
- error(`name: ${e.options.field}, type: ${e.options.type}`);
38
- }else{
39
- error(e);
40
- }
41
- }
6
+ const fieldsIsArray = (mod) => mod && Array.isArray(mod.fields);
7
+ const extractPrivateFields = (mod) =>
8
+ Array.isArray(mod.privateFields) ? [...mod.privateFields] : [];
42
9
 
10
+ module.exports = class notModuleInitializatorManifests {
11
+ static openFile = require;
12
+ constructor({ nModule }) {
13
+ this.run({ nModule });
43
14
  }
44
- }
45
-
46
15
 
16
+ run({ nModule }) {
17
+ const moduleName = nModule.getName();
18
+ for (let routeName in nModule.getRoutesManifests()) {
19
+ try {
20
+ const mod = nModule.getRouteManifest(routeName);
21
+ if (fieldsIsArray(mod)) {
22
+ const rawMutationsList = [...mod.fields];
23
+ const ModelName = firstLetterToUpper(mod.model);
24
+ const schema = nModule.getModelSchema(ModelName);
25
+ let privateFields = [];
26
+ if (mod.privateFields) {
27
+ privateFields = extractPrivateFields(mod);
28
+ delete mod.privateFields;
29
+ }
30
+ mod.fields = initManifestFields(
31
+ nModule.getApp(),
32
+ schema,
33
+ rawMutationsList,
34
+ privateFields,
35
+ moduleName
36
+ );
37
+ }
38
+ } catch (e) {
39
+ error(
40
+ `Error while initialization of route: ${moduleName}//${routeName}`
41
+ );
42
+ if (e instanceof notError) {
43
+ error(`name: ${e.options.field}, type: ${e.options.type}`);
44
+ } else {
45
+ error(e);
46
+ }
47
+ }
48
+ }
49
+ }
47
50
  };
@@ -1,39 +1,42 @@
1
- const {log, error} = require('not-log')(module, 'initializator');
2
- const protoModel = require('../../model/proto.js');
3
- const {initFileSchemaFromFields} = require('../../fields');
4
- const {notError} = require('not-error');
1
+ const { error } = require("not-log")(module, "initializator");
2
+ const protoModel = require("../../model/proto.js");
3
+ const { initFileSchemaFromFields } = require("../../fields");
4
+ const { notError } = require("not-error");
5
5
 
6
- module.exports = class notModuleInitializatorModels{
7
- static openFile = require;
8
- constructor({nModule}){
9
- this.run({nModule, app: nModule.getApp()});
10
- }
6
+ module.exports = class notModuleInitializatorModels {
7
+ static openFile = require;
8
+ constructor({ nModule }) {
9
+ this.run({ nModule, app: nModule.getApp() });
10
+ }
11
11
 
12
- run({app, nModule}) {
13
- const moduleName = nModule.getName();
14
- for(let modelName in nModule.getModels()) {
15
- try{
16
- initFileSchemaFromFields({
17
- app,
18
- moduleName: nModule.getName(),
19
- mod: nModule.getModelFile(modelName),
20
- type: 'model',
21
- from: ':FIELDS',
22
- to: ':thisSchema',
23
- });
24
- protoModel.fabricate(nModule.getModelFile(modelName), nModule.getOptions(), nModule.mongoose);
25
- //log(`${moduleName}//${modelName}`);
26
- }catch(e){
27
- error(`Error while initialization of model: ${moduleName}//${modelName}`);
28
- if(e instanceof notError){
29
- error(`name: ${e.options.field}, type: ${e.options.type}`);
30
- }else{
31
- error(e);
12
+ run({ app, nModule }) {
13
+ const moduleName = nModule.getName();
14
+ for (let modelName in nModule.getModels()) {
15
+ try {
16
+ initFileSchemaFromFields({
17
+ app,
18
+ moduleName: nModule.getName(),
19
+ mod: nModule.getModelFile(modelName),
20
+ type: "model",
21
+ from: ":FIELDS",
22
+ to: ":thisSchema",
23
+ });
24
+ protoModel.fabricate(
25
+ nModule.getModelFile(modelName),
26
+ nModule.getOptions(),
27
+ nModule.mongoose
28
+ );
29
+ //log(`${moduleName}//${modelName}`);
30
+ } catch (e) {
31
+ error(
32
+ `Error while initialization of model: ${moduleName}//${modelName}`
33
+ );
34
+ if (e instanceof notError) {
35
+ error(`name: ${e.options.field}, type: ${e.options.type}`);
36
+ } else {
37
+ error(e);
38
+ }
39
+ }
32
40
  }
33
- }
34
-
35
41
  }
36
- }
37
-
38
-
39
42
  };
@@ -1,112 +1,145 @@
1
- const merge = require('deepmerge');
2
- const Auth = require('../auth');
1
+ const merge = require("deepmerge");
2
+ const Auth = require("../auth");
3
3
 
4
- const DIRTY_FIELDS = ['rules', 'admin', 'root', 'safe', 'auth', 'role', 'actionName', 'actionPrefix'];
4
+ const DIRTY_FIELDS = [
5
+ "rules",
6
+ "admin",
7
+ "root",
8
+ "safe",
9
+ "auth",
10
+ "role",
11
+ "actionName",
12
+ "actionPrefix",
13
+ ];
5
14
 
6
15
  module.exports = class notManifestFilter {
7
- /**
8
- * Clear route from action variants that not permited for user according to
9
- * his auth, role, root status
10
- *
11
- * @param {object} route route object
12
- * @param {boolean} auth user auth status
13
- * @param {boolean} role user role status
14
- * @param {boolean} root user root status
15
- *
16
- * @return {object} Return router with only actions user can access with current states of auth, role, root. With removed definitions of what rules of access are.
17
- **/
18
- static filterRoute(route, auth, role, root) {
19
- let result = JSON.parse(JSON.stringify(route));
20
- result.actions = {};
21
- if (!route || !route.actions) {
22
- return result;
23
- }
24
- for (let actionName in route.actions) {
25
- if (!route.actions[actionName]) {
26
- continue;
27
- }
28
- let actionSet = route.actions[actionName];
29
- notManifestFilter.filterRouteAction(actionName, actionSet, auth, role, root, result);
16
+ /**
17
+ * Clear route from action variants that not permited for user according to
18
+ * his auth, role, root status
19
+ *
20
+ * @param {object} route route object
21
+ * @param {boolean} auth user auth status
22
+ * @param {boolean} role user role status
23
+ * @param {boolean} root user root status
24
+ *
25
+ * @return {object} Return router with only actions user can access with current states of auth, role, root. With removed definitions of what rules of access are.
26
+ **/
27
+ static filterRoute(route, auth, role, root) {
28
+ let result = JSON.parse(JSON.stringify(route));
29
+ result.actions = {};
30
+ if (!route || !route.actions) {
31
+ return result;
32
+ }
33
+ for (let actionName in route.actions) {
34
+ if (!route.actions[actionName]) {
35
+ continue;
36
+ }
37
+ let actionSet = route.actions[actionName];
38
+ notManifestFilter.filterRouteAction(
39
+ actionName,
40
+ actionSet,
41
+ auth,
42
+ role,
43
+ root,
44
+ result
45
+ );
46
+ }
47
+ return result;
30
48
  }
31
- return result;
32
- }
33
49
 
34
- /**
35
- *
36
- */
37
- static filterRouteAction(actionName, actionSet, auth, role, root, result) {
38
- if (Array.isArray(actionSet.rules)) {
39
- for (let i = 0; i < actionSet.rules.length; i++) {
40
- if (Auth.checkCredentials(actionSet.rules[i], auth, role, root)) {
41
- result.actions[actionName] = notManifestFilter.clearActionFromRules(actionSet, actionSet.rules[i]);
42
- break;
50
+ /**
51
+ *
52
+ */
53
+ static filterRouteAction(actionName, actionSet, auth, role, root, result) {
54
+ if (Array.isArray(actionSet.rules)) {
55
+ for (let i = 0; i < actionSet.rules.length; i++) {
56
+ if (
57
+ Auth.checkCredentials(actionSet.rules[i], auth, role, root)
58
+ ) {
59
+ result.actions[actionName] =
60
+ notManifestFilter.clearActionFromRules(
61
+ actionSet,
62
+ actionSet.rules[i]
63
+ );
64
+ break;
65
+ }
66
+ }
67
+ } else {
68
+ if (Auth.checkCredentials(actionSet, auth, role, root)) {
69
+ result.actions[actionName] =
70
+ notManifestFilter.clearActionFromRules(actionSet);
71
+ }
43
72
  }
44
- }
45
- } else {
46
- if (Auth.checkCredentials(actionSet, auth, role, root)) {
47
- result.actions[actionName] = notManifestFilter.clearActionFromRules(actionSet);
48
- }
49
73
  }
50
- }
51
74
 
52
- /**
53
- * Filters manifest for current user auth, role, root.
54
- * Removes all actions that can not be performed
55
- *
56
- * @param {object} manifest full raw manifest
57
- * @param {boolean} auth user auth status
58
- * @param {boolean} role user role status
59
- * @param {boolean} root user root status
60
- *
61
- * @return {object} filtered manifest
62
- **/
75
+ /**
76
+ * Filters manifest for current user auth, role, root.
77
+ * Removes all actions that can not be performed
78
+ *
79
+ * @param {object} manifest full raw manifest
80
+ * @param {boolean} auth user auth status
81
+ * @param {boolean} role user role status
82
+ * @param {boolean} root user root status
83
+ *
84
+ * @return {object} filtered manifest
85
+ **/
63
86
 
64
- static filter(manifest, auth, role, root) {
65
- var result = {};
66
- for (let routeName in manifest) {
67
- let routeMan = notManifestFilter.filterRoute(manifest[routeName], auth, role, root);
68
- if (Object.keys(routeMan.actions).length > 0) {
69
- result[routeName] = routeMan;
70
- }
87
+ static filter(manifest, auth, role, root) {
88
+ var result = {};
89
+ for (let routeName in manifest) {
90
+ let routeMan = notManifestFilter.filterRoute(
91
+ manifest[routeName],
92
+ auth,
93
+ role,
94
+ root
95
+ );
96
+ if (Object.keys(routeMan.actions).length > 0) {
97
+ result[routeName] = routeMan;
98
+ }
99
+ }
100
+ return result;
71
101
  }
72
- return result;
73
- }
74
102
 
75
- /**
76
- * Return true if ruleSet object has not empty list of fields
77
- * @param {Object} ruleSet specific set of rules for action
78
- * @return {boolean} if rule set has not empty fields list
79
- */
80
- static ruleSetHasFieldsDirective(ruleSet) {
81
- return (typeof ruleSet !== 'undefined' && ruleSet !== null) && (ruleSet.fields && Array.isArray(ruleSet.fields) && ruleSet.fields.length);
82
- }
83
-
84
- /**
85
- * Clear action definition from rules of access
86
- * @param {object} action action data
87
- * @param {object} ruleSet specific set of rules for this action
88
- * @return {object} clean action data
89
- **/
90
- static clearActionFromRules(action, ruleSet = null) {
91
- let copy = merge({}, action);
92
- notManifestFilter.clearFromDirtyFields(copy);
93
- //copy fields list from rule to action if it exists
94
- //fields list is used to restrict fields of data that could be accessed via
95
- //this action
96
- if (notManifestFilter.ruleSetHasFieldsDirective(ruleSet)) {
97
- copy.fields = [...ruleSet.fields];
103
+ /**
104
+ * Return true if ruleSet object has not empty list of fields
105
+ * @param {Object} ruleSet specific set of rules for action
106
+ * @return {boolean} if rule set has not empty fields list
107
+ */
108
+ static ruleSetHasFieldsDirective(ruleSet) {
109
+ return (
110
+ typeof ruleSet !== "undefined" &&
111
+ ruleSet !== null &&
112
+ ruleSet.fields &&
113
+ Array.isArray(ruleSet.fields) &&
114
+ ruleSet.fields.length
115
+ );
98
116
  }
99
- return copy;
100
- }
101
117
 
118
+ /**
119
+ * Clear action definition from rules of access
120
+ * @param {object} action action data
121
+ * @param {object} ruleSet specific set of rules for this action
122
+ * @return {object} clean action data
123
+ **/
124
+ static clearActionFromRules(action, ruleSet = null) {
125
+ let copy = merge({}, action);
126
+ notManifestFilter.clearFromDirtyFields(copy);
127
+ //copy fields list from rule to action if it exists
128
+ //fields list is used to restrict fields of data that could be accessed via
129
+ //this action
130
+ if (notManifestFilter.ruleSetHasFieldsDirective(ruleSet)) {
131
+ copy.fields = [...ruleSet.fields];
132
+ }
133
+ return copy;
134
+ }
102
135
 
103
- /**
104
- * Deletes fields listed in DIRTY_FIELDS constant from object
105
- * @param {Object} action action object
106
- **/
107
- static clearFromDirtyFields(action) {
108
- DIRTY_FIELDS.forEach(fieldName => {
109
- delete action[fieldName];
110
- });
111
- }
136
+ /**
137
+ * Deletes fields listed in DIRTY_FIELDS constant from object
138
+ * @param {Object} action action object
139
+ **/
140
+ static clearFromDirtyFields(action) {
141
+ DIRTY_FIELDS.forEach((fieldName) => {
142
+ delete action[fieldName];
143
+ });
144
+ }
112
145
  };
@@ -1,10 +1,9 @@
1
- const Parser = require('../parser');
2
- const Route = require('./route');
1
+ const Parser = require("../parser");
2
+ const Route = require("./route");
3
3
 
4
- const {objHas} = require('../common');
5
-
6
- const notManifestFilter = require('./manifest.filter.js');
4
+ const { objHas } = require("../common");
7
5
 
6
+ const notManifestFilter = require("./manifest.filter.js");
8
7
 
9
8
  /**
10
9
  * API manifest
@@ -14,86 +13,113 @@ const notManifestFilter = require('./manifest.filter.js');
14
13
  * @param {string} moduleName name of owner module
15
14
  **/
16
15
  class notManifest {
17
- constructor(app, notApp, moduleName) {
18
- this.app = app;
19
- this.notApp = notApp;
20
- this.moduleName = moduleName;
21
- return this;
22
- }
16
+ constructor(app, notApp, moduleName) {
17
+ this.app = app;
18
+ this.notApp = notApp;
19
+ this.moduleName = moduleName;
20
+ return this;
21
+ }
23
22
 
24
- /**
25
- * Создаем путь для одной конечной точки
26
- *
27
- * @param {object} app express app object
28
- * @param {string} routesPath directory where routes files is placed
29
- * @param {string} routeLine aka '/login', '/user/:id', etc
30
- * @param {string} modelName name of the mongoose model, should be exact as file name with routes for this model. If /models/theme.js contains 'Theme' mongoose model, then /routes/theme.js should `
31
- * contain routes for that model.
32
- * @param {string} actionSetName name of action in routes file. Look for existing route file for understanding
33
- * @param {object} actionData representation of action data
34
- *
35
- * @return {boolean} if route were registered
36
- **/
23
+ /**
24
+ * Создаем путь для одной конечной точки
25
+ *
26
+ * @param {object} app express app object
27
+ * @param {string} routesPath directory where routes files is placed
28
+ * @param {string} routeLine aka '/login', '/user/:id', etc
29
+ * @param {string} modelName name of the mongoose model, should be exact as file name with routes for this model. If /models/theme.js contains 'Theme' mongoose model, then /routes/theme.js should `
30
+ * contain routes for that model.
31
+ * @param {string} actionSetName name of action in routes file. Look for existing route file for understanding
32
+ * @param {object} actionData representation of action data
33
+ *
34
+ * @return {boolean} if route were registered
35
+ **/
37
36
 
38
- registerRouteForAction(routeLine, routeName, actionName, actionData) {
39
- if (actionData && actionData.method) {
40
- const routerAction = new Route(this.notApp, this.moduleName, routeName, actionName, actionData);
41
- this.app[actionData.method.toLowerCase()](routeLine, routerAction.exec.bind(routerAction));
42
- return true;
43
- } else {
44
- return false;
37
+ registerRouteForAction(routeLine, routeName, actionName, actionData) {
38
+ if (actionData && actionData.method) {
39
+ const routerAction = new Route(
40
+ this.notApp,
41
+ this.moduleName,
42
+ routeName,
43
+ actionName,
44
+ actionData
45
+ );
46
+ this.app[actionData.method.toLowerCase()](
47
+ routeLine,
48
+ routerAction.exec.bind(routerAction)
49
+ );
50
+ return true;
51
+ } else {
52
+ return false;
53
+ }
45
54
  }
46
- }
47
55
 
48
- /**
49
- * Создаем пути согласно манифесту
50
- *
51
- * @param {object} moduleManifest notManifest of module
52
- **/
53
- registerRoutes(moduleManifest) {
54
- Object.values(moduleManifest).forEach(route => this.registerRoute(route));
55
- }
56
-
57
- /**
58
- * Check if manifest file has url, model and actions, so we could register routes
59
- * @param {object} route content of .manifest.js file
60
- * @return {boolean} true if could create routes
61
- **/
62
- routeHasRoutes(route){
63
- return objHas(route, 'actions') && objHas(route, 'url') && (objHas(route, 'model') && route.model !== '');
64
- }
56
+ /**
57
+ * Создаем пути согласно манифесту
58
+ *
59
+ * @param {object} moduleManifest notManifest of module
60
+ **/
61
+ registerRoutes(moduleManifest) {
62
+ Object.values(moduleManifest).forEach((route) =>
63
+ this.registerRoute(route)
64
+ );
65
+ }
65
66
 
66
- /**
67
- * Check if manifest file has url and actions, so we could register routes
68
- * @param {object} moduleManifest library of .manifest.js files
69
- * @param {string} routeName name of
70
- **/
71
- registerRoute(route){
72
- if(!this.routeHasRoutes(route)){return;}
73
- const routeName = route.model;
74
- Object.keys(route.actions).forEach((actionName)=>{
75
- const actionData = route.actions[actionName];
76
- const routeLine = Parser.getRouteLine(route.url, routeName, actionName, actionData);
77
- this.registerRouteForAction(routeLine, routeName, actionName, actionData);
78
- });
79
- }
67
+ /**
68
+ * Check if manifest file has url, model and actions, so we could register routes
69
+ * @param {object} route content of .manifest.js file
70
+ * @return {boolean} true if could create routes
71
+ **/
72
+ routeHasRoutes(route) {
73
+ return (
74
+ objHas(route, "actions") &&
75
+ objHas(route, "url") &&
76
+ objHas(route, "model") &&
77
+ route.model !== ""
78
+ );
79
+ }
80
80
 
81
- /**
82
- * Filters manifest for current user auth, role, root.
83
- * Removes all actions that can not be performed
84
- *
85
- * @param {object} manifest full raw manifest
86
- * @param {boolean} auth user auth status
87
- * @param {boolean} role user role status
88
- * @param {boolean} root user root status
89
- *
90
- * @return {object} filtered manifest
91
- **/
81
+ /**
82
+ * Check if manifest file has url and actions, so we could register routes
83
+ * @param {object} moduleManifest library of .manifest.js files
84
+ * @param {string} routeName name of
85
+ **/
86
+ registerRoute(route) {
87
+ if (!this.routeHasRoutes(route)) {
88
+ return;
89
+ }
90
+ const routeName = route.model;
91
+ Object.keys(route.actions).forEach((actionName) => {
92
+ const actionData = route.actions[actionName];
93
+ const routeLine = Parser.getRouteLine(
94
+ route.url,
95
+ routeName,
96
+ actionName,
97
+ actionData
98
+ );
99
+ this.registerRouteForAction(
100
+ routeLine,
101
+ routeName,
102
+ actionName,
103
+ actionData
104
+ );
105
+ });
106
+ }
92
107
 
93
- filterManifest(manifest, auth, role, root) {
94
- return notManifestFilter.filter(manifest, auth, role, root);
95
- }
108
+ /**
109
+ * Filters manifest for current user auth, role, root.
110
+ * Removes all actions that can not be performed
111
+ *
112
+ * @param {object} manifest full raw manifest
113
+ * @param {boolean} auth user auth status
114
+ * @param {boolean} role user role status
115
+ * @param {boolean} root user root status
116
+ *
117
+ * @return {object} filtered manifest
118
+ **/
96
119
 
120
+ filterManifest(manifest, auth, role, root) {
121
+ return notManifestFilter.filter(manifest, auth, role, root);
122
+ }
97
123
  }
98
124
 
99
125
  module.exports = notManifest;