@pvh-afl/core 1.2.35 → 1.2.37

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 (51) hide show
  1. package/dist/cache/cache.service.d.ts +2 -2
  2. package/dist/cache/cache.service.js +25 -25
  3. package/dist/cache/cache.service.js.map +1 -1
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +2 -0
  7. package/dist/index.js.map +1 -1
  8. package/dist/integrations/engagement/index.d.ts +3 -0
  9. package/dist/integrations/engagement/index.d.ts.map +1 -0
  10. package/dist/integrations/engagement/index.js +6 -0
  11. package/dist/integrations/engagement/index.js.map +1 -0
  12. package/dist/integrations/engagement/netcore-email.service.d.ts +32 -0
  13. package/dist/integrations/engagement/netcore-email.service.d.ts.map +1 -0
  14. package/dist/integrations/engagement/netcore-email.service.js +184 -0
  15. package/dist/integrations/engagement/netcore-email.service.js.map +1 -0
  16. package/dist/integrations/engagement/netcore-email.types.d.ts +74 -0
  17. package/dist/integrations/engagement/netcore-email.types.d.ts.map +1 -0
  18. package/dist/integrations/engagement/netcore-email.types.js +3 -0
  19. package/dist/integrations/engagement/netcore-email.types.js.map +1 -0
  20. package/dist/integrations/index.d.ts +1 -0
  21. package/dist/integrations/index.d.ts.map +1 -1
  22. package/dist/integrations/index.js +2 -0
  23. package/dist/integrations/index.js.map +1 -1
  24. package/dist/integrations/integrations.module.d.ts.map +1 -1
  25. package/dist/integrations/integrations.module.js +5 -0
  26. package/dist/integrations/integrations.module.js.map +1 -1
  27. package/dist/notifications/index.d.ts +6 -0
  28. package/dist/notifications/index.d.ts.map +1 -0
  29. package/dist/notifications/index.js +9 -0
  30. package/dist/notifications/index.js.map +1 -0
  31. package/dist/notifications/notifications.module.d.ts +9 -0
  32. package/dist/notifications/notifications.module.d.ts.map +1 -0
  33. package/dist/notifications/notifications.module.js +25 -0
  34. package/dist/notifications/notifications.module.js.map +1 -0
  35. package/dist/notifications/order-email.mapper.d.ts +15 -0
  36. package/dist/notifications/order-email.mapper.d.ts.map +1 -0
  37. package/dist/notifications/order-email.mapper.js +131 -0
  38. package/dist/notifications/order-email.mapper.js.map +1 -0
  39. package/dist/notifications/order-email.service.d.ts +30 -0
  40. package/dist/notifications/order-email.service.d.ts.map +1 -0
  41. package/dist/notifications/order-email.service.js +151 -0
  42. package/dist/notifications/order-email.service.js.map +1 -0
  43. package/dist/notifications/order-notification.types.d.ts +41 -0
  44. package/dist/notifications/order-notification.types.d.ts.map +1 -0
  45. package/dist/notifications/order-notification.types.js +20 -0
  46. package/dist/notifications/order-notification.types.js.map +1 -0
  47. package/dist/notifications/order.source.d.ts +46 -0
  48. package/dist/notifications/order.source.d.ts.map +1 -0
  49. package/dist/notifications/order.source.js +139 -0
  50. package/dist/notifications/order.source.js.map +1 -0
  51. package/package.json +1 -1
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrderSource = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const logger_1 = require("../common/logger");
7
+ const shopify_admin_service_1 = require("../integrations/commerce/shopify-admin.service");
8
+ const ORDER_QUERY = `
9
+ query OrderEmailSnapshot($id: ID!) {
10
+ order(id: $id) {
11
+ id
12
+ name
13
+ email
14
+ phone
15
+ statusPageUrl
16
+ totalPriceSet { shopMoney { amount currencyCode } }
17
+ totalTaxSet { shopMoney { amount } }
18
+ totalDiscountsSet { shopMoney { amount } }
19
+ totalShippingPriceSet { shopMoney { amount } }
20
+ customer { firstName lastName email phone }
21
+ billingAddress { address1 address2 city province zip country }
22
+ shippingAddress { address1 address2 city province zip country phone }
23
+ shippingLine { title }
24
+ paymentGatewayNames
25
+ lineItems(first: 50) {
26
+ edges {
27
+ node {
28
+ title
29
+ quantity
30
+ sku
31
+ variantTitle
32
+ originalTotalSet { shopMoney { amount } }
33
+ variant {
34
+ barcode
35
+ sku
36
+ selectedOptions { name value }
37
+ }
38
+ }
39
+ }
40
+ }
41
+ fulfillments(first: 10) {
42
+ trackingInfo { url number }
43
+ }
44
+ }
45
+ }
46
+ `;
47
+ const toNumber = (value) => {
48
+ const n = parseFloat(value ?? '0');
49
+ return Number.isFinite(n) ? n : 0;
50
+ };
51
+ const formatAddress = (address) => {
52
+ if (!address)
53
+ return [];
54
+ const cityLine = [address.city, address.zip].filter(Boolean).join(' ');
55
+ return [address.address1, address.address2, address.province, cityLine]
56
+ .map((part) => (part ?? '').trim())
57
+ .filter((part) => part.length > 0);
58
+ };
59
+ /** Reads a variant option by name, e.g. "Size" / "Colour". */
60
+ const option = (node, ...names) => {
61
+ const wanted = names.map((n) => n.toLowerCase());
62
+ const match = node.variant?.selectedOptions?.find((o) => wanted.includes((o.name ?? '').toLowerCase()));
63
+ return match?.value?.trim() || null;
64
+ };
65
+ let OrderSource = class OrderSource {
66
+ shopifyAdminService;
67
+ constructor(shopifyAdminService) {
68
+ this.shopifyAdminService = shopifyAdminService;
69
+ }
70
+ /**
71
+ * Fetch one order. `orderId` may be a numeric Shopify id or a full GID.
72
+ * Returns null when the order is gone or the query errored — the caller
73
+ * decides whether that is worth retrying.
74
+ */
75
+ async load(brand, orderId) {
76
+ const gid = String(orderId).startsWith('gid://')
77
+ ? String(orderId)
78
+ : `gid://shopify/Order/${orderId}`;
79
+ const response = await this.shopifyAdminService.adminGraphQL(brand, ORDER_QUERY, { id: gid });
80
+ if (response.errors?.length) {
81
+ logger_1.logger.error('Order email snapshot query failed', {
82
+ brand,
83
+ orderId: gid,
84
+ error: response.errors[0]?.message,
85
+ });
86
+ return null;
87
+ }
88
+ const order = response.data?.order;
89
+ if (!order) {
90
+ logger_1.logger.warn('Order email snapshot not found', { brand, orderId: gid });
91
+ return null;
92
+ }
93
+ return this.toSnapshot(order);
94
+ }
95
+ toSnapshot(order) {
96
+ const firstName = order.customer?.firstName?.trim() ?? '';
97
+ const lastName = order.customer?.lastName?.trim() ?? '';
98
+ const trackingUrl = order.fulfillments
99
+ ?.flatMap((f) => f.trackingInfo ?? [])
100
+ .map((t) => t.url)
101
+ .find((url) => Boolean(url)) ?? null;
102
+ return {
103
+ // `name` is the customer-facing number (e.g. "#31083220934").
104
+ orderNumber: (order.name ?? '').replace(/^#/, ''),
105
+ email: order.email ?? order.customer?.email ?? null,
106
+ phone: order.phone ??
107
+ order.customer?.phone ??
108
+ order.shippingAddress?.phone ??
109
+ null,
110
+ currency: order.totalPriceSet?.shopMoney?.currencyCode ?? 'INR',
111
+ customerName: [firstName, lastName].filter(Boolean).join(' '),
112
+ totalPrice: toNumber(order.totalPriceSet?.shopMoney?.amount),
113
+ totalTax: toNumber(order.totalTaxSet?.shopMoney?.amount),
114
+ totalDiscount: toNumber(order.totalDiscountsSet?.shopMoney?.amount),
115
+ totalShipping: toNumber(order.totalShippingPriceSet?.shopMoney?.amount),
116
+ billingAddress: formatAddress(order.billingAddress),
117
+ shippingAddress: formatAddress(order.shippingAddress),
118
+ paymentMethod: (order.paymentGatewayNames ?? []).join(', '),
119
+ shippingMethod: order.shippingLine?.title?.trim() ?? '',
120
+ trackingUrl,
121
+ orderStatusUrl: order.statusPageUrl ?? null,
122
+ items: (order.lineItems?.edges ?? []).map(({ node }) => ({
123
+ title: node.title ?? '',
124
+ quantity: node.quantity ?? 1,
125
+ amount: toNumber(node.originalTotalSet?.shopMoney?.amount),
126
+ size: option(node, 'Size'),
127
+ colour: option(node, 'Colour', 'Color'),
128
+ // The design's "Item nr." is a 13-digit EAN, i.e. the variant barcode.
129
+ itemNumber: node.variant?.barcode ?? node.variant?.sku ?? node.sku ?? null,
130
+ })),
131
+ };
132
+ }
133
+ };
134
+ exports.OrderSource = OrderSource;
135
+ exports.OrderSource = OrderSource = tslib_1.__decorate([
136
+ (0, common_1.Injectable)(),
137
+ tslib_1.__metadata("design:paramtypes", [shopify_admin_service_1.ShopifyAdminService])
138
+ ], OrderSource);
139
+ //# sourceMappingURL=order.source.js.map
@@ -0,0 +1 @@
1
+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uC,2CAAmB;GAD1D,WAAW,CA6EvB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pvh-afl/core",
3
- "version": "1.2.35",
3
+ "version": "1.2.37",
4
4
  "description": "AFL Core - Shared services for multi-brand commerce platform",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",