not-node 6.4.2 → 6.4.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-node",
3
- "version": "6.4.2",
3
+ "version": "6.4.4",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -15,14 +15,5 @@ module.exports = ({ MODULE_NAME, MODEL_NAME, actionName, FIELDS = [] }) => {
15
15
  FIELDS: [...STANDART_FIELDS, ...FIELDS],
16
16
  });
17
17
  }
18
-
19
- async extract(req) {
20
- return this.afterExtract(
21
- {
22
- ...this.extractRequestEnvs(req),
23
- },
24
- req
25
- );
26
- }
27
18
  };
28
19
  };
@@ -10,18 +10,15 @@ const FIELDS = [
10
10
  module.exports = ({ MODULE_NAME, MODEL_NAME, actionName = "getByID" }) => {
11
11
  return class extends Form {
12
12
  constructor(params) {
13
- super({ ...params, MODULE_NAME, MODEL_NAME,actionName, FIELDS });
13
+ super({ ...params, MODULE_NAME, MODEL_NAME, actionName, FIELDS });
14
14
  }
15
15
 
16
16
  async extract(req) {
17
17
  const envs = this.extractRequestEnvs(req);
18
- return this.afterExtract(
19
- {
20
- ...envs,
21
- targetId: envs.modelNameID,
22
- },
23
- req
24
- );
18
+ return {
19
+ ...envs,
20
+ targetId: envs.modelNameID,
21
+ };
25
22
  }
26
23
  };
27
24
  };
@@ -12,15 +12,5 @@ module.exports = ({ MODULE_NAME, MODEL_NAME, actionName = "getById" }) => {
12
12
  constructor(params) {
13
13
  super({ ...params, MODULE_NAME, MODEL_NAME, actionName, FIELDS });
14
14
  }
15
-
16
- async extract(req) {
17
- const envs = this.extractRequestEnvs(req);
18
- return this.afterExtract(
19
- {
20
- ...envs,
21
- },
22
- req
23
- );
24
- }
25
15
  };
26
16
  };
@@ -47,12 +47,9 @@ const FactoryFormList = ({ MODULE_NAME, MODEL_NAME, actionName = "list" }) => {
47
47
  );
48
48
  }
49
49
 
50
- return this.afterExtract(
51
- {
52
- ...envs,
53
- },
54
- req
55
- );
50
+ return {
51
+ ...envs,
52
+ };
56
53
  }
57
54
  };
58
55
  };
@@ -22,8 +22,6 @@ const FactoryFormListAndCount = ({
22
22
  MODEL_NAME,
23
23
  actionName = "listAndCount",
24
24
  }) => {
25
-
26
-
27
25
  return class extends Form {
28
26
  constructor(params) {
29
27
  super({
@@ -31,7 +29,7 @@ const FactoryFormListAndCount = ({
31
29
  FIELDS,
32
30
  MODULE_NAME,
33
31
  MODEL_NAME,
34
- actionName
32
+ actionName,
35
33
  });
36
34
  }
37
35
 
@@ -52,12 +50,9 @@ const FactoryFormListAndCount = ({
52
50
  }
53
51
  );
54
52
  }
55
- return this.afterExtract(
56
- {
57
- ...envs,
58
- },
59
- req
60
- );
53
+ return {
54
+ ...envs,
55
+ };
61
56
  }
62
57
  };
63
58
  };
@@ -3,6 +3,8 @@ const { HttpExceptionForbidden } = require("../exceptions/http");
3
3
  module.exports = ({ getLogic, before, after }) => {
4
4
  class notGenericRoute {
5
5
  static restrictRootAccess = false;
6
+ static rootAsUser = false;
7
+
6
8
  static exceptionOnRootAccess = HttpExceptionForbidden;
7
9
  static exceptionParamsPacker = (prepared) => {
8
10
  return [{ params: prepared }];
@@ -22,7 +24,11 @@ module.exports = ({ getLogic, before, after }) => {
22
24
  ...this.exceptionParamsPacker(prepared)
23
25
  );
24
26
  }
25
- return await getLogic().create(prepared);
27
+ if (this.rootAsUser) {
28
+ return await getLogic().createOwn(prepared);
29
+ } else {
30
+ return await getLogic().create(prepared);
31
+ }
26
32
  }
27
33
 
28
34
  static async create(req, res, next, prepared) {
@@ -35,7 +41,11 @@ module.exports = ({ getLogic, before, after }) => {
35
41
  ...this.exceptionParamsPacker(prepared)
36
42
  );
37
43
  }
38
- return await getLogic().get(prepared);
44
+ if (this.rootAsUser) {
45
+ return await getLogic().getOwn(prepared);
46
+ } else {
47
+ return await getLogic().get(prepared);
48
+ }
39
49
  }
40
50
 
41
51
  static async get(req, res, next, prepared) {
@@ -48,7 +58,11 @@ module.exports = ({ getLogic, before, after }) => {
48
58
  ...this.exceptionParamsPacker(prepared)
49
59
  );
50
60
  }
51
- return await getLogic().getByID(prepared);
61
+ if (this.rootAsUser) {
62
+ return await getLogic().getByIDOwn(prepared);
63
+ } else {
64
+ return await getLogic().getByID(prepared);
65
+ }
52
66
  }
53
67
 
54
68
  static async getByID(req, res, next, prepared) {
@@ -61,7 +75,11 @@ module.exports = ({ getLogic, before, after }) => {
61
75
  ...this.exceptionParamsPacker(prepared)
62
76
  );
63
77
  }
64
- return await getLogic().getRaw(prepared);
78
+ if (this.rootAsUser) {
79
+ return await getLogic().getOwnRaw(prepared);
80
+ } else {
81
+ return await getLogic().getRaw(prepared);
82
+ }
65
83
  }
66
84
 
67
85
  static async getRaw(req, res, next, prepared) {
@@ -74,7 +92,11 @@ module.exports = ({ getLogic, before, after }) => {
74
92
  ...this.exceptionParamsPacker(prepared)
75
93
  );
76
94
  }
77
- return await getLogic().update(prepared);
95
+ if (this.rootAsUser) {
96
+ return await getLogic().updateOwn(prepared);
97
+ } else {
98
+ return await getLogic().update(prepared);
99
+ }
78
100
  }
79
101
 
80
102
  static async update(req, res, next, prepared) {
@@ -87,7 +109,11 @@ module.exports = ({ getLogic, before, after }) => {
87
109
  ...this.exceptionParamsPacker(prepared)
88
110
  );
89
111
  }
90
- return await getLogic().listAll(prepared);
112
+ if (this.rootAsUser) {
113
+ return await getLogic().listAllOwn(prepared);
114
+ } else {
115
+ return await getLogic().listAll(prepared);
116
+ }
91
117
  }
92
118
 
93
119
  static async listAll(req, res, next, prepared) {
@@ -100,7 +126,11 @@ module.exports = ({ getLogic, before, after }) => {
100
126
  ...this.exceptionParamsPacker(prepared)
101
127
  );
102
128
  }
103
- return await getLogic().listAndCount(prepared);
129
+ if (this.rootAsUser) {
130
+ return await getLogic().listAndCountOwn(prepared);
131
+ } else {
132
+ return await getLogic().listAndCount(prepared);
133
+ }
104
134
  }
105
135
 
106
136
  static async listAndCount(req, res, next, prepared) {
@@ -113,7 +143,11 @@ module.exports = ({ getLogic, before, after }) => {
113
143
  ...this.exceptionParamsPacker(prepared)
114
144
  );
115
145
  }
116
- return await getLogic().list(prepared);
146
+ if (this.rootAsUser) {
147
+ return await getLogic().listOwn(prepared);
148
+ } else {
149
+ return await getLogic().list(prepared);
150
+ }
117
151
  }
118
152
 
119
153
  static async list(req, res, next, prepared) {
@@ -126,7 +160,11 @@ module.exports = ({ getLogic, before, after }) => {
126
160
  ...this.exceptionParamsPacker(prepared)
127
161
  );
128
162
  }
129
- return await getLogic().count(prepared);
163
+ if (this.rootAsUser) {
164
+ return await getLogic().countOwn(prepared);
165
+ } else {
166
+ return await getLogic().count(prepared);
167
+ }
130
168
  }
131
169
 
132
170
  static async count(req, res, next, prepared) {
@@ -139,7 +177,11 @@ module.exports = ({ getLogic, before, after }) => {
139
177
  ...this.exceptionParamsPacker(prepared)
140
178
  );
141
179
  }
142
- return await getLogic().delete(prepared);
180
+ if (this.rootAsUser) {
181
+ return await getLogic().deleteOwn(prepared);
182
+ } else {
183
+ return await getLogic().delete(prepared);
184
+ }
143
185
  }
144
186
 
145
187
  static async delete(req, res, next, prepared) {
@@ -46,6 +46,7 @@ class nc<%- ModelName %>Common extends notCRUD {
46
46
  id: -1,
47
47
  },
48
48
  showSearch: true,
49
+ showSelect: false,
49
50
  idField: "_id",
50
51
  fields: [
51
52
  <% if (increment) { %>