@mx-cartographer/experiences 9.7.206 → 10.0.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 (259) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/accounts/components/detailsdrawer/Accounts/AccountDetailsChart.d.ts +2 -0
  3. package/dist/accounts/components/detailsdrawer/Accounts/AccountDetailsChart.es.js +39 -23
  4. package/dist/accounts/components/detailsdrawer/Accounts/AccountDetailsChart.es.js.map +1 -1
  5. package/dist/accounts/components/detailsdrawer/Accounts/AccountDetailsHeader.d.ts +3 -1
  6. package/dist/accounts/components/detailsdrawer/Accounts/AccountDetailsHeader.es.js +37 -33
  7. package/dist/accounts/components/detailsdrawer/Accounts/AccountDetailsHeader.es.js.map +1 -1
  8. package/dist/accounts/utils/AccountFields.d.ts +3 -1
  9. package/dist/accounts/utils/AccountFields.es.js +39 -39
  10. package/dist/accounts/utils/AccountFields.es.js.map +1 -1
  11. package/dist/common/components/charts/LineChart.d.ts +4 -0
  12. package/dist/common/components/charts/LineChart.es.js +114 -112
  13. package/dist/common/components/charts/LineChart.es.js.map +1 -1
  14. package/dist/common/components/charts/linechart/CustomLegend.es.js +24 -21
  15. package/dist/common/components/charts/linechart/CustomLegend.es.js.map +1 -1
  16. package/dist/core/types/Insights.d.ts +9 -1
  17. package/dist/core/types/Insights.es.js.map +1 -1
  18. package/dist/core/types/localization/InsightsFeedCopy.d.ts +42 -0
  19. package/dist/core/types/localization/index.d.ts +1 -1
  20. package/dist/insights-v2/actionBlocks/AccountDetailsBlock/AccountDetailsBlock.d.ts +7 -1
  21. package/dist/insights-v2/actionBlocks/AccountDetailsBlock/AccountDetailsBlock.es.js +39 -20
  22. package/dist/insights-v2/actionBlocks/AccountDetailsBlock/AccountDetailsBlock.es.js.map +1 -1
  23. package/dist/insights-v2/actionBlocks/AccountDetailsBlock/SpendVsIncomeChart.d.ts +4 -0
  24. package/dist/insights-v2/actionBlocks/AccountDetailsBlock/SpendVsIncomeChart.es.js +42 -0
  25. package/dist/insights-v2/actionBlocks/AccountDetailsBlock/SpendVsIncomeChart.es.js.map +1 -0
  26. package/dist/insights-v2/actionBlocks/AccountDetailsBlock/SpendVsPaymentChart.d.ts +7 -0
  27. package/dist/insights-v2/actionBlocks/AccountDetailsBlock/SpendVsPaymentChart.es.js +54 -0
  28. package/dist/insights-v2/actionBlocks/AccountDetailsBlock/SpendVsPaymentChart.es.js.map +1 -0
  29. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js +10 -10
  30. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js +24 -23
  31. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js.map +1 -1
  32. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js +75 -73
  33. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js.map +1 -1
  34. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.d.ts +5 -1
  35. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js +21 -21
  36. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js.map +1 -1
  37. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.d.ts +11 -0
  38. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js +65 -58
  39. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js.map +1 -1
  40. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsV2.es.js +17 -17
  41. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsV2.es.js.map +1 -1
  42. package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/BalanceStepper.es.js +9 -10
  43. package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/BalanceStepper.es.js.map +1 -1
  44. package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/SaveEnoughToLiveOnBottomSection.es.js +21 -22
  45. package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/SaveEnoughToLiveOnBottomSection.es.js.map +1 -1
  46. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.es.js +35 -35
  47. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.es.js.map +1 -1
  48. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.d.ts +1 -1
  49. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.es.js +44 -49
  50. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.es.js.map +1 -1
  51. package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesBlock.d.ts +1 -1
  52. package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesBlock.es.js +19 -16
  53. package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesBlock.es.js.map +1 -1
  54. package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesContent.d.ts +2 -2
  55. package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesContent.es.js +212 -166
  56. package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesContent.es.js.map +1 -1
  57. package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/StepIcon.d.ts +4 -0
  58. package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/StepIcon.es.js +24 -0
  59. package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/StepIcon.es.js.map +1 -0
  60. package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/layout.d.ts +6 -5
  61. package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/layout.es.js +38 -38
  62. package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/layout.es.js.map +1 -1
  63. package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.es.js +1 -1
  64. package/dist/insights-v2/actionBlocks/TopMerchantsBlock/TopMerchantsBlock.d.ts +1 -5
  65. package/dist/insights-v2/actionBlocks/TopMerchantsBlock/TopMerchantsBlock.es.js +37 -36
  66. package/dist/insights-v2/actionBlocks/TopMerchantsBlock/TopMerchantsBlock.es.js.map +1 -1
  67. package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/layout.d.ts +9 -11
  68. package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/layout.es.js +12 -6
  69. package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/layout.es.js.map +1 -1
  70. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js +46 -40
  71. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js.map +1 -1
  72. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +141 -126
  73. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
  74. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +8 -1
  75. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +243 -200
  76. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
  77. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.d.ts +2 -0
  78. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js.map +1 -1
  79. package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListBlock.es.js +54 -53
  80. package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListBlock.es.js.map +1 -1
  81. package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.d.ts +6 -1
  82. package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.es.js +14 -13
  83. package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.es.js.map +1 -1
  84. package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.d.ts +4 -3
  85. package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.es.js +24 -21
  86. package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.es.js.map +1 -1
  87. package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.d.ts +14 -4
  88. package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js +79 -67
  89. package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js.map +1 -1
  90. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChart.d.ts +3 -1
  91. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChart.es.js +48 -32
  92. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChart.es.js.map +1 -1
  93. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js +19 -14
  94. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js.map +1 -1
  95. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.d.ts +4 -0
  96. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.es.js +19 -15
  97. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.es.js.map +1 -1
  98. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.es.js +26 -19
  99. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.es.js.map +1 -1
  100. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.d.ts +1 -0
  101. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.es.js +17 -21
  102. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.es.js.map +1 -1
  103. package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/StepChartBlock.d.ts +1 -1
  104. package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/StepChartBlock.es.js +11 -11
  105. package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/StepChartBlock.es.js.map +1 -1
  106. package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/index.es.js +15 -11
  107. package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/index.es.js.map +1 -1
  108. package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/layout.d.ts +20 -0
  109. package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/layout.es.js +21 -0
  110. package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/layout.es.js.map +1 -0
  111. package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/variants/MilestoneProgress.d.ts +2 -4
  112. package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/variants/MilestoneProgress.es.js +78 -82
  113. package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/variants/MilestoneProgress.es.js.map +1 -1
  114. package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/variants/WithText.d.ts +10 -2
  115. package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/variants/WithText.es.js +115 -54
  116. package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/variants/WithText.es.js.map +1 -1
  117. package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.d.ts +1 -1
  118. package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js +37 -36
  119. package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js.map +1 -1
  120. package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.es.js +27 -22
  121. package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.es.js.map +1 -1
  122. package/dist/insights-v2/blocks/ComponentBlocks/BudgetBlock/BudgetBlock.es.js +8 -8
  123. package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/CompactDirectDepositBlock.d.ts +7 -0
  124. package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/CompactDirectDepositBlock.es.js +46 -0
  125. package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/CompactDirectDepositBlock.es.js.map +1 -0
  126. package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/index.d.ts +3 -0
  127. package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/layout.d.ts +13 -0
  128. package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/layout.es.js +22 -0
  129. package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/layout.es.js.map +1 -0
  130. package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js +29 -21
  131. package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js.map +1 -1
  132. package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/layout.d.ts +0 -2
  133. package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/layout.es.js +17 -21
  134. package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/layout.es.js.map +1 -1
  135. package/dist/insights-v2/blocks/ComponentBlocks/FeeChargedBlock/FeeChargedBlock.es.js +5 -6
  136. package/dist/insights-v2/blocks/ComponentBlocks/FeeChargedBlock/FeeChargedBlock.es.js.map +1 -1
  137. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/FeedbackBlock.d.ts +3 -7
  138. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/FeedbackBlock.es.js +120 -306
  139. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/FeedbackBlock.es.js.map +1 -1
  140. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/RatingScale.d.ts +17 -0
  141. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/RatingScale.es.js +93 -0
  142. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/RatingScale.es.js.map +1 -0
  143. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/StepBar.d.ts +5 -0
  144. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/StepBar.es.js +21 -0
  145. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/StepBar.es.js.map +1 -0
  146. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/SurveyResult.d.ts +18 -0
  147. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/SurveyResult.es.js +71 -0
  148. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/SurveyResult.es.js.map +1 -0
  149. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/survey.d.ts +82 -8
  150. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/survey.es.js +66 -15
  151. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/survey.es.js.map +1 -1
  152. package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js +46 -63
  153. package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js.map +1 -1
  154. package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.d.ts +3 -3
  155. package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.es.js +44 -53
  156. package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.es.js.map +1 -1
  157. package/dist/insights-v2/blocks/ComponentBlocks/QuizBlock/QuizBlock.d.ts +1 -1
  158. package/dist/insights-v2/blocks/ComponentBlocks/QuizBlock/QuizBlock.es.js +30 -31
  159. package/dist/insights-v2/blocks/ComponentBlocks/QuizBlock/QuizBlock.es.js.map +1 -1
  160. package/dist/insights-v2/blocks/ComponentBlocks/SaveExtraBlock/SaveExtraBlock.es.js +25 -20
  161. package/dist/insights-v2/blocks/ComponentBlocks/SaveExtraBlock/SaveExtraBlock.es.js.map +1 -1
  162. package/dist/insights-v2/blocks/ComponentBlocks/SaveExtraBlock/layout.d.ts +22 -0
  163. package/dist/insights-v2/blocks/ComponentBlocks/SaveExtraBlock/layout.es.js +24 -0
  164. package/dist/insights-v2/blocks/ComponentBlocks/SaveExtraBlock/layout.es.js.map +1 -0
  165. package/dist/insights-v2/blocks/ComponentBlocks/StrategiesBlock/StrategiesBlock.d.ts +7 -0
  166. package/dist/insights-v2/blocks/ComponentBlocks/StrategiesBlock/StrategiesBlock.es.js +89 -0
  167. package/dist/insights-v2/blocks/ComponentBlocks/StrategiesBlock/StrategiesBlock.es.js.map +1 -0
  168. package/dist/insights-v2/blocks/ComponentBlocks/StrategiesBlock/index.d.ts +1 -0
  169. package/dist/insights-v2/blocks/ComponentBlocks/StrategiesBlock/layout.d.ts +43 -0
  170. package/dist/insights-v2/blocks/ComponentBlocks/StrategiesBlock/layout.es.js +28 -0
  171. package/dist/insights-v2/blocks/ComponentBlocks/StrategiesBlock/layout.es.js.map +1 -0
  172. package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +54 -53
  173. package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js.map +1 -1
  174. package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.d.ts +7 -3
  175. package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.es.js +20 -11
  176. package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.es.js.map +1 -1
  177. package/dist/insights-v2/blocks/ComponentBlocks/WeeklySmallPurchasesBlock/WeeklySmallPurchasesBlock.es.js +29 -28
  178. package/dist/insights-v2/blocks/ComponentBlocks/WeeklySmallPurchasesBlock/WeeklySmallPurchasesBlock.es.js.map +1 -1
  179. package/dist/insights-v2/blocks/ComponentBlocks/index.d.ts +2 -0
  180. package/dist/insights-v2/blocks/ImageBlocks/ImageBlock.es.js +6 -5
  181. package/dist/insights-v2/blocks/ImageBlocks/ImageBlock.es.js.map +1 -1
  182. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/images/FederalBankHoliday.es.js +117 -71
  183. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/images/FederalBankHoliday.es.js.map +1 -1
  184. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/layout.d.ts +1 -1
  185. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/layout.es.js +10 -7
  186. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/layout.es.js.map +1 -1
  187. package/dist/insights-v2/components/AccountHeroCard.d.ts +3 -1
  188. package/dist/insights-v2/components/AccountHeroCard.es.js.map +1 -1
  189. package/dist/insights-v2/components/BaseLayout.d.ts +3 -1
  190. package/dist/insights-v2/components/BaseLayout.es.js +134 -119
  191. package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
  192. package/dist/insights-v2/components/CompactDirectDepositCard.d.ts +28 -0
  193. package/dist/insights-v2/components/CompactDirectDepositCard.es.js +78 -0
  194. package/dist/insights-v2/components/CompactDirectDepositCard.es.js.map +1 -0
  195. package/dist/insights-v2/components/CompactInsightCard.es.js +122 -118
  196. package/dist/insights-v2/components/CompactInsightCard.es.js.map +1 -1
  197. package/dist/insights-v2/components/DirectDepositCard.d.ts +6 -1
  198. package/dist/insights-v2/components/DirectDepositCard.es.js +24 -22
  199. package/dist/insights-v2/components/DirectDepositCard.es.js.map +1 -1
  200. package/dist/insights-v2/components/LoadingCard.es.js +13 -9
  201. package/dist/insights-v2/components/LoadingCard.es.js.map +1 -1
  202. package/dist/insights-v2/components/LogoFromGuid.d.ts +1 -1
  203. package/dist/insights-v2/components/LogoFromGuid.es.js.map +1 -1
  204. package/dist/insights-v2/components/MerchantHighlightCard.es.js +4 -4
  205. package/dist/insights-v2/components/SaveAnExtraCard.d.ts +4 -1
  206. package/dist/insights-v2/components/SaveAnExtraCard.es.js +32 -20
  207. package/dist/insights-v2/components/SaveAnExtraCard.es.js.map +1 -1
  208. package/dist/insights-v2/components/SubTabs.d.ts +2 -1
  209. package/dist/insights-v2/components/SubTabs.es.js +29 -24
  210. package/dist/insights-v2/components/SubTabs.es.js.map +1 -1
  211. package/dist/insights-v2/components/TransactionListCard.d.ts +3 -1
  212. package/dist/insights-v2/components/TransactionListCard.es.js +39 -37
  213. package/dist/insights-v2/components/TransactionListCard.es.js.map +1 -1
  214. package/dist/insights-v2/components/TransferLogoCard.es.js +1 -0
  215. package/dist/insights-v2/components/TransferLogoCard.es.js.map +1 -1
  216. package/dist/insights-v2/components/UpcomingBillCard.es.js +39 -35
  217. package/dist/insights-v2/components/UpcomingBillCard.es.js.map +1 -1
  218. package/dist/insights-v2/components/celebrationGradients.d.ts +17 -8
  219. package/dist/insights-v2/components/celebrationGradients.es.js +14 -14
  220. package/dist/insights-v2/components/celebrationGradients.es.js.map +1 -1
  221. package/dist/insights-v2/components/chartblocks/ChartLegend.es.js +16 -10
  222. package/dist/insights-v2/components/chartblocks/ChartLegend.es.js.map +1 -1
  223. package/dist/insights-v2/components/chartblocks/DoubleBarChart.d.ts +10 -4
  224. package/dist/insights-v2/components/chartblocks/DoubleBarChart.es.js +62 -61
  225. package/dist/insights-v2/components/chartblocks/DoubleBarChart.es.js.map +1 -1
  226. package/dist/insights-v2/components/chartblocks/EmptyBarChart.es.js +13 -6
  227. package/dist/insights-v2/components/chartblocks/EmptyBarChart.es.js.map +1 -1
  228. package/dist/insights-v2/components/shared/images/DesignateEmergencySavings.es.js +2 -3
  229. package/dist/insights-v2/components/shared/images/DesignateEmergencySavings.es.js.map +1 -1
  230. package/dist/insights-v2/components/statusIcon.d.ts +2 -1
  231. package/dist/insights-v2/components/statusIcon.es.js +10 -8
  232. package/dist/insights-v2/components/statusIcon.es.js.map +1 -1
  233. package/dist/insights-v2/ctaActions/ctaConfig.es.js +19 -17
  234. package/dist/insights-v2/ctaActions/ctaConfig.es.js.map +1 -1
  235. package/dist/insights-v2/ctaActions/ctaHandlers.d.ts +5 -1
  236. package/dist/insights-v2/ctaActions/ctaHandlers.es.js +71 -54
  237. package/dist/insights-v2/ctaActions/ctaHandlers.es.js.map +1 -1
  238. package/dist/insights-v2/ctaActions/ctaPostMessages.es.js +41 -24
  239. package/dist/insights-v2/ctaActions/ctaPostMessages.es.js.map +1 -1
  240. package/dist/insights-v2/ctaActions/feedbackSurvey.d.ts +9 -0
  241. package/dist/insights-v2/ctaActions/feedbackSurvey.es.js +51 -0
  242. package/dist/insights-v2/ctaActions/feedbackSurvey.es.js.map +1 -0
  243. package/dist/insights-v2/ctaActions/runCtaAction.es.js +36 -35
  244. package/dist/insights-v2/ctaActions/runCtaAction.es.js.map +1 -1
  245. package/dist/insights-v2/ctaActions/types.d.ts +7 -0
  246. package/dist/insights-v2/index.es.js +126 -120
  247. package/dist/insights-v2/mappings/actionBlocksKey.d.ts +1 -1
  248. package/dist/insights-v2/mappings/actionBlocksKey.es.js +1 -1
  249. package/dist/insights-v2/mappings/actionBlocksKey.es.js.map +1 -1
  250. package/dist/insights-v2/mappings/blocks.es.js +126 -122
  251. package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
  252. package/dist/microinsights/MicroCardTemplate.es.js +1 -1
  253. package/dist/microinsights/MicroCardTemplate.es.js.map +1 -1
  254. package/dist/microinsights/cards/InsightCard.es.js +53 -53
  255. package/dist/microinsights/cards/InsightCard.es.js.map +1 -1
  256. package/package.json +1 -1
  257. package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/index.d.ts +0 -13
  258. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/images/DesignateEmergencySavingsAccount.es.js +0 -296
  259. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/images/DesignateEmergencySavingsAccount.es.js.map +0 -1
@@ -1,22 +1,23 @@
1
1
  import { ANALYTICS_EVENTS_CONFIG as a } from "../analytics/analyticsEventsConfig.es.js";
2
2
  import { CTA_STATUS_CONTENT_CLASS as n } from "../components/CtaStatus.es.js";
3
- import { QUIZ_CONTEXT as e } from "../blocks/ComponentBlocks/QuizBlock/quiz.es.js";
3
+ import { QUIZ_CONTEXT as t } from "../blocks/ComponentBlocks/QuizBlock/quiz.es.js";
4
4
  import { HOST_ACTIONS as c } from "./hostActions.es.js";
5
- import { subscriptionEntryStep as d, subscriptionSurvey as _ } from "./subscriptionAnswer.es.js";
5
+ import { feedbackSurveyStep as _ } from "./feedbackSurvey.es.js";
6
+ import { subscriptionEntryStep as d, subscriptionSurvey as m } from "./subscriptionAnswer.es.js";
6
7
  import { alpha as u } from "@mui/material/styles";
7
- var s = ({ beat: t, stores: i }) => i.insightsV2Store.beatContext[t.guid] ?? {}, p = ({ beat: t, stores: i }) => {
8
- const r = i.insightsV2Store.beatContext[t.guid]?.selected_account_guid;
8
+ var s = ({ beat: e, stores: i }) => i.insightsV2Store.beatContext[e.guid] ?? {}, p = ({ beat: e, stores: i }) => {
9
+ const r = i.insightsV2Store.beatContext[e.guid]?.selected_account_guid;
9
10
  if (typeof r == "string")
10
11
  return i.accountStore.visibleSavingsAccounts.some((o) => o.guid === r && !o.is_closed && !o.is_deleted) ? r : void 0;
11
- }, b = {
12
+ }, v = {
12
13
  dismiss_beat: {
13
14
  run: "delegateToHost",
14
15
  params: { hostAction: c.dismissBeat }
15
16
  },
16
17
  select_savings_account: {
17
18
  run: "updateUserInsightProfile",
18
- params: (t) => ({ fields: { emergency_savings_account_guid: p(t) } }),
19
- disabledWhen: (t) => !p(t),
19
+ params: (e) => ({ fields: { emergency_savings_account_guid: p(e) } }),
20
+ disabledWhen: (e) => !p(e),
20
21
  onSuccess: ["refreshBeat"],
21
22
  analytics: a.EMERGENCY_SAVINGS_ACCT_SAVED
22
23
  },
@@ -30,13 +31,13 @@ var s = ({ beat: t, stores: i }) => i.insightsV2Store.beatContext[t.guid] ?? {},
30
31
  positive: "confirmed",
31
32
  negative: "incorrect"
32
33
  } }),
33
- surveyAnswer: _
34
+ surveyAnswer: m
34
35
  },
35
36
  check_quiz_answer: {
36
37
  run: "updateBeatContext",
37
- params: { fields: { [e.CHECKED]: !0 } },
38
- disabledWhen: (t) => !s(t)[e.PICK] || !!s(t)[e.CHECKED],
39
- presenter: (t) => s(t)[e.REVEALED] ? {
38
+ params: { fields: { [t.CHECKED]: !0 } },
39
+ disabledWhen: (e) => !s(e)[t.PICK] || !!s(e)[t.CHECKED],
40
+ presenter: (e) => s(e)[t.REVEALED] ? {
40
41
  kind: "hidden",
41
42
  hideAll: !0
42
43
  } : void 0
@@ -44,11 +45,12 @@ var s = ({ beat: t, stores: i }) => i.insightsV2Store.beatContext[t.guid] ?? {},
44
45
  skip_quiz: {
45
46
  run: "updateBeatContext",
46
47
  params: {
47
- fields: { [e.REVEALED]: !0 },
48
+ fields: { [t.REVEALED]: !0 },
48
49
  markCtaClicked: !0
49
50
  },
50
- disabledWhen: (t) => !!s(t)[e.CHECKED]
51
+ disabledWhen: (e) => !!s(e)[t.CHECKED]
51
52
  },
53
+ answer_feedback_survey: _,
52
54
  confirm_subscription_status: {
53
55
  ...d({
54
56
  statusLabels: {
@@ -69,16 +71,16 @@ var s = ({ beat: t, stores: i }) => i.insightsV2Store.beatContext[t.guid] ?? {},
69
71
  },
70
72
  negativeSx: {
71
73
  bgcolor: "background.paper",
72
- borderColor: (t) => u(t.palette.text.primary, 0.5),
73
- [`& .${n} .MuiSvgIcon-root`]: { color: (t) => u(t.palette.text.primary, 0.7) }
74
+ borderColor: (e) => u(e.palette.text.primary, 0.5),
75
+ [`& .${n} .MuiSvgIcon-root`]: { color: (e) => u(e.palette.text.primary, 0.7) }
74
76
  },
75
- answeredTitle: (t) => t.insights_feed?.subscription_status_modal?.reviewed_title
77
+ answeredTitle: (e) => e.insights_feed?.subscription_status_modal?.reviewed_title
76
78
  }),
77
79
  compactStatus: !0
78
80
  }
79
81
  };
80
82
  export {
81
- b as ctaActions
83
+ v as ctaActions
82
84
  };
83
85
 
84
86
  //# sourceMappingURL=ctaConfig.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ctaConfig.es.js","names":[],"sources":["../../../src/insights-v2/ctaActions/ctaConfig.ts"],"sourcesContent":["import { alpha, type Theme } from '@mui/material/styles'\n\nimport { ANALYTICS_EVENTS_CONFIG } from '../analytics/analyticsEventsConfig'\nimport { CTA_STATUS_CONTENT_CLASS } from '../components/CtaStatus'\nimport { QUIZ_CONTEXT } from '../blocks/ComponentBlocks/QuizBlock/quiz'\nimport { HOST_ACTIONS } from './hostActions'\nimport { subscriptionEntryStep, subscriptionSurvey } from './subscriptionAnswer'\nimport type { CtaStateContext, CtaStep } from './types'\n\nconst quizContext = ({ beat, stores }: Pick<CtaStateContext, 'beat' | 'stores'>) =>\n stores.insightsV2Store.beatContext[beat.guid] ?? {}\n\n/**\n * The account the svg_image_block picker wrote into this beat's context, and only while it is\n * still one the user can save into (visible, open, not deleted) — a pick that went stale between\n * pick and Save never reaches the API.\n */\nconst pickedSavingsAccountGuid = ({ beat, stores }: Pick<CtaStateContext, 'beat' | 'stores'>) => {\n const picked = stores.insightsV2Store.beatContext[beat.guid]?.selected_account_guid\n\n if (typeof picked !== 'string') return undefined\n\n const usable = stores.accountStore.visibleSavingsAccounts.some(\n (account) => account.guid === picked && !account.is_closed && !account.is_deleted,\n )\n\n return usable ? picked : undefined\n}\n\n/**\n * Steps keyed by the backend-named `cta.action_key` (ditto `*_cta_action`, via tupac). No key or\n * an unknown key = default: open the CTA's block drawer, if any. Its post message, when one\n * resolves (`cta.metadata` / `ctaPostMessages`), is sent either way. A new key is registered in\n * ditto and here in the same change; most CTAs need none. See README.md.\n */\nexport const ctaActions: Record<string, CtaStep> = {\n /** ConnectDiscoveredAccounts \"I don't have any\": dismiss through the host, then stop. */\n dismiss_beat: {\n run: 'delegateToHost',\n params: { hostAction: HOST_ACTIONS.dismissBeat },\n },\n\n /**\n * Designate Emergency Savings Account \"Save\": designates the account picked in the\n * svg_image_block picker (kept in the per-beat context), then refreshes the beat. The beat is\n * sampled, so the refresh re-reads its sample, which the backend rebuilds as the saved card\n * (change_account: \"Account Saved!\", no CTA). Disabled until a pick is made.\n */\n select_savings_account: {\n run: 'updateUserInsightProfile',\n params: (ctx) => ({\n fields: { emergency_savings_account_guid: pickedSavingsAccountGuid(ctx) },\n }),\n disabledWhen: (ctx) => !pickedSavingsAccountGuid(ctx),\n onSuccess: ['refreshBeat'],\n analytics: ANALYTICS_EVENTS_CONFIG.EMERGENCY_SAVINGS_ACCT_SAVED,\n },\n\n /**\n * Designate Emergency Savings Account \"Open a Savings Account\": no handler. The op_1 post\n * message comes from `ctaPostMessages`; this step adds the Created event.\n */\n open_savings_account: {\n analytics: ANALYTICS_EVENTS_CONFIG.EMERGENCY_SAVINGS_ACCT_CREATED,\n },\n\n /**\n * SetUpDirectDeposit `not_set_up`: hand the press to the host, which owns the Atomic SDK and its\n * lifecycle. No drawer, no `refreshBeat`, and no interim post message is registered for the\n * template (a backend-supplied `cta.metadata` would still post).\n */\n atomic_flow: {\n run: 'delegateToHost',\n params: { hostAction: HOST_ACTIONS.atomicTransact },\n },\n\n /**\n * SubscriptionDetected \"Does this look right?\": the shared subscription status CTA (every answer\n * counts, as pulse), answered through the survey.\n */\n confirm_subscription_detected: {\n ...subscriptionEntryStep({ statusLabels: { positive: 'confirmed', negative: 'incorrect' } }),\n surveyAnswer: subscriptionSurvey,\n },\n\n /** Monthly Top Transacted Merchant \"Check Answer\": the block plays the feedback, then the results. */\n check_quiz_answer: {\n run: 'updateBeatContext',\n params: { fields: { [QUIZ_CONTEXT.CHECKED]: true } },\n disabledWhen: (ctx) =>\n !quizContext(ctx)[QUIZ_CONTEXT.PICK] || !!quizContext(ctx)[QUIZ_CONTEXT.CHECKED],\n // Once the results show, the card has no buttons, as Figma's Results state.\n presenter: (ctx) =>\n quizContext(ctx)[QUIZ_CONTEXT.REVEALED] ? { kind: 'hidden', hideAll: true } : undefined,\n },\n\n /** Monthly Top Transacted Merchant \"Skip to Results\": shows the results and records `cta_clicked_at`. */\n skip_quiz: {\n run: 'updateBeatContext',\n params: { fields: { [QUIZ_CONTEXT.REVEALED]: true }, markCtaClicked: true },\n disabledWhen: (ctx) => !!quizContext(ctx)[QUIZ_CONTEXT.CHECKED],\n },\n\n /** Unexpected Subscription Payment: Figma's status bar; mini and micro mirror it (`compactStatus`). */\n confirm_subscription_status: {\n ...subscriptionEntryStep({\n statusLabels: { positive: 'subscribed', negative: 'not_subscribed' },\n sx: {\n minHeight: 56,\n [`& .${CTA_STATUS_CONTENT_CLASS}`]: { gap: 10 },\n '& > .MuiButton-root': {\n fontSize: 13,\n fontWeight: 600,\n lineHeight: '16px',\n minWidth: 0,\n px: 8,\n py: 4,\n },\n },\n negativeSx: {\n bgcolor: 'background.paper',\n borderColor: (theme: Theme) => alpha(theme.palette.text.primary, 0.5),\n [`& .${CTA_STATUS_CONTENT_CLASS} .MuiSvgIcon-root`]: {\n color: (theme: Theme) => alpha(theme.palette.text.primary, 0.7),\n },\n },\n answeredTitle: (copy) => copy.insights_feed?.subscription_status_modal?.reviewed_title,\n }),\n compactStatus: true,\n },\n}\n"],"mappings":";;;;;;AASA,IAAM,IAAA,CAAe,EAAE,MAAA,GAAM,QAAA,EAAA,MAC3B,EAAO,gBAAgB,YAAY,EAAK,IAAA,KAAS,CAAC,GAO9C,IAAA,CAA4B,EAAE,MAAA,GAAM,QAAA,EAAA,MAAuD;AAC/F,QAAM,IAAS,EAAO,gBAAgB,YAAY,EAAK,IAAA,GAAO;AAE9D,MAAI,OAAO,KAAW;AAMtB,WAJe,EAAO,aAAa,uBAAuB,KAAA,CACvD,MAAY,EAAQ,SAAS,KAAU,CAAC,EAAQ,aAAa,CAAC,EAAQ,UAGlE,IAAS,IAAS;AAC3B,GAQa,IAAsC;AAAA,EAEjD,cAAc;AAAA,IACZ,KAAK;AAAA,IACL,QAAQ,EAAE,YAAY,EAAa,YAAY;AAAA,EACjD;AAAA,EAQA,wBAAwB;AAAA,IACtB,KAAK;AAAA,IACL,QAAA,CAAS,OAAS,EAChB,QAAQ,EAAE,gCAAgC,EAAyB,CAAG,EAAE,EAC1E;AAAA,IACA,cAAA,CAAe,MAAQ,CAAC,EAAyB,CAAG;AAAA,IACpD,WAAW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V,IAAI;AAAA,UACJ,IAAI;AAAA,QACN;AAAA,MACF;AAAA,MACA,YAAY;AAAA,QACV,SAAS;AAAA,QACT,aAAA,CAAc,MAAiB,EAAM,EAAM,QAAQ,KAAK,SAAS,GAAG;AAAA,QACnE,CAAA,MAAM,CAAA,mBAAyB,GAAqB,EACnD,OAAA,CAAQ,MAAiB,EAAM,EAAM,QAAQ,KAAK,SAAS,GAAG,EAChE;AAAA,MACF;AAAA,MACA,eAAA,CAAgB,MAAS,EAAK,eAAe,2BAA2B;AAAA,IAC1E,CAAC;AAAA,IACD,eAAe;AAAA,EACjB;AACF"}
1
+ {"version":3,"file":"ctaConfig.es.js","names":[],"sources":["../../../src/insights-v2/ctaActions/ctaConfig.ts"],"sourcesContent":["import { alpha, type Theme } from '@mui/material/styles'\n\nimport { ANALYTICS_EVENTS_CONFIG } from '../analytics/analyticsEventsConfig'\nimport { CTA_STATUS_CONTENT_CLASS } from '../components/CtaStatus'\nimport { QUIZ_CONTEXT } from '../blocks/ComponentBlocks/QuizBlock/quiz'\nimport { feedbackSurveyStep } from './feedbackSurvey'\nimport { HOST_ACTIONS } from './hostActions'\nimport { subscriptionEntryStep, subscriptionSurvey } from './subscriptionAnswer'\nimport type { CtaStateContext, CtaStep } from './types'\n\nconst quizContext = ({ beat, stores }: Pick<CtaStateContext, 'beat' | 'stores'>) =>\n stores.insightsV2Store.beatContext[beat.guid] ?? {}\n\n/**\n * The account the svg_image_block picker wrote into this beat's context, and only while it is\n * still one the user can save into (visible, open, not deleted) — a pick that went stale between\n * pick and Save never reaches the API.\n */\nconst pickedSavingsAccountGuid = ({ beat, stores }: Pick<CtaStateContext, 'beat' | 'stores'>) => {\n const picked = stores.insightsV2Store.beatContext[beat.guid]?.selected_account_guid\n\n if (typeof picked !== 'string') return undefined\n\n const usable = stores.accountStore.visibleSavingsAccounts.some(\n (account) => account.guid === picked && !account.is_closed && !account.is_deleted,\n )\n\n return usable ? picked : undefined\n}\n\n/**\n * Steps keyed by the backend-named `cta.action_key` (ditto `*_cta_action`, via tupac). No key or\n * an unknown key = default: open the CTA's block drawer, if any. Its post message, when one\n * resolves (`cta.metadata` / `ctaPostMessages`), is sent either way. A new key is registered in\n * ditto and here in the same change; most CTAs need none. See README.md.\n */\nexport const ctaActions: Record<string, CtaStep> = {\n /** ConnectDiscoveredAccounts \"I don't have any\": dismiss through the host, then stop. */\n dismiss_beat: {\n run: 'delegateToHost',\n params: { hostAction: HOST_ACTIONS.dismissBeat },\n },\n\n /**\n * Designate Emergency Savings Account \"Save\": designates the account picked in the\n * svg_image_block picker (kept in the per-beat context), then refreshes the beat. The beat is\n * sampled, so the refresh re-reads its sample, which the backend rebuilds as the saved card\n * (change_account: \"Account Saved!\", no CTA). Disabled until a pick is made.\n */\n select_savings_account: {\n run: 'updateUserInsightProfile',\n params: (ctx) => ({\n fields: { emergency_savings_account_guid: pickedSavingsAccountGuid(ctx) },\n }),\n disabledWhen: (ctx) => !pickedSavingsAccountGuid(ctx),\n onSuccess: ['refreshBeat'],\n analytics: ANALYTICS_EVENTS_CONFIG.EMERGENCY_SAVINGS_ACCT_SAVED,\n },\n\n /**\n * Designate Emergency Savings Account \"Open a Savings Account\": no handler. The op_1 post\n * message comes from `ctaPostMessages`; this step adds the Created event.\n */\n open_savings_account: {\n analytics: ANALYTICS_EVENTS_CONFIG.EMERGENCY_SAVINGS_ACCT_CREATED,\n },\n\n /**\n * SetUpDirectDeposit `not_set_up`: hand the press to the host, which owns the Atomic SDK and its\n * lifecycle. No drawer, no `refreshBeat`, and no interim post message is registered for the\n * template (a backend-supplied `cta.metadata` would still post).\n */\n atomic_flow: {\n run: 'delegateToHost',\n params: { hostAction: HOST_ACTIONS.atomicTransact },\n },\n\n /**\n * SubscriptionDetected \"Does this look right?\": the shared subscription status CTA (every answer\n * counts, as pulse), answered through the survey.\n */\n confirm_subscription_detected: {\n ...subscriptionEntryStep({ statusLabels: { positive: 'confirmed', negative: 'incorrect' } }),\n surveyAnswer: subscriptionSurvey,\n },\n\n /** Monthly Top Transacted Merchant \"Check Answer\": the block plays the feedback, then the results. */\n check_quiz_answer: {\n run: 'updateBeatContext',\n params: { fields: { [QUIZ_CONTEXT.CHECKED]: true } },\n disabledWhen: (ctx) =>\n !quizContext(ctx)[QUIZ_CONTEXT.PICK] || !!quizContext(ctx)[QUIZ_CONTEXT.CHECKED],\n // Once the results show, the card has no buttons, as Figma's Results state.\n presenter: (ctx) =>\n quizContext(ctx)[QUIZ_CONTEXT.REVEALED] ? { kind: 'hidden', hideAll: true } : undefined,\n },\n\n /** Monthly Top Transacted Merchant \"Skip to Results\": shows the results and records `cta_clicked_at`. */\n skip_quiz: {\n run: 'updateBeatContext',\n params: { fields: { [QUIZ_CONTEXT.REVEALED]: true }, markCtaClicked: true },\n disabledWhen: (ctx) => !!quizContext(ctx)[QUIZ_CONTEXT.CHECKED],\n },\n\n /** A `feedback_block` survey's Continue / Submit; the block keeps the answers in the beat context. */\n answer_feedback_survey: feedbackSurveyStep,\n\n /** Unexpected Subscription Payment: Figma's status bar; mini and micro mirror it (`compactStatus`). */\n confirm_subscription_status: {\n ...subscriptionEntryStep({\n statusLabels: { positive: 'subscribed', negative: 'not_subscribed' },\n sx: {\n minHeight: 56,\n [`& .${CTA_STATUS_CONTENT_CLASS}`]: { gap: 10 },\n '& > .MuiButton-root': {\n fontSize: 13,\n fontWeight: 600,\n lineHeight: '16px',\n minWidth: 0,\n px: 8,\n py: 4,\n },\n },\n negativeSx: {\n bgcolor: 'background.paper',\n borderColor: (theme: Theme) => alpha(theme.palette.text.primary, 0.5),\n [`& .${CTA_STATUS_CONTENT_CLASS} .MuiSvgIcon-root`]: {\n color: (theme: Theme) => alpha(theme.palette.text.primary, 0.7),\n },\n },\n answeredTitle: (copy) => copy.insights_feed?.subscription_status_modal?.reviewed_title,\n }),\n compactStatus: true,\n },\n}\n"],"mappings":";;;;;;;AAUA,IAAM,IAAA,CAAe,EAAE,MAAA,GAAM,QAAA,EAAA,MAC3B,EAAO,gBAAgB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E,MAAM;AAAA,MAAU,SAAS;AAAA,IAAK,IAAI;AAAA,EAClF;AAAA,EAGA,WAAW;AAAA,IACT,KAAK;AAAA,IACL,QAAQ;AAAA,MAAE,QAAQ,EAAA,CAAG,EAAa,QAAA,GAAW,GAAK;AAAA,MAAG,gBAAgB;AAAA,IAAK;AAAA,IAC1E,cAAA,CAAe,MAAQ,CAAC,CAAC,EAAY,CAAG,EAAE,EAAa,OAAA;AAAA,EACzD;AAAA,EAGA,wBAAwB;AAAA,EAGxB,6BAA6B;AAAA,IAC3B,GAAG,EAAsB;AAAA,MACvB,cAAc;AAAA,QAAE,UAAU;AAAA,QAAc,UAAU;AAAA,MAAiB;AAAA,MACnE,IAAI;AAAA,QACF,WAAW;AAAA,QACV,CAAA,MAAM,CAAA,EAAA,GAA6B,EAAE,KAAK,GAAG;AAAA,QAC9C,uBAAuB;AAAA,UACrB,UAAU;AAAA,UACV,YAAY;AAAA,UACZ,YAAY;AAAA,UACZ,UAAU;AAAA,UACV,IAAI;AAAA,UACJ,IAAI;AAAA,QACN;AAAA,MACF;AAAA,MACA,YAAY;AAAA,QACV,SAAS;AAAA,QACT,aAAA,CAAc,MAAiB,EAAM,EAAM,QAAQ,KAAK,SAAS,GAAG;AAAA,QACnE,CAAA,MAAM,CAAA,mBAAyB,GAAqB,EACnD,OAAA,CAAQ,MAAiB,EAAM,EAAM,QAAQ,KAAK,SAAS,GAAG,EAChE;AAAA,MACF;AAAA,MACA,eAAA,CAAgB,MAAS,EAAK,eAAe,2BAA2B;AAAA,IAC1E,CAAC;AAAA,IACD,eAAe;AAAA,EACjB;AACF"}
@@ -13,7 +13,10 @@ export declare const ctaHandlers: {
13
13
  updateAccountField: (ctx: CtaContext) => Promise<void>;
14
14
  /** `PUT notification_profiles/:guid` setting `threshold` on the named profile. */
15
15
  updateNotificationProfileThreshold: (ctx: CtaContext) => Promise<void>;
16
- /** `POST budgets` for `params.categoryGuid` with `params.amount` (+ optional parentGuid). */
16
+ /**
17
+ * `POST budgets` for `params.categoryGuid` with `params.amount` (+ optional parentGuid). A subcategory budget
18
+ * shows on the Budgets screen only under its parent's budget, so one is found or created first.
19
+ */
17
20
  createBudget: (ctx: CtaContext) => Promise<void>;
18
21
  /** `PUT budgets/:guid` setting `amount`. */
19
22
  updateBudget: (ctx: CtaContext) => Promise<void>;
@@ -35,6 +38,7 @@ export declare const ctaHandlers: {
35
38
  applyTransactionRule: (ctx: CtaContext) => Promise<void>;
36
39
  /** Merges `params.fields` into beat context; `params.markCtaClicked` records `cta_clicked_at`. */
37
40
  updateBeatContext: (ctx: CtaContext) => Promise<void>;
41
+ answerFeedbackSurvey: (ctx: CtaContext) => Promise<void>;
38
42
  delegateToHost: (ctx: CtaContext) => Promise<void>;
39
43
  };
40
44
  /** A registered handler name. */
@@ -1,21 +1,22 @@
1
- import { HOST_ACTIONS as g } from "./hostActions.es.js";
2
- var s = (t, e) => t.params[e], n = (t, e) => {
3
- const r = s(t, e);
4
- if (r == null || r === "") throw new Error(`CTA handler requires params.${e}`);
5
- return r;
6
- }, u = (t) => {
7
- const e = s(t, "fields");
1
+ import { HOST_ACTIONS as h } from "./hostActions.es.js";
2
+ import { answerFeedbackSurvey as m } from "./feedbackSurvey.es.js";
3
+ var u = (t, e) => t.params[e], n = (t, e) => {
4
+ const a = u(t, e);
5
+ if (a == null || a === "") throw new Error(`CTA handler requires params.${e}`);
6
+ return a;
7
+ }, l = (t) => {
8
+ const e = u(t, "fields");
8
9
  if (!e || Object.keys(e).length === 0) throw new Error("CTA handler requires params.fields");
9
- const r = Object.keys(e).filter((a) => e[a] === void 0);
10
- if (r.length > 0) throw new Error(`CTA handler could not resolve field(s): ${r.join(", ")}`);
10
+ const a = Object.keys(e).filter((r) => e[r] === void 0);
11
+ if (a.length > 0) throw new Error(`CTA handler could not resolve field(s): ${a.join(", ")}`);
11
12
  return e;
12
- }, i = (t, e, r) => {
13
- const a = t.find(e);
14
- if (!a) throw new Error(`${r} not found in store`);
15
- return a;
16
- }, p = {
13
+ }, d = (t, e, a) => {
14
+ const r = t.find(e);
15
+ if (!r) throw new Error(`${a} not found in store`);
16
+ return r;
17
+ }, S = {
17
18
  updateUserInsightProfile: async (t) => {
18
- await t.stores.userStore.updateUserInsightProfile(u(t));
19
+ await t.stores.userStore.updateUserInsightProfile(l(t));
19
20
  },
20
21
  markOfferClicked: async ({ beat: t, stores: e }) => {
21
22
  await e.beatStore.updateOffer({
@@ -24,39 +25,54 @@ var s = (t, e) => t.params[e], n = (t, e) => {
24
25
  });
25
26
  },
26
27
  updateRepeatingTransactionResponse: async (t) => {
27
- const { beat: e, stores: r } = t, a = n(t, "userResponse"), o = s(t, "repeatingTransactionGuid") ?? e.primary_transaction?.repeating_transaction_guid;
28
+ const { beat: e, stores: a } = t, r = n(t, "userResponse"), o = u(t, "repeatingTransactionGuid") ?? e.primary_transaction?.repeating_transaction_guid;
28
29
  if (!o) throw new Error("No repeating transaction guid for beat");
29
- const d = i(r.recurringTransactionsStore.repeatingTransactions, (c) => c.guid === o, `Repeating transaction ${o}`);
30
- if (!await r.recurringTransactionsStore.updateRepeatingTransaction({
31
- ...d,
32
- user_response: a
30
+ const i = d(a.recurringTransactionsStore.repeatingTransactions, (s) => s.guid === o, `Repeating transaction ${o}`);
31
+ if (!await a.recurringTransactionsStore.updateRepeatingTransaction({
32
+ ...i,
33
+ user_response: r
33
34
  })) throw new Error("Failed to update repeating transaction");
34
35
  },
35
36
  updateAccountField: async (t) => {
36
- const { beat: e, stores: r } = t, a = s(t, "accountGuid") ?? e.primary_account_guid;
37
- if (!a) throw new Error("No account guid for beat");
38
- const o = i(r.accountStore.accounts, (d) => d.guid === a, `Account ${a}`);
39
- if (!await r.accountStore.updateAccount({
37
+ const { beat: e, stores: a } = t, r = u(t, "accountGuid") ?? e.primary_account_guid;
38
+ if (!r) throw new Error("No account guid for beat");
39
+ const o = d(a.accountStore.accounts, (i) => i.guid === r, `Account ${r}`);
40
+ if (!await a.accountStore.updateAccount({
40
41
  ...o,
41
- ...u(t)
42
+ ...l(t)
42
43
  })) throw new Error("Failed to update account");
43
44
  },
44
45
  updateNotificationProfileThreshold: async (t) => {
45
- const e = n(t, "profileGuid"), r = n(t, "threshold"), a = i(t.stores.settingsStore.notificationProfiles, (o) => o.guid === e, `Notification profile ${e}`);
46
+ const e = n(t, "profileGuid"), a = n(t, "threshold"), r = d(t.stores.settingsStore.notificationProfiles, (o) => o.guid === e, `Notification profile ${e}`);
46
47
  if (!await t.stores.settingsStore.updateNotificationProfile({
47
- ...a,
48
- threshold: r
48
+ ...r,
49
+ threshold: a
49
50
  })) throw new Error("Failed to update notification profile");
50
51
  },
51
52
  createBudget: async (t) => {
52
- const e = n(t, "categoryGuid"), r = n(t, "amount"), a = i(t.stores.categoryStore.categories, (o) => o.guid === e, `Category ${e}`);
53
- if (!await t.stores.budgetsStore.addBudget(a, r, s(t, "parentGuid") ?? null)) throw new Error("Failed to create budget");
53
+ const e = n(t, "categoryGuid"), a = n(t, "amount"), { budgetsStore: r, categoryStore: o } = t.stores, i = d(o.categories, (c) => c.guid === e, `Category ${e}`);
54
+ let s = u(t, "parentGuid") ?? null;
55
+ if (!s && i.parent_guid) {
56
+ r.isDataLoaded || await r.loadBudgets();
57
+ const c = i.parent_guid, p = () => r.budgets.find((g) => g.category_guid === c && !g.parent_guid)?.guid;
58
+ let f;
59
+ if (!p()) {
60
+ const g = d(o.categories, (w) => w.guid === c, `Category ${c}`);
61
+ if (!await r.addBudget(g, a, null)) throw new Error("Failed to create budget");
62
+ f = p();
63
+ }
64
+ if (s = p() ?? null, !s) throw new Error("Parent budget not found after creating it");
65
+ if (!await r.addBudget(i, a, s))
66
+ throw f && await r.deleteBudget(f), new Error("Failed to create budget");
67
+ return;
68
+ }
69
+ if (!await r.addBudget(i, a, s)) throw new Error("Failed to create budget");
54
70
  },
55
71
  updateBudget: async (t) => {
56
- const e = n(t, "budgetGuid"), r = n(t, "amount"), a = i(t.stores.budgetsStore.budgets, (o) => o.guid === e, `Budget ${e}`);
72
+ const e = n(t, "budgetGuid"), a = n(t, "amount"), r = d(t.stores.budgetsStore.budgets, (o) => o.guid === e, `Budget ${e}`);
57
73
  if (!await t.stores.budgetsStore.updateBudget({
58
- ...a,
59
- amount: r
74
+ ...r,
75
+ amount: a
60
76
  })) throw new Error("Failed to update budget");
61
77
  },
62
78
  deleteBudget: async (t) => {
@@ -66,54 +82,55 @@ var s = (t, e) => t.params[e], n = (t, e) => {
66
82
  if (!(await t.stores.budgetsStore.addMerchantBudget(n(t, "merchantGuid"), n(t, "amount")))?.isSuccess) throw new Error("Failed to create merchant budget");
67
83
  },
68
84
  updateMerchantBudget: async (t) => {
69
- const e = n(t, "merchantBudgetGuid"), r = n(t, "amount"), a = i(t.stores.budgetsStore.merchantBudgets, (o) => o.guid === e, `Merchant budget ${e}`);
85
+ const e = n(t, "merchantBudgetGuid"), a = n(t, "amount"), r = d(t.stores.budgetsStore.merchantBudgets, (o) => o.guid === e, `Merchant budget ${e}`);
70
86
  if (!(await t.stores.budgetsStore.updateMerchantBudget({
71
- ...a,
72
- amount: r
87
+ ...r,
88
+ amount: a
73
89
  }))?.isSuccess) throw new Error("Failed to update merchant budget");
74
90
  },
75
91
  deleteMerchantBudget: async (t) => {
76
92
  if (!(await t.stores.budgetsStore.deleteMerchantBudget(n(t, "merchantBudgetGuid")))?.isSuccess) throw new Error("Failed to delete merchant budget");
77
93
  },
78
94
  updateTransactionField: async (t) => {
79
- const { beat: e, stores: r } = t, a = s(t, "transactionGuid") ?? e.primary_transaction_guid;
80
- if (!a) throw new Error("No transaction guid for beat");
81
- const o = i(r.transactionStore.transactions, (d) => d.guid === a, `Transaction ${a}`);
82
- if (!await r.transactionStore.updateTransaction({
95
+ const { beat: e, stores: a } = t, r = u(t, "transactionGuid") ?? e.primary_transaction_guid;
96
+ if (!r) throw new Error("No transaction guid for beat");
97
+ const o = d(a.transactionStore.transactions, (i) => i.guid === r, `Transaction ${r}`);
98
+ if (!await a.transactionStore.updateTransaction({
83
99
  ...o,
84
- ...u(t)
100
+ ...l(t)
85
101
  })) throw new Error("Failed to update transaction");
86
102
  },
87
103
  applyTransactionRule: async (t) => {
88
- const { beat: e, stores: r } = t, a = n(t, "categoryGuid"), o = s(t, "transactionGuid") ?? e.primary_transaction_guid;
104
+ const { beat: e, stores: a } = t, r = n(t, "categoryGuid"), o = u(t, "transactionGuid") ?? e.primary_transaction_guid;
89
105
  if (!o) throw new Error("No transaction guid for beat");
90
- const d = i(r.transactionStore.transactions, (c) => c.guid === o, `Transaction ${o}`);
91
- if (!await r.transactionStore.addOrUpdateTransactionRule(a, d)) throw new Error("Failed to save transaction rule");
106
+ const i = d(a.transactionStore.transactions, (s) => s.guid === o, `Transaction ${o}`);
107
+ if (!await a.transactionStore.addOrUpdateTransactionRule(r, i)) throw new Error("Failed to save transaction rule");
92
108
  },
93
109
  updateBeatContext: async (t) => {
94
- const { beat: e, hostActions: r, stores: a } = t;
95
- a.insightsV2Store.setBeatContext(e.guid, u(t)), !(!s(t, "markCtaClicked") || e.cta_clicked_at) && Promise.resolve().then(() => r.onCtaAction?.({
110
+ const { beat: e, hostActions: a, stores: r } = t;
111
+ r.insightsV2Store.setBeatContext(e.guid, l(t)), !(!u(t, "markCtaClicked") || e.cta_clicked_at) && Promise.resolve().then(() => a.onCtaAction?.({
96
112
  beatGuid: e.guid,
97
- name: g.markCtaClicked
98
- })).catch((o) => a.captureException(o, {
113
+ name: h.markCtaClicked
114
+ })).catch((o) => r.captureException(o, {
99
115
  store: "ctaActions",
100
116
  template: e.template,
101
117
  handler: "updateBeatContext"
102
118
  }));
103
119
  },
120
+ answerFeedbackSurvey: m,
104
121
  delegateToHost: async (t) => {
105
- const { hostAction: e, ...r } = t.params, a = typeof e == "string" ? e : "";
106
- if (!a) throw new Error("delegateToHost requires params.hostAction");
107
- if (!t.hostActions.onCtaAction) throw new Error(`Host does not implement onCtaAction (needed for "${a}")`);
122
+ const { hostAction: e, ...a } = t.params, r = typeof e == "string" ? e : "";
123
+ if (!r) throw new Error("delegateToHost requires params.hostAction");
124
+ if (!t.hostActions.onCtaAction) throw new Error(`Host does not implement onCtaAction (needed for "${r}")`);
108
125
  await t.hostActions.onCtaAction({
109
126
  beatGuid: t.beat.guid,
110
- name: a,
111
- params: r
127
+ name: r,
128
+ params: a
112
129
  });
113
130
  }
114
131
  };
115
132
  export {
116
- p as ctaHandlers
133
+ S as ctaHandlers
117
134
  };
118
135
 
119
136
  //# sourceMappingURL=ctaHandlers.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ctaHandlers.es.js","names":[],"sources":["../../../src/insights-v2/ctaActions/ctaHandlers.ts"],"sourcesContent":["import type { Account, Budget, MerchantBudget, Transaction, UserInsightProfile } from '../../core'\nimport { HOST_ACTIONS } from './hostActions'\nimport type { CtaContext, CtaHandler } from './types'\n\n// Step side effects: call stores, throw on failure, read ctx.params.\n// Host-owned effects (beat endpoints, spending plan) use delegateToHost.\n\nconst param = <T>(ctx: CtaContext, key: string): T | undefined => ctx.params[key] as T | undefined\n\nconst requireParam = <T>(ctx: CtaContext, key: string): T => {\n const value = param<T>(ctx, key)\n\n if (value === undefined || value === null || value === '') {\n throw new Error(`CTA handler requires params.${key}`)\n }\n\n return value\n}\n\n// The write set under params.fields; throws if a pick is missing.\nconst requireFields = (ctx: CtaContext): Record<string, unknown> => {\n const fields = param<Record<string, unknown>>(ctx, 'fields')\n\n if (!fields || Object.keys(fields).length === 0) {\n throw new Error('CTA handler requires params.fields')\n }\n\n const missing = Object.keys(fields).filter((field) => fields[field] === undefined)\n\n if (missing.length > 0) {\n throw new Error(`CTA handler could not resolve field(s): ${missing.join(', ')}`)\n }\n\n return fields\n}\n\nconst findOrThrow = <T>(items: T[], predicate: (item: T) => boolean, what: string): T => {\n const found = items.find(predicate)\n\n if (!found) throw new Error(`${what} not found in store`)\n\n return found\n}\n\nexport const ctaHandlers = {\n /** `PUT user_insight_profile` (designate emergency savings, thresholds, safety net). */\n updateUserInsightProfile: async (ctx) => {\n await ctx.stores.userStore.updateUserInsightProfile(\n requireFields(ctx) as Partial<UserInsightProfile>,\n )\n },\n\n /** `PUT offers/:guid` flagging a marketing offer as clicked. */\n markOfferClicked: async ({ beat, stores }) => {\n await stores.beatStore.updateOffer({ ...beat, has_been_clicked: true } as typeof beat)\n },\n\n /**\n * `PUT repeating_transactions/:guid` writing `user_response`. Resolves the repeating\n * transaction from `params.repeatingTransactionGuid`, else the beat's primary transaction.\n */\n updateRepeatingTransactionResponse: async (ctx) => {\n const { beat, stores } = ctx\n const userResponse = requireParam<string>(ctx, 'userResponse')\n const guid =\n param<string>(ctx, 'repeatingTransactionGuid') ??\n beat.primary_transaction?.repeating_transaction_guid\n\n if (!guid) throw new Error('No repeating transaction guid for beat')\n\n const repeating = findOrThrow(\n stores.recurringTransactionsStore.repeatingTransactions,\n (rt) => rt.guid === guid,\n `Repeating transaction ${guid}`,\n )\n const ok = await stores.recurringTransactionsStore.updateRepeatingTransaction({\n ...repeating,\n user_response: userResponse,\n })\n\n if (!ok) throw new Error('Failed to update repeating transaction')\n },\n\n /** `PUT accounts/:guid` merging `params.fields`; `params.accountGuid` picks the account, else the beat's primary. */\n updateAccountField: async (ctx) => {\n const { beat, stores } = ctx\n const guid = param<string>(ctx, 'accountGuid') ?? beat.primary_account_guid\n\n if (!guid) throw new Error('No account guid for beat')\n\n const account = findOrThrow(\n stores.accountStore.accounts,\n (a) => a.guid === guid,\n `Account ${guid}`,\n )\n\n const ok = await stores.accountStore.updateAccount({\n ...account,\n ...requireFields(ctx),\n } as Account)\n\n if (!ok) throw new Error('Failed to update account')\n },\n\n /** `PUT notification_profiles/:guid` setting `threshold` on the named profile. */\n updateNotificationProfileThreshold: async (ctx) => {\n const profileGuid = requireParam<string>(ctx, 'profileGuid')\n const threshold = requireParam<number>(ctx, 'threshold')\n const profile = findOrThrow(\n ctx.stores.settingsStore.notificationProfiles,\n (p) => p.guid === profileGuid,\n `Notification profile ${profileGuid}`,\n )\n\n const ok = await ctx.stores.settingsStore.updateNotificationProfile({ ...profile, threshold })\n\n if (!ok) throw new Error('Failed to update notification profile')\n },\n\n /** `POST budgets` for `params.categoryGuid` with `params.amount` (+ optional parentGuid). */\n createBudget: async (ctx) => {\n const categoryGuid = requireParam<string>(ctx, 'categoryGuid')\n const amount = requireParam<number>(ctx, 'amount')\n const category = findOrThrow(\n ctx.stores.categoryStore.categories,\n (c) => c.guid === categoryGuid,\n `Category ${categoryGuid}`,\n )\n\n const ok = await ctx.stores.budgetsStore.addBudget(\n category,\n amount,\n param<string | null>(ctx, 'parentGuid') ?? null,\n )\n\n if (!ok) throw new Error('Failed to create budget')\n },\n\n /** `PUT budgets/:guid` setting `amount`. */\n updateBudget: async (ctx) => {\n const budgetGuid = requireParam<string>(ctx, 'budgetGuid')\n const amount = requireParam<number>(ctx, 'amount')\n const budget = findOrThrow(\n ctx.stores.budgetsStore.budgets,\n (b) => b.guid === budgetGuid,\n `Budget ${budgetGuid}`,\n )\n const ok = await ctx.stores.budgetsStore.updateBudget({ ...budget, amount } as Budget)\n\n if (!ok) throw new Error('Failed to update budget')\n },\n\n /** `DELETE budgets/:guid`. */\n deleteBudget: async (ctx) => {\n const ok = await ctx.stores.budgetsStore.deleteBudget(requireParam<string>(ctx, 'budgetGuid'))\n\n if (!ok) throw new Error('Failed to delete budget')\n },\n\n /** `POST merchant_budgets`. */\n createMerchantBudget: async (ctx) => {\n const result = await ctx.stores.budgetsStore.addMerchantBudget(\n requireParam<string>(ctx, 'merchantGuid'),\n requireParam<number>(ctx, 'amount'),\n )\n\n if (!result?.isSuccess) throw new Error('Failed to create merchant budget')\n },\n\n /** `PUT merchant_budgets/:guid` setting `amount`. */\n updateMerchantBudget: async (ctx) => {\n const guid = requireParam<string>(ctx, 'merchantBudgetGuid')\n const amount = requireParam<number>(ctx, 'amount')\n const merchantBudget = findOrThrow(\n ctx.stores.budgetsStore.merchantBudgets,\n (mb) => mb.guid === guid,\n `Merchant budget ${guid}`,\n )\n const result = await ctx.stores.budgetsStore.updateMerchantBudget({\n ...merchantBudget,\n amount,\n } as MerchantBudget)\n\n if (!result?.isSuccess) throw new Error('Failed to update merchant budget')\n },\n\n /** `DELETE merchant_budgets/:guid`. */\n deleteMerchantBudget: async (ctx) => {\n const result = await ctx.stores.budgetsStore.deleteMerchantBudget(\n requireParam<string>(ctx, 'merchantBudgetGuid'),\n )\n\n if (!result?.isSuccess) throw new Error('Failed to delete merchant budget')\n },\n\n /**\n * `PUT transactions/:guid` merging `params.fields` (category_guid, date, memo,\n * description, is_hidden...). Resolves the transaction from `params.transactionGuid`,\n * else the beat's primary transaction guid.\n */\n updateTransactionField: async (ctx) => {\n const { beat, stores } = ctx\n const guid = param<string>(ctx, 'transactionGuid') ?? beat.primary_transaction_guid\n\n if (!guid) throw new Error('No transaction guid for beat')\n\n const transaction = findOrThrow(\n stores.transactionStore.transactions,\n (t) => t.guid === guid,\n `Transaction ${guid}`,\n )\n\n const ok = await stores.transactionStore.updateTransaction({\n ...transaction,\n ...requireFields(ctx),\n } as Transaction)\n\n if (!ok) throw new Error('Failed to update transaction')\n },\n\n /** `POST`/`PUT transaction_rules` so `params.categoryGuid` applies to future matches. */\n applyTransactionRule: async (ctx) => {\n const { beat, stores } = ctx\n const categoryGuid = requireParam<string>(ctx, 'categoryGuid')\n const guid = param<string>(ctx, 'transactionGuid') ?? beat.primary_transaction_guid\n\n if (!guid) throw new Error('No transaction guid for beat')\n\n const transaction = findOrThrow(\n stores.transactionStore.transactions,\n (t) => t.guid === guid,\n `Transaction ${guid}`,\n )\n\n const ok = await stores.transactionStore.addOrUpdateTransactionRule(categoryGuid, transaction)\n\n if (!ok) throw new Error('Failed to save transaction rule')\n },\n\n /** Merges `params.fields` into beat context; `params.markCtaClicked` records `cta_clicked_at`. */\n updateBeatContext: async (ctx) => {\n const { beat, hostActions, stores } = ctx\n stores.insightsV2Store.setBeatContext(beat.guid, requireFields(ctx))\n\n if (!param<boolean>(ctx, 'markCtaClicked') || beat.cta_clicked_at) return\n\n // Fire-and-forget, like the runner's markCtaClicked: a failed write must not fail the press.\n Promise.resolve()\n .then(() =>\n hostActions.onCtaAction?.({ beatGuid: beat.guid, name: HOST_ACTIONS.markCtaClicked }),\n )\n .catch((error) =>\n stores.captureException(error, {\n store: 'ctaActions',\n template: beat.template,\n handler: 'updateBeatContext',\n }),\n )\n },\n\n // Hands a host-owned effect to the app via beatActions.onCtaAction.\n delegateToHost: async (ctx) => {\n const { hostAction, ...rest } = ctx.params\n const name = typeof hostAction === 'string' ? hostAction : ''\n\n if (!name) throw new Error('delegateToHost requires params.hostAction')\n if (!ctx.hostActions.onCtaAction) {\n throw new Error(`Host does not implement onCtaAction (needed for \"${name}\")`)\n }\n\n await ctx.hostActions.onCtaAction({ beatGuid: ctx.beat.guid, name, params: rest })\n },\n} satisfies Record<string, CtaHandler>\n\n/** A registered handler name. */\nexport type CtaHandlerName = keyof typeof ctaHandlers\n"],"mappings":";AAOA,IAAM,IAAA,CAAY,GAAiB,MAA+B,EAAI,OAAO,CAAA,GAEvE,IAAA,CAAmB,GAAiB,MAAmB;AAC3D,QAAM,IAAQ,EAAS,GAAK,CAAG;AAE/B,MAA2B,KAAU,QAAQ,MAAU,GACrD,OAAM,IAAI,MAAM,+BAA+B,CAAA,EAAK;AAGtD,SAAO;AACT,GAGM,IAAA,CAAiB,MAA6C;AAClE,QAAM,IAAS,EAA+B,GAAK,QAAQ;AAE3D,MAAI,CAAC,KAAU,OAAO,KAAK,CAAM,EAAE,WAAW,EAC5C,OAAM,IAAI,MAAM,oCAAoC;AAGtD,QAAM,IAAU,OAAO,KAAK,CAAM,EAAE,OAAA,CAAQ,MAAU,EAAO,CAAA,MAAW,MAAS;AAEjF,MAAI,EAAQ,SAAS,EACnB,OAAM,IAAI,MAAM,2CAA2C,EAAQ,KAAK,IAAI,CAAA,EAAG;AAGjF,SAAO;AACT,GAEM,IAAA,CAAkB,GAAY,GAAiC,MAAoB;AACvF,QAAM,IAAQ,EAAM,KAAK,CAAS;AAElC,MAAI,CAAC,EAAO,OAAM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,IAAI,MAAM,8BAA8B;AAEzD,UAAM,IAAc,EAClB,EAAO,iBAAiB,cAAA,CACvB,MAAM,EAAE,SAAS,GAClB,eAAe,CAAA,EACjB;AAIA,QAAI,CAAC,MAFY,EAAO,iBAAiB,2BAA2B,GAAc,CAAW,EAEpF,OAAM,IAAI,MAAM,iCAAiC;AAAA,EAC5D;AAAA,EAGA,mBAAmB,OAAO,MAAQ;AAChC,UAAM,EAAE,MAAA,GAAM,aAAA,GAAa,QAAA,EAAA,IAAW;AAGtC,IAFA,EAAO,gBAAgB,eAAe,EAAK,MAAM,EAAc,CAAG,CAAC,GAE/D,GAAC,EAAe,GAAK,gBAAgB,KAAK,EAAK,mBAGnD,QAAQ,QAAQ,EACb,KAAA,MACC,EAAY,cAAc;AAAA,MAAE,UAAU,EAAK;AAAA,MAAM,MAAM,EAAa;AAAA,IAAe,CAAC,CACtF,EACC,MAAA,CAAO,MACN,EAAO,iBAAiB,GAAO;AAAA,MAC7B,OAAO;AAAA,MACP,UAAU,EAAK;AAAA,MACf,SAAS;AAAA,IACX,CAAC,CACH;AAAA,EACJ;AAAA,EAGA,gBAAgB,OAAO,MAAQ;AAC7B,UAAM,EAAE,YAAA,GAAY,GAAG,EAAA,IAAS,EAAI,QAC9B,IAAO,OAAO,KAAe,WAAW,IAAa;AAE3D,QAAI,CAAC,EAAM,OAAM,IAAI,MAAM,2CAA2C;AACtE,QAAI,CAAC,EAAI,YAAY,YACnB,OAAM,IAAI,MAAM,oDAAoD,CAAA,IAAQ;AAG9E,UAAM,EAAI,YAAY,YAAY;AAAA,MAAE,UAAU,EAAI,KAAK;AAAA,MAAM,MAAA;AAAA,MAAM,QAAQ;AAAA,IAAK,CAAC;AAAA,EACnF;AACF"}
1
+ {"version":3,"file":"ctaHandlers.es.js","names":[],"sources":["../../../src/insights-v2/ctaActions/ctaHandlers.ts"],"sourcesContent":["import type { Account, Budget, MerchantBudget, Transaction, UserInsightProfile } from '../../core'\nimport { answerFeedbackSurvey } from './feedbackSurvey'\nimport { HOST_ACTIONS } from './hostActions'\nimport type { CtaContext, CtaHandler } from './types'\n\n// Step side effects: call stores, throw on failure, read ctx.params.\n// Host-owned effects (beat endpoints, spending plan) use delegateToHost.\n\nconst param = <T>(ctx: CtaContext, key: string): T | undefined => ctx.params[key] as T | undefined\n\nconst requireParam = <T>(ctx: CtaContext, key: string): T => {\n const value = param<T>(ctx, key)\n\n if (value === undefined || value === null || value === '') {\n throw new Error(`CTA handler requires params.${key}`)\n }\n\n return value\n}\n\n// The write set under params.fields; throws if a pick is missing.\nconst requireFields = (ctx: CtaContext): Record<string, unknown> => {\n const fields = param<Record<string, unknown>>(ctx, 'fields')\n\n if (!fields || Object.keys(fields).length === 0) {\n throw new Error('CTA handler requires params.fields')\n }\n\n const missing = Object.keys(fields).filter((field) => fields[field] === undefined)\n\n if (missing.length > 0) {\n throw new Error(`CTA handler could not resolve field(s): ${missing.join(', ')}`)\n }\n\n return fields\n}\n\nconst findOrThrow = <T>(items: T[], predicate: (item: T) => boolean, what: string): T => {\n const found = items.find(predicate)\n\n if (!found) throw new Error(`${what} not found in store`)\n\n return found\n}\n\nexport const ctaHandlers = {\n /** `PUT user_insight_profile` (designate emergency savings, thresholds, safety net). */\n updateUserInsightProfile: async (ctx) => {\n await ctx.stores.userStore.updateUserInsightProfile(\n requireFields(ctx) as Partial<UserInsightProfile>,\n )\n },\n\n /** `PUT offers/:guid` flagging a marketing offer as clicked. */\n markOfferClicked: async ({ beat, stores }) => {\n await stores.beatStore.updateOffer({ ...beat, has_been_clicked: true } as typeof beat)\n },\n\n /**\n * `PUT repeating_transactions/:guid` writing `user_response`. Resolves the repeating\n * transaction from `params.repeatingTransactionGuid`, else the beat's primary transaction.\n */\n updateRepeatingTransactionResponse: async (ctx) => {\n const { beat, stores } = ctx\n const userResponse = requireParam<string>(ctx, 'userResponse')\n const guid =\n param<string>(ctx, 'repeatingTransactionGuid') ??\n beat.primary_transaction?.repeating_transaction_guid\n\n if (!guid) throw new Error('No repeating transaction guid for beat')\n\n const repeating = findOrThrow(\n stores.recurringTransactionsStore.repeatingTransactions,\n (rt) => rt.guid === guid,\n `Repeating transaction ${guid}`,\n )\n const ok = await stores.recurringTransactionsStore.updateRepeatingTransaction({\n ...repeating,\n user_response: userResponse,\n })\n\n if (!ok) throw new Error('Failed to update repeating transaction')\n },\n\n /** `PUT accounts/:guid` merging `params.fields`; `params.accountGuid` picks the account, else the beat's primary. */\n updateAccountField: async (ctx) => {\n const { beat, stores } = ctx\n const guid = param<string>(ctx, 'accountGuid') ?? beat.primary_account_guid\n\n if (!guid) throw new Error('No account guid for beat')\n\n const account = findOrThrow(\n stores.accountStore.accounts,\n (a) => a.guid === guid,\n `Account ${guid}`,\n )\n\n const ok = await stores.accountStore.updateAccount({\n ...account,\n ...requireFields(ctx),\n } as Account)\n\n if (!ok) throw new Error('Failed to update account')\n },\n\n /** `PUT notification_profiles/:guid` setting `threshold` on the named profile. */\n updateNotificationProfileThreshold: async (ctx) => {\n const profileGuid = requireParam<string>(ctx, 'profileGuid')\n const threshold = requireParam<number>(ctx, 'threshold')\n const profile = findOrThrow(\n ctx.stores.settingsStore.notificationProfiles,\n (p) => p.guid === profileGuid,\n `Notification profile ${profileGuid}`,\n )\n\n const ok = await ctx.stores.settingsStore.updateNotificationProfile({ ...profile, threshold })\n\n if (!ok) throw new Error('Failed to update notification profile')\n },\n\n /**\n * `POST budgets` for `params.categoryGuid` with `params.amount` (+ optional parentGuid). A subcategory budget\n * shows on the Budgets screen only under its parent's budget, so one is found or created first.\n */\n createBudget: async (ctx) => {\n const categoryGuid = requireParam<string>(ctx, 'categoryGuid')\n const amount = requireParam<number>(ctx, 'amount')\n const { budgetsStore, categoryStore } = ctx.stores\n const category = findOrThrow(\n categoryStore.categories,\n (c) => c.guid === categoryGuid,\n `Category ${categoryGuid}`,\n )\n\n let parentGuid = param<string | null>(ctx, 'parentGuid') ?? null\n if (!parentGuid && category.parent_guid) {\n if (!budgetsStore.isDataLoaded) await budgetsStore.loadBudgets()\n const parentCategoryGuid = category.parent_guid\n const parentBudgetGuid = () =>\n budgetsStore.budgets.find((b) => b.category_guid === parentCategoryGuid && !b.parent_guid)\n ?.guid\n\n let createdParentGuid: string | undefined\n if (!parentBudgetGuid()) {\n const parent = findOrThrow(\n categoryStore.categories,\n (c) => c.guid === parentCategoryGuid,\n `Category ${parentCategoryGuid}`,\n )\n // The screen shows a parent with sub-budgets as their sum, so its own amount is a placeholder.\n if (!(await budgetsStore.addBudget(parent, amount, null))) {\n throw new Error('Failed to create budget')\n }\n createdParentGuid = parentBudgetGuid()\n }\n parentGuid = parentBudgetGuid() ?? null\n // A sub-budget saved without its parent never shows on the Budgets screen.\n if (!parentGuid) throw new Error('Parent budget not found after creating it')\n\n if (!(await budgetsStore.addBudget(category, amount, parentGuid))) {\n // Undo a parent made only for this sub-budget, so a failure leaves nothing behind.\n if (createdParentGuid) await budgetsStore.deleteBudget(createdParentGuid)\n throw new Error('Failed to create budget')\n }\n return\n }\n\n if (!(await budgetsStore.addBudget(category, amount, parentGuid))) {\n throw new Error('Failed to create budget')\n }\n },\n\n /** `PUT budgets/:guid` setting `amount`. */\n updateBudget: async (ctx) => {\n const budgetGuid = requireParam<string>(ctx, 'budgetGuid')\n const amount = requireParam<number>(ctx, 'amount')\n const budget = findOrThrow(\n ctx.stores.budgetsStore.budgets,\n (b) => b.guid === budgetGuid,\n `Budget ${budgetGuid}`,\n )\n const ok = await ctx.stores.budgetsStore.updateBudget({ ...budget, amount } as Budget)\n\n if (!ok) throw new Error('Failed to update budget')\n },\n\n /** `DELETE budgets/:guid`. */\n deleteBudget: async (ctx) => {\n const ok = await ctx.stores.budgetsStore.deleteBudget(requireParam<string>(ctx, 'budgetGuid'))\n\n if (!ok) throw new Error('Failed to delete budget')\n },\n\n /** `POST merchant_budgets`. */\n createMerchantBudget: async (ctx) => {\n const result = await ctx.stores.budgetsStore.addMerchantBudget(\n requireParam<string>(ctx, 'merchantGuid'),\n requireParam<number>(ctx, 'amount'),\n )\n\n if (!result?.isSuccess) throw new Error('Failed to create merchant budget')\n },\n\n /** `PUT merchant_budgets/:guid` setting `amount`. */\n updateMerchantBudget: async (ctx) => {\n const guid = requireParam<string>(ctx, 'merchantBudgetGuid')\n const amount = requireParam<number>(ctx, 'amount')\n const merchantBudget = findOrThrow(\n ctx.stores.budgetsStore.merchantBudgets,\n (mb) => mb.guid === guid,\n `Merchant budget ${guid}`,\n )\n const result = await ctx.stores.budgetsStore.updateMerchantBudget({\n ...merchantBudget,\n amount,\n } as MerchantBudget)\n\n if (!result?.isSuccess) throw new Error('Failed to update merchant budget')\n },\n\n /** `DELETE merchant_budgets/:guid`. */\n deleteMerchantBudget: async (ctx) => {\n const result = await ctx.stores.budgetsStore.deleteMerchantBudget(\n requireParam<string>(ctx, 'merchantBudgetGuid'),\n )\n\n if (!result?.isSuccess) throw new Error('Failed to delete merchant budget')\n },\n\n /**\n * `PUT transactions/:guid` merging `params.fields` (category_guid, date, memo,\n * description, is_hidden...). Resolves the transaction from `params.transactionGuid`,\n * else the beat's primary transaction guid.\n */\n updateTransactionField: async (ctx) => {\n const { beat, stores } = ctx\n const guid = param<string>(ctx, 'transactionGuid') ?? beat.primary_transaction_guid\n\n if (!guid) throw new Error('No transaction guid for beat')\n\n const transaction = findOrThrow(\n stores.transactionStore.transactions,\n (t) => t.guid === guid,\n `Transaction ${guid}`,\n )\n\n const ok = await stores.transactionStore.updateTransaction({\n ...transaction,\n ...requireFields(ctx),\n } as Transaction)\n\n if (!ok) throw new Error('Failed to update transaction')\n },\n\n /** `POST`/`PUT transaction_rules` so `params.categoryGuid` applies to future matches. */\n applyTransactionRule: async (ctx) => {\n const { beat, stores } = ctx\n const categoryGuid = requireParam<string>(ctx, 'categoryGuid')\n const guid = param<string>(ctx, 'transactionGuid') ?? beat.primary_transaction_guid\n\n if (!guid) throw new Error('No transaction guid for beat')\n\n const transaction = findOrThrow(\n stores.transactionStore.transactions,\n (t) => t.guid === guid,\n `Transaction ${guid}`,\n )\n\n const ok = await stores.transactionStore.addOrUpdateTransactionRule(categoryGuid, transaction)\n\n if (!ok) throw new Error('Failed to save transaction rule')\n },\n\n /** Merges `params.fields` into beat context; `params.markCtaClicked` records `cta_clicked_at`. */\n updateBeatContext: async (ctx) => {\n const { beat, hostActions, stores } = ctx\n stores.insightsV2Store.setBeatContext(beat.guid, requireFields(ctx))\n\n if (!param<boolean>(ctx, 'markCtaClicked') || beat.cta_clicked_at) return\n\n // Fire-and-forget, like the runner's markCtaClicked: a failed write must not fail the press.\n Promise.resolve()\n .then(() =>\n hostActions.onCtaAction?.({ beatGuid: beat.guid, name: HOST_ACTIONS.markCtaClicked }),\n )\n .catch((error) =>\n stores.captureException(error, {\n store: 'ctaActions',\n template: beat.template,\n handler: 'updateBeatContext',\n }),\n )\n },\n\n answerFeedbackSurvey,\n\n // Hands a host-owned effect to the app via beatActions.onCtaAction.\n delegateToHost: async (ctx) => {\n const { hostAction, ...rest } = ctx.params\n const name = typeof hostAction === 'string' ? hostAction : ''\n\n if (!name) throw new Error('delegateToHost requires params.hostAction')\n if (!ctx.hostActions.onCtaAction) {\n throw new Error(`Host does not implement onCtaAction (needed for \"${name}\")`)\n }\n\n await ctx.hostActions.onCtaAction({ beatGuid: ctx.beat.guid, name, params: rest })\n },\n} satisfies Record<string, CtaHandler>\n\n/** A registered handler name. */\nexport type CtaHandlerName = keyof typeof ctaHandlers\n"],"mappings":";;AAQA,IAAM,IAAA,CAAY,GAAiB,MAA+B,EAAI,OAAO,CAAA,GAEvE,IAAA,CAAmB,GAAiB,MAAmB;AAC3D,QAAM,IAAQ,EAAS,GAAK,CAAG;AAE/B,MAA2B,KAAU,QAAQ,MAAU,GACrD,OAAM,IAAI,MAAM,+BAA+B,CAAA,EAAK;AAGtD,SAAO;AACT,GAGM,IAAA,CAAiB,MAA6C;AAClE,QAAM,IAAS,EAA+B,GAAK,QAAQ;AAE3D,MAAI,CAAC,KAAU,OAAO,KAAK,CAAM,EAAE,WAAW,EAC5C,OAA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F,OAAM,IAAI,MAAM,iCAAiC;AAAA,EAC5D;AAAA,EAGA,mBAAmB,OAAO,MAAQ;AAChC,UAAM,EAAE,MAAA,GAAM,aAAA,GAAa,QAAA,EAAA,IAAW;AAGtC,IAFA,EAAO,gBAAgB,eAAe,EAAK,MAAM,EAAc,CAAG,CAAC,GAE/D,GAAC,EAAe,GAAK,gBAAgB,KAAK,EAAK,mBAGnD,QAAQ,QAAQ,EACb,KAAA,MACC,EAAY,cAAc;AAAA,MAAE,UAAU,EAAK;AAAA,MAAM,MAAM,EAAa;AAAA,IAAe,CAAC,CACtF,EACC,MAAA,CAAO,MACN,EAAO,iBAAiB,GAAO;AAAA,MAC7B,OAAO;AAAA,MACP,UAAU,EAAK;AAAA,MACf,SAAS;AAAA,IACX,CAAC,CACH;AAAA,EACJ;AAAA,EAEA,sBAAA;AAAA,EAGA,gBAAgB,OAAO,MAAQ;AAC7B,UAAM,EAAE,YAAA,GAAY,GAAG,EAAA,IAAS,EAAI,QAC9B,IAAO,OAAO,KAAe,WAAW,IAAa;AAE3D,QAAI,CAAC,EAAM,OAAM,IAAI,MAAM,2CAA2C;AACtE,QAAI,CAAC,EAAI,YAAY,YACnB,OAAM,IAAI,MAAM,oDAAoD,CAAA,IAAQ;AAG9E,UAAM,EAAI,YAAY,YAAY;AAAA,MAAE,UAAU,EAAI,KAAK;AAAA,MAAM,MAAA;AAAA,MAAM,QAAQ;AAAA,IAAK,CAAC;AAAA,EACnF;AACF"}
@@ -1,35 +1,35 @@
1
- import { AccountType as l } from "../../core/types/Account.es.js";
2
- import { BEAT_OPERATION_1 as r, BEAT_OPERATION_2 as d } from "../../common/utils/PostMessage.es.js";
1
+ import { AccountType as d } from "../../core/types/Account.es.js";
2
+ import { BEAT_OPERATION_1 as o, BEAT_OPERATION_2 as l } from "../../common/utils/PostMessage.es.js";
3
3
  import { resolveOverdraftFacts as _ } from "../actionBlocks/OverdraftBlock/layout.es.js";
4
- var s = (a) => !a.is_hidden && !a.is_deleted && !a.is_closed, e = ({ beat: a, stores: t }) => a.primary_account ?? t.accountStore.accounts.find((n) => n.guid === a.primary_account_guid), p = ({ beat: a, stores: t }) => {
4
+ var u = (a) => !a.is_hidden && !a.is_deleted && !a.is_closed, r = ({ beat: a, stores: t }) => a.primary_account ?? t.accountStore.accounts.find((n) => n.guid === a.primary_account_guid), p = ({ beat: a, stores: t }) => {
5
5
  const n = new Set(a.account_guids);
6
- return t.accountStore.accounts.filter((o) => n.has(o.guid) && s(o));
7
- }, m = ({ stores: a }) => a.accountStore.accounts.filter((t) => t.account_type === l.SAVINGS && s(t)), i = { primary: () => ({ action: r }) }, c = { primary: (a) => {
8
- const t = e(a)?.external_guid, { amount: n } = _(a.beat);
6
+ return t.accountStore.accounts.filter((e) => n.has(e.guid) && u(e));
7
+ }, g = ({ stores: a }) => a.accountStore.accounts.filter((t) => t.account_type === d.SAVINGS && u(t)), i = { primary: () => ({ action: o }) }, c = { primary: (a) => {
8
+ const t = r(a)?.external_guid, { amount: n } = _(a.beat);
9
9
  return !t || n === void 0 ? null : {
10
- action: r,
10
+ action: o,
11
11
  payload: {
12
12
  projected_overdraft_amount: n,
13
13
  destination_account_ids: [t],
14
14
  destination_account_id: t
15
15
  }
16
16
  };
17
- } }, y = {
17
+ } }, m = {
18
18
  SaveAnExtra100Dollars: i,
19
19
  SaveAnExtra100DollarsV2: i,
20
- PaydayCashLeftOverStatus: { primary: () => ({ action: r }) },
21
- EmergencyFundWithdrawal: { primary: () => ({ action: r }) },
20
+ PaydayCashLeftOverStatus: { primary: () => ({ action: o }) },
21
+ EmergencyFundWithdrawal: { primary: () => ({ action: o }) },
22
22
  LowAccountBalance: { primary: (a) => {
23
- const t = e(a);
23
+ const t = r(a);
24
24
  return t ? {
25
- action: r,
25
+ action: o,
26
26
  payload: { account_guid: t.external_guid }
27
27
  } : null;
28
28
  } },
29
- MonthlyObligationsStatus: { primary: ({ beat: a }) => (a.payload?.total_remaining ?? 0) < 0 ? { action: r } : null },
30
- DesignateEmergencySavingsAccount: { primary: ({ cta: a }) => a.action_key === "open_savings_account" ? { action: r } : null },
29
+ MonthlyObligationsStatus: { primary: ({ beat: a }) => (a.payload?.total_remaining ?? 0) < 0 ? { action: o } : null },
30
+ DesignateEmergencySavingsAccount: { primary: ({ cta: a }) => a.action_key === "open_savings_account" ? { action: o } : null },
31
31
  ReplenishSavings: { primary: (a) => ({
32
- action: r,
32
+ action: o,
33
33
  payload: {
34
34
  total_amount_withdrawn: a.beat.payload?.total_amount,
35
35
  accounts: p(a).map((t) => ({
@@ -40,27 +40,44 @@ var s = (a) => !a.is_hidden && !a.is_deleted && !a.is_closed, e = ({ beat: a, st
40
40
  }) },
41
41
  TransparentOverdraft: c,
42
42
  TransparentOverdraftV2: c,
43
+ UnifiedDepositEmergencyFund: { primary: ({ cta: a }) => {
44
+ const t = a.post_message_metadata, n = t?.action, e = t?.account_guid;
45
+ return !n || !e ? null : {
46
+ action: n,
47
+ payload: {
48
+ account_guid: e,
49
+ goal_guid: t?.goal_guid ?? ""
50
+ }
51
+ };
52
+ } },
53
+ GreenStatementFeeV2: { primary: ({ cta: a }) => {
54
+ const { action: t, account_guid: n } = a.post_message_metadata ?? {};
55
+ return typeof t == "string" && t && typeof n == "string" && n ? {
56
+ action: t,
57
+ payload: { account_guid: n }
58
+ } : null;
59
+ } },
43
60
  SavingsOpportunityV2: { primary: (a) => {
44
- const t = e(a);
61
+ const t = r(a);
45
62
  if (!t) return null;
46
- const n = m(a), o = {
63
+ const n = g(a), e = {
47
64
  amount: a.beat.payload?.suggested_savings_amount,
48
65
  source_account_id: t.external_guid
49
66
  };
50
67
  return n.length ? {
51
- action: r,
68
+ action: o,
52
69
  payload: {
53
- ...o,
54
- destination_account_ids: n.map((u) => u.external_guid)
70
+ ...e,
71
+ destination_account_ids: n.map((s) => s.external_guid)
55
72
  }
56
73
  } : {
57
- action: d,
58
- payload: o
74
+ action: l,
75
+ payload: e
59
76
  };
60
77
  } }
61
- }, A = (a) => a.cta.metadata ?? y[a.beat.template]?.[a.slot]?.(a) ?? null;
78
+ }, A = (a) => a.cta.metadata ?? m[a.beat.template]?.[a.slot]?.(a) ?? null;
62
79
  export {
63
- y as ctaPostMessages,
80
+ m as ctaPostMessages,
64
81
  A as resolveCtaMetadata
65
82
  };
66
83
 
@@ -1 +1 @@
1
- {"version":3,"file":"ctaPostMessages.es.js","names":[],"sources":["../../../src/insights-v2/ctaActions/ctaPostMessages.ts"],"sourcesContent":["import { BEAT_OPERATION_1, BEAT_OPERATION_2 } from '../../common/utils/PostMessage'\nimport { AccountType, type Account, type CtaPostMessageMetadata } from '../../core'\nimport { resolveOverdraftFacts } from '../actionBlocks/OverdraftBlock/layout'\nimport type { CtaSlot, CtaStateContext } from './types'\n\n/**\n * Interim per-template post messages, carried over from the pulse beats, for CTAs the backend\n * does not yet describe with `cta.metadata`. Each resolver returns the same shape the backend\n * will send, or `null` for \"no message\" (the default then only opens the drawer for a block).\n * Backend `metadata` always wins, so entries become dead the moment tupac ships the key for\n * their template.\n *\n * Remove once every template here has `metadata` from the backend: delete this file, its test\n * and README section, and the `resolveCtaMetadata` call in `runCtaAction.ts`.\n */\nexport type CtaPostMessageResolver = (ctx: CtaStateContext) => CtaPostMessageMetadata | null\n\ntype BeatContext = Pick<CtaStateContext, 'beat' | 'stores'>\n\nconst isUsable = (account: Account) =>\n !account.is_hidden && !account.is_deleted && !account.is_closed\n\n/** The beat's primary account: from the beat when the host attached it, else the account store. */\nconst primaryAccountOf = ({ beat, stores }: BeatContext): Account | undefined =>\n beat.primary_account ??\n stores.accountStore.accounts.find((account) => account.guid === beat.primary_account_guid)\n\n/** The accounts the beat points at (`account_guids`), as loaded in the account store. */\nconst beatAccountsOf = ({ beat, stores }: BeatContext): Account[] => {\n const guids = new Set<string>(beat.account_guids)\n\n return stores.accountStore.accounts.filter(\n (account) => guids.has(account.guid) && isUsable(account),\n )\n}\n\nconst savingsAccountsOf = ({ stores }: BeatContext): Account[] =>\n stores.accountStore.accounts.filter(\n (account) => account.account_type === AccountType.SAVINGS && isUsable(account),\n )\n\n/** \"Make Transfer\": the base `beat/cta` op_1, nothing beat-specific. */\nconst saveAnExtra100Dollars: Partial<Record<CtaSlot, CtaPostMessageResolver>> = {\n primary: () => ({ action: BEAT_OPERATION_1 }),\n}\n\n/**\n * \"Transfer funds\": op_1 with the projected overdraft and the primary account's external id, sent\n * twice because the beat only ever has one account: hosts read the legacy `destination_account_ids`\n * list or the newer `destination_account_id`. Money movement, so no message without both the amount\n * and a destination id → default.\n */\nconst overdraft: Partial<Record<CtaSlot, CtaPostMessageResolver>> = {\n primary: (ctx) => {\n const destination = primaryAccountOf(ctx)?.external_guid\n const { amount } = resolveOverdraftFacts(ctx.beat)\n\n if (!destination || amount === undefined) return null\n\n return {\n action: BEAT_OPERATION_1,\n payload: {\n projected_overdraft_amount: amount,\n destination_account_ids: [destination],\n destination_account_id: destination,\n },\n }\n },\n}\n\nexport const ctaPostMessages: Record<string, Partial<Record<CtaSlot, CtaPostMessageResolver>>> = {\n SaveAnExtra100Dollars: saveAnExtra100Dollars,\n /** The Insights 2.0 template: the same \"Make a Transfer\" op_1 as V1. */\n SaveAnExtra100DollarsV2: saveAnExtra100Dollars,\n\n /** \"Transfer to Savings\" / \"Transfer Funds\": the base `beat/cta` op_1 on both variants. */\n PaydayCashLeftOverStatus: {\n primary: () => ({ action: BEAT_OPERATION_1 }),\n },\n\n /**\n * \"Make a Transfer\" / \"View Emergency Savings\": both deep-link into online banking through the\n * base `beat/cta` op_1 (the label differs by variant, the action does not, as in V1). The\n * secondary \"View Transaction\" opens the transaction-details drilldown, not a post message.\n */\n EmergencyFundWithdrawal: {\n primary: () => ({ action: BEAT_OPERATION_1 }),\n },\n\n /** \"Transfer\": op_1 with the primary account's external id. No primary account → default. */\n LowAccountBalance: {\n primary: (ctx) => {\n const account = primaryAccountOf(ctx)\n\n return account\n ? { action: BEAT_OPERATION_1, payload: { account_guid: account.external_guid } }\n : null\n },\n },\n\n /** Posts only while off track (negative remaining); on track the CTA opens the drawer. */\n MonthlyObligationsStatus: {\n primary: ({ beat }) =>\n (beat.payload?.total_remaining ?? 0) < 0 ? { action: BEAT_OPERATION_1 } : null,\n },\n\n /**\n * \"Open a Savings Account\": op_1 for the open_savings_account press only. The backend names that\n * key on the open_account state (no designation and no savings account — pulse's legacy branch),\n * so the frontend repeats no data rule and it holds on every widget. \"Save\"\n * (select_savings_account) saves the pick through ctaConfig instead; the saved state has no press.\n */\n DesignateEmergencySavingsAccount: {\n primary: ({ cta }) =>\n cta.action_key === 'open_savings_account' ? { action: BEAT_OPERATION_1 } : null,\n },\n\n /** op_1 with the withdrawn total and the beat's accounts (external ids). */\n ReplenishSavings: {\n primary: (ctx) => ({\n action: BEAT_OPERATION_1,\n payload: {\n total_amount_withdrawn: ctx.beat.payload?.total_amount,\n accounts: beatAccountsOf(ctx).map((account) => ({\n account_guid: account.external_guid,\n account_name: ctx.beat.payload?.account_name?.default,\n })),\n },\n }),\n },\n\n TransparentOverdraft: overdraft,\n TransparentOverdraftV2: overdraft,\n\n /** op_1 = transfer into the user's savings accounts; op_2 = open one when there are none. */\n SavingsOpportunityV2: {\n primary: (ctx) => {\n const source = primaryAccountOf(ctx)\n\n if (!source) return null\n\n const savings = savingsAccountsOf(ctx)\n const payload = {\n amount: ctx.beat.payload?.suggested_savings_amount,\n source_account_id: source.external_guid,\n }\n\n return savings.length\n ? {\n action: BEAT_OPERATION_1,\n payload: {\n ...payload,\n destination_account_ids: savings.map((account) => account.external_guid),\n },\n }\n : { action: BEAT_OPERATION_2, payload }\n },\n },\n}\n\n/** Backend `cta.metadata` first, else this template's interim resolver for the slot, else null. */\nexport const resolveCtaMetadata = (ctx: CtaStateContext): CtaPostMessageMetadata | null =>\n ctx.cta.metadata ?? ctaPostMessages[ctx.beat.template]?.[ctx.slot]?.(ctx) ?? null\n"],"mappings":";;;AAmBA,IAAM,IAAA,CAAY,MAChB,CAAC,EAAQ,aAAa,CAAC,EAAQ,cAAc,CAAC,EAAQ,WA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import { BEAT_OPERATION_1, BEAT_OPERATION_2 } from '../../common/utils/PostMessage'\nimport { AccountType, type Account, type CtaPostMessageMetadata } from '../../core'\nimport { resolveOverdraftFacts } from '../actionBlocks/OverdraftBlock/layout'\nimport type { CtaSlot, CtaStateContext } from './types'\n\n/**\n * Interim per-template post messages, carried over from the pulse beats, for CTAs the backend\n * does not yet describe with `cta.metadata`. Each resolver returns the same shape the backend\n * will send, or `null` for \"no message\" (the default then only opens the drawer for a block).\n * Backend `metadata` always wins, so entries become dead the moment tupac ships the key for\n * their template.\n *\n * Remove once every template here has `metadata` from the backend: delete this file, its test\n * and README section, and the `resolveCtaMetadata` call in `runCtaAction.ts`.\n */\nexport type CtaPostMessageResolver = (ctx: CtaStateContext) => CtaPostMessageMetadata | null\n\ntype BeatContext = Pick<CtaStateContext, 'beat' | 'stores'>\n\nconst isUsable = (account: Account) =>\n !account.is_hidden && !account.is_deleted && !account.is_closed\n\n/** The beat's primary account: from the beat when the host attached it, else the account store. */\nconst primaryAccountOf = ({ beat, stores }: BeatContext): Account | undefined =>\n beat.primary_account ??\n stores.accountStore.accounts.find((account) => account.guid === beat.primary_account_guid)\n\n/** The accounts the beat points at (`account_guids`), as loaded in the account store. */\nconst beatAccountsOf = ({ beat, stores }: BeatContext): Account[] => {\n const guids = new Set<string>(beat.account_guids)\n\n return stores.accountStore.accounts.filter(\n (account) => guids.has(account.guid) && isUsable(account),\n )\n}\n\nconst savingsAccountsOf = ({ stores }: BeatContext): Account[] =>\n stores.accountStore.accounts.filter(\n (account) => account.account_type === AccountType.SAVINGS && isUsable(account),\n )\n\n/** \"Make Transfer\": the base `beat/cta` op_1, nothing beat-specific. */\nconst saveAnExtra100Dollars: Partial<Record<CtaSlot, CtaPostMessageResolver>> = {\n primary: () => ({ action: BEAT_OPERATION_1 }),\n}\n\n/**\n * \"Transfer funds\": op_1 with the projected overdraft and the primary account's external id, sent\n * twice because the beat only ever has one account: hosts read the legacy `destination_account_ids`\n * list or the newer `destination_account_id`. Money movement, so no message without both the amount\n * and a destination id → default.\n */\nconst overdraft: Partial<Record<CtaSlot, CtaPostMessageResolver>> = {\n primary: (ctx) => {\n const destination = primaryAccountOf(ctx)?.external_guid\n const { amount } = resolveOverdraftFacts(ctx.beat)\n\n if (!destination || amount === undefined) return null\n\n return {\n action: BEAT_OPERATION_1,\n payload: {\n projected_overdraft_amount: amount,\n destination_account_ids: [destination],\n destination_account_id: destination,\n },\n }\n },\n}\n\nexport const ctaPostMessages: Record<string, Partial<Record<CtaSlot, CtaPostMessageResolver>>> = {\n SaveAnExtra100Dollars: saveAnExtra100Dollars,\n /** The Insights 2.0 template: the same \"Make a Transfer\" op_1 as V1. */\n SaveAnExtra100DollarsV2: saveAnExtra100Dollars,\n\n /** \"Transfer to Savings\" / \"Transfer Funds\": the base `beat/cta` op_1 on both variants. */\n PaydayCashLeftOverStatus: {\n primary: () => ({ action: BEAT_OPERATION_1 }),\n },\n\n /**\n * \"Make a Transfer\" / \"View Emergency Savings\": both deep-link into online banking through the\n * base `beat/cta` op_1 (the label differs by variant, the action does not, as in V1). The\n * secondary \"View Transaction\" opens the transaction-details drilldown, not a post message.\n */\n EmergencyFundWithdrawal: {\n primary: () => ({ action: BEAT_OPERATION_1 }),\n },\n\n /** \"Transfer\": op_1 with the primary account's external id. No primary account → default. */\n LowAccountBalance: {\n primary: (ctx) => {\n const account = primaryAccountOf(ctx)\n\n return account\n ? { action: BEAT_OPERATION_1, payload: { account_guid: account.external_guid } }\n : null\n },\n },\n\n /** Posts only while off track (negative remaining); on track the CTA opens the drawer. */\n MonthlyObligationsStatus: {\n primary: ({ beat }) =>\n (beat.payload?.total_remaining ?? 0) < 0 ? { action: BEAT_OPERATION_1 } : null,\n },\n\n /**\n * \"Open a Savings Account\": op_1 for the open_savings_account press only. The backend names that\n * key on the open_account state (no designation and no savings account — pulse's legacy branch),\n * so the frontend repeats no data rule and it holds on every widget. \"Save\"\n * (select_savings_account) saves the pick through ctaConfig instead; the saved state has no press.\n */\n DesignateEmergencySavingsAccount: {\n primary: ({ cta }) =>\n cta.action_key === 'open_savings_account' ? { action: BEAT_OPERATION_1 } : null,\n },\n\n /** op_1 with the withdrawn total and the beat's accounts (external ids). */\n ReplenishSavings: {\n primary: (ctx) => ({\n action: BEAT_OPERATION_1,\n payload: {\n total_amount_withdrawn: ctx.beat.payload?.total_amount,\n accounts: beatAccountsOf(ctx).map((account) => ({\n account_guid: account.external_guid,\n account_name: ctx.beat.payload?.account_name?.default,\n })),\n },\n }),\n },\n\n TransparentOverdraft: overdraft,\n TransparentOverdraftV2: overdraft,\n\n /**\n * tupac's message for the state it labelled (op_1 / op_2 / op_3 with the account and goal, internal guids as the\n * legacy pulse card), forwarded as sent so label, op and payload have one source. No op or no account → none.\n */\n UnifiedDepositEmergencyFund: {\n primary: ({ cta }) => {\n const message = cta.post_message_metadata\n const action = message?.action\n const accountGuid = message?.account_guid\n\n if (!action || !accountGuid) return null\n\n return { action, payload: { account_guid: accountGuid, goal_guid: message?.goal_guid ?? '' } }\n },\n },\n\n /** Switch to Paperless (see README). */\n GreenStatementFeeV2: {\n primary: ({ cta }) => {\n const { action, account_guid: accountGuid } = cta.post_message_metadata ?? {}\n\n return typeof action === 'string' && action && typeof accountGuid === 'string' && accountGuid\n ? { action, payload: { account_guid: accountGuid } }\n : null\n },\n },\n\n /** op_1 = transfer into the user's savings accounts; op_2 = open one when there are none. */\n SavingsOpportunityV2: {\n primary: (ctx) => {\n const source = primaryAccountOf(ctx)\n\n if (!source) return null\n\n const savings = savingsAccountsOf(ctx)\n const payload = {\n amount: ctx.beat.payload?.suggested_savings_amount,\n source_account_id: source.external_guid,\n }\n\n return savings.length\n ? {\n action: BEAT_OPERATION_1,\n payload: {\n ...payload,\n destination_account_ids: savings.map((account) => account.external_guid),\n },\n }\n : { action: BEAT_OPERATION_2, payload }\n },\n },\n}\n\n/** Backend `cta.metadata` first, else this template's interim resolver for the slot, else null. */\nexport const resolveCtaMetadata = (ctx: CtaStateContext): CtaPostMessage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E;AAAA,MAAE,QAAA;AAAA,MAAQ,SAAS,EAAE,cAAc,EAAY;AAAA,IAAE,IACjD;AAAA,EACN,EACF;AAAA,EAGA,sBAAsB,EACpB,SAAA,CAAU,MAAQ;AAChB,UAAM,IAAS,EAAiB,CAAG;AAEnC,QAAI,CAAC,EAAQ,QAAO;AAEpB,UAAM,IAAU,EAAkB,CAAG,GAC/B,IAAU;AAAA,MACd,QAAQ,EAAI,KAAK,SAAS;AAAA,MAC1B,mBAAmB,EAAO;AAAA,IAC5B;AAEA,WAAO,EAAQ,SACX;AAAA,MACE,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,GAAG;AAAA,QACH,yBAAyB,EAAQ,IAAA,CAAK,MAAY,EAAQ,aAAa;AAAA,MACzE;AAAA,IACF,IACA;AAAA,MAAE,QAAQ;AAAA,MAAkB,SAAA;AAAA,IAAQ;AAAA,EAC1C,EACF;AACF,GAGa,IAAA,CAAsB,MACjC,EAAI,IAAI,YAAY,EAAgB,EAAI,KAAK,QAAA,IAAY,EAAI,IAAA,IAAQ,CAAG,KAAK"}
@@ -0,0 +1,9 @@
1
+ import { CtaContext, CtaStep } from './types';
2
+ /** Continue moves to the next step; Submit sends the answers once, then dismisses. */
3
+ export declare const answerFeedbackSurvey: (ctx: CtaContext) => Promise<void>;
4
+ /**
5
+ * `answer_feedback_survey`: the card CTA of a `feedback_block` survey. Continue moves through the
6
+ * steps; on the last, Submit sends the answers to PostHog and dismisses the beat, and the block shows
7
+ * the result.
8
+ */
9
+ export declare const feedbackSurveyStep: CtaStep;