@saltcorn/server 0.6.1-beta.0 → 0.6.1

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.
Files changed (53) hide show
  1. package/app.js +7 -0
  2. package/auth/admin.js +120 -5
  3. package/auth/index.js +7 -0
  4. package/auth/resetpw.js +22 -0
  5. package/auth/roleadmin.js +52 -0
  6. package/auth/routes.js +211 -2
  7. package/auth/testhelp.js +69 -0
  8. package/errors.js +14 -1
  9. package/fixture_persons.js +14 -0
  10. package/index.js +6 -0
  11. package/load_plugins.js +4 -3
  12. package/locales/en.json +7 -1
  13. package/markup/admin.js +97 -1
  14. package/markup/blockly.js +15 -0
  15. package/markup/expression_blurb.js +45 -0
  16. package/markup/forms.js +24 -0
  17. package/markup/index.js +7 -0
  18. package/markup/plugin-store.js +36 -0
  19. package/package.json +6 -6
  20. package/public/saltcorn-builder.css +1 -0
  21. package/public/saltcorn.js +5 -1
  22. package/routes/actions.js +53 -1
  23. package/routes/admin.js +97 -1
  24. package/routes/api.js +45 -10
  25. package/routes/config.js +18 -0
  26. package/routes/crashlog.js +31 -0
  27. package/routes/delete.js +19 -0
  28. package/routes/edit.js +19 -0
  29. package/routes/eventlog.js +65 -1
  30. package/routes/events.js +19 -0
  31. package/routes/fields.js +88 -0
  32. package/routes/files.js +62 -0
  33. package/routes/homepage.js +175 -80
  34. package/routes/index.js +7 -1
  35. package/routes/infoarch.js +56 -0
  36. package/routes/library.js +32 -0
  37. package/routes/list.js +28 -1
  38. package/routes/menu.js +45 -0
  39. package/routes/packs.js +53 -0
  40. package/routes/page.js +26 -0
  41. package/routes/pageedit.js +129 -3
  42. package/routes/plugins.js +156 -5
  43. package/routes/scapi.js +79 -23
  44. package/routes/search.js +51 -0
  45. package/routes/settings.js +27 -0
  46. package/routes/tables.js +148 -19
  47. package/routes/tenant.js +123 -31
  48. package/routes/utils.js +60 -1
  49. package/routes/view.js +37 -0
  50. package/routes/viewedit.js +114 -1
  51. package/serve.js +138 -88
  52. package/systemd.js +18 -1
  53. package/wrapper.js +4 -0
package/routes/scapi.js CHANGED
@@ -1,8 +1,12 @@
1
1
  /**
2
2
  * SC service API handler
3
3
  * Allows to list tables, views, etc
4
- * @type {module:express-promise-router}
4
+ * @category server
5
+ * @module routes/scapi
6
+ * @subcategory routes
5
7
  */
8
+
9
+ /** @type {module:express-promise-router} */
6
10
  const Router = require("express-promise-router");
7
11
  //const db = require("@saltcorn/data/db");
8
12
  const { setTenant, error_catcher } = require("./utils.js");
@@ -21,15 +25,22 @@ const {
21
25
  stateFieldsToWhere,
22
26
  readState,
23
27
  } = require("@saltcorn/data/plugin-helper");
28
+
29
+ /**
30
+ * @type {object}
31
+ * @const
32
+ * @namespace scapiRouter
33
+ * @category server
34
+ * @subcategory routes
35
+ */
24
36
  const router = new Router();
25
37
  module.exports = router;
26
38
 
27
-
28
39
  /**
29
40
  * Check that user has right to read sc service api data.
30
41
  * Only admin currently can call this api.
31
- * @param req - httprequest
32
- * @param user - user based on access token
42
+ * @param {object} req httprequest
43
+ * @param {object} user user based on access token
33
44
  * @returns {boolean}
34
45
  */
35
46
  function accessAllowedRead(req, user){
@@ -43,12 +54,17 @@ function accessAllowedRead(req, user){
43
54
  return false;
44
55
  }
45
56
 
46
- /**
47
- * List SC Tables using GET
48
- */
57
+
49
58
  // todo add paging
50
59
  // todo more granular access rights for api. Currently only admin can call this api.
51
60
  // todo add support of fields
61
+ /**
62
+ * List SC Tables using GET
63
+ * @name get/sc_tables
64
+ * @function
65
+ * @memberof module:routes/scapi~scapiRouter
66
+ * @function
67
+ */
52
68
  router.get(
53
69
  "/sc_tables/",
54
70
  setTenant,
@@ -70,11 +86,16 @@ router.get(
70
86
  )(req, res, next);
71
87
  })
72
88
  );
89
+
90
+ // todo add paging
91
+ // todo more granular access rights for api. Currently only admin can call this api.
73
92
  /**
74
93
  * List SC Views using GET
94
+ * @name get/sc_views
95
+ * @function
96
+ * @memberof module:routes/scapi~scapiRouter
97
+ * @function
75
98
  */
76
- // todo add paging
77
- // todo more granular access rights for api. Currently only admin can call this api.
78
99
  router.get(
79
100
  "/sc_views/",
80
101
  setTenant,
@@ -97,11 +118,16 @@ router.get(
97
118
  })
98
119
  );
99
120
 
121
+
122
+ // todo add paging
123
+ // todo more granular access rights to api. Currently only admin can call this api.
100
124
  /**
101
125
  * List SC Pages using GET
126
+ * @name get/sc_pages
127
+ * @function
128
+ * @memberof module:routes/scapi~scapiRouter
129
+ * @function
102
130
  */
103
- // todo add paging
104
- // todo more granular access rights to api. Currently only admin can call this api.
105
131
  router.get(
106
132
  "/sc_pages/",
107
133
  setTenant,
@@ -123,11 +149,16 @@ router.get(
123
149
  )(req, res, next);
124
150
  })
125
151
  );
152
+
153
+ // todo add paging
154
+ // todo more granular access rights to api. Currently only admin can call this api.
126
155
  /**
127
156
  * List SC Files using GET
157
+ * @name get/sc_files
158
+ * @function
159
+ * @memberof module:routes/scapi~scapiRouter
160
+ * @function
128
161
  */
129
- // todo add paging
130
- // todo more granular access rights to api. Currently only admin can call this api.
131
162
  router.get(
132
163
  "/sc_files/",
133
164
  setTenant,
@@ -149,11 +180,16 @@ router.get(
149
180
  )(req, res, next);
150
181
  })
151
182
  );
183
+
184
+ // todo add paging
185
+ // todo more granular access rights to api. Currently only admin can call this api.
152
186
  /**
153
187
  * List SC Triggers using GET
188
+ * @name get/sc_triggers
189
+ * @function
190
+ * @memberof module:routes/scapi~scapiRouter
191
+ * @function
154
192
  */
155
- // todo add paging
156
- // todo more granular access rights to api. Currently only admin can call this api.
157
193
  router.get(
158
194
  "/sc_triggers/",
159
195
  setTenant,
@@ -175,11 +211,16 @@ router.get(
175
211
  )(req, res, next);
176
212
  })
177
213
  );
214
+
215
+ // todo add paging
216
+ // todo more granular access rights to api. Currently only admin can call this api.
178
217
  /**
179
218
  * List SC Roles using GET
219
+ * @name get/sc_roles
220
+ * @function
221
+ * @memberof module:routes/scapi~scapiRouter
222
+ * @function
180
223
  */
181
- // todo add paging
182
- // todo more granular access rights to api. Currently only admin can call this api.
183
224
  router.get(
184
225
  "/sc_roles/",
185
226
  setTenant,
@@ -201,11 +242,16 @@ router.get(
201
242
  )(req, res, next);
202
243
  })
203
244
  );
245
+
246
+ // todo add paging
247
+ // todo more granular access rights to api. Currently only admin can call this api.
204
248
  /**
205
249
  * List SC Tenants using GET
250
+ * @name get/sc_tenants
251
+ * @function
252
+ * @memberof module:routes/scapi~scapiRouter
253
+ * @function
206
254
  */
207
- // todo add paging
208
- // todo more granular access rights to api. Currently only admin can call this api.
209
255
  router.get(
210
256
  "/sc_tenants/",
211
257
  setTenant,
@@ -227,11 +273,16 @@ router.get(
227
273
  )(req, res, next);
228
274
  })
229
275
  );
276
+
277
+ // todo add paging
278
+ // todo more granular access rights to api. Currently only admin can call this api.
230
279
  /**
231
280
  * List SC Plugins using GET
281
+ * @name get/sc_plugins
282
+ * @function
283
+ * @memberof module:routes/scapi~scapiRouter
284
+ * @function
232
285
  */
233
- // todo add paging
234
- // todo more granular access rights to api. Currently only admin can call this api.
235
286
  router.get(
236
287
  "/sc_plugins/",
237
288
  setTenant,
@@ -253,11 +304,16 @@ router.get(
253
304
  )(req, res, next);
254
305
  })
255
306
  );
307
+
308
+ // todo add paging
309
+ // todo more granular access rights to api. Currently only admin can call this api.
256
310
  /**
257
311
  * List SC Config Items using GET
312
+ * @name get/sc_config
313
+ * @function
314
+ * @memberof module:routes/scapi~scapiRouter
315
+ * @function
258
316
  */
259
- // todo add paging
260
- // todo more granular access rights to api. Currently only admin can call this api.
261
317
  router.get(
262
318
  "/sc_config/",
263
319
  setTenant,
package/routes/search.js CHANGED
@@ -1,3 +1,9 @@
1
+ /**
2
+ * @category server
3
+ * @module routes/search
4
+ * @subcategory routes
5
+ */
6
+
1
7
  const Router = require("express-promise-router");
2
8
  const { span, h5, h4, nbsp, p, a, div } = require("@saltcorn/markup/tags");
3
9
 
@@ -10,9 +16,22 @@ const { renderForm } = require("@saltcorn/markup");
10
16
  const { pagination } = require("@saltcorn/markup/helpers");
11
17
  const { send_infoarch_page } = require("../markup/admin.js");
12
18
 
19
+ /**
20
+ * @type {object}
21
+ * @const
22
+ * @namespace searchRouter
23
+ * @category server
24
+ * @subcategory routes
25
+ */
13
26
  const router = new Router();
14
27
  module.exports = router;
15
28
 
29
+ /**
30
+ * @param {object[]} tables
31
+ * @param {object[]} views
32
+ * @param {object} req
33
+ * @returns {Forms}
34
+ */
16
35
  const searchConfigForm = (tables, views, req) => {
17
36
  var fields = [];
18
37
  var tbls_noviews = [];
@@ -48,6 +67,12 @@ const searchConfigForm = (tables, views, req) => {
48
67
  });
49
68
  };
50
69
 
70
+ /**
71
+ * @name get/config
72
+ * @function
73
+ * @memberof module:routes/search~searchRouter
74
+ * @function
75
+ */
51
76
  router.get(
52
77
  "/config",
53
78
  setTenant,
@@ -70,6 +95,13 @@ router.get(
70
95
  })
71
96
  );
72
97
 
98
+
99
+ /**
100
+ * @name post/config
101
+ * @function
102
+ * @memberof module:routes/search~searchRouter
103
+ * @function
104
+ */
73
105
  router.post(
74
106
  "/config",
75
107
  setTenant,
@@ -98,6 +130,9 @@ router.post(
98
130
  })
99
131
  );
100
132
 
133
+ /**
134
+ * @returns {Form}
135
+ */
101
136
  const searchForm = () =>
102
137
  new Form({
103
138
  action: "/search",
@@ -113,6 +148,16 @@ const searchForm = () =>
113
148
  ],
114
149
  });
115
150
 
151
+ /**
152
+ * @param {object} opts
153
+ * @param {*} opts.q
154
+ * @param {*} opts._page
155
+ * @param {*} opts.table
156
+ * @param {object} opts
157
+ * @param {object} req
158
+ * @param {object} res
159
+ * @returns {Promise<void>}
160
+ */
116
161
  const runSearch = async ({ q, _page, table }, req, res) => {
117
162
  const role = (req.user || {}).role_id || 10;
118
163
  const cfg = getState().getConfig("globalSearch");
@@ -200,6 +245,12 @@ const runSearch = async ({ q, _page, table }, req, res) => {
200
245
  });
201
246
  };
202
247
 
248
+ /**
249
+ * @name get
250
+ * @function
251
+ * @memberof module:routes/search~searchRouter
252
+ * @function
253
+ */
203
254
  router.get(
204
255
  "/",
205
256
  setTenant,
@@ -1,10 +1,31 @@
1
+ /**
2
+ * @category server
3
+ * @module routes/settings
4
+ * @subcategory routes
5
+ */
6
+
1
7
  const Router = require("express-promise-router");
2
8
  const { i, h3, p, a } = require("@saltcorn/markup/tags");
3
9
  const { setTenant, isAdmin, error_catcher } = require("./utils.js");
4
10
 
11
+ /**
12
+ * @type {object}
13
+ * @const
14
+ * @namespace settingsRouter
15
+ * @category server
16
+ * @subcategory routes
17
+ */
5
18
  const router = new Router();
6
19
  module.exports = router;
7
20
 
21
+ /**
22
+ * @param {object} opts
23
+ * @param {string} opts.title
24
+ * @param {string} opts.icon
25
+ * @param {string} opts.blurb
26
+ * @param {string} opts.href
27
+ * @returns {object}
28
+ */
8
29
  const settingsCard = ({ title, icon, blurb, href }) => ({
9
30
  type: "card",
10
31
  url: href,
@@ -17,6 +38,12 @@ const settingsCard = ({ title, icon, blurb, href }) => ({
17
38
  },
18
39
  });
19
40
 
41
+ /**
42
+ * @name get
43
+ * @function
44
+ * @memberof module:routes/settings~settingsRouter
45
+ * @function
46
+ */
20
47
  router.get(
21
48
  "/",
22
49
  setTenant,