@infuro/cms-core 1.0.45 → 1.0.47

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 (82) hide show
  1. package/README.md +19 -2
  2. package/dist/admin.cjs +4249 -2872
  3. package/dist/admin.d.cts +24 -4
  4. package/dist/admin.d.ts +24 -4
  5. package/dist/admin.js +3179 -1804
  6. package/dist/api.cjs +41 -39
  7. package/dist/api.d.cts +10 -4
  8. package/dist/api.d.ts +10 -4
  9. package/dist/api.js +9 -7
  10. package/dist/auth.cjs +55 -51
  11. package/dist/auth.d.cts +6 -3
  12. package/dist/auth.d.ts +6 -3
  13. package/dist/auth.js +3 -3
  14. package/dist/{chunk-KFFB6EMZ.js → chunk-2HU5R2JE.js} +2 -0
  15. package/dist/chunk-2IAXTKQN.cjs +19 -0
  16. package/dist/chunk-2KUCQVAQ.js +936 -0
  17. package/dist/chunk-3K5AIEIZ.js +256 -0
  18. package/dist/{chunk-SPQFNIYJ.cjs → chunk-4PMK3RNA.cjs} +2 -0
  19. package/dist/{chunk-X6UQFV4X.cjs → chunk-77NUXO6A.cjs} +14 -12
  20. package/dist/chunk-BXYZDMTZ.cjs +953 -0
  21. package/dist/chunk-DBPSJYLZ.js +47 -0
  22. package/dist/chunk-EIZKW2PF.js +13 -0
  23. package/dist/chunk-HY3AXLOI.cjs +265 -0
  24. package/dist/{chunk-X47PBV4I.js → chunk-JE22VP6S.js} +1 -0
  25. package/dist/{chunk-DN65KDIA.js → chunk-JIWUVQ6B.js} +14 -13
  26. package/dist/{chunk-HT5DI3XW.cjs → chunk-KOTXDSQB.cjs} +1 -0
  27. package/dist/chunk-L3525VXI.js +243 -0
  28. package/dist/{chunk-22FFHLTO.cjs → chunk-LMJ7RKPF.cjs} +421 -150
  29. package/dist/chunk-OY2YTBMP.cjs +50 -0
  30. package/dist/{chunk-TAHX46EI.cjs → chunk-Q3HQEM4R.cjs} +15 -7
  31. package/dist/chunk-V25RDUOU.cjs +248 -0
  32. package/dist/{chunk-ZMRQ72F6.cjs → chunk-VUQFARRT.cjs} +10 -10
  33. package/dist/{chunk-MVXLRANV.js → chunk-W42UZLQO.js} +1977 -891
  34. package/dist/{chunk-F5XFHYTG.cjs → chunk-XUCKZPML.cjs} +2088 -991
  35. package/dist/{chunk-I6NH72MO.js → chunk-YC4NUZCS.js} +10 -2
  36. package/dist/{chunk-NNQBWDCI.js → chunk-YXH2UUEZ.js} +418 -146
  37. package/dist/{chunk-BLR6H5GL.js → chunk-ZF2RQWXB.js} +4 -4
  38. package/dist/cli.cjs +9 -4
  39. package/dist/cli.js +9 -4
  40. package/dist/{email-queue-TPZWLTIV.cjs → email-queue-6NJY6HNM.cjs} +7 -5
  41. package/dist/email-queue-OI2HSCGE.js +4 -0
  42. package/dist/{emit-order-notification-trigger-IVLWKKJL.js → emit-order-notification-trigger-6XX7LSC4.js} +1 -1
  43. package/dist/{emit-order-notification-trigger-D2N3KFHL.cjs → emit-order-notification-trigger-NASG7ZEO.cjs} +3 -3
  44. package/dist/erp-order-invoice-3GXDE443.js +3 -0
  45. package/dist/erp-order-invoice-EYYNR526.cjs +24 -0
  46. package/dist/{event-order-defaults-EMWBIGL3.cjs → event-order-defaults-7Z3UZOEH.cjs} +9 -9
  47. package/dist/{event-order-defaults-SDRNAZHC.js → event-order-defaults-XQ3IDPD7.js} +1 -1
  48. package/dist/hooks.cjs +43 -0
  49. package/dist/hooks.d.cts +10 -1
  50. package/dist/hooks.d.ts +10 -1
  51. package/dist/hooks.js +39 -1
  52. package/dist/index.cjs +429 -298
  53. package/dist/index.d.cts +317 -30
  54. package/dist/index.d.ts +317 -30
  55. package/dist/index.js +17 -13
  56. package/dist/migrations/1781810000000-OrderItemsVariantId.ts +44 -0
  57. package/dist/migrations/1781900000000-UserInviteStatusToken.ts +46 -0
  58. package/dist/migrations/1782000000000-ComboSlug.ts +58 -0
  59. package/dist/migrations/1782100000000-DiscountDeviceType.ts +20 -0
  60. package/dist/migrations/1782200000000-VendorTeamProfiles.ts +233 -0
  61. package/dist/migrations/1782300000000-AddTypeToOrderNotificationBindings.ts +75 -0
  62. package/dist/order-inventory-2MYRKEPC.cjs +39 -0
  63. package/dist/order-inventory-76V4XIGW.js +2 -0
  64. package/dist/{order-notification-dispatcher-XWIJYDGA.js → order-notification-dispatcher-6WNG24NY.js} +4 -2
  65. package/dist/{order-notification-dispatcher-RU7BTGGX.cjs → order-notification-dispatcher-6XSU3AR7.cjs} +6 -4
  66. package/dist/{rbac-debug-db-2SGNLANF.js → rbac-debug-db-6EMIVMGF.js} +1 -1
  67. package/dist/{rbac-debug-db-4Z6A425H.cjs → rbac-debug-db-6PWTLBEL.cjs} +2 -2
  68. package/dist/retire-soft-deleted-unique-5VXBA5XX.cjs +15 -0
  69. package/dist/retire-soft-deleted-unique-NXQIH4BC.js +2 -0
  70. package/dist/theme.cjs +6 -1
  71. package/dist/theme.d.cts +4 -1
  72. package/dist/theme.d.ts +4 -1
  73. package/dist/theme.js +3 -1
  74. package/package.json +5 -4
  75. package/src/admin/admin.css +34 -24
  76. package/dist/chunk-5ELSW2UP.js +0 -150
  77. package/dist/chunk-PNOKNSG2.cjs +0 -222
  78. package/dist/chunk-WEMDMVHQ.js +0 -216
  79. package/dist/chunk-XW5ATPRW.cjs +0 -155
  80. package/dist/email-queue-CGZBVVAS.js +0 -2
  81. package/dist/erp-order-invoice-3YISSOWW.js +0 -3
  82. package/dist/erp-order-invoice-ZR5F2KTA.cjs +0 -12
@@ -1,216 +0,0 @@
1
- import { isErpIntegrationEnabled } from './chunk-JC6DLWTE.js';
2
- import { __name } from './chunk-SHUYVCID.js';
3
-
4
- // src/plugins/erp/erp-response-map.ts
5
- function pickString(o, keys) {
6
- for (const k of keys) {
7
- const v = o[k];
8
- if (typeof v === "string" && v.trim()) return v.trim();
9
- }
10
- return void 0;
11
- }
12
- __name(pickString, "pickString");
13
- function unwrapErpReadData(json) {
14
- if (!json || typeof json !== "object") return null;
15
- const o = json;
16
- const d = o.data;
17
- if (d && typeof d === "object" && !Array.isArray(d)) return d;
18
- return o;
19
- }
20
- __name(unwrapErpReadData, "unwrapErpReadData");
21
- function firstObject(data, keys) {
22
- for (const k of keys) {
23
- const v = data[k];
24
- if (v && typeof v === "object" && !Array.isArray(v)) return v;
25
- }
26
- return null;
27
- }
28
- __name(firstObject, "firstObject");
29
- function extractEvents(src) {
30
- const timeline = src.timeline ?? src.events ?? src.history ?? src.trackingEvents;
31
- if (!Array.isArray(timeline) || !timeline.length) return void 0;
32
- const events = [];
33
- for (const row of timeline) {
34
- if (!row || typeof row !== "object") continue;
35
- const r = row;
36
- const at = pickString(r, [
37
- "at",
38
- "timestamp",
39
- "date",
40
- "occurredAt"
41
- ]) ?? (r.at instanceof Date ? r.at.toISOString() : void 0);
42
- const label = pickString(r, [
43
- "label",
44
- "status",
45
- "title",
46
- "message",
47
- "description"
48
- ]);
49
- const detail = pickString(r, [
50
- "detail",
51
- "notes",
52
- "description"
53
- ]);
54
- if (at || label || detail) events.push({
55
- at,
56
- label,
57
- detail
58
- });
59
- }
60
- return events.length ? events : void 0;
61
- }
62
- __name(extractEvents, "extractEvents");
63
- function mapErpPayloadToFulfillment(data) {
64
- const nested = firstObject(data, [
65
- "fulfillment",
66
- "packaging",
67
- "shipment",
68
- "shipping",
69
- "delivery"
70
- ]);
71
- const src = nested || data;
72
- const status = pickString(src, [
73
- "status",
74
- "fulfillmentStatus",
75
- "state",
76
- "label",
77
- "packagingStatus"
78
- ]);
79
- const trackingId = pickString(src, [
80
- "trackingId",
81
- "tracking_id",
82
- "trackingNumber",
83
- "awb",
84
- "trackingUrl"
85
- ]);
86
- const events = extractEvents(src);
87
- if (!status && !trackingId && !(events && events.length)) return void 0;
88
- return {
89
- status,
90
- trackingId,
91
- events
92
- };
93
- }
94
- __name(mapErpPayloadToFulfillment, "mapErpPayloadToFulfillment");
95
- function mapErpPayloadToInvoiceNumber(data) {
96
- const nested = firstObject(data, [
97
- "invoice",
98
- "latestInvoice",
99
- "postedInvoice"
100
- ]);
101
- const src = nested || data;
102
- return pickString(src, [
103
- "invoiceNumber",
104
- "invoice_number",
105
- "number",
106
- "name",
107
- "id"
108
- ]);
109
- }
110
- __name(mapErpPayloadToInvoiceNumber, "mapErpPayloadToInvoiceNumber");
111
- function extractChildOrderRefsFromSalePayload(data) {
112
- const lists = [
113
- data.returns,
114
- data.returnOrders,
115
- data.relatedReturns,
116
- data.childOrders,
117
- data.children
118
- ];
119
- const seen = /* @__PURE__ */ new Set();
120
- const out = [];
121
- for (const list of lists) {
122
- if (!Array.isArray(list)) continue;
123
- for (const item of list) {
124
- if (!item || typeof item !== "object") continue;
125
- const o = item;
126
- const ref = pickString(o, [
127
- "platformReturnId",
128
- "platform_return_id",
129
- "refId",
130
- "ref_id"
131
- ]) ?? (typeof o.id === "string" ? o.id : void 0);
132
- if (!ref || seen.has(ref)) continue;
133
- seen.add(ref);
134
- const t = (pickString(o, [
135
- "kind",
136
- "type",
137
- "orderKind"
138
- ]) || "").toLowerCase();
139
- const orderKind = /replac/.test(t) ? "replacement" : "return";
140
- out.push({
141
- ref,
142
- orderKind
143
- });
144
- }
145
- }
146
- return out;
147
- }
148
- __name(extractChildOrderRefsFromSalePayload, "extractChildOrderRefsFromSalePayload");
149
-
150
- // src/plugins/erp/erp-order-invoice.ts
151
- function pickInvoiceId(data) {
152
- const nested = data.invoice && typeof data.invoice === "object" && !Array.isArray(data.invoice) ? data.invoice : null;
153
- const src = nested || data;
154
- for (const k of [
155
- "invoiceId",
156
- "invoice_id",
157
- "id"
158
- ]) {
159
- const v = src[k];
160
- if (typeof v === "string" && v.trim()) return v.trim();
161
- }
162
- return void 0;
163
- }
164
- __name(pickInvoiceId, "pickInvoiceId");
165
- async function streamOrderInvoicePdf(cms, dataSource, entityMap, orderId, options) {
166
- const jsonErr = /* @__PURE__ */ __name((msg, status) => new Response(JSON.stringify({
167
- error: msg
168
- }), {
169
- status,
170
- headers: {
171
- "Content-Type": "application/json"
172
- }
173
- }), "jsonErr");
174
- const on = await isErpIntegrationEnabled(cms, dataSource, entityMap);
175
- if (!on) return jsonErr("Invoice not available", 503);
176
- const erp = cms.getPlugin("erp");
177
- if (!erp?.submission) return jsonErr("Invoice not available", 503);
178
- const orderRepo = dataSource.getRepository(entityMap.orders);
179
- const order = await orderRepo.findOne({
180
- where: {
181
- id: orderId,
182
- deleted: false
183
- }
184
- });
185
- if (!order) return jsonErr("Not found", 404);
186
- const kind = order.orderKind || "sale";
187
- if (kind !== "sale") return jsonErr("Invoice only for sale orders", 400);
188
- if (options.ownerContactId != null && order.contactId !== options.ownerContactId) {
189
- return jsonErr("Not found", 404);
190
- }
191
- const meta = order.metadata && typeof order.metadata === "object" && !Array.isArray(order.metadata) ? order.metadata : {};
192
- const inv = meta.invoice && typeof meta.invoice === "object" && !Array.isArray(meta.invoice) ? meta.invoice : {};
193
- let invoiceId = typeof inv.invoiceId === "string" ? inv.invoiceId.trim() : "";
194
- if (!invoiceId) {
195
- const refId = String(order.orderNumber || "");
196
- const r = await erp.submission.postErpReadAction("get-invoice", {
197
- platformOrderId: refId
198
- });
199
- const d = r.ok ? unwrapErpReadData(r.json) : null;
200
- invoiceId = d ? pickInvoiceId(d) || "" : "";
201
- }
202
- if (!invoiceId) return jsonErr("Invoice not ready", 404);
203
- const pdf = await erp.submission.fetchInvoicePdf(invoiceId);
204
- if (!pdf.ok || !pdf.buffer) return jsonErr(pdf.error || "PDF fetch failed", 502);
205
- const filename = `invoice-${orderId}.pdf`;
206
- return new Response(pdf.buffer, {
207
- status: 200,
208
- headers: {
209
- "Content-Type": pdf.contentType || "application/pdf",
210
- "Content-Disposition": `attachment; filename="${filename}"`
211
- }
212
- });
213
- }
214
- __name(streamOrderInvoicePdf, "streamOrderInvoicePdf");
215
-
216
- export { extractChildOrderRefsFromSalePayload, mapErpPayloadToFulfillment, mapErpPayloadToInvoiceNumber, streamOrderInvoicePdf, unwrapErpReadData };
@@ -1,155 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
4
-
5
- // src/plugins/email/email-queue.ts
6
- var EMAIL_QUEUE_NAME = "email";
7
- function registerEmailQueueProcessor(cms) {
8
- const queue = cms.getPlugin("queue");
9
- const email = cms.getPlugin("email");
10
- if (!queue || !email) return;
11
- queue.registerProcessor(EMAIL_QUEUE_NAME, async (data) => {
12
- const payload = data;
13
- const { to, templateName, ctx, subject, html, text } = payload;
14
- if (!to) return;
15
- if (templateName && ctx) {
16
- const rendered = email.renderTemplate(templateName, ctx);
17
- await email.send({
18
- to,
19
- subject: rendered.subject,
20
- html: rendered.html,
21
- text: rendered.text
22
- });
23
- } else if (subject != null && html != null) {
24
- await email.send({
25
- to,
26
- subject,
27
- html,
28
- text
29
- });
30
- }
31
- });
32
- }
33
- chunkUSNT2KNT_cjs.__name(registerEmailQueueProcessor, "registerEmailQueueProcessor");
34
- async function queueEmail(cms, payload) {
35
- const queue = cms.getPlugin("queue");
36
- if (queue) {
37
- await queue.add(EMAIL_QUEUE_NAME, payload);
38
- return;
39
- }
40
- const email = cms.getPlugin("email");
41
- if (email && payload.templateName && payload.ctx) {
42
- const rendered = email.renderTemplate(payload.templateName, payload.ctx);
43
- await email.send({
44
- to: payload.to,
45
- subject: rendered.subject,
46
- html: rendered.html,
47
- text: rendered.text
48
- });
49
- } else if (email && payload.subject != null && payload.html != null) {
50
- await email.send({
51
- to: payload.to,
52
- subject: payload.subject,
53
- html: payload.html,
54
- text: payload.text
55
- });
56
- }
57
- }
58
- chunkUSNT2KNT_cjs.__name(queueEmail, "queueEmail");
59
- async function queueOrderPlacedEmails(cms, payload) {
60
- const { orderNumber, total, subtotal, tax, currency, customerName, customerEmail, salesTeamEmails, companyDetails, lineItems, billingAddress, shippingAddress } = payload;
61
- const base = {
62
- orderNumber,
63
- total: total != null ? String(total) : void 0,
64
- subtotal: subtotal != null ? String(subtotal) : void 0,
65
- tax: tax != null ? String(tax) : void 0,
66
- currency,
67
- customerName,
68
- companyDetails: companyDetails ?? {},
69
- lineItems: lineItems ?? [],
70
- billingAddress,
71
- shippingAddress
72
- };
73
- const customerLower = customerEmail?.trim().toLowerCase() ?? "";
74
- const jobs = [];
75
- if (customerEmail?.trim()) {
76
- jobs.push(queueEmail(cms, {
77
- to: customerEmail.trim(),
78
- templateName: "orderPlaced",
79
- ctx: {
80
- ...base,
81
- audience: "customer"
82
- }
83
- }));
84
- }
85
- const seen = /* @__PURE__ */ new Set();
86
- for (const raw of salesTeamEmails) {
87
- const to = raw.trim();
88
- if (!to) continue;
89
- const key = to.toLowerCase();
90
- if (seen.has(key)) continue;
91
- seen.add(key);
92
- if (customerLower && key === customerLower) continue;
93
- jobs.push(queueEmail(cms, {
94
- to,
95
- templateName: "orderPlaced",
96
- ctx: {
97
- ...base,
98
- audience: "sales",
99
- internalCustomerEmail: customerEmail?.trim() || void 0
100
- }
101
- }));
102
- }
103
- await Promise.all(jobs);
104
- }
105
- chunkUSNT2KNT_cjs.__name(queueOrderPlacedEmails, "queueOrderPlacedEmails");
106
- async function queueVendorOnboardEmails(cms, payload) {
107
- const { vendorName, vendorSlug, ownerName, ownerEmail, activation, inviteLink, signInLink, kind = "vendor_onboard", notifyEmails, companyDetails, sendToOwner = true } = payload;
108
- const base = {
109
- vendorName,
110
- vendorSlug,
111
- ownerName,
112
- ownerEmail,
113
- activation,
114
- inviteLink,
115
- signInLink,
116
- kind,
117
- companyDetails: companyDetails ?? {}
118
- };
119
- const ownerLower = ownerEmail?.trim().toLowerCase() ?? "";
120
- const jobs = [];
121
- if (sendToOwner && ownerEmail?.trim()) {
122
- jobs.push(queueEmail(cms, {
123
- to: ownerEmail.trim(),
124
- templateName: "vendorOnboarded",
125
- ctx: {
126
- ...base,
127
- audience: "owner"
128
- }
129
- }));
130
- }
131
- const seen = /* @__PURE__ */ new Set();
132
- for (const raw of notifyEmails) {
133
- const to = raw.trim();
134
- if (!to) continue;
135
- const key = to.toLowerCase();
136
- if (seen.has(key)) continue;
137
- seen.add(key);
138
- if (ownerLower && key === ownerLower) continue;
139
- jobs.push(queueEmail(cms, {
140
- to,
141
- templateName: "vendorOnboarded",
142
- ctx: {
143
- ...base,
144
- audience: "internal"
145
- }
146
- }));
147
- }
148
- await Promise.all(jobs);
149
- }
150
- chunkUSNT2KNT_cjs.__name(queueVendorOnboardEmails, "queueVendorOnboardEmails");
151
-
152
- exports.queueEmail = queueEmail;
153
- exports.queueOrderPlacedEmails = queueOrderPlacedEmails;
154
- exports.queueVendorOnboardEmails = queueVendorOnboardEmails;
155
- exports.registerEmailQueueProcessor = registerEmailQueueProcessor;
@@ -1,2 +0,0 @@
1
- export { queueEmail, queueOrderPlacedEmails, queueVendorOnboardEmails, registerEmailQueueProcessor } from './chunk-5ELSW2UP.js';
2
- import './chunk-SHUYVCID.js';
@@ -1,3 +0,0 @@
1
- export { streamOrderInvoicePdf } from './chunk-WEMDMVHQ.js';
2
- import './chunk-JC6DLWTE.js';
3
- import './chunk-SHUYVCID.js';
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkPNOKNSG2_cjs = require('./chunk-PNOKNSG2.cjs');
4
- require('./chunk-UPLVMVRX.cjs');
5
- require('./chunk-USNT2KNT.cjs');
6
-
7
-
8
-
9
- Object.defineProperty(exports, "streamOrderInvoicePdf", {
10
- enumerable: true,
11
- get: function () { return chunkPNOKNSG2_cjs.streamOrderInvoicePdf; }
12
- });