not-node 6.0.7 → 6.1.0
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-builder.js +418 -293
- package/bin/not-cli.mjs +369 -0
- package/index.js +6 -0
- package/package.json +133 -128
- package/playground/.babelrc +11 -0
- package/playground/.eslintignore +4 -0
- package/playground/.eslintrc.json +23 -0
- package/playground/app/front/index.!.js +64 -0
- package/playground/app/front/rollup.!.js +70 -0
- package/playground/app/front/src/admin/main/index.js +45 -0
- package/playground/app/front/src/client/main/index.js +45 -0
- package/playground/app/front/src/common/index.js +39 -0
- package/playground/app/front/src/common/ncInit.js +18 -0
- package/playground/app/front/src/common/ws.client.main.js +35 -0
- package/playground/app/front/src/guest/main/index.js +34 -0
- package/playground/app/front/src/root/main/index.js +45 -0
- package/playground/app/front/src/user/main/index.js +45 -0
- package/playground/app/server/app.js +22 -0
- package/playground/app/server/config/common.json +53 -0
- package/playground/app/server/config/development.json +34 -0
- package/playground/app/server/config/production.json +34 -0
- package/playground/app/server/config/stage.json +34 -0
- package/playground/app/server/index.js +20 -0
- package/playground/app/server/routes/index.js +36 -0
- package/playground/app/server/routes/site.js +71 -0
- package/playground/app/server/views/admin/foot.pug +1 -0
- package/playground/app/server/views/admin/head.pug +7 -0
- package/playground/app/server/views/admin/menu.pug +2 -0
- package/playground/app/server/views/admin.pug +19 -0
- package/playground/app/server/views/dashboard.pug +20 -0
- package/playground/app/server/views/index.pug +15 -0
- package/playground/app/server/views/parts/header.android.pug +7 -0
- package/playground/app/server/views/parts/header.ios.pug +5 -0
- package/playground/app/server/views/parts/header.pug +18 -0
- package/playground/app/server/views/parts/menu.pug +1 -0
- package/playground/app/server/views/parts/overview.pug +2 -0
- package/playground/app/server/ws/auth.js +41 -0
- package/playground/app/server/ws/index.js +84 -0
- package/playground/bin/build.sh +8 -0
- package/playground/package.json +66 -0
- package/playground/project.manifest.json +34 -0
- package/src/app.js +3 -3
- package/src/cli/const.mjs +71 -0
- package/src/cli/readers/AppDescription.mjs +14 -0
- package/src/cli/readers/AppName.mjs +14 -0
- package/src/cli/readers/ModelName.mjs +14 -0
- package/src/cli/readers/ModuleName.mjs +14 -0
- package/src/cli/readers/actions.mjs +25 -0
- package/src/cli/readers/appName.mjs +14 -0
- package/src/cli/readers/cors.mjs +12 -0
- package/src/cli/readers/db/ioredis.mjs +3 -0
- package/src/cli/readers/db/mongoose.mjs +61 -0
- package/src/cli/readers/db/redis.mjs +3 -0
- package/src/cli/readers/db.mjs +30 -0
- package/src/cli/readers/entityData.mjs +44 -0
- package/src/cli/readers/entityLayers.mjs +21 -0
- package/src/cli/readers/fields.mjs +13 -0
- package/src/cli/readers/filter.mjs +34 -0
- package/src/cli/readers/hostname.mjs +23 -0
- package/src/cli/readers/index.mjs +86 -0
- package/src/cli/readers/init_root_user.mjs +55 -0
- package/src/cli/readers/isUserNeedCreateEntity.mjs +14 -0
- package/src/cli/readers/isUserNeedCreateServerModule.mjs +14 -0
- package/src/cli/readers/isUserNeedFrontModuleBootstrap.mjs +14 -0
- package/src/cli/readers/modelIncrement.mjs +32 -0
- package/src/cli/readers/modelIncrementFilter.mjs +49 -0
- package/src/cli/readers/modelOptions.mjs +61 -0
- package/src/cli/readers/modelValidators.mjs +14 -0
- package/src/cli/readers/modelVersioning.mjs +14 -0
- package/src/cli/readers/moduleLayers.mjs +25 -0
- package/src/cli/readers/modules.mjs +19 -0
- package/src/cli/readers/not_node_monitor.mjs +48 -0
- package/src/cli/readers/not_node_reporter.mjs +42 -0
- package/src/cli/readers/port.mjs +14 -0
- package/src/cli/readers/roles.mjs +25 -0
- package/src/cli/readers/rolesSecondary.mjs +14 -0
- package/src/cli/readers/secret.mjs +21 -0
- package/src/cli/readers/session.mjs +55 -0
- package/src/cli/readers/ssl.mjs +38 -0
- package/src/cli/readers/user.mjs +62 -0
- package/src/cli/readers/ws.mjs +35 -0
- package/src/cli/renderers/controllers.mjs +26 -0
- package/src/cli/renderers/controllersCommons.mjs +42 -0
- package/src/cli/renderers/controllersIndex.mjs +18 -0
- package/src/cli/renderers/fields.mjs +1 -0
- package/src/cli/renderers/forms.mjs +43 -0
- package/src/cli/renderers/frontModuleGuestMain.mjs +10 -0
- package/src/cli/renderers/frontModuleRoleMain.mjs +10 -0
- package/src/cli/renderers/index.mjs +29 -0
- package/src/cli/renderers/logics.mjs +17 -0
- package/src/cli/renderers/models.mjs +16 -0
- package/src/cli/renderers/routes.mjs +31 -0
- package/src/domain.js +8 -9
- package/src/headers.js +17 -0
- package/src/identity/identity.js +0 -1
- package/src/init/index.js +1 -0
- package/src/init/lib/app.js +5 -7
- package/src/init/lib/modules.js +2 -1
- package/src/init/lib/routes.js +1 -0
- package/src/manifest/module.js +6 -20
- package/src/metas.js +34 -0
- package/src/styler.js +38 -0
- package/tmpl/dirs/app.mjs +32 -0
- package/tmpl/dirs/front.mjs +12 -0
- package/tmpl/dirs/module.front.mjs +19 -0
- package/tmpl/dirs/module.server.controllers.common.mjs +7 -0
- package/tmpl/dirs/module.server.mjs +14 -0
- package/tmpl/dirs/server.mjs +127 -0
- package/tmpl/dirs/static.mjs +9 -0
- package/tmpl/files/app/.babelrc +11 -0
- package/tmpl/files/app/.eslintignore +4 -0
- package/tmpl/files/app/.eslintrc.json +23 -0
- package/tmpl/files/app/app.ejs +22 -0
- package/tmpl/files/app/build.sh +8 -0
- package/tmpl/files/app/config/common.ejs +131 -0
- package/tmpl/files/app/config/other.ejs +34 -0
- package/tmpl/files/app/deploy.pm2.ejs +23 -0
- package/tmpl/files/app/env.ejs +16 -0
- package/tmpl/files/app/front/build.env.ejs +7 -0
- package/tmpl/files/app/front/index.!.ejs +66 -0
- package/tmpl/files/app/front/rollup.!.ejs +70 -0
- package/tmpl/files/app/index.ejs +20 -0
- package/tmpl/files/app/package.ejs +66 -0
- package/tmpl/files/app/project.manifest.ejs +23 -0
- package/tmpl/files/app/routes/index.ejs +36 -0
- package/tmpl/files/app/routes/site.ejs +71 -0
- package/tmpl/files/app/views/admin/foot.ejs +1 -0
- package/tmpl/files/app/views/admin/head.ejs +7 -0
- package/tmpl/files/app/views/admin/menu.ejs +2 -0
- package/tmpl/files/app/views/admin.ejs +19 -0
- package/tmpl/files/app/views/dashboard.ejs +20 -0
- package/tmpl/files/app/views/index.ejs +15 -0
- package/tmpl/files/app/views/parts/header.android.ejs +7 -0
- package/tmpl/files/app/views/parts/header.ejs +18 -0
- package/tmpl/files/app/views/parts/header.ios.ejs +5 -0
- package/tmpl/files/app/views/parts/menu.ejs +1 -0
- package/tmpl/files/app/views/parts/overview.ejs +2 -0
- package/tmpl/files/app/ws/auth.ejs +41 -0
- package/tmpl/files/app/ws/index.ejs +84 -0
- package/tmpl/files/module.front/common/index.ejs +39 -0
- package/tmpl/files/module.front/common/ncInit.ejs +18 -0
- package/tmpl/files/module.front/common/ws.client.main.ejs +35 -0
- package/tmpl/files/module.front/role/guest.index.ejs +45 -0
- package/tmpl/files/module.front/role/index.ejs +34 -0
- package/tmpl/files/module.server/const.ejs +1 -0
- package/{scaffold/base.js → tmpl/files/module.server/extractor.ejs} +0 -0
- package/tmpl/files/module.server/index.ejs +8 -0
- package/tmpl/files/module.server/layers/controllers/common/crud.ejs +95 -0
- package/tmpl/files/module.server/layers/controllers/common/index.ejs +59 -0
- package/tmpl/files/module.server/layers/controllers/common/validators.ejs +44 -0
- package/tmpl/files/module.server/layers/controllers/common/ws.client.ejs +25 -0
- package/tmpl/files/module.server/layers/controllers/role/crud.ejs +11 -0
- package/tmpl/files/module.server/layers/controllers/role/index.ejs +29 -0
- package/tmpl/files/module.server/layers/fields.ejs +30 -0
- package/tmpl/files/module.server/layers/forms/_data.ejs +35 -0
- package/tmpl/files/module.server/layers/forms/create.ejs +47 -0
- package/tmpl/files/module.server/layers/forms/delete.ejs +8 -0
- package/tmpl/files/module.server/layers/forms/get.ejs +8 -0
- package/tmpl/files/module.server/layers/forms/getRaw.ejs +8 -0
- package/tmpl/files/module.server/layers/forms/listAll.ejs +8 -0
- package/tmpl/files/module.server/layers/forms/listAndCount.ejs +8 -0
- package/tmpl/files/module.server/layers/forms/update.ejs +40 -0
- package/tmpl/files/module.server/layers/forms/validator.ejs +32 -0
- package/tmpl/files/module.server/layers/forms.ejs +49 -0
- package/tmpl/files/module.server/layers/locales.ejs +3 -0
- package/tmpl/files/module.server/layers/logics.ejs +73 -0
- package/tmpl/files/module.server/layers/models.ejs +68 -0
- package/tmpl/files/module.server/layers/routes.ejs +50 -0
- package/tmpl/files/module.server/layers/routes.manifest.ejs +211 -0
- package/tmpl/files/module.server/layers/routes.ws.ejs +29 -0
- package/tmpl/files/module.server/validationEnv.ejs +5 -0
- package/tmpl/files/notComponent.ejs +57 -0
- package/tmpl/files/notService.ejs +39 -0
- package/scaffold/field.js +0 -0
- package/scaffold/form.js +0 -0
- package/scaffold/logic.js +0 -0
- package/scaffold/model.js +0 -0
- package/scaffold/module.js +0 -0
- package/scaffold/route.js +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const { MODULE_NAME } = require("../const");
|
|
2
|
+
//DB related validation tools
|
|
3
|
+
const Form = require("not-node").Form;
|
|
4
|
+
//not-node
|
|
5
|
+
const getIP = require("not-node").Auth.getIP;
|
|
6
|
+
//form
|
|
7
|
+
const FIELDS = [
|
|
8
|
+
["activeUser", "not-node//requiredObject"],
|
|
9
|
+
["data", `${MODULE_NAME}//_data`],
|
|
10
|
+
["ip", "not-node//ip"],
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
const FORM_NAME = `${MODULE_NAME}:CreateForm`;
|
|
14
|
+
const USER_MODEL_NAME = "User";
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
**/
|
|
18
|
+
module.exports = class CreateForm extends Form {
|
|
19
|
+
constructor({ app }) {
|
|
20
|
+
super({ FIELDS, FORM_NAME, app });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Extracts data
|
|
25
|
+
* @param {ExpressRequest} req expressjs request object
|
|
26
|
+
* @return {Object} forma data
|
|
27
|
+
**/
|
|
28
|
+
extract(req) {
|
|
29
|
+
const ip = getIP(req);
|
|
30
|
+
const instructions = {
|
|
31
|
+
title: "fromBody",
|
|
32
|
+
keys: "fromBody",
|
|
33
|
+
owner: "fromBody", //req.body.owner || req.user._id.toString(),
|
|
34
|
+
ownerModel: "fromBody", //req.body.ownerModel || USER_MODEL_NAME,
|
|
35
|
+
};
|
|
36
|
+
const data = this.extractByInstructions(req, instructions);
|
|
37
|
+
|
|
38
|
+
if (!req.user.isRoot() && !req.user.isAdmin()) {
|
|
39
|
+
data.owner = req.user._id.toString();
|
|
40
|
+
data.ownerModel = USER_MODEL_NAME;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
data,
|
|
45
|
+
activeUser: req.user,
|
|
46
|
+
ip,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
const MODEL_NAME = "<%- ModelName %>";
|
|
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 <%- ModelName %>GenericLogic = 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 <%- ModelName %>Logic extends <%- ModelName %>GenericLogic {
|
|
42
|
+
<% if(Object.keys(actions).length){ %>
|
|
43
|
+
<% for(let actionName in actions) { %>
|
|
44
|
+
static async <%- actionName %>({ targetId, activeUser, ip, root, shouldOwn, data }) {
|
|
45
|
+
const action = "<%- actionName %>";
|
|
46
|
+
Log.debug(
|
|
47
|
+
`${MODULE_NAME}//Logic//${MODEL_NAME}//${action}`,
|
|
48
|
+
targetId,
|
|
49
|
+
ip,
|
|
50
|
+
root
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const results = await getModel().<%- actionName %>(
|
|
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
|
+
<% } %>
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
module.exports[MODEL_NAME] = <%- ModelName %>Logic;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const MODEL_NAME = "<%- ModelName %>";
|
|
2
|
+
|
|
3
|
+
module.exports.thisModelName = MODEL_NAME;
|
|
4
|
+
module.exports.keepNotExtended = false;
|
|
5
|
+
|
|
6
|
+
module.exports.enrich = {
|
|
7
|
+
versioning: <%= versioning %>,
|
|
8
|
+
increment: <%= increment?true:false %>,
|
|
9
|
+
<% if (increment && increment?.options){ %>
|
|
10
|
+
incrementOptions: {
|
|
11
|
+
<% if (increment.options?.filter){ %>
|
|
12
|
+
filter: [<%- increment.options.filter.map((entry) => `"${entry}"`).join(',') %>],
|
|
13
|
+
<% } %>
|
|
14
|
+
},
|
|
15
|
+
<% } %>
|
|
16
|
+
validators: <%= validators %>,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const FIELDS = [
|
|
20
|
+
<% if (fields && Array.isArray(fields)) { %>
|
|
21
|
+
<% for(let field of fields){ %>
|
|
22
|
+
"<%- field %>",
|
|
23
|
+
<% } %>
|
|
24
|
+
<% } %>
|
|
25
|
+
["owner", "not-node//owner"],
|
|
26
|
+
["ownerModel", "not-node//ownerModel"],
|
|
27
|
+
["createdAt", "not-node//createdAt"],
|
|
28
|
+
["updatedAt", "not-node//updatedAt"],
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
module.exports.FIELDS = FIELDS;
|
|
32
|
+
|
|
33
|
+
module.exports.thisStatics = {
|
|
34
|
+
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
module.exports.thisMethods = {
|
|
38
|
+
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
module.exports.thisVirtuals = {
|
|
43
|
+
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
module.exports.thisPre = {
|
|
47
|
+
updateOne: async () => {
|
|
48
|
+
// console.debug('model pre updateOne');
|
|
49
|
+
},
|
|
50
|
+
insert: async () => {
|
|
51
|
+
//console.log('model pre insert');
|
|
52
|
+
},
|
|
53
|
+
save: async () => {
|
|
54
|
+
//console.log('model pre save');
|
|
55
|
+
},
|
|
56
|
+
update: async () => {
|
|
57
|
+
//console.log('model pre update' );
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
module.exports.thisPost = {
|
|
62
|
+
save: async () => {
|
|
63
|
+
//console.log('model post save');
|
|
64
|
+
},
|
|
65
|
+
update: async () => {
|
|
66
|
+
//console.log('model post update');
|
|
67
|
+
},
|
|
68
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const { MODULE_NAME } = require("../const");
|
|
2
|
+
const MODEL_NAME = "<%- ModelName %>";
|
|
3
|
+
const notNode = require("not-node");
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
// say,
|
|
7
|
+
// config,
|
|
8
|
+
// Log,
|
|
9
|
+
before,
|
|
10
|
+
after,
|
|
11
|
+
getLogic,
|
|
12
|
+
// getModel,
|
|
13
|
+
// getModelSchema,
|
|
14
|
+
} = notNode.Bootstrap.notBootstrapRoute({
|
|
15
|
+
target: module,
|
|
16
|
+
MODEL_NAME,
|
|
17
|
+
MODULE_NAME,
|
|
18
|
+
defaultAccessRule: true,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const <%- ModelName %>GenericRoute = notNode.Generic.GenericRoute({
|
|
22
|
+
before, //<-this prepares `prepared`
|
|
23
|
+
after,
|
|
24
|
+
getLogic,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
class <%- ModelName %>Route extends <%- ModelName %>GenericRoute {
|
|
28
|
+
<% if(Object.keys(actions).length){ %>
|
|
29
|
+
<% for(let actionName in actions) { %>
|
|
30
|
+
static async <%- actionName %>(
|
|
31
|
+
req, res, next, //standart express routes objects
|
|
32
|
+
prepared //extracted by `before` if form class exists
|
|
33
|
+
) {
|
|
34
|
+
<% if (layers.includes('forms') && layers.includes('logics')){ %>
|
|
35
|
+
return await getLogic().<%- actionName %>({ ...prepared });
|
|
36
|
+
<% } %>
|
|
37
|
+
|
|
38
|
+
<% if (layers.includes('forms') && !layers.includes('logics')){ %>
|
|
39
|
+
return {...prepared};
|
|
40
|
+
<% } %>
|
|
41
|
+
|
|
42
|
+
<% if (!layers.includes('forms') && layers.includes('logics')){ %>
|
|
43
|
+
return await getLogic().<%- actionName %>();
|
|
44
|
+
<% } %>
|
|
45
|
+
}
|
|
46
|
+
<% } %>
|
|
47
|
+
<% } %>
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = <%- ModelName %>Route;
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
const FIELDS = [
|
|
2
|
+
["_id", "not-node//_id"],
|
|
3
|
+
["<%- modelName %>ID", "not-node//ID"],
|
|
4
|
+
<% if (fields && Array.isArray(fields)) { %>
|
|
5
|
+
<% for(let field of fields){ %>
|
|
6
|
+
"<%- field %>",
|
|
7
|
+
<% } %>
|
|
8
|
+
<% } %>
|
|
9
|
+
["owner", "not-node//owner"],
|
|
10
|
+
["ownerModel", "not-node//ownerModel"],
|
|
11
|
+
["createdAt", "not-node//createdAt"],
|
|
12
|
+
["updatedAt", "not-node//updatedAt"],
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const actionNamePath = "/:actionName";
|
|
16
|
+
const idActionPath = "/:record[_id]/:actionName";
|
|
17
|
+
|
|
18
|
+
module.exports = {
|
|
19
|
+
model: "<%- modelName %>",
|
|
20
|
+
url: "/api/:modelName",
|
|
21
|
+
fields: FIELDS,
|
|
22
|
+
privateFields: [],
|
|
23
|
+
actions: {
|
|
24
|
+
<% if (Object.hasOwn(actions, 'create')){ %>
|
|
25
|
+
create: {
|
|
26
|
+
method: "put",
|
|
27
|
+
title: "<%- ModuleName %>:form_title_create",
|
|
28
|
+
description: "<%- ModuleName %>:form_description_create",
|
|
29
|
+
rules: [
|
|
30
|
+
{
|
|
31
|
+
auth: true,
|
|
32
|
+
root: true,
|
|
33
|
+
fields: [<%- fields.map((entry) => `"${entry}"`).join(',') %>,"owner"],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
auth: true,
|
|
37
|
+
role: ["client", "confirmed"],
|
|
38
|
+
fields: ["title"],
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
data: ["record"],
|
|
42
|
+
postFix: actionNamePath,
|
|
43
|
+
},
|
|
44
|
+
<% } %>
|
|
45
|
+
<% if (Object.hasOwn(actions,'get')){ %>
|
|
46
|
+
get: {
|
|
47
|
+
method: "get",
|
|
48
|
+
title: "<%- ModuleName %>:form_title_details",
|
|
49
|
+
description: "<%- ModuleName %>:form_description_details",
|
|
50
|
+
rules: [
|
|
51
|
+
{
|
|
52
|
+
auth: true,
|
|
53
|
+
root: true,
|
|
54
|
+
fields: [
|
|
55
|
+
"_id",
|
|
56
|
+
"<%- modelName %>ID",
|
|
57
|
+
<%- fields.map((entry) => `"${entry}"`).join(',') %>,
|
|
58
|
+
"owner",
|
|
59
|
+
"ownerModel",
|
|
60
|
+
"createdAt",
|
|
61
|
+
"updatedAt",
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
auth: true,
|
|
66
|
+
role: ["client", "confirmed"],
|
|
67
|
+
fields: [
|
|
68
|
+
"_id",
|
|
69
|
+
"<%- modelName %>ID",
|
|
70
|
+
<%- fields.map((entry) => `"${entry}"`).join(',') %>,
|
|
71
|
+
"createdAt",
|
|
72
|
+
"updatedAt",
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
postFix: idActionPath,
|
|
77
|
+
},
|
|
78
|
+
<% } %>
|
|
79
|
+
<% if (Object.hasOwn(actions,'getRaw')){ %>
|
|
80
|
+
getRaw: {
|
|
81
|
+
method: "get",
|
|
82
|
+
title: "<%- ModuleName %>:form_title_details",
|
|
83
|
+
description: "<%- ModuleName %>:form_description_details",
|
|
84
|
+
rules: [
|
|
85
|
+
{
|
|
86
|
+
auth: true,
|
|
87
|
+
root: true,
|
|
88
|
+
fields: [
|
|
89
|
+
"_id",
|
|
90
|
+
"<%- modelName %>ID",
|
|
91
|
+
<%- fields.map((entry) => `"${entry}"`).join(',') %>,
|
|
92
|
+
"owner",
|
|
93
|
+
"ownerModel",
|
|
94
|
+
"createdAt",
|
|
95
|
+
"updatedAt",
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
auth: true,
|
|
100
|
+
role: "admin",
|
|
101
|
+
fields: [
|
|
102
|
+
"_id",
|
|
103
|
+
"<%- modelName %>ID",
|
|
104
|
+
<%- fields.map((entry) => `"${entry}"`).join(',') %>,
|
|
105
|
+
"owner",
|
|
106
|
+
"ownerModel",
|
|
107
|
+
"createdAt",
|
|
108
|
+
"updatedAt",
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
auth: true,
|
|
113
|
+
role: ["client", "confirmed"],
|
|
114
|
+
fields: [
|
|
115
|
+
"<%- modelName %>ID",
|
|
116
|
+
<%- fields.map((entry) => `"${entry}"`).join(',') %>,
|
|
117
|
+
"createdAt",
|
|
118
|
+
"updatedAt",
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
postFix: idActionPath,
|
|
123
|
+
},
|
|
124
|
+
<% } %>
|
|
125
|
+
<% if (Object.hasOwn(actions,'update')){ %>
|
|
126
|
+
update: {
|
|
127
|
+
title: "<%- ModuleName %>:form_title_update",
|
|
128
|
+
description: "<%- ModuleName %>:form_description_update",
|
|
129
|
+
method: "post",
|
|
130
|
+
rules: [
|
|
131
|
+
{
|
|
132
|
+
auth: true,
|
|
133
|
+
root: true,
|
|
134
|
+
fields: [<%- fields.map((entry) => `"${entry}"`).join(',') %>, "owner", "ownerModel"],
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
auth: true,
|
|
138
|
+
role: ["client", "confirmed"],
|
|
139
|
+
fields: [<%- fields.map((entry) => `"${entry}"`).join(',') %>],
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
data: ["record"],
|
|
143
|
+
postFix: idActionPath,
|
|
144
|
+
},
|
|
145
|
+
<% } %>
|
|
146
|
+
<% if (Object.hasOwn(actions,'delete')){ %>
|
|
147
|
+
delete: {
|
|
148
|
+
title: "<%- ModuleName %>:form_title_delete",
|
|
149
|
+
description: "<%- ModuleName %>:form_description_delete",
|
|
150
|
+
method: "delete",
|
|
151
|
+
rules: [
|
|
152
|
+
{
|
|
153
|
+
auth: true,
|
|
154
|
+
root: true,
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
auth: true,
|
|
158
|
+
role: ["client", "confirmed"],
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
data: ["record"],
|
|
162
|
+
postFix: idActionPath,
|
|
163
|
+
},
|
|
164
|
+
<% } %>
|
|
165
|
+
<% if (Object.hasOwn(actions,'listAndCount')){ %>
|
|
166
|
+
listAndCount: {
|
|
167
|
+
method: "get",
|
|
168
|
+
data: ["pager", "sorter", "filter", "search"],
|
|
169
|
+
rules: [
|
|
170
|
+
{
|
|
171
|
+
auth: true,
|
|
172
|
+
root: true,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
auth: true,
|
|
176
|
+
role: "admin",
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
auth: true,
|
|
180
|
+
role: ["client", "confirmed"],
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
postFix: actionNamePath,
|
|
184
|
+
},
|
|
185
|
+
<% } %>
|
|
186
|
+
<% if (Object.hasOwn(actions,'listAll')){ %>
|
|
187
|
+
listAll: {
|
|
188
|
+
method: "get",
|
|
189
|
+
data: ["record", "sorter"],
|
|
190
|
+
fields: [
|
|
191
|
+
<%- fields.map((entry) => `"${entry}"`).join(',') %>,
|
|
192
|
+
"createdAt",
|
|
193
|
+
"updatedAt",
|
|
194
|
+
],
|
|
195
|
+
postFix: actionNamePath,
|
|
196
|
+
rules: [
|
|
197
|
+
{
|
|
198
|
+
root: true,
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
auth: true,
|
|
202
|
+
role: ["manager"],
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
auth: true,
|
|
206
|
+
},
|
|
207
|
+
],
|
|
208
|
+
},
|
|
209
|
+
<% } %>
|
|
210
|
+
},
|
|
211
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const notNode = require("not-node");
|
|
2
|
+
const { MODULE_NAME } = require("../const");
|
|
3
|
+
const MODEL_NAME = "<%- ModelName %>";
|
|
4
|
+
|
|
5
|
+
const getLogic = () =>
|
|
6
|
+
notNode.Application.getLogic(`${MODULE_NAME}//${MODEL_NAME}`);
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
async function someAction({ data, client }) {
|
|
10
|
+
return await getLogic().getData({
|
|
11
|
+
data,
|
|
12
|
+
activeUser: client.identity,
|
|
13
|
+
ip: client.getIP(),
|
|
14
|
+
root: false,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = {
|
|
19
|
+
servers: {
|
|
20
|
+
main: {
|
|
21
|
+
request: {
|
|
22
|
+
someAction
|
|
23
|
+
},
|
|
24
|
+
event:{
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import UI<%- ComponentName %> from "./<%- componentName %>.svelte";
|
|
2
|
+
|
|
3
|
+
class not<%- ComponentName %> extends notBase{
|
|
4
|
+
|
|
5
|
+
static UIConstructor = UI<%- ComponentName %>;
|
|
6
|
+
|
|
7
|
+
constructor({
|
|
8
|
+
target = null,
|
|
9
|
+
name = "Default",
|
|
10
|
+
options = {},
|
|
11
|
+
working = {},
|
|
12
|
+
data = {},
|
|
13
|
+
}){
|
|
14
|
+
super({
|
|
15
|
+
working: {
|
|
16
|
+
name: `${name}<%- ComponentName %>`,
|
|
17
|
+
...working,
|
|
18
|
+
},
|
|
19
|
+
options,
|
|
20
|
+
data,
|
|
21
|
+
});
|
|
22
|
+
if (target) {
|
|
23
|
+
this.setOptions("target", target);
|
|
24
|
+
}
|
|
25
|
+
this.render();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
render(){
|
|
29
|
+
this.remove();
|
|
30
|
+
if(this.UIConstructor){
|
|
31
|
+
this.ui = new this.UIConstructor({
|
|
32
|
+
target: this.getOptions('target'),
|
|
33
|
+
props:{
|
|
34
|
+
/* props */
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
update(){
|
|
41
|
+
if(this.ui){
|
|
42
|
+
this.ui.$set({ /* update props */ });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
remove(){
|
|
47
|
+
if (this.ui) {
|
|
48
|
+
this.ui.$destroy();
|
|
49
|
+
this.ui = null;
|
|
50
|
+
}
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default not<%- ComponentName %>;
|
|
57
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const INTERVAL = 360;
|
|
2
|
+
const INIT_UPDATE_DELAY = 5;
|
|
3
|
+
|
|
4
|
+
class ns<%- ServiceName %> {
|
|
5
|
+
#INTERVAL = INTERVAL;
|
|
6
|
+
#INIT_UPDATE_DELAY = INIT_UPDATE_DELAY;
|
|
7
|
+
|
|
8
|
+
constructor(app) {
|
|
9
|
+
this.app = app;
|
|
10
|
+
<% if(modelName){ %>
|
|
11
|
+
this.interface = this.app.getInterface("<%- modelName %>"");
|
|
12
|
+
if(this.interface){
|
|
13
|
+
this.init();
|
|
14
|
+
}else{
|
|
15
|
+
app.error('no network interface');
|
|
16
|
+
}
|
|
17
|
+
<% }else{ %>
|
|
18
|
+
this.init();
|
|
19
|
+
<% } %>
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
init() {
|
|
23
|
+
setTimeout(this.update.bind(this), this.#INIT_UPDATE_DELAY * 100);
|
|
24
|
+
this.int = setInterval(this.update.bind(this), this.#INTERVAL * 1000);
|
|
25
|
+
window.addEventListener('unload', () => {
|
|
26
|
+
clearInterval(this.int);
|
|
27
|
+
delete this.app;
|
|
28
|
+
<% if(modelName){ %>
|
|
29
|
+
delete this.interface;
|
|
30
|
+
<% } %>
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
update() {
|
|
35
|
+
//serve
|
|
36
|
+
}}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
export default ns<%- ServiceName %>;
|
package/scaffold/field.js
DELETED
|
File without changes
|
package/scaffold/form.js
DELETED
|
File without changes
|
package/scaffold/logic.js
DELETED
|
File without changes
|
package/scaffold/model.js
DELETED
|
File without changes
|
package/scaffold/module.js
DELETED
|
File without changes
|
package/scaffold/route.js
DELETED
|
File without changes
|