not-node 6.1.5 → 6.1.6
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/bin/not-cli.mjs +3 -521
- package/package.json +1 -1
- package/playground/.env +2 -2
- package/playground/nginx/development.conf +4 -12
- package/playground/nginx/production.conf +1 -9
- package/playground/nginx/stage.conf +1 -9
- package/playground/pm2/development.json +6 -6
- package/playground/pm2/production.json +5 -5
- package/playground/pm2/stage.json +5 -5
- package/playground/site/app/front/build/admin.js +1 -45
- package/playground/site/app/front/build/client.js +1 -45
- package/playground/site/app/front/build/guest.js +1 -45
- package/playground/site/app/front/build/root.js +1 -45
- package/playground/site/app/front/build/user.js +1 -45
- package/playground/site/app/front/src/admin/notNodeModule/index.js +25 -0
- package/playground/site/app/front/src/client/notNodeModule/index.js +25 -0
- package/playground/site/app/front/src/common/index.js +0 -15
- package/playground/site/app/front/src/guest/notNodeModule/index.js +25 -0
- package/playground/site/app/front/src/root/notNodeModule/index.js +25 -0
- package/playground/site/app/front/src/user/notNodeModule/index.js +25 -0
- package/playground/site/app/server/config/common.json +83 -117
- package/playground/site/app/server/config/development.json +32 -31
- package/playground/site/app/server/modules/notNodeModule/index.js +8 -0
- package/playground/site/app/server/modules/notNodeModule/src/const.js +1 -0
- package/playground/site/app/server/modules/notNodeModule/src/controllers/admin/index.js +29 -0
- package/playground/site/app/server/modules/notNodeModule/src/controllers/admin/ncNewModel.js +11 -0
- package/playground/site/app/server/modules/notNodeModule/src/controllers/admin/ncTester.js +11 -0
- package/playground/site/app/server/modules/notNodeModule/src/controllers/client/index.js +29 -0
- package/playground/site/app/server/modules/notNodeModule/src/controllers/client/ncNewModel.js +11 -0
- package/playground/site/app/server/modules/notNodeModule/src/controllers/client/ncTester.js +11 -0
- package/playground/site/app/server/modules/notNodeModule/src/controllers/common/ncNewModelCommon.js +103 -0
- package/playground/site/app/server/modules/notNodeModule/src/controllers/common/validators.js +44 -0
- package/playground/site/app/server/modules/notNodeModule/src/controllers/common/ws.client.js +25 -0
- package/playground/site/app/server/modules/notNodeModule/src/controllers/guest/index.js +29 -0
- package/playground/site/app/server/modules/notNodeModule/src/controllers/guest/ncNewModel.js +11 -0
- package/playground/site/app/server/modules/notNodeModule/src/controllers/guest/ncTester.js +11 -0
- package/playground/site/app/server/modules/notNodeModule/src/controllers/root/index.js +29 -0
- package/playground/site/app/server/modules/notNodeModule/src/controllers/root/ncNewModel.js +11 -0
- package/playground/site/app/server/modules/notNodeModule/src/controllers/root/ncTester.js +11 -0
- package/playground/site/app/server/modules/notNodeModule/src/controllers/user/index.js +29 -0
- package/playground/site/app/server/modules/notNodeModule/src/controllers/user/ncNewModel.js +11 -0
- package/playground/site/app/server/modules/notNodeModule/src/controllers/user/ncTester.js +11 -0
- package/playground/site/app/server/modules/notNodeModule/src/forms/_newModel_data.js +35 -0
- package/playground/site/app/server/modules/notNodeModule/src/forms/_tester_data.js +36 -0
- package/playground/site/app/server/modules/notNodeModule/src/forms/newModel.create.js +49 -0
- package/playground/site/app/server/modules/notNodeModule/src/forms/newModel.delete.js +8 -0
- package/playground/site/app/server/modules/notNodeModule/src/forms/newModel.get.js +8 -0
- package/playground/site/app/server/modules/notNodeModule/src/forms/newModel.getRaw.js +8 -0
- package/playground/site/app/server/modules/notNodeModule/src/forms/newModel.listAll.js +8 -0
- package/playground/site/app/server/modules/notNodeModule/src/forms/newModel.listAndCount.js +8 -0
- package/playground/site/app/server/modules/notNodeModule/src/forms/newModel.update.js +40 -0
- package/playground/site/app/server/modules/notNodeModule/src/forms/tester.create.js +52 -0
- package/playground/site/app/server/modules/notNodeModule/src/forms/tester.delete.js +8 -0
- package/playground/site/app/server/modules/notNodeModule/src/forms/tester.get.js +8 -0
- package/playground/site/app/server/modules/notNodeModule/src/forms/tester.getRaw.js +8 -0
- package/playground/site/app/server/modules/notNodeModule/src/forms/tester.listAll.js +8 -0
- package/playground/site/app/server/modules/notNodeModule/src/forms/tester.listAndCount.js +8 -0
- package/playground/site/app/server/modules/notNodeModule/src/forms/tester.update.js +41 -0
- package/playground/site/app/server/modules/notNodeModule/src/logics/newModel.js +229 -0
- package/playground/site/app/server/modules/notNodeModule/src/logics/tester.js +229 -0
- package/playground/site/app/server/modules/notNodeModule/src/models/newModel.js +64 -0
- package/playground/site/app/server/modules/notNodeModule/src/models/tester.js +66 -0
- package/playground/site/app/server/modules/notNodeModule/src/routes/newModel.js +124 -0
- package/playground/site/app/server/modules/notNodeModule/src/routes/newModel.manifest.js +213 -0
- package/playground/site/app/server/modules/notNodeModule/src/routes/newModel.ws.js +29 -0
- package/playground/site/app/server/modules/notNodeModule/src/routes/tester.js +92 -0
- package/playground/site/app/server/modules/notNodeModule/src/routes/tester.manifest.js +215 -0
- package/playground/site/app/server/modules/notNodeModule/src/routes/tester.ws.js +29 -0
- package/playground/site/app/server/routes/site.js +71 -59
- package/src/cli/actions/entity.mjs +33 -0
- package/src/cli/actions/env.mjs +1 -0
- package/src/cli/actions/index.mjs +23 -0
- package/src/cli/actions/module.front.mjs +35 -0
- package/src/cli/actions/module.server.mjs +33 -0
- package/src/cli/actions/nginx.mjs +1 -0
- package/src/cli/actions/pm2.mjs +1 -0
- package/src/cli/actions/project.mjs +146 -0
- package/src/cli/lib/args.mjs +72 -0
- package/src/cli/lib/entity.mjs +46 -0
- package/src/cli/lib/fs.mjs +176 -0
- package/src/cli/lib/log.mjs +25 -0
- package/src/cli/lib/messages.mjs +29 -0
- package/src/cli/lib/module.front.mjs +57 -0
- package/src/cli/lib/module.server.mjs +128 -0
- package/src/cli/lib/opts.mjs +33 -0
- package/src/cli/lib/project.mjs +16 -0
- package/src/cli/lib/structures.mjs +37 -0
- package/src/cli/readers/roles.mjs +2 -2
- package/src/cli/renderers/controllersIndex.mjs +1 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const { MODULE_NAME } = require("../const");
|
|
2
|
+
const Form = require("not-node").Form;
|
|
3
|
+
const getIP = require("not-node").Auth.getIP;
|
|
4
|
+
|
|
5
|
+
const FIELDS = [
|
|
6
|
+
["targetId", { required: true }, "not-node//objectId"],
|
|
7
|
+
["activeUser", "not-node//requiredObject"],
|
|
8
|
+
["data", `${ModuleName}//_${ModelName}_data`], //sub forms validators should start with underscore
|
|
9
|
+
["ip", "not-node//ip"],
|
|
10
|
+
];
|
|
11
|
+
const FORM_NAME = `${ModuleName}:NewModelUpdateForm`;
|
|
12
|
+
|
|
13
|
+
module.exports = class NewModelUpdateForm extends Form {
|
|
14
|
+
constructor({ app }) {
|
|
15
|
+
super({ FIELDS, FORM_NAME, app });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
extract(req) {
|
|
19
|
+
const instructions = {
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
legend: "extractFromBody",
|
|
23
|
+
title: "extractFromBody",
|
|
24
|
+
|
|
25
|
+
owner: "fromBody",
|
|
26
|
+
ownerModel: "fromBody",
|
|
27
|
+
};
|
|
28
|
+
const data = this.extractByInstructions(req, instructions);
|
|
29
|
+
if (!req.user.isRoot() && !req.user.isAdmin()) {
|
|
30
|
+
data.owner = req.user._id;
|
|
31
|
+
data.ownerModel = "User";
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
targetId: req.params._id.toString(),
|
|
35
|
+
activeUser: req.user,
|
|
36
|
+
data,
|
|
37
|
+
ip: getIP(req),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const getIP = require("not-node").Auth.getIP;
|
|
2
|
+
const { MODULE_NAME } = require("../const");
|
|
3
|
+
//DB related validation tools
|
|
4
|
+
const Form = require("not-node").Form;
|
|
5
|
+
//form
|
|
6
|
+
const FIELDS = [
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
"title",
|
|
10
|
+
|
|
11
|
+
"age",
|
|
12
|
+
|
|
13
|
+
"qualification",
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
const FORM_NAME = `${MODULE_NAME}:TesterCreateForm`;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
**/
|
|
23
|
+
module.exports = class TesterCreateForm extends Form {
|
|
24
|
+
constructor({ app }) {
|
|
25
|
+
super({ FIELDS, FORM_NAME, app });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Extracts data
|
|
30
|
+
* @param {ExpressRequest} req expressjs request object
|
|
31
|
+
* @return {Object} forma data
|
|
32
|
+
**/
|
|
33
|
+
extract(req) {
|
|
34
|
+
const ip = getIP(req);
|
|
35
|
+
const instructions = {
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
title: "extractFromBody",
|
|
39
|
+
age: "extractFromBody",
|
|
40
|
+
qualification: "extractFromBody",
|
|
41
|
+
|
|
42
|
+
owner: "activeUserId",
|
|
43
|
+
ownerModel: "activeUserModelName",
|
|
44
|
+
};
|
|
45
|
+
const data = this.extractByInstructions(req, instructions);
|
|
46
|
+
return {
|
|
47
|
+
activeUser: req.user,
|
|
48
|
+
ip,
|
|
49
|
+
data,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const { MODULE_NAME } = require("../const");
|
|
2
|
+
const Form = require("not-node").Form;
|
|
3
|
+
const getIP = require("not-node").Auth.getIP;
|
|
4
|
+
|
|
5
|
+
const FIELDS = [
|
|
6
|
+
["targetId", { required: true }, "not-node//objectId"],
|
|
7
|
+
["activeUser", "not-node//requiredObject"],
|
|
8
|
+
["data", `${ModuleName}//_${ModelName}_data`], //sub forms validators should start with underscore
|
|
9
|
+
["ip", "not-node//ip"],
|
|
10
|
+
];
|
|
11
|
+
const FORM_NAME = `${ModuleName}:TesterUpdateForm`;
|
|
12
|
+
|
|
13
|
+
module.exports = class TesterUpdateForm extends Form {
|
|
14
|
+
constructor({ app }) {
|
|
15
|
+
super({ FIELDS, FORM_NAME, app });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
extract(req) {
|
|
19
|
+
const instructions = {
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
title: "extractFromBody",
|
|
23
|
+
age: "extractFromBody",
|
|
24
|
+
qualification: "extractFromBody",
|
|
25
|
+
|
|
26
|
+
owner: "fromBody",
|
|
27
|
+
ownerModel: "fromBody",
|
|
28
|
+
};
|
|
29
|
+
const data = this.extractByInstructions(req, instructions);
|
|
30
|
+
if (!req.user.isRoot() && !req.user.isAdmin()) {
|
|
31
|
+
data.owner = req.user._id;
|
|
32
|
+
data.ownerModel = "User";
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
targetId: req.params._id.toString(),
|
|
36
|
+
activeUser: req.user,
|
|
37
|
+
data,
|
|
38
|
+
ip: getIP(req),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
};
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
const MODEL_NAME = "NewModel";
|
|
2
|
+
|
|
3
|
+
const { MODULE_NAME } = require("../const.js");
|
|
4
|
+
const notNode = require("not-node");
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
Log,
|
|
8
|
+
LogAction,
|
|
9
|
+
say,
|
|
10
|
+
phrase,
|
|
11
|
+
config,
|
|
12
|
+
getModel,
|
|
13
|
+
getModelSchema,
|
|
14
|
+
getLogic,
|
|
15
|
+
getModelUser,
|
|
16
|
+
} = notNode.Bootstrap.notBootstrapLogic({
|
|
17
|
+
target: module,
|
|
18
|
+
MODEL_NAME,
|
|
19
|
+
MODULE_NAME,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const populateBuilders = {};
|
|
23
|
+
|
|
24
|
+
const NewModelGenericLogic = notNode.Generic.GenericLogic({
|
|
25
|
+
MODEL_NAME,
|
|
26
|
+
MODULE_NAME,
|
|
27
|
+
Log,
|
|
28
|
+
LogAction,
|
|
29
|
+
say,
|
|
30
|
+
phrase,
|
|
31
|
+
config,
|
|
32
|
+
getModel,
|
|
33
|
+
getModelSchema,
|
|
34
|
+
getLogic,
|
|
35
|
+
getModelUser,
|
|
36
|
+
populateBuilders,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
module.exports.thisLogicName = MODEL_NAME;
|
|
40
|
+
|
|
41
|
+
class NewModelLogic extends NewModelGenericLogic {
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
static async create({ targetId, activeUser, ip, root, shouldOwn, data }) {
|
|
45
|
+
const action = "create";
|
|
46
|
+
Log.debug(
|
|
47
|
+
`${MODULE_NAME}//Logic//${MODEL_NAME}//${action}`,
|
|
48
|
+
targetId,
|
|
49
|
+
ip,
|
|
50
|
+
root
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const results = await getModel().create(
|
|
54
|
+
targetId,
|
|
55
|
+
activeUser._id,
|
|
56
|
+
data
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
LogAction({
|
|
60
|
+
action,
|
|
61
|
+
by: activeUser._id,
|
|
62
|
+
role: activeUser.role,
|
|
63
|
+
ip,
|
|
64
|
+
root,
|
|
65
|
+
shouldOwn,
|
|
66
|
+
});
|
|
67
|
+
return results;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static async delete({ targetId, activeUser, ip, root, shouldOwn, data }) {
|
|
71
|
+
const action = "delete";
|
|
72
|
+
Log.debug(
|
|
73
|
+
`${MODULE_NAME}//Logic//${MODEL_NAME}//${action}`,
|
|
74
|
+
targetId,
|
|
75
|
+
ip,
|
|
76
|
+
root
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const results = await getModel().delete(
|
|
80
|
+
targetId,
|
|
81
|
+
activeUser._id,
|
|
82
|
+
data
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
LogAction({
|
|
86
|
+
action,
|
|
87
|
+
by: activeUser._id,
|
|
88
|
+
role: activeUser.role,
|
|
89
|
+
ip,
|
|
90
|
+
root,
|
|
91
|
+
shouldOwn,
|
|
92
|
+
});
|
|
93
|
+
return results;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static async get({ targetId, activeUser, ip, root, shouldOwn, data }) {
|
|
97
|
+
const action = "get";
|
|
98
|
+
Log.debug(
|
|
99
|
+
`${MODULE_NAME}//Logic//${MODEL_NAME}//${action}`,
|
|
100
|
+
targetId,
|
|
101
|
+
ip,
|
|
102
|
+
root
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const results = await getModel().get(
|
|
106
|
+
targetId,
|
|
107
|
+
activeUser._id,
|
|
108
|
+
data
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
LogAction({
|
|
112
|
+
action,
|
|
113
|
+
by: activeUser._id,
|
|
114
|
+
role: activeUser.role,
|
|
115
|
+
ip,
|
|
116
|
+
root,
|
|
117
|
+
shouldOwn,
|
|
118
|
+
});
|
|
119
|
+
return results;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static async getRaw({ targetId, activeUser, ip, root, shouldOwn, data }) {
|
|
123
|
+
const action = "getRaw";
|
|
124
|
+
Log.debug(
|
|
125
|
+
`${MODULE_NAME}//Logic//${MODEL_NAME}//${action}`,
|
|
126
|
+
targetId,
|
|
127
|
+
ip,
|
|
128
|
+
root
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
const results = await getModel().getRaw(
|
|
132
|
+
targetId,
|
|
133
|
+
activeUser._id,
|
|
134
|
+
data
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
LogAction({
|
|
138
|
+
action,
|
|
139
|
+
by: activeUser._id,
|
|
140
|
+
role: activeUser.role,
|
|
141
|
+
ip,
|
|
142
|
+
root,
|
|
143
|
+
shouldOwn,
|
|
144
|
+
});
|
|
145
|
+
return results;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
static async listAll({ targetId, activeUser, ip, root, shouldOwn, data }) {
|
|
149
|
+
const action = "listAll";
|
|
150
|
+
Log.debug(
|
|
151
|
+
`${MODULE_NAME}//Logic//${MODEL_NAME}//${action}`,
|
|
152
|
+
targetId,
|
|
153
|
+
ip,
|
|
154
|
+
root
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
const results = await getModel().listAll(
|
|
158
|
+
targetId,
|
|
159
|
+
activeUser._id,
|
|
160
|
+
data
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
LogAction({
|
|
164
|
+
action,
|
|
165
|
+
by: activeUser._id,
|
|
166
|
+
role: activeUser.role,
|
|
167
|
+
ip,
|
|
168
|
+
root,
|
|
169
|
+
shouldOwn,
|
|
170
|
+
});
|
|
171
|
+
return results;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
static async listAndCount({ targetId, activeUser, ip, root, shouldOwn, data }) {
|
|
175
|
+
const action = "listAndCount";
|
|
176
|
+
Log.debug(
|
|
177
|
+
`${MODULE_NAME}//Logic//${MODEL_NAME}//${action}`,
|
|
178
|
+
targetId,
|
|
179
|
+
ip,
|
|
180
|
+
root
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
const results = await getModel().listAndCount(
|
|
184
|
+
targetId,
|
|
185
|
+
activeUser._id,
|
|
186
|
+
data
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
LogAction({
|
|
190
|
+
action,
|
|
191
|
+
by: activeUser._id,
|
|
192
|
+
role: activeUser.role,
|
|
193
|
+
ip,
|
|
194
|
+
root,
|
|
195
|
+
shouldOwn,
|
|
196
|
+
});
|
|
197
|
+
return results;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
static async update({ targetId, activeUser, ip, root, shouldOwn, data }) {
|
|
201
|
+
const action = "update";
|
|
202
|
+
Log.debug(
|
|
203
|
+
`${MODULE_NAME}//Logic//${MODEL_NAME}//${action}`,
|
|
204
|
+
targetId,
|
|
205
|
+
ip,
|
|
206
|
+
root
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
const results = await getModel().update(
|
|
210
|
+
targetId,
|
|
211
|
+
activeUser._id,
|
|
212
|
+
data
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
LogAction({
|
|
216
|
+
action,
|
|
217
|
+
by: activeUser._id,
|
|
218
|
+
role: activeUser.role,
|
|
219
|
+
ip,
|
|
220
|
+
root,
|
|
221
|
+
shouldOwn,
|
|
222
|
+
});
|
|
223
|
+
return results;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
module.exports[MODEL_NAME] = NewModelLogic;
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
const MODEL_NAME = "Tester";
|
|
2
|
+
|
|
3
|
+
const { MODULE_NAME } = require("../const.js");
|
|
4
|
+
const notNode = require("not-node");
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
Log,
|
|
8
|
+
LogAction,
|
|
9
|
+
say,
|
|
10
|
+
phrase,
|
|
11
|
+
config,
|
|
12
|
+
getModel,
|
|
13
|
+
getModelSchema,
|
|
14
|
+
getLogic,
|
|
15
|
+
getModelUser,
|
|
16
|
+
} = notNode.Bootstrap.notBootstrapLogic({
|
|
17
|
+
target: module,
|
|
18
|
+
MODEL_NAME,
|
|
19
|
+
MODULE_NAME,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const populateBuilders = {};
|
|
23
|
+
|
|
24
|
+
const TesterGenericLogic = notNode.Generic.GenericLogic({
|
|
25
|
+
MODEL_NAME,
|
|
26
|
+
MODULE_NAME,
|
|
27
|
+
Log,
|
|
28
|
+
LogAction,
|
|
29
|
+
say,
|
|
30
|
+
phrase,
|
|
31
|
+
config,
|
|
32
|
+
getModel,
|
|
33
|
+
getModelSchema,
|
|
34
|
+
getLogic,
|
|
35
|
+
getModelUser,
|
|
36
|
+
populateBuilders,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
module.exports.thisLogicName = MODEL_NAME;
|
|
40
|
+
|
|
41
|
+
class TesterLogic extends TesterGenericLogic {
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
static async create({ targetId, activeUser, ip, root, shouldOwn, data }) {
|
|
45
|
+
const action = "create";
|
|
46
|
+
Log.debug(
|
|
47
|
+
`${MODULE_NAME}//Logic//${MODEL_NAME}//${action}`,
|
|
48
|
+
targetId,
|
|
49
|
+
ip,
|
|
50
|
+
root
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const results = await getModel().create(
|
|
54
|
+
targetId,
|
|
55
|
+
activeUser._id,
|
|
56
|
+
data
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
LogAction({
|
|
60
|
+
action,
|
|
61
|
+
by: activeUser._id,
|
|
62
|
+
role: activeUser.role,
|
|
63
|
+
ip,
|
|
64
|
+
root,
|
|
65
|
+
shouldOwn,
|
|
66
|
+
});
|
|
67
|
+
return results;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static async delete({ targetId, activeUser, ip, root, shouldOwn, data }) {
|
|
71
|
+
const action = "delete";
|
|
72
|
+
Log.debug(
|
|
73
|
+
`${MODULE_NAME}//Logic//${MODEL_NAME}//${action}`,
|
|
74
|
+
targetId,
|
|
75
|
+
ip,
|
|
76
|
+
root
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const results = await getModel().delete(
|
|
80
|
+
targetId,
|
|
81
|
+
activeUser._id,
|
|
82
|
+
data
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
LogAction({
|
|
86
|
+
action,
|
|
87
|
+
by: activeUser._id,
|
|
88
|
+
role: activeUser.role,
|
|
89
|
+
ip,
|
|
90
|
+
root,
|
|
91
|
+
shouldOwn,
|
|
92
|
+
});
|
|
93
|
+
return results;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static async get({ targetId, activeUser, ip, root, shouldOwn, data }) {
|
|
97
|
+
const action = "get";
|
|
98
|
+
Log.debug(
|
|
99
|
+
`${MODULE_NAME}//Logic//${MODEL_NAME}//${action}`,
|
|
100
|
+
targetId,
|
|
101
|
+
ip,
|
|
102
|
+
root
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const results = await getModel().get(
|
|
106
|
+
targetId,
|
|
107
|
+
activeUser._id,
|
|
108
|
+
data
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
LogAction({
|
|
112
|
+
action,
|
|
113
|
+
by: activeUser._id,
|
|
114
|
+
role: activeUser.role,
|
|
115
|
+
ip,
|
|
116
|
+
root,
|
|
117
|
+
shouldOwn,
|
|
118
|
+
});
|
|
119
|
+
return results;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static async getRaw({ targetId, activeUser, ip, root, shouldOwn, data }) {
|
|
123
|
+
const action = "getRaw";
|
|
124
|
+
Log.debug(
|
|
125
|
+
`${MODULE_NAME}//Logic//${MODEL_NAME}//${action}`,
|
|
126
|
+
targetId,
|
|
127
|
+
ip,
|
|
128
|
+
root
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
const results = await getModel().getRaw(
|
|
132
|
+
targetId,
|
|
133
|
+
activeUser._id,
|
|
134
|
+
data
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
LogAction({
|
|
138
|
+
action,
|
|
139
|
+
by: activeUser._id,
|
|
140
|
+
role: activeUser.role,
|
|
141
|
+
ip,
|
|
142
|
+
root,
|
|
143
|
+
shouldOwn,
|
|
144
|
+
});
|
|
145
|
+
return results;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
static async listAll({ targetId, activeUser, ip, root, shouldOwn, data }) {
|
|
149
|
+
const action = "listAll";
|
|
150
|
+
Log.debug(
|
|
151
|
+
`${MODULE_NAME}//Logic//${MODEL_NAME}//${action}`,
|
|
152
|
+
targetId,
|
|
153
|
+
ip,
|
|
154
|
+
root
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
const results = await getModel().listAll(
|
|
158
|
+
targetId,
|
|
159
|
+
activeUser._id,
|
|
160
|
+
data
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
LogAction({
|
|
164
|
+
action,
|
|
165
|
+
by: activeUser._id,
|
|
166
|
+
role: activeUser.role,
|
|
167
|
+
ip,
|
|
168
|
+
root,
|
|
169
|
+
shouldOwn,
|
|
170
|
+
});
|
|
171
|
+
return results;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
static async listAndCount({ targetId, activeUser, ip, root, shouldOwn, data }) {
|
|
175
|
+
const action = "listAndCount";
|
|
176
|
+
Log.debug(
|
|
177
|
+
`${MODULE_NAME}//Logic//${MODEL_NAME}//${action}`,
|
|
178
|
+
targetId,
|
|
179
|
+
ip,
|
|
180
|
+
root
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
const results = await getModel().listAndCount(
|
|
184
|
+
targetId,
|
|
185
|
+
activeUser._id,
|
|
186
|
+
data
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
LogAction({
|
|
190
|
+
action,
|
|
191
|
+
by: activeUser._id,
|
|
192
|
+
role: activeUser.role,
|
|
193
|
+
ip,
|
|
194
|
+
root,
|
|
195
|
+
shouldOwn,
|
|
196
|
+
});
|
|
197
|
+
return results;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
static async update({ targetId, activeUser, ip, root, shouldOwn, data }) {
|
|
201
|
+
const action = "update";
|
|
202
|
+
Log.debug(
|
|
203
|
+
`${MODULE_NAME}//Logic//${MODEL_NAME}//${action}`,
|
|
204
|
+
targetId,
|
|
205
|
+
ip,
|
|
206
|
+
root
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
const results = await getModel().update(
|
|
210
|
+
targetId,
|
|
211
|
+
activeUser._id,
|
|
212
|
+
data
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
LogAction({
|
|
216
|
+
action,
|
|
217
|
+
by: activeUser._id,
|
|
218
|
+
role: activeUser.role,
|
|
219
|
+
ip,
|
|
220
|
+
root,
|
|
221
|
+
shouldOwn,
|
|
222
|
+
});
|
|
223
|
+
return results;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
module.exports[MODEL_NAME] = TesterLogic;
|