@saltcorn/server 0.6.2-beta.1 → 0.6.2-beta.2

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/routes/page.js CHANGED
@@ -10,11 +10,7 @@ const Page = require("@saltcorn/data/models/page");
10
10
  const { div, a, i } = require("@saltcorn/markup/tags");
11
11
  const { renderForm } = require("@saltcorn/markup");
12
12
  const { getState } = require("@saltcorn/data/db/state");
13
- const {
14
- setTenant,
15
- error_catcher,
16
- scan_for_page_title,
17
- } = require("../routes/utils.js");
13
+ const { error_catcher, scan_for_page_title } = require("../routes/utils.js");
18
14
  const { add_edit_bar } = require("../markup/admin.js");
19
15
  const { traverseSync } = require("@saltcorn/data/models/layout");
20
16
  const { run_action_column } = require("@saltcorn/data/plugin-helper");
@@ -38,7 +34,6 @@ module.exports = router;
38
34
  */
39
35
  router.get(
40
36
  "/:pagename",
41
- setTenant,
42
37
  error_catcher(async (req, res) => {
43
38
  const { pagename } = req.params;
44
39
 
@@ -76,7 +71,6 @@ router.get(
76
71
  */
77
72
  router.post(
78
73
  "/:pagename/action/:rndid",
79
- setTenant,
80
74
  error_catcher(async (req, res) => {
81
75
  const { pagename, rndid } = req.params;
82
76
  const role = req.isAuthenticated() ? req.user.role_id : 10;
@@ -20,7 +20,7 @@ const { getViews, traverseSync } = require("@saltcorn/data/models/layout");
20
20
  const { add_to_menu } = require("@saltcorn/data/models/pack");
21
21
  const db = require("@saltcorn/data/db");
22
22
 
23
- const { setTenant, isAdmin, error_catcher } = require("./utils.js");
23
+ const { isAdmin, error_catcher } = require("./utils.js");
24
24
  const {
25
25
  mkTable,
26
26
  renderForm,
@@ -46,9 +46,9 @@ const router = new Router();
46
46
  module.exports = router;
47
47
 
48
48
  /**
49
- * @param {object} page
50
- * @param {*} roles
51
- * @param {object} req
49
+ * @param {object} page
50
+ * @param {*} roles
51
+ * @param {object} req
52
52
  * @returns {Form}
53
53
  */
54
54
  const editPageRoleForm = (page, roles, req) =>
@@ -60,8 +60,8 @@ const editPageRoleForm = (page, roles, req) =>
60
60
  });
61
61
 
62
62
  /**
63
- * @param {object} page
64
- * @param {object} req
63
+ * @param {object} page
64
+ * @param {object} req
65
65
  * @returns {string}
66
66
  */
67
67
  const page_dropdown = (page, req) =>
@@ -101,8 +101,8 @@ const page_dropdown = (page, req) =>
101
101
  ]);
102
102
 
103
103
  /**
104
- *
105
- * @param {object} req
104
+ *
105
+ * @param {object} req
106
106
  * @returns {Promise<Form>}
107
107
  */
108
108
  const pagePropertiesForm = async (req) => {
@@ -146,9 +146,9 @@ const pagePropertiesForm = async (req) => {
146
146
  };
147
147
 
148
148
  /**
149
- *
150
- * @param {object} req
151
- * @param {object} context
149
+ *
150
+ * @param {object} req
151
+ * @param {object} context
152
152
  * @returns {Promise<object>}
153
153
  */
154
154
  const pageBuilderData = async (req, context) => {
@@ -225,9 +225,9 @@ const pageBuilderData = async (req, context) => {
225
225
  };
226
226
 
227
227
  /**
228
- * @param {*} rows
229
- * @param {*} roles
230
- * @param {object} req
228
+ * @param {*} rows
229
+ * @param {*} roles
230
+ * @param {object} req
231
231
  * @returns {div}
232
232
  */
233
233
  const getPageList = (rows, roles, req) => {
@@ -308,7 +308,6 @@ const getRootPageForm = (pages, roles, req) => {
308
308
  */
309
309
  router.get(
310
310
  "/",
311
- setTenant,
312
311
  isAdmin,
313
312
  error_catcher(async (req, res) => {
314
313
  const pages = await Page.find({}, { orderBy: "name" });
@@ -339,10 +338,10 @@ router.get(
339
338
  );
340
339
 
341
340
  /**
342
- * @param {*} contents
343
- * @param {*} noCard
344
- * @param {object} req
345
- * @param {*} page
341
+ * @param {*} contents
342
+ * @param {*} noCard
343
+ * @param {object} req
344
+ * @param {*} page
346
345
  * @returns {*}
347
346
  */
348
347
  const wrap = (contents, noCard, req, page) => ({
@@ -372,7 +371,6 @@ const wrap = (contents, noCard, req, page) => ({
372
371
  */
373
372
  router.get(
374
373
  "/edit-properties/:pagename",
375
- setTenant,
376
374
  isAdmin,
377
375
  error_catcher(async (req, res) => {
378
376
  const { pagename } = req.params;
@@ -401,7 +399,6 @@ router.get(
401
399
  */
402
400
  router.get(
403
401
  "/new",
404
- setTenant,
405
402
  isAdmin,
406
403
  error_catcher(async (req, res) => {
407
404
  const form = await pagePropertiesForm(req);
@@ -420,7 +417,6 @@ router.get(
420
417
  */
421
418
  router.post(
422
419
  "/edit-properties",
423
- setTenant,
424
420
  isAdmin,
425
421
  error_catcher(async (req, res) => {
426
422
  const form = await pagePropertiesForm(req);
@@ -456,7 +452,6 @@ router.post(
456
452
  */
457
453
  router.get(
458
454
  "/edit/:pagename",
459
- setTenant,
460
455
  isAdmin,
461
456
  error_catcher(async (req, res) => {
462
457
  const { pagename } = req.params;
@@ -498,7 +493,6 @@ router.get(
498
493
  */
499
494
  router.post(
500
495
  "/edit/:pagename",
501
- setTenant,
502
496
  isAdmin,
503
497
  error_catcher(async (req, res) => {
504
498
  const { pagename } = req.params;
@@ -529,7 +523,6 @@ router.post(
529
523
  */
530
524
  router.post(
531
525
  "/savebuilder/:id",
532
- setTenant,
533
526
  isAdmin,
534
527
  error_catcher(async (req, res) => {
535
528
  const { id } = req.params;
@@ -551,7 +544,6 @@ router.post(
551
544
  */
552
545
  router.post(
553
546
  "/delete/:id",
554
- setTenant,
555
547
  isAdmin,
556
548
  error_catcher(async (req, res) => {
557
549
  const { id } = req.params;
@@ -570,7 +562,6 @@ router.post(
570
562
  */
571
563
  router.post(
572
564
  "/set_root_page",
573
- setTenant,
574
565
  isAdmin,
575
566
  error_catcher(async (req, res) => {
576
567
  const pages = await Page.find({}, { orderBy: "name" });
@@ -598,7 +589,6 @@ router.post(
598
589
  */
599
590
  router.post(
600
591
  "/add-to-menu/:id",
601
- setTenant,
602
592
  isAdmin,
603
593
  error_catcher(async (req, res) => {
604
594
  const { id } = req.params;
@@ -628,7 +618,6 @@ router.post(
628
618
  */
629
619
  router.post(
630
620
  "/clone/:id",
631
- setTenant,
632
621
  isAdmin,
633
622
  error_catcher(async (req, res) => {
634
623
  const { id } = req.params;
@@ -650,7 +639,6 @@ router.post(
650
639
  */
651
640
  router.post(
652
641
  "/setrole/:id",
653
- setTenant,
654
642
  isAdmin,
655
643
  error_catcher(async (req, res) => {
656
644
  const { id } = req.params;
package/routes/plugins.js CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * Plugin Handler for Admin zone
3
- * @category server
3
+ * @category server
4
4
  * @module routes/plugins
5
5
  * @subcategory routes
6
6
  */
7
7
 
8
8
  const Router = require("express-promise-router");
9
- const { setTenant, isAdmin, error_catcher } = require("./utils.js");
9
+ const { isAdmin, error_catcher } = require("./utils.js");
10
10
  const {
11
11
  mkTable,
12
12
  renderForm,
@@ -189,8 +189,8 @@ const get_store_items = async () => {
189
189
  };
190
190
 
191
191
  /**
192
- * @param {object} req
193
- * @param {object} row
192
+ * @param {object} req
193
+ * @param {object} row
194
194
  * @returns {a|string}
195
195
  */
196
196
  const cfg_link = (req, row) => {
@@ -219,8 +219,8 @@ const cfg_link = (req, row) => {
219
219
  };
220
220
 
221
221
  /**
222
- * @param {object} req
223
- * @param {object} row
222
+ * @param {object} req
223
+ * @param {object} row
224
224
  * @returns {a}
225
225
  */
226
226
  const info_link = (req, row) =>
@@ -235,15 +235,15 @@ const info_link = (req, row) =>
235
235
  );
236
236
 
237
237
  /**
238
- * @param {string} title
238
+ * @param {string} title
239
239
  * @returns {span}
240
240
  */
241
- const badge = (title) =>
241
+ const badge = (title) =>
242
242
  span({ class: "badge badge-secondary plugin-store" }, title);
243
243
 
244
244
  /**
245
- *
246
- * @param {object} req
245
+ *
246
+ * @param {object} req
247
247
  * @returns {function}
248
248
  */
249
249
  const store_item_html = (req) => (item) => ({
@@ -334,7 +334,7 @@ const store_item_html = (req) => (item) => ({
334
334
  });
335
335
 
336
336
  /**
337
- * @param {object} req
337
+ * @param {object} req
338
338
  * @returns {ul}
339
339
  */
340
340
  const storeNavPills = (req) => {
@@ -365,8 +365,8 @@ const storeNavPills = (req) => {
365
365
  };
366
366
 
367
367
  /**
368
- * @param {object[]} items
369
- * @param {object} query
368
+ * @param {object[]} items
369
+ * @param {object} query
370
370
  * @returns {object[]}
371
371
  */
372
372
  const filter_items = (items, query) => {
@@ -376,8 +376,8 @@ const filter_items = (items, query) => {
376
376
  };
377
377
 
378
378
  /**
379
- * @param {string} s
380
- * @param {string} q
379
+ * @param {string} s
380
+ * @param {string} q
381
381
  * @returns {boolean}
382
382
  */
383
383
  const match_string = (s, q) => {
@@ -387,7 +387,7 @@ const match_string = (s, q) => {
387
387
 
388
388
  /**
389
389
  * @param {string} p
390
- * @param {string} q
390
+ * @param {string} q
391
391
  * @returns {boolean}
392
392
  */
393
393
  const satisfy_q = (p, q) => {
@@ -395,8 +395,8 @@ const satisfy_q = (p, q) => {
395
395
  };
396
396
 
397
397
  /**
398
- * @param {object[]} items
399
- * @param {object} query
398
+ * @param {object[]} items
399
+ * @param {object} query
400
400
  * @returns {object[]}
401
401
  */
402
402
  const filter_items_set = (items, query) => {
@@ -415,7 +415,7 @@ const filter_items_set = (items, query) => {
415
415
  };
416
416
 
417
417
  /**
418
- * @param {object} req
418
+ * @param {object} req
419
419
  * @returns {div}
420
420
  */
421
421
  const store_actions_dropdown = (req) =>
@@ -483,8 +483,8 @@ const store_actions_dropdown = (req) =>
483
483
  );
484
484
 
485
485
  /**
486
- * @param {object[]} items
487
- * @param {object} req
486
+ * @param {object[]} items
487
+ * @param {object} req
488
488
  * @returns {object}
489
489
  */
490
490
  const plugin_store_html = (items, req) => {
@@ -525,7 +525,6 @@ const plugin_store_html = (items, req) => {
525
525
  */
526
526
  router.get(
527
527
  "/",
528
- setTenant,
529
528
  isAdmin,
530
529
  error_catcher(async (req, res) => {
531
530
  const items = await get_store_items();
@@ -542,7 +541,6 @@ router.get(
542
541
  */
543
542
  router.get(
544
543
  "/configure/:name",
545
- setTenant,
546
544
  isAdmin,
547
545
  error_catcher(async (req, res) => {
548
546
  const { name } = req.params;
@@ -575,7 +573,6 @@ router.get(
575
573
  */
576
574
  router.post(
577
575
  "/configure/:name",
578
- setTenant,
579
576
  isAdmin,
580
577
  error_catcher(async (req, res) => {
581
578
  const { name } = req.params;
@@ -617,7 +614,6 @@ router.post(
617
614
  */
618
615
  router.get(
619
616
  "/new",
620
- setTenant,
621
617
  isAdmin,
622
618
  error_catcher(async (req, res) => {
623
619
  res.sendWrap(req.__(`New Plugin`), {
@@ -648,7 +644,6 @@ router.get(
648
644
  */
649
645
  router.get(
650
646
  "/public/:plugin/*",
651
- setTenant,
652
647
  error_catcher(async (req, res) => {
653
648
  const { plugin } = req.params;
654
649
  const filepath = req.params[0];
@@ -674,7 +669,6 @@ router.get(
674
669
  */
675
670
  router.get(
676
671
  "/pubdeps/:plugin/:dependency/:version/*",
677
- setTenant,
678
672
  error_catcher(async (req, res) => {
679
673
  const { plugin, dependency } = req.params;
680
674
  const filepath = req.params[0];
@@ -707,7 +701,6 @@ router.get(
707
701
  */
708
702
  router.get(
709
703
  "/info/:name",
710
- setTenant,
711
704
  isAdmin,
712
705
  error_catcher(async (req, res) => {
713
706
  const { name } = req.params;
@@ -816,7 +809,6 @@ router.get(
816
809
  */
817
810
  router.get(
818
811
  "/refresh",
819
- setTenant,
820
812
  isAdmin,
821
813
  error_catcher(async (req, res) => {
822
814
  await getState().deleteConfig(
@@ -840,7 +832,6 @@ router.get(
840
832
  */
841
833
  router.get(
842
834
  "/upgrade",
843
- setTenant,
844
835
  isAdmin,
845
836
  error_catcher(async (req, res) => {
846
837
  const installed_plugins = await Plugin.find({});
@@ -861,7 +852,6 @@ router.get(
861
852
  */
862
853
  router.get(
863
854
  "/upgrade-plugin/:name",
864
- setTenant,
865
855
  isAdmin,
866
856
  error_catcher(async (req, res) => {
867
857
  const { name } = req.params;
@@ -882,7 +872,6 @@ router.get(
882
872
  */
883
873
  router.post(
884
874
  "/",
885
- setTenant,
886
875
  isAdmin,
887
876
  error_catcher(async (req, res) => {
888
877
  const plugin = new Plugin(req.body);
@@ -918,7 +907,6 @@ router.post(
918
907
  */
919
908
  router.post(
920
909
  "/delete/:name",
921
- setTenant,
922
910
  isAdmin,
923
911
  error_catcher(async (req, res) => {
924
912
  const { name } = req.params;
@@ -954,7 +942,6 @@ router.post(
954
942
  */
955
943
  router.post(
956
944
  "/install/:name",
957
- setTenant,
958
945
  isAdmin,
959
946
  error_catcher(async (req, res) => {
960
947
  const { name } = req.params;