@pvh-afl/graphql 1.2.10 → 1.2.11
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.
|
@@ -8,6 +8,15 @@ import { ServiceabilityCheckInput, ServiceabilityResult } from './serviceability
|
|
|
8
8
|
*/
|
|
9
9
|
export declare class ServiceabilityService {
|
|
10
10
|
private readonly integrationFactory;
|
|
11
|
+
/**
|
|
12
|
+
* Omuni reports delivery dates in store-local time (Asia/Kolkata for AFL
|
|
13
|
+
* brands) WITHOUT any timezone marker — e.g. `deliveryDate` =
|
|
14
|
+
* "07-09-2026 02:55:01". A date we derive ourselves has to be rendered at
|
|
15
|
+
* that same offset, not the server's zone (UTC in prod), or it lands on the
|
|
16
|
+
* wrong calendar day. Same constant and reason as
|
|
17
|
+
* CAPILLARY_STORE_UTC_OFFSET in ShopifyAdminService.
|
|
18
|
+
*/
|
|
19
|
+
private readonly OMUNI_STORE_UTC_OFFSET;
|
|
11
20
|
constructor(integrationFactory: IntegrationFactory);
|
|
12
21
|
/**
|
|
13
22
|
* Check serviceability for items at a given location.
|
|
@@ -22,6 +31,18 @@ export declare class ServiceabilityService {
|
|
|
22
31
|
* Map Omuni response to GraphQL result type.
|
|
23
32
|
*/
|
|
24
33
|
private mapResponse;
|
|
34
|
+
/**
|
|
35
|
+
* Fallback `expectedDeliveryDate` for the responses that carry `deliveryTime`
|
|
36
|
+
* but no `deliveryDate` (PROD). Emitted in the same "DD-MM-YYYY HH:mm:ss"
|
|
37
|
+
* store-local shape Omuni uses, so consumers parse one format either way.
|
|
38
|
+
*
|
|
39
|
+
* The clock part is request time + hours, so it is an SLA horizon and not an
|
|
40
|
+
* Omuni-supplied slot; it shifts between requests and can cross midnight.
|
|
41
|
+
*/
|
|
42
|
+
private estimateDeliveryDate;
|
|
43
|
+
/** `OMUNI_STORE_UTC_OFFSET` ("+05:30") as milliseconds, so the offset literal
|
|
44
|
+
* stays the only place the store's zone is stated. */
|
|
45
|
+
private storeUtcOffsetMs;
|
|
25
46
|
/**
|
|
26
47
|
* Extract payment method availability from delivery modes.
|
|
27
48
|
* - If only "Prepaid" present → prepaidEnabled=true, codEnabled=false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceability.service.d.ts","sourceRoot":"","sources":["../../src/serviceability/serviceability.service.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAKnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EAGrB,MAAM,wBAAwB,CAAC;AAEhC;;;;;GAKG;AACH,qBACa,qBAAqB;
|
|
1
|
+
{"version":3,"file":"serviceability.service.d.ts","sourceRoot":"","sources":["../../src/serviceability/serviceability.service.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAKnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EAGrB,MAAM,wBAAwB,CAAC;AAEhC;;;;;GAKG;AACH,qBACa,qBAAqB;IAWpB,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IAV/C;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAY;gBAEtB,kBAAkB,EAAE,kBAAkB;IAEnE;;;OAGG;IACG,mBAAmB,CACvB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,wBAAwB,GAC9B,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAIlC;;OAEG;YACW,YAAY;IA8C1B;;OAEG;IACH,OAAO,CAAC,WAAW;IAuDnB;;;;;;;OAOG;IACH,OAAO,CAAC,oBAAoB;IAuB5B;0DACsD;IACtD,OAAO,CAAC,gBAAgB;IAQxB;;;;;OAKG;IACH,OAAO,CAAC,gCAAgC;CAazC"}
|
|
@@ -12,6 +12,15 @@ const core_1 = require("@pvh-afl/core");
|
|
|
12
12
|
*/
|
|
13
13
|
let ServiceabilityService = class ServiceabilityService {
|
|
14
14
|
integrationFactory;
|
|
15
|
+
/**
|
|
16
|
+
* Omuni reports delivery dates in store-local time (Asia/Kolkata for AFL
|
|
17
|
+
* brands) WITHOUT any timezone marker — e.g. `deliveryDate` =
|
|
18
|
+
* "07-09-2026 02:55:01". A date we derive ourselves has to be rendered at
|
|
19
|
+
* that same offset, not the server's zone (UTC in prod), or it lands on the
|
|
20
|
+
* wrong calendar day. Same constant and reason as
|
|
21
|
+
* CAPILLARY_STORE_UTC_OFFSET in ShopifyAdminService.
|
|
22
|
+
*/
|
|
23
|
+
OMUNI_STORE_UTC_OFFSET = '+05:30';
|
|
15
24
|
constructor(integrationFactory) {
|
|
16
25
|
this.integrationFactory = integrationFactory;
|
|
17
26
|
}
|
|
@@ -89,8 +98,8 @@ let ServiceabilityService = class ServiceabilityService {
|
|
|
89
98
|
amount: mode.deliveryCost.value,
|
|
90
99
|
},
|
|
91
100
|
courierName: mode.courierName,
|
|
92
|
-
fulfillmentCenterId: mode.
|
|
93
|
-
expectedDeliveryDate: mode.deliveryDate,
|
|
101
|
+
fulfillmentCenterId: mode.fcenterId,
|
|
102
|
+
expectedDeliveryDate: mode.deliveryDate || this.estimateDeliveryDate(mode.deliveryTime),
|
|
94
103
|
}));
|
|
95
104
|
// Determine payment method availability from delivery modes
|
|
96
105
|
// paymentType values: "Prepaid" or "cod" (case-insensitive check)
|
|
@@ -104,6 +113,37 @@ let ServiceabilityService = class ServiceabilityService {
|
|
|
104
113
|
};
|
|
105
114
|
});
|
|
106
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Fallback `expectedDeliveryDate` for the responses that carry `deliveryTime`
|
|
118
|
+
* but no `deliveryDate` (PROD). Emitted in the same "DD-MM-YYYY HH:mm:ss"
|
|
119
|
+
* store-local shape Omuni uses, so consumers parse one format either way.
|
|
120
|
+
*
|
|
121
|
+
* The clock part is request time + hours, so it is an SLA horizon and not an
|
|
122
|
+
* Omuni-supplied slot; it shifts between requests and can cross midnight.
|
|
123
|
+
*/
|
|
124
|
+
estimateDeliveryDate(deliveryTime) {
|
|
125
|
+
// Number('') is 0, which would render today as the date — treat blank as absent.
|
|
126
|
+
const raw = typeof deliveryTime === 'string' ? deliveryTime.trim() : deliveryTime;
|
|
127
|
+
const hours = typeof raw === 'string' ? (raw === '' ? NaN : Number(raw)) : raw;
|
|
128
|
+
if (hours === undefined || !Number.isFinite(hours) || hours <= 0) {
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
// Adding the store offset makes the UTC getters read as store-local wall
|
|
132
|
+
// clock, which is the format Omuni itself sends.
|
|
133
|
+
const eta = new Date(Date.now() + hours * 60 * 60 * 1000 + this.storeUtcOffsetMs());
|
|
134
|
+
const pad = (value) => String(value).padStart(2, '0');
|
|
135
|
+
return (`${pad(eta.getUTCDate())}-${pad(eta.getUTCMonth() + 1)}-${eta.getUTCFullYear()}` +
|
|
136
|
+
` ${pad(eta.getUTCHours())}:${pad(eta.getUTCMinutes())}:${pad(eta.getUTCSeconds())}`);
|
|
137
|
+
}
|
|
138
|
+
/** `OMUNI_STORE_UTC_OFFSET` ("+05:30") as milliseconds, so the offset literal
|
|
139
|
+
* stays the only place the store's zone is stated. */
|
|
140
|
+
storeUtcOffsetMs() {
|
|
141
|
+
const [hours, minutes] = this.OMUNI_STORE_UTC_OFFSET.slice(1)
|
|
142
|
+
.split(':')
|
|
143
|
+
.map(Number);
|
|
144
|
+
const magnitude = (hours * 60 + minutes) * 60 * 1000;
|
|
145
|
+
return this.OMUNI_STORE_UTC_OFFSET.startsWith('-') ? -magnitude : magnitude;
|
|
146
|
+
}
|
|
107
147
|
/**
|
|
108
148
|
* Extract payment method availability from delivery modes.
|
|
109
149
|
* - If only "Prepaid" present → prepaidEnabled=true, codEnabled=false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceability.service.js","sourceRoot":"","sources":["../../src/serviceability/serviceability.service.ts"],"names":[],"mappings":";;;;AAAA,2CAAyE;AACzE,wCAMuB;AAQvB;;;;;GAKG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;
|
|
1
|
+
{"version":3,"file":"serviceability.service.js","sourceRoot":"","sources":["../../src/serviceability/serviceability.service.ts"],"names":[],"mappings":";;;;AAAA,2CAAyE;AACzE,wCAMuB;AAQvB;;;;;GAKG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAWH;IAV7B;;;;;;;OAOG;IACc,sBAAsB,GAAG,QAAQ,CAAC;IAEnD,YAA6B,kBAAsC;QAAtC,uBAAkB,GAAlB,kBAAkB,CAAoB;IAAG,CAAC;IAEvE;;;OAGG;IACH,KAAK,CAAC,mBAAmB,CACvB,KAAa,EACb,KAA+B;QAE/B,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,YAAY,CACxB,KAAa,EACb,KAA+B;QAE/B,MAAM,UAAU,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAe,KAAK,EAAE,KAAK,CAAC,CAAC;QAE3E,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,aAAM,CAAC,IAAI,CAAC,gCAAgC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YACzD,MAAM,IAAI,oCAA2B,CAAC;gBACpC,IAAI,EAAE,oBAAoB;gBAC1B,OAAO,EAAE,+CAA+C;aACzD,CAAC,CAAC;QACL,CAAC;QAED,gBAAgB;QAChB,MAAM,OAAO,GAA+B;YAC1C,QAAQ,EAAE,KAAK,CAAC,OAAO;YACvB,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC5B,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE;gBAClF,CAAC,CAAC,SAAS;YACb,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;YACnD,YAAY,EAAE,KAAK,CAAC,aAA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