@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,192 @@
1
+ import { logErp, queueErp, errorErp } from './chunk-SYBOCAWB.js';
2
+ import { __name } from './chunk-SHUYVCID.js';
3
+
4
+ // src/plugins/erp/paid-order-erp.ts
5
+ function roundMoney(major) {
6
+ return Math.round(major * 100) / 100;
7
+ }
8
+ __name(roundMoney, "roundMoney");
9
+ function addressToWebhookDto(a) {
10
+ if (!a) return {};
11
+ return {
12
+ line1: a.line1 ?? "",
13
+ line2: a.line2 ?? "",
14
+ city: a.city ?? "",
15
+ state: a.state ?? "",
16
+ postalCode: a.postalCode ?? "",
17
+ country: a.country ?? ""
18
+ };
19
+ }
20
+ __name(addressToWebhookDto, "addressToWebhookDto");
21
+ function orderStatusLabel(status) {
22
+ const s = (status || "").toLowerCase();
23
+ if (s === "confirmed") return "Confirmed";
24
+ if (s === "pending") return "Pending";
25
+ if (!status) return "Pending";
26
+ return status.charAt(0).toUpperCase() + status.slice(1);
27
+ }
28
+ __name(orderStatusLabel, "orderStatusLabel");
29
+ function paymentRowToWebhookDto(p, amountMajorOverride) {
30
+ const currency = String(p.currency || "INR");
31
+ const amountMajor = amountMajorOverride != null && Number.isFinite(amountMajorOverride) ? amountMajorOverride : Number(p.amount);
32
+ const meta = {
33
+ ...p.metadata || {}
34
+ };
35
+ delete meta.amount;
36
+ delete meta.currency;
37
+ return {
38
+ id: String(p.externalReference || `payment_${p.id}`),
39
+ amount: roundMoney(amountMajor),
40
+ currency_code: currency,
41
+ captured_at: p.paidAt ? new Date(p.paidAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
42
+ provider_id: String(p.method || "unknown"),
43
+ data: {
44
+ status: "captured",
45
+ ...meta
46
+ }
47
+ };
48
+ }
49
+ __name(paymentRowToWebhookDto, "paymentRowToWebhookDto");
50
+ async function queueErpPaidOrderForOrderId(cms, dataSource, entityMap, orderId) {
51
+ try {
52
+ const configRepo = dataSource.getRepository(entityMap.configs);
53
+ const cfgRows = await configRepo.find({
54
+ where: {
55
+ settings: "erp",
56
+ deleted: false
57
+ }
58
+ });
59
+ for (const row of cfgRows) {
60
+ const r = row;
61
+ if (r.key === "enabled" && r.value === "false") {
62
+ logErp("paid-order:skip", {
63
+ orderId,
64
+ reason: "erp_config_disabled"
65
+ });
66
+ return;
67
+ }
68
+ }
69
+ if (!cms.getPlugin("erp")) {
70
+ logErp("paid-order:skip", {
71
+ orderId,
72
+ reason: "erp_plugin_missing"
73
+ });
74
+ return;
75
+ }
76
+ const orderRepo = dataSource.getRepository(entityMap.orders);
77
+ const ord = await orderRepo.findOne({
78
+ where: {
79
+ id: orderId
80
+ },
81
+ relations: [
82
+ "items",
83
+ "items.product",
84
+ "contact",
85
+ "billingAddress",
86
+ "shippingAddress",
87
+ "payments"
88
+ ]
89
+ });
90
+ if (!ord) {
91
+ logErp("paid-order:skip", {
92
+ orderId,
93
+ reason: "order_not_found"
94
+ });
95
+ return;
96
+ }
97
+ const o = ord;
98
+ const okKind = o.orderKind === void 0 || o.orderKind === null || o.orderKind === "sale";
99
+ if (!okKind) {
100
+ logErp("paid-order:skip", {
101
+ orderId,
102
+ reason: "order_kind_not_sale",
103
+ orderKind: o.orderKind
104
+ });
105
+ return;
106
+ }
107
+ const rawPayments = o.payments ?? [];
108
+ const completedPayments = rawPayments.filter((pay) => pay.status === "completed" && pay.deleted !== true);
109
+ if (!completedPayments.length) {
110
+ logErp("paid-order:skip", {
111
+ orderId,
112
+ reason: "no_completed_payments"
113
+ });
114
+ return;
115
+ }
116
+ const rawItems = o.items ?? [];
117
+ const lines = rawItems.filter((it) => it.product).map((it) => {
118
+ const p = it.product;
119
+ const sku = p.sku || `SKU-${p.id}`;
120
+ const itemType = typeof it.productType === "string" && it.productType.trim() ? String(it.productType).trim() : p.type === "service" ? "service" : "product";
121
+ return {
122
+ sku,
123
+ quantity: Number(it.quantity) || 1,
124
+ unitPrice: Number(it.unitPrice),
125
+ title: p.name || sku,
126
+ discount: 0,
127
+ tax: Number(it.tax) || 0,
128
+ uom: (typeof it.uom === "string" && it.uom.trim() ? it.uom : p.uom) || void 0,
129
+ tax_code: typeof it.taxCode === "string" && it.taxCode.trim() ? String(it.taxCode).trim() : void 0,
130
+ hsn_number: (typeof it.hsn === "string" && it.hsn.trim() ? it.hsn : p.hsn) || void 0,
131
+ type: itemType
132
+ };
133
+ });
134
+ if (!lines.length) {
135
+ logErp("paid-order:skip", {
136
+ orderId,
137
+ reason: "no_line_items_with_product"
138
+ });
139
+ return;
140
+ }
141
+ const contact = o.contact;
142
+ const orderTotalMajor = Number(o.total);
143
+ const paymentDtos = completedPayments.length === 1 && Number.isFinite(orderTotalMajor) ? [
144
+ paymentRowToWebhookDto(completedPayments[0], orderTotalMajor)
145
+ ] : completedPayments.map((pay) => paymentRowToWebhookDto(pay));
146
+ const baseMeta = o.metadata && typeof o.metadata === "object" && !Array.isArray(o.metadata) ? {
147
+ ...o.metadata
148
+ } : {};
149
+ const orderDto = {
150
+ platformType: "website",
151
+ platformOrderId: String(o.orderNumber),
152
+ platformOrderNumber: String(o.orderNumber),
153
+ order_date: o.createdAt ? new Date(o.createdAt).toISOString() : void 0,
154
+ status: orderStatusLabel(o.status),
155
+ customer: {
156
+ name: contact?.name || "",
157
+ email: contact?.email || "",
158
+ phone: contact?.phone || ""
159
+ },
160
+ shippingAddress: addressToWebhookDto(o.shippingAddress),
161
+ billingAddress: addressToWebhookDto(o.billingAddress),
162
+ items: lines,
163
+ payments: paymentDtos,
164
+ metadata: {
165
+ ...baseMeta,
166
+ source: "storefront"
167
+ }
168
+ };
169
+ logErp("paid-order:payload_built", {
170
+ orderId,
171
+ platformOrderId: orderDto.platformOrderId,
172
+ status: orderDto.status,
173
+ itemCount: lines.length,
174
+ skus: lines.map((l) => l.sku),
175
+ paymentCount: paymentDtos.length,
176
+ paymentIds: paymentDtos.map((p) => p.id),
177
+ total: orderTotalMajor
178
+ });
179
+ await queueErp(cms, {
180
+ kind: "order",
181
+ order: orderDto
182
+ });
183
+ } catch (e) {
184
+ errorErp("paid-order:enqueue_failed", {
185
+ orderId,
186
+ message: e instanceof Error ? e.message : String(e)
187
+ });
188
+ }
189
+ }
190
+ __name(queueErpPaidOrderForOrderId, "queueErpPaidOrderForOrderId");
191
+
192
+ export { queueErpPaidOrderForOrderId };