@ozdao/prometheus-framework 0.2.137 → 0.2.139

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. package/dist/auth.server.js +29 -14
  2. package/dist/auth.server.mjs +29 -14
  3. package/dist/community.server.js +3 -3
  4. package/dist/community.server.mjs +3 -3
  5. package/dist/events.server.js +3 -3
  6. package/dist/events.server.mjs +3 -3
  7. package/dist/files.server.js +3 -3
  8. package/dist/files.server.mjs +3 -3
  9. package/dist/gallery.server.js +4 -4
  10. package/dist/gallery.server.mjs +4 -4
  11. package/dist/index-DNI4aUP2.js +259 -0
  12. package/dist/index-Tcyehi73.mjs +260 -0
  13. package/dist/main-DTHFR7H_.mjs +14510 -0
  14. package/dist/main-wXdocsbd.js +92 -0
  15. package/dist/main.css +1 -1
  16. package/dist/orders.server.js +9 -8
  17. package/dist/orders.server.mjs +9 -8
  18. package/dist/organizations.server.js +32 -17
  19. package/dist/organizations.server.mjs +32 -17
  20. package/dist/products.server.js +37 -5
  21. package/dist/products.server.mjs +37 -5
  22. package/dist/prometheus-framework/src/components/Block/Block.vue.cjs +1 -1
  23. package/dist/prometheus-framework/src/components/Block/Block.vue.js +1 -1
  24. package/dist/prometheus-framework/src/components/Completion/Completion.vue.cjs +1 -1
  25. package/dist/prometheus-framework/src/components/Completion/Completion.vue.js +19 -19
  26. package/dist/prometheus-framework/src/components/Feed/Feed.vue.cjs +1 -1
  27. package/dist/prometheus-framework/src/components/Feed/Feed.vue.js +1 -1
  28. package/dist/prometheus-framework/src/components/Map/Map.vue.cjs +1 -1
  29. package/dist/prometheus-framework/src/components/Map/Map.vue.js +3 -2
  30. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.cjs +1 -1
  31. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.js +32 -31
  32. package/dist/prometheus-framework/src/modules/auth/store/auth.cjs +1 -1
  33. package/dist/prometheus-framework/src/modules/auth/store/auth.js +50 -47
  34. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.cjs +1 -1
  35. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.js +1 -1
  36. package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.cjs +1 -1
  37. package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.js +1 -1
  38. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.cjs +1 -1
  39. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.js +2 -2
  40. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.cjs +1 -1
  41. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.js +1 -1
  42. package/dist/prometheus-framework/src/modules/marketplace/store/marketplace.cjs +1 -1
  43. package/dist/prometheus-framework/src/modules/marketplace/store/marketplace.js +1 -1
  44. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.cjs +1 -1
  45. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.js +12 -12
  46. package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.cjs +1 -1
  47. package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.js +2 -2
  48. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardOrganization.vue.cjs +1 -1
  49. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardOrganization.vue.js +41 -38
  50. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
  51. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.js +123 -114
  52. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.cjs +1 -1
  53. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.js +51 -52
  54. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationBackoffice.vue.cjs +1 -1
  55. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationBackoffice.vue.js +1 -1
  56. package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.cjs +1 -1
  57. package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.js +16 -15
  58. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
  59. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.js +120 -60
  60. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
  61. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.js +1 -1
  62. package/dist/prometheus-framework/src/modules/organizations/store/invites.cjs +1 -1
  63. package/dist/prometheus-framework/src/modules/organizations/store/invites.js +25 -24
  64. package/dist/prometheus-framework/src/modules/spots/components/blocks/CardSpot.vue.cjs +1 -1
  65. package/dist/prometheus-framework/src/modules/spots/components/blocks/CardSpot.vue.js +7 -7
  66. package/dist/prometheus-framework/src/modules/spots/components/layouts/Spots.vue.cjs +1 -1
  67. package/dist/prometheus-framework/src/modules/spots/components/layouts/Spots.vue.js +3 -3
  68. package/dist/prometheus-framework/src/modules/spots/components/pages/Map.vue.cjs +1 -1
  69. package/dist/prometheus-framework/src/modules/spots/components/pages/Map.vue.js +65 -66
  70. package/dist/prometheus-framework/src/modules/spots/components/pages/SpotEdit.vue.cjs +1 -1
  71. package/dist/prometheus-framework/src/modules/spots/components/pages/SpotEdit.vue.js +81 -76
  72. package/dist/prometheus-framework/src/modules/spots/router/spots.cjs +1 -1
  73. package/dist/prometheus-framework/src/modules/spots/router/spots.js +1 -1
  74. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.cjs +1 -1
  75. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.js +2 -2
  76. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.cjs +1 -1
  77. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.js +78 -74
  78. package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.cjs +1 -1
  79. package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.js +2 -2
  80. package/dist/prometheus-framework.cjs.js +1 -1
  81. package/dist/prometheus-framework.es.js +1 -1
  82. package/dist/reports.server.js +0 -3
  83. package/dist/reports.server.mjs +0 -3
  84. package/dist/spots.server.js +3 -3
  85. package/dist/spots.server.mjs +3 -3
  86. package/dist/style.css +1 -1
  87. package/dist/wallet.server.js +5 -5
  88. package/dist/wallet.server.mjs +8 -8
  89. package/dist/web-Dh669DqQ.mjs +54 -0
  90. package/dist/web-Dt2RCU54.js +1 -0
  91. package/package.json +1 -1
  92. package/src/components/Completion/Completion.vue +29 -30
  93. package/src/components/Map/Map.vue +2 -2
  94. package/src/modules/auth/components/pages/Invite.vue +4 -2
  95. package/src/modules/auth/controllers/auth.controller.js +30 -12
  96. package/src/modules/auth/middlewares/authJwt.js +80 -0
  97. package/src/modules/{middlewares/server → auth/middlewares}/index.js +1 -3
  98. package/src/modules/{middlewares/server → auth/middlewares}/verifyAccesses.js +1 -1
  99. package/src/modules/auth/routes/auth.routes.js +2 -2
  100. package/src/modules/auth/routes/twofa.routes.js +1 -1
  101. package/src/modules/auth/store/auth.js +9 -0
  102. package/src/modules/chats/routes/chats.routes.js +1 -1
  103. package/src/modules/community/routes/blog.routes.js +2 -2
  104. package/src/modules/events/routes/events.routes.js +2 -2
  105. package/src/modules/files/routes/files.routes.js +2 -2
  106. package/src/modules/gallery/routes/gallery.routes.js +4 -5
  107. package/src/modules/globals/services/globals.crud.js +2 -2
  108. package/src/modules/marketplace/store/marketplace.js +1 -1
  109. package/src/modules/orders/components/pages/OrderCreateBackoffice.vue +2 -2
  110. package/src/modules/orders/components/sections/FormAddCustomer.vue +2 -2
  111. package/src/modules/orders/controllers/orders.controller.js +1 -0
  112. package/src/modules/orders/routes/applications.routes.js +2 -2
  113. package/src/modules/orders/routes/orders.routes.js +2 -2
  114. package/src/modules/organizations/components/blocks/CardOrganization.vue +9 -7
  115. package/src/modules/organizations/components/pages/Members.vue +26 -15
  116. package/src/modules/organizations/components/pages/Organization.vue +3 -3
  117. package/src/modules/organizations/components/sections/DetailsTab.vue +1 -1
  118. package/src/modules/organizations/components/sections/MembersAdd.vue +101 -43
  119. package/src/modules/organizations/controllers/invites.controller.js +18 -13
  120. package/src/modules/organizations/controllers/memberships.controller.js +18 -11
  121. package/src/modules/organizations/controllers/organizations.controller.js +3 -4
  122. package/src/modules/organizations/models/membership.model.js +2 -0
  123. package/src/modules/organizations/models/organization.model.js +4 -0
  124. package/src/modules/organizations/routes/invites.routes.js +2 -2
  125. package/src/modules/organizations/store/invites.js +2 -1
  126. package/src/modules/products/controllers/leftovers.controller.js +1 -1
  127. package/src/modules/products/middlewares/index.js +11 -0
  128. package/src/modules/products/routes/categories.routes.js +2 -2
  129. package/src/modules/reports/routes/reports.routes.js +2 -2
  130. package/src/modules/spots/components/blocks/CardSpot.vue +0 -1
  131. package/src/modules/spots/components/layouts/Spots.vue +2 -2
  132. package/src/modules/spots/components/pages/Map.vue +79 -78
  133. package/src/modules/spots/components/pages/SpotEdit.vue +8 -5
  134. package/src/modules/spots/controllers/spots.controller.js +1 -5
  135. package/src/modules/spots/router/spots.js +1 -1
  136. package/src/modules/users/components/pages/ProfileEdit.vue +37 -22
  137. package/src/modules/wallet/controllers/routes/payments.routes.js +2 -2
  138. package/src/modules/wallet/controllers/routes/rewards.routes.js +2 -2
  139. package/src/modules/middlewares/server/authJwt.js +0 -68
  140. /package/src/modules/{middlewares/server → auth/middlewares}/authSecret.js +0 -0
  141. /package/src/modules/{middlewares/server → auth/middlewares}/verifyInvites.js +0 -0
  142. /package/src/modules/{middlewares/server → auth/middlewares}/verifySignUp.js +0 -0
  143. /package/src/modules/{middlewares/server → auth/middlewares}/verifyUser.js +0 -0
  144. /package/src/modules/globals/services/{globals.cashe.js → globals.cache.js} +0 -0
  145. /package/src/modules/{middlewares/server → products/middlewares}/verifyCategory.js +0 -0
@@ -5,7 +5,7 @@ const profile_schema = require("./profile.schema-CkOhhf37.js");
5
5
  const credentials_schema = require("./credentials.schema-B-KD_ozQ.js");
6
6
  const queryProcessor = require("./queryProcessor-iewDZq_f.js");
7
7
  const mailing = require("./mailing-BX0q8DIs.js");
8
- const index = require("./index-CDbtWkBj.js");
8
+ const index = require("./index-DNI4aUP2.js");
9
9
  const require$$0 = require("node-cache");
10
10
  const applyOwnershipSchema$1 = ownership_schema.ownership_schema;
11
11
  var order_model = (db) => {
@@ -261,6 +261,7 @@ async function sendOrderMessage(orderData) {
261
261
  const controllerFactory$1 = (db) => {
262
262
  const Order = db.order;
263
263
  const Customer = db.customer;
264
+ const Leftover = db.leftover;
264
265
  const create = async (req, res) => {
265
266
  const orderData = req.body;
266
267
  req.userId || req.body.creator.target;
@@ -409,10 +410,10 @@ const controllerFactory$1 = (db) => {
409
410
  };
410
411
  var orders_controller = controllerFactory$1;
411
412
  const controllerFactory = orders_controller;
412
- const middlewareFactory = index.server;
413
+ const middlewareFactoryAuth = index.middlewares;
413
414
  var orders_routes = function(app, db, origins, publicPath) {
414
415
  const controller = controllerFactory(db);
415
- middlewareFactory(db);
416
+ middlewareFactoryAuth(db);
416
417
  app.post(
417
418
  "/api/orders/create",
418
419
  // [
@@ -441,7 +442,7 @@ var orders_routes = function(app, db, origins, publicPath) {
441
442
  };
442
443
  const NodeCache = require$$0;
443
444
  const stdTTL = 60 * 5;
444
- class Cache {
445
+ let Cache$1 = class Cache {
445
446
  constructor(ttlSeconds = stdTTL) {
446
447
  this.cache = new NodeCache({ stdTTL: ttlSeconds });
447
448
  }
@@ -457,8 +458,8 @@ class Cache {
457
458
  async flush() {
458
459
  this.cache.flushAll();
459
460
  }
460
- }
461
- var globals_cashe = Cache;
461
+ };
462
+ var globals_cache = Cache$1;
462
463
  let Logger$1 = class Logger {
463
464
  static logModel = null;
464
465
  constructor(db) {
@@ -494,12 +495,12 @@ let Logger$1 = class Logger {
494
495
  };
495
496
  var globals_logger = Logger$1;
496
497
  const globalsQuery = queryProcessor.queryProcessor;
497
- const Cashe = globals_cashe;
498
+ const Cache2 = globals_cache;
498
499
  const Logger2 = globals_logger;
499
500
  let CRUD$1 = class CRUD {
500
501
  constructor(basePath, app, db, model) {
501
502
  this.model = model;
502
- this.cache = new Cashe();
503
+ this.cache = new Cache2();
503
504
  this.logger = new Logger2(db);
504
505
  this.app = app;
505
506
  this.basePath = basePath;
@@ -4,7 +4,7 @@ import { p as profile_schema } from "./profile.schema-24ZpZQJe.mjs";
4
4
  import { c as credentials_schema } from "./credentials.schema-C9dmNy7o.mjs";
5
5
  import { q as queryProcessor } from "./queryProcessor-DQSFR9YA.mjs";
6
6
  import { m as mailing } from "./mailing-Cdp8NXhP.mjs";
7
- import { s as server } from "./index-C-8xOJnM.mjs";
7
+ import { m as middlewares } from "./index-Tcyehi73.mjs";
8
8
  import require$$0 from "node-cache";
9
9
  const applyOwnershipSchema$1 = ownership_schema;
10
10
  var order_model = (db) => {
@@ -260,6 +260,7 @@ async function sendOrderMessage(orderData) {
260
260
  const controllerFactory$1 = (db) => {
261
261
  const Order = db.order;
262
262
  const Customer = db.customer;
263
+ const Leftover = db.leftover;
263
264
  const create = async (req, res) => {
264
265
  const orderData = req.body;
265
266
  req.userId || req.body.creator.target;
@@ -408,10 +409,10 @@ const controllerFactory$1 = (db) => {
408
409
  };
409
410
  var orders_controller = controllerFactory$1;
410
411
  const controllerFactory = orders_controller;
411
- const middlewareFactory = server;
412
+ const middlewareFactoryAuth = middlewares;
412
413
  var orders_routes = function(app, db, origins, publicPath) {
413
414
  const controller = controllerFactory(db);
414
- middlewareFactory(db);
415
+ middlewareFactoryAuth(db);
415
416
  app.post(
416
417
  "/api/orders/create",
417
418
  // [
@@ -440,7 +441,7 @@ var orders_routes = function(app, db, origins, publicPath) {
440
441
  };
441
442
  const NodeCache = require$$0;
442
443
  const stdTTL = 60 * 5;
443
- class Cache {
444
+ let Cache$1 = class Cache {
444
445
  constructor(ttlSeconds = stdTTL) {
445
446
  this.cache = new NodeCache({ stdTTL: ttlSeconds });
446
447
  }
@@ -456,8 +457,8 @@ class Cache {
456
457
  async flush() {
457
458
  this.cache.flushAll();
458
459
  }
459
- }
460
- var globals_cashe = Cache;
460
+ };
461
+ var globals_cache = Cache$1;
461
462
  let Logger$1 = class Logger {
462
463
  static logModel = null;
463
464
  constructor(db) {
@@ -493,12 +494,12 @@ let Logger$1 = class Logger {
493
494
  };
494
495
  var globals_logger = Logger$1;
495
496
  const globalsQuery = queryProcessor;
496
- const Cashe = globals_cashe;
497
+ const Cache2 = globals_cache;
497
498
  const Logger2 = globals_logger;
498
499
  let CRUD$1 = class CRUD {
499
500
  constructor(basePath, app, db, model) {
500
501
  this.model = model;
501
- this.cache = new Cashe();
502
+ this.cache = new Cache2();
502
503
  this.logger = new Logger2(db);
503
504
  this.app = app;
504
505
  this.basePath = basePath;
@@ -9,7 +9,7 @@ const require$$5 = require("@googlemaps/google-maps-services-js");
9
9
  const addMembersQuantity$1 = require("./addMembersQuantity-B8UgqlUM.js");
10
10
  const queryProcessor = require("./queryProcessor-iewDZq_f.js");
11
11
  const mailing = require("./mailing-BX0q8DIs.js");
12
- const index = require("./index-CDbtWkBj.js");
12
+ const index = require("./index-DNI4aUP2.js");
13
13
  const engagement_schema = require("./engagement.schema-D-9md46B.js");
14
14
  const ownership_schema = require("./ownership.schema-DN0SlQL6.js");
15
15
  const credentials_schema = require("./credentials.schema-B-KD_ozQ.js");
@@ -101,7 +101,6 @@ const controllerFactory$5 = (db) => {
101
101
  const sort = {
102
102
  ...sortParam === "distance" ? { "distanceExist": -1 } : {},
103
103
  [sortParam]: sortOrder === "desc" ? -1 : 1,
104
- "numberOfProducts": -1,
105
104
  "_id": 1
106
105
  };
107
106
  console.log(sort);
@@ -179,7 +178,7 @@ const controllerFactory$5 = (db) => {
179
178
  console.log(err);
180
179
  return res.status(500).send({ message: "Error occurred while geocoding." });
181
180
  }
182
- const radius = city ? 500 : state ? 1e3 : 5e3;
181
+ const radius = city ? 25 : state ? 50 : 250;
183
182
  matchConditions.push({
184
183
  "spots.location.coordinates": {
185
184
  $geoWithin: {
@@ -212,9 +211,9 @@ const controllerFactory$5 = (db) => {
212
211
  if (locationRadius) {
213
212
  radius = parseFloat(locationRadius) / earthRadiusKm;
214
213
  } else if (city) {
215
- radius = 500 / earthRadiusKm;
214
+ radius = 25 / earthRadiusKm;
216
215
  } else if (state) {
217
- radius = 1e3 / earthRadiusKm;
216
+ radius = 50 / earthRadiusKm;
218
217
  } else {
219
218
  radius = null;
220
219
  }
@@ -451,6 +450,7 @@ const ObjectId = require$$0.Types.ObjectId;
451
450
  const queryProcessorGlobals = queryProcessor.queryProcessor;
452
451
  const controllerFactory$4 = (db) => {
453
452
  const Membership = db.membership;
453
+ const Department = db.department;
454
454
  const read = async (req, res) => {
455
455
  try {
456
456
  let search = req.query.search;
@@ -501,10 +501,9 @@ const controllerFactory$4 = (db) => {
501
501
  req.query.limit
502
502
  )
503
503
  ]);
504
- if (!memberships || memberships.length === 0) {
504
+ if (!memberships) {
505
505
  return res.status(404).send({ errorCode: "MEMBERSHIPS_NOT_FOUND" });
506
506
  }
507
- console.log("membership is", memberships[0].user);
508
507
  res.send(memberships);
509
508
  } catch (err) {
510
509
  console.log(err);
@@ -538,15 +537,18 @@ const controllerFactory$4 = (db) => {
538
537
  };
539
538
  const deleteMembership = async (req, res) => {
540
539
  const { _id, type, target, user: user2, role } = req.body;
541
- console.log(req.body);
542
540
  try {
543
- const membership = _id ? await Membership.findOneAndDelete({ _id: new ObjectId(req.body._id) }) : await Membership.findOne({ type, target, user: user2, role });
541
+ const membership = _id ? await Membership.findOneAndDelete({ _id: new ObjectId(_id) }) : await Membership.findOneAndDelete({ type, target, user: user2, role });
544
542
  if (!membership) {
545
543
  return res.status(404).send({ errorCode: "MEMBERSHIP_NOT_FOUND" });
546
- } else {
547
- await Membership.deleteOne({ _id: membership._id });
548
- res.status(200).send(membership);
549
544
  }
545
+ if (membership.type === "organization") {
546
+ await Department.updateMany(
547
+ { organization: target },
548
+ { $pull: { members: { user: user2 } } }
549
+ );
550
+ }
551
+ res.status(200).send(membership);
550
552
  } catch (error) {
551
553
  console.log(error);
552
554
  res.status(500).send({ errorCode: "SERVER_ERROR" });
@@ -592,9 +594,14 @@ const сontrollerFactory = (db) => {
592
594
  const creator = req.body.creator;
593
595
  const owner = req.body.owner;
594
596
  const list = req.body.invites;
597
+ const createdInvites = [];
598
+ const createdMemberships = [];
595
599
  try {
596
600
  for (let invite of list) {
597
601
  let user2 = null;
602
+ if (!invite || !invite.contact) {
603
+ continue;
604
+ }
598
605
  if (invite.contact.includes("@")) {
599
606
  user2 = await User.findOne({ email: invite.contact });
600
607
  } else {
@@ -608,7 +615,8 @@ const сontrollerFactory = (db) => {
608
615
  role: "member",
609
616
  label: "member"
610
617
  });
611
- await membership.save();
618
+ const savedMembership = await membership.save();
619
+ createdMemberships.push(savedMembership);
612
620
  } else {
613
621
  const newInvite = new Invite({
614
622
  code: uuid(),
@@ -619,10 +627,11 @@ const сontrollerFactory = (db) => {
619
627
  phone: !invite.contact.includes("@") ? invite.contact : null
620
628
  });
621
629
  const savedInvite = await newInvite.save();
630
+ createdInvites.push(savedInvite);
622
631
  if (savedInvite.email !== null) {
623
632
  const to = savedInvite.email;
624
633
  const subject = "You have been added to the organization";
625
- const text = `You have been invited to join an organization on ${process.env.APP_NAME}! Use this link to register: ${process.env.API_URL}/auth/invite?inviteCode=${newInvite.code}&type=email"`;
634
+ const text = `You have been invited to join an organization on ${process.env.APP_NAME}! Use this link to register: ${process.env.API_URL}/auth/invite?inviteCode=${newInvite.code}&type=email`;
626
635
  await sendEmail(to, subject, text);
627
636
  }
628
637
  if (savedInvite.phone !== null) {
@@ -632,7 +641,11 @@ const сontrollerFactory = (db) => {
632
641
  }
633
642
  }
634
643
  }
635
- res.status(200).json({ message: "Invites sent successfully!" });
644
+ res.status(200).json({
645
+ message: "Invites sent successfully!",
646
+ createdInvites,
647
+ createdMemberships
648
+ });
636
649
  } catch (error) {
637
650
  console.error(error);
638
651
  res.status(500).json({ message: "Something went wrong" });
@@ -710,10 +723,10 @@ var memberships_routes = function(app, db) {
710
723
  );
711
724
  };
712
725
  const controllerFactory = invites_controller;
713
- const middlewareFactory = index.server;
726
+ const middlewareFactoryAuth = index.middlewares;
714
727
  var invites_routes = function(app, db) {
715
728
  const controller = controllerFactory(db);
716
- const { verifyInvites } = middlewareFactory(db);
729
+ const { verifyInvites } = middlewareFactoryAuth(db);
717
730
  app.get(
718
731
  "/api/invites/get/:_id",
719
732
  controller.getOneByCode
@@ -943,6 +956,7 @@ var organization_model = (db) => {
943
956
  timestamps: true
944
957
  });
945
958
  applyEngagementSchema(OrganizationSchema);
959
+ OrganizationSchema.index({ _id: 1, owner: 1 });
946
960
  const Organization = db.mongoose.model("Organization", OrganizationSchema);
947
961
  return Organization;
948
962
  };
@@ -979,6 +993,7 @@ var membership_model = (mongoose) => {
979
993
  }, {
980
994
  timestamps: true
981
995
  });
996
+ MembershipSchema.index({ user: 1, target: 1 });
982
997
  const Membership = mongoose.model("Membership", MembershipSchema);
983
998
  return Membership;
984
999
  };
@@ -8,7 +8,7 @@ import require$$5 from "@googlemaps/google-maps-services-js";
8
8
  import { a as addUserStatusFields_1, b as addMembersQuantity_1 } from "./addMembersQuantity-BXp_LeQd.mjs";
9
9
  import { q as queryProcessor } from "./queryProcessor-DQSFR9YA.mjs";
10
10
  import { m as mailing } from "./mailing-Cdp8NXhP.mjs";
11
- import { s as server } from "./index-C-8xOJnM.mjs";
11
+ import { m as middlewares } from "./index-Tcyehi73.mjs";
12
12
  import { e as engagement_schema } from "./engagement.schema-CCdSLKd4.mjs";
13
13
  import { o as ownership_schema } from "./ownership.schema-oyx6eNkZ.mjs";
14
14
  import { c as credentials_schema } from "./credentials.schema-C9dmNy7o.mjs";
@@ -100,7 +100,6 @@ const controllerFactory$5 = (db) => {
100
100
  const sort = {
101
101
  ...sortParam === "distance" ? { "distanceExist": -1 } : {},
102
102
  [sortParam]: sortOrder === "desc" ? -1 : 1,
103
- "numberOfProducts": -1,
104
103
  "_id": 1
105
104
  };
106
105
  console.log(sort);
@@ -178,7 +177,7 @@ const controllerFactory$5 = (db) => {
178
177
  console.log(err);
179
178
  return res.status(500).send({ message: "Error occurred while geocoding." });
180
179
  }
181
- const radius = city ? 500 : state ? 1e3 : 5e3;
180
+ const radius = city ? 25 : state ? 50 : 250;
182
181
  matchConditions.push({
183
182
  "spots.location.coordinates": {
184
183
  $geoWithin: {
@@ -211,9 +210,9 @@ const controllerFactory$5 = (db) => {
211
210
  if (locationRadius) {
212
211
  radius = parseFloat(locationRadius) / earthRadiusKm;
213
212
  } else if (city) {
214
- radius = 500 / earthRadiusKm;
213
+ radius = 25 / earthRadiusKm;
215
214
  } else if (state) {
216
- radius = 1e3 / earthRadiusKm;
215
+ radius = 50 / earthRadiusKm;
217
216
  } else {
218
217
  radius = null;
219
218
  }
@@ -450,6 +449,7 @@ const ObjectId = require$$0.Types.ObjectId;
450
449
  const queryProcessorGlobals = queryProcessor;
451
450
  const controllerFactory$4 = (db) => {
452
451
  const Membership = db.membership;
452
+ const Department = db.department;
453
453
  const read = async (req, res) => {
454
454
  try {
455
455
  let search = req.query.search;
@@ -500,10 +500,9 @@ const controllerFactory$4 = (db) => {
500
500
  req.query.limit
501
501
  )
502
502
  ]);
503
- if (!memberships || memberships.length === 0) {
503
+ if (!memberships) {
504
504
  return res.status(404).send({ errorCode: "MEMBERSHIPS_NOT_FOUND" });
505
505
  }
506
- console.log("membership is", memberships[0].user);
507
506
  res.send(memberships);
508
507
  } catch (err) {
509
508
  console.log(err);
@@ -537,15 +536,18 @@ const controllerFactory$4 = (db) => {
537
536
  };
538
537
  const deleteMembership = async (req, res) => {
539
538
  const { _id, type, target, user: user2, role } = req.body;
540
- console.log(req.body);
541
539
  try {
542
- const membership = _id ? await Membership.findOneAndDelete({ _id: new ObjectId(req.body._id) }) : await Membership.findOne({ type, target, user: user2, role });
540
+ const membership = _id ? await Membership.findOneAndDelete({ _id: new ObjectId(_id) }) : await Membership.findOneAndDelete({ type, target, user: user2, role });
543
541
  if (!membership) {
544
542
  return res.status(404).send({ errorCode: "MEMBERSHIP_NOT_FOUND" });
545
- } else {
546
- await Membership.deleteOne({ _id: membership._id });
547
- res.status(200).send(membership);
548
543
  }
544
+ if (membership.type === "organization") {
545
+ await Department.updateMany(
546
+ { organization: target },
547
+ { $pull: { members: { user: user2 } } }
548
+ );
549
+ }
550
+ res.status(200).send(membership);
549
551
  } catch (error) {
550
552
  console.log(error);
551
553
  res.status(500).send({ errorCode: "SERVER_ERROR" });
@@ -591,9 +593,14 @@ const сontrollerFactory = (db) => {
591
593
  const creator = req.body.creator;
592
594
  const owner = req.body.owner;
593
595
  const list = req.body.invites;
596
+ const createdInvites = [];
597
+ const createdMemberships = [];
594
598
  try {
595
599
  for (let invite of list) {
596
600
  let user2 = null;
601
+ if (!invite || !invite.contact) {
602
+ continue;
603
+ }
597
604
  if (invite.contact.includes("@")) {
598
605
  user2 = await User.findOne({ email: invite.contact });
599
606
  } else {
@@ -607,7 +614,8 @@ const сontrollerFactory = (db) => {
607
614
  role: "member",
608
615
  label: "member"
609
616
  });
610
- await membership.save();
617
+ const savedMembership = await membership.save();
618
+ createdMemberships.push(savedMembership);
611
619
  } else {
612
620
  const newInvite = new Invite({
613
621
  code: uuid(),
@@ -618,10 +626,11 @@ const сontrollerFactory = (db) => {
618
626
  phone: !invite.contact.includes("@") ? invite.contact : null
619
627
  });
620
628
  const savedInvite = await newInvite.save();
629
+ createdInvites.push(savedInvite);
621
630
  if (savedInvite.email !== null) {
622
631
  const to = savedInvite.email;
623
632
  const subject = "You have been added to the organization";
624
- const text = `You have been invited to join an organization on ${process.env.APP_NAME}! Use this link to register: ${process.env.API_URL}/auth/invite?inviteCode=${newInvite.code}&type=email"`;
633
+ const text = `You have been invited to join an organization on ${process.env.APP_NAME}! Use this link to register: ${process.env.API_URL}/auth/invite?inviteCode=${newInvite.code}&type=email`;
625
634
  await sendEmail(to, subject, text);
626
635
  }
627
636
  if (savedInvite.phone !== null) {
@@ -631,7 +640,11 @@ const сontrollerFactory = (db) => {
631
640
  }
632
641
  }
633
642
  }
634
- res.status(200).json({ message: "Invites sent successfully!" });
643
+ res.status(200).json({
644
+ message: "Invites sent successfully!",
645
+ createdInvites,
646
+ createdMemberships
647
+ });
635
648
  } catch (error) {
636
649
  console.error(error);
637
650
  res.status(500).json({ message: "Something went wrong" });
@@ -709,10 +722,10 @@ var memberships_routes = function(app, db) {
709
722
  );
710
723
  };
711
724
  const controllerFactory = invites_controller;
712
- const middlewareFactory = server;
725
+ const middlewareFactoryAuth = middlewares;
713
726
  var invites_routes = function(app, db) {
714
727
  const controller = controllerFactory(db);
715
- const { verifyInvites } = middlewareFactory(db);
728
+ const { verifyInvites } = middlewareFactoryAuth(db);
716
729
  app.get(
717
730
  "/api/invites/get/:_id",
718
731
  controller.getOneByCode
@@ -942,6 +955,7 @@ var organization_model = (db) => {
942
955
  timestamps: true
943
956
  });
944
957
  applyEngagementSchema(OrganizationSchema);
958
+ OrganizationSchema.index({ _id: 1, owner: 1 });
945
959
  const Organization = db.mongoose.model("Organization", OrganizationSchema);
946
960
  return Organization;
947
961
  };
@@ -978,6 +992,7 @@ var membership_model = (mongoose) => {
978
992
  }, {
979
993
  timestamps: true
980
994
  });
995
+ MembershipSchema.index({ user: 1, target: 1 });
981
996
  const Membership = mongoose.model("Membership", MembershipSchema);
982
997
  return Membership;
983
998
  };
@@ -6,7 +6,6 @@ require("uuid");
6
6
  const require$$0 = require("mongoose");
7
7
  require("path");
8
8
  const require$$3 = require("openai");
9
- const index = require("./index-CDbtWkBj.js");
10
9
  const queryProcessor = require("./queryProcessor-iewDZq_f.js");
11
10
  var product_model = (mongoose) => {
12
11
  const ProductSchema = new mongoose.Schema({
@@ -803,11 +802,44 @@ const controllerFactory$3 = (db) => {
803
802
  };
804
803
  };
805
804
  var categories_controller = controllerFactory$3;
805
+ var verifyCategory;
806
+ var hasRequiredVerifyCategory;
807
+ function requireVerifyCategory() {
808
+ if (hasRequiredVerifyCategory) return verifyCategory;
809
+ hasRequiredVerifyCategory = 1;
810
+ const middlewareFactory = (db) => {
811
+ const Category = db.category;
812
+ const checkCategoryExistOrNot = async (req, res, next) => {
813
+ try {
814
+ const category = await Category.findOne({ url: req.body.url });
815
+ if (category) {
816
+ res.status(400).send({ message: "Failed! Category with this URL is already in use!" });
817
+ return;
818
+ }
819
+ next();
820
+ } catch (err) {
821
+ res.status(500).send({ message: err });
822
+ }
823
+ };
824
+ return {
825
+ checkCategoryExistOrNot
826
+ };
827
+ };
828
+ verifyCategory = middlewareFactory;
829
+ return verifyCategory;
830
+ }
831
+ const middlewareIndexFactory = (db) => {
832
+ const verifyCategory2 = requireVerifyCategory()(db);
833
+ return {
834
+ verifyCategory: verifyCategory2
835
+ };
836
+ };
837
+ var middlewares = middlewareIndexFactory;
806
838
  const controllerFactory$2 = categories_controller;
807
- const middlewareFactory = index.server;
839
+ const middlewareFactoryProducts = middlewares;
808
840
  var categories_routes = function(app, db) {
809
841
  const controller = controllerFactory$2(db);
810
- const { verifyCategory } = middlewareFactory(db);
842
+ const { verifyCategory: verifyCategory2 } = middlewareFactoryProducts(db);
811
843
  app.get(
812
844
  "/categories",
813
845
  controller.getCategories
@@ -823,7 +855,7 @@ var categories_routes = function(app, db) {
823
855
  app.post(
824
856
  "/categories/add",
825
857
  [
826
- verifyCategory.checkCategoryExistOrNot
858
+ verifyCategory2.checkCategoryExistOrNot
827
859
  ],
828
860
  controller.addCategory
829
861
  );
@@ -883,7 +915,7 @@ const controllerFactory$1 = (db) => {
883
915
  )
884
916
  ];
885
917
  const leftoveres = await Leftover.aggregate(stages).exec();
886
- if (!leftoveres.length) {
918
+ if (!leftoveres) {
887
919
  return res.status(404).send({ message: "LEFTOVERES_NOT_FOUND" });
888
920
  }
889
921
  res.status(200).send(leftoveres);
@@ -4,7 +4,6 @@ import "uuid";
4
4
  import require$$0 from "mongoose";
5
5
  import "path";
6
6
  import require$$3 from "openai";
7
- import { s as server } from "./index-C-8xOJnM.mjs";
8
7
  import { q as queryProcessor } from "./queryProcessor-DQSFR9YA.mjs";
9
8
  var product_model = (mongoose) => {
10
9
  const ProductSchema = new mongoose.Schema({
@@ -801,11 +800,44 @@ const controllerFactory$3 = (db) => {
801
800
  };
802
801
  };
803
802
  var categories_controller = controllerFactory$3;
803
+ var verifyCategory;
804
+ var hasRequiredVerifyCategory;
805
+ function requireVerifyCategory() {
806
+ if (hasRequiredVerifyCategory) return verifyCategory;
807
+ hasRequiredVerifyCategory = 1;
808
+ const middlewareFactory = (db) => {
809
+ const Category = db.category;
810
+ const checkCategoryExistOrNot = async (req, res, next) => {
811
+ try {
812
+ const category = await Category.findOne({ url: req.body.url });
813
+ if (category) {
814
+ res.status(400).send({ message: "Failed! Category with this URL is already in use!" });
815
+ return;
816
+ }
817
+ next();
818
+ } catch (err) {
819
+ res.status(500).send({ message: err });
820
+ }
821
+ };
822
+ return {
823
+ checkCategoryExistOrNot
824
+ };
825
+ };
826
+ verifyCategory = middlewareFactory;
827
+ return verifyCategory;
828
+ }
829
+ const middlewareIndexFactory = (db) => {
830
+ const verifyCategory2 = requireVerifyCategory()(db);
831
+ return {
832
+ verifyCategory: verifyCategory2
833
+ };
834
+ };
835
+ var middlewares = middlewareIndexFactory;
804
836
  const controllerFactory$2 = categories_controller;
805
- const middlewareFactory = server;
837
+ const middlewareFactoryProducts = middlewares;
806
838
  var categories_routes = function(app, db) {
807
839
  const controller = controllerFactory$2(db);
808
- const { verifyCategory } = middlewareFactory(db);
840
+ const { verifyCategory: verifyCategory2 } = middlewareFactoryProducts(db);
809
841
  app.get(
810
842
  "/categories",
811
843
  controller.getCategories
@@ -821,7 +853,7 @@ var categories_routes = function(app, db) {
821
853
  app.post(
822
854
  "/categories/add",
823
855
  [
824
- verifyCategory.checkCategoryExistOrNot
856
+ verifyCategory2.checkCategoryExistOrNot
825
857
  ],
826
858
  controller.addCategory
827
859
  );
@@ -881,7 +913,7 @@ const controllerFactory$1 = (db) => {
881
913
  )
882
914
  ];
883
915
  const leftoveres = await Leftover.aggregate(stages).exec();
884
- if (!leftoveres.length) {
916
+ if (!leftoveres) {
885
917
  return res.status(404).send({ message: "LEFTOVERES_NOT_FOUND" });
886
918
  }
887
919
  res.status(200).send(leftoveres);
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),i=require("../Tooltip/Tooltip.vue2.cjs"),a={class:"bg-light pd-medium radius-big"},c={key:0,class:"mn-b-small flex-v-center flex-nowrap flex"},s={key:0,class:"mn-r-thin t-medium p-big"},u=["onClick"],d=e.createElementVNode("p",{class:"bg-main radius-small t-center i-medium"},"i",-1),m={key:1,class:"w-100"},h={__name:"Block",props:{title:{type:String,default:null},tooltip:{type:String,default:null},actions:{type:Array,default:null},placeholder:{type:String,default:"Nothing here"},options:{type:Object,default:{theme:"white"}}},setup(t){e.useSlots();const r=(n,o={})=>n?n(o).some(l=>Array.isArray(l.children)?!!l.children.length:l.type!==e.Comment):!1;return(n,o)=>(e.openBlock(),e.createElementBlock("div",a,[t.title||t.actions?(e.openBlock(),e.createElementBlock("div",c,[t.title?(e.openBlock(),e.createElementBlock("p",s,e.toDisplayString(t.title),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.actions,l=>(e.openBlock(),e.createElementBlock("button",{onClick:l.function,class:e.normalizeClass(["pd-thin button-delete button",l.class||"bg-main radius-small t-center i-medium"])},e.toDisplayString(l.label),11,u))),256)),t.tooltip?(e.openBlock(),e.createBlock(i.default,{key:1,text:t.tooltip},{default:e.withCtx(()=>[d]),_:1},8,["text"])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),r(n.$slots.default)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",m,e.toDisplayString(t.placeholder),1)),e.renderSlot(n.$slots,"default")]))}};exports.default=h;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),i=require("../Tooltip/Tooltip.vue.cjs"),a={class:"bg-light pd-medium radius-big"},c={key:0,class:"mn-b-small flex-v-center flex-nowrap flex"},s={key:0,class:"mn-r-thin t-medium p-big"},u=["onClick"],d=e.createElementVNode("p",{class:"bg-main radius-small t-center i-medium"},"i",-1),m={key:1,class:"w-100"},h={__name:"Block",props:{title:{type:String,default:null},tooltip:{type:String,default:null},actions:{type:Array,default:null},placeholder:{type:String,default:"Nothing here"},options:{type:Object,default:{theme:"white"}}},setup(t){e.useSlots();const r=(n,o={})=>n?n(o).some(l=>Array.isArray(l.children)?!!l.children.length:l.type!==e.Comment):!1;return(n,o)=>(e.openBlock(),e.createElementBlock("div",a,[t.title||t.actions?(e.openBlock(),e.createElementBlock("div",c,[t.title?(e.openBlock(),e.createElementBlock("p",s,e.toDisplayString(t.title),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.actions,l=>(e.openBlock(),e.createElementBlock("button",{onClick:l.function,class:e.normalizeClass(["pd-thin button-delete button",l.class||"bg-main radius-small t-center i-medium"])},e.toDisplayString(l.label),11,u))),256)),t.tooltip?(e.openBlock(),e.createBlock(i.default,{key:1,text:t.tooltip},{default:e.withCtx(()=>[d]),_:1},8,["text"])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),r(n.$slots.default)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",m,e.toDisplayString(t.placeholder),1)),e.renderSlot(n.$slots,"default")]))}};exports.default=h;
@@ -1,5 +1,5 @@
1
1
  import { useSlots as c, openBlock as l, createElementBlock as n, toDisplayString as s, createCommentVNode as r, Fragment as u, renderList as d, normalizeClass as m, createBlock as h, withCtx as f, renderSlot as y, createElementVNode as g, Comment as p } from "vue";
2
- import b from "../Tooltip/Tooltip.vue2.js";
2
+ import b from "../Tooltip/Tooltip.vue.js";
3
3
  const k = { class: "bg-light pd-medium radius-big" }, C = {
4
4
  key: 0,
5
5
  class: "mn-b-small flex-v-center flex-nowrap flex"
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),d={class:"w-100 radius-big pd-medium bg-second t-black"},m={class:"mn-b-thin flex-v-center flex-nowrap flex"},g={class:"mn-l-thin uppercase radius-big t-semi t-medium t-white bg-black w-max pd-thin"},p={class:"w-100 h-2r pos-relative pd-nano bg-black radius-big"},h={__name:"Completion",props:{user:Object,target:Object,cta:Boolean,percentage:Number,text:String,text_cta:String},setup(a){const{user:f,cta:b,target:c}=a,l=e.ref(0),u=o=>{let r=0,i=0;function s(t){for(let n in t)t.hasOwnProperty(n)&&(t[n]&&typeof t[n]=="object"&&!Array.isArray(t[n])?s(t[n]):(r++,t[n]!=null&&t[n]!==""&&i++))}return s(o),r===0?0:Math.round(i/r*100)};return c&&(l.value=u(c)),(o,r)=>{const i=e.resolveComponent("router-link");return e.openBlock(),e.createElementBlock("section",d,[e.createElementVNode("div",m,[e.createElementVNode("h3",null,e.toDisplayString(a.text),1),e.createElementVNode("h4",g,e.toDisplayString(a.percentage||l.value)+"% ",1),a.cta?(e.openBlock(),e.createBlock(i,{key:0,to:{name:"User Edit Profile",params:{_id:a.user}},class:"mn-l-auto uppercase radius-big t-semi t-medium t-white bg-black w-max pd-thin"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.text_cta),1)]),_:1},8,["to"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",p,[e.createElementVNode("div",{style:e.normalizeStyle(`width: ${l.value}%`),class:"h-100 bg-second mn-b-thin radius-big"},null,4)])])}}};exports.default=h;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),d={class:"w-100 radius-big pd-medium bg-second t-black"},m={class:"mn-b-thin flex-v-center flex-nowrap flex"},g={class:"mn-l-thin uppercase radius-big t-semi t-medium t-white bg-black w-max pd-thin"},p={class:"w-100 h-2r pos-relative pd-nano bg-black radius-big"},h={__name:"Completion",props:{user:Object,target:Object,cta:Boolean,percentage:Number,text:String,text_cta:String},setup(r){const{user:b,cta:f,target:l}=r,u=o=>{let a=0,i=0;function s(t){for(let n in t)t.hasOwnProperty(n)&&(t[n]&&typeof t[n]=="object"&&!Array.isArray(t[n])?s(t[n]):(a++,t[n]!=null&&t[n]!==""&&i++))}return s(o),a===0?0:Math.round(i/a*100)},c=e.computed(()=>l?u(l):0);return(o,a)=>{const i=e.resolveComponent("router-link");return e.openBlock(),e.createElementBlock("section",d,[e.createElementVNode("div",m,[e.createElementVNode("h3",null,e.toDisplayString(r.text),1),e.createElementVNode("h4",g,e.toDisplayString(r.percentage||c.value)+"% ",1),r.cta?(e.openBlock(),e.createBlock(i,{key:0,to:{name:"User Edit Profile",params:{_id:r.user}},class:"mn-l-auto uppercase radius-big t-semi t-medium t-white bg-black w-max pd-thin"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(r.text_cta),1)]),_:1},8,["to"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",p,[e.createElementVNode("div",{style:e.normalizeStyle(`width: ${c.value}%`),class:"h-100 bg-second mn-b-thin radius-big"},null,4)])])}}};exports.default=h;