@infuro/cms-core 1.0.34 → 1.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/README.md +13 -0
  2. package/dist/OrderTrackPage-W3J6WIG2.js +426 -0
  3. package/dist/OrderTrackPage-Z6FCJQYY.cjs +428 -0
  4. package/dist/admin.cjs +34329 -20923
  5. package/dist/admin.d.cts +186 -9
  6. package/dist/admin.d.ts +186 -9
  7. package/dist/admin.js +34140 -20829
  8. package/dist/api.cjs +120 -17515
  9. package/dist/api.d.cts +633 -3
  10. package/dist/api.d.ts +633 -3
  11. package/dist/api.js +14 -17528
  12. package/dist/auth.cjs +192 -1034
  13. package/dist/auth.d.cts +194 -51
  14. package/dist/auth.d.ts +194 -51
  15. package/dist/auth.js +4 -966
  16. package/dist/chunk-2XE4X74C.js +29602 -0
  17. package/dist/chunk-3DZRIZOD.cjs +52 -0
  18. package/dist/chunk-3KPNTQBV.cjs +620 -0
  19. package/dist/chunk-46GKADYE.cjs +84 -0
  20. package/dist/chunk-4TRPKBKO.js +589 -0
  21. package/dist/chunk-5ELSW2UP.js +150 -0
  22. package/dist/chunk-6KPQWRFW.js +171 -0
  23. package/dist/chunk-7NMT3GBR.cjs +29 -0
  24. package/dist/chunk-7YIBMQDR.cjs +86 -0
  25. package/dist/chunk-BGJAV67S.cjs +29710 -0
  26. package/dist/chunk-CNTSLED2.cjs +559 -0
  27. package/dist/chunk-CRFV5WJK.js +16 -0
  28. package/dist/chunk-D5FBNKQM.cjs +104 -0
  29. package/dist/chunk-EF2JBPDM.js +114 -0
  30. package/dist/chunk-EQPITOP6.js +543 -0
  31. package/dist/chunk-GO7PPYNU.js +76 -0
  32. package/dist/chunk-HF3L2GIT.cjs +194 -0
  33. package/dist/chunk-J7XHLOLO.js +830 -0
  34. package/dist/chunk-JBRR5UYL.js +87 -0
  35. package/dist/chunk-JC6DLWTE.js +21 -0
  36. package/dist/chunk-JHF4YYRC.cjs +188 -0
  37. package/dist/chunk-JXF23MPG.js +25 -0
  38. package/dist/chunk-MQBT33IV.js +48 -0
  39. package/dist/chunk-N44BJZ4C.cjs +123 -0
  40. package/dist/chunk-OOTLNH63.cjs +18 -0
  41. package/dist/chunk-PAMVINEX.cjs +577 -0
  42. package/dist/chunk-PNOKNSG2.cjs +222 -0
  43. package/dist/chunk-QM733NUK.js +186 -0
  44. package/dist/chunk-R73BKDRO.cjs +90 -0
  45. package/dist/chunk-SHUYVCID.js +4 -0
  46. package/dist/chunk-SYBOCAWB.js +97 -0
  47. package/dist/chunk-TDV6EJHV.js +192 -0
  48. package/dist/chunk-TFUOHI37.cjs +839 -0
  49. package/dist/chunk-TIAEXJLI.cjs +182 -0
  50. package/dist/chunk-UPLVMVRX.cjs +23 -0
  51. package/dist/chunk-USNT2KNT.cjs +6 -0
  52. package/dist/chunk-WEMDMVHQ.js +216 -0
  53. package/dist/chunk-XDSNZUW7.js +564 -0
  54. package/dist/chunk-XQ3QUHWR.cjs +83 -0
  55. package/dist/chunk-XW5ATPRW.cjs +155 -0
  56. package/dist/chunk-ZQ4X6OAU.js +82 -0
  57. package/dist/chunk-ZSVCP6N3.js +83 -0
  58. package/dist/cli.cjs +103 -84
  59. package/dist/cli.js +62 -27
  60. package/dist/email-FKR4FXFI.js +5 -0
  61. package/dist/email-KVKVPNCL.cjs +58 -0
  62. package/dist/email-queue-CGZBVVAS.js +2 -0
  63. package/dist/email-queue-TPZWLTIV.cjs +23 -0
  64. package/dist/erp-config-enabled-CUMQ6N2V.cjs +11 -0
  65. package/dist/erp-config-enabled-T37X7T34.js +2 -0
  66. package/dist/erp-order-invoice-3YISSOWW.js +3 -0
  67. package/dist/erp-order-invoice-ZR5F2KTA.cjs +12 -0
  68. package/dist/event-order-defaults-6E543227.js +2 -0
  69. package/dist/event-order-defaults-DUGDVGJI.cjs +39 -0
  70. package/dist/event-order-notifications-5GSAOYVS.cjs +27 -0
  71. package/dist/event-order-notifications-IIIF23D5.js +10 -0
  72. package/dist/hooks.cjs +259 -132
  73. package/dist/hooks.d.cts +42 -1
  74. package/dist/hooks.d.ts +42 -1
  75. package/dist/hooks.js +234 -91
  76. package/dist/index.cjs +3884 -22307
  77. package/dist/index.d.cts +2203 -772
  78. package/dist/index.d.ts +2203 -772
  79. package/dist/index.js +2871 -22064
  80. package/dist/interpolate-WAKPN56R.cjs +11 -0
  81. package/dist/interpolate-WDUWDF3I.js +2 -0
  82. package/dist/layout-36UFTHC5.cjs +11 -0
  83. package/dist/layout-AOBN26XG.js +2 -0
  84. package/dist/migrations/1779400000000-ConvertStatusToEnum.ts +142 -0
  85. package/dist/migrations/1779400000000-SeedDefaultCurrencies.ts +33 -0
  86. package/dist/migrations/1779500000000-VendorRolesAndPermissions.ts +102 -0
  87. package/dist/migrations/1779600000000-VendorRegistrationProfile.ts +52 -0
  88. package/dist/migrations/1779700000000-CollectionIsCatalog.ts +22 -0
  89. package/dist/migrations/1779710000000-CollectionPlatformCatalog.ts +60 -0
  90. package/dist/migrations/1779720000000-ProductCategoryPlatformCatalog.ts +157 -0
  91. package/dist/migrations/1779800000000-EventsAndEventProducts.ts +173 -0
  92. package/dist/migrations/1779810000000-BackfillVendorRoleEventsPermissions.ts +38 -0
  93. package/dist/migrations/1779820000000-FixProductsCategoryForeignKey.ts +70 -0
  94. package/dist/migrations/1779830000000-ProductTitleColumn.ts +32 -0
  95. package/dist/migrations/1779840000000-EventAboutAndVisibilityFields.ts +34 -0
  96. package/dist/migrations/1779850000000-EventCityCountrySplit.ts +43 -0
  97. package/dist/migrations/1779860000000-CreateCombos.ts +140 -0
  98. package/dist/migrations/1780100000000-OrderAttendeesEventId.ts +55 -0
  99. package/dist/migrations/1780110000000-EventContactFormId.ts +49 -0
  100. package/dist/migrations/1780130000000-ProductVariants.ts +54 -0
  101. package/dist/migrations/1780140000000-EventManagementEnhancements.ts +44 -0
  102. package/dist/migrations/1780160000000-EventRegistrationGstProductContactForm.ts +79 -0
  103. package/dist/migrations/1780170000000-ComboCurrencyPrices.ts +20 -0
  104. package/dist/migrations/1781110000000-VendorOwnerCombosPermission.ts +38 -0
  105. package/dist/migrations/1781120000000-RefundPoliciesAndRequests.ts +225 -0
  106. package/dist/migrations/1781130000000-CreateAttendees.ts +44 -0
  107. package/dist/migrations/1781140000000-EventOrderNotifications.ts +29 -0
  108. package/dist/migrations/1781150000000-EventNamedLists.ts +28 -0
  109. package/dist/migrations/1781160000000-RefundPolicyEventTiers.ts +27 -0
  110. package/dist/migrations/1781170000000-EventRefundPolicy.ts +42 -0
  111. package/dist/migrations/1781180000000-RemoveCartItemsUniqueConstraint.ts +15 -0
  112. package/dist/migrations/1781190000000-RenameProductTaxesToProductConfig.ts +84 -0
  113. package/dist/migrations/1781200000000-VendorOwnerProductConfigPermissions.ts +51 -0
  114. package/dist/migrations/1781210000000-VendorRoleProductConfigPermissions.ts +46 -0
  115. package/dist/migrations/helpers/vendor-role-seed.ts +243 -0
  116. package/dist/paid-order-erp-3USEG6WL.js +3 -0
  117. package/dist/paid-order-erp-FSQ3GSXE.cjs +12 -0
  118. package/dist/pg-boss-service-4XF2TQ2E.js +2 -0
  119. package/dist/pg-boss-service-L6MTF4EQ.cjs +15 -0
  120. package/dist/razorpay-KLO2KNCB.js +49 -0
  121. package/dist/razorpay-U23LGY72.cjs +56 -0
  122. package/dist/rbac-debug-db-D7ME7QUY.cjs +35 -0
  123. package/dist/rbac-debug-db-MTCTVNNM.js +33 -0
  124. package/dist/sms-defaults-2NL24H57.js +2 -0
  125. package/dist/sms-defaults-KCOPKQBA.cjs +19 -0
  126. package/dist/stripe-4FD27QVJ.js +51 -0
  127. package/dist/stripe-VU6OEG2D.cjs +57 -0
  128. package/dist/theme.cjs +31 -59
  129. package/dist/theme.d.cts +78 -3
  130. package/dist/theme.d.ts +78 -3
  131. package/dist/theme.js +23 -20
  132. package/dist/vendor-invite-status-77O7ZQ3U.cjs +19 -0
  133. package/dist/vendor-invite-status-PWJ3DE76.js +2 -0
  134. package/dist/whatsapp-queue-3DXA4MXU.js +2 -0
  135. package/dist/whatsapp-queue-KG65MXD5.cjs +15 -0
  136. package/package.json +147 -142
  137. package/dist/admin.cjs.map +0 -1
  138. package/dist/admin.js.map +0 -1
  139. package/dist/api.cjs.map +0 -1
  140. package/dist/api.js.map +0 -1
  141. package/dist/auth.cjs.map +0 -1
  142. package/dist/auth.js.map +0 -1
  143. package/dist/cli.cjs.map +0 -1
  144. package/dist/cli.js.map +0 -1
  145. package/dist/config-DJ5CmQvS.d.cts +0 -8
  146. package/dist/config-DJ5CmQvS.d.ts +0 -8
  147. package/dist/hooks.cjs.map +0 -1
  148. package/dist/hooks.js.map +0 -1
  149. package/dist/index-Bf5GO8fu.d.cts +0 -583
  150. package/dist/index-DOiJuMQA.d.ts +0 -583
  151. package/dist/index.cjs.map +0 -1
  152. package/dist/index.js.map +0 -1
  153. package/dist/theme.cjs.map +0 -1
  154. package/dist/theme.js.map +0 -1
  155. package/dist/types-DCVaXlPV.d.cts +0 -78
  156. package/dist/types-DCVaXlPV.d.ts +0 -78
  157. package/dist/vendor-scope-DTYhJk_I.d.cts +0 -129
  158. package/dist/vendor-scope-DTYhJk_I.d.ts +0 -129
@@ -0,0 +1,150 @@
1
+ import { __name } from './chunk-SHUYVCID.js';
2
+
3
+ // src/plugins/email/email-queue.ts
4
+ var EMAIL_QUEUE_NAME = "email";
5
+ function registerEmailQueueProcessor(cms) {
6
+ const queue = cms.getPlugin("queue");
7
+ const email = cms.getPlugin("email");
8
+ if (!queue || !email) return;
9
+ queue.registerProcessor(EMAIL_QUEUE_NAME, async (data) => {
10
+ const payload = data;
11
+ const { to, templateName, ctx, subject, html, text } = payload;
12
+ if (!to) return;
13
+ if (templateName && ctx) {
14
+ const rendered = email.renderTemplate(templateName, ctx);
15
+ await email.send({
16
+ to,
17
+ subject: rendered.subject,
18
+ html: rendered.html,
19
+ text: rendered.text
20
+ });
21
+ } else if (subject != null && html != null) {
22
+ await email.send({
23
+ to,
24
+ subject,
25
+ html,
26
+ text
27
+ });
28
+ }
29
+ });
30
+ }
31
+ __name(registerEmailQueueProcessor, "registerEmailQueueProcessor");
32
+ async function queueEmail(cms, payload) {
33
+ const queue = cms.getPlugin("queue");
34
+ if (queue) {
35
+ await queue.add(EMAIL_QUEUE_NAME, payload);
36
+ return;
37
+ }
38
+ const email = cms.getPlugin("email");
39
+ if (email && payload.templateName && payload.ctx) {
40
+ const rendered = email.renderTemplate(payload.templateName, payload.ctx);
41
+ await email.send({
42
+ to: payload.to,
43
+ subject: rendered.subject,
44
+ html: rendered.html,
45
+ text: rendered.text
46
+ });
47
+ } else if (email && payload.subject != null && payload.html != null) {
48
+ await email.send({
49
+ to: payload.to,
50
+ subject: payload.subject,
51
+ html: payload.html,
52
+ text: payload.text
53
+ });
54
+ }
55
+ }
56
+ __name(queueEmail, "queueEmail");
57
+ async function queueOrderPlacedEmails(cms, payload) {
58
+ const { orderNumber, total, subtotal, tax, currency, customerName, customerEmail, salesTeamEmails, companyDetails, lineItems, billingAddress, shippingAddress } = payload;
59
+ const base = {
60
+ orderNumber,
61
+ total: total != null ? String(total) : void 0,
62
+ subtotal: subtotal != null ? String(subtotal) : void 0,
63
+ tax: tax != null ? String(tax) : void 0,
64
+ currency,
65
+ customerName,
66
+ companyDetails: companyDetails ?? {},
67
+ lineItems: lineItems ?? [],
68
+ billingAddress,
69
+ shippingAddress
70
+ };
71
+ const customerLower = customerEmail?.trim().toLowerCase() ?? "";
72
+ const jobs = [];
73
+ if (customerEmail?.trim()) {
74
+ jobs.push(queueEmail(cms, {
75
+ to: customerEmail.trim(),
76
+ templateName: "orderPlaced",
77
+ ctx: {
78
+ ...base,
79
+ audience: "customer"
80
+ }
81
+ }));
82
+ }
83
+ const seen = /* @__PURE__ */ new Set();
84
+ for (const raw of salesTeamEmails) {
85
+ const to = raw.trim();
86
+ if (!to) continue;
87
+ const key = to.toLowerCase();
88
+ if (seen.has(key)) continue;
89
+ seen.add(key);
90
+ if (customerLower && key === customerLower) continue;
91
+ jobs.push(queueEmail(cms, {
92
+ to,
93
+ templateName: "orderPlaced",
94
+ ctx: {
95
+ ...base,
96
+ audience: "sales",
97
+ internalCustomerEmail: customerEmail?.trim() || void 0
98
+ }
99
+ }));
100
+ }
101
+ await Promise.all(jobs);
102
+ }
103
+ __name(queueOrderPlacedEmails, "queueOrderPlacedEmails");
104
+ async function queueVendorOnboardEmails(cms, payload) {
105
+ const { vendorName, vendorSlug, ownerName, ownerEmail, activation, inviteLink, signInLink, kind = "vendor_onboard", notifyEmails, companyDetails, sendToOwner = true } = payload;
106
+ const base = {
107
+ vendorName,
108
+ vendorSlug,
109
+ ownerName,
110
+ ownerEmail,
111
+ activation,
112
+ inviteLink,
113
+ signInLink,
114
+ kind,
115
+ companyDetails: companyDetails ?? {}
116
+ };
117
+ const ownerLower = ownerEmail?.trim().toLowerCase() ?? "";
118
+ const jobs = [];
119
+ if (sendToOwner && ownerEmail?.trim()) {
120
+ jobs.push(queueEmail(cms, {
121
+ to: ownerEmail.trim(),
122
+ templateName: "vendorOnboarded",
123
+ ctx: {
124
+ ...base,
125
+ audience: "owner"
126
+ }
127
+ }));
128
+ }
129
+ const seen = /* @__PURE__ */ new Set();
130
+ for (const raw of notifyEmails) {
131
+ const to = raw.trim();
132
+ if (!to) continue;
133
+ const key = to.toLowerCase();
134
+ if (seen.has(key)) continue;
135
+ seen.add(key);
136
+ if (ownerLower && key === ownerLower) continue;
137
+ jobs.push(queueEmail(cms, {
138
+ to,
139
+ templateName: "vendorOnboarded",
140
+ ctx: {
141
+ ...base,
142
+ audience: "internal"
143
+ }
144
+ }));
145
+ }
146
+ await Promise.all(jobs);
147
+ }
148
+ __name(queueVendorOnboardEmails, "queueVendorOnboardEmails");
149
+
150
+ export { queueEmail, queueOrderPlacedEmails, queueVendorOnboardEmails, registerEmailQueueProcessor };
@@ -0,0 +1,171 @@
1
+ import { explainSessionEntityAccess, isVendorPortalUser, logRbac } from './chunk-4TRPKBKO.js';
2
+ import { __name } from './chunk-SHUYVCID.js';
3
+
4
+ // src/auth/helpers.ts
5
+ var RBAC_ADMIN_ONLY_ENTITIES = /* @__PURE__ */ new Set([
6
+ "users",
7
+ "user_groups",
8
+ "permissions"
9
+ ]);
10
+ function sessionHasEntityAccess(user, entity, action) {
11
+ return explainSessionEntityAccess(user, entity, action).allowed;
12
+ }
13
+ __name(sessionHasEntityAccess, "sessionHasEntityAccess");
14
+ function canManageRoles(user) {
15
+ return !!(user?.email && user.isRBACAdmin);
16
+ }
17
+ __name(canManageRoles, "canManageRoles");
18
+ var OPEN_ENDPOINTS = [
19
+ {
20
+ "/api/contacts": [
21
+ "POST"
22
+ ]
23
+ },
24
+ {
25
+ "/api/form-submissions": [
26
+ "POST"
27
+ ]
28
+ },
29
+ {
30
+ "/api/blogs": [
31
+ "GET"
32
+ ]
33
+ }
34
+ ];
35
+ var PERMISSION_REQUIRED_ENDPOINTS = {};
36
+ function isOpenEndpoint(pathname) {
37
+ return OPEN_ENDPOINTS.some((endpoint) => pathname.startsWith(Object.keys(endpoint)[0]));
38
+ }
39
+ __name(isOpenEndpoint, "isOpenEndpoint");
40
+ function getRequiredPermission(pathname) {
41
+ return null;
42
+ }
43
+ __name(getRequiredPermission, "getRequiredPermission");
44
+ function isPublicMethod(pathname, method) {
45
+ for (const endpoint of OPEN_ENDPOINTS) {
46
+ const key = Object.keys(endpoint)[0];
47
+ if (pathname.startsWith(key) && endpoint[key].includes(method)) return true;
48
+ }
49
+ return false;
50
+ }
51
+ __name(isPublicMethod, "isPublicMethod");
52
+ function createAuthHelpers(getSession, NextResponse) {
53
+ return createAuthHelpersFromGetSession(getSession, NextResponse);
54
+ }
55
+ __name(createAuthHelpers, "createAuthHelpers");
56
+ function createCmsAuthBundle(getSession, NextResponse) {
57
+ const auth = createAuthHelpers(getSession, NextResponse);
58
+ return {
59
+ requireAuth: auth.requireAuth,
60
+ requireAdminAccess: auth.requireAdminAccess,
61
+ requireEntityPermission: auth.requireEntityPermission,
62
+ getSessionUser: auth.getAuthenticatedUser,
63
+ getAuthenticatedUser: auth.getAuthenticatedUser
64
+ };
65
+ }
66
+ __name(createCmsAuthBundle, "createCmsAuthBundle");
67
+ function createAuthHelpersFromGetSession(getSession, NextResponse) {
68
+ return {
69
+ async requireAuth() {
70
+ const session = await getSession();
71
+ if (!session?.user?.email) {
72
+ return NextResponse.json({
73
+ error: "Unauthorized"
74
+ }, {
75
+ status: 401
76
+ });
77
+ }
78
+ return null;
79
+ },
80
+ async requirePermission() {
81
+ const session = await getSession();
82
+ if (!session?.user?.email) {
83
+ return NextResponse.json({
84
+ error: "Unauthorized"
85
+ }, {
86
+ status: 401
87
+ });
88
+ }
89
+ return null;
90
+ },
91
+ async requireEntityPermission(_req, entity, action) {
92
+ const session = await getSession();
93
+ if (!session?.user?.email) {
94
+ return NextResponse.json({
95
+ error: "Unauthorized"
96
+ }, {
97
+ status: 401
98
+ });
99
+ }
100
+ const u = session.user;
101
+ const allowed = sessionHasEntityAccess(u, entity, action);
102
+ const { reason } = explainSessionEntityAccess(u, entity, action);
103
+ logRbac("authHelpers.requireEntityPermission", {
104
+ entity,
105
+ action,
106
+ allowed,
107
+ reason,
108
+ email: u.email,
109
+ groupName: u.groupName,
110
+ vendorIds: u.vendorIds,
111
+ isVendorPortal: u.isVendorPortal,
112
+ isVendorOwner: u.isVendorOwner
113
+ });
114
+ if (allowed) return null;
115
+ return NextResponse.json({
116
+ error: "Forbidden",
117
+ entity,
118
+ action,
119
+ reason
120
+ }, {
121
+ status: 403
122
+ });
123
+ },
124
+ async requireAdminAccess() {
125
+ const session = await getSession();
126
+ if (!session?.user?.email) {
127
+ return NextResponse.json({
128
+ error: "Unauthorized"
129
+ }, {
130
+ status: 401
131
+ });
132
+ }
133
+ const u = session.user;
134
+ if (u.isRBACAdmin) return null;
135
+ if (isVendorPortalUser(u)) return null;
136
+ if (u.adminAccess === true) return null;
137
+ if (u.adminAccess === false) {
138
+ logRbac("requireAdminAccess denied (adminAccess:false)", {
139
+ email: u.email,
140
+ groupName: u.groupName,
141
+ isVendorPortal: u.isVendorPortal
142
+ });
143
+ return NextResponse.json({
144
+ error: "Forbidden",
145
+ reason: "admin_access"
146
+ }, {
147
+ status: 403
148
+ });
149
+ }
150
+ logRbac("requireAdminAccess denied (no matching rule)", {
151
+ email: u.email,
152
+ adminAccess: u.adminAccess,
153
+ groupName: u.groupName,
154
+ isVendorPortal: u.isVendorPortal
155
+ });
156
+ return NextResponse.json({
157
+ error: "Forbidden",
158
+ reason: "admin_access"
159
+ }, {
160
+ status: 403
161
+ });
162
+ },
163
+ async getAuthenticatedUser() {
164
+ const session = await getSession();
165
+ return session?.user ?? null;
166
+ }
167
+ };
168
+ }
169
+ __name(createAuthHelpersFromGetSession, "createAuthHelpersFromGetSession");
170
+
171
+ export { OPEN_ENDPOINTS, PERMISSION_REQUIRED_ENDPOINTS, RBAC_ADMIN_ONLY_ENTITIES, canManageRoles, createAuthHelpers, createCmsAuthBundle, getRequiredPermission, isOpenEndpoint, isPublicMethod, sessionHasEntityAccess };
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
4
+
5
+ // src/lib/vendor-invite-status.ts
6
+ function inviteStatusForActivation(activation) {
7
+ return activation === "invite" ? "pending" : "accepted";
8
+ }
9
+ chunkUSNT2KNT_cjs.__name(inviteStatusForActivation, "inviteStatusForActivation");
10
+ async function markVendorInviteAcceptedForUser(dataSource, vendorEntity, userId) {
11
+ await dataSource.getRepository(vendorEntity).update({
12
+ userId
13
+ }, {
14
+ inviteStatus: "accepted"
15
+ });
16
+ }
17
+ chunkUSNT2KNT_cjs.__name(markVendorInviteAcceptedForUser, "markVendorInviteAcceptedForUser");
18
+ async function markVendorInvitePendingForUser(dataSource, vendorEntity, userId) {
19
+ await dataSource.getRepository(vendorEntity).update({
20
+ userId
21
+ }, {
22
+ inviteStatus: "pending"
23
+ });
24
+ }
25
+ chunkUSNT2KNT_cjs.__name(markVendorInvitePendingForUser, "markVendorInvitePendingForUser");
26
+
27
+ exports.inviteStatusForActivation = inviteStatusForActivation;
28
+ exports.markVendorInviteAcceptedForUser = markVendorInviteAcceptedForUser;
29
+ exports.markVendorInvitePendingForUser = markVendorInvitePendingForUser;
@@ -0,0 +1,86 @@
1
+ 'use strict';
2
+
3
+ var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
4
+
5
+ // src/plugins/whatsapp/whatsapp-queue.ts
6
+ var WHATSAPP_QUEUE_NAME = "whatsapp";
7
+ function maskPhone(raw) {
8
+ const digits = raw.replace(/\D/g, "");
9
+ if (digits.length <= 4) return "****";
10
+ return `${"*".repeat(Math.max(0, digits.length - 4))}${digits.slice(-4)}`;
11
+ }
12
+ chunkUSNT2KNT_cjs.__name(maskPhone, "maskPhone");
13
+ function registerWhatsAppQueueProcessor(cms) {
14
+ const queue = cms.getPlugin("queue");
15
+ const whatsapp = cms.getPlugin("whatsapp");
16
+ if (!queue) {
17
+ console.warn("[whatsapp] queue processor not registered: queue plugin missing");
18
+ return;
19
+ }
20
+ if (!whatsapp || typeof whatsapp.send !== "function") {
21
+ console.warn("[whatsapp] queue processor not registered: whatsapp plugin missing or not configured");
22
+ return;
23
+ }
24
+ queue.registerProcessor(WHATSAPP_QUEUE_NAME, async (data) => {
25
+ const payload = data;
26
+ if (!payload.to) {
27
+ console.warn("[whatsapp] queue job skipped: missing recipient");
28
+ return;
29
+ }
30
+ console.log("[whatsapp] queue job processing", {
31
+ to: maskPhone(payload.to),
32
+ templateKey: payload.templateKey ?? null,
33
+ externalTemplateRef: payload.externalTemplateRef ?? null
34
+ });
35
+ try {
36
+ const ok = await whatsapp.send(payload);
37
+ if (ok) {
38
+ console.log("[whatsapp] queue job completed", {
39
+ to: maskPhone(payload.to),
40
+ sent: true
41
+ });
42
+ } else {
43
+ console.warn("[whatsapp] queue job completed without delivery", {
44
+ to: maskPhone(payload.to),
45
+ sent: false
46
+ });
47
+ }
48
+ } catch (err) {
49
+ console.error("[whatsapp] queue job failed", {
50
+ to: maskPhone(payload.to),
51
+ error: err instanceof Error ? err.message : String(err)
52
+ });
53
+ }
54
+ });
55
+ console.log("[whatsapp] queue processor registered", {
56
+ queue: WHATSAPP_QUEUE_NAME
57
+ });
58
+ }
59
+ chunkUSNT2KNT_cjs.__name(registerWhatsAppQueueProcessor, "registerWhatsAppQueueProcessor");
60
+ async function queueWhatsApp(cms, payload) {
61
+ const queue = cms.getPlugin("queue");
62
+ if (queue) {
63
+ console.log("[whatsapp] enqueue", {
64
+ to: maskPhone(payload.to),
65
+ templateKey: payload.templateKey ?? null,
66
+ externalTemplateRef: payload.externalTemplateRef ?? null
67
+ });
68
+ await queue.add(WHATSAPP_QUEUE_NAME, payload);
69
+ return true;
70
+ }
71
+ const whatsapp = cms.getPlugin("whatsapp");
72
+ if (whatsapp && typeof whatsapp.send === "function") {
73
+ console.log("[whatsapp] no queue plugin \u2014 sending immediately", {
74
+ to: maskPhone(payload.to)
75
+ });
76
+ return whatsapp.send(payload);
77
+ }
78
+ console.warn("[whatsapp] send skipped: neither queue nor whatsapp plugin available", {
79
+ to: maskPhone(payload.to)
80
+ });
81
+ return false;
82
+ }
83
+ chunkUSNT2KNT_cjs.__name(queueWhatsApp, "queueWhatsApp");
84
+
85
+ exports.queueWhatsApp = queueWhatsApp;
86
+ exports.registerWhatsAppQueueProcessor = registerWhatsAppQueueProcessor;