@infuro/cms-core 1.0.35 → 1.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin.cjs +1222 -1024
- package/dist/admin.d.cts +6 -0
- package/dist/admin.d.ts +6 -0
- package/dist/admin.js +1224 -1026
- package/dist/api.cjs +40 -39
- package/dist/api.js +8 -7
- package/dist/auth.cjs +51 -51
- package/dist/auth.d.cts +3 -3
- package/dist/auth.d.ts +3 -3
- package/dist/auth.js +3 -3
- package/dist/chunk-22FFHLTO.cjs +2356 -0
- package/dist/{chunk-CNTSLED2.cjs → chunk-E6WVP7BK.cjs} +75 -14
- package/dist/chunk-HCIRL37O.js +21 -0
- package/dist/chunk-HT5DI3XW.cjs +82 -0
- package/dist/{chunk-EF2JBPDM.js → chunk-KFFB6EMZ.js} +9 -0
- package/dist/chunk-NNQBWDCI.js +2325 -0
- package/dist/{chunk-TIAEXJLI.cjs → chunk-OIGCAGH7.cjs} +7 -7
- package/dist/{chunk-4TRPKBKO.js → chunk-P7QCLE5W.js} +52 -24
- package/dist/{chunk-2XE4X74C.js → chunk-PYUXVU75.js} +7801 -6871
- package/dist/{chunk-EQPITOP6.js → chunk-SBRBR3VO.js} +70 -9
- package/dist/{chunk-N44BJZ4C.cjs → chunk-SPQFNIYJ.cjs} +9 -0
- package/dist/chunk-UCKN4BBY.cjs +24 -0
- package/dist/{chunk-6KPQWRFW.js → chunk-UXMDSNIG.js} +1 -1
- package/dist/{chunk-BGJAV67S.cjs → chunk-VJDUKAJ3.cjs} +8207 -7261
- package/dist/{chunk-3KPNTQBV.cjs → chunk-WMXPKKXU.cjs} +52 -23
- package/dist/chunk-X47PBV4I.js +79 -0
- package/dist/cli.cjs +4 -2
- package/dist/cli.js +4 -2
- package/dist/emit-order-notification-trigger-D2N3KFHL.cjs +16 -0
- package/dist/emit-order-notification-trigger-IVLWKKJL.js +3 -0
- package/dist/{event-order-defaults-DUGDVGJI.cjs → event-order-defaults-EMWBIGL3.cjs} +9 -9
- package/dist/{event-order-defaults-6E543227.js → event-order-defaults-SDRNAZHC.js} +1 -1
- package/dist/index.cjs +805 -1059
- package/dist/index.d.cts +834 -728
- package/dist/index.d.ts +834 -728
- package/dist/index.js +385 -724
- package/dist/migrations/1775500000000-RssFeedsAndArticles.ts +0 -1
- package/dist/migrations/1775700000000-JobSchedules.ts +0 -1
- package/dist/migrations/1781220000000-AddWhatsappTriggerBindings.ts +23 -0
- package/dist/migrations/1781230000000-AddOrderNotificationTriggers.ts +46 -0
- package/dist/migrations/1781240000000-DropEventOrderNotificationColumns.ts +29 -0
- package/dist/migrations/1781250000000-RemoveOrderRefundedTrigger.ts +36 -0
- package/dist/migrations/1781260000000-RenameWhatsappTriggerBindingsToOrderNotificationBindings.ts +92 -0
- package/dist/migrations/1781270000000-ComboVendorId.ts +58 -0
- package/dist/order-notification-dispatcher-RU7BTGGX.cjs +18 -0
- package/dist/order-notification-dispatcher-XWIJYDGA.js +5 -0
- package/dist/{rbac-debug-db-D7ME7QUY.cjs → rbac-debug-db-KHG4FJC3.cjs} +2 -2
- package/dist/{rbac-debug-db-MTCTVNNM.js → rbac-debug-db-QWHOENBR.js} +1 -1
- package/package.json +1 -1
- package/dist/chunk-46GKADYE.cjs +0 -84
- package/dist/chunk-7YIBMQDR.cjs +0 -86
- package/dist/chunk-J7XHLOLO.js +0 -830
- package/dist/chunk-JBRR5UYL.js +0 -87
- package/dist/chunk-JHF4YYRC.cjs +0 -188
- package/dist/chunk-PAMVINEX.cjs +0 -577
- package/dist/chunk-QM733NUK.js +0 -186
- package/dist/chunk-R73BKDRO.cjs +0 -90
- package/dist/chunk-TFUOHI37.cjs +0 -839
- package/dist/chunk-XDSNZUW7.js +0 -564
- package/dist/chunk-ZQ4X6OAU.js +0 -82
- package/dist/chunk-ZSVCP6N3.js +0 -83
- package/dist/email-FKR4FXFI.js +0 -5
- package/dist/email-KVKVPNCL.cjs +0 -58
- package/dist/event-order-notifications-5GSAOYVS.cjs +0 -27
- package/dist/event-order-notifications-IIIF23D5.js +0 -10
- package/dist/layout-36UFTHC5.cjs +0 -11
- package/dist/layout-AOBN26XG.js +0 -2
- package/dist/whatsapp-queue-3DXA4MXU.js +0 -2
- package/dist/whatsapp-queue-KG65MXD5.cjs +0 -15
package/dist/chunk-QM733NUK.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { renderLayout } from './chunk-ZQ4X6OAU.js';
|
|
2
|
-
import { applyTemplateVars } from './chunk-CRFV5WJK.js';
|
|
3
|
-
import { queueWhatsApp } from './chunk-ZSVCP6N3.js';
|
|
4
|
-
import { resolvePublicSiteUrl, buildEventOrderTemplateVariables } from './chunk-JBRR5UYL.js';
|
|
5
|
-
import { mergeEmailLayoutCompanyDetails } from './chunk-XDSNZUW7.js';
|
|
6
|
-
import { queueEmail } from './chunk-5ELSW2UP.js';
|
|
7
|
-
import { resolveEventOrderTemplate, EVENT_ORDER_TEMPLATE_KEY } from './chunk-EF2JBPDM.js';
|
|
8
|
-
import { __name } from './chunk-SHUYVCID.js';
|
|
9
|
-
|
|
10
|
-
// src/lib/event-order-notifications.ts
|
|
11
|
-
async function getSettingsGroup(deps, group) {
|
|
12
|
-
const rows = await deps.dataSource.getRepository(deps.entityMap["configs"]).find({
|
|
13
|
-
where: {
|
|
14
|
-
settings: group,
|
|
15
|
-
deleted: false
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
return Object.fromEntries(rows.map((r) => [
|
|
19
|
-
r.key,
|
|
20
|
-
r.value
|
|
21
|
-
]));
|
|
22
|
-
}
|
|
23
|
-
__name(getSettingsGroup, "getSettingsGroup");
|
|
24
|
-
function channelEnabled(channels, ch) {
|
|
25
|
-
if (!Array.isArray(channels) || channels.length === 0) return false;
|
|
26
|
-
return channels.includes(ch);
|
|
27
|
-
}
|
|
28
|
-
__name(channelEnabled, "channelEnabled");
|
|
29
|
-
async function dispatchEventOrderNotifications(orderId, deps) {
|
|
30
|
-
const orderRepo = deps.dataSource.getRepository(deps.entityMap["orders"]);
|
|
31
|
-
const order = await orderRepo.findOne({
|
|
32
|
-
where: {
|
|
33
|
-
id: orderId,
|
|
34
|
-
deleted: false
|
|
35
|
-
},
|
|
36
|
-
relations: [
|
|
37
|
-
"contact"
|
|
38
|
-
]
|
|
39
|
-
});
|
|
40
|
-
if (!order) return;
|
|
41
|
-
const o = order;
|
|
42
|
-
const contact = o.contact ?? {};
|
|
43
|
-
const siteUrl = resolvePublicSiteUrl();
|
|
44
|
-
const itemRows = await deps.dataSource.getRepository(deps.entityMap["order_items"]).find({
|
|
45
|
-
where: {
|
|
46
|
-
orderId
|
|
47
|
-
},
|
|
48
|
-
relations: [
|
|
49
|
-
"product"
|
|
50
|
-
],
|
|
51
|
-
order: {
|
|
52
|
-
id: "ASC"
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
if (!itemRows.length) return;
|
|
56
|
-
const epRepo = deps.dataSource.getRepository(deps.entityMap["event_products"]);
|
|
57
|
-
const eventRepo = deps.dataSource.getRepository(deps.entityMap["events"]);
|
|
58
|
-
const templateRepo = deps.dataSource.getRepository(deps.entityMap["message_templates"]);
|
|
59
|
-
const getTemplateRow = /* @__PURE__ */ __name(async (channel, templateKey) => {
|
|
60
|
-
const row = await templateRepo.findOne({
|
|
61
|
-
where: {
|
|
62
|
-
channel,
|
|
63
|
-
templateKey,
|
|
64
|
-
deleted: false
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
if (!row) return null;
|
|
68
|
-
const r = row;
|
|
69
|
-
return {
|
|
70
|
-
subject: r.subject,
|
|
71
|
-
body: r.body,
|
|
72
|
-
externalTemplateRef: r.externalTemplateRef,
|
|
73
|
-
enabled: r.enabled
|
|
74
|
-
};
|
|
75
|
-
}, "getTemplateRow");
|
|
76
|
-
const orderLines = itemRows.map((item) => {
|
|
77
|
-
const row = item;
|
|
78
|
-
const name = row.product?.name || row.product?.title || `Product #${row.productId}`;
|
|
79
|
-
return {
|
|
80
|
-
name: String(name),
|
|
81
|
-
quantity: Number(row.quantity) || 1,
|
|
82
|
-
total: row.total,
|
|
83
|
-
currency: String(o.currency ?? "INR")
|
|
84
|
-
};
|
|
85
|
-
});
|
|
86
|
-
const eventMap = /* @__PURE__ */ new Map();
|
|
87
|
-
for (const item of itemRows) {
|
|
88
|
-
const productId = item.productId;
|
|
89
|
-
const productName = item.product?.name || item.product?.title || `Product #${productId}`;
|
|
90
|
-
const eps = await epRepo.find({
|
|
91
|
-
where: {
|
|
92
|
-
productId,
|
|
93
|
-
isActive: true
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
for (const ep of eps) {
|
|
97
|
-
const eventId = ep.eventId;
|
|
98
|
-
const existing = eventMap.get(eventId);
|
|
99
|
-
if (existing) {
|
|
100
|
-
if (!existing.productNames.includes(productName)) {
|
|
101
|
-
existing.productNames.push(productName);
|
|
102
|
-
}
|
|
103
|
-
} else {
|
|
104
|
-
const event = await eventRepo.findOne({
|
|
105
|
-
where: {
|
|
106
|
-
id: eventId,
|
|
107
|
-
deleted: false
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
if (event) {
|
|
111
|
-
eventMap.set(eventId, {
|
|
112
|
-
event,
|
|
113
|
-
productNames: [
|
|
114
|
-
productName
|
|
115
|
-
]
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
if (eventMap.size === 0) return;
|
|
122
|
-
const notifSettings = await getSettingsGroup(deps, "event_notifications");
|
|
123
|
-
if (notifSettings.enabled === "false" || notifSettings.enabled === "0") return;
|
|
124
|
-
const cms = await deps.getCms();
|
|
125
|
-
const branding = await getSettingsGroup(deps, "branding");
|
|
126
|
-
const emailSettings = await getSettingsGroup(deps, "email");
|
|
127
|
-
const companyDetails = mergeEmailLayoutCompanyDetails(branding, emailSettings);
|
|
128
|
-
for (const { event, productNames: eventProductNames } of eventMap.values()) {
|
|
129
|
-
if (!event.orderNotificationsEnabled) continue;
|
|
130
|
-
const channels = event.orderNotificationChannels;
|
|
131
|
-
const overrides = event.orderNotificationTemplates;
|
|
132
|
-
const vars = buildEventOrderTemplateVariables({
|
|
133
|
-
event,
|
|
134
|
-
order: {
|
|
135
|
-
orderNumber: o.orderNumber,
|
|
136
|
-
total: o.total,
|
|
137
|
-
currency: o.currency,
|
|
138
|
-
qrToken: o.qrToken
|
|
139
|
-
},
|
|
140
|
-
contact,
|
|
141
|
-
productNames: eventProductNames.join(", "),
|
|
142
|
-
orderLines,
|
|
143
|
-
siteUrl
|
|
144
|
-
});
|
|
145
|
-
if (channelEnabled(channels, "email") && contact.email?.trim()) {
|
|
146
|
-
const resolved = await resolveEventOrderTemplate("email", getTemplateRow, overrides?.email ?? null);
|
|
147
|
-
if (resolved?.enabled) {
|
|
148
|
-
const subject = applyTemplateVars(resolved.subject ?? "Event registration confirmed", vars);
|
|
149
|
-
const bodyHtml = applyTemplateVars(resolved.body, vars);
|
|
150
|
-
const html = renderLayout({
|
|
151
|
-
bodyHtml,
|
|
152
|
-
companyDetails
|
|
153
|
-
});
|
|
154
|
-
await queueEmail(cms, {
|
|
155
|
-
to: contact.email.trim(),
|
|
156
|
-
subject,
|
|
157
|
-
html,
|
|
158
|
-
text: bodyHtml.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim()
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
if (channelEnabled(channels, "whatsapp") && contact.phone?.trim()) {
|
|
163
|
-
const resolved = await resolveEventOrderTemplate("whatsapp", getTemplateRow, overrides?.whatsapp ?? null);
|
|
164
|
-
if (resolved?.enabled) {
|
|
165
|
-
const { EVENT_ORDER_WHATSAPP_PARAM_KEYS } = await import('./event-order-defaults-6E543227.js');
|
|
166
|
-
const sent = await queueWhatsApp(cms, {
|
|
167
|
-
to: contact.phone.trim(),
|
|
168
|
-
templateKey: EVENT_ORDER_TEMPLATE_KEY,
|
|
169
|
-
externalTemplateRef: resolved.externalTemplateRef,
|
|
170
|
-
body: resolved.body,
|
|
171
|
-
variables: vars,
|
|
172
|
-
templateParamOrder: EVENT_ORDER_WHATSAPP_PARAM_KEYS
|
|
173
|
-
});
|
|
174
|
-
if (!sent) {
|
|
175
|
-
console.warn("[event-order-notifications] WhatsApp not sent for order", {
|
|
176
|
-
orderId,
|
|
177
|
-
eventId: event.id
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
__name(dispatchEventOrderNotifications, "dispatchEventOrderNotifications");
|
|
185
|
-
|
|
186
|
-
export { dispatchEventOrderNotifications };
|
package/dist/chunk-R73BKDRO.cjs
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
|
|
4
|
-
|
|
5
|
-
// src/lib/event-order-template-context.ts
|
|
6
|
-
function resolvePublicSiteUrl() {
|
|
7
|
-
if (typeof process !== "undefined") {
|
|
8
|
-
const u = (process.env.CMS_PUBLIC_URL || process.env.NEXT_PUBLIC_SITE_URL || "").trim();
|
|
9
|
-
if (u) return u.replace(/\/+$/, "");
|
|
10
|
-
const v = (process.env.VERCEL_URL || "").trim();
|
|
11
|
-
if (v) return v.startsWith("http") ? v.replace(/\/+$/, "") : `https://${v.replace(/\/+$/, "")}`;
|
|
12
|
-
}
|
|
13
|
-
return "";
|
|
14
|
-
}
|
|
15
|
-
chunkUSNT2KNT_cjs.__name(resolvePublicSiteUrl, "resolvePublicSiteUrl");
|
|
16
|
-
function buildOrderTrackUrl(qrToken, siteUrl) {
|
|
17
|
-
const token = qrToken?.trim();
|
|
18
|
-
if (!token) return "";
|
|
19
|
-
const base = (siteUrl ?? resolvePublicSiteUrl()).replace(/\/+$/, "");
|
|
20
|
-
if (!base) return `/track/${token}`;
|
|
21
|
-
return `${base}/track/${token}`;
|
|
22
|
-
}
|
|
23
|
-
chunkUSNT2KNT_cjs.__name(buildOrderTrackUrl, "buildOrderTrackUrl");
|
|
24
|
-
function buildOrderQrImageUrl(trackUrl, size = 200) {
|
|
25
|
-
if (!trackUrl.trim()) return "";
|
|
26
|
-
return `https://api.qrserver.com/v1/create-qr-code/?size=${size}x${size}&data=${encodeURIComponent(trackUrl)}`;
|
|
27
|
-
}
|
|
28
|
-
chunkUSNT2KNT_cjs.__name(buildOrderQrImageUrl, "buildOrderQrImageUrl");
|
|
29
|
-
function formatOrderDetailsText(input) {
|
|
30
|
-
const { orderNumber, total, currency, lines } = input;
|
|
31
|
-
const header = `Order: ${orderNumber}
|
|
32
|
-
Total: ${total} ${currency}`;
|
|
33
|
-
if (!lines.length) return header;
|
|
34
|
-
const items = lines.map((line) => `- ${line.name} \xD7 ${line.quantity} (${line.total} ${line.currency})`).join("\n");
|
|
35
|
-
return `${header}
|
|
36
|
-
|
|
37
|
-
Items:
|
|
38
|
-
${items}`;
|
|
39
|
-
}
|
|
40
|
-
chunkUSNT2KNT_cjs.__name(formatOrderDetailsText, "formatOrderDetailsText");
|
|
41
|
-
function formatOrderDetailsHtml(input) {
|
|
42
|
-
const text = formatOrderDetailsText(input);
|
|
43
|
-
const escaped = text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
44
|
-
return `<pre style="font-family:inherit;white-space:pre-wrap;margin:0">${escaped}</pre>`;
|
|
45
|
-
}
|
|
46
|
-
chunkUSNT2KNT_cjs.__name(formatOrderDetailsHtml, "formatOrderDetailsHtml");
|
|
47
|
-
function buildEventOrderTemplateVariables(input) {
|
|
48
|
-
const { event, order, contact, productNames, orderLines = [], siteUrl } = input;
|
|
49
|
-
const trackUrl = buildOrderTrackUrl(order.qrToken, siteUrl);
|
|
50
|
-
const qrImageUrl = buildOrderQrImageUrl(trackUrl);
|
|
51
|
-
const orderDetailsPayload = {
|
|
52
|
-
orderNumber: String(order.orderNumber ?? ""),
|
|
53
|
-
total: String(order.total ?? ""),
|
|
54
|
-
currency: String(order.currency ?? "INR"),
|
|
55
|
-
lines: orderLines
|
|
56
|
-
};
|
|
57
|
-
return {
|
|
58
|
-
eventName: event.name ?? "",
|
|
59
|
-
eventSlug: event.slug ?? "",
|
|
60
|
-
venue: event.venue ?? "",
|
|
61
|
-
startDate: formatEventDate(event.startDate),
|
|
62
|
-
orderNumber: String(order.orderNumber ?? ""),
|
|
63
|
-
orderTotal: String(order.total ?? ""),
|
|
64
|
-
currency: String(order.currency ?? "INR"),
|
|
65
|
-
customerName: contact.name?.trim() || contact.email?.split("@")[0] || "Guest",
|
|
66
|
-
customerEmail: contact.email?.trim() || "",
|
|
67
|
-
customerPhone: contact.phone?.trim() || "",
|
|
68
|
-
productNames,
|
|
69
|
-
trackUrl,
|
|
70
|
-
qrImageUrl,
|
|
71
|
-
orderDetails: formatOrderDetailsText(orderDetailsPayload),
|
|
72
|
-
orderDetailsHtml: formatOrderDetailsHtml(orderDetailsPayload)
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
chunkUSNT2KNT_cjs.__name(buildEventOrderTemplateVariables, "buildEventOrderTemplateVariables");
|
|
76
|
-
function formatEventDate(d) {
|
|
77
|
-
if (!d) return "";
|
|
78
|
-
try {
|
|
79
|
-
return new Date(d).toLocaleString(void 0, {
|
|
80
|
-
dateStyle: "medium",
|
|
81
|
-
timeStyle: "short"
|
|
82
|
-
});
|
|
83
|
-
} catch {
|
|
84
|
-
return String(d);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
chunkUSNT2KNT_cjs.__name(formatEventDate, "formatEventDate");
|
|
88
|
-
|
|
89
|
-
exports.buildEventOrderTemplateVariables = buildEventOrderTemplateVariables;
|
|
90
|
-
exports.resolvePublicSiteUrl = resolvePublicSiteUrl;
|