not-node 6.3.66 → 6.3.69
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
package/src/common.js
CHANGED
|
@@ -248,6 +248,20 @@ module.exports.tryFileAsync = async (filePath) => {
|
|
|
248
248
|
}
|
|
249
249
|
};
|
|
250
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Asynchronously check dir existence and if it's really a file
|
|
253
|
+
* @param {string} dirPath full path to file
|
|
254
|
+
* @return {Promise<boolean>} true if path exists and it's a file
|
|
255
|
+
**/
|
|
256
|
+
module.exports.tryDirAsync = async (dirPath) => {
|
|
257
|
+
try {
|
|
258
|
+
const stat = await fs.promises.lstat(dirPath);
|
|
259
|
+
return stat && stat.isDirectory();
|
|
260
|
+
} catch (e) {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
|
|
251
265
|
/**
|
|
252
266
|
* Trying to parse input to JSON or returns def
|
|
253
267
|
* @param {string} input string to be parsed
|
package/src/generic/logic.js
CHANGED
|
@@ -349,7 +349,12 @@ module.exports = ({
|
|
|
349
349
|
if (!itm) {
|
|
350
350
|
throw new DBExceptionDocumentIsNotFound();
|
|
351
351
|
}
|
|
352
|
-
if (
|
|
352
|
+
if (
|
|
353
|
+
shouldOwn &&
|
|
354
|
+
identity &&
|
|
355
|
+
identity?.uid &&
|
|
356
|
+
!isOwner(itm, identity.uid)
|
|
357
|
+
) {
|
|
353
358
|
throw new DBExceptionDocumentIsNotOwnerByActiveUser({
|
|
354
359
|
params: {
|
|
355
360
|
targetId,
|
|
@@ -447,12 +452,12 @@ module.exports = ({
|
|
|
447
452
|
shouldOwn = false,
|
|
448
453
|
}) {
|
|
449
454
|
logDebugAction(action, identity);
|
|
450
|
-
|
|
455
|
+
let { skip, size, sorter, filter, search } = query;
|
|
451
456
|
let populate = await getPopulate(action, {
|
|
452
457
|
identity,
|
|
453
458
|
});
|
|
454
459
|
if (shouldOwn) {
|
|
455
|
-
notFilter.filter.modifyRules(filter, {
|
|
460
|
+
filter = notFilter.filter.modifyRules(filter, {
|
|
456
461
|
[ownerFieldName]: identity?.uid,
|
|
457
462
|
});
|
|
458
463
|
}
|
|
@@ -489,12 +494,12 @@ module.exports = ({
|
|
|
489
494
|
|
|
490
495
|
static async _list({ query, identity, action, shouldOwn = false }) {
|
|
491
496
|
logDebugAction(action, identity);
|
|
492
|
-
|
|
497
|
+
let { skip, size, sorter, filter } = query;
|
|
493
498
|
let populate = await getPopulate(action, {
|
|
494
499
|
identity,
|
|
495
500
|
});
|
|
496
501
|
if (shouldOwn) {
|
|
497
|
-
notFilter.filter.modifyRules(filter, {
|
|
502
|
+
filter = notFilter.filter.modifyRules(filter, {
|
|
498
503
|
[ownerFieldName]: identity?.uid,
|
|
499
504
|
});
|
|
500
505
|
}
|
|
@@ -529,14 +534,14 @@ module.exports = ({
|
|
|
529
534
|
|
|
530
535
|
static async _count({ query, action, identity, shouldOwn = false }) {
|
|
531
536
|
logDebugAction(action, identity);
|
|
532
|
-
|
|
537
|
+
let { filter, search } = query;
|
|
533
538
|
if (shouldOwn) {
|
|
534
|
-
notFilter.filter.modifyRules(filter, {
|
|
539
|
+
filter = notFilter.filter.modifyRules(filter, {
|
|
535
540
|
[ownerFieldName]: identity?.uid,
|
|
536
541
|
});
|
|
537
542
|
}
|
|
538
543
|
if (search) {
|
|
539
|
-
notFilter.filter.modifyRules(search, filter);
|
|
544
|
+
filter = notFilter.filter.modifyRules(search, filter);
|
|
540
545
|
}
|
|
541
546
|
const result = await getModel().countWithFilter(search || filter);
|
|
542
547
|
LogAction(action, identity, { shouldOwn });
|
package/src/init/lib/env.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const log = require("not-log")(module, "not-node//init//env");
|
|
2
|
+
const { tryDirAsync } = require("../../common");
|
|
2
3
|
|
|
3
4
|
module.exports = class InitENV {
|
|
4
5
|
static getProxyPort(config) {
|
|
@@ -20,8 +21,21 @@ module.exports = class InitENV {
|
|
|
20
21
|
return name;
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
static async checkPaths(master, config) {
|
|
25
|
+
const paths = config.get("path");
|
|
26
|
+
if (paths) {
|
|
27
|
+
for (let pathName of Object.keys(paths)) {
|
|
28
|
+
if (await tryDirAsync(paths[pathName])) {
|
|
29
|
+
log?.error(
|
|
30
|
+
`config path (${pathName}) not exists: ${paths[pathName]}`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
23
37
|
async run({ config, options, master, emit }) {
|
|
24
|
-
log
|
|
38
|
+
log?.info("Setting up server environment variables...");
|
|
25
39
|
await emit("env.pre", { config, options, master });
|
|
26
40
|
config.set(
|
|
27
41
|
"staticPath",
|
|
@@ -41,9 +55,10 @@ module.exports = class InitENV {
|
|
|
41
55
|
config.set("npmPath", options.pathToNPM);
|
|
42
56
|
config.set("fullServerName", InitENV.getFullServerName(config));
|
|
43
57
|
if (config.get("path:ws")) {
|
|
44
|
-
log
|
|
58
|
+
log?.log("wsPath", master.getAbsolutePath(config.get("path:ws")));
|
|
45
59
|
config.set("wsPath", master.getAbsolutePath(config.get("path:ws")));
|
|
46
60
|
}
|
|
61
|
+
await InitENV.checkPaths(master, config);
|
|
47
62
|
await emit("env.post", { config, options, master });
|
|
48
63
|
}
|
|
49
64
|
};
|
|
@@ -18,13 +18,13 @@ module.exports = class OwnageBeforeAction {
|
|
|
18
18
|
if (identity.uid) {
|
|
19
19
|
//if searching, counting, listing and so on
|
|
20
20
|
//adding condition of ownership by this excat user
|
|
21
|
-
|
|
21
|
+
let { filter, search } = query;
|
|
22
22
|
if (filter) {
|
|
23
|
-
notFilter.filter.modifyRules(filter, {
|
|
23
|
+
filter = notFilter.filter.modifyRules(filter, {
|
|
24
24
|
[OwnageBeforeAction.ownerFieldName]: identity?.uid,
|
|
25
25
|
});
|
|
26
26
|
if (search) {
|
|
27
|
-
notFilter.filter.modifyRules(search, filter);
|
|
27
|
+
search = notFilter.filter.modifyRules(search, filter);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
args.defaultQueryById = {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { MODULE_NAME } from "../../const.js";
|
|
2
2
|
import Validators from "../common/validators.js";
|
|
3
3
|
import { Frame } from "not-bulma";
|
|
4
|
+
import CRUDActionList from "not-bulma/src/frame/crud/actions/list";
|
|
5
|
+
|
|
4
6
|
const { notCRUD } = Frame;
|
|
5
7
|
|
|
6
8
|
const MODEL_NAME = "<%- ModelName %>";
|
|
@@ -53,27 +55,7 @@ class nc<%- ModelName %>Common extends notCRUD {
|
|
|
53
55
|
path: ":_id",
|
|
54
56
|
title: "Действия",
|
|
55
57
|
type: "button",
|
|
56
|
-
preprocessor: (value) =>
|
|
57
|
-
return [
|
|
58
|
-
{
|
|
59
|
-
action: ()=>this.goDetails(value),
|
|
60
|
-
title: "Подробнее",
|
|
61
|
-
size: "small",
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
action: ()=>this.goUpdate(value),
|
|
65
|
-
title: "Изменить",
|
|
66
|
-
size: "small",
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
action: ()=>this.goDelete(value),
|
|
70
|
-
color: "danger",
|
|
71
|
-
title: "Удалить",
|
|
72
|
-
size: "small",
|
|
73
|
-
style: "outlined",
|
|
74
|
-
},
|
|
75
|
-
];
|
|
76
|
-
},
|
|
58
|
+
preprocessor: (value) => CRUDActionList.createActionsButtons(this, value),
|
|
77
59
|
},
|
|
78
60
|
],
|
|
79
61
|
});
|
|
@@ -82,8 +64,8 @@ class nc<%- ModelName %>Common extends notCRUD {
|
|
|
82
64
|
return this;
|
|
83
65
|
}
|
|
84
66
|
|
|
85
|
-
createDefault() {
|
|
86
|
-
let newRecord = this.getModel({
|
|
67
|
+
createDefault() {
|
|
68
|
+
let newRecord = this.getModel({
|
|
87
69
|
<% for (let fieldName of fields){ %><%- fieldName %>: undefined,
|
|
88
70
|
<% } %>
|
|
89
71
|
});
|