@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.
Files changed (169) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/lib/commonjs/apiEnvironment.js +1 -7
  3. package/lib/commonjs/apiEnvironment.js.map +1 -1
  4. package/lib/commonjs/capabilities/core/src/system/cnfContext/CnfContext.js +0 -12
  5. package/lib/commonjs/capabilities/core/src/system/cnfContext/CnfContext.js.map +1 -1
  6. package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/App.js +0 -16
  7. package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/App.js.map +1 -1
  8. package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Brand.js +0 -120
  9. package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Brand.js.map +1 -1
  10. package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Configuration.js +0 -39
  11. package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Configuration.js.map +1 -1
  12. package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Request.js +0 -19
  13. package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Request.js.map +1 -1
  14. package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Session.js +0 -10
  15. package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Session.js.map +1 -1
  16. package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Signals.js +0 -39
  17. package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Signals.js.map +1 -1
  18. package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Subaccount.js +0 -24
  19. package/lib/commonjs/capabilities/core/src/system/cnfContext/schemas/Subaccount.js.map +1 -1
  20. package/lib/commonjs/capabilities/errors/types/index.js +22 -1
  21. package/lib/commonjs/capabilities/errors/types/index.js.map +1 -1
  22. package/lib/commonjs/capabilities/offer-catalog/src/api/offerCatalogApi.js +3 -3
  23. package/lib/commonjs/capabilities/offer-catalog/src/api/offerCatalogApi.js.map +1 -1
  24. package/lib/commonjs/components/MoneyLionOfferCarousel.js +16 -13
  25. package/lib/commonjs/components/MoneyLionOfferCarousel.js.map +1 -1
  26. package/lib/commonjs/components/utils/errorUtils.js +2 -2
  27. package/lib/commonjs/components/utils/errorUtils.js.map +1 -1
  28. package/lib/commonjs/index.js +11 -0
  29. package/lib/commonjs/index.js.map +1 -1
  30. package/lib/commonjs/pageData.js +1 -12
  31. package/lib/commonjs/pageData.js.map +1 -1
  32. package/lib/commonjs/services/getDynamicOffers.js +5 -4
  33. package/lib/commonjs/services/getDynamicOffers.js.map +1 -1
  34. package/lib/commonjs/services/getProductTypes.js +3 -22
  35. package/lib/commonjs/services/getProductTypes.js.map +1 -1
  36. package/lib/commonjs/utils/index.js +0 -11
  37. package/lib/commonjs/utils/index.js.map +1 -1
  38. package/lib/commonjs/utils/resolveProductTypes.js.map +1 -1
  39. package/lib/commonjs/version.js +1 -1
  40. package/lib/commonjs/version.js.map +1 -1
  41. package/lib/module/apiEnvironment.js +0 -5
  42. package/lib/module/apiEnvironment.js.map +1 -1
  43. package/lib/module/capabilities/core/src/system/cnfContext/CnfContext.js +1 -11
  44. package/lib/module/capabilities/core/src/system/cnfContext/CnfContext.js.map +1 -1
  45. package/lib/module/capabilities/core/src/system/cnfContext/schemas/App.js +1 -11
  46. package/lib/module/capabilities/core/src/system/cnfContext/schemas/App.js.map +1 -1
  47. package/lib/module/capabilities/core/src/system/cnfContext/schemas/Brand.js +1 -115
  48. package/lib/module/capabilities/core/src/system/cnfContext/schemas/Brand.js.map +1 -1
  49. package/lib/module/capabilities/core/src/system/cnfContext/schemas/Configuration.js +1 -34
  50. package/lib/module/capabilities/core/src/system/cnfContext/schemas/Configuration.js.map +1 -1
  51. package/lib/module/capabilities/core/src/system/cnfContext/schemas/Request.js +1 -14
  52. package/lib/module/capabilities/core/src/system/cnfContext/schemas/Request.js.map +1 -1
  53. package/lib/module/capabilities/core/src/system/cnfContext/schemas/Session.js +1 -5
  54. package/lib/module/capabilities/core/src/system/cnfContext/schemas/Session.js.map +1 -1
  55. package/lib/module/capabilities/core/src/system/cnfContext/schemas/Signals.js +1 -34
  56. package/lib/module/capabilities/core/src/system/cnfContext/schemas/Signals.js.map +1 -1
  57. package/lib/module/capabilities/core/src/system/cnfContext/schemas/Subaccount.js +1 -19
  58. package/lib/module/capabilities/core/src/system/cnfContext/schemas/Subaccount.js.map +1 -1
  59. package/lib/module/capabilities/errors/types/index.js +21 -0
  60. package/lib/module/capabilities/errors/types/index.js.map +1 -1
  61. package/lib/module/capabilities/offer-catalog/src/api/offerCatalogApi.js +4 -4
  62. package/lib/module/capabilities/offer-catalog/src/api/offerCatalogApi.js.map +1 -1
  63. package/lib/module/components/MoneyLionOfferCarousel.js +17 -14
  64. package/lib/module/components/MoneyLionOfferCarousel.js.map +1 -1
  65. package/lib/module/components/utils/errorUtils.js +3 -3
  66. package/lib/module/components/utils/errorUtils.js.map +1 -1
  67. package/lib/module/index.js +1 -0
  68. package/lib/module/index.js.map +1 -1
  69. package/lib/module/pageData.js +1 -11
  70. package/lib/module/pageData.js.map +1 -1
  71. package/lib/module/services/getDynamicOffers.js +6 -5
  72. package/lib/module/services/getDynamicOffers.js.map +1 -1
  73. package/lib/module/services/getProductTypes.js +3 -22
  74. package/lib/module/services/getProductTypes.js.map +1 -1
  75. package/lib/module/utils/index.js +0 -1
  76. package/lib/module/utils/index.js.map +1 -1
  77. package/lib/module/utils/resolveProductTypes.js.map +1 -1
  78. package/lib/module/version.js +1 -1
  79. package/lib/module/version.js.map +1 -1
  80. package/lib/typescript/src/apiEnvironment.d.ts +0 -4
  81. package/lib/typescript/src/apiEnvironment.d.ts.map +1 -1
  82. package/lib/typescript/src/capabilities/core/src/system/cnfContext/CnfContext.d.ts +15 -102
  83. package/lib/typescript/src/capabilities/core/src/system/cnfContext/CnfContext.d.ts.map +1 -1
  84. package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/App.d.ts +10 -12
  85. package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/App.d.ts.map +1 -1
  86. package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Brand.d.ts +101 -472
  87. package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Brand.d.ts.map +1 -1
  88. package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Configuration.d.ts +24 -58
  89. package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Configuration.d.ts.map +1 -1
  90. package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Request.d.ts +11 -15
  91. package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Request.d.ts.map +1 -1
  92. package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Session.d.ts +4 -7
  93. package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Session.d.ts.map +1 -1
  94. package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Signals.d.ts +30 -63
  95. package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Signals.d.ts.map +1 -1
  96. package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Subaccount.d.ts +17 -17
  97. package/lib/typescript/src/capabilities/core/src/system/cnfContext/schemas/Subaccount.d.ts.map +1 -1
  98. package/lib/typescript/src/capabilities/errors/types/index.d.ts +18 -2
  99. package/lib/typescript/src/capabilities/errors/types/index.d.ts.map +1 -1
  100. package/lib/typescript/src/capabilities/offer-catalog/src/utils/contextUtil.d.ts +1 -1
  101. package/lib/typescript/src/capabilities/offer-catalog/src/utils/contextUtil.d.ts.map +1 -1
  102. package/lib/typescript/src/capabilities/offers/pipeline/src/sources/ratetables/withDeviceSignals.d.ts +11 -11
  103. package/lib/typescript/src/components/MoneyLionOfferCarousel.d.ts +0 -2
  104. package/lib/typescript/src/components/MoneyLionOfferCarousel.d.ts.map +1 -1
  105. package/lib/typescript/src/index.d.ts +1 -0
  106. package/lib/typescript/src/index.d.ts.map +1 -1
  107. package/lib/typescript/src/pageData.d.ts +0 -2
  108. package/lib/typescript/src/pageData.d.ts.map +1 -1
  109. package/lib/typescript/src/services/getDynamicOffers.d.ts +3 -4
  110. package/lib/typescript/src/services/getDynamicOffers.d.ts.map +1 -1
  111. package/lib/typescript/src/services/getProductTypes.d.ts +2 -7
  112. package/lib/typescript/src/services/getProductTypes.d.ts.map +1 -1
  113. package/lib/typescript/src/utils/getOffersByProductTypes.d.ts +1 -1
  114. package/lib/typescript/src/utils/getProductTypesDefinition.d.ts +8 -8
  115. package/lib/typescript/src/utils/index.d.ts +0 -1
  116. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  117. package/lib/typescript/src/utils/resolveProductTypes.d.ts +0 -5
  118. package/lib/typescript/src/utils/resolveProductTypes.d.ts.map +1 -1
  119. package/lib/typescript/src/version.d.ts +1 -1
  120. package/lib/typescript/src/version.d.ts.map +1 -1
  121. package/package.json +2 -12
  122. package/src/apiEnvironment.ts +0 -6
  123. package/src/capabilities/core/src/system/cnfContext/CnfContext.ts +15 -20
  124. package/src/capabilities/core/src/system/cnfContext/schemas/App.ts +10 -13
  125. package/src/capabilities/core/src/system/cnfContext/schemas/Brand.ts +108 -148
  126. package/src/capabilities/core/src/system/cnfContext/schemas/Configuration.ts +21 -46
  127. package/src/capabilities/core/src/system/cnfContext/schemas/Request.ts +11 -16
  128. package/src/capabilities/core/src/system/cnfContext/schemas/Session.ts +4 -8
  129. package/src/capabilities/core/src/system/cnfContext/schemas/Signals.ts +30 -41
  130. package/src/capabilities/core/src/system/cnfContext/schemas/Subaccount.ts +16 -24
  131. package/src/capabilities/errors/types/index.ts +30 -1
  132. package/src/capabilities/offer-catalog/src/api/offerCatalogApi.ts +4 -4
  133. package/src/components/MoneyLionOfferCarousel.tsx +16 -17
  134. package/src/components/utils/errorUtils.ts +3 -3
  135. package/src/index.tsx +4 -0
  136. package/src/pageData.ts +2 -20
  137. package/src/services/getDynamicOffers.ts +14 -28
  138. package/src/services/getProductTypes.ts +5 -28
  139. package/src/utils/index.ts +0 -1
  140. package/src/utils/resolveProductTypes.ts +0 -5
  141. package/src/version.ts +1 -1
  142. package/lib/commonjs/capabilities/core/src/domain/third-party-search/index.js +0 -17
  143. package/lib/commonjs/capabilities/core/src/domain/third-party-search/index.js.map +0 -1
  144. package/lib/commonjs/capabilities/core/src/domain/third-party-search/orderProductTypesByRankUtils.js +0 -33
  145. package/lib/commonjs/capabilities/core/src/domain/third-party-search/orderProductTypesByRankUtils.js.map +0 -1
  146. package/lib/commonjs/services/getProductTypesByQuery.js +0 -72
  147. package/lib/commonjs/services/getProductTypesByQuery.js.map +0 -1
  148. package/lib/commonjs/utils/selectDynamicOffers.js +0 -13
  149. package/lib/commonjs/utils/selectDynamicOffers.js.map +0 -1
  150. package/lib/module/capabilities/core/src/domain/third-party-search/index.js +0 -2
  151. package/lib/module/capabilities/core/src/domain/third-party-search/index.js.map +0 -1
  152. package/lib/module/capabilities/core/src/domain/third-party-search/orderProductTypesByRankUtils.js +0 -26
  153. package/lib/module/capabilities/core/src/domain/third-party-search/orderProductTypesByRankUtils.js.map +0 -1
  154. package/lib/module/services/getProductTypesByQuery.js +0 -65
  155. package/lib/module/services/getProductTypesByQuery.js.map +0 -1
  156. package/lib/module/utils/selectDynamicOffers.js +0 -6
  157. package/lib/module/utils/selectDynamicOffers.js.map +0 -1
  158. package/lib/typescript/src/capabilities/core/src/domain/third-party-search/index.d.ts +0 -2
  159. package/lib/typescript/src/capabilities/core/src/domain/third-party-search/index.d.ts.map +0 -1
  160. package/lib/typescript/src/capabilities/core/src/domain/third-party-search/orderProductTypesByRankUtils.d.ts +0 -19
  161. package/lib/typescript/src/capabilities/core/src/domain/third-party-search/orderProductTypesByRankUtils.d.ts.map +0 -1
  162. package/lib/typescript/src/services/getProductTypesByQuery.d.ts +0 -30
  163. package/lib/typescript/src/services/getProductTypesByQuery.d.ts.map +0 -1
  164. package/lib/typescript/src/utils/selectDynamicOffers.d.ts +0 -3
  165. package/lib/typescript/src/utils/selectDynamicOffers.d.ts.map +0 -1
  166. package/src/capabilities/core/src/domain/third-party-search/index.ts +0 -1
  167. package/src/capabilities/core/src/domain/third-party-search/orderProductTypesByRankUtils.ts +0 -33
  168. package/src/services/getProductTypesByQuery.ts +0 -76
  169. package/src/utils/selectDynamicOffers.ts +0 -17
@@ -1,65 +0,0 @@
1
- import { pipe } from "effect";
2
- import { getEwsSearchApiBaseUrl } from "../apiEnvironment";
3
- import { orderProductTypesByRank } from "../capabilities/core/src/domain/third-party-search";
4
- import { ErrorCodes } from "../capabilities/errors/types";
5
- import { getApiErrorLogProperties } from "../components/utils/errorUtils";
6
- /**
7
- * Get product types by query
8
- * @param query {string} - The query to get the product types for
9
- * @param context The context to get the product types from
10
- * @returns {Promise<string[]>} The product types
11
- *
12
- * @example
13
- * ```ts
14
- * const productTypes = await getProductTypesByQuery('best credit cards', {
15
- * cnfEnv: {
16
- * THIRD_PARTY_SEARCH_API_URL: 'https://api.third-party-search.com',
17
- * THIRD_PARTY_SEARCH_API_TOKEN: 'your-token',
18
- * },
19
- * thirdPartySearchApiClient: makeThirdPartySearchApiClient,
20
- * })
21
- * // productTypes = ['credit-card', 'loan', 'insurance']
22
- * or
23
- * // productTypes = []
24
- * ```
25
- */
26
-
27
- export const getProductTypesByQuery = async ({
28
- query,
29
- searchAPIToken,
30
- isDev,
31
- onError
32
- }) => {
33
- const url = `${getEwsSearchApiBaseUrl(isDev)}/search/product-types?query=${encodeURIComponent(query)}`;
34
- const headers = {
35
- Authorization: `Bearer ${searchAPIToken}`
36
- };
37
- try {
38
- const response = await fetch(url, {
39
- headers
40
- });
41
- if (!response.ok) {
42
- const error = new Error();
43
- error.code = response.status;
44
- throw error;
45
- }
46
- const productTypes = await response.json();
47
- return pipe(productTypes, orderProductTypesByRank);
48
- } catch (error) {
49
- console.error("Error fetching ProductTypesByQuery", JSON.stringify(error));
50
- onError === null || onError === void 0 || onError({
51
- message: "Failed to fetch product types by query",
52
- error,
53
- additionalInfo: {
54
- query,
55
- isDev
56
- },
57
- ...(getApiErrorLogProperties(error) || {
58
- code: ErrorCodes.FLOW_ERROR,
59
- severity: "error"
60
- })
61
- });
62
- return [];
63
- }
64
- };
65
- //# sourceMappingURL=getProductTypesByQuery.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["pipe","getEwsSearchApiBaseUrl","orderProductTypesByRank","ErrorCodes","getApiErrorLogProperties","getProductTypesByQuery","query","searchAPIToken","isDev","onError","url","encodeURIComponent","headers","Authorization","response","fetch","ok","error","Error","code","status","productTypes","json","console","JSON","stringify","message","additionalInfo","FLOW_ERROR","severity"],"sourceRoot":"../../../src","sources":["services/getProductTypesByQuery.ts"],"mappings":"AAAA,SAASA,IAAI,QAAQ,QAAQ;AAC7B,SAASC,sBAAsB,QAAQ,mBAAmB;AAC1D,SAASC,uBAAuB,QAAQ,oDAAoD;AAC5F,SACCC,UAAU,QAGJ,8BAA8B;AACrC,SAASC,wBAAwB,QAAQ,gCAAgC;AASzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,sBAAsB,GAAG,MAAAA,CAAO;EAC5CC,KAAK;EACLC,cAAc;EACdC,KAAK;EACLC;AAC4B,CAAC,KAAK;EAClC,MAAMC,GAAG,GAAG,GAAGT,sBAAsB,CAACO,KAAK,CAAC,+BAA+BG,kBAAkB,CAACL,KAAK,CAAC,EAAE;EACtG,MAAMM,OAAO,GAAG;IACfC,aAAa,EAAE,UAAUN,cAAc;EACxC,CAAC;EACD,IAAI;IACH,MAAMO,QAAQ,GAAG,MAAMC,KAAK,CAACL,GAAG,EAAE;MAAEE;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,OAAOtB,IAAI,CAACqB,YAAY,EAAEnB,uBAAuB,CAAC;EACnD,CAAC,CAAC,OAAOe,KAAK,EAAE;IACfM,OAAO,CAACN,KAAK,CAAC,oCAAoC,EAAEO,IAAI,CAACC,SAAS,CAACR,KAAK,CAAC,CAAC;IAC1ER,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAG;MACTiB,OAAO,EAAE,wCAAwC;MACjDT,KAAK;MACLU,cAAc,EAAE;QACfrB,KAAK;QACLE;MACD,CAAC;MACD,IAAIJ,wBAAwB,CAACa,KAAK,CAAC,IAAI;QACtCE,IAAI,EAAEhB,UAAU,CAACyB,UAAU;QAC3BC,QAAQ,EAAE;MACX,CAAC;IACF,CAAC,CAAC;IAEF,OAAO,EAAE;EACV;AACD,CAAC","ignoreList":[]}
@@ -1,6 +0,0 @@
1
- import { sortOffersByRecommendationScore } from "./sortOffersByRecommendationScore";
2
- export const selectDynamicOffers = (offers, productTypes) => {
3
- const resultOffers = productTypes.flatMap(productType => sortOffersByRecommendationScore(offers.filter(offer => offer.productType === productType))).slice(0, 10);
4
- return resultOffers;
5
- };
6
- //# sourceMappingURL=selectDynamicOffers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["sortOffersByRecommendationScore","selectDynamicOffers","offers","productTypes","resultOffers","flatMap","productType","filter","offer","slice"],"sourceRoot":"../../../src","sources":["utils/selectDynamicOffers.ts"],"mappings":"AACA,SAASA,+BAA+B,QAAQ,mCAAmC;AAEnF,OAAO,MAAMC,mBAAmB,GAAGA,CAClCC,MAAmB,EACnBC,YAAsB,KAClB;EACJ,MAAMC,YAAY,GAAGD,YAAY,CAC/BE,OAAO,CAAEC,WAAW,IACpBN,+BAA+B,CAC9BE,MAAM,CAACK,MAAM,CAAEC,KAAK,IAAKA,KAAK,CAACF,WAAW,KAAKA,WAAW,CAC3D,CACD,CAAC,CACAG,KAAK,CAAC,CAAC,EAAE,EAAE,CAAgB;EAE7B,OAAOL,YAAY;AACpB,CAAC","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- export * from "./orderProductTypesByRankUtils";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/capabilities/core/src/domain/third-party-search/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC"}
@@ -1,19 +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 declare const orderProductTypesByRank: (productTypes: Record<string, number>) => string[];
19
- //# sourceMappingURL=orderProductTypesByRankUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"orderProductTypesByRankUtils.d.ts","sourceRoot":"","sources":["../../../../../../../../src/capabilities/core/src/domain/third-party-search/orderProductTypesByRankUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,uBAAuB,GACnC,cAAc,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,aAcpC,CAAC"}
@@ -1,30 +0,0 @@
1
- import { type InternalOnErrorCallback } from "../capabilities/errors/types";
2
- type GetProductTypesByQueryProps = {
3
- query: string;
4
- searchAPIToken: string;
5
- isDev: boolean;
6
- onError?: InternalOnErrorCallback;
7
- };
8
- /**
9
- * Get product types by query
10
- * @param query {string} - The query to get the product types for
11
- * @param context The context to get the product types from
12
- * @returns {Promise<string[]>} The product types
13
- *
14
- * @example
15
- * ```ts
16
- * const productTypes = await getProductTypesByQuery('best credit cards', {
17
- * cnfEnv: {
18
- * THIRD_PARTY_SEARCH_API_URL: 'https://api.third-party-search.com',
19
- * THIRD_PARTY_SEARCH_API_TOKEN: 'your-token',
20
- * },
21
- * thirdPartySearchApiClient: makeThirdPartySearchApiClient,
22
- * })
23
- * // productTypes = ['credit-card', 'loan', 'insurance']
24
- * or
25
- * // productTypes = []
26
- * ```
27
- */
28
- export declare const getProductTypesByQuery: ({ query, searchAPIToken, isDev, onError, }: GetProductTypesByQueryProps) => Promise<string[]>;
29
- export {};
30
- //# sourceMappingURL=getProductTypesByQuery.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getProductTypesByQuery.d.ts","sourceRoot":"","sources":["../../../../src/services/getProductTypesByQuery.ts"],"names":[],"mappings":"AAGA,OAAO,EAGN,KAAK,uBAAuB,EAC5B,MAAM,8BAA8B,CAAC;AAGtC,KAAK,2BAA2B,GAAG;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,uBAAuB,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,eAAO,MAAM,sBAAsB,GAAU,4CAK1C,2BAA2B,sBAgC7B,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { BaseOffer } from "../capabilities/offer-catalog/src";
2
- export declare const selectDynamicOffers: (offers: BaseOffer[], productTypes: string[]) => BaseOffer[];
3
- //# sourceMappingURL=selectDynamicOffers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"selectDynamicOffers.d.ts","sourceRoot":"","sources":["../../../../src/utils/selectDynamicOffers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAGnE,eAAO,MAAM,mBAAmB,GAC/B,QAAQ,SAAS,EAAE,EACnB,cAAc,MAAM,EAAE,gBAWtB,CAAC"}
@@ -1 +0,0 @@
1
- export * from "./orderProductTypesByRankUtils";
@@ -1,33 +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 = (
19
- productTypes: Record<string, number>
20
- ) => {
21
- const productTypesWithRank = Object.entries(productTypes).map(
22
- ([productType, count]) => ({
23
- productType,
24
- rank: count as number,
25
- })
26
- );
27
-
28
- const sortedProductTypes = productTypesWithRank.sort(
29
- (a, b) => b.rank - a.rank
30
- );
31
-
32
- return sortedProductTypes.map((pt) => pt.productType);
33
- };
@@ -1,76 +0,0 @@
1
- import { pipe } from "effect";
2
- import { getEwsSearchApiBaseUrl } from "../apiEnvironment";
3
- import { orderProductTypesByRank } from "../capabilities/core/src/domain/third-party-search";
4
- import {
5
- ErrorCodes,
6
- type ApiError,
7
- type InternalOnErrorCallback,
8
- } from "../capabilities/errors/types";
9
- import { getApiErrorLogProperties } from "../components/utils/errorUtils";
10
-
11
- type GetProductTypesByQueryProps = {
12
- query: string;
13
- searchAPIToken: string;
14
- isDev: boolean;
15
- onError?: InternalOnErrorCallback;
16
- };
17
-
18
- /**
19
- * Get product types by query
20
- * @param query {string} - The query to get the product types for
21
- * @param context The context to get the product types from
22
- * @returns {Promise<string[]>} The product types
23
- *
24
- * @example
25
- * ```ts
26
- * const productTypes = await getProductTypesByQuery('best credit cards', {
27
- * cnfEnv: {
28
- * THIRD_PARTY_SEARCH_API_URL: 'https://api.third-party-search.com',
29
- * THIRD_PARTY_SEARCH_API_TOKEN: 'your-token',
30
- * },
31
- * thirdPartySearchApiClient: makeThirdPartySearchApiClient,
32
- * })
33
- * // productTypes = ['credit-card', 'loan', 'insurance']
34
- * or
35
- * // productTypes = []
36
- * ```
37
- */
38
-
39
- export const getProductTypesByQuery = async ({
40
- query,
41
- searchAPIToken,
42
- isDev,
43
- onError,
44
- }: GetProductTypesByQueryProps) => {
45
- const url = `${getEwsSearchApiBaseUrl(isDev)}/search/product-types?query=${encodeURIComponent(query)}`;
46
- const headers = {
47
- Authorization: `Bearer ${searchAPIToken}`,
48
- };
49
- try {
50
- const response = await fetch(url, { headers });
51
- if (!response.ok) {
52
- const error = new Error() as ApiError;
53
- error.code = response.status;
54
- throw error;
55
- }
56
- const productTypes = await response.json();
57
-
58
- return pipe(productTypes, orderProductTypesByRank);
59
- } catch (error) {
60
- console.error("Error fetching ProductTypesByQuery", JSON.stringify(error));
61
- onError?.({
62
- message: "Failed to fetch product types by query",
63
- error,
64
- additionalInfo: {
65
- query,
66
- isDev,
67
- },
68
- ...(getApiErrorLogProperties(error) || {
69
- code: ErrorCodes.FLOW_ERROR,
70
- severity: "error",
71
- }),
72
- });
73
-
74
- return [];
75
- }
76
- };
@@ -1,17 +0,0 @@
1
- import type { BaseOffer } from "../capabilities/offer-catalog/src";
2
- import { sortOffersByRecommendationScore } from "./sortOffersByRecommendationScore";
3
-
4
- export const selectDynamicOffers = (
5
- offers: BaseOffer[],
6
- productTypes: string[]
7
- ) => {
8
- const resultOffers = productTypes
9
- .flatMap((productType) =>
10
- sortOffersByRecommendationScore(
11
- offers.filter((offer) => offer.productType === productType)
12
- )
13
- )
14
- .slice(0, 10) as BaseOffer[];
15
-
16
- return resultOffers;
17
- };