not-node 6.2.18 → 6.2.19

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 (47) hide show
  1. package/.husky/pre-commit +4 -0
  2. package/package.json +7 -4
  3. package/src/auth/roles.js +9 -1
  4. package/src/auth/rules.js +5 -5
  5. package/src/cli/actions/env.mjs +1 -1
  6. package/src/cli/actions/nginx.mjs +1 -1
  7. package/src/cli/actions/pm2.mjs +1 -1
  8. package/src/common.js +1 -1
  9. package/src/domain.js +36 -24
  10. package/src/identity/providers/session.js +3 -0
  11. package/src/manifest/batchRunner.js +5 -1
  12. package/src/manifest/registrator/fields.js +4 -4
  13. package/src/manifest/route.js +1 -0
  14. package/src/model/exceptions.js +3 -3
  15. package/src/model/versioning.js +2 -2
  16. package/test/auth/routes.js +34 -10
  17. package/test/fakes.js +52 -0
  18. package/test/identity/providers/session.js +14 -5
  19. package/test/identity/providers/token.js +1 -1
  20. package/test/init/additional.js +31 -33
  21. package/test/init/app.js +66 -10
  22. package/test/init/bodyparser.js +4 -1
  23. package/test/init/compression.js +4 -1
  24. package/test/init/cors.js +5 -1
  25. package/test/init/csp.js +2 -2
  26. package/test/init/db.js +5 -1
  27. package/test/init/env.js +12 -2
  28. package/test/init/express.js +4 -1
  29. package/test/init/fileupload.js +4 -1
  30. package/test/init/http.js +21 -4
  31. package/test/init/middleware.js +13 -1
  32. package/test/init/routes.js +1 -0
  33. package/test/init/sessions/mongoose.js +5 -1
  34. package/test/init/sessions/redis.js +5 -1
  35. package/test/init/sessions.js +21 -15
  36. package/test/init/static.js +4 -1
  37. package/test/init/template.js +5 -1
  38. package/test/model/versioning.js +3 -3
  39. package/test/module/fields.js +45 -20
  40. package/test/module/index.js +26 -15
  41. package/test/notApp.js +221 -187
  42. package/test/notDomain.js +799 -707
  43. package/test/notManifestFilter.js +385 -322
  44. package/test/notModule.js +689 -644
  45. package/test/notRoute.js +112 -99
  46. package/test/testies/module/fields/collection.js +16 -14
  47. package/test/testies/module/fields/single.js +11 -11
@@ -1,4 +1,3 @@
1
- const FIELDS = require("../../src/fields");
2
1
  const path = require("path");
3
2
  const notModuleRegistratorFields = require("../../src/manifest/registrator/fields");
4
3
 
@@ -87,9 +86,14 @@ module.exports = ({ expect }) => {
87
86
 
88
87
  describe("register", function () {
89
88
  it("file is lib", (done) => {
89
+ const libPath = path.resolve(
90
+ __dirname,
91
+ "../testies/module/fields/collection.js"
92
+ );
90
93
  const ctx = {
91
- registerFields({ lib, fieldsImportRules }) {
92
- expect(fieldsImportRules).to.be.deep.equal({
94
+ registerFields({ lib, fromPath, nModule }) {
95
+ expect(fromPath).to.be.deep.equal(libPath);
96
+ expect(nModule.fieldsImportRules).to.be.deep.equal({
93
97
  one: true,
94
98
  });
95
99
  expect(lib).to.be.have.keys(["collectionItem"]);
@@ -102,19 +106,15 @@ module.exports = ({ expect }) => {
102
106
  one: true,
103
107
  },
104
108
  },
105
- fromPath: path.resolve(
106
- __dirname,
107
- "../testies/module/fields/collection.js"
108
- ),
109
+ fromPath: libPath,
109
110
  };
110
111
  notModuleRegistratorFields.prototype.register.call(ctx, param);
111
- expect(result).to.be.deep.equal(list);
112
112
  });
113
113
 
114
114
  it("file is single field", (done) => {
115
115
  const ctx = {
116
- registerField({ name, field, fieldsImportRules }) {
117
- expect(fieldsImportRules).to.be.deep.equal({
116
+ registerField({ name, field, nModule }) {
117
+ expect(nModule.fieldsImportRules).to.be.deep.equal({
118
118
  one: true,
119
119
  });
120
120
  expect(field).to.be.have.keys(["ui", "model"]);
@@ -134,13 +134,30 @@ module.exports = ({ expect }) => {
134
134
  ),
135
135
  };
136
136
  notModuleRegistratorFields.prototype.register.call(ctx, param);
137
- expect(result).to.be.deep.equal(list);
138
137
  });
139
138
  });
140
139
 
141
140
  describe("registerFields", function () {
142
141
  it("file is a lib", () => {
143
- const ctx = {};
142
+ const fField = {
143
+ ui: {
144
+ component: "UITextfield",
145
+ placeholder: "collectionItem",
146
+ label: "collectionItem",
147
+ readonly: true,
148
+ },
149
+ model: {
150
+ type: String,
151
+ searchable: true,
152
+ required: true,
153
+ },
154
+ };
155
+ const ctx = {
156
+ registerField({ name, field }) {
157
+ expect(name).to.be.equal("collectionItem");
158
+ expect(field).to.be.deep.equal(fField);
159
+ },
160
+ };
144
161
  const param = {
145
162
  fieldsImportRules: {},
146
163
  lib: require(path.resolve(
@@ -152,29 +169,37 @@ module.exports = ({ expect }) => {
152
169
  ctx,
153
170
  param
154
171
  );
155
- expect(Object.keys(FIELDS.LIB).includes("collectionItem")).to.be
156
- .true;
157
172
  });
158
173
  });
159
174
 
160
175
  describe("registerField", function () {
161
176
  it("file is a single field", () => {
177
+ const fPath = path.resolve(
178
+ __dirname,
179
+ "../testies/module/fields/single.js"
180
+ );
181
+ let FIELDS = {};
162
182
  const ctx = {
163
183
  extendByFrontValidators() {},
164
184
  };
165
185
  const param = {
166
186
  name: "single",
167
- field: require(path.resolve(
168
- __dirname,
169
- "../testies/module/fields/single.js"
170
- )),
171
- fieldsImportRules: {},
187
+ field: require(fPath),
188
+ fromPath: fPath,
189
+ nModule: {
190
+ setField(name, val) {
191
+ FIELDS[name] = val;
192
+ },
193
+ getName() {
194
+ return "test_module";
195
+ },
196
+ },
172
197
  };
173
198
  notModuleRegistratorFields.prototype.registerField.call(
174
199
  ctx,
175
200
  param
176
201
  );
177
- expect(Object.keys(FIELDS.LIB).includes("single")).to.be.true;
202
+ expect(Object.keys(FIELDS).includes("single")).to.be.true;
178
203
  });
179
204
  });
180
205
  });
@@ -1,10 +1,10 @@
1
- const notModuleRegistrator = require("../../src/manifest/registrator");
1
+ const BatchRunner = require("../../src/manifest/batchRunner");
2
2
 
3
3
  module.exports = (input) => {
4
4
  const { expect } = input;
5
5
 
6
- describe("notModuleRegistrator", () => {
7
- it("setRegistrators", (done) => {
6
+ describe("BatchRunner", () => {
7
+ it("setProcessors", (done) => {
8
8
  const param = "query";
9
9
  const regs = [
10
10
  {
@@ -14,17 +14,26 @@ module.exports = (input) => {
14
14
  },
15
15
  },
16
16
  ];
17
- notModuleRegistrator.setRegistrators(regs);
18
- expect(notModuleRegistrator.registrators).to.be.deep.equal(regs);
19
- notModuleRegistrator.registrators[0].run(param);
17
+ const runner = new BatchRunner();
18
+ runner.setProcessors(regs);
19
+ expect(runner.processors).to.be.deep.equal(regs);
20
+ runner.processors[0].run(param);
20
21
  });
21
22
 
22
- it("resetRegistrators", () => {
23
- const regs = [];
24
- notModuleRegistrator.setRegistrators(regs);
25
- expect(notModuleRegistrator.registrators.length).to.be.equal(0);
26
- notModuleRegistrator.resetRegistrators();
27
- expect(notModuleRegistrator.registrators.length).to.be.equal(6);
23
+ it("resetBatchRunners", () => {
24
+ const regs = [
25
+ () => {},
26
+ () => {},
27
+ () => {},
28
+ () => {},
29
+ () => {},
30
+ () => {},
31
+ ];
32
+ const runner = new BatchRunner();
33
+ runner.setProcessors(regs);
34
+ expect(runner.processors.length).to.be.equal(6);
35
+ runner.resetProcessors();
36
+ expect(runner.processors.length).to.be.equal(0);
28
37
  });
29
38
 
30
39
  it("with paths", () => {
@@ -33,14 +42,16 @@ module.exports = (input) => {
33
42
  paths: {},
34
43
  },
35
44
  };
36
- notModuleRegistrator.setRegistrators([]);
37
- const res = notModuleRegistrator.registerContent({ nModule });
45
+ const runner = new BatchRunner();
46
+ runner.setProcessors([]);
47
+ const res = runner.exec({ nModule });
38
48
  expect(res).to.be.true;
39
49
  });
40
50
 
41
51
  it("without paths", function () {
42
52
  const nModule = { module: {} };
43
- const res = notModuleRegistrator.registerContent({ nModule });
53
+ const runner = new BatchRunner();
54
+ const res = runner.exec({ nModule });
44
55
  expect(res).to.be.false;
45
56
  });
46
57
 
package/test/notApp.js CHANGED
@@ -1,205 +1,239 @@
1
- const expect = require('chai').expect,
2
- notApp = require('../src/app');
3
- const mock = require('mock-require');
1
+ const expect = require("chai").expect,
2
+ notApp = require("../src/app");
3
+ const mock = require("mock-require");
4
+ const { notAppIdentity } = require("..");
4
5
 
5
- mock('not-inform',{
6
- Inform: class FakeInformer{}
6
+ mock("not-inform", {
7
+ Inform: class FakeInformer {},
7
8
  });
8
9
 
9
- describe('noApp', function() {
10
-
11
- describe('Constructor', function() {
12
- it('With options', function() {
13
- let app = new notApp({
14
- someOption: true
15
- });
16
- expect(app.getOptions()).to.deep.equal({
17
- someOption: true
18
- });
19
- expect(app.getModulesNames()).to.deep.equal([]);
10
+ describe("noApp", function () {
11
+ describe("Constructor", function () {
12
+ it("With options", function () {
13
+ let app = new notApp({
14
+ someOption: true,
15
+ });
16
+ expect(app.getOptions()).to.deep.equal({
17
+ someOption: true,
18
+ });
19
+ expect(app.getModulesNames()).to.deep.equal([]);
20
+ });
20
21
  });
21
- });
22
22
 
23
- describe('getManifest', function() {
24
- it('getManifest', function() {
25
- const ctx = {
26
- collectManifest() {
27
- return {
28
- manifest: true
29
- };
30
- }
31
- };
32
- const res = notApp.prototype.getManifest.call(ctx);
33
- expect(res).to.deep.equal({
34
- manifest: true
35
- });
23
+ describe("getManifest", function () {
24
+ it("getManifest", function () {
25
+ notAppIdentity.identity = class {
26
+ static of() {
27
+ return class {
28
+ static isRoot() {}
29
+ static isUser() {}
30
+ static getRole() {}
31
+ static getPrimaryRole() {}
32
+ static getUserId() {}
33
+ static getSessionId() {}
34
+ };
35
+ }
36
+ };
37
+ const ctx = {
38
+ collectManifest() {
39
+ return {
40
+ manifest: true,
41
+ };
42
+ },
43
+ };
44
+ const res = notApp.prototype.getManifest.call(ctx);
45
+ expect(res).to.deep.equal({
46
+ manifest: true,
47
+ });
48
+ });
36
49
  });
37
- });
38
50
 
39
- describe('collectManifest', function() {
40
- it('modules - empty', function() {
41
- const ctx = {
42
- modules: {}
43
- };
44
- const res = notApp.prototype.collectManifest.call(ctx);
45
- expect(res).to.deep.equal({});
46
- });
51
+ describe("collectManifest", function () {
52
+ it("modules - empty", function () {
53
+ const ctx = {
54
+ modules: {},
55
+ getModulesNames() {
56
+ return Object.keys({});
57
+ },
58
+ };
59
+ const res = notApp.prototype.collectManifest.call(ctx);
60
+ expect(res).to.deep.equal({});
61
+ });
47
62
 
48
- it('modules - empty', function() {
49
- const ctx = {
50
- modules: {
51
- user: {
52
- getManifest() {
53
- return {
63
+ it("modules - empty", function () {
64
+ const fModules = {
54
65
  user: {
55
- url: '/api/:modelName',
56
- modelName: 'user',
57
- actions: {
58
- tst: {
59
- mathod: 'get'
60
- }
61
- }
62
- }
63
- };
64
- }
65
- },
66
- far: {
67
- getManifest() {
68
- return {
66
+ getManifest() {
67
+ return {
68
+ user: {
69
+ url: "/api/:modelName",
70
+ modelName: "user",
71
+ actions: {
72
+ tst: {
73
+ mathod: "get",
74
+ },
75
+ },
76
+ },
77
+ };
78
+ },
79
+ },
69
80
  far: {
70
- url: '/api/:modelName',
71
- modelName: 'far',
72
- actions: {
73
- pst: {
74
- mathod: 'get'
75
- }
76
- }
77
- }
78
- };
79
- }
80
- }
81
- }
82
- };
83
- const res = notApp.prototype.collectManifest.call(ctx);
84
- expect(res).to.deep.equal({
85
- user: {
86
- url: '/api/:modelName',
87
- modelName: 'user',
88
- actions: {
89
- tst: {
90
- mathod: 'get'
91
- }
92
- }
93
- },
94
- far: {
95
- url: '/api/:modelName',
96
- modelName: 'far',
97
- actions: {
98
- pst: {
99
- mathod: 'get'
100
- }
101
- }
102
- }
103
- });
81
+ getManifest() {
82
+ return {
83
+ far: {
84
+ url: "/api/:modelName",
85
+ modelName: "far",
86
+ actions: {
87
+ pst: {
88
+ mathod: "get",
89
+ },
90
+ },
91
+ },
92
+ };
93
+ },
94
+ },
95
+ };
96
+ const ctx = {
97
+ getModulesNames() {
98
+ return Object.keys(fModules);
99
+ },
100
+ getModule(name) {
101
+ return fModules[name];
102
+ },
103
+ modules: fModules,
104
+ };
105
+ const res = notApp.prototype.collectManifest.call(ctx);
106
+ expect(res).to.deep.equal({
107
+ user: {
108
+ url: "/api/:modelName",
109
+ modelName: "user",
110
+ actions: {
111
+ tst: {
112
+ mathod: "get",
113
+ },
114
+ },
115
+ },
116
+ far: {
117
+ url: "/api/:modelName",
118
+ modelName: "far",
119
+ actions: {
120
+ pst: {
121
+ mathod: "get",
122
+ },
123
+ },
124
+ },
125
+ });
126
+ });
104
127
  });
105
- });
106
128
 
107
- describe('expose', function() {
108
- it('ok', function() {
109
- let exposed = [];
110
- const ctx = {
111
- forEachMod(cb) {
112
- [
113
- [
114
- 'mod1',
115
- {
116
- expose(app, n) {
117
- exposed.push(n);
118
- }
119
- }
120
- ],
121
- ['mod2', {}]
122
- ].forEach(item => cb(...item));
123
- }
124
- };
125
- notApp.prototype.expose.call(ctx);
126
- expect(exposed).to.deep.equal(['mod1']);
129
+ describe("expose", function () {
130
+ it("ok", function () {
131
+ let exposed = [];
132
+ const ctx = {
133
+ forEachMod(cb) {
134
+ [
135
+ [
136
+ "mod1",
137
+ {
138
+ expose(app, n) {
139
+ exposed.push(n);
140
+ },
141
+ },
142
+ ],
143
+ ["mod2", {}],
144
+ ].forEach((item) => cb(...item));
145
+ },
146
+ };
147
+ notApp.prototype.expose.call(ctx);
148
+ expect(exposed).to.deep.equal(["mod1"]);
149
+ });
127
150
  });
128
- });
129
151
 
152
+ describe("getActionManifestForUser", function () {
153
+ it("model and action exists", function () {
154
+ const ctx = {
155
+ collectManifest() {
156
+ return {
157
+ user: {
158
+ actions: {
159
+ tst: {
160
+ lf: true,
161
+ },
162
+ },
163
+ },
164
+ };
165
+ },
166
+ };
167
+ const model = "user",
168
+ action = "tst",
169
+ user = {
170
+ auth: true,
171
+ };
172
+ const res = notApp.prototype.getActionManifestForUser.call(
173
+ ctx,
174
+ model,
175
+ action,
176
+ user
177
+ );
178
+ expect(res).to.deep.equal({
179
+ lf: true,
180
+ });
181
+ });
130
182
 
183
+ it("model not exists", function () {
184
+ const ctx = {
185
+ collectManifest() {
186
+ return {
187
+ book: {
188
+ actions: {
189
+ tst: {
190
+ lf: true,
191
+ },
192
+ },
193
+ },
194
+ };
195
+ },
196
+ };
197
+ const model = "user",
198
+ action = "tst",
199
+ user = {
200
+ auth: true,
201
+ };
202
+ const res = notApp.prototype.getActionManifestForUser.call(
203
+ ctx,
204
+ model,
205
+ action,
206
+ user
207
+ );
208
+ expect(res).to.deep.equal(false);
209
+ });
131
210
 
132
- describe('getActionManifestForUser', function() {
133
- it('model and action exists', function() {
134
- const ctx = {
135
- collectManifest() {
136
- return {
137
- user: {
138
- actions: {
139
- tst: {
140
- lf: true
141
- }
142
- }
143
- }
144
- };
145
- }
146
- };
147
- const model = 'user',
148
- action = 'tst',
149
- user = {
150
- auth: true
151
- };
152
- const res = notApp.prototype.getActionManifestForUser.call(ctx, model, action, user);
153
- expect(res).to.deep.equal({
154
- lf: true
155
- });
156
- });
157
-
158
- it('model not exists', function() {
159
- const ctx = {
160
- collectManifest() {
161
- return {
162
- book: {
163
- actions: {
164
- tst: {
165
- lf: true
166
- }
167
- }
168
- }
169
- };
170
- }
171
- };
172
- const model = 'user',
173
- action = 'tst',
174
- user = {
175
- auth: true
176
- };
177
- const res = notApp.prototype.getActionManifestForUser.call(ctx, model, action, user);
178
- expect(res).to.deep.equal(false);
211
+ it("action not exists", function () {
212
+ const ctx = {
213
+ collectManifest() {
214
+ return {
215
+ user: {
216
+ actions: {
217
+ look: {
218
+ lf: true,
219
+ },
220
+ },
221
+ },
222
+ };
223
+ },
224
+ };
225
+ const model = "user",
226
+ action = "tst",
227
+ user = {
228
+ auth: true,
229
+ };
230
+ const res = notApp.prototype.getActionManifestForUser.call(
231
+ ctx,
232
+ model,
233
+ action,
234
+ user
235
+ );
236
+ expect(res).to.deep.equal(false);
237
+ });
179
238
  });
180
-
181
- it('action not exists', function() {
182
- const ctx = {
183
- collectManifest() {
184
- return {
185
- user: {
186
- actions: {
187
- look: {
188
- lf: true
189
- }
190
- }
191
- }
192
- };
193
- }
194
- };
195
- const model = 'user',
196
- action = 'tst',
197
- user = {
198
- auth: true
199
- };
200
- const res = notApp.prototype.getActionManifestForUser.call(ctx, model, action, user);
201
- expect(res).to.deep.equal(false);
202
- });
203
- });
204
-
205
239
  });