@ozdao/prometheus-framework 0.2.126 → 0.2.127

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. package/dist/auth.server.js +61 -2
  2. package/dist/auth.server.mjs +61 -2
  3. package/dist/gallery.server.js +55 -3
  4. package/dist/gallery.server.mjs +55 -3
  5. package/dist/main-CF35oB7q.js +92 -0
  6. package/dist/main-CmL_j3wv.mjs +14223 -0
  7. package/dist/organizations.server.js +112 -184
  8. package/dist/organizations.server.mjs +112 -184
  9. package/dist/prometheus-framework/src/components/Block/Block.vue.cjs +1 -1
  10. package/dist/prometheus-framework/src/components/Block/Block.vue.js +1 -1
  11. package/dist/prometheus-framework/src/components/Button/Button.vue.cjs +1 -1
  12. package/dist/prometheus-framework/src/components/Button/Button.vue.js +1 -94
  13. package/dist/prometheus-framework/src/components/Button/Button.vue2.cjs +1 -1
  14. package/dist/prometheus-framework/src/components/Button/Button.vue2.js +94 -1
  15. package/dist/prometheus-framework/src/components/Field/Field.vue.cjs +1 -1
  16. package/dist/prometheus-framework/src/components/Field/Field.vue.js +1 -84
  17. package/dist/prometheus-framework/src/components/Field/Field.vue2.cjs +1 -1
  18. package/dist/prometheus-framework/src/components/Field/Field.vue2.js +84 -1
  19. package/dist/prometheus-framework/src/components/FieldBig/FieldBig.vue.cjs +1 -1
  20. package/dist/prometheus-framework/src/components/FieldBig/FieldBig.vue.js +1 -1
  21. package/dist/prometheus-framework/src/components/Popup/Popup.vue.cjs +1 -1
  22. package/dist/prometheus-framework/src/components/Popup/Popup.vue.js +1 -77
  23. package/dist/prometheus-framework/src/components/Popup/Popup.vue2.cjs +1 -1
  24. package/dist/prometheus-framework/src/components/Popup/Popup.vue2.js +77 -1
  25. package/dist/prometheus-framework/src/components/Tooltip/Tooltip.vue.cjs +1 -1
  26. package/dist/prometheus-framework/src/components/Tooltip/Tooltip.vue.js +1 -45
  27. package/dist/prometheus-framework/src/components/Tooltip/Tooltip.vue2.cjs +1 -1
  28. package/dist/prometheus-framework/src/components/Tooltip/Tooltip.vue2.js +45 -1
  29. package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.cjs +1 -1
  30. package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.js +2 -2
  31. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterCode.vue.cjs +1 -1
  32. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterCode.vue.js +1 -1
  33. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.cjs +1 -1
  34. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.js +2 -2
  35. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.cjs +1 -1
  36. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.js +2 -2
  37. package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.cjs +1 -1
  38. package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.js +2 -2
  39. package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.cjs +1 -1
  40. package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.js +2 -2
  41. package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.cjs +1 -1
  42. package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.js +2 -2
  43. package/dist/prometheus-framework/src/modules/auth/store/auth.cjs +1 -1
  44. package/dist/prometheus-framework/src/modules/auth/store/auth.js +57 -50
  45. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.cjs +1 -1
  46. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.js +68 -62
  47. package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.cjs +1 -1
  48. package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.js +2 -2
  49. package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.cjs +1 -1
  50. package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.js +3 -3
  51. package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.cjs +1 -1
  52. package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.js +1 -1
  53. package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.cjs +1 -1
  54. package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.js +1 -1
  55. package/dist/prometheus-framework/src/modules/events/components/elements/ButtonCheck.vue.cjs +1 -1
  56. package/dist/prometheus-framework/src/modules/events/components/elements/ButtonCheck.vue.js +2 -2
  57. package/dist/prometheus-framework/src/modules/events/components/elements/ButtonJoin.vue.cjs +1 -1
  58. package/dist/prometheus-framework/src/modules/events/components/elements/ButtonJoin.vue.js +1 -1
  59. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.cjs +1 -1
  60. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.js +3 -3
  61. package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue.cjs +1 -1
  62. package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue.js +3 -3
  63. package/dist/prometheus-framework/src/modules/gallery/components/pages/Gallery.vue.cjs +1 -1
  64. package/dist/prometheus-framework/src/modules/gallery/components/pages/Gallery.vue.js +1 -1
  65. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +1 -1
  66. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.js +3 -3
  67. package/dist/prometheus-framework/src/modules/gallery/gallery.client.cjs +1 -1
  68. package/dist/prometheus-framework/src/modules/gallery/gallery.client.js +4 -4
  69. package/dist/prometheus-framework/src/modules/globals/components/blocks/BlockSearch.vue.cjs +1 -1
  70. package/dist/prometheus-framework/src/modules/globals/components/blocks/BlockSearch.vue.js +1 -1
  71. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.cjs +1 -1
  72. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.js +2 -2
  73. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.cjs +1 -1
  74. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.js +2 -2
  75. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderBackoffice.vue.cjs +1 -1
  76. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderBackoffice.vue.js +1 -1
  77. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.cjs +1 -1
  78. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.js +3 -3
  79. package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.cjs +1 -1
  80. package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.js +2 -2
  81. package/dist/prometheus-framework/src/modules/orders/components/sections/FormCustomerDetails.vue.cjs +1 -1
  82. package/dist/prometheus-framework/src/modules/orders/components/sections/FormCustomerDetails.vue.js +1 -1
  83. package/dist/prometheus-framework/src/modules/orders/components/sections/FormDelivery.vue.cjs +1 -1
  84. package/dist/prometheus-framework/src/modules/orders/components/sections/FormDelivery.vue.js +1 -1
  85. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardDepartment.vue.cjs +1 -1
  86. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardDepartment.vue.js +14 -14
  87. package/dist/prometheus-framework/src/modules/organizations/components/elements/ButtonToggleMembership.vue.cjs +1 -1
  88. package/dist/prometheus-framework/src/modules/organizations/components/elements/ButtonToggleMembership.vue.js +1 -1
  89. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.cjs +1 -1
  90. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.js +116 -94
  91. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
  92. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.js +3 -3
  93. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.cjs +1 -1
  94. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.js +3 -3
  95. package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.cjs +1 -1
  96. package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.js +3 -3
  97. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
  98. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.js +2 -2
  99. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
  100. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.js +3 -3
  101. package/dist/prometheus-framework/src/modules/organizations/store/departments.cjs +1 -1
  102. package/dist/prometheus-framework/src/modules/organizations/store/departments.js +9 -4
  103. package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.cjs +1 -1
  104. package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.js +1 -1
  105. package/dist/prometheus-framework/src/modules/products/components/blocks/ImagesThumbnails.vue.cjs +1 -1
  106. package/dist/prometheus-framework/src/modules/products/components/blocks/ImagesThumbnails.vue.js +1 -1
  107. package/dist/prometheus-framework/src/modules/products/components/blocks/LeftoverPositions.vue.cjs +1 -1
  108. package/dist/prometheus-framework/src/modules/products/components/blocks/LeftoverPositions.vue.js +1 -1
  109. package/dist/prometheus-framework/src/modules/products/components/blocks/ListPositions.vue.cjs +1 -1
  110. package/dist/prometheus-framework/src/modules/products/components/blocks/ListPositions.vue.js +1 -1
  111. package/dist/prometheus-framework/src/modules/products/components/pages/Categories.vue.cjs +1 -1
  112. package/dist/prometheus-framework/src/modules/products/components/pages/Categories.vue.js +1 -1
  113. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.cjs +1 -1
  114. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.js +2 -2
  115. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.cjs +1 -1
  116. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.js +2 -2
  117. package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.cjs +1 -1
  118. package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.js +3 -3
  119. package/dist/prometheus-framework/src/modules/products/components/sections/EditModifications.vue.cjs +1 -1
  120. package/dist/prometheus-framework/src/modules/products/components/sections/EditModifications.vue.js +1 -1
  121. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.cjs +1 -1
  122. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.js +2 -2
  123. package/dist/prometheus-framework/src/modules/products/components/sections/SectionProduct.vue.cjs +1 -1
  124. package/dist/prometheus-framework/src/modules/products/components/sections/SectionProduct.vue.js +1 -1
  125. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.cjs +1 -1
  126. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.js +2 -2
  127. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.cjs +1 -1
  128. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.js +2 -2
  129. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.cjs +1 -1
  130. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.js +2 -2
  131. package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.cjs +1 -1
  132. package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.js +3 -3
  133. package/dist/prometheus-framework.cjs.js +1 -1
  134. package/dist/prometheus-framework.es.js +1 -1
  135. package/dist/style.css +1 -1
  136. package/dist/web-BDaOF322.js +1 -0
  137. package/dist/web-DtWmpLE-.mjs +54 -0
  138. package/package.json +1 -1
  139. package/src/modules/auth/controllers/auth.controller.js +68 -2
  140. package/src/modules/auth/routes/auth.routes.js +8 -1
  141. package/src/modules/auth/store/auth.js +21 -9
  142. package/src/modules/backoffice/components/pages/Dashboard.vue +6 -0
  143. package/src/modules/gallery/gallery.client.js +1 -1
  144. package/src/modules/gallery/routes/gallery.routes.js +7 -3
  145. package/src/modules/globals/mixins/mixins.js +17 -0
  146. package/src/modules/middlewares/server/verifyAccesses.js +100 -23
  147. package/src/modules/organizations/components/blocks/CardDepartment.vue +1 -1
  148. package/src/modules/organizations/components/pages/DepartmentEdit.vue +24 -2
  149. package/src/modules/organizations/components/pages/Members.vue +1 -1
  150. package/src/modules/organizations/models/department.model.js +42 -2
  151. package/src/modules/organizations/routes/departments.routes.js +1 -8
  152. package/src/modules/organizations/store/departments.js +5 -0
@@ -15,17 +15,17 @@ const ownership_schema = require("./ownership.schema-DN0SlQL6.js");
15
15
  const credentials_schema = require("./credentials.schema-B-KD_ozQ.js");
16
16
  const controllerFactory$6 = (db) => {
17
17
  const Department = db.department;
18
- const readOne = (req, res2) => {
18
+ const readOne = (req, res) => {
19
19
  Department.findOne({ _id: req.params._id }).populate("members.user").populate("subdepartments").then((department) => {
20
20
  if (!department) {
21
- return res2.status(404).send({ message: "Отдел не найден" });
21
+ return res.status(404).send({ message: "Отдел не найден" });
22
22
  }
23
- res2.send(department);
23
+ res.send(department);
24
24
  }).catch((err) => {
25
- res2.status(500).send({ message: err.message });
25
+ res.status(500).send({ message: err.message });
26
26
  });
27
27
  };
28
- const read = (req, res2) => {
28
+ const read = (req, res) => {
29
29
  let query = {};
30
30
  let options = {};
31
31
  if (req.query.organization) {
@@ -36,43 +36,43 @@ const controllerFactory$6 = (db) => {
36
36
  }
37
37
  Department.find(query, null, options).populate("members.user").populate("subdepartments").then((departments) => {
38
38
  if (!departments) {
39
- return res2.status(404).send({ message: "Departments not found" });
39
+ return res.status(404).send({ message: "Departments not found" });
40
40
  }
41
- res2.send(departments);
41
+ res.send(departments);
42
42
  }).catch((err) => {
43
- res2.status(500).send({ message: err.message });
43
+ res.status(500).send({ message: err.message });
44
44
  });
45
45
  };
46
- const create = async (req, res2) => {
46
+ const create = async (req, res) => {
47
47
  try {
48
48
  const newDepartment = new Department({
49
49
  ...req.body,
50
50
  organization: req.params._id
51
51
  });
52
52
  const data = await newDepartment.save();
53
- res2.send(data);
53
+ res.send(data);
54
54
  } catch (err) {
55
- res2.status(500).send({ message: err.message });
55
+ res.status(500).send({ message: err.message });
56
56
  }
57
57
  };
58
- const update = (req, res2) => {
58
+ const update = (req, res) => {
59
59
  Department.findOneAndUpdate({ _id: req.body._id }, req.body, { new: true }).then((department) => {
60
60
  if (!department) {
61
- return res2.status(404).send({ message: "Department not found" });
61
+ return res.status(404).send({ message: "Department not found" });
62
62
  }
63
- res2.send(department);
63
+ res.send(department);
64
64
  }).catch((err) => {
65
- res2.status(500).send({ message: err.message });
65
+ res.status(500).send({ message: err.message });
66
66
  });
67
67
  };
68
- const deleteDepartment = (req, res2) => {
68
+ const deleteDepartment = (req, res) => {
69
69
  Department.findOneAndRemove({ _id: req.body._id, organization: req.params._id }).then((department) => {
70
70
  if (!department) {
71
- return res2.status(404).send({ message: "Department not found" });
71
+ return res.status(404).send({ message: "Department not found" });
72
72
  }
73
- res2.send({ message: "Department deleted successfully" });
73
+ res.send({ message: "Department deleted successfully" });
74
74
  }).catch((err) => {
75
- res2.status(500).send({ message: err.message });
75
+ res.status(500).send({ message: err.message });
76
76
  });
77
77
  };
78
78
  return {
@@ -95,7 +95,7 @@ const controllerFactory$5 = (db) => {
95
95
  const Membership = db.membership;
96
96
  db.user;
97
97
  db.role;
98
- const read = async (req, res2) => {
98
+ const read = async (req, res) => {
99
99
  const sortParam = req.query.sortParam || "numberOfProducts";
100
100
  const sortOrder = req.query.sortOrder || "desc";
101
101
  const sort = {
@@ -175,11 +175,11 @@ const controllerFactory$5 = (db) => {
175
175
  ];
176
176
  console.log(userLocation);
177
177
  } else {
178
- return res2.status(400).send({ message: "Unable to geocode the provided location." });
178
+ return res.status(400).send({ message: "Unable to geocode the provided location." });
179
179
  }
180
180
  } catch (err) {
181
181
  console.log(err);
182
- return res2.status(500).send({ message: "Error occurred while geocoding." });
182
+ return res.status(500).send({ message: "Error occurred while geocoding." });
183
183
  }
184
184
  const radius = city ? 500 : state ? 1e3 : 5e3;
185
185
  matchConditions.push({
@@ -349,13 +349,13 @@ const controllerFactory$5 = (db) => {
349
349
  try {
350
350
  console.log(stages);
351
351
  const organizations = await Organization.aggregate(stages);
352
- res2.status(200).send(organizations);
352
+ res.status(200).send(organizations);
353
353
  } catch (err) {
354
354
  console.log(err);
355
- return res2.status(500).send({ message: err });
355
+ return res.status(500).send({ message: err });
356
356
  }
357
357
  };
358
- const fetch = async (req, res2) => {
358
+ const fetch = async (req, res) => {
359
359
  const Organization2 = db.organization;
360
360
  let query = {};
361
361
  console.log(req.query);
@@ -374,14 +374,14 @@ const controllerFactory$5 = (db) => {
374
374
  try {
375
375
  const organizations = await Organization2.find(query, null, options);
376
376
  if (!organizations || organizations.length === 0) {
377
- return res2.status(404).send({ message: "Organizations not found." });
377
+ return res.status(404).send({ message: "Organizations not found." });
378
378
  }
379
- res2.status(200).send(organizations);
379
+ res.status(200).send(organizations);
380
380
  } catch (err) {
381
- return res2.status(500).send({ message: err });
381
+ return res.status(500).send({ message: err });
382
382
  }
383
383
  };
384
- const create = async (req, res2) => {
384
+ const create = async (req, res) => {
385
385
  if (req.body._id === null) {
386
386
  delete req.body._id;
387
387
  }
@@ -396,13 +396,13 @@ const controllerFactory$5 = (db) => {
396
396
  label: "owner"
397
397
  });
398
398
  const savedMembership = await membership.save();
399
- res2.status(201).json(savedOrganization);
399
+ res.status(201).json(savedOrganization);
400
400
  } catch (error) {
401
401
  console.error("Error:", error);
402
- res2.status(500).send(error);
402
+ res.status(500).send(error);
403
403
  }
404
404
  };
405
- const update = async (req, res2) => {
405
+ const update = async (req, res) => {
406
406
  try {
407
407
  const organizationId = req.params._id;
408
408
  const updatedData = req.body;
@@ -411,17 +411,17 @@ const controllerFactory$5 = (db) => {
411
411
  runValidators: true
412
412
  });
413
413
  if (!organization) {
414
- return res2.status(404).json({ message: "Organization not found" });
414
+ return res.status(404).json({ message: "Organization not found" });
415
415
  }
416
- res2.status(200).json({ message: "Organization updated successfully", organization });
416
+ res.status(200).json({ message: "Organization updated successfully", organization });
417
417
  } catch (error) {
418
- res2.status(500).json({ error: error.message });
418
+ res.status(500).json({ error: error.message });
419
419
  }
420
420
  };
421
- const deleteOrganization = async (req, res2) => {
421
+ const deleteOrganization = async (req, res) => {
422
422
  Organization.findOneAndRemove({ _id: req.params._id }).then((organization) => {
423
423
  if (!organization) {
424
- return res2.status(404).send({ message: "Organization not found" });
424
+ return res.status(404).send({ message: "Organization not found" });
425
425
  }
426
426
  Membership.deleteMany({ target: req.params._id }).then(() => {
427
427
  const newToken = jwt.sign({
@@ -431,12 +431,12 @@ const controllerFactory$5 = (db) => {
431
431
  expiresIn: 86400
432
432
  // 24 hours
433
433
  });
434
- res2.send({ newToken });
434
+ res.send({ newToken });
435
435
  }).catch((err) => {
436
- res2.status(500).send({ message: "Error deleting memberships: " + err.message });
436
+ res.status(500).send({ message: "Error deleting memberships: " + err.message });
437
437
  });
438
438
  }).catch((err) => {
439
- res2.status(500).send({ message: err.message });
439
+ res.status(500).send({ message: err.message });
440
440
  });
441
441
  };
442
442
  return {
@@ -453,7 +453,7 @@ const ObjectId = require$$0.Types.ObjectId;
453
453
  const queryProcessorGlobals = queryProcessor.queryProcessor;
454
454
  const controllerFactory$4 = (db) => {
455
455
  const Membership = db.membership;
456
- const read = async (req, res2) => {
456
+ const read = async (req, res) => {
457
457
  try {
458
458
  let search = req.query.search;
459
459
  let regexPattern = "";
@@ -504,16 +504,16 @@ const controllerFactory$4 = (db) => {
504
504
  )
505
505
  ]);
506
506
  if (!memberships || memberships.length === 0) {
507
- return res2.status(404).send({ errorCode: "MEMBERSHIPS_NOT_FOUND" });
507
+ return res.status(404).send({ errorCode: "MEMBERSHIPS_NOT_FOUND" });
508
508
  }
509
509
  console.log("membership is", memberships[0].user);
510
- res2.send(memberships);
510
+ res.send(memberships);
511
511
  } catch (err) {
512
512
  console.log(err);
513
- res2.status(500).send({ errorCode: "SERVER_ERROR" });
513
+ res.status(500).send({ errorCode: "SERVER_ERROR" });
514
514
  }
515
515
  };
516
- const create = async (req, res2) => {
516
+ const create = async (req, res) => {
517
517
  const newMembership = new Membership({
518
518
  user: req.body.user,
519
519
  type: req.body.type,
@@ -522,35 +522,35 @@ const controllerFactory$4 = (db) => {
522
522
  });
523
523
  try {
524
524
  const data = await newMembership.save();
525
- res2.send(data);
525
+ res.send(data);
526
526
  } catch (err) {
527
- res2.status(500).send({ errorCode: "SERVER_ERROR" });
527
+ res.status(500).send({ errorCode: "SERVER_ERROR" });
528
528
  }
529
529
  };
530
- const update = async (req, res2) => {
530
+ const update = async (req, res) => {
531
531
  try {
532
532
  const membership = await Membership.findByIdAndUpdate(req.body._id, req.body, { new: true });
533
533
  if (!membership) {
534
- return res2.status(404).send({ errorCode: "MEMBERSHIP_NOT_FOUND" });
534
+ return res.status(404).send({ errorCode: "MEMBERSHIP_NOT_FOUND" });
535
535
  }
536
- res2.send(membership);
536
+ res.send(membership);
537
537
  } catch (err) {
538
- res2.status(500).send({ errorCode: "SERVER_ERROR" });
538
+ res.status(500).send({ errorCode: "SERVER_ERROR" });
539
539
  }
540
540
  };
541
- const deleteMembership = async (req, res2) => {
541
+ const deleteMembership = async (req, res) => {
542
542
  console.log(req.body);
543
543
  try {
544
544
  const membership = await Membership.findOneAndDelete({ _id: new ObjectId(req.body._id) });
545
545
  if (!membership) {
546
- return res2.status(404).send({ errorCode: "MEMBERSHIP_NOT_FOUND" });
546
+ return res.status(404).send({ errorCode: "MEMBERSHIP_NOT_FOUND" });
547
547
  } else {
548
548
  await Membership.deleteOne({ _id: membership._id });
549
- res2.status(200).send(membership);
549
+ res.status(200).send(membership);
550
550
  }
551
551
  } catch (error) {
552
552
  console.log(error);
553
- res2.status(500).send({ errorCode: "SERVER_ERROR" });
553
+ res.status(500).send({ errorCode: "SERVER_ERROR" });
554
554
  }
555
555
  };
556
556
  return {
@@ -567,29 +567,29 @@ const сontrollerFactory = (db) => {
567
567
  const User = db.user;
568
568
  const Invite = db.invite;
569
569
  const Membership = db.membership;
570
- const getOneByCode = async (req, res2) => {
570
+ const getOneByCode = async (req, res) => {
571
571
  try {
572
572
  const invite = await Invite.findOne({ code: req.params._id });
573
573
  if (!invite) {
574
- return res2.status(404).send({ message: "Приглашение не найдено" });
574
+ return res.status(404).send({ message: "Приглашение не найдено" });
575
575
  }
576
- res2.send(invite);
576
+ res.send(invite);
577
577
  } catch (err) {
578
- res2.status(500).send({ message: err.message });
578
+ res.status(500).send({ message: err.message });
579
579
  }
580
580
  };
581
- const read = async (req, res2) => {
581
+ const read = async (req, res) => {
582
582
  try {
583
583
  const invites = await Invite.find({ "owner.target": req.params._id });
584
584
  if (!invites || invites.length === 0) {
585
- return res2.status(200).send([]);
585
+ return res.status(200).send([]);
586
586
  }
587
- res2.send(invites);
587
+ res.send(invites);
588
588
  } catch (err) {
589
- res2.status(500).send({ message: err.message });
589
+ res.status(500).send({ message: err.message });
590
590
  }
591
591
  };
592
- const create = async (req, res2) => {
592
+ const create = async (req, res) => {
593
593
  const creator = req.body.creator;
594
594
  const owner = req.body.owner;
595
595
  const list = req.body.invites;
@@ -633,21 +633,21 @@ const сontrollerFactory = (db) => {
633
633
  }
634
634
  }
635
635
  }
636
- res2.status(200).json({ message: "Invites sent successfully!" });
636
+ res.status(200).json({ message: "Invites sent successfully!" });
637
637
  } catch (error) {
638
638
  console.error(error);
639
- res2.status(500).json({ message: "Something went wrong" });
639
+ res.status(500).json({ message: "Something went wrong" });
640
640
  }
641
641
  };
642
- const deleteInvite = async (req, res2) => {
642
+ const deleteInvite = async (req, res) => {
643
643
  try {
644
644
  const invite = await Invite.findOneAndDelete({ _id: req.params._id });
645
645
  if (!invite) {
646
- return res2.status(404).send({ message: "Invite not found" });
646
+ return res.status(404).send({ message: "Invite not found" });
647
647
  }
648
- res2.send({ message: "Invite deleted successfully" });
648
+ res.send({ message: "Invite deleted successfully" });
649
649
  } catch (err) {
650
- res2.status(500).send({ message: err.message });
650
+ res.status(500).send({ message: err.message });
651
651
  }
652
652
  };
653
653
  return {
@@ -658,125 +658,11 @@ const сontrollerFactory = (db) => {
658
658
  };
659
659
  };
660
660
  var invites_controller = сontrollerFactory;
661
- let AccessController$1 = class AccessController {
662
- db = null;
663
- rule = null;
664
- next = null;
665
- entity = null;
666
- /**
667
- * @param {String} rule - Права на проверку (read, create, ...)
668
- * @param {String} entity - Сущность на проверку (departments, post, ...)
669
- */
670
- check(rule, entity) {
671
- if (this.rule === rule && this.entity === entity) {
672
- return this.access.bind(this);
673
- } else if (this.next) {
674
- this.next.check(rule, entity);
675
- } else {
676
- console.error("Неудачная попытка вызова посредника verifyAccesses");
677
- console.error("Переданные аргументы:", this.rule, this.entity);
678
- return async (req, res2, next) => {
679
- return res2.status(403).send({ message: "Access Denied. Middleware not founded" });
680
- };
681
- }
682
- }
683
- };
684
- var AccessController_1 = AccessController$1;
685
- const AccessController2 = AccessController_1;
686
- let ReadDepartments$1 = class ReadDepartments extends AccessController2 {
687
- rule = "read";
688
- entity = "departments";
689
- async access(req, res2, next) {
690
- const Department = this.db.department;
691
- try {
692
- const userId = req.cookies.user._id;
693
- const organization = req.query.organization;
694
- const departments = await Department.find({
695
- organization: { $eq: organization },
696
- members: { $elemMatch: { user: userId } }
697
- });
698
- if (!departments.length) {
699
- return res2.status(403).send({
700
- message: "Access Denied. Read Departments. Департаменты не найдены"
701
- });
702
- }
703
- let hasAccess = false;
704
- departments.forEach((departament) => {
705
- const accesses = departament.accesses;
706
- if (getNestedProperty(accesses, rulePath)) {
707
- hasAccess = true;
708
- }
709
- });
710
- if (hasAccess) {
711
- next();
712
- } else {
713
- return res2.status(403).send({ message: "Access Denied. Read Departments. No access" });
714
- }
715
- } catch (error) {
716
- console.error("[canReadDepartments]", error);
717
- return res2.status(500).send({ message: error.message });
718
- }
719
- }
720
- /**
721
- * // note: пока не использовался метод
722
- * @param {Object} req объект
723
- * @returns
724
- */
725
- async departmentsWhereUserIsMember(req) {
726
- const Department = this.db.department;
727
- try {
728
- const userId = req.cookies.user._id;
729
- const organization = req.query.organization;
730
- const departments = await Department.find({
731
- organization: { $eq: organization },
732
- members: { $elemMatch: { user: userId } }
733
- });
734
- return departments;
735
- } catch (error) {
736
- console.error("[canReadDepartments]", error);
737
- return res.status(500).send({ message: error.message });
738
- }
739
- }
740
- };
741
- var ReadDepartments_1 = ReadDepartments$1;
742
- function getNestedProperty(obj, propertyPath) {
743
- const properties = propertyPath.split(".");
744
- let value = obj;
745
- for (const property of properties) {
746
- if (!value.hasOwnProperty(property)) {
747
- return void 0;
748
- }
749
- value = value[property];
750
- }
751
- return value;
752
- }
753
- const ReadDepartments2 = ReadDepartments_1;
754
- var verifyAccesses = (db) => {
755
- const instances = [];
756
- const middlewares = [
757
- ReadDepartments2
758
- ];
759
- let nextMiddleware = null;
760
- for (let i = middlewares.length - 1; i >= 0; i--) {
761
- const Middleware = middlewares[i];
762
- const middleware = new Middleware();
763
- middleware.db = db;
764
- middleware.next = nextMiddleware;
765
- instances.unshift(middleware);
766
- nextMiddleware = middleware;
767
- }
768
- return (rule, entity) => instances[0].check(rule, entity);
769
- };
770
661
  const controllerFactory$3 = departments_controller;
771
- const accessMiddlewaresFactory = verifyAccesses;
772
662
  var departments_routes = function(app, db) {
773
663
  const controller = controllerFactory$3(db);
774
- accessMiddlewaresFactory(db);
775
664
  app.get(
776
665
  "/api/departments/read",
777
- // [
778
- // verifyAccesses('read', 'departments'),
779
- // ],
780
666
  controller.read
781
667
  );
782
668
  app.get("/api/departments/get/:_id", controller.readOne);
@@ -878,6 +764,48 @@ var department_model = (mongoose) => {
878
764
  default: false
879
765
  },
880
766
  accesses: {
767
+ members: {
768
+ read: {
769
+ type: Boolean,
770
+ default: false
771
+ },
772
+ edit: {
773
+ type: Boolean,
774
+ default: false
775
+ },
776
+ delete: {
777
+ type: Boolean,
778
+ default: false
779
+ }
780
+ },
781
+ gallery: {
782
+ read: {
783
+ type: Boolean,
784
+ default: false
785
+ },
786
+ edit: {
787
+ type: Boolean,
788
+ default: false
789
+ },
790
+ delete: {
791
+ type: Boolean,
792
+ default: false
793
+ }
794
+ },
795
+ leftovers: {
796
+ read: {
797
+ type: Boolean,
798
+ default: false
799
+ },
800
+ edit: {
801
+ type: Boolean,
802
+ default: false
803
+ },
804
+ delete: {
805
+ type: Boolean,
806
+ default: false
807
+ }
808
+ },
881
809
  products: {
882
810
  read: {
883
811
  type: Boolean,