@pvh-afl/graphql 1.2.60 → 1.2.61
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IntegrationFactory } from '@pvh-afl/core';
|
|
1
|
+
import { ConfigService, IntegrationFactory, ThemeContentService } from '@pvh-afl/core';
|
|
2
2
|
import { StoreLocatorInput, StoreLocatorResult } from './store-locator.types';
|
|
3
3
|
/**
|
|
4
4
|
* Store Locator Service
|
|
@@ -7,11 +7,21 @@ import { StoreLocatorInput, StoreLocatorResult } from './store-locator.types';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare class StoreLocatorService {
|
|
9
9
|
private readonly integrationFactory;
|
|
10
|
-
|
|
10
|
+
private readonly themeContentService;
|
|
11
|
+
private readonly configService;
|
|
12
|
+
constructor(integrationFactory: IntegrationFactory, themeContentService: ThemeContentService, configService: ConfigService);
|
|
11
13
|
/**
|
|
12
14
|
* Find stores near a given location.
|
|
13
15
|
*/
|
|
14
16
|
findStores(brand: string, input: StoreLocatorInput): Promise<StoreLocatorResult>;
|
|
17
|
+
/**
|
|
18
|
+
* Fetch stores from the Shopify store_directory metaobject.
|
|
19
|
+
*/
|
|
20
|
+
private fetchFromStoreDirectory;
|
|
21
|
+
/**
|
|
22
|
+
* Map a store_location metaobject entry to GraphQL result type.
|
|
23
|
+
*/
|
|
24
|
+
private mapDirectoryEntry;
|
|
15
25
|
/**
|
|
16
26
|
* Fetch store data from OMS.
|
|
17
27
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-locator.service.d.ts","sourceRoot":"","sources":["../../src/store-locator/store-locator.service.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,
|
|
1
|
+
{"version":3,"file":"store-locator.service.d.ts","sourceRoot":"","sources":["../../src/store-locator/store-locator.service.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,kBAAkB,EAKlB,mBAAmB,EAEpB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAEnB,MAAM,uBAAuB,CAAC;AAE/B;;;;GAIG;AACH,qBACa,mBAAmB;IAE5B,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAFb,kBAAkB,EAAE,kBAAkB,EACtC,mBAAmB,EAAE,mBAAmB,EACxC,aAAa,EAAE,aAAa;IAG/C;;OAEG;IACG,UAAU,CACd,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,kBAAkB,CAAC;IAY9B;;OAEG;YACW,uBAAuB;IAsBrC;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA+BzB;;OAEG;YACW,YAAY;IAwC1B;;OAEG;IACH,OAAO,CAAC,WAAW;IA0CnB;;OAEG;IACH,OAAO,CAAC,UAAU;CAQnB"}
|
|
@@ -11,15 +11,76 @@ const core_1 = require("@pvh-afl/core");
|
|
|
11
11
|
*/
|
|
12
12
|
let StoreLocatorService = class StoreLocatorService {
|
|
13
13
|
integrationFactory;
|
|
14
|
-
|
|
14
|
+
themeContentService;
|
|
15
|
+
configService;
|
|
16
|
+
constructor(integrationFactory, themeContentService, configService) {
|
|
15
17
|
this.integrationFactory = integrationFactory;
|
|
18
|
+
this.themeContentService = themeContentService;
|
|
19
|
+
this.configService = configService;
|
|
16
20
|
}
|
|
17
21
|
/**
|
|
18
22
|
* Find stores near a given location.
|
|
19
23
|
*/
|
|
20
24
|
async findStores(brand, input) {
|
|
25
|
+
// No location: never call Omuni; use the brand's store directory if configured.
|
|
26
|
+
if (!input.pincode && !input.coordinates) {
|
|
27
|
+
const directoryHandle = this.configService.getStoreDirectoryHandle(brand);
|
|
28
|
+
if (directoryHandle) {
|
|
29
|
+
return this.fetchFromStoreDirectory(brand, directoryHandle);
|
|
30
|
+
}
|
|
31
|
+
return { stores: [], totalCount: 0 };
|
|
32
|
+
}
|
|
21
33
|
return this.fetchFromOms(brand, input);
|
|
22
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Fetch stores from the Shopify store_directory metaobject.
|
|
37
|
+
*/
|
|
38
|
+
async fetchFromStoreDirectory(brand, handle) {
|
|
39
|
+
const result = await this.themeContentService.getStoreDirectory(brand, handle);
|
|
40
|
+
if (!result.data) {
|
|
41
|
+
core_1.logger.error('Store directory fetch failed', {
|
|
42
|
+
brand,
|
|
43
|
+
error: result.error,
|
|
44
|
+
});
|
|
45
|
+
return { stores: [], totalCount: 0 };
|
|
46
|
+
}
|
|
47
|
+
const stores = result.data.map((entry) => this.mapDirectoryEntry(entry));
|
|
48
|
+
return {
|
|
49
|
+
stores,
|
|
50
|
+
totalCount: stores.length,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Map a store_location metaobject entry to GraphQL result type.
|
|
55
|
+
*/
|
|
56
|
+
mapDirectoryEntry(entry) {
|
|
57
|
+
const latitude = parseFloat(entry.latitude);
|
|
58
|
+
const longitude = parseFloat(entry.longitude);
|
|
59
|
+
return {
|
|
60
|
+
id: entry.store_code,
|
|
61
|
+
name: entry.name,
|
|
62
|
+
address: {
|
|
63
|
+
streetName: entry.address_line,
|
|
64
|
+
city: entry.locality,
|
|
65
|
+
state: entry.region,
|
|
66
|
+
country: entry.country,
|
|
67
|
+
pincode: entry.pincode,
|
|
68
|
+
},
|
|
69
|
+
coordinates: Number.isFinite(latitude) && Number.isFinite(longitude)
|
|
70
|
+
? { latitude, longitude }
|
|
71
|
+
: undefined,
|
|
72
|
+
contact: {
|
|
73
|
+
phone: entry.phone,
|
|
74
|
+
},
|
|
75
|
+
timing: {
|
|
76
|
+
openingTime: entry.opening_time,
|
|
77
|
+
closingTime: entry.closing_time,
|
|
78
|
+
workingDays: entry.working_days ? [entry.working_days] : undefined,
|
|
79
|
+
},
|
|
80
|
+
isEnabled: true,
|
|
81
|
+
isStoreLocatorEnabled: true,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
23
84
|
/**
|
|
24
85
|
* Fetch store data from OMS.
|
|
25
86
|
*/
|
|
@@ -111,6 +172,8 @@ let StoreLocatorService = class StoreLocatorService {
|
|
|
111
172
|
exports.StoreLocatorService = StoreLocatorService;
|
|
112
173
|
exports.StoreLocatorService = StoreLocatorService = tslib_1.__decorate([
|
|
113
174
|
(0, common_1.Injectable)(),
|
|
114
|
-
tslib_1.__metadata("design:paramtypes", [core_1.IntegrationFactory
|
|
175
|
+
tslib_1.__metadata("design:paramtypes", [core_1.IntegrationFactory,
|
|
176
|
+
core_1.ThemeContentService,
|
|
177
|
+
core_1.ConfigService])
|
|
115
178
|
], StoreLocatorService);
|
|
116
179
|
//# sourceMappingURL=store-locator.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-locator.service.js","sourceRoot":"","sources":["../../src/store-locator/store-locator.service.ts"],"names":[],"mappings":";;;;AAAA,2CAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"store-locator.service.js","sourceRoot":"","sources":["../../src/store-locator/store-locator.service.ts"],"names":[],"mappings":";;;;AAAA,2CAA4C;AAC5C,wCASuB;AAOvB;;;;GAIG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAEX;IACA;IACA;IAHnB,YACmB,kBAAsC,EACtC,mBAAwC,EACxC,aAA4B;QAF5B,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,wBAAmB,GAAnB,mBAAmB,CAAqB;QACxC,kBAAa,GAAb,aAAa,CAAe;IAC5C,CAAC;IAEJ;;OAEG;IACH,KAAK,CAAC,UAAU,CACd,KAAa,EACb,KAAwB;QAExB,gFAAgF;QAChF,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;YACzC,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAAC,KAAK,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