not-node 6.3.33 → 6.3.34

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.3.33",
3
+ "version": "6.3.34",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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 = resolve(CWD, "./site");
21
+ const siteDir = getProjectSiteDir(opts.dir, CWD);
18
22
  if (opts.v) {
19
23
  Logger.setSilent(false);
20
24
  }
21
- console.log("project in", opts.dir);
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 = resolve(CWD, "./site");
20
+ const siteDir = getProjectSiteDir(opts.dir, CWD);
17
21
  if (opts.v) {
18
22
  Logger.setSilent(false);
19
23
  }
20
- console.log("project in", opts.dir);
24
+ console.log("project in", siteDir);
21
25
  const infoFromManifest = await loadProjectConfig(siteDir);
22
26
  const modulesDir = resolve(
23
27
  siteDir,
@@ -5,7 +5,7 @@ export default (inquirer) => {
5
5
  type: "input",
6
6
  name: "name",
7
7
  message: "Module Name",
8
- default: "notNodeModule",
8
+ default: "not-my-module",
9
9
  },
10
10
  ])
11
11
  .then((answers) => {
@@ -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} forma data
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;
@@ -45,16 +49,21 @@ module.exports.thisVirtuals = {
45
49
 
46
50
  module.exports.thisPre = {
47
51
  updateOne: async () => {
52
+ <% if (dates){ %>this.updatedAt = new Date();<% } %>
48
53
  // console.debug('model pre updateOne');
49
54
  },
50
- insert: async () => {
55
+ insert: async () => {
51
56
  //console.log('model pre insert');
57
+ <% if (dates){ %>this.updatedAt = new Date();
58
+ this.createdAt = new Date();<% } %>
52
59
  },
53
60
  save: async () => {
54
61
  //console.log('model pre save');
62
+ <% if (dates){ %>this.updatedAt = new Date();<% } %>
55
63
  },
56
64
  update: async () => {
57
65
  //console.log('model pre update' );
66
+ <% if (dates){ %>this.updatedAt = new Date();<% } %>
58
67
  },
59
68
  };
60
69
 
@@ -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
- model: "<%- modelName %>",
21
- url: "/api/:modelName",
22
- fields: FIELDS,
23
- privateFields: [],
24
- actions: {
25
- <% if (Object.hasOwn(actions, 'create')){ %>
26
- create: {
27
- method: "put",
28
- actionSignature: ACTION_SIGNATURES.CREATE,
29
- title: "<%- ModuleName %>:form_title_create",
30
- description: "<%- ModuleName %>:form_description_create",
31
- rules: [
32
- {
33
- auth: true,
34
- root: true,
35
- fields: [<%- fields.map((entry) => `"${entry}"`).join(',') %>,"owner"],
36
- },
37
- {
38
- auth: true,
39
- role: ["client", "confirmed"],
40
- fields: ["title"],
41
- },
42
- ],
43
- data: ["record"],
44
- postFix: actionNamePath,
45
- },
46
- <% } %>
47
- <% if (Object.hasOwn(actions,'get')){ %>
48
- get: {
49
- method: "get",
50
- actionSignature: ACTION_SIGNATURES.READ,
51
- title: "<%- ModuleName %>:form_title_details",
52
- description: "<%- ModuleName %>:form_description_details",
53
- rules: [
54
- {
55
- auth: true,
56
- root: true,
57
- fields: [
58
- "_id",
59
- "<%- modelName %>ID",
60
- <%- fields.map((entry) => `"${entry}"`).join(',') %>,
61
- "owner",
62
- "ownerModel",
63
- "createdAt",
64
- "updatedAt",
65
- ],
66
- },
67
- {
68
- auth: true,
69
- role: ["client", "confirmed"],
70
- fields: [
71
- "_id",
72
- "<%- modelName %>ID",
73
- <%- fields.map((entry) => `"${entry}"`).join(',') %>,
74
- "createdAt",
75
- "updatedAt",
76
- ],
77
- },
78
- ],
79
- postFix: idActionPath,
80
- },
81
- <% } %>
82
- <% if (Object.hasOwn(actions,'getRaw')){ %>
83
- getRaw: {
84
- method: "get",
85
- actionSignature: ACTION_SIGNATURES.READ,
86
- title: "<%- ModuleName %>:form_title_details",
87
- description: "<%- ModuleName %>:form_description_details",
88
- rules: [
89
- {
90
- auth: true,
91
- root: true,
92
- fields: [
93
- "_id",
94
- "<%- modelName %>ID",
95
- <%- fields.map((entry) => `"${entry}"`).join(',') %>,
96
- "owner",
97
- "ownerModel",
98
- "createdAt",
99
- "updatedAt",
100
- ],
101
- },
102
- {
103
- auth: true,
104
- role: "admin",
105
- fields: [
106
- "_id",
107
- "<%- modelName %>ID",
108
- <%- fields.map((entry) => `"${entry}"`).join(',') %>,
109
- "owner",
110
- "ownerModel",
111
- "createdAt",
112
- "updatedAt",
113
- ],
114
- },
115
- {
116
- auth: true,
117
- role: ["client", "confirmed"],
118
- fields: [
119
- "<%- modelName %>ID",
120
- <%- fields.map((entry) => `"${entry}"`).join(',') %>,
121
- "createdAt",
122
- "updatedAt",
123
- ],
124
- },
125
- ],
126
- postFix: idActionPath,
127
- },
128
- <% } %>
129
- <% if (Object.hasOwn(actions,'update')){ %>
130
- update: {
131
- title: "<%- ModuleName %>:form_title_update",
132
- actionSignature: ACTION_SIGNATURES.UPDATE,
133
- description: "<%- ModuleName %>:form_description_update",
134
- method: "post",
135
- rules: [
136
- {
137
- auth: true,
138
- root: true,
139
- fields: [<%- fields.map((entry) => `"${entry}"`).join(',') %>, "owner", "ownerModel"],
140
- },
141
- {
142
- auth: true,
143
- role: ["client", "confirmed"],
144
- fields: [<%- fields.map((entry) => `"${entry}"`).join(',') %>],
145
- },
146
- ],
147
- data: ["record"],
148
- postFix: idActionPath,
149
- },
150
- <% } %>
151
- <% if (Object.hasOwn(actions,'delete')){ %>
152
- delete: {
153
- actionSignature: ACTION_SIGNATURES.DELETE,
154
- title: "<%- ModuleName %>:form_title_delete",
155
- description: "<%- ModuleName %>:form_description_delete",
156
- method: "delete",
157
- rules: [
158
- {
159
- auth: true,
160
- root: true,
161
- },
162
- {
163
- auth: true,
164
- role: ["client", "confirmed"],
165
- },
166
- ],
167
- data: ["record"],
168
- postFix: idActionPath,
169
- },
170
- <% } %>
171
- <% if (Object.hasOwn(actions,'listAndCount')){ %>
172
- listAndCount: {
173
- method: "get",
174
- actionSignature: ACTION_SIGNATURES.READ,
175
- data: ["pager", "sorter", "filter", "search"],
176
- rules: [
177
- {
178
- auth: true,
179
- root: true,
180
- },
181
- {
182
- auth: true,
183
- role: "admin",
184
- },
185
- {
186
- auth: true,
187
- role: ["client", "confirmed"],
188
- },
189
- ],
190
- postFix: actionNamePath,
191
- },
192
- <% } %>
193
- <% if (Object.hasOwn(actions,'listAll')){ %>
194
- listAll: {
195
- method: "get",
196
- actionSignature: ACTION_SIGNATURES.READ,
197
- data: ["record", "sorter"],
198
- fields: [
199
- <%- fields.map((entry) => `"${entry}"`).join(',') %>,
200
- "createdAt",
201
- "updatedAt",
202
- ],
203
- postFix: actionNamePath,
204
- rules: [
205
- {
206
- root: true,
207
- },
208
- {
209
- auth: true,
210
- role: ["manager"],
211
- },
212
- {
213
- auth: true,
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
+