not-node 6.3.33 → 6.3.35
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 +1 -1
- package/src/cli/actions/module.front.mjs +6 -2
- package/src/cli/actions/module.server.mjs +6 -2
- package/src/cli/readers/ModuleName.mjs +1 -1
- package/tmpl/files/module.server/layers/forms/create.ejs +2 -2
- package/tmpl/files/module.server/layers/forms/update.ejs +1 -1
- package/tmpl/files/module.server/layers/models.ejs +15 -6
- package/tmpl/files/module.server/layers/routes.manifest.ejs +203 -199
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import { resolve } from "node:path";
|
|
|
3
3
|
import Logger from "../lib/log.mjs";
|
|
4
4
|
import { createFrontModule } from "../lib/module.front.mjs";
|
|
5
5
|
import { loadProjectConfig } from "../lib/project.mjs";
|
|
6
|
+
import { getProjectSiteDir } from "../lib/fs.mjs";
|
|
6
7
|
import Options from "../lib/opts.mjs";
|
|
7
8
|
|
|
8
9
|
export default (program, { CWD }) => {
|
|
@@ -11,14 +12,17 @@ export default (program, { CWD }) => {
|
|
|
11
12
|
.addOption(
|
|
12
13
|
new Option("-v, --verbose").default(false, "extensive output")
|
|
13
14
|
)
|
|
15
|
+
.addOption(
|
|
16
|
+
new Option("-d, --dir <dir>").default("", "project site directory")
|
|
17
|
+
)
|
|
14
18
|
.description("adds new front module to existing project")
|
|
15
19
|
.action(async (opts) => {
|
|
16
20
|
console.log(CWD);
|
|
17
|
-
const siteDir =
|
|
21
|
+
const siteDir = getProjectSiteDir(opts.dir, CWD);
|
|
18
22
|
if (opts.v) {
|
|
19
23
|
Logger.setSilent(false);
|
|
20
24
|
}
|
|
21
|
-
console.log("project in",
|
|
25
|
+
console.log("project in", siteDir);
|
|
22
26
|
const infoFromManifest = await loadProjectConfig(siteDir);
|
|
23
27
|
const modulesDir = resolve(
|
|
24
28
|
siteDir,
|
|
@@ -3,6 +3,7 @@ import { resolve } from "node:path";
|
|
|
3
3
|
import Logger from "../lib/log.mjs";
|
|
4
4
|
import { createServerModule } from "../lib/module.server.mjs";
|
|
5
5
|
import { loadProjectConfig } from "../lib/project.mjs";
|
|
6
|
+
import { getProjectSiteDir } from "../lib/fs.mjs";
|
|
6
7
|
|
|
7
8
|
export default (program, { CWD }) => {
|
|
8
9
|
program
|
|
@@ -10,14 +11,17 @@ export default (program, { CWD }) => {
|
|
|
10
11
|
.addOption(
|
|
11
12
|
new Option("-v, --verbose").default(false, "extensive output")
|
|
12
13
|
)
|
|
14
|
+
.addOption(
|
|
15
|
+
new Option("-d, --dir <dir>").default("", "project site directory")
|
|
16
|
+
)
|
|
13
17
|
.description("adds new server module to existing project")
|
|
14
18
|
.action(async (opts) => {
|
|
15
19
|
console.log(CWD);
|
|
16
|
-
const siteDir =
|
|
20
|
+
const siteDir = getProjectSiteDir(opts.dir, CWD);
|
|
17
21
|
if (opts.v) {
|
|
18
22
|
Logger.setSilent(false);
|
|
19
23
|
}
|
|
20
|
-
console.log("project in",
|
|
24
|
+
console.log("project in", siteDir);
|
|
21
25
|
const infoFromManifest = await loadProjectConfig(siteDir);
|
|
22
26
|
const modulesDir = resolve(
|
|
23
27
|
siteDir,
|
|
@@ -19,9 +19,9 @@ class <%- ModelName %>CreateForm extends Form {
|
|
|
19
19
|
/**
|
|
20
20
|
* Extracts data
|
|
21
21
|
* @param {import('not-node/src/types.js').notNodeExpressRequest} req expressjs request object
|
|
22
|
-
* @return {Object}
|
|
22
|
+
* @return {Promise<Object>} form data
|
|
23
23
|
**/
|
|
24
|
-
extract(req) {
|
|
24
|
+
async extract(req) {
|
|
25
25
|
const data = this.extractByInstructionsFromRouteActionFields(
|
|
26
26
|
req, //request object
|
|
27
27
|
["fromBody", "xss"], //extraction common pipe [extractor, ...transformers]
|
|
@@ -13,7 +13,7 @@ class <%- ModelName %>UpdateForm extends Form {
|
|
|
13
13
|
super({ FIELDS, FORM_NAME, app });
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
extract(req) {
|
|
16
|
+
async extract(req) {
|
|
17
17
|
const data = this.extractByInstructionsFromRouteActionFields(req, ["fromBody", "xss"], {});
|
|
18
18
|
const envs = this.extractRequestEnvs(req);
|
|
19
19
|
<% if ( ownage ) { %>
|
|
@@ -22,10 +22,14 @@ const FIELDS = [
|
|
|
22
22
|
"<%- field %>",
|
|
23
23
|
<% } %>
|
|
24
24
|
<% } %>
|
|
25
|
+
<% if (ownage){ %>
|
|
25
26
|
["owner", "not-node//owner"],
|
|
26
27
|
["ownerModel", "not-node//ownerModel"],
|
|
28
|
+
<% } %>
|
|
29
|
+
<% if (dates){ %>
|
|
27
30
|
["createdAt", "not-node//createdAt"],
|
|
28
31
|
["updatedAt", "not-node//updatedAt"],
|
|
32
|
+
<% } %>
|
|
29
33
|
];
|
|
30
34
|
|
|
31
35
|
module.exports.FIELDS = FIELDS;
|
|
@@ -44,25 +48,30 @@ module.exports.thisVirtuals = {
|
|
|
44
48
|
};
|
|
45
49
|
|
|
46
50
|
module.exports.thisPre = {
|
|
47
|
-
|
|
51
|
+
async updateOne(){
|
|
52
|
+
<% if (dates){ %>this.updatedAt = new Date();<% } %>
|
|
48
53
|
// console.debug('model pre updateOne');
|
|
49
54
|
},
|
|
50
|
-
|
|
55
|
+
async insert(){
|
|
51
56
|
//console.log('model pre insert');
|
|
57
|
+
<% if (dates){ %>this.updatedAt = new Date();
|
|
58
|
+
this.createdAt = new Date();<% } %>
|
|
52
59
|
},
|
|
53
|
-
|
|
60
|
+
async save(){
|
|
54
61
|
//console.log('model pre save');
|
|
62
|
+
<% if (dates){ %>this.updatedAt = new Date();<% } %>
|
|
55
63
|
},
|
|
56
|
-
|
|
64
|
+
async update(){
|
|
57
65
|
//console.log('model pre update' );
|
|
66
|
+
<% if (dates){ %>this.updatedAt = new Date();<% } %>
|
|
58
67
|
},
|
|
59
68
|
};
|
|
60
69
|
|
|
61
70
|
module.exports.thisPost = {
|
|
62
|
-
|
|
71
|
+
async save(){
|
|
63
72
|
//console.log('model post save');
|
|
64
73
|
},
|
|
65
|
-
|
|
74
|
+
async update(){
|
|
66
75
|
//console.log('model post update');
|
|
67
76
|
},
|
|
68
77
|
};
|
|
@@ -1,220 +1,224 @@
|
|
|
1
1
|
const ACTION_SIGNATURES = require('not-node/src/auth/const').ACTION_SIGNATURES;
|
|
2
2
|
const FIELDS = [
|
|
3
3
|
["_id", "not-node//_id"],
|
|
4
|
+
<% if (increment){ %>
|
|
4
5
|
["<%- modelName %>ID", "not-node//ID"],
|
|
6
|
+
<% } %>
|
|
5
7
|
<% if (fields && Array.isArray(fields)) { %>
|
|
6
8
|
<% for(let field of fields){ %>
|
|
7
9
|
"<%- field %>",
|
|
8
10
|
<% } %>
|
|
9
11
|
<% } %>
|
|
12
|
+
<% if (ownage){ %>
|
|
10
13
|
["owner", "not-node//owner"],
|
|
11
14
|
["ownerModel", "not-node//ownerModel"],
|
|
15
|
+
<% } %>
|
|
16
|
+
<% if (dates){ %>
|
|
12
17
|
["createdAt", "not-node//createdAt"],
|
|
13
18
|
["updatedAt", "not-node//updatedAt"],
|
|
19
|
+
<% } %>
|
|
14
20
|
];
|
|
15
21
|
|
|
16
22
|
const actionNamePath = "/:actionName";
|
|
17
23
|
const idActionPath = "/:record[_id]/:actionName";
|
|
18
24
|
|
|
19
25
|
module.exports = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
},
|
|
217
|
-
<% } %>
|
|
218
|
-
},
|
|
26
|
+
model: "<%- modelName %>",
|
|
27
|
+
url: "/api/:modelName",
|
|
28
|
+
fields: FIELDS,
|
|
29
|
+
privateFields: [],
|
|
30
|
+
actions: {
|
|
31
|
+
<% if (Object.hasOwn(actions, 'create')){ %>
|
|
32
|
+
create: {
|
|
33
|
+
method: "put",
|
|
34
|
+
actionSignature: ACTION_SIGNATURES.CREATE,
|
|
35
|
+
title: "<%- ModuleName %>:form_title_create",
|
|
36
|
+
description: "<%- ModuleName %>:form_description_create",
|
|
37
|
+
rules: [
|
|
38
|
+
{
|
|
39
|
+
auth: true,
|
|
40
|
+
root: true,
|
|
41
|
+
fields: [
|
|
42
|
+
<%- fields.map((entry) => `"${entry}"`).join(',') %>,
|
|
43
|
+
<% if (ownage){ %>"owner",<% } %>
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
auth: true,
|
|
48
|
+
role: ["client", "confirmed"],
|
|
49
|
+
fields: ["title"],
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
data: ["record"],
|
|
53
|
+
postFix: actionNamePath,
|
|
54
|
+
},
|
|
55
|
+
<% } %>
|
|
56
|
+
<% if (Object.hasOwn(actions,'get')){ %>
|
|
57
|
+
get: {
|
|
58
|
+
method: "get",
|
|
59
|
+
actionSignature: ACTION_SIGNATURES.READ,
|
|
60
|
+
title: "<%- ModuleName %>:form_title_details",
|
|
61
|
+
description: "<%- ModuleName %>:form_description_details",
|
|
62
|
+
rules: [
|
|
63
|
+
{
|
|
64
|
+
auth: true,
|
|
65
|
+
root: true,
|
|
66
|
+
fields: [
|
|
67
|
+
"_id",
|
|
68
|
+
<% if (increment){ %>"<%- modelName %>ID",<% } %>
|
|
69
|
+
<%- fields.map((entry) => `"${entry}"`).join(',') %>,
|
|
70
|
+
<% if (ownage){ %>"owner","ownerModel",<% } %>
|
|
71
|
+
<% if (dates){ %>"createdAt","updatedAt",<% } %>
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
auth: true,
|
|
76
|
+
role: ["client", "confirmed"],
|
|
77
|
+
fields: [
|
|
78
|
+
"_id",
|
|
79
|
+
<% if (increment){ %>"<%- modelName %>ID",<% } %>
|
|
80
|
+
<%- fields.map((entry) => `"${entry}"`).join(',') %>,
|
|
81
|
+
<% if (dates){ %>"createdAt","updatedAt",<% } %>
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
postFix: idActionPath,
|
|
86
|
+
},
|
|
87
|
+
<% } %>
|
|
88
|
+
<% if (Object.hasOwn(actions,'getRaw')){ %>
|
|
89
|
+
getRaw: {
|
|
90
|
+
method: "get",
|
|
91
|
+
actionSignature: ACTION_SIGNATURES.READ,
|
|
92
|
+
title: "<%- ModuleName %>:form_title_details",
|
|
93
|
+
description: "<%- ModuleName %>:form_description_details",
|
|
94
|
+
rules: [
|
|
95
|
+
{
|
|
96
|
+
auth: true,
|
|
97
|
+
root: true,
|
|
98
|
+
fields: [
|
|
99
|
+
"_id",
|
|
100
|
+
<% if (increment){ %>"<%- modelName %>ID",<% } %>
|
|
101
|
+
<%- fields.map((entry) => `"${entry}"`).join(',') %>,
|
|
102
|
+
<% if (ownage){ %>"owner","ownerModel",<% } %>
|
|
103
|
+
<% if (dates){ %>"createdAt","updatedAt",<% } %>
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
auth: true,
|
|
108
|
+
role: "admin",
|
|
109
|
+
fields: [
|
|
110
|
+
"_id",
|
|
111
|
+
<% if (increment){ %>"<%- modelName %>ID",<% } %>
|
|
112
|
+
<%- fields.map((entry) => `"${entry}"`).join(',') %>,
|
|
113
|
+
<% if (ownage){ %>"owner","ownerModel",<% } %>
|
|
114
|
+
<% if (dates){ %>"createdAt","updatedAt",<% } %>
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
auth: true,
|
|
119
|
+
role: ["client", "confirmed"],
|
|
120
|
+
fields: [
|
|
121
|
+
<% if (increment){ %>"<%- modelName %>ID",<% } %>
|
|
122
|
+
<%- fields.map((entry) => `"${entry}"`).join(',') %>,
|
|
123
|
+
<% if (dates){ %>"createdAt","updatedAt",<% } %>
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
postFix: idActionPath,
|
|
128
|
+
},
|
|
129
|
+
<% } %>
|
|
130
|
+
<% if (Object.hasOwn(actions,'update')){ %>
|
|
131
|
+
update: {
|
|
132
|
+
title: "<%- ModuleName %>:form_title_update",
|
|
133
|
+
actionSignature: ACTION_SIGNATURES.UPDATE,
|
|
134
|
+
description: "<%- ModuleName %>:form_description_update",
|
|
135
|
+
method: "post",
|
|
136
|
+
rules: [
|
|
137
|
+
{
|
|
138
|
+
auth: true,
|
|
139
|
+
root: true,
|
|
140
|
+
fields: [
|
|
141
|
+
<%- fields.map((entry) => `"${entry}"`).join(',') %>,
|
|
142
|
+
<% if (ownage){ %>"owner", "ownerModel",<% } %>
|
|
143
|
+
],
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
auth: true,
|
|
147
|
+
role: ["client", "confirmed"],
|
|
148
|
+
fields: [<%- fields.map((entry) => `"${entry}"`).join(',') %>],
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
data: ["record"],
|
|
152
|
+
postFix: idActionPath,
|
|
153
|
+
},
|
|
154
|
+
<% } %>
|
|
155
|
+
<% if (Object.hasOwn(actions,'delete')){ %>
|
|
156
|
+
delete: {
|
|
157
|
+
actionSignature: ACTION_SIGNATURES.DELETE,
|
|
158
|
+
title: "<%- ModuleName %>:form_title_delete",
|
|
159
|
+
description: "<%- ModuleName %>:form_description_delete",
|
|
160
|
+
method: "delete",
|
|
161
|
+
rules: [
|
|
162
|
+
{
|
|
163
|
+
auth: true,
|
|
164
|
+
root: true,
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
auth: true,
|
|
168
|
+
role: ["client", "confirmed"],
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
data: ["record"],
|
|
172
|
+
postFix: idActionPath,
|
|
173
|
+
},
|
|
174
|
+
<% } %>
|
|
175
|
+
<% if (Object.hasOwn(actions,'listAndCount')){ %>
|
|
176
|
+
listAndCount: {
|
|
177
|
+
method: "get",
|
|
178
|
+
actionSignature: ACTION_SIGNATURES.READ,
|
|
179
|
+
data: ["pager", "sorter", "filter", "search"],
|
|
180
|
+
rules: [
|
|
181
|
+
{
|
|
182
|
+
auth: true,
|
|
183
|
+
root: true,
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
auth: true,
|
|
187
|
+
role: "admin",
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
auth: true,
|
|
191
|
+
role: ["client", "confirmed"],
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
postFix: actionNamePath,
|
|
195
|
+
},
|
|
196
|
+
<% } %>
|
|
197
|
+
<% if (Object.hasOwn(actions,'listAll')){ %>
|
|
198
|
+
listAll: {
|
|
199
|
+
method: "get",
|
|
200
|
+
actionSignature: ACTION_SIGNATURES.READ,
|
|
201
|
+
data: ["record", "sorter"],
|
|
202
|
+
fields: [
|
|
203
|
+
<%- fields.map((entry) => `"${entry}"`).join(',') %>,
|
|
204
|
+
<% if (dates){ %>"createdAt","updatedAt",<% } %>
|
|
205
|
+
],
|
|
206
|
+
postFix: actionNamePath,
|
|
207
|
+
rules: [
|
|
208
|
+
{
|
|
209
|
+
root: true,
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
auth: true,
|
|
213
|
+
role: ["manager"],
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
auth: true,
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
},
|
|
220
|
+
<% } %>
|
|
221
|
+
},
|
|
219
222
|
};
|
|
220
223
|
|
|
224
|
+
|