@ozdao/prometheus-framework 0.2.59 → 0.2.61

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. package/dist/auth.server.js +12 -223
  2. package/dist/auth.server.mjs +12 -223
  3. package/dist/community.server.js +3 -2
  4. package/dist/community.server.mjs +2 -1
  5. package/dist/events.server.js +117 -25
  6. package/dist/events.server.mjs +116 -24
  7. package/dist/files.server.js +7 -7
  8. package/dist/files.server.mjs +7 -7
  9. package/dist/gallery.server.js +2 -2
  10. package/dist/gallery.server.mjs +2 -2
  11. package/dist/main-DsseFd2d.mjs +13753 -0
  12. package/dist/main-U466Gwzt.js +91 -0
  13. package/dist/main.css +1 -1
  14. package/dist/metadata.schema-CS6_9GLU.js +174 -0
  15. package/dist/metadata.schema-CjpDDEnW.mjs +210 -0
  16. package/dist/metadata.schema-D88c1Ebp.mjs +175 -0
  17. package/dist/metadata.schema-doiYQfuO.js +209 -0
  18. package/dist/organizations.server.js +212 -16
  19. package/dist/organizations.server.mjs +212 -16
  20. package/dist/ownership.schema-DN0SlQL6.js +36 -0
  21. package/dist/ownership.schema-oyx6eNkZ.mjs +37 -0
  22. package/dist/products.server.js +8 -5
  23. package/dist/products.server.mjs +8 -5
  24. package/dist/prometheus-framework/src/components/Chips/Chips.vue.cjs +1 -1
  25. package/dist/prometheus-framework/src/components/Chips/Chips.vue.js +19 -14
  26. package/dist/prometheus-framework/src/components/Feed/Feed.vue.cjs +1 -1
  27. package/dist/prometheus-framework/src/components/Feed/Feed.vue.js +26 -26
  28. package/dist/prometheus-framework/src/components/FieldPhone/FieldPhone2.vue.cjs +1 -1
  29. package/dist/prometheus-framework/src/components/FieldPhone/FieldPhone2.vue.js +1 -373
  30. package/dist/prometheus-framework/src/components/Popup/Popup.vue.cjs +1 -1
  31. package/dist/prometheus-framework/src/components/Popup/Popup.vue.js +1 -72
  32. package/dist/prometheus-framework/src/components/Popup/Popup.vue2.cjs +1 -1
  33. package/dist/prometheus-framework/src/components/Popup/Popup.vue2.js +72 -1
  34. package/dist/prometheus-framework/src/components/Select/Select.vue.cjs +1 -1
  35. package/dist/prometheus-framework/src/components/Select/Select.vue.js +1 -97
  36. package/dist/prometheus-framework/src/components/Select/Select.vue2.cjs +1 -1
  37. package/dist/prometheus-framework/src/components/Select/Select.vue2.js +97 -1
  38. package/dist/prometheus-framework/src/components/Tab/Tab.vue.cjs +1 -1
  39. package/dist/prometheus-framework/src/components/Tab/Tab.vue.js +46 -1
  40. package/dist/prometheus-framework/src/components/Tab/Tab.vue2.cjs +1 -1
  41. package/dist/prometheus-framework/src/components/Tab/Tab.vue2.js +1 -46
  42. package/dist/prometheus-framework/src/modules/auth/auth.client.cjs +1 -1
  43. package/dist/prometheus-framework/src/modules/auth/auth.client.js +12 -14
  44. package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.cjs +1 -1
  45. package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.js +1 -1
  46. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.cjs +1 -1
  47. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.js +1 -1
  48. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.cjs +1 -1
  49. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.js +2 -2
  50. package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.cjs +1 -1
  51. package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.js +1 -1
  52. package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.cjs +1 -1
  53. package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.js +1 -1
  54. package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.cjs +1 -1
  55. package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.js +1 -1
  56. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.cjs +1 -1
  57. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.js +1 -1
  58. package/dist/prometheus-framework/src/modules/community/components/layouts/Community.vue.cjs +1 -1
  59. package/dist/prometheus-framework/src/modules/community/components/layouts/Community.vue.js +1 -1
  60. package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.cjs +1 -1
  61. package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.js +1 -1
  62. package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.cjs +1 -1
  63. package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.js +2 -2
  64. package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue.cjs +1 -5
  65. package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue.js +0 -66
  66. package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue2.cjs +5 -1
  67. package/dist/prometheus-framework/src/modules/constructor/components/elements/Textarea.vue2.js +66 -0
  68. package/dist/prometheus-framework/src/modules/constructor/components/sections/Constructor.vue.cjs +1 -1
  69. package/dist/prometheus-framework/src/modules/constructor/components/sections/Constructor.vue.js +1 -1
  70. package/dist/prometheus-framework/src/modules/events/components/layouts/layoutEvents.vue.cjs +1 -1
  71. package/dist/prometheus-framework/src/modules/events/components/layouts/layoutEvents.vue.js +1 -1
  72. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.cjs +1 -1
  73. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.js +199 -185
  74. package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue.cjs +1 -0
  75. package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue.js +168 -0
  76. package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue2.cjs +1 -0
  77. package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue2.js +1 -0
  78. package/dist/prometheus-framework/src/modules/events/components/pages/Event.vue.cjs +2 -2
  79. package/dist/prometheus-framework/src/modules/events/components/pages/Event.vue.js +43 -43
  80. package/dist/prometheus-framework/src/modules/events/components/pages/Events.vue.cjs +1 -1
  81. package/dist/prometheus-framework/src/modules/events/components/pages/Events.vue.js +2 -2
  82. package/dist/prometheus-framework/src/modules/events/router/events.cjs +1 -1
  83. package/dist/prometheus-framework/src/modules/events/router/events.js +11 -2
  84. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +1 -1
  85. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.js +1 -1
  86. package/dist/prometheus-framework/src/modules/gallery/components/sections/GalleryWithCategories.vue.cjs +1 -1
  87. package/dist/prometheus-framework/src/modules/gallery/components/sections/GalleryWithCategories.vue.js +1 -1
  88. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.cjs +1 -1
  89. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.js +59 -56
  90. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.cjs +1 -1
  91. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.js +1 -1
  92. package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue.cjs +1 -1
  93. package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue.js +1 -13
  94. package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue2.cjs +1 -1
  95. package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue2.js +13 -1
  96. package/dist/prometheus-framework/src/modules/orders/components/pages/EditOrder.vue.cjs +1 -1
  97. package/dist/prometheus-framework/src/modules/orders/components/pages/EditOrder.vue.js +167 -124
  98. package/dist/prometheus-framework/src/modules/orders/components/pages/Orders.vue.cjs +1 -1
  99. package/dist/prometheus-framework/src/modules/orders/components/pages/Orders.vue.js +56 -45
  100. package/dist/prometheus-framework/src/modules/orders/store/orders.cjs +1 -1
  101. package/dist/prometheus-framework/src/modules/orders/store/orders.js +19 -24
  102. package/dist/prometheus-framework/src/modules/organizations/components/blocks/DepartmentMemberModify.vue.cjs +1 -1
  103. package/dist/prometheus-framework/src/modules/organizations/components/blocks/DepartmentMemberModify.vue.js +1 -1
  104. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.cjs +1 -1
  105. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.js +3 -3
  106. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
  107. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.js +3 -3
  108. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.cjs +1 -1
  109. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.js +25 -25
  110. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.cjs +1 -1
  111. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.js +3 -3
  112. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organizations.vue.cjs +1 -1
  113. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organizations.vue.js +1 -1
  114. package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.cjs +1 -1
  115. package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.js +1 -1
  116. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
  117. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.js +2 -2
  118. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
  119. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.js +3 -3
  120. package/dist/prometheus-framework/src/modules/organizations/organizations.client.cjs +1 -1
  121. package/dist/prometheus-framework/src/modules/organizations/organizations.client.js +40 -38
  122. package/dist/prometheus-framework/src/modules/organizations/store/departments.cjs +1 -1
  123. package/dist/prometheus-framework/src/modules/organizations/store/departments.js +19 -19
  124. package/dist/prometheus-framework/src/modules/organizations/store/invites.cjs +1 -1
  125. package/dist/prometheus-framework/src/modules/organizations/store/invites.js +5 -5
  126. package/dist/prometheus-framework/src/modules/products/components/blocks/CardLeftover.vue.cjs +1 -1
  127. package/dist/prometheus-framework/src/modules/products/components/blocks/CardLeftover.vue.js +36 -27
  128. package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.cjs +1 -1
  129. package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.js +16 -16
  130. package/dist/prometheus-framework/src/modules/products/components/blocks/ImagesThumbnails.vue.cjs +1 -1
  131. package/dist/prometheus-framework/src/modules/products/components/blocks/ImagesThumbnails.vue.js +1 -1
  132. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.cjs +1 -1
  133. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.js +1 -1
  134. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.cjs +1 -1
  135. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.js +11 -11
  136. package/dist/prometheus-framework/src/modules/products/components/pages/Leftovers.vue.cjs +1 -1
  137. package/dist/prometheus-framework/src/modules/products/components/pages/Leftovers.vue.js +21 -21
  138. package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.cjs +1 -1
  139. package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.js +2 -2
  140. package/dist/prometheus-framework/src/modules/products/components/pages/Products.vue.cjs +1 -1
  141. package/dist/prometheus-framework/src/modules/products/components/pages/Products.vue.js +36 -50
  142. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.cjs +1 -1
  143. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.js +1 -1
  144. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.cjs +1 -1
  145. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.js +2 -2
  146. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.cjs +1 -1
  147. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.js +1 -1
  148. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileBlogposts.vue.cjs +1 -1
  149. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileBlogposts.vue.js +1 -1
  150. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.cjs +1 -1
  151. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.js +1 -1
  152. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEvents.vue.cjs +1 -1
  153. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEvents.vue.js +1 -1
  154. package/dist/prometheus-framework/src/modules/wallet/components/pages/Wallet.vue.cjs +1 -1
  155. package/dist/prometheus-framework/src/modules/wallet/components/pages/Wallet.vue.js +2 -2
  156. package/dist/prometheus-framework.cjs.js +1 -1
  157. package/dist/prometheus-framework.es.js +1 -1
  158. package/dist/style.css +1 -1
  159. package/dist/web-D7bW32Ul.mjs +54 -0
  160. package/dist/web-DpE9HxA3.js +1 -0
  161. package/package.json +1 -1
  162. package/src/components/Chips/Chips.vue +2 -2
  163. package/src/components/Feed/Feed.vue +2 -1
  164. package/src/modules/auth/auth.client.js +0 -2
  165. package/src/modules/auth/auth.server.js +1 -7
  166. package/src/modules/auth/components/pages/Invite.vue +1 -1
  167. package/src/modules/events/components/pages/EditEvent.vue +19 -0
  168. package/src/modules/events/components/pages/EditEventTickets.vue +194 -0
  169. package/src/modules/events/controllers/tickets.controller.js +103 -28
  170. package/src/modules/events/models/ticket.model.js +22 -4
  171. package/src/modules/events/router/events.js +5 -0
  172. package/src/modules/events/routes/tickets.routes.js +2 -2
  173. package/src/modules/events/store/tickets.js +1 -0
  174. package/src/modules/globals/components/blocks/CardHeader.vue +6 -6
  175. package/src/modules/organizations/components/pages/Members.vue +1 -1
  176. package/src/modules/organizations/components/pages/Organization.vue +4 -4
  177. package/src/modules/organizations/components/sections/MembersAdd.vue +1 -1
  178. package/src/modules/organizations/controllers/departments.controller.js +14 -1
  179. package/src/modules/organizations/models/department.model.js +5 -1
  180. package/src/modules/organizations/organizations.client.js +2 -0
  181. package/src/modules/organizations/organizations.server.js +6 -2
  182. package/src/modules/organizations/routes/departments.routes.js +1 -1
  183. package/src/modules/organizations/store/departments.js +3 -2
  184. package/src/modules/products/components/blocks/CardLeftover.vue +19 -7
  185. package/src/modules/products/components/pages/EditLeftover.vue +1 -1
  186. package/src/modules/products/components/pages/Leftovers.vue +14 -3
  187. package/src/modules/products/components/pages/Products.vue +8 -8
  188. package/src/modules/products/models/leftover.model.js +9 -5
  189. package/src/modules/users/models/client.model.js +60 -0
  190. /package/src/modules/{auth → organizations}/controllers/invites.controller.js +0 -0
  191. /package/src/modules/{auth → organizations}/models/invite.model.js +0 -0
  192. /package/src/modules/{auth → organizations}/routes/invites.routes.js +0 -0
  193. /package/src/modules/{auth → organizations}/store/invites.js +0 -0
@@ -2,8 +2,13 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const _commonjsHelpers = require("./_commonjsHelpers-DHfMLFPC.js");
4
4
  const require$$0 = require("mongoose");
5
- const metadata_schema = require("./metadata.schema-IGS4BjqG.js");
5
+ const metadata_schema = require("./metadata.schema-CS6_9GLU.js");
6
6
  const index = require("./index-CL9l0HRS.js");
7
+ const require$$0$1 = require("qrcode");
8
+ const require$$1 = require("jimp");
9
+ const require$$2 = require("path");
10
+ const mailing = require("./mailing-CxEcQ8NY.js");
11
+ const ownership_schema = require("./ownership.schema-DN0SlQL6.js");
7
12
  const ObjectId = require$$0.Types.ObjectId;
8
13
  function getDateConditions(date) {
9
14
  if (date) {
@@ -425,8 +430,79 @@ var events_routes = function(app, db, origins) {
425
430
  );
426
431
  };
427
432
  const events_routes$1 = /* @__PURE__ */ _commonjsHelpers.getDefaultExportFromCjs(events_routes);
428
- const controllerFactory$1 = (db) => {
433
+ const QRCode = require$$0$1;
434
+ const Jimp = require$$1;
435
+ const path = require$$2;
436
+ const { sendEmail } = mailing.mailing;
437
+ const controllerFactory$1 = (db, publicPath) => {
429
438
  const Ticket = db.ticket;
439
+ async function saveAndSendTicket(ticketData) {
440
+ console.log(ticketData);
441
+ const ticket = new Ticket(ticketData);
442
+ const data = await ticket.save();
443
+ const qrData = data._id.toString();
444
+ const qrCode = await QRCode.toDataURL(qrData, { errorCorrectionLevel: "H", type: "image/png" });
445
+ data.status = "unused";
446
+ data.qrcode = qrCode;
447
+ data.client_refactor.name = ticketData.name;
448
+ data.client_refactor.email = ticketData.email;
449
+ const templatePath = path.join(publicPath, "tickets", "template.png");
450
+ const outputPath = path.join(publicPath, "tickets", `ticket-${data._id}.png`);
451
+ data.image = `/tickets/ticket-${data._id}.png`;
452
+ const ticketTemplate = await Jimp.read(templatePath);
453
+ const qrImage = await Jimp.read(Buffer.from(qrCode.split(",")[1], "base64"));
454
+ const resizedQrWidth = qrImage.bitmap.width * 1.5;
455
+ const resizedQrHeight = qrImage.bitmap.height * 1.5;
456
+ qrImage.resize(resizedQrWidth, resizedQrHeight);
457
+ const { width: templateWidth, height: templateHeight } = ticketTemplate.bitmap;
458
+ const xPosition = (templateWidth - resizedQrWidth) / 2;
459
+ const yPosition = templateHeight / 2 - resizedQrHeight / 2 + 275;
460
+ await ticketTemplate.composite(qrImage, xPosition, yPosition);
461
+ await ticketTemplate.writeAsync(outputPath);
462
+ if (ticketData.email) {
463
+ const emailBody = `
464
+ <h1>Your Ticket from ${process.env.APP_NAME}</h1>
465
+ <p>Dear ${ticketData.name || "Anonymous"},<br>
466
+ Your ticket is now ready.<br>
467
+ Please find your ticket attached below:</p>
468
+ <img src="${process.env.API_URL + data.image}" alt="Ticket Image" style="width:100%;max-width:600px;height:auto;">
469
+ Keep this ticket safe, and show the QR code at the entrance.<br>
470
+ Looking forward to seeing you!<br>
471
+ Best regards,<br>
472
+ <p>The ${process.env.APP_NAME} Team</p>
473
+ `;
474
+ try {
475
+ const emailSent = await sendEmail(ticketData.email, `Your Ticket from ${process.env.APP_NAME}`, emailBody);
476
+ } catch (err) {
477
+ console.log(err);
478
+ }
479
+ }
480
+ await data.save();
481
+ return data;
482
+ }
483
+ const create = async (req, res) => {
484
+ if (Array.isArray(req.body)) {
485
+ const ticketsData = req.body;
486
+ try {
487
+ const ticketsPromises = ticketsData.map(
488
+ (ticketData) => saveAndSendTicket(ticketData)
489
+ );
490
+ const tickets = await Promise.all(ticketsPromises);
491
+ res.json(tickets);
492
+ } catch (err) {
493
+ console.log(err);
494
+ res.status(500).send({ errorCode: "SERVER_ERROR" });
495
+ }
496
+ } else {
497
+ try {
498
+ const data = await saveAndSendTicket(req.body);
499
+ res.json(data);
500
+ } catch (err) {
501
+ console.log(err);
502
+ res.status(500).send({ errorCode: "SERVER_ERROR" });
503
+ }
504
+ }
505
+ };
430
506
  const read = async (req, res) => {
431
507
  let query = {};
432
508
  let options = {};
@@ -452,27 +528,18 @@ const controllerFactory$1 = (db) => {
452
528
  res.status(500).send({ errorCode: "SERVER_ERROR" });
453
529
  }
454
530
  };
455
- const create = async (req, res) => {
456
- const newTicket = new Ticket({
457
- user: req.body.user,
458
- type: req.body.type,
459
- target: req.body.target,
460
- role: req.body.role
461
- });
462
- try {
463
- const data = await newTicket.save();
464
- res.send(data);
465
- } catch (err) {
466
- res.status(500).send({ errorCode: "SERVER_ERROR" });
467
- }
468
- };
469
531
  const update = async (req, res) => {
470
532
  try {
471
- const ticket = await Ticket.findByIdAndUpdate(req.body._id, req.body, { new: true });
533
+ const { _id } = req.body;
534
+ const ticket = await Ticket.findById(_id);
472
535
  if (!ticket) {
473
536
  return res.status(404).send({ errorCode: "TICKET_NOT_FOUND" });
474
537
  }
475
- res.send(ticket);
538
+ if (ticket.status === "used") {
539
+ return res.status(500).send({ errorCode: "TICKET_ALREADY_USED" });
540
+ }
541
+ const updatedTicket = await Ticket.findByIdAndUpdate(_id, req.body, { new: true });
542
+ res.send(updatedTicket);
476
543
  } catch (err) {
477
544
  res.status(500).send({ errorCode: "SERVER_ERROR" });
478
545
  }
@@ -500,8 +567,8 @@ const controllerFactory$1 = (db) => {
500
567
  };
501
568
  var tickets_controller = controllerFactory$1;
502
569
  const controllerFactory = tickets_controller;
503
- var tickets_routes = function(app, db, origins) {
504
- const controller = controllerFactory(db);
570
+ var tickets_routes = function(app, db, origins, publicPath) {
571
+ const controller = controllerFactory(db, publicPath);
505
572
  app.use(function(req, res, next) {
506
573
  const origin = req.headers.origin;
507
574
  if (origins.includes(origin)) {
@@ -530,7 +597,7 @@ var tickets_routes = function(app, db, origins) {
530
597
  const tickets_routes$1 = /* @__PURE__ */ _commonjsHelpers.getDefaultExportFromCjs(tickets_routes);
531
598
  const applyCommonSchema = metadata_schema.common_schema;
532
599
  const applyEngagementSchema = metadata_schema.engagement_schema;
533
- const applyOwnershipSchema = metadata_schema.ownership_schema;
600
+ const applyOwnershipSchema = ownership_schema.ownership_schema;
534
601
  const applyMetadataSchema = metadata_schema.metadata_schema;
535
602
  var event_model = (db) => {
536
603
  const EventSchema = new db.mongoose.Schema({
@@ -615,19 +682,29 @@ var event_model = (db) => {
615
682
  const event_model$1 = /* @__PURE__ */ _commonjsHelpers.getDefaultExportFromCjs(event_model);
616
683
  var ticket_model = (mongoose) => {
617
684
  const TicketSchema = new mongoose.Schema({
685
+ client: {
686
+ type: mongoose.Schema.Types.ObjectId,
687
+ ref: "Client"
688
+ },
689
+ client_refactor: {
690
+ email: {
691
+ type: String
692
+ },
693
+ name: {
694
+ type: String
695
+ }
696
+ },
618
697
  user: {
619
698
  type: mongoose.Schema.Types.ObjectId,
620
- ref: "User",
621
- required: true
699
+ ref: "User"
622
700
  },
623
701
  type: {
624
702
  type: String,
625
703
  enum: ["event", "parking"],
626
- default: "organization",
704
+ default: "event",
627
705
  required: true
628
706
  },
629
707
  target: {
630
- // заменяем 'organization' на 'target', так как это может быть или User, или Organization
631
708
  type: mongoose.Schema.Types.ObjectId,
632
709
  ref: function(value) {
633
710
  if (this.type === "event")
@@ -640,6 +717,21 @@ var ticket_model = (mongoose) => {
640
717
  role: {
641
718
  type: String,
642
719
  default: "participant"
720
+ },
721
+ qrcode: {
722
+ type: String
723
+ },
724
+ image: {
725
+ type: String
726
+ },
727
+ status: {
728
+ type: String,
729
+ enum: ["unused", "used", "deactivated"],
730
+ deafult: "unused"
731
+ }
732
+ }, {
733
+ timestamps: {
734
+ currentTime: () => Date.now()
643
735
  }
644
736
  });
645
737
  TicketSchema.index({ user: 1, type: 1, target: 1 });
@@ -1,7 +1,12 @@
1
1
  import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-CUmg6egw.mjs";
2
2
  import require$$0 from "mongoose";
3
- import { q as queryProcessor$2, c as common_schema, e as engagement_schema, o as ownership_schema, m as metadata_schema } from "./metadata.schema-C_AgyVgg.mjs";
3
+ import { q as queryProcessor$2, c as common_schema, e as engagement_schema, m as metadata_schema } from "./metadata.schema-D88c1Ebp.mjs";
4
4
  import { s as server$1 } from "./index-CGIn4v5E.mjs";
5
+ import require$$0$1 from "qrcode";
6
+ import require$$1 from "jimp";
7
+ import require$$2 from "path";
8
+ import { m as mailing } from "./mailing-DT2ZSkCD.mjs";
9
+ import { o as ownership_schema } from "./ownership.schema-oyx6eNkZ.mjs";
5
10
  const ObjectId = require$$0.Types.ObjectId;
6
11
  function getDateConditions(date) {
7
12
  if (date) {
@@ -423,8 +428,79 @@ var events_routes = function(app, db, origins) {
423
428
  );
424
429
  };
425
430
  const events_routes$1 = /* @__PURE__ */ getDefaultExportFromCjs(events_routes);
426
- const controllerFactory$1 = (db) => {
431
+ const QRCode = require$$0$1;
432
+ const Jimp = require$$1;
433
+ const path = require$$2;
434
+ const { sendEmail } = mailing;
435
+ const controllerFactory$1 = (db, publicPath) => {
427
436
  const Ticket = db.ticket;
437
+ async function saveAndSendTicket(ticketData) {
438
+ console.log(ticketData);
439
+ const ticket = new Ticket(ticketData);
440
+ const data = await ticket.save();
441
+ const qrData = data._id.toString();
442
+ const qrCode = await QRCode.toDataURL(qrData, { errorCorrectionLevel: "H", type: "image/png" });
443
+ data.status = "unused";
444
+ data.qrcode = qrCode;
445
+ data.client_refactor.name = ticketData.name;
446
+ data.client_refactor.email = ticketData.email;
447
+ const templatePath = path.join(publicPath, "tickets", "template.png");
448
+ const outputPath = path.join(publicPath, "tickets", `ticket-${data._id}.png`);
449
+ data.image = `/tickets/ticket-${data._id}.png`;
450
+ const ticketTemplate = await Jimp.read(templatePath);
451
+ const qrImage = await Jimp.read(Buffer.from(qrCode.split(",")[1], "base64"));
452
+ const resizedQrWidth = qrImage.bitmap.width * 1.5;
453
+ const resizedQrHeight = qrImage.bitmap.height * 1.5;
454
+ qrImage.resize(resizedQrWidth, resizedQrHeight);
455
+ const { width: templateWidth, height: templateHeight } = ticketTemplate.bitmap;
456
+ const xPosition = (templateWidth - resizedQrWidth) / 2;
457
+ const yPosition = templateHeight / 2 - resizedQrHeight / 2 + 275;
458
+ await ticketTemplate.composite(qrImage, xPosition, yPosition);
459
+ await ticketTemplate.writeAsync(outputPath);
460
+ if (ticketData.email) {
461
+ const emailBody = `
462
+ <h1>Your Ticket from ${process.env.APP_NAME}</h1>
463
+ <p>Dear ${ticketData.name || "Anonymous"},<br>
464
+ Your ticket is now ready.<br>
465
+ Please find your ticket attached below:</p>
466
+ <img src="${process.env.API_URL + data.image}" alt="Ticket Image" style="width:100%;max-width:600px;height:auto;">
467
+ Keep this ticket safe, and show the QR code at the entrance.<br>
468
+ Looking forward to seeing you!<br>
469
+ Best regards,<br>
470
+ <p>The ${process.env.APP_NAME} Team</p>
471
+ `;
472
+ try {
473
+ const emailSent = await sendEmail(ticketData.email, `Your Ticket from ${process.env.APP_NAME}`, emailBody);
474
+ } catch (err) {
475
+ console.log(err);
476
+ }
477
+ }
478
+ await data.save();
479
+ return data;
480
+ }
481
+ const create = async (req, res) => {
482
+ if (Array.isArray(req.body)) {
483
+ const ticketsData = req.body;
484
+ try {
485
+ const ticketsPromises = ticketsData.map(
486
+ (ticketData) => saveAndSendTicket(ticketData)
487
+ );
488
+ const tickets = await Promise.all(ticketsPromises);
489
+ res.json(tickets);
490
+ } catch (err) {
491
+ console.log(err);
492
+ res.status(500).send({ errorCode: "SERVER_ERROR" });
493
+ }
494
+ } else {
495
+ try {
496
+ const data = await saveAndSendTicket(req.body);
497
+ res.json(data);
498
+ } catch (err) {
499
+ console.log(err);
500
+ res.status(500).send({ errorCode: "SERVER_ERROR" });
501
+ }
502
+ }
503
+ };
428
504
  const read = async (req, res) => {
429
505
  let query = {};
430
506
  let options = {};
@@ -450,27 +526,18 @@ const controllerFactory$1 = (db) => {
450
526
  res.status(500).send({ errorCode: "SERVER_ERROR" });
451
527
  }
452
528
  };
453
- const create = async (req, res) => {
454
- const newTicket = new Ticket({
455
- user: req.body.user,
456
- type: req.body.type,
457
- target: req.body.target,
458
- role: req.body.role
459
- });
460
- try {
461
- const data = await newTicket.save();
462
- res.send(data);
463
- } catch (err) {
464
- res.status(500).send({ errorCode: "SERVER_ERROR" });
465
- }
466
- };
467
529
  const update = async (req, res) => {
468
530
  try {
469
- const ticket = await Ticket.findByIdAndUpdate(req.body._id, req.body, { new: true });
531
+ const { _id } = req.body;
532
+ const ticket = await Ticket.findById(_id);
470
533
  if (!ticket) {
471
534
  return res.status(404).send({ errorCode: "TICKET_NOT_FOUND" });
472
535
  }
473
- res.send(ticket);
536
+ if (ticket.status === "used") {
537
+ return res.status(500).send({ errorCode: "TICKET_ALREADY_USED" });
538
+ }
539
+ const updatedTicket = await Ticket.findByIdAndUpdate(_id, req.body, { new: true });
540
+ res.send(updatedTicket);
474
541
  } catch (err) {
475
542
  res.status(500).send({ errorCode: "SERVER_ERROR" });
476
543
  }
@@ -498,8 +565,8 @@ const controllerFactory$1 = (db) => {
498
565
  };
499
566
  var tickets_controller = controllerFactory$1;
500
567
  const controllerFactory = tickets_controller;
501
- var tickets_routes = function(app, db, origins) {
502
- const controller = controllerFactory(db);
568
+ var tickets_routes = function(app, db, origins, publicPath) {
569
+ const controller = controllerFactory(db, publicPath);
503
570
  app.use(function(req, res, next) {
504
571
  const origin = req.headers.origin;
505
572
  if (origins.includes(origin)) {
@@ -613,19 +680,29 @@ var event_model = (db) => {
613
680
  const event_model$1 = /* @__PURE__ */ getDefaultExportFromCjs(event_model);
614
681
  var ticket_model = (mongoose) => {
615
682
  const TicketSchema = new mongoose.Schema({
683
+ client: {
684
+ type: mongoose.Schema.Types.ObjectId,
685
+ ref: "Client"
686
+ },
687
+ client_refactor: {
688
+ email: {
689
+ type: String
690
+ },
691
+ name: {
692
+ type: String
693
+ }
694
+ },
616
695
  user: {
617
696
  type: mongoose.Schema.Types.ObjectId,
618
- ref: "User",
619
- required: true
697
+ ref: "User"
620
698
  },
621
699
  type: {
622
700
  type: String,
623
701
  enum: ["event", "parking"],
624
- default: "organization",
702
+ default: "event",
625
703
  required: true
626
704
  },
627
705
  target: {
628
- // заменяем 'organization' на 'target', так как это может быть или User, или Organization
629
706
  type: mongoose.Schema.Types.ObjectId,
630
707
  ref: function(value) {
631
708
  if (this.type === "event")
@@ -638,6 +715,21 @@ var ticket_model = (mongoose) => {
638
715
  role: {
639
716
  type: String,
640
717
  default: "participant"
718
+ },
719
+ qrcode: {
720
+ type: String
721
+ },
722
+ image: {
723
+ type: String
724
+ },
725
+ status: {
726
+ type: String,
727
+ enum: ["unused", "used", "deactivated"],
728
+ deafult: "unused"
729
+ }
730
+ }, {
731
+ timestamps: {
732
+ currentTime: () => Date.now()
641
733
  }
642
734
  });
643
735
  TicketSchema.index({ user: 1, type: 1, target: 1 });
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  const _commonjsHelpers = require("./_commonjsHelpers-DHfMLFPC.js");
3
- const require$$0 = require("path");
3
+ const require$$2 = require("path");
4
4
  const index = require("./index-CL9l0HRS.js");
5
- const require$$0$1 = require("sharp");
5
+ const require$$0 = require("sharp");
6
6
  const require$$1 = require("fs");
7
- const require$$2 = require("fs/promises");
7
+ const require$$2$1 = require("fs/promises");
8
8
  const require$$4 = require("busboy");
9
- const path = require$$0;
9
+ const path = require$$2;
10
10
  const controllerFactory$1 = (db, publicPath) => {
11
11
  const uploadMultipleFileController = async (req, res, next) => {
12
12
  console.log("uploadMultipleFileController called");
@@ -40,10 +40,10 @@ function requireMiddlewareBusboy() {
40
40
  if (hasRequiredMiddlewareBusboy)
41
41
  return middlewareBusboy;
42
42
  hasRequiredMiddlewareBusboy = 1;
43
- const sharp = require$$0$1;
43
+ const sharp = require$$0;
44
44
  const fs = require$$1;
45
- const fsp = require$$2;
46
- const path2 = require$$0;
45
+ const fsp = require$$2$1;
46
+ const path2 = require$$2;
47
47
  const busboy = require$$4;
48
48
  const createThumbnail = async (originalPath) => {
49
49
  const thumbnailPath = path2.join(
@@ -1,11 +1,11 @@
1
1
  import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-CUmg6egw.mjs";
2
- import require$$0 from "path";
2
+ import require$$2 from "path";
3
3
  import { s as server$1 } from "./index-CGIn4v5E.mjs";
4
- import require$$0$1 from "sharp";
4
+ import require$$0 from "sharp";
5
5
  import require$$1 from "fs";
6
- import require$$2 from "fs/promises";
6
+ import require$$2$1 from "fs/promises";
7
7
  import require$$4 from "busboy";
8
- const path = require$$0;
8
+ const path = require$$2;
9
9
  const controllerFactory$1 = (db, publicPath) => {
10
10
  const uploadMultipleFileController = async (req, res, next) => {
11
11
  console.log("uploadMultipleFileController called");
@@ -39,10 +39,10 @@ function requireMiddlewareBusboy() {
39
39
  if (hasRequiredMiddlewareBusboy)
40
40
  return middlewareBusboy;
41
41
  hasRequiredMiddlewareBusboy = 1;
42
- const sharp = require$$0$1;
42
+ const sharp = require$$0;
43
43
  const fs = require$$1;
44
- const fsp = require$$2;
45
- const path2 = require$$0;
44
+ const fsp = require$$2$1;
45
+ const path2 = require$$2;
46
46
  const busboy = require$$4;
47
47
  const createThumbnail = async (originalPath) => {
48
48
  const thumbnailPath = path2.join(
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  const _commonjsHelpers = require("./_commonjsHelpers-DHfMLFPC.js");
3
- const require$$0 = require("path");
3
+ const require$$2 = require("path");
4
4
  const index = require("./index-CL9l0HRS.js");
5
- const path = require$$0;
5
+ const path = require$$2;
6
6
  const controllerFactory$1 = (db) => {
7
7
  const Photo = db.photo;
8
8
  const read = async (req, res) => {
@@ -1,7 +1,7 @@
1
1
  import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-CUmg6egw.mjs";
2
- import require$$0 from "path";
2
+ import require$$2 from "path";
3
3
  import { s as server } from "./index-CGIn4v5E.mjs";
4
- const path = require$$0;
4
+ const path = require$$2;
5
5
  const controllerFactory$1 = (db) => {
6
6
  const Photo = db.photo;
7
7
  const read = async (req, res) => {