@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-JBRR5UYL.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { __name } from './chunk-SHUYVCID.js';
|
|
2
|
-
|
|
3
|
-
// src/lib/event-order-template-context.ts
|
|
4
|
-
function resolvePublicSiteUrl() {
|
|
5
|
-
if (typeof process !== "undefined") {
|
|
6
|
-
const u = (process.env.CMS_PUBLIC_URL || process.env.NEXT_PUBLIC_SITE_URL || "").trim();
|
|
7
|
-
if (u) return u.replace(/\/+$/, "");
|
|
8
|
-
const v = (process.env.VERCEL_URL || "").trim();
|
|
9
|
-
if (v) return v.startsWith("http") ? v.replace(/\/+$/, "") : `https://${v.replace(/\/+$/, "")}`;
|
|
10
|
-
}
|
|
11
|
-
return "";
|
|
12
|
-
}
|
|
13
|
-
__name(resolvePublicSiteUrl, "resolvePublicSiteUrl");
|
|
14
|
-
function buildOrderTrackUrl(qrToken, siteUrl) {
|
|
15
|
-
const token = qrToken?.trim();
|
|
16
|
-
if (!token) return "";
|
|
17
|
-
const base = (siteUrl ?? resolvePublicSiteUrl()).replace(/\/+$/, "");
|
|
18
|
-
if (!base) return `/track/${token}`;
|
|
19
|
-
return `${base}/track/${token}`;
|
|
20
|
-
}
|
|
21
|
-
__name(buildOrderTrackUrl, "buildOrderTrackUrl");
|
|
22
|
-
function buildOrderQrImageUrl(trackUrl, size = 200) {
|
|
23
|
-
if (!trackUrl.trim()) return "";
|
|
24
|
-
return `https://api.qrserver.com/v1/create-qr-code/?size=${size}x${size}&data=${encodeURIComponent(trackUrl)}`;
|
|
25
|
-
}
|
|
26
|
-
__name(buildOrderQrImageUrl, "buildOrderQrImageUrl");
|
|
27
|
-
function formatOrderDetailsText(input) {
|
|
28
|
-
const { orderNumber, total, currency, lines } = input;
|
|
29
|
-
const header = `Order: ${orderNumber}
|
|
30
|
-
Total: ${total} ${currency}`;
|
|
31
|
-
if (!lines.length) return header;
|
|
32
|
-
const items = lines.map((line) => `- ${line.name} \xD7 ${line.quantity} (${line.total} ${line.currency})`).join("\n");
|
|
33
|
-
return `${header}
|
|
34
|
-
|
|
35
|
-
Items:
|
|
36
|
-
${items}`;
|
|
37
|
-
}
|
|
38
|
-
__name(formatOrderDetailsText, "formatOrderDetailsText");
|
|
39
|
-
function formatOrderDetailsHtml(input) {
|
|
40
|
-
const text = formatOrderDetailsText(input);
|
|
41
|
-
const escaped = text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
42
|
-
return `<pre style="font-family:inherit;white-space:pre-wrap;margin:0">${escaped}</pre>`;
|
|
43
|
-
}
|
|
44
|
-
__name(formatOrderDetailsHtml, "formatOrderDetailsHtml");
|
|
45
|
-
function buildEventOrderTemplateVariables(input) {
|
|
46
|
-
const { event, order, contact, productNames, orderLines = [], siteUrl } = input;
|
|
47
|
-
const trackUrl = buildOrderTrackUrl(order.qrToken, siteUrl);
|
|
48
|
-
const qrImageUrl = buildOrderQrImageUrl(trackUrl);
|
|
49
|
-
const orderDetailsPayload = {
|
|
50
|
-
orderNumber: String(order.orderNumber ?? ""),
|
|
51
|
-
total: String(order.total ?? ""),
|
|
52
|
-
currency: String(order.currency ?? "INR"),
|
|
53
|
-
lines: orderLines
|
|
54
|
-
};
|
|
55
|
-
return {
|
|
56
|
-
eventName: event.name ?? "",
|
|
57
|
-
eventSlug: event.slug ?? "",
|
|
58
|
-
venue: event.venue ?? "",
|
|
59
|
-
startDate: formatEventDate(event.startDate),
|
|
60
|
-
orderNumber: String(order.orderNumber ?? ""),
|
|
61
|
-
orderTotal: String(order.total ?? ""),
|
|
62
|
-
currency: String(order.currency ?? "INR"),
|
|
63
|
-
customerName: contact.name?.trim() || contact.email?.split("@")[0] || "Guest",
|
|
64
|
-
customerEmail: contact.email?.trim() || "",
|
|
65
|
-
customerPhone: contact.phone?.trim() || "",
|
|
66
|
-
productNames,
|
|
67
|
-
trackUrl,
|
|
68
|
-
qrImageUrl,
|
|
69
|
-
orderDetails: formatOrderDetailsText(orderDetailsPayload),
|
|
70
|
-
orderDetailsHtml: formatOrderDetailsHtml(orderDetailsPayload)
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
__name(buildEventOrderTemplateVariables, "buildEventOrderTemplateVariables");
|
|
74
|
-
function formatEventDate(d) {
|
|
75
|
-
if (!d) return "";
|
|
76
|
-
try {
|
|
77
|
-
return new Date(d).toLocaleString(void 0, {
|
|
78
|
-
dateStyle: "medium",
|
|
79
|
-
timeStyle: "short"
|
|
80
|
-
});
|
|
81
|
-
} catch {
|
|
82
|
-
return String(d);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
__name(formatEventDate, "formatEventDate");
|
|
86
|
-
|
|
87
|
-
export { buildEventOrderTemplateVariables, resolvePublicSiteUrl };
|
package/dist/chunk-JHF4YYRC.cjs
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunk46GKADYE_cjs = require('./chunk-46GKADYE.cjs');
|
|
4
|
-
var chunkOOTLNH63_cjs = require('./chunk-OOTLNH63.cjs');
|
|
5
|
-
var chunk7YIBMQDR_cjs = require('./chunk-7YIBMQDR.cjs');
|
|
6
|
-
var chunkR73BKDRO_cjs = require('./chunk-R73BKDRO.cjs');
|
|
7
|
-
var chunkPAMVINEX_cjs = require('./chunk-PAMVINEX.cjs');
|
|
8
|
-
var chunkXW5ATPRW_cjs = require('./chunk-XW5ATPRW.cjs');
|
|
9
|
-
var chunkN44BJZ4C_cjs = require('./chunk-N44BJZ4C.cjs');
|
|
10
|
-
var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
|
|
11
|
-
|
|
12
|
-
// src/lib/event-order-notifications.ts
|
|
13
|
-
async function getSettingsGroup(deps, group) {
|
|
14
|
-
const rows = await deps.dataSource.getRepository(deps.entityMap["configs"]).find({
|
|
15
|
-
where: {
|
|
16
|
-
settings: group,
|
|
17
|
-
deleted: false
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
return Object.fromEntries(rows.map((r) => [
|
|
21
|
-
r.key,
|
|
22
|
-
r.value
|
|
23
|
-
]));
|
|
24
|
-
}
|
|
25
|
-
chunkUSNT2KNT_cjs.__name(getSettingsGroup, "getSettingsGroup");
|
|
26
|
-
function channelEnabled(channels, ch) {
|
|
27
|
-
if (!Array.isArray(channels) || channels.length === 0) return false;
|
|
28
|
-
return channels.includes(ch);
|
|
29
|
-
}
|
|
30
|
-
chunkUSNT2KNT_cjs.__name(channelEnabled, "channelEnabled");
|
|
31
|
-
async function dispatchEventOrderNotifications(orderId, deps) {
|
|
32
|
-
const orderRepo = deps.dataSource.getRepository(deps.entityMap["orders"]);
|
|
33
|
-
const order = await orderRepo.findOne({
|
|
34
|
-
where: {
|
|
35
|
-
id: orderId,
|
|
36
|
-
deleted: false
|
|
37
|
-
},
|
|
38
|
-
relations: [
|
|
39
|
-
"contact"
|
|
40
|
-
]
|
|
41
|
-
});
|
|
42
|
-
if (!order) return;
|
|
43
|
-
const o = order;
|
|
44
|
-
const contact = o.contact ?? {};
|
|
45
|
-
const siteUrl = chunkR73BKDRO_cjs.resolvePublicSiteUrl();
|
|
46
|
-
const itemRows = await deps.dataSource.getRepository(deps.entityMap["order_items"]).find({
|
|
47
|
-
where: {
|
|
48
|
-
orderId
|
|
49
|
-
},
|
|
50
|
-
relations: [
|
|
51
|
-
"product"
|
|
52
|
-
],
|
|
53
|
-
order: {
|
|
54
|
-
id: "ASC"
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
if (!itemRows.length) return;
|
|
58
|
-
const epRepo = deps.dataSource.getRepository(deps.entityMap["event_products"]);
|
|
59
|
-
const eventRepo = deps.dataSource.getRepository(deps.entityMap["events"]);
|
|
60
|
-
const templateRepo = deps.dataSource.getRepository(deps.entityMap["message_templates"]);
|
|
61
|
-
const getTemplateRow = /* @__PURE__ */ chunkUSNT2KNT_cjs.__name(async (channel, templateKey) => {
|
|
62
|
-
const row = await templateRepo.findOne({
|
|
63
|
-
where: {
|
|
64
|
-
channel,
|
|
65
|
-
templateKey,
|
|
66
|
-
deleted: false
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
if (!row) return null;
|
|
70
|
-
const r = row;
|
|
71
|
-
return {
|
|
72
|
-
subject: r.subject,
|
|
73
|
-
body: r.body,
|
|
74
|
-
externalTemplateRef: r.externalTemplateRef,
|
|
75
|
-
enabled: r.enabled
|
|
76
|
-
};
|
|
77
|
-
}, "getTemplateRow");
|
|
78
|
-
const orderLines = itemRows.map((item) => {
|
|
79
|
-
const row = item;
|
|
80
|
-
const name = row.product?.name || row.product?.title || `Product #${row.productId}`;
|
|
81
|
-
return {
|
|
82
|
-
name: String(name),
|
|
83
|
-
quantity: Number(row.quantity) || 1,
|
|
84
|
-
total: row.total,
|
|
85
|
-
currency: String(o.currency ?? "INR")
|
|
86
|
-
};
|
|
87
|
-
});
|
|
88
|
-
const eventMap = /* @__PURE__ */ new Map();
|
|
89
|
-
for (const item of itemRows) {
|
|
90
|
-
const productId = item.productId;
|
|
91
|
-
const productName = item.product?.name || item.product?.title || `Product #${productId}`;
|
|
92
|
-
const eps = await epRepo.find({
|
|
93
|
-
where: {
|
|
94
|
-
productId,
|
|
95
|
-
isActive: true
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
for (const ep of eps) {
|
|
99
|
-
const eventId = ep.eventId;
|
|
100
|
-
const existing = eventMap.get(eventId);
|
|
101
|
-
if (existing) {
|
|
102
|
-
if (!existing.productNames.includes(productName)) {
|
|
103
|
-
existing.productNames.push(productName);
|
|
104
|
-
}
|
|
105
|
-
} else {
|
|
106
|
-
const event = await eventRepo.findOne({
|
|
107
|
-
where: {
|
|
108
|
-
id: eventId,
|
|
109
|
-
deleted: false
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
if (event) {
|
|
113
|
-
eventMap.set(eventId, {
|
|
114
|
-
event,
|
|
115
|
-
productNames: [
|
|
116
|
-
productName
|
|
117
|
-
]
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
if (eventMap.size === 0) return;
|
|
124
|
-
const notifSettings = await getSettingsGroup(deps, "event_notifications");
|
|
125
|
-
if (notifSettings.enabled === "false" || notifSettings.enabled === "0") return;
|
|
126
|
-
const cms = await deps.getCms();
|
|
127
|
-
const branding = await getSettingsGroup(deps, "branding");
|
|
128
|
-
const emailSettings = await getSettingsGroup(deps, "email");
|
|
129
|
-
const companyDetails = chunkPAMVINEX_cjs.mergeEmailLayoutCompanyDetails(branding, emailSettings);
|
|
130
|
-
for (const { event, productNames: eventProductNames } of eventMap.values()) {
|
|
131
|
-
if (!event.orderNotificationsEnabled) continue;
|
|
132
|
-
const channels = event.orderNotificationChannels;
|
|
133
|
-
const overrides = event.orderNotificationTemplates;
|
|
134
|
-
const vars = chunkR73BKDRO_cjs.buildEventOrderTemplateVariables({
|
|
135
|
-
event,
|
|
136
|
-
order: {
|
|
137
|
-
orderNumber: o.orderNumber,
|
|
138
|
-
total: o.total,
|
|
139
|
-
currency: o.currency,
|
|
140
|
-
qrToken: o.qrToken
|
|
141
|
-
},
|
|
142
|
-
contact,
|
|
143
|
-
productNames: eventProductNames.join(", "),
|
|
144
|
-
orderLines,
|
|
145
|
-
siteUrl
|
|
146
|
-
});
|
|
147
|
-
if (channelEnabled(channels, "email") && contact.email?.trim()) {
|
|
148
|
-
const resolved = await chunkN44BJZ4C_cjs.resolveEventOrderTemplate("email", getTemplateRow, overrides?.email ?? null);
|
|
149
|
-
if (resolved?.enabled) {
|
|
150
|
-
const subject = chunkOOTLNH63_cjs.applyTemplateVars(resolved.subject ?? "Event registration confirmed", vars);
|
|
151
|
-
const bodyHtml = chunkOOTLNH63_cjs.applyTemplateVars(resolved.body, vars);
|
|
152
|
-
const html = chunk46GKADYE_cjs.renderLayout({
|
|
153
|
-
bodyHtml,
|
|
154
|
-
companyDetails
|
|
155
|
-
});
|
|
156
|
-
await chunkXW5ATPRW_cjs.queueEmail(cms, {
|
|
157
|
-
to: contact.email.trim(),
|
|
158
|
-
subject,
|
|
159
|
-
html,
|
|
160
|
-
text: bodyHtml.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim()
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
if (channelEnabled(channels, "whatsapp") && contact.phone?.trim()) {
|
|
165
|
-
const resolved = await chunkN44BJZ4C_cjs.resolveEventOrderTemplate("whatsapp", getTemplateRow, overrides?.whatsapp ?? null);
|
|
166
|
-
if (resolved?.enabled) {
|
|
167
|
-
const { EVENT_ORDER_WHATSAPP_PARAM_KEYS } = await import('./event-order-defaults-DUGDVGJI.cjs');
|
|
168
|
-
const sent = await chunk7YIBMQDR_cjs.queueWhatsApp(cms, {
|
|
169
|
-
to: contact.phone.trim(),
|
|
170
|
-
templateKey: chunkN44BJZ4C_cjs.EVENT_ORDER_TEMPLATE_KEY,
|
|
171
|
-
externalTemplateRef: resolved.externalTemplateRef,
|
|
172
|
-
body: resolved.body,
|
|
173
|
-
variables: vars,
|
|
174
|
-
templateParamOrder: EVENT_ORDER_WHATSAPP_PARAM_KEYS
|
|
175
|
-
});
|
|
176
|
-
if (!sent) {
|
|
177
|
-
console.warn("[event-order-notifications] WhatsApp not sent for order", {
|
|
178
|
-
orderId,
|
|
179
|
-
eventId: event.id
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
chunkUSNT2KNT_cjs.__name(dispatchEventOrderNotifications, "dispatchEventOrderNotifications");
|
|
187
|
-
|
|
188
|
-
exports.dispatchEventOrderNotifications = dispatchEventOrderNotifications;
|