@moneylion/react-native-offer-carousel 1.9.0 → 1.10.0
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/CHANGELOG.md +12 -0
- package/lib/commonjs/apiEnvironment.js +1 -7
- package/lib/commonjs/apiEnvironment.js.map +1 -1
- package/lib/commonjs/capabilities/core/src/system/cnfContext/CnfContext.js +0 -12
- package/lib/commonjs/capabilities/core/src/system/cnfContext/CnfContext.js.map +1 -1
- package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/App.js +0 -16
- package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/App.js.map +1 -1
- package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Brand.js +0 -120
- package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Brand.js.map +1 -1
- package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Configuration.js +0 -39
- package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Configuration.js.map +1 -1
- package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Request.js +0 -19
- package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Request.js.map +1 -1
- package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Session.js +0 -10
- package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Session.js.map +1 -1
- package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Signals.js +0 -39
- package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Signals.js.map +1 -1
- package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Subaccount.js +0 -24
- package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Subaccount.js.map +1 -1
- package/lib/commonjs/capabilities/errors/types/index.js +22 -1
- package/lib/commonjs/capabilities/errors/types/index.js.map +1 -1
- package/lib/commonjs/capabilities/offer-catalog/src/api/offerCatalogApi.js +3 -3
- package/lib/commonjs/capabilities/offer-catalog/src/api/offerCatalogApi.js.map +1 -1
- package/lib/commonjs/components/MoneyLionOfferCarousel.js +16 -13
- package/lib/commonjs/components/MoneyLionOfferCarousel.js.map +1 -1
- package/lib/commonjs/components/utils/errorUtils.js +2 -2
- package/lib/commonjs/components/utils/errorUtils.js.map +1 -1
- package/lib/commonjs/index.js +11 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/pageData.js +1 -12
- package/lib/commonjs/pageData.js.map +1 -1
- package/lib/commonjs/services/getDynamicOffers.js +5 -4
- package/lib/commonjs/services/getDynamicOffers.js.map +1 -1
- package/lib/commonjs/services/getProductTypes.js +3 -22
- package/lib/commonjs/services/getProductTypes.js.map +1 -1
- package/lib/commonjs/utils/index.js +0 -11
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/resolveProductTypes.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/apiEnvironment.js +0 -5
- package/lib/module/apiEnvironment.js.map +1 -1
- package/lib/module/capabilities/core/src/system/cnfContext/CnfContext.js +1 -11
- package/lib/module/capabilities/core/src/system/cnfContext/CnfContext.js.map +1 -1
- package/lib/module/capabilities/core/src/system/cnfContext/schemas/App.js +1 -11
- package/lib/module/capabilities/core/src/system/cnfContext/schemas/App.js.map +1 -1
- package/lib/module/capabilities/core/src/system/cnfContext/schemas/Brand.js +1 -115
- package/lib/module/capabilities/core/src/system/cnfContext/schemas/Brand.js.map +1 -1
- package/lib/module/capabilities/core/src/system/cnfContext/schemas/Configuration.js +1 -34
- package/lib/module/capabilities/core/src/system/cnfContext/schemas/Configuration.js.map +1 -1
- package/lib/module/capabilities/core/src/system/cnfContext/schemas/Request.js +1 -14
- package/lib/module/capabilities/core/src/system/cnfContext/schemas/Request.js.map +1 -1
- package/lib/module/capabilities/core/src/system/cnfContext/schemas/Session.js +1 -5
- package/lib/module/capabilities/core/src/system/cnfContext/schemas/Session.js.map +1 -1
- package/lib/module/capabilities/core/src/system/cnfContext/schemas/Signals.js +1 -34
- package/lib/module/capabilities/core/src/system/cnfContext/schemas/Signals.js.map +1 -1
- package/lib/module/capabilities/core/src/system/cnfContext/schemas/Subaccount.js +1 -19
- package/lib/module/capabilities/core/src/system/cnfContext/schemas/Subaccount.js.map +1 -1
- package/lib/module/capabilities/errors/types/index.js +21 -0
- package/lib/module/capabilities/errors/types/index.js.map +1 -1
- package/lib/module/capabilities/offer-catalog/src/api/offerCatalogApi.js +4 -4
- package/lib/module/capabilities/offer-catalog/src/api/offerCatalogApi.js.map +1 -1
- package/lib/module/components/MoneyLionOfferCarousel.js +17 -14
- package/lib/module/components/MoneyLionOfferCarousel.js.map +1 -1
- package/lib/module/components/utils/errorUtils.js +3 -3
- package/lib/module/components/utils/errorUtils.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/pageData.js +1 -11
- package/lib/module/pageData.js.map +1 -1
- package/lib/module/services/getDynamicOffers.js +6 -5
- package/lib/module/services/getDynamicOffers.js.map +1 -1
- package/lib/module/services/getProductTypes.js +3 -22
- package/lib/module/services/getProductTypes.js.map +1 -1
- package/lib/module/utils/index.js +0 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/resolveProductTypes.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/src/apiEnvironment.d.ts +0 -4
- package/lib/typescript/src/apiEnvironment.d.ts.map +1 -1
- package/lib/typescript/src/capabilities/core/src/system/cnfContext/CnfContext.d.ts +15 -102
- package/lib/typescript/src/capabilities/core/src/system/cnfContext/CnfContext.d.ts.map +1 -1
- package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/App.d.ts +10 -12
- package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/App.d.ts.map +1 -1
- package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Brand.d.ts +101 -472
- package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Brand.d.ts.map +1 -1
- package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Configuration.d.ts +24 -58
- package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Configuration.d.ts.map +1 -1
- package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Request.d.ts +11 -15
- package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Request.d.ts.map +1 -1
- package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Session.d.ts +4 -7
- package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Session.d.ts.map +1 -1
- package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Signals.d.ts +30 -63
- package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Signals.d.ts.map +1 -1
- package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Subaccount.d.ts +17 -17
- package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Subaccount.d.ts.map +1 -1
- package/lib/typescript/src/capabilities/errors/types/index.d.ts +18 -2
- package/lib/typescript/src/capabilities/errors/types/index.d.ts.map +1 -1
- package/lib/typescript/src/capabilities/offer-catalog/src/utils/contextUtil.d.ts +1 -1
- package/lib/typescript/src/capabilities/offer-catalog/src/utils/contextUtil.d.ts.map +1 -1
- package/lib/typescript/src/capabilities/offers/pipeline/src/sources/ratetables/withDeviceSignals.d.ts +11 -11
- package/lib/typescript/src/components/MoneyLionOfferCarousel.d.ts +0 -2
- package/lib/typescript/src/components/MoneyLionOfferCarousel.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/pageData.d.ts +0 -2
- package/lib/typescript/src/pageData.d.ts.map +1 -1
- package/lib/typescript/src/services/getDynamicOffers.d.ts +3 -4
- package/lib/typescript/src/services/getDynamicOffers.d.ts.map +1 -1
- package/lib/typescript/src/services/getProductTypes.d.ts +2 -7
- package/lib/typescript/src/services/getProductTypes.d.ts.map +1 -1
- package/lib/typescript/src/utils/getOffersByProductTypes.d.ts +1 -1
- package/lib/typescript/src/utils/getProductTypesDefinition.d.ts +8 -8
- package/lib/typescript/src/utils/index.d.ts +0 -1
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/resolveProductTypes.d.ts +0 -5
- package/lib/typescript/src/utils/resolveProductTypes.d.ts.map +1 -1
- package/lib/typescript/src/version.d.ts +1 -1
- package/lib/typescript/src/version.d.ts.map +1 -1
- package/package.json +2 -12
- package/src/apiEnvironment.ts +0 -6
- package/src/capabilities/core/src/system/cnfContext/CnfContext.ts +15 -20
- package/src/capabilities/core/src/system/cnfContext/schemas/App.ts +10 -13
- package/src/capabilities/core/src/system/cnfContext/schemas/Brand.ts +108 -148
- package/src/capabilities/core/src/system/cnfContext/schemas/Configuration.ts +21 -46
- package/src/capabilities/core/src/system/cnfContext/schemas/Request.ts +11 -16
- package/src/capabilities/core/src/system/cnfContext/schemas/Session.ts +4 -8
- package/src/capabilities/core/src/system/cnfContext/schemas/Signals.ts +30 -41
- package/src/capabilities/core/src/system/cnfContext/schemas/Subaccount.ts +16 -24
- package/src/capabilities/errors/types/index.ts +30 -1
- package/src/capabilities/offer-catalog/src/api/offerCatalogApi.ts +4 -4
- package/src/components/MoneyLionOfferCarousel.tsx +16 -17
- package/src/components/utils/errorUtils.ts +3 -3
- package/src/index.tsx +4 -0
- package/src/pageData.ts +2 -20
- package/src/services/getDynamicOffers.ts +14 -28
- package/src/services/getProductTypes.ts +5 -28
- package/src/utils/index.ts +0 -1
- package/src/utils/resolveProductTypes.ts +0 -5
- package/src/version.ts +1 -1
- package/lib/commonjs/capabilities/core/src/domain/third-party-search/index.js +0 -17
- package/lib/commonjs/capabilities/core/src/domain/third-party-search/index.js.map +0 -1
- package/lib/commonjs/capabilities/core/src/domain/third-party-search/orderProductTypesByRankUtils.js +0 -33
- package/lib/commonjs/capabilities/core/src/domain/third-party-search/orderProductTypesByRankUtils.js.map +0 -1
- package/lib/commonjs/services/getProductTypesByQuery.js +0 -72
- package/lib/commonjs/services/getProductTypesByQuery.js.map +0 -1
- package/lib/commonjs/utils/selectDynamicOffers.js +0 -13
- package/lib/commonjs/utils/selectDynamicOffers.js.map +0 -1
- package/lib/module/capabilities/core/src/domain/third-party-search/index.js +0 -2
- package/lib/module/capabilities/core/src/domain/third-party-search/index.js.map +0 -1
- package/lib/module/capabilities/core/src/domain/third-party-search/orderProductTypesByRankUtils.js +0 -26
- package/lib/module/capabilities/core/src/domain/third-party-search/orderProductTypesByRankUtils.js.map +0 -1
- package/lib/module/services/getProductTypesByQuery.js +0 -65
- package/lib/module/services/getProductTypesByQuery.js.map +0 -1
- package/lib/module/utils/selectDynamicOffers.js +0 -6
- package/lib/module/utils/selectDynamicOffers.js.map +0 -1
- package/lib/typescript/src/capabilities/core/src/domain/third-party-search/index.d.ts +0 -2
- package/lib/typescript/src/capabilities/core/src/domain/third-party-search/index.d.ts.map +0 -1
- package/lib/typescript/src/capabilities/core/src/domain/third-party-search/orderProductTypesByRankUtils.d.ts +0 -19
- package/lib/typescript/src/capabilities/core/src/domain/third-party-search/orderProductTypesByRankUtils.d.ts.map +0 -1
- package/lib/typescript/src/services/getProductTypesByQuery.d.ts +0 -30
- package/lib/typescript/src/services/getProductTypesByQuery.d.ts.map +0 -1
- package/lib/typescript/src/utils/selectDynamicOffers.d.ts +0 -3
- package/lib/typescript/src/utils/selectDynamicOffers.d.ts.map +0 -1
- package/src/capabilities/core/src/domain/third-party-search/index.ts +0 -1
- package/src/capabilities/core/src/domain/third-party-search/orderProductTypesByRankUtils.ts +0 -33
- package/src/services/getProductTypesByQuery.ts +0 -76
- package/src/utils/selectDynamicOffers.ts +0 -17
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated use ErrorCodeMap instead.
|
|
3
|
+
* TypeScript 5.8 introduced the --erasableSyntaxOnly flag, which treats enums as
|
|
4
|
+
* a compile error. this enum will be removed in a future version.
|
|
5
|
+
*/
|
|
1
6
|
export enum ErrorCodes {
|
|
2
7
|
// Configuration
|
|
3
8
|
MISSING_CONFIG = "MISSING_CONFIG",
|
|
@@ -12,10 +17,34 @@ export enum ErrorCodes {
|
|
|
12
17
|
NETWORK_REQUEST_ERROR = "NETWORK_REQUEST_ERROR",
|
|
13
18
|
NETWORK_SERVER_ERROR = "NETWORK_SERVER_ERROR",
|
|
14
19
|
NETWORK_OTHER_ERROR = "NETWORK_OTHER_ERROR",
|
|
20
|
+
|
|
21
|
+
// Geo
|
|
22
|
+
NON_US = "NON_US",
|
|
15
23
|
}
|
|
16
24
|
|
|
25
|
+
export const ErrorCodeMap = {
|
|
26
|
+
// Configuration
|
|
27
|
+
MISSING_CONFIG: "MISSING_CONFIG",
|
|
28
|
+
|
|
29
|
+
// UI
|
|
30
|
+
UI_CRASH: "UI_CRASH",
|
|
31
|
+
|
|
32
|
+
// Flow
|
|
33
|
+
FLOW_ERROR: "FLOW_ERROR",
|
|
34
|
+
|
|
35
|
+
// Network
|
|
36
|
+
NETWORK_REQUEST_ERROR: "NETWORK_REQUEST_ERROR",
|
|
37
|
+
NETWORK_SERVER_ERROR: "NETWORK_SERVER_ERROR",
|
|
38
|
+
NETWORK_OTHER_ERROR: "NETWORK_OTHER_ERROR",
|
|
39
|
+
|
|
40
|
+
// Geo
|
|
41
|
+
NON_US: "NON_US",
|
|
42
|
+
} as const;
|
|
43
|
+
|
|
44
|
+
export type ErrorCodeValues = (typeof ErrorCodeMap)[keyof typeof ErrorCodeMap];
|
|
45
|
+
|
|
17
46
|
export interface MoneyLionOfferCarouselError {
|
|
18
|
-
code:
|
|
47
|
+
code: ErrorCodeValues;
|
|
19
48
|
severity: "warning" | "error";
|
|
20
49
|
message: string;
|
|
21
50
|
timestamp: string;
|
|
@@ -14,7 +14,7 @@ import { getOfferCatalogApiBaseUrl } from "../../../../apiEnvironment";
|
|
|
14
14
|
import type { UserData } from "../../../configuration/src/userData/types";
|
|
15
15
|
import type { CnfContext } from "../../../core/src/system/cnfContext/CnfContext";
|
|
16
16
|
import {
|
|
17
|
-
|
|
17
|
+
ErrorCodeMap,
|
|
18
18
|
type ApiError,
|
|
19
19
|
type InternalOnErrorCallback,
|
|
20
20
|
} from "../../../errors/types";
|
|
@@ -92,7 +92,7 @@ export const getCachedOffersByProductTypes =
|
|
|
92
92
|
context,
|
|
93
93
|
},
|
|
94
94
|
...(getApiErrorLogProperties(error) || {
|
|
95
|
-
code:
|
|
95
|
+
code: ErrorCodeMap.FLOW_ERROR,
|
|
96
96
|
severity: "error",
|
|
97
97
|
}),
|
|
98
98
|
});
|
|
@@ -203,7 +203,7 @@ export const getOffersForProductTypes =
|
|
|
203
203
|
} catch (error) {
|
|
204
204
|
onError?.({
|
|
205
205
|
message: "Failed to add device signals to payload",
|
|
206
|
-
code:
|
|
206
|
+
code: ErrorCodeMap.FLOW_ERROR,
|
|
207
207
|
severity: "error",
|
|
208
208
|
error,
|
|
209
209
|
additionalInfo: {
|
|
@@ -300,7 +300,7 @@ export const getOffersForProductTypes =
|
|
|
300
300
|
customClientTags,
|
|
301
301
|
},
|
|
302
302
|
...(getApiErrorLogProperties(error) || {
|
|
303
|
-
code:
|
|
303
|
+
code: ErrorCodeMap.FLOW_ERROR,
|
|
304
304
|
severity: "error",
|
|
305
305
|
}),
|
|
306
306
|
});
|
|
@@ -33,7 +33,7 @@ import type {
|
|
|
33
33
|
InternalOnErrorCallback,
|
|
34
34
|
OnErrorCallback,
|
|
35
35
|
} from "../capabilities/errors/types";
|
|
36
|
-
import {
|
|
36
|
+
import { ErrorCodeMap } from "../capabilities/errors/types";
|
|
37
37
|
import { getApiErrorLogProperties } from "./utils/errorUtils";
|
|
38
38
|
|
|
39
39
|
export type CustomError = {
|
|
@@ -46,9 +46,7 @@ export type MoneyLionOfferCarouselProps = {
|
|
|
46
46
|
channel: string;
|
|
47
47
|
zone: string;
|
|
48
48
|
subAccountToken: string;
|
|
49
|
-
searchAPIToken: string;
|
|
50
49
|
productType?: string;
|
|
51
|
-
query?: string;
|
|
52
50
|
tags?: string;
|
|
53
51
|
staticProductTypes?: string;
|
|
54
52
|
fontFamily?: Partial<FontFamily>;
|
|
@@ -116,7 +114,7 @@ const getConfiguration = async ({
|
|
|
116
114
|
isDev,
|
|
117
115
|
},
|
|
118
116
|
...(getApiErrorLogProperties(error) || {
|
|
119
|
-
code:
|
|
117
|
+
code: ErrorCodeMap.FLOW_ERROR,
|
|
120
118
|
severity: "error",
|
|
121
119
|
}),
|
|
122
120
|
});
|
|
@@ -141,9 +139,7 @@ const InternalMoneyLionOfferCarousel = (
|
|
|
141
139
|
subtitle,
|
|
142
140
|
isDarkTheme = false,
|
|
143
141
|
productType,
|
|
144
|
-
query,
|
|
145
142
|
tags,
|
|
146
|
-
searchAPIToken,
|
|
147
143
|
showProductTypeLabel: _showProductTypeLabel,
|
|
148
144
|
showCardBorder: _showCardBorder,
|
|
149
145
|
userData,
|
|
@@ -176,9 +172,7 @@ const InternalMoneyLionOfferCarousel = (
|
|
|
176
172
|
const getPageDataParams: GetPageDataParams = useMemo(
|
|
177
173
|
() => ({
|
|
178
174
|
productType,
|
|
179
|
-
query,
|
|
180
175
|
tags,
|
|
181
|
-
searchAPIToken,
|
|
182
176
|
userData: {
|
|
183
177
|
email: userData?.email || "",
|
|
184
178
|
_mockUserCountry: userData?._mockUserCountry || "",
|
|
@@ -188,9 +182,7 @@ const InternalMoneyLionOfferCarousel = (
|
|
|
188
182
|
}),
|
|
189
183
|
[
|
|
190
184
|
productType,
|
|
191
|
-
query,
|
|
192
185
|
tags,
|
|
193
|
-
searchAPIToken,
|
|
194
186
|
_showProductTypeLabel,
|
|
195
187
|
_showCardBorder,
|
|
196
188
|
userData?.email,
|
|
@@ -243,7 +235,7 @@ const InternalMoneyLionOfferCarousel = (
|
|
|
243
235
|
isDev,
|
|
244
236
|
},
|
|
245
237
|
...(getApiErrorLogProperties(errorObj) || {
|
|
246
|
-
code:
|
|
238
|
+
code: ErrorCodeMap.FLOW_ERROR,
|
|
247
239
|
severity: "error",
|
|
248
240
|
}),
|
|
249
241
|
});
|
|
@@ -268,27 +260,34 @@ const InternalMoneyLionOfferCarousel = (
|
|
|
268
260
|
}, [isFetchingConfig]);
|
|
269
261
|
|
|
270
262
|
useEffect(() => {
|
|
271
|
-
if (!channel || !zone || !subAccountToken
|
|
263
|
+
if (!channel || !zone || !subAccountToken) {
|
|
272
264
|
const missingParams: string[] = [];
|
|
273
265
|
if (!channel) missingParams.push("channel");
|
|
274
266
|
if (!zone) missingParams.push("zone");
|
|
275
267
|
if (!subAccountToken) missingParams.push("subAccountToken");
|
|
276
|
-
if (!searchAPIToken) missingParams.push("searchAPIToken");
|
|
277
268
|
|
|
278
269
|
onError?.({
|
|
279
|
-
code:
|
|
270
|
+
code: ErrorCodeMap.MISSING_CONFIG,
|
|
280
271
|
message: `Missing required parameters: ${missingParams.join(", ")}`,
|
|
281
272
|
severity: "error",
|
|
282
273
|
});
|
|
283
274
|
}
|
|
284
275
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
285
|
-
}, [channel, zone, subAccountToken
|
|
276
|
+
}, [channel, zone, subAccountToken]);
|
|
286
277
|
|
|
287
278
|
useEffect(() => {
|
|
288
279
|
const fetchPageData = async () => {
|
|
289
280
|
// Should only fetch data if context is done fetching
|
|
290
281
|
if (context && !isFetchingConfig) {
|
|
291
282
|
if (isNonUSCountry) {
|
|
283
|
+
onError?.({
|
|
284
|
+
code: ErrorCodeMap.NON_US,
|
|
285
|
+
severity: "warning",
|
|
286
|
+
message: "This service is not available in your country",
|
|
287
|
+
additionalInfo: {
|
|
288
|
+
country,
|
|
289
|
+
},
|
|
290
|
+
});
|
|
292
291
|
setIsFetchingData(false);
|
|
293
292
|
return;
|
|
294
293
|
}
|
|
@@ -324,7 +323,7 @@ const InternalMoneyLionOfferCarousel = (
|
|
|
324
323
|
pageDataParams: getPageDataParams,
|
|
325
324
|
},
|
|
326
325
|
...(getApiErrorLogProperties(errorObj) || {
|
|
327
|
-
code:
|
|
326
|
+
code: ErrorCodeMap.FLOW_ERROR,
|
|
328
327
|
severity: "error",
|
|
329
328
|
}),
|
|
330
329
|
});
|
|
@@ -449,7 +448,7 @@ export const MoneyLionOfferCarousel = (
|
|
|
449
448
|
const logErrorBoundary = useCallback(
|
|
450
449
|
(error: Error) => {
|
|
451
450
|
onError?.({
|
|
452
|
-
code:
|
|
451
|
+
code: ErrorCodeMap.UI_CRASH,
|
|
453
452
|
severity: "error",
|
|
454
453
|
message: "Error boundary crash",
|
|
455
454
|
error,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ErrorCodeMap } from "../../capabilities/errors/types";
|
|
2
2
|
import type { InternalMoneyLionOfferCarouselError } from "../../capabilities/errors/types";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -51,7 +51,7 @@ export const getApiErrorLogProperties = (
|
|
|
51
51
|
return {
|
|
52
52
|
...logProperties,
|
|
53
53
|
statusCode,
|
|
54
|
-
code:
|
|
54
|
+
code: ErrorCodeMap.NETWORK_REQUEST_ERROR,
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -59,6 +59,6 @@ export const getApiErrorLogProperties = (
|
|
|
59
59
|
return {
|
|
60
60
|
...logProperties,
|
|
61
61
|
statusCode,
|
|
62
|
-
code:
|
|
62
|
+
code: ErrorCodeMap.NETWORK_SERVER_ERROR,
|
|
63
63
|
};
|
|
64
64
|
};
|
package/src/index.tsx
CHANGED
package/src/pageData.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { UserData } from "./capabilities/configuration/src/userData/types";
|
|
2
2
|
import type { CnfContext } from "./capabilities/core/src/system/cnfContext/CnfContext";
|
|
3
3
|
import type { InternalOnErrorCallback } from "./capabilities/errors/types";
|
|
4
|
-
import { getIsDevEnvironment } from "./capabilities/offer-catalog/src/utils/contextUtil";
|
|
5
4
|
|
|
6
5
|
import type { onRateTableSubmitProps } from "./context/EventHandlerProvider";
|
|
7
6
|
import { getDynamicOffers } from "./services/getDynamicOffers";
|
|
8
|
-
// import { getDynamicOffers } from "./services/getDynamicOffers";
|
|
9
7
|
import {
|
|
10
8
|
getDefaultProductType,
|
|
11
9
|
getProductTypesDefinition,
|
|
@@ -15,9 +13,7 @@ import { getEnableUseCachedOffers } from "./utils/getEnableUseCachedOffers";
|
|
|
15
13
|
|
|
16
14
|
export type GetPageDataParams = {
|
|
17
15
|
productType?: string;
|
|
18
|
-
query?: string;
|
|
19
16
|
tags?: string;
|
|
20
|
-
searchAPIToken: string;
|
|
21
17
|
showProductTypeLabel?: boolean;
|
|
22
18
|
showCardBorder?: boolean;
|
|
23
19
|
userData?: UserData;
|
|
@@ -36,15 +32,8 @@ export async function getPageData({
|
|
|
36
32
|
onRateTableSubmit,
|
|
37
33
|
onError,
|
|
38
34
|
}: GetPageDataProps) {
|
|
39
|
-
const {
|
|
40
|
-
|
|
41
|
-
query,
|
|
42
|
-
tags,
|
|
43
|
-
searchAPIToken,
|
|
44
|
-
showProductTypeLabel,
|
|
45
|
-
showCardBorder,
|
|
46
|
-
userData,
|
|
47
|
-
} = params;
|
|
35
|
+
const { productType, tags, showProductTypeLabel, showCardBorder, userData } =
|
|
36
|
+
params;
|
|
48
37
|
|
|
49
38
|
// Resolve Tags
|
|
50
39
|
const resolvedTags = `${tags?.trim()}`;
|
|
@@ -56,8 +45,6 @@ export async function getPageData({
|
|
|
56
45
|
// TODO: Check if this is needed or if we can remove it
|
|
57
46
|
// const parsedStaticProductTypes = parseStringProductTypes(staticProductTypes);
|
|
58
47
|
|
|
59
|
-
const isDev = getIsDevEnvironment(context);
|
|
60
|
-
|
|
61
48
|
const { productTypesDefinition, partnersOverrideDefinition } =
|
|
62
49
|
getProductTypesDefinition(context);
|
|
63
50
|
|
|
@@ -69,10 +56,6 @@ export async function getPageData({
|
|
|
69
56
|
const { productTypes, resultType } = await resolveProductTypes({
|
|
70
57
|
defaultProductType,
|
|
71
58
|
productType,
|
|
72
|
-
query,
|
|
73
|
-
searchAPIToken,
|
|
74
|
-
isDev,
|
|
75
|
-
onError,
|
|
76
59
|
});
|
|
77
60
|
|
|
78
61
|
onRateTableSubmit?.({
|
|
@@ -87,7 +70,6 @@ export async function getPageData({
|
|
|
87
70
|
await getDynamicOffers({
|
|
88
71
|
tags: safeTags,
|
|
89
72
|
productTypes,
|
|
90
|
-
resultType,
|
|
91
73
|
isCachedOffersRequest,
|
|
92
74
|
productTypesDefinition: [...productTypesDefinition],
|
|
93
75
|
partnersOverrideDefinition: [...partnersOverrideDefinition],
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import { isEmpty } from "radash";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
getOffersByProductTypes,
|
|
5
|
-
selectDynamicOffers,
|
|
6
|
-
} from "../utils";
|
|
7
|
-
import type {
|
|
8
|
-
GetProductTypesProps,
|
|
9
|
-
ProductTypesResult,
|
|
10
|
-
} from "./getProductTypes";
|
|
2
|
+
import { addClientTagsToOfferLinks, getOffersByProductTypes } from "../utils";
|
|
3
|
+
import type { GetProductTypesProps } from "./getProductTypes";
|
|
11
4
|
import { sortOffersByRecommendationScore } from "../utils/sortOffersByRecommendationScore";
|
|
12
|
-
import { pipe } from "effect";
|
|
13
5
|
import { formatOfferUrl } from "../utils/formatOfferUrl";
|
|
14
6
|
import type {
|
|
15
7
|
PartnerOverride,
|
|
@@ -22,7 +14,6 @@ import type { InternalOnErrorCallback } from "../capabilities/errors/types";
|
|
|
22
14
|
export type GetDynamicOffersProps = {
|
|
23
15
|
tags: string;
|
|
24
16
|
productTypes: string[];
|
|
25
|
-
resultType: ProductTypesResult["resultType"];
|
|
26
17
|
isCachedOffersRequest: boolean;
|
|
27
18
|
productTypesDefinition: ProductTypeDefinition[];
|
|
28
19
|
partnersOverrideDefinition: PartnerOverride[];
|
|
@@ -31,12 +22,7 @@ export type GetDynamicOffersProps = {
|
|
|
31
22
|
onError?: InternalOnErrorCallback;
|
|
32
23
|
} & Omit<
|
|
33
24
|
GetProductTypesProps,
|
|
34
|
-
| "
|
|
35
|
-
| "productTypeOrUrl"
|
|
36
|
-
| "query"
|
|
37
|
-
| "isDevMode"
|
|
38
|
-
| "referrer"
|
|
39
|
-
| "searchAPIToken"
|
|
25
|
+
"context" | "productTypeOrUrl" | "isDevMode" | "referrer"
|
|
40
26
|
>;
|
|
41
27
|
|
|
42
28
|
/**
|
|
@@ -49,7 +35,6 @@ export const getDynamicOffers = async ({
|
|
|
49
35
|
tags,
|
|
50
36
|
defaultProductType,
|
|
51
37
|
productTypes,
|
|
52
|
-
resultType,
|
|
53
38
|
isCachedOffersRequest,
|
|
54
39
|
productTypesDefinition,
|
|
55
40
|
partnersOverrideDefinition,
|
|
@@ -89,18 +74,19 @@ export const getDynamicOffers = async ({
|
|
|
89
74
|
errorCode = fallbackResult.errorCode;
|
|
90
75
|
}
|
|
91
76
|
|
|
92
|
-
const sortedOffers =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
77
|
+
const sortedOffers = sortOffersByRecommendationScore(offers);
|
|
78
|
+
const formattedOffers = formatOfferUrl(
|
|
79
|
+
productTypesDefinition,
|
|
80
|
+
partnersOverrideDefinition
|
|
81
|
+
)(sortedOffers);
|
|
82
|
+
const offersWithTags = addClientTagsToOfferLinks(
|
|
83
|
+
isCachedOffersRequest,
|
|
84
|
+
tags
|
|
85
|
+
)(formattedOffers);
|
|
86
|
+
const finalOffers = sortOffersByRecommendationScore(offersWithTags);
|
|
96
87
|
|
|
97
88
|
return {
|
|
98
|
-
offers:
|
|
99
|
-
sortedOffers,
|
|
100
|
-
formatOfferUrl(productTypesDefinition, partnersOverrideDefinition),
|
|
101
|
-
addClientTagsToOfferLinks(isCachedOffersRequest, tags),
|
|
102
|
-
sortOffersByRecommendationScore
|
|
103
|
-
),
|
|
89
|
+
offers: finalOffers,
|
|
104
90
|
isError,
|
|
105
91
|
errorCode,
|
|
106
92
|
leadUuid: leadUuid,
|
|
@@ -1,26 +1,19 @@
|
|
|
1
|
-
import type { InternalOnErrorCallback } from "../capabilities/errors/types";
|
|
2
|
-
import { getProductTypesByQuery } from "./getProductTypesByQuery";
|
|
3
|
-
|
|
4
1
|
export type GetProductTypesProps = {
|
|
5
2
|
productType?: string;
|
|
6
|
-
query?: string;
|
|
7
3
|
defaultProductType: string;
|
|
8
|
-
searchAPIToken: string;
|
|
9
|
-
isDev: boolean;
|
|
10
|
-
onError?: InternalOnErrorCallback;
|
|
11
4
|
};
|
|
12
5
|
|
|
13
|
-
export type ResultType = "STATIC" | "
|
|
6
|
+
export type ResultType = "STATIC" | "PRODUCT_TYPE" | "DEFAULT";
|
|
14
7
|
|
|
15
8
|
export type ProductTypesResult = {
|
|
16
9
|
productTypes: string[];
|
|
17
10
|
resultType: ResultType;
|
|
18
11
|
};
|
|
19
12
|
|
|
20
|
-
const parseProductTypes = (
|
|
21
|
-
return
|
|
22
|
-
?
|
|
23
|
-
: [
|
|
13
|
+
const parseProductTypes = (productType: string): string[] => {
|
|
14
|
+
return productType.includes(",")
|
|
15
|
+
? productType.split(",").map((productTypeSlug) => productTypeSlug.trim())
|
|
16
|
+
: [productType];
|
|
24
17
|
};
|
|
25
18
|
|
|
26
19
|
/**
|
|
@@ -31,23 +24,7 @@ const parseProductTypes = (query: string): string[] => {
|
|
|
31
24
|
export const getProductTypes = async ({
|
|
32
25
|
productType,
|
|
33
26
|
defaultProductType,
|
|
34
|
-
query,
|
|
35
|
-
searchAPIToken,
|
|
36
|
-
isDev,
|
|
37
|
-
onError,
|
|
38
27
|
}: GetProductTypesProps): Promise<ProductTypesResult> => {
|
|
39
|
-
if (query && query.trim().length > 0) {
|
|
40
|
-
const productTypes = await getProductTypesByQuery({
|
|
41
|
-
query,
|
|
42
|
-
searchAPIToken,
|
|
43
|
-
isDev,
|
|
44
|
-
onError,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
return { productTypes, resultType: "QUERY" };
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// TODO: Check if need to add support for productType as enf app
|
|
51
28
|
if (productType && productType.trim().length > 0) {
|
|
52
29
|
const productTypes = await parseProductTypes(productType);
|
|
53
30
|
return { productTypes, resultType: "PRODUCT_TYPE" };
|
package/src/utils/index.ts
CHANGED
|
@@ -3,7 +3,6 @@ export * from "./getDefaultProductType";
|
|
|
3
3
|
export * from "./getOffersByProductTypes";
|
|
4
4
|
export * from "./getProductTypesDefinition";
|
|
5
5
|
export * from "./resolveProductTypes";
|
|
6
|
-
export * from "./selectDynamicOffers";
|
|
7
6
|
export * from "./sortOffersByRecommendationScore";
|
|
8
7
|
export * from "./parseStringProductTypes";
|
|
9
8
|
export * from "./getEnableUseCachedOffers";
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import type { InternalOnErrorCallback } from "../capabilities/errors/types";
|
|
2
1
|
import { getProductTypes, type ResultType } from "../services/getProductTypes";
|
|
3
2
|
|
|
4
3
|
type ResolveProductTypesProps = {
|
|
5
4
|
productType?: string;
|
|
6
|
-
query?: string;
|
|
7
5
|
defaultProductType: string;
|
|
8
|
-
searchAPIToken: string;
|
|
9
|
-
isDev: boolean;
|
|
10
|
-
onError?: InternalOnErrorCallback;
|
|
11
6
|
};
|
|
12
7
|
|
|
13
8
|
export const resolveProductTypes = async (
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Version is kept in sync with package.json via the sync-version script
|
|
2
|
-
export const VERSION = "1.
|
|
2
|
+
export const VERSION = "1.10.0";
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _orderProductTypesByRankUtils = require("./orderProductTypesByRankUtils");
|
|
7
|
-
Object.keys(_orderProductTypesByRankUtils).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _orderProductTypesByRankUtils[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _orderProductTypesByRankUtils[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_orderProductTypesByRankUtils","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sourceRoot":"../../../../../../../src","sources":["capabilities/core/src/domain/third-party-search/index.ts"],"mappings":";;;;;AAAA,IAAAA,6BAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,6BAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,6BAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,6BAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
package/lib/commonjs/capabilities/core/src/domain/third-party-search/orderProductTypesByRankUtils.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.orderProductTypesByRank = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Orders product types by rank.
|
|
9
|
-
*
|
|
10
|
-
* @param productTypes {Record<string, number>} - The product types to order.
|
|
11
|
-
* @returns {string[]} The product types ordered by rank.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* const productTypes = {
|
|
16
|
-
* 'credit-card': 1,
|
|
17
|
-
* 'loan': 2,
|
|
18
|
-
* 'insurance': 3,
|
|
19
|
-
* }
|
|
20
|
-
* const orderedProductTypes = orderProductTypesByRank(productTypes)
|
|
21
|
-
* // orderedProductTypes = ['insurance', 'loan', 'credit-card']
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
const orderProductTypesByRank = productTypes => {
|
|
25
|
-
const productTypesWithRank = Object.entries(productTypes).map(([productType, count]) => ({
|
|
26
|
-
productType,
|
|
27
|
-
rank: count
|
|
28
|
-
}));
|
|
29
|
-
const sortedProductTypes = productTypesWithRank.sort((a, b) => b.rank - a.rank);
|
|
30
|
-
return sortedProductTypes.map(pt => pt.productType);
|
|
31
|
-
};
|
|
32
|
-
exports.orderProductTypesByRank = orderProductTypesByRank;
|
|
33
|
-
//# sourceMappingURL=orderProductTypesByRankUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["orderProductTypesByRank","productTypes","productTypesWithRank","Object","entries","map","productType","count","rank","sortedProductTypes","sort","a","b","pt","exports"],"sourceRoot":"../../../../../../../src","sources":["capabilities/core/src/domain/third-party-search/orderProductTypesByRankUtils.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,uBAAuB,GACnCC,YAAoC,IAChC;EACJ,MAAMC,oBAAoB,GAAGC,MAAM,CAACC,OAAO,CAACH,YAAY,CAAC,CAACI,GAAG,CAC5D,CAAC,CAACC,WAAW,EAAEC,KAAK,CAAC,MAAM;IAC1BD,WAAW;IACXE,IAAI,EAAED;EACP,CAAC,CACF,CAAC;EAED,MAAME,kBAAkB,GAAGP,oBAAoB,CAACQ,IAAI,CACnD,CAACC,CAAC,EAAEC,CAAC,KAAKA,CAAC,CAACJ,IAAI,GAAGG,CAAC,CAACH,IACtB,CAAC;EAED,OAAOC,kBAAkB,CAACJ,GAAG,CAAEQ,EAAE,IAAKA,EAAE,CAACP,WAAW,CAAC;AACtD,CAAC;AAACQ,OAAA,CAAAd,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getProductTypesByQuery = void 0;
|
|
7
|
-
var _effect = require("effect");
|
|
8
|
-
var _apiEnvironment = require("../apiEnvironment");
|
|
9
|
-
var _thirdPartySearch = require("../capabilities/core/src/domain/third-party-search");
|
|
10
|
-
var _types = require("../capabilities/errors/types");
|
|
11
|
-
var _errorUtils = require("../components/utils/errorUtils");
|
|
12
|
-
/**
|
|
13
|
-
* Get product types by query
|
|
14
|
-
* @param query {string} - The query to get the product types for
|
|
15
|
-
* @param context The context to get the product types from
|
|
16
|
-
* @returns {Promise<string[]>} The product types
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* const productTypes = await getProductTypesByQuery('best credit cards', {
|
|
21
|
-
* cnfEnv: {
|
|
22
|
-
* THIRD_PARTY_SEARCH_API_URL: 'https://api.third-party-search.com',
|
|
23
|
-
* THIRD_PARTY_SEARCH_API_TOKEN: 'your-token',
|
|
24
|
-
* },
|
|
25
|
-
* thirdPartySearchApiClient: makeThirdPartySearchApiClient,
|
|
26
|
-
* })
|
|
27
|
-
* // productTypes = ['credit-card', 'loan', 'insurance']
|
|
28
|
-
* or
|
|
29
|
-
* // productTypes = []
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
const getProductTypesByQuery = async ({
|
|
34
|
-
query,
|
|
35
|
-
searchAPIToken,
|
|
36
|
-
isDev,
|
|
37
|
-
onError
|
|
38
|
-
}) => {
|
|
39
|
-
const url = `${(0, _apiEnvironment.getEwsSearchApiBaseUrl)(isDev)}/search/product-types?query=${encodeURIComponent(query)}`;
|
|
40
|
-
const headers = {
|
|
41
|
-
Authorization: `Bearer ${searchAPIToken}`
|
|
42
|
-
};
|
|
43
|
-
try {
|
|
44
|
-
const response = await fetch(url, {
|
|
45
|
-
headers
|
|
46
|
-
});
|
|
47
|
-
if (!response.ok) {
|
|
48
|
-
const error = new Error();
|
|
49
|
-
error.code = response.status;
|
|
50
|
-
throw error;
|
|
51
|
-
}
|
|
52
|
-
const productTypes = await response.json();
|
|
53
|
-
return (0, _effect.pipe)(productTypes, _thirdPartySearch.orderProductTypesByRank);
|
|
54
|
-
} catch (error) {
|
|
55
|
-
console.error("Error fetching ProductTypesByQuery", JSON.stringify(error));
|
|
56
|
-
onError === null || onError === void 0 || onError({
|
|
57
|
-
message: "Failed to fetch product types by query",
|
|
58
|
-
error,
|
|
59
|
-
additionalInfo: {
|
|
60
|
-
query,
|
|
61
|
-
isDev
|
|
62
|
-
},
|
|
63
|
-
...((0, _errorUtils.getApiErrorLogProperties)(error) || {
|
|
64
|
-
code: _types.ErrorCodes.FLOW_ERROR,
|
|
65
|
-
severity: "error"
|
|
66
|
-
})
|
|
67
|
-
});
|
|
68
|
-
return [];
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
exports.getProductTypesByQuery = getProductTypesByQuery;
|
|
72
|
-
//# sourceMappingURL=getProductTypesByQuery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_effect","require","_apiEnvironment","_thirdPartySearch","_types","_errorUtils","getProductTypesByQuery","query","searchAPIToken","isDev","onError","url","getEwsSearchApiBaseUrl","encodeURIComponent","headers","Authorization","response","fetch","ok","error","Error","code","status","productTypes","json","pipe","orderProductTypesByRank","console","JSON","stringify","message","additionalInfo","getApiErrorLogProperties","ErrorCodes","FLOW_ERROR","severity","exports"],"sourceRoot":"../../../src","sources":["services/getProductTypesByQuery.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAKA,IAAAI,WAAA,GAAAJ,OAAA;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,MAAMK,sBAAsB,GAAG,MAAAA,CAAO;EAC5CC,KAAK;EACLC,cAAc;EACdC,KAAK;EACLC;AAC4B,CAAC,KAAK;EAClC,MAAMC,GAAG,GAAG,GAAG,IAAAC,sCAAsB,EAACH,KAAK,CAAC,+BAA+BI,kBAAkB,CAACN,KAAK,CAAC,EAAE;EACtG,MAAMO,OAAO,GAAG;IACfC,aAAa,EAAE,UAAUP,cAAc;EACxC,CAAC;EACD,IAAI;IACH,MAAMQ,QAAQ,GAAG,MAAMC,KAAK,CAACN,GAAG,EAAE;MAAEG;IAAQ,CAAC,CAAC;IAC9C,IAAI,CAACE,QAAQ,CAACE,EAAE,EAAE;MACjB,MAAMC,KAAK,GAAG,IAAIC,KAAK,CAAC,CAAa;MACrCD,KAAK,CAACE,IAAI,GAAGL,QAAQ,CAACM,MAAM;MAC5B,MAAMH,KAAK;IACZ;IACA,MAAMI,YAAY,GAAG,MAAMP,QAAQ,CAACQ,IAAI,CAAC,CAAC;IAE1C,OAAO,IAAAC,YAAI,EAACF,YAAY,EAAEG,yCAAuB,CAAC;EACnD,CAAC,CAAC,OAAOP,KAAK,EAAE;IACfQ,OAAO,CAACR,KAAK,CAAC,oCAAoC,EAAES,IAAI,CAACC,SAAS,CAACV,KAAK,CAAC,CAAC;IAC1ET,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAG;MACToB,OAAO,EAAE,wCAAwC;MACjDX,KAAK;MACLY,cAAc,EAAE;QACfxB,KAAK;QACLE;MACD,CAAC;MACD,IAAI,IAAAuB,oCAAwB,EAACb,KAAK,CAAC,IAAI;QACtCE,IAAI,EAAEY,iBAAU,CAACC,UAAU;QAC3BC,QAAQ,EAAE;MACX,CAAC;IACF,CAAC,CAAC;IAEF,OAAO,EAAE;EACV;AACD,CAAC;AAACC,OAAA,CAAA9B,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.selectDynamicOffers = void 0;
|
|
7
|
-
var _sortOffersByRecommendationScore = require("./sortOffersByRecommendationScore");
|
|
8
|
-
const selectDynamicOffers = (offers, productTypes) => {
|
|
9
|
-
const resultOffers = productTypes.flatMap(productType => (0, _sortOffersByRecommendationScore.sortOffersByRecommendationScore)(offers.filter(offer => offer.productType === productType))).slice(0, 10);
|
|
10
|
-
return resultOffers;
|
|
11
|
-
};
|
|
12
|
-
exports.selectDynamicOffers = selectDynamicOffers;
|
|
13
|
-
//# sourceMappingURL=selectDynamicOffers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_sortOffersByRecommendationScore","require","selectDynamicOffers","offers","productTypes","resultOffers","flatMap","productType","sortOffersByRecommendationScore","filter","offer","slice","exports"],"sourceRoot":"../../../src","sources":["utils/selectDynamicOffers.ts"],"mappings":";;;;;;AACA,IAAAA,gCAAA,GAAAC,OAAA;AAEO,MAAMC,mBAAmB,GAAGA,CAClCC,MAAmB,EACnBC,YAAsB,KAClB;EACJ,MAAMC,YAAY,GAAGD,YAAY,CAC/BE,OAAO,CAAEC,WAAW,IACpB,IAAAC,gEAA+B,EAC9BL,MAAM,CAACM,MAAM,CAAEC,KAAK,IAAKA,KAAK,CAACH,WAAW,KAAKA,WAAW,CAC3D,CACD,CAAC,CACAI,KAAK,CAAC,CAAC,EAAE,EAAE,CAAgB;EAE7B,OAAON,YAAY;AACpB,CAAC;AAACO,OAAA,CAAAV,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../../../../../src","sources":["capabilities/core/src/domain/third-party-search/index.ts"],"mappings":"AAAA,cAAc,gCAAgC","ignoreList":[]}
|
package/lib/module/capabilities/core/src/domain/third-party-search/orderProductTypesByRankUtils.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Orders product types by rank.
|
|
3
|
-
*
|
|
4
|
-
* @param productTypes {Record<string, number>} - The product types to order.
|
|
5
|
-
* @returns {string[]} The product types ordered by rank.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* const productTypes = {
|
|
10
|
-
* 'credit-card': 1,
|
|
11
|
-
* 'loan': 2,
|
|
12
|
-
* 'insurance': 3,
|
|
13
|
-
* }
|
|
14
|
-
* const orderedProductTypes = orderProductTypesByRank(productTypes)
|
|
15
|
-
* // orderedProductTypes = ['insurance', 'loan', 'credit-card']
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export const orderProductTypesByRank = productTypes => {
|
|
19
|
-
const productTypesWithRank = Object.entries(productTypes).map(([productType, count]) => ({
|
|
20
|
-
productType,
|
|
21
|
-
rank: count
|
|
22
|
-
}));
|
|
23
|
-
const sortedProductTypes = productTypesWithRank.sort((a, b) => b.rank - a.rank);
|
|
24
|
-
return sortedProductTypes.map(pt => pt.productType);
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=orderProductTypesByRankUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["orderProductTypesByRank","productTypes","productTypesWithRank","Object","entries","map","productType","count","rank","sortedProductTypes","sort","a","b","pt"],"sourceRoot":"../../../../../../../src","sources":["capabilities/core/src/domain/third-party-search/orderProductTypesByRankUtils.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,uBAAuB,GACnCC,YAAoC,IAChC;EACJ,MAAMC,oBAAoB,GAAGC,MAAM,CAACC,OAAO,CAACH,YAAY,CAAC,CAACI,GAAG,CAC5D,CAAC,CAACC,WAAW,EAAEC,KAAK,CAAC,MAAM;IAC1BD,WAAW;IACXE,IAAI,EAAED;EACP,CAAC,CACF,CAAC;EAED,MAAME,kBAAkB,GAAGP,oBAAoB,CAACQ,IAAI,CACnD,CAACC,CAAC,EAAEC,CAAC,KAAKA,CAAC,CAACJ,IAAI,GAAGG,CAAC,CAACH,IACtB,CAAC;EAED,OAAOC,kBAAkB,CAACJ,GAAG,CAAEQ,EAAE,IAAKA,EAAE,CAACP,WAAW,CAAC;AACtD,CAAC","ignoreList":[]}
|