@moneylion/react-native-offer-carousel 1.0.9 → 1.0.10
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.
- package/lib/commonjs/pageData.js +2 -2
- package/lib/commonjs/pageData.js.map +1 -1
- package/lib/commonjs/services/getDynamicOffers.js +27 -19
- package/lib/commonjs/services/getDynamicOffers.js.map +1 -1
- package/lib/commonjs/utils/getOffersByProductTypes.js +27 -6
- package/lib/commonjs/utils/getOffersByProductTypes.js.map +1 -1
- package/lib/module/pageData.js +2 -2
- package/lib/module/pageData.js.map +1 -1
- package/lib/module/services/getDynamicOffers.js +27 -19
- package/lib/module/services/getDynamicOffers.js.map +1 -1
- package/lib/module/utils/getOffersByProductTypes.js +27 -6
- package/lib/module/utils/getOffersByProductTypes.js.map +1 -1
- package/lib/typescript/src/services/getDynamicOffers.d.ts +2 -2
- package/lib/typescript/src/services/getDynamicOffers.d.ts.map +1 -1
- package/lib/typescript/src/utils/getOffersByProductTypes.d.ts +9 -4
- package/lib/typescript/src/utils/getOffersByProductTypes.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/pageData.ts +2 -2
- package/src/services/getDynamicOffers.ts +29 -27
- package/src/utils/getOffersByProductTypes.ts +13 -10
package/lib/commonjs/pageData.js
CHANGED
|
@@ -27,7 +27,7 @@ async function getPageData({
|
|
|
27
27
|
|
|
28
28
|
// Resolve Tags
|
|
29
29
|
const resolvedTags = `${tags === null || tags === void 0 ? void 0 : tags.trim()}`;
|
|
30
|
-
const
|
|
30
|
+
const isCachedOffersRequest = (0, _getEnableUseCachedOffers.getEnableUseCachedOffers)(context);
|
|
31
31
|
const defaultProductType = (0, _utils.getDefaultProductType)(context);
|
|
32
32
|
|
|
33
33
|
// TODO: Check if this is needed or if we can remove it
|
|
@@ -71,7 +71,7 @@ async function getPageData({
|
|
|
71
71
|
displayLayout: safeDisplayLayout,
|
|
72
72
|
productTypes,
|
|
73
73
|
resultType,
|
|
74
|
-
|
|
74
|
+
isCachedOffersRequest,
|
|
75
75
|
productTypesDefinition: [...productTypesDefinition],
|
|
76
76
|
partnersOverrideDefinition: [...partnersOverrideDefinition],
|
|
77
77
|
context,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_contextUtil","require","_getDynamicOffers","_utils","_getEnableUseCachedOffers","getPageData","context","params","onRateTableSubmit","productType","query","tags","displayLayout","searchAPIToken","showProductTypeLabel","showCardBorder","resolvedTags","trim","
|
|
1
|
+
{"version":3,"names":["_contextUtil","require","_getDynamicOffers","_utils","_getEnableUseCachedOffers","getPageData","context","params","onRateTableSubmit","productType","query","tags","displayLayout","searchAPIToken","showProductTypeLabel","showCardBorder","resolvedTags","trim","isCachedOffersRequest","getEnableUseCachedOffers","defaultProductType","getDefaultProductType","isDev","getIsDevEnvironment","productTypesDefinition","partnersOverrideDefinition","getProductTypesDefinition","currentCountry","signals","deviceSignals","country","safeTags","encodeURI","safeDisplayLayout","getLayout","productTypes","resultType","resolveProductTypes","timestamp","Date","toISOString","offers","isError","leadUuid","rateTableUuid","getDynamicOffers"],"sourceRoot":"../../src","sources":["pageData.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAIA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAMA,IAAAG,yBAAA,GAAAH,OAAA;AAPA;;AAeO,eAAeI,WAAWA,CAAC;EACjCC,OAAO;EACPC,MAAM;EACNC;AACiB,CAAC,EAAE;EACpB,MAAM;IACLC,WAAW;IACXC,KAAK;IACLC,IAAI;IACJC,aAAa;IACbC,cAAc;IACdC,oBAAoB;IACpBC;EACD,CAAC,GAAGR,MAAM;;EAEV;EACA,MAAMS,YAAY,GAAG,GAAGL,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEM,IAAI,CAAC,CAAC,EAAE;EAEtC,MAAMC,qBAAqB,GAAG,IAAAC,kDAAwB,EAACb,OAAO,CAAC;EAE/D,MAAMc,kBAAkB,GAAG,IAAAC,4BAAqB,EAACf,OAAO,CAAC;;EAEzD;EACA;;EAEA,MAAMgB,KAAK,GAAG,IAAAC,gCAAmB,EAACjB,OAAO,CAAC;EAE1C,MAAM;IAAEkB,sBAAsB;IAAEC;EAA2B,CAAC,GAC3D,IAAAC,gCAAyB,EAACpB,OAAO,CAAC;EAEnC,MAAMqB,cAAc,GAAGrB,OAAO,CAACsB,OAAO,CAACC,aAAa,CAACC,OAAO;EAE5D,MAAMC,QAAQ,GAAGC,SAAS,CAAChB,YAAY,CAAC;EAExC,MAAMiB,iBAAiB,GAAG,IAAAC,gBAAS,EAACtB,aAAa,CAAC;;EAElD;EACA,MAAM;IAAEuB,YAAY;IAAEC;EAAW,CAAC,GAAG,MAAM,IAAAC,0BAAmB,EAAC;IAC9DjB,kBAAkB;IAClBX,WAAW;IACXC,KAAK;IACLG,cAAc;IACdS;EACD,CAAC,CAAC;EAEFd,iBAAiB,aAAjBA,iBAAiB,eAAjBA,iBAAiB,CAAG;IACnB8B,SAAS,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;IACnCL,YAAY;IACZC,UAAU;IACVhB;EACD,CAAC,CAAC;;EAEF;EACA,MAAM;IAAEqB,MAAM;IAAEC,OAAO;IAAEC,QAAQ;IAAEC;EAAc,CAAC,GAAG,MAAM,IAAAC,kCAAgB,EAAC;IAC3ElC,IAAI,EAAEoB,QAAQ;IACdnB,aAAa,EAAEqB,iBAAiB;IAChCE,YAAY;IACZC,UAAU;IACVlB,qBAAqB;IACrBM,sBAAsB,EAAE,CAAC,GAAGA,sBAAsB,CAAC;IACnDC,0BAA0B,EAAE,CAAC,GAAGA,0BAA0B,CAAC;IAC3DnB,OAAO;IACPc;EACD,CAAC,CAAC;EAEF,OAAO;IACNsB,OAAO;IACPC,QAAQ;IACRC,aAAa;IACb;IACAH,MAAM;IACNd,cAAc;IACd;IACAZ,cAAc;IACd;IACAD,oBAAoB;IACpBF,aAAa,EAAEqB;EAChB,CAAC;AACF","ignoreList":[]}
|
|
@@ -22,38 +22,46 @@ const getDynamicOffers = async ({
|
|
|
22
22
|
defaultProductType,
|
|
23
23
|
productTypes,
|
|
24
24
|
resultType,
|
|
25
|
-
|
|
25
|
+
isCachedOffersRequest,
|
|
26
26
|
productTypesDefinition,
|
|
27
27
|
partnersOverrideDefinition,
|
|
28
28
|
context
|
|
29
29
|
}) => {
|
|
30
30
|
// Get the initial offers
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
let {
|
|
32
|
+
offers,
|
|
33
|
+
rateTableUuid,
|
|
34
|
+
isError,
|
|
35
|
+
leadUuid
|
|
36
|
+
} = await (0, _utils.getOffersByProductTypes)({
|
|
37
|
+
isCachedOffersRequest,
|
|
33
38
|
productTypes,
|
|
34
39
|
tags,
|
|
35
40
|
context
|
|
36
41
|
});
|
|
37
42
|
|
|
38
|
-
//
|
|
39
|
-
if ((0, _radash.isEmpty)(
|
|
40
|
-
|
|
43
|
+
// If no offers found, fall back to the default product type
|
|
44
|
+
if ((0, _radash.isEmpty)(offers)) {
|
|
45
|
+
const fallbackResult = await (0, _utils.getOffersByProductTypes)({
|
|
46
|
+
isCachedOffersRequest,
|
|
47
|
+
productTypes: [defaultProductType],
|
|
48
|
+
tags,
|
|
49
|
+
context
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Update the offers, rateTableUuid, isError, leafUuid and productTypes
|
|
53
|
+
offers = fallbackResult.offers;
|
|
54
|
+
rateTableUuid = fallbackResult.rateTableUuid;
|
|
55
|
+
isError = fallbackResult.isError;
|
|
56
|
+
leadUuid = fallbackResult.leadUuid;
|
|
41
57
|
productTypes = [defaultProductType];
|
|
42
58
|
}
|
|
43
|
-
|
|
44
|
-
// if initial offers are returned, return them
|
|
45
|
-
const offersData = (0, _radash.isEmpty)(initialOffersData === null || initialOffersData === void 0 ? void 0 : initialOffersData.offers) ? await (0, _utils.getOffersByProductTypes)({
|
|
46
|
-
enableUseCachedOffers,
|
|
47
|
-
productTypes,
|
|
48
|
-
tags,
|
|
49
|
-
context
|
|
50
|
-
}) : initialOffersData;
|
|
51
|
-
const sortedOffers = resultType === "QUERY" ? (0, _utils.selectDynamicOffers)(offersData.offers, productTypes) : (0, _sortOffersByRecommendationScore.sortOffersByRecommendationScore)(offersData.offers);
|
|
59
|
+
const sortedOffers = resultType === "QUERY" ? (0, _utils.selectDynamicOffers)(offers, productTypes) : (0, _sortOffersByRecommendationScore.sortOffersByRecommendationScore)(offers);
|
|
52
60
|
return {
|
|
53
|
-
offers: (0, _effect.pipe)(sortedOffers, (0, _formatOfferUrl.formatOfferUrl)(productTypesDefinition, partnersOverrideDefinition), (0, _utils.addClientTagsToOfferLinks)(
|
|
54
|
-
isError:
|
|
55
|
-
leadUuid:
|
|
56
|
-
rateTableUuid
|
|
61
|
+
offers: (0, _effect.pipe)(sortedOffers, (0, _formatOfferUrl.formatOfferUrl)(productTypesDefinition, partnersOverrideDefinition), (0, _utils.addClientTagsToOfferLinks)(isCachedOffersRequest, tags), (0, _getOffersBasedOnLayout.getOffersBasedOnLayout)(displayLayout)),
|
|
62
|
+
isError: isError,
|
|
63
|
+
leadUuid: leadUuid,
|
|
64
|
+
rateTableUuid
|
|
57
65
|
};
|
|
58
66
|
};
|
|
59
67
|
exports.getDynamicOffers = getDynamicOffers;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_radash","require","_utils","_sortOffersByRecommendationScore","_effect","_formatOfferUrl","_getOffersBasedOnLayout","getDynamicOffers","tags","displayLayout","defaultProductType","productTypes","resultType","
|
|
1
|
+
{"version":3,"names":["_radash","require","_utils","_sortOffersByRecommendationScore","_effect","_formatOfferUrl","_getOffersBasedOnLayout","getDynamicOffers","tags","displayLayout","defaultProductType","productTypes","resultType","isCachedOffersRequest","productTypesDefinition","partnersOverrideDefinition","context","offers","rateTableUuid","isError","leadUuid","getOffersByProductTypes","isEmpty","fallbackResult","sortedOffers","selectDynamicOffers","sortOffersByRecommendationScore","pipe","formatOfferUrl","addClientTagsToOfferLinks","getOffersBasedOnLayout","exports"],"sourceRoot":"../../../src","sources":["services/getDynamicOffers.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAUA,IAAAE,gCAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,uBAAA,GAAAL,OAAA;AA0BA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMM,gBAAgB,GAAG,MAAAA,CAAO;EACtCC,IAAI;EACJC,aAAa;EACbC,kBAAkB;EAClBC,YAAY;EACZC,UAAU;EACVC,qBAAqB;EACrBC,sBAAsB;EACtBC,0BAA0B;EAC1BC;AACqC,CAAC,KAAK;EAC3C;EACA,IAAI;IAAEC,MAAM;IAAEC,aAAa;IAAEC,OAAO;IAAEC;EAAS,CAAC,GAC/C,MAAM,IAAAC,8BAAuB,EAAC;IAC7BR,qBAAqB;IACrBF,YAAY;IACZH,IAAI;IACJQ;EACD,CAAC,CAAC;;EAEH;EACA,IAAI,IAAAM,eAAO,EAACL,MAAM,CAAC,EAAE;IACpB,MAAMM,cAAc,GAAG,MAAM,IAAAF,8BAAuB,EAAC;MACpDR,qBAAqB;MACrBF,YAAY,EAAE,CAACD,kBAAkB,CAAC;MAClCF,IAAI;MACJQ;IACD,CAAC,CAAC;;IAEF;IACAC,MAAM,GAAGM,cAAc,CAACN,MAAM;IAC9BC,aAAa,GAAGK,cAAc,CAACL,aAAa;IAC5CC,OAAO,GAAGI,cAAc,CAACJ,OAAO;IAChCC,QAAQ,GAAGG,cAAc,CAACH,QAAQ;IAClCT,YAAY,GAAG,CAACD,kBAAkB,CAAC;EACpC;EAEA,MAAMc,YAAY,GACjBZ,UAAU,KAAK,OAAO,GACnB,IAAAa,0BAAmB,EAACR,MAAM,EAAEN,YAAY,CAAC,GACzC,IAAAe,gEAA+B,EAACT,MAAM,CAAC;EAE3C,OAAO;IACNA,MAAM,EAAE,IAAAU,YAAI,EACXH,YAAY,EACZ,IAAAI,8BAAc,EAACd,sBAAsB,EAAEC,0BAA0B,CAAC,EAClE,IAAAc,gCAAyB,EAAChB,qBAAqB,EAAEL,IAAI,CAAC,EACtD,IAAAsB,8CAAsB,EAACrB,aAAa,CACrC,CAAC;IACDU,OAAO,EAAEA,OAAO;IAChBC,QAAQ,EAAEA,QAAQ;IAClBF;EACD,CAAC;AACF,CAAC;AAACa,OAAA,CAAAxB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -10,22 +10,43 @@ var _contextUtil = require("../capabilities/offer-catalog/src/utils/contextUtil"
|
|
|
10
10
|
* Retrieves offers by product types.
|
|
11
11
|
*
|
|
12
12
|
* @param {Object} params - The parameters for retrieving offers by product types.
|
|
13
|
-
* @param {boolean} params.
|
|
13
|
+
* @param {boolean} params.isCachedOffersRequest - Indicates if the offers should be retrieved from the cache.
|
|
14
14
|
* @param {string[]} params.productTypes - The product types to retrieve offers for.
|
|
15
15
|
* @param {string} params.tags - The tags to use for retrieving offers.
|
|
16
16
|
* @returns {Promise<OffersData>} A promise that resolves to an array of offers or undefined if no offers are found.
|
|
17
17
|
*/
|
|
18
18
|
const getOffersByProductTypes = async ({
|
|
19
|
-
|
|
19
|
+
isCachedOffersRequest,
|
|
20
20
|
productTypes,
|
|
21
21
|
tags,
|
|
22
22
|
context
|
|
23
23
|
}) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
if (isCachedOffersRequest) {
|
|
25
|
+
const {
|
|
26
|
+
offers,
|
|
27
|
+
uuid,
|
|
28
|
+
isError,
|
|
29
|
+
leadUuid
|
|
30
|
+
} = await (0, _offerCatalogApi.getCachedOffersByProductTypes)(context)(productTypes);
|
|
31
|
+
return {
|
|
32
|
+
offers,
|
|
33
|
+
rateTableUuid: uuid,
|
|
34
|
+
isError,
|
|
35
|
+
leadUuid
|
|
36
|
+
};
|
|
27
37
|
}
|
|
28
|
-
|
|
38
|
+
const {
|
|
39
|
+
offers,
|
|
40
|
+
uuid,
|
|
41
|
+
isError,
|
|
42
|
+
leadUuid
|
|
43
|
+
} = await (0, _offerCatalogApi.getOffersForProductTypes)(context)(productTypes, (0, _contextUtil.parseClientTags)(tags));
|
|
44
|
+
return {
|
|
45
|
+
offers,
|
|
46
|
+
rateTableUuid: uuid,
|
|
47
|
+
isError,
|
|
48
|
+
leadUuid
|
|
49
|
+
};
|
|
29
50
|
};
|
|
30
51
|
exports.getOffersByProductTypes = getOffersByProductTypes;
|
|
31
52
|
//# sourceMappingURL=getOffersByProductTypes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_offerCatalogApi","require","_contextUtil","getOffersByProductTypes","
|
|
1
|
+
{"version":3,"names":["_offerCatalogApi","require","_contextUtil","getOffersByProductTypes","isCachedOffersRequest","productTypes","tags","context","offers","uuid","isError","leadUuid","getCachedOffersByProductTypes","rateTableUuid","getOffersForProductTypes","parseClientTags","exports"],"sourceRoot":"../../../src","sources":["utils/getOffersByProductTypes.ts"],"mappings":";;;;;;AACA,IAAAA,gBAAA,GAAAC,OAAA;AAIA,IAAAC,YAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,uBAAuB,GAAG,MAAAA,CAAO;EAC7CC,qBAAqB;EACrBC,YAAY;EACZC,IAAI;EACJC;AAMD,CAAC,KAAK;EACL,IAAIH,qBAAqB,EAAE;IAC1B,MAAM;MAAEI,MAAM;MAAEC,IAAI;MAAEC,OAAO;MAAEC;IAAS,CAAC,GACxC,MAAM,IAAAC,8CAA6B,EAACL,OAAO,CAAC,CAACF,YAAY,CAAC;IAE3D,OAAO;MAAEG,MAAM;MAAEK,aAAa,EAAEJ,IAAI;MAAEC,OAAO;MAAEC;IAAS,CAAC;EAC1D;EAEA,MAAM;IAAEH,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC;EAAS,CAAC,GAAG,MAAM,IAAAG,yCAAwB,EACzEP,OACD,CAAC,CAACF,YAAY,EAAE,IAAAU,4BAAe,EAACT,IAAI,CAAC,CAAC;EAEtC,OAAO;IAAEE,MAAM;IAAEK,aAAa,EAAEJ,IAAI;IAAEC,OAAO;IAAEC;EAAS,CAAC;AAC1D,CAAC;AAACK,OAAA,CAAAb,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
package/lib/module/pageData.js
CHANGED
|
@@ -20,7 +20,7 @@ export async function getPageData({
|
|
|
20
20
|
|
|
21
21
|
// Resolve Tags
|
|
22
22
|
const resolvedTags = `${tags === null || tags === void 0 ? void 0 : tags.trim()}`;
|
|
23
|
-
const
|
|
23
|
+
const isCachedOffersRequest = getEnableUseCachedOffers(context);
|
|
24
24
|
const defaultProductType = getDefaultProductType(context);
|
|
25
25
|
|
|
26
26
|
// TODO: Check if this is needed or if we can remove it
|
|
@@ -64,7 +64,7 @@ export async function getPageData({
|
|
|
64
64
|
displayLayout: safeDisplayLayout,
|
|
65
65
|
productTypes,
|
|
66
66
|
resultType,
|
|
67
|
-
|
|
67
|
+
isCachedOffersRequest,
|
|
68
68
|
productTypesDefinition: [...productTypesDefinition],
|
|
69
69
|
partnersOverrideDefinition: [...partnersOverrideDefinition],
|
|
70
70
|
context,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getIsDevEnvironment","getDynamicOffers","getDefaultProductType","getLayout","getProductTypesDefinition","resolveProductTypes","getEnableUseCachedOffers","getPageData","context","params","onRateTableSubmit","productType","query","tags","displayLayout","searchAPIToken","showProductTypeLabel","showCardBorder","resolvedTags","trim","
|
|
1
|
+
{"version":3,"names":["getIsDevEnvironment","getDynamicOffers","getDefaultProductType","getLayout","getProductTypesDefinition","resolveProductTypes","getEnableUseCachedOffers","getPageData","context","params","onRateTableSubmit","productType","query","tags","displayLayout","searchAPIToken","showProductTypeLabel","showCardBorder","resolvedTags","trim","isCachedOffersRequest","defaultProductType","isDev","productTypesDefinition","partnersOverrideDefinition","currentCountry","signals","deviceSignals","country","safeTags","encodeURI","safeDisplayLayout","productTypes","resultType","timestamp","Date","toISOString","offers","isError","leadUuid","rateTableUuid"],"sourceRoot":"../../src","sources":["pageData.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,oDAAoD;AAIxF,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D;AACA,SACCC,qBAAqB,EACrBC,SAAS,EACTC,yBAAyB,EACzBC,mBAAmB,QACb,SAAS;AAChB,SAASC,wBAAwB,QAAQ,kCAAkC;AAQ3E,OAAO,eAAeC,WAAWA,CAAC;EACjCC,OAAO;EACPC,MAAM;EACNC;AACiB,CAAC,EAAE;EACpB,MAAM;IACLC,WAAW;IACXC,KAAK;IACLC,IAAI;IACJC,aAAa;IACbC,cAAc;IACdC,oBAAoB;IACpBC;EACD,CAAC,GAAGR,MAAM;;EAEV;EACA,MAAMS,YAAY,GAAG,GAAGL,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEM,IAAI,CAAC,CAAC,EAAE;EAEtC,MAAMC,qBAAqB,GAAGd,wBAAwB,CAACE,OAAO,CAAC;EAE/D,MAAMa,kBAAkB,GAAGnB,qBAAqB,CAACM,OAAO,CAAC;;EAEzD;EACA;;EAEA,MAAMc,KAAK,GAAGtB,mBAAmB,CAACQ,OAAO,CAAC;EAE1C,MAAM;IAAEe,sBAAsB;IAAEC;EAA2B,CAAC,GAC3DpB,yBAAyB,CAACI,OAAO,CAAC;EAEnC,MAAMiB,cAAc,GAAGjB,OAAO,CAACkB,OAAO,CAACC,aAAa,CAACC,OAAO;EAE5D,MAAMC,QAAQ,GAAGC,SAAS,CAACZ,YAAY,CAAC;EAExC,MAAMa,iBAAiB,GAAG5B,SAAS,CAACW,aAAa,CAAC;;EAElD;EACA,MAAM;IAAEkB,YAAY;IAAEC;EAAW,CAAC,GAAG,MAAM5B,mBAAmB,CAAC;IAC9DgB,kBAAkB;IAClBV,WAAW;IACXC,KAAK;IACLG,cAAc;IACdO;EACD,CAAC,CAAC;EAEFZ,iBAAiB,aAAjBA,iBAAiB,eAAjBA,iBAAiB,CAAG;IACnBwB,SAAS,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;IACnCJ,YAAY;IACZC,UAAU;IACVZ;EACD,CAAC,CAAC;;EAEF;EACA,MAAM;IAAEgB,MAAM;IAAEC,OAAO;IAAEC,QAAQ;IAAEC;EAAc,CAAC,GAAG,MAAMvC,gBAAgB,CAAC;IAC3EY,IAAI,EAAEgB,QAAQ;IACdf,aAAa,EAAEiB,iBAAiB;IAChCC,YAAY;IACZC,UAAU;IACVb,qBAAqB;IACrBG,sBAAsB,EAAE,CAAC,GAAGA,sBAAsB,CAAC;IACnDC,0BAA0B,EAAE,CAAC,GAAGA,0BAA0B,CAAC;IAC3DhB,OAAO;IACPa;EACD,CAAC,CAAC;EAEF,OAAO;IACNiB,OAAO;IACPC,QAAQ;IACRC,aAAa;IACb;IACAH,MAAM;IACNZ,cAAc;IACd;IACAR,cAAc;IACd;IACAD,oBAAoB;IACpBF,aAAa,EAAEiB;EAChB,CAAC;AACF","ignoreList":[]}
|
|
@@ -16,38 +16,46 @@ export const getDynamicOffers = async ({
|
|
|
16
16
|
defaultProductType,
|
|
17
17
|
productTypes,
|
|
18
18
|
resultType,
|
|
19
|
-
|
|
19
|
+
isCachedOffersRequest,
|
|
20
20
|
productTypesDefinition,
|
|
21
21
|
partnersOverrideDefinition,
|
|
22
22
|
context
|
|
23
23
|
}) => {
|
|
24
24
|
// Get the initial offers
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
let {
|
|
26
|
+
offers,
|
|
27
|
+
rateTableUuid,
|
|
28
|
+
isError,
|
|
29
|
+
leadUuid
|
|
30
|
+
} = await getOffersByProductTypes({
|
|
31
|
+
isCachedOffersRequest,
|
|
27
32
|
productTypes,
|
|
28
33
|
tags,
|
|
29
34
|
context
|
|
30
35
|
});
|
|
31
36
|
|
|
32
|
-
//
|
|
33
|
-
if (isEmpty(
|
|
34
|
-
|
|
37
|
+
// If no offers found, fall back to the default product type
|
|
38
|
+
if (isEmpty(offers)) {
|
|
39
|
+
const fallbackResult = await getOffersByProductTypes({
|
|
40
|
+
isCachedOffersRequest,
|
|
41
|
+
productTypes: [defaultProductType],
|
|
42
|
+
tags,
|
|
43
|
+
context
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Update the offers, rateTableUuid, isError, leafUuid and productTypes
|
|
47
|
+
offers = fallbackResult.offers;
|
|
48
|
+
rateTableUuid = fallbackResult.rateTableUuid;
|
|
49
|
+
isError = fallbackResult.isError;
|
|
50
|
+
leadUuid = fallbackResult.leadUuid;
|
|
35
51
|
productTypes = [defaultProductType];
|
|
36
52
|
}
|
|
37
|
-
|
|
38
|
-
// if initial offers are returned, return them
|
|
39
|
-
const offersData = isEmpty(initialOffersData === null || initialOffersData === void 0 ? void 0 : initialOffersData.offers) ? await getOffersByProductTypes({
|
|
40
|
-
enableUseCachedOffers,
|
|
41
|
-
productTypes,
|
|
42
|
-
tags,
|
|
43
|
-
context
|
|
44
|
-
}) : initialOffersData;
|
|
45
|
-
const sortedOffers = resultType === "QUERY" ? selectDynamicOffers(offersData.offers, productTypes) : sortOffersByRecommendationScore(offersData.offers);
|
|
53
|
+
const sortedOffers = resultType === "QUERY" ? selectDynamicOffers(offers, productTypes) : sortOffersByRecommendationScore(offers);
|
|
46
54
|
return {
|
|
47
|
-
offers: pipe(sortedOffers, formatOfferUrl(productTypesDefinition, partnersOverrideDefinition), addClientTagsToOfferLinks(
|
|
48
|
-
isError:
|
|
49
|
-
leadUuid:
|
|
50
|
-
rateTableUuid
|
|
55
|
+
offers: pipe(sortedOffers, formatOfferUrl(productTypesDefinition, partnersOverrideDefinition), addClientTagsToOfferLinks(isCachedOffersRequest, tags), getOffersBasedOnLayout(displayLayout)),
|
|
56
|
+
isError: isError,
|
|
57
|
+
leadUuid: leadUuid,
|
|
58
|
+
rateTableUuid
|
|
51
59
|
};
|
|
52
60
|
};
|
|
53
61
|
//# sourceMappingURL=getDynamicOffers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isEmpty","addClientTagsToOfferLinks","getOffersByProductTypes","selectDynamicOffers","sortOffersByRecommendationScore","pipe","formatOfferUrl","getOffersBasedOnLayout","getDynamicOffers","tags","displayLayout","defaultProductType","productTypes","resultType","
|
|
1
|
+
{"version":3,"names":["isEmpty","addClientTagsToOfferLinks","getOffersByProductTypes","selectDynamicOffers","sortOffersByRecommendationScore","pipe","formatOfferUrl","getOffersBasedOnLayout","getDynamicOffers","tags","displayLayout","defaultProductType","productTypes","resultType","isCachedOffersRequest","productTypesDefinition","partnersOverrideDefinition","context","offers","rateTableUuid","isError","leadUuid","fallbackResult","sortedOffers"],"sourceRoot":"../../../src","sources":["services/getDynamicOffers.ts"],"mappings":"AAAA,SAASA,OAAO,QAAQ,QAAQ;AAChC,SACCC,yBAAyB,EACzBC,uBAAuB,EACvBC,mBAAmB,QAEb,UAAU;AAKjB,SAASC,+BAA+B,QAAQ,0CAA0C;AAC1F,SAASC,IAAI,QAAQ,QAAQ;AAC7B,SAASC,cAAc,QAAQ,yBAAyB;AACxD,SAASC,sBAAsB,QAAQ,iCAAiC;AA0BxE;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAG,MAAAA,CAAO;EACtCC,IAAI;EACJC,aAAa;EACbC,kBAAkB;EAClBC,YAAY;EACZC,UAAU;EACVC,qBAAqB;EACrBC,sBAAsB;EACtBC,0BAA0B;EAC1BC;AACqC,CAAC,KAAK;EAC3C;EACA,IAAI;IAAEC,MAAM;IAAEC,aAAa;IAAEC,OAAO;IAAEC;EAAS,CAAC,GAC/C,MAAMnB,uBAAuB,CAAC;IAC7BY,qBAAqB;IACrBF,YAAY;IACZH,IAAI;IACJQ;EACD,CAAC,CAAC;;EAEH;EACA,IAAIjB,OAAO,CAACkB,MAAM,CAAC,EAAE;IACpB,MAAMI,cAAc,GAAG,MAAMpB,uBAAuB,CAAC;MACpDY,qBAAqB;MACrBF,YAAY,EAAE,CAACD,kBAAkB,CAAC;MAClCF,IAAI;MACJQ;IACD,CAAC,CAAC;;IAEF;IACAC,MAAM,GAAGI,cAAc,CAACJ,MAAM;IAC9BC,aAAa,GAAGG,cAAc,CAACH,aAAa;IAC5CC,OAAO,GAAGE,cAAc,CAACF,OAAO;IAChCC,QAAQ,GAAGC,cAAc,CAACD,QAAQ;IAClCT,YAAY,GAAG,CAACD,kBAAkB,CAAC;EACpC;EAEA,MAAMY,YAAY,GACjBV,UAAU,KAAK,OAAO,GACnBV,mBAAmB,CAACe,MAAM,EAAEN,YAAY,CAAC,GACzCR,+BAA+B,CAACc,MAAM,CAAC;EAE3C,OAAO;IACNA,MAAM,EAAEb,IAAI,CACXkB,YAAY,EACZjB,cAAc,CAACS,sBAAsB,EAAEC,0BAA0B,CAAC,EAClEf,yBAAyB,CAACa,qBAAqB,EAAEL,IAAI,CAAC,EACtDF,sBAAsB,CAACG,aAAa,CACrC,CAAC;IACDU,OAAO,EAAEA,OAAO;IAChBC,QAAQ,EAAEA,QAAQ;IAClBF;EACD,CAAC;AACF,CAAC","ignoreList":[]}
|
|
@@ -5,21 +5,42 @@ import { parseClientTags } from "../capabilities/offer-catalog/src/utils/context
|
|
|
5
5
|
* Retrieves offers by product types.
|
|
6
6
|
*
|
|
7
7
|
* @param {Object} params - The parameters for retrieving offers by product types.
|
|
8
|
-
* @param {boolean} params.
|
|
8
|
+
* @param {boolean} params.isCachedOffersRequest - Indicates if the offers should be retrieved from the cache.
|
|
9
9
|
* @param {string[]} params.productTypes - The product types to retrieve offers for.
|
|
10
10
|
* @param {string} params.tags - The tags to use for retrieving offers.
|
|
11
11
|
* @returns {Promise<OffersData>} A promise that resolves to an array of offers or undefined if no offers are found.
|
|
12
12
|
*/
|
|
13
13
|
export const getOffersByProductTypes = async ({
|
|
14
|
-
|
|
14
|
+
isCachedOffersRequest,
|
|
15
15
|
productTypes,
|
|
16
16
|
tags,
|
|
17
17
|
context
|
|
18
18
|
}) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
if (isCachedOffersRequest) {
|
|
20
|
+
const {
|
|
21
|
+
offers,
|
|
22
|
+
uuid,
|
|
23
|
+
isError,
|
|
24
|
+
leadUuid
|
|
25
|
+
} = await getCachedOffersByProductTypes(context)(productTypes);
|
|
26
|
+
return {
|
|
27
|
+
offers,
|
|
28
|
+
rateTableUuid: uuid,
|
|
29
|
+
isError,
|
|
30
|
+
leadUuid
|
|
31
|
+
};
|
|
22
32
|
}
|
|
23
|
-
|
|
33
|
+
const {
|
|
34
|
+
offers,
|
|
35
|
+
uuid,
|
|
36
|
+
isError,
|
|
37
|
+
leadUuid
|
|
38
|
+
} = await getOffersForProductTypes(context)(productTypes, parseClientTags(tags));
|
|
39
|
+
return {
|
|
40
|
+
offers,
|
|
41
|
+
rateTableUuid: uuid,
|
|
42
|
+
isError,
|
|
43
|
+
leadUuid
|
|
44
|
+
};
|
|
24
45
|
};
|
|
25
46
|
//# sourceMappingURL=getOffersByProductTypes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getCachedOffersByProductTypes","getOffersForProductTypes","parseClientTags","getOffersByProductTypes","
|
|
1
|
+
{"version":3,"names":["getCachedOffersByProductTypes","getOffersForProductTypes","parseClientTags","getOffersByProductTypes","isCachedOffersRequest","productTypes","tags","context","offers","uuid","isError","leadUuid","rateTableUuid"],"sourceRoot":"../../../src","sources":["utils/getOffersByProductTypes.ts"],"mappings":"AACA,SACCA,6BAA6B,EAC7BC,wBAAwB,QAClB,uDAAuD;AAC9D,SAASC,eAAe,QAAQ,qDAAqD;;AAErF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,uBAAuB,GAAG,MAAAA,CAAO;EAC7CC,qBAAqB;EACrBC,YAAY;EACZC,IAAI;EACJC;AAMD,CAAC,KAAK;EACL,IAAIH,qBAAqB,EAAE;IAC1B,MAAM;MAAEI,MAAM;MAAEC,IAAI;MAAEC,OAAO;MAAEC;IAAS,CAAC,GACxC,MAAMX,6BAA6B,CAACO,OAAO,CAAC,CAACF,YAAY,CAAC;IAE3D,OAAO;MAAEG,MAAM;MAAEI,aAAa,EAAEH,IAAI;MAAEC,OAAO;MAAEC;IAAS,CAAC;EAC1D;EAEA,MAAM;IAAEH,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC;EAAS,CAAC,GAAG,MAAMV,wBAAwB,CACzEM,OACD,CAAC,CAACF,YAAY,EAAEH,eAAe,CAACI,IAAI,CAAC,CAAC;EAEtC,OAAO;IAAEE,MAAM;IAAEI,aAAa,EAAEH,IAAI;IAAEC,OAAO;IAAEC;EAAS,CAAC;AAC1D,CAAC","ignoreList":[]}
|
|
@@ -7,7 +7,7 @@ export type GetDynamicOffersProps = {
|
|
|
7
7
|
displayLayout: Layout;
|
|
8
8
|
productTypes: string[];
|
|
9
9
|
resultType: ProductTypesResult["resultType"];
|
|
10
|
-
|
|
10
|
+
isCachedOffersRequest: boolean;
|
|
11
11
|
productTypesDefinition: ProductTypeDefinition[];
|
|
12
12
|
partnersOverrideDefinition: PartnerOverride[];
|
|
13
13
|
context: CnfContext;
|
|
@@ -18,7 +18,7 @@ export type GetDynamicOffersProps = {
|
|
|
18
18
|
* @param {GetDynamicOffersProps} params - The parameters for retrieving dynamic offers.
|
|
19
19
|
* @returns {Promise<{ productTypeDisplayName: string; offers: typeof offers }>} An object containing the product type display name and the offers.
|
|
20
20
|
*/
|
|
21
|
-
export declare const getDynamicOffers: ({ tags, displayLayout, defaultProductType, productTypes, resultType,
|
|
21
|
+
export declare const getDynamicOffers: ({ tags, displayLayout, defaultProductType, productTypes, resultType, isCachedOffersRequest, productTypesDefinition, partnersOverrideDefinition, context, }: Omit<GetDynamicOffersProps, "isDev">) => Promise<{
|
|
22
22
|
offers: import("../capabilities/offer-catalog/src").BaseOffer[];
|
|
23
23
|
isError: boolean | undefined;
|
|
24
24
|
leadUuid: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDynamicOffers.d.ts","sourceRoot":"","sources":["../../../../src/services/getDynamicOffers.ts"],"names":[],"mappings":"AACA,OAAO,EAIN,KAAK,MAAM,EACX,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACX,oBAAoB,EACpB,kBAAkB,EAClB,MAAM,mBAAmB,CAAC;AAK3B,OAAO,KAAK,EACX,eAAe,EACf,qBAAqB,EACrB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uDAAuD,CAAC;AAExF,MAAM,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAC;IAC7C,qBAAqB,EAAE,OAAO,CAAC;IAC/B,sBAAsB,EAAE,qBAAqB,EAAE,CAAC;IAChD,0BAA0B,EAAE,eAAe,EAAE,CAAC;IAC9C,OAAO,EAAE,UAAU,CAAC;CACpB,GAAG,IAAI,CACP,oBAAoB,EAClB,SAAS,GACT,kBAAkB,GAClB,OAAO,GACP,WAAW,GACX,UAAU,GACV,gBAAgB,CAClB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,+JAU1B,KAAK,qBAAqB,EAAE,OAAO,CAAC;;;;;
|
|
1
|
+
{"version":3,"file":"getDynamicOffers.d.ts","sourceRoot":"","sources":["../../../../src/services/getDynamicOffers.ts"],"names":[],"mappings":"AACA,OAAO,EAIN,KAAK,MAAM,EACX,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACX,oBAAoB,EACpB,kBAAkB,EAClB,MAAM,mBAAmB,CAAC;AAK3B,OAAO,KAAK,EACX,eAAe,EACf,qBAAqB,EACrB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uDAAuD,CAAC;AAExF,MAAM,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAC;IAC7C,qBAAqB,EAAE,OAAO,CAAC;IAC/B,sBAAsB,EAAE,qBAAqB,EAAE,CAAC;IAChD,0BAA0B,EAAE,eAAe,EAAE,CAAC;IAC9C,OAAO,EAAE,UAAU,CAAC;CACpB,GAAG,IAAI,CACP,oBAAoB,EAClB,SAAS,GACT,kBAAkB,GAClB,OAAO,GACP,WAAW,GACX,UAAU,GACV,gBAAgB,CAClB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,+JAU1B,KAAK,qBAAqB,EAAE,OAAO,CAAC;;;;;EA2CtC,CAAC"}
|
|
@@ -3,15 +3,20 @@ import type { CnfContext } from "../capabilities/core/src/system/cnfContext/CnfC
|
|
|
3
3
|
* Retrieves offers by product types.
|
|
4
4
|
*
|
|
5
5
|
* @param {Object} params - The parameters for retrieving offers by product types.
|
|
6
|
-
* @param {boolean} params.
|
|
6
|
+
* @param {boolean} params.isCachedOffersRequest - Indicates if the offers should be retrieved from the cache.
|
|
7
7
|
* @param {string[]} params.productTypes - The product types to retrieve offers for.
|
|
8
8
|
* @param {string} params.tags - The tags to use for retrieving offers.
|
|
9
9
|
* @returns {Promise<OffersData>} A promise that resolves to an array of offers or undefined if no offers are found.
|
|
10
10
|
*/
|
|
11
|
-
export declare const getOffersByProductTypes: ({
|
|
12
|
-
|
|
11
|
+
export declare const getOffersByProductTypes: ({ isCachedOffersRequest, productTypes, tags, context, }: {
|
|
12
|
+
isCachedOffersRequest: boolean;
|
|
13
13
|
productTypes: string[];
|
|
14
14
|
tags: string;
|
|
15
15
|
context: CnfContext;
|
|
16
|
-
}) => Promise<
|
|
16
|
+
}) => Promise<{
|
|
17
|
+
offers: import("../capabilities/offer-catalog/src").BaseOffer[];
|
|
18
|
+
rateTableUuid: string;
|
|
19
|
+
isError: boolean | undefined;
|
|
20
|
+
leadUuid: string;
|
|
21
|
+
}>;
|
|
17
22
|
//# sourceMappingURL=getOffersByProductTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOffersByProductTypes.d.ts","sourceRoot":"","sources":["../../../../src/utils/getOffersByProductTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uDAAuD,CAAC;AAOxF;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB;2BAMZ,OAAO;kBAChB,MAAM,EAAE;UAChB,MAAM;aACH,UAAU
|
|
1
|
+
{"version":3,"file":"getOffersByProductTypes.d.ts","sourceRoot":"","sources":["../../../../src/utils/getOffersByProductTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uDAAuD,CAAC;AAOxF;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB;2BAMZ,OAAO;kBAChB,MAAM,EAAE;UAChB,MAAM;aACH,UAAU;;;;;;EAcnB,CAAC"}
|
package/package.json
CHANGED
package/src/pageData.ts
CHANGED
|
@@ -37,7 +37,7 @@ export async function getPageData({
|
|
|
37
37
|
// Resolve Tags
|
|
38
38
|
const resolvedTags = `${tags?.trim()}`;
|
|
39
39
|
|
|
40
|
-
const
|
|
40
|
+
const isCachedOffersRequest = getEnableUseCachedOffers(context);
|
|
41
41
|
|
|
42
42
|
const defaultProductType = getDefaultProductType(context);
|
|
43
43
|
|
|
@@ -77,7 +77,7 @@ export async function getPageData({
|
|
|
77
77
|
displayLayout: safeDisplayLayout,
|
|
78
78
|
productTypes,
|
|
79
79
|
resultType,
|
|
80
|
-
|
|
80
|
+
isCachedOffersRequest,
|
|
81
81
|
productTypesDefinition: [...productTypesDefinition],
|
|
82
82
|
partnersOverrideDefinition: [...partnersOverrideDefinition],
|
|
83
83
|
context,
|
|
@@ -24,7 +24,7 @@ export type GetDynamicOffersProps = {
|
|
|
24
24
|
displayLayout: Layout;
|
|
25
25
|
productTypes: string[];
|
|
26
26
|
resultType: ProductTypesResult["resultType"];
|
|
27
|
-
|
|
27
|
+
isCachedOffersRequest: boolean;
|
|
28
28
|
productTypesDefinition: ProductTypeDefinition[];
|
|
29
29
|
partnersOverrideDefinition: PartnerOverride[];
|
|
30
30
|
context: CnfContext;
|
|
@@ -50,49 +50,51 @@ export const getDynamicOffers = async ({
|
|
|
50
50
|
defaultProductType,
|
|
51
51
|
productTypes,
|
|
52
52
|
resultType,
|
|
53
|
-
|
|
53
|
+
isCachedOffersRequest,
|
|
54
54
|
productTypesDefinition,
|
|
55
55
|
partnersOverrideDefinition,
|
|
56
56
|
context,
|
|
57
57
|
}: Omit<GetDynamicOffersProps, "isDev">) => {
|
|
58
58
|
// Get the initial offers
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
let { offers, rateTableUuid, isError, leadUuid } =
|
|
60
|
+
await getOffersByProductTypes({
|
|
61
|
+
isCachedOffersRequest,
|
|
62
|
+
productTypes,
|
|
63
|
+
tags,
|
|
64
|
+
context,
|
|
65
|
+
});
|
|
65
66
|
|
|
66
|
-
//
|
|
67
|
-
if (isEmpty(
|
|
68
|
-
|
|
67
|
+
// If no offers found, fall back to the default product type
|
|
68
|
+
if (isEmpty(offers)) {
|
|
69
|
+
const fallbackResult = await getOffersByProductTypes({
|
|
70
|
+
isCachedOffersRequest,
|
|
71
|
+
productTypes: [defaultProductType],
|
|
72
|
+
tags,
|
|
73
|
+
context,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Update the offers, rateTableUuid, isError, leafUuid and productTypes
|
|
77
|
+
offers = fallbackResult.offers;
|
|
78
|
+
rateTableUuid = fallbackResult.rateTableUuid;
|
|
79
|
+
isError = fallbackResult.isError;
|
|
80
|
+
leadUuid = fallbackResult.leadUuid;
|
|
69
81
|
productTypes = [defaultProductType];
|
|
70
82
|
}
|
|
71
83
|
|
|
72
|
-
// if initial offers are returned, return them
|
|
73
|
-
const offersData = isEmpty(initialOffersData?.offers)
|
|
74
|
-
? await getOffersByProductTypes({
|
|
75
|
-
enableUseCachedOffers,
|
|
76
|
-
productTypes,
|
|
77
|
-
tags,
|
|
78
|
-
context,
|
|
79
|
-
})
|
|
80
|
-
: initialOffersData;
|
|
81
|
-
|
|
82
84
|
const sortedOffers =
|
|
83
85
|
resultType === "QUERY"
|
|
84
|
-
? selectDynamicOffers(
|
|
85
|
-
: sortOffersByRecommendationScore(
|
|
86
|
+
? selectDynamicOffers(offers, productTypes)
|
|
87
|
+
: sortOffersByRecommendationScore(offers);
|
|
86
88
|
|
|
87
89
|
return {
|
|
88
90
|
offers: pipe(
|
|
89
91
|
sortedOffers,
|
|
90
92
|
formatOfferUrl(productTypesDefinition, partnersOverrideDefinition),
|
|
91
|
-
addClientTagsToOfferLinks(
|
|
93
|
+
addClientTagsToOfferLinks(isCachedOffersRequest, tags),
|
|
92
94
|
getOffersBasedOnLayout(displayLayout)
|
|
93
95
|
),
|
|
94
|
-
isError:
|
|
95
|
-
leadUuid:
|
|
96
|
-
rateTableUuid
|
|
96
|
+
isError: isError,
|
|
97
|
+
leadUuid: leadUuid,
|
|
98
|
+
rateTableUuid,
|
|
97
99
|
};
|
|
98
100
|
};
|
|
@@ -9,29 +9,32 @@ import { parseClientTags } from "../capabilities/offer-catalog/src/utils/context
|
|
|
9
9
|
* Retrieves offers by product types.
|
|
10
10
|
*
|
|
11
11
|
* @param {Object} params - The parameters for retrieving offers by product types.
|
|
12
|
-
* @param {boolean} params.
|
|
12
|
+
* @param {boolean} params.isCachedOffersRequest - Indicates if the offers should be retrieved from the cache.
|
|
13
13
|
* @param {string[]} params.productTypes - The product types to retrieve offers for.
|
|
14
14
|
* @param {string} params.tags - The tags to use for retrieving offers.
|
|
15
15
|
* @returns {Promise<OffersData>} A promise that resolves to an array of offers or undefined if no offers are found.
|
|
16
16
|
*/
|
|
17
17
|
export const getOffersByProductTypes = async ({
|
|
18
|
-
|
|
18
|
+
isCachedOffersRequest,
|
|
19
19
|
productTypes,
|
|
20
20
|
tags,
|
|
21
21
|
context,
|
|
22
22
|
}: {
|
|
23
|
-
|
|
23
|
+
isCachedOffersRequest: boolean;
|
|
24
24
|
productTypes: string[];
|
|
25
25
|
tags: string;
|
|
26
26
|
context: CnfContext;
|
|
27
27
|
}) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
if (isCachedOffersRequest) {
|
|
29
|
+
const { offers, uuid, isError, leadUuid } =
|
|
30
|
+
await getCachedOffersByProductTypes(context)(productTypes);
|
|
31
|
+
|
|
32
|
+
return { offers, rateTableUuid: uuid, isError, leadUuid };
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const { offers, uuid, isError, leadUuid } = await getOffersForProductTypes(
|
|
36
|
+
context
|
|
37
|
+
)(productTypes, parseClientTags(tags));
|
|
38
|
+
|
|
39
|
+
return { offers, rateTableUuid: uuid, isError, leadUuid };
|
|
37
40
|
};
|