@frontegg/redux-store 5.61.0 → 6.0.1-alpha.2

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 (389) hide show
  1. package/audits/AuditLogsState/index.d.ts +47 -47
  2. package/audits/AuditLogsState/index.js +28 -0
  3. package/audits/AuditLogsState/interfaces.d.ts +19 -19
  4. package/audits/AuditLogsState/interfaces.js +1 -0
  5. package/audits/AuditLogsState/saga.d.ts +2 -2
  6. package/audits/AuditLogsState/saga.js +166 -0
  7. package/audits/AuditsMetadataState/index.d.ts +35 -35
  8. package/audits/AuditsMetadataState/index.js +18 -0
  9. package/audits/AuditsMetadataState/interfaces.d.ts +17 -17
  10. package/audits/AuditsMetadataState/interfaces.js +1 -0
  11. package/audits/AuditsMetadataState/saga.d.ts +2 -2
  12. package/audits/AuditsMetadataState/saga.js +56 -0
  13. package/audits/backward-compatibility/index.d.ts +4 -4
  14. package/audits/backward-compatibility/index.js +4 -4
  15. package/audits/backward-compatibility/initialState.d.ts +2 -2
  16. package/audits/backward-compatibility/initialState.js +20 -0
  17. package/audits/backward-compatibility/interfaces.d.ts +55 -55
  18. package/audits/backward-compatibility/interfaces.js +1 -0
  19. package/audits/backward-compatibility/reducer.d.ts +35 -35
  20. package/audits/backward-compatibility/reducer.js +129 -0
  21. package/audits/backward-compatibility/saga.d.ts +1 -1
  22. package/audits/backward-compatibility/saga.js +187 -0
  23. package/audits/dummy.d.ts +10 -10
  24. package/audits/dummy.js +191 -0
  25. package/audits/index.d.ts +40 -40
  26. package/audits/index.js +18 -362
  27. package/audits/initialState.d.ts +2 -2
  28. package/audits/initialState.js +6 -0
  29. package/audits/interfaces.d.ts +6 -6
  30. package/audits/interfaces.js +1 -0
  31. package/audits/reducer.d.ts +31 -31
  32. package/audits/reducer.js +23 -0
  33. package/audits/saga.d.ts +2 -2
  34. package/audits/saga.js +9 -0
  35. package/audits/utils.d.ts +14 -14
  36. package/audits/utils.js +13 -0
  37. package/auth/AcceptInvitationState/index.d.ts +85 -85
  38. package/auth/AcceptInvitationState/index.js +20 -0
  39. package/auth/AcceptInvitationState/interfaces.d.ts +11 -11
  40. package/auth/AcceptInvitationState/interfaces.js +9 -0
  41. package/auth/AcceptInvitationState/saga.d.ts +1 -1
  42. package/auth/AcceptInvitationState/saga.js +41 -0
  43. package/auth/AccountSettingsState/index.d.ts +92 -92
  44. package/auth/AccountSettingsState/index.js +22 -0
  45. package/auth/AccountSettingsState/interfaces.d.ts +10 -10
  46. package/auth/AccountSettingsState/interfaces.js +1 -0
  47. package/auth/AccountSettingsState/saga.d.ts +2 -2
  48. package/auth/AccountSettingsState/saga.js +133 -0
  49. package/auth/ActivateState/index.d.ts +130 -130
  50. package/auth/ActivateState/index.js +35 -0
  51. package/auth/ActivateState/interfaces.d.ts +26 -26
  52. package/auth/ActivateState/interfaces.js +8 -0
  53. package/auth/ActivateState/saga.d.ts +1 -1
  54. package/auth/ActivateState/saga.js +187 -0
  55. package/auth/ApiTokensState/index.d.ts +119 -119
  56. package/auth/ApiTokensState/index.js +54 -0
  57. package/auth/ApiTokensState/interfaces.d.ts +49 -49
  58. package/auth/ApiTokensState/interfaces.js +7 -0
  59. package/auth/ApiTokensState/saga.d.ts +2 -2
  60. package/auth/ApiTokensState/saga.js +410 -0
  61. package/auth/ForgotPasswordState/index.d.ts +90 -90
  62. package/auth/ForgotPasswordState/index.js +29 -0
  63. package/auth/ForgotPasswordState/interfaces.d.ts +18 -18
  64. package/auth/ForgotPasswordState/interfaces.js +6 -0
  65. package/auth/ForgotPasswordState/saga.d.ts +8 -8
  66. package/auth/ForgotPasswordState/saga.js +83 -0
  67. package/auth/LoginState/index.d.ts +132 -144
  68. package/auth/LoginState/index.js +64 -0
  69. package/auth/LoginState/interfaces.d.ts +41 -60
  70. package/auth/LoginState/interfaces.js +17 -0
  71. package/auth/LoginState/saga.d.ts +80 -84
  72. package/auth/LoginState/saga.js +860 -0
  73. package/auth/MfaState/index.d.ts +92 -92
  74. package/auth/MfaState/index.js +28 -0
  75. package/auth/MfaState/interfaces.d.ts +12 -12
  76. package/auth/MfaState/interfaces.js +6 -0
  77. package/auth/MfaState/saga.d.ts +2 -2
  78. package/auth/MfaState/saga.js +252 -0
  79. package/auth/ProfileState/index.d.ts +90 -90
  80. package/auth/ProfileState/index.js +24 -0
  81. package/auth/ProfileState/interfaces.d.ts +9 -9
  82. package/auth/ProfileState/interfaces.js +1 -0
  83. package/auth/ProfileState/saga.d.ts +2 -2
  84. package/auth/ProfileState/saga.js +230 -0
  85. package/auth/ResetPhoneNumberState/index.d.ts +96 -96
  86. package/auth/ResetPhoneNumberState/index.js +27 -0
  87. package/auth/ResetPhoneNumberState/interfaces.d.ts +18 -18
  88. package/auth/ResetPhoneNumberState/interfaces.js +7 -0
  89. package/auth/ResetPhoneNumberState/saga.d.ts +17 -17
  90. package/auth/ResetPhoneNumberState/saga.js +127 -0
  91. package/auth/RolesState/index.d.ts +100 -100
  92. package/auth/RolesState/index.js +37 -0
  93. package/auth/RolesState/interfaces.d.ts +7 -7
  94. package/auth/RolesState/interfaces.js +1 -0
  95. package/auth/RolesState/saga.d.ts +1 -1
  96. package/auth/RolesState/saga.js +197 -0
  97. package/auth/SSOState/index.d.ts +224 -224
  98. package/auth/SSOState/index.js +83 -0
  99. package/auth/SSOState/interfaces.d.ts +92 -92
  100. package/auth/SSOState/interfaces.js +28 -0
  101. package/auth/SSOState/saga.d.ts +2 -2
  102. package/auth/SSOState/saga.js +523 -0
  103. package/auth/SSOState/saga.v2.d.ts +1 -1
  104. package/auth/SSOState/saga.v2.js +501 -0
  105. package/auth/SecurityPolicyState/index.d.ts +456 -502
  106. package/auth/SecurityPolicyState/index.js +64 -0
  107. package/auth/SecurityPolicyState/interfaces.d.ts +26 -28
  108. package/auth/SecurityPolicyState/interfaces.js +1 -0
  109. package/auth/SecurityPolicyState/saga.d.ts +18 -24
  110. package/auth/SecurityPolicyState/saga.js +464 -0
  111. package/auth/SignUp/index.d.ts +86 -86
  112. package/auth/SignUp/index.js +25 -0
  113. package/auth/SignUp/interfaces.d.ts +19 -19
  114. package/auth/SignUp/interfaces.js +6 -0
  115. package/auth/SignUp/saga.d.ts +49 -49
  116. package/auth/SignUp/saga.js +147 -0
  117. package/auth/SocialLogins/index.d.ts +91 -91
  118. package/auth/SocialLogins/index.js +26 -0
  119. package/auth/SocialLogins/interfaces.d.ts +13 -13
  120. package/auth/SocialLogins/interfaces.js +1 -0
  121. package/auth/SocialLogins/saga.d.ts +10 -10
  122. package/auth/SocialLogins/saga.js +140 -0
  123. package/auth/TeamState/index.d.ts +168 -168
  124. package/auth/TeamState/index.js +111 -0
  125. package/auth/TeamState/interfaces.d.ts +78 -78
  126. package/auth/TeamState/interfaces.js +16 -0
  127. package/auth/TeamState/saga.d.ts +2 -2
  128. package/auth/TeamState/saga.js +1123 -0
  129. package/auth/TenantsState/index.d.ts +104 -104
  130. package/auth/TenantsState/index.js +31 -0
  131. package/auth/TenantsState/interfaces.d.ts +9 -9
  132. package/auth/TenantsState/interfaces.js +1 -0
  133. package/auth/TenantsState/saga.d.ts +2 -2
  134. package/auth/TenantsState/saga.js +136 -0
  135. package/auth/dummy.d.ts +28 -28
  136. package/auth/dummy.js +250 -0
  137. package/auth/index.d.ts +378 -392
  138. package/auth/index.js +46 -4078
  139. package/auth/initialState.d.ts +3 -3
  140. package/auth/initialState.js +58 -0
  141. package/auth/interfaces.d.ts +161 -161
  142. package/auth/interfaces.js +14 -0
  143. package/auth/reducer.d.ts +356 -370
  144. package/auth/reducer.js +39 -0
  145. package/auth/saga.d.ts +2 -2
  146. package/auth/saga.js +24 -0
  147. package/auth/utils.d.ts +162 -165
  148. package/auth/utils.js +74 -0
  149. package/connectivity/ConnectivityState/index.d.ts +292 -292
  150. package/connectivity/ConnectivityState/index.js +94 -0
  151. package/connectivity/consts.d.ts +12 -12
  152. package/connectivity/consts.js +71 -0
  153. package/connectivity/index.d.ts +40 -40
  154. package/connectivity/index.js +12 -454
  155. package/connectivity/interfaces.d.ts +112 -112
  156. package/connectivity/interfaces.js +1 -0
  157. package/connectivity/reducer.d.ts +31 -31
  158. package/connectivity/reducer.js +25 -0
  159. package/connectivity/saga.d.ts +1 -1
  160. package/connectivity/saga.js +546 -0
  161. package/constants.d.ts +7 -7
  162. package/constants.js +7 -0
  163. package/helpers.d.ts +5 -5
  164. package/helpers.js +37 -0
  165. package/index.d.ts +28 -28
  166. package/index.js +17 -15
  167. package/interfaces.d.ts +15 -15
  168. package/interfaces.js +1 -0
  169. package/node/audits/AuditLogsState/index.js +43 -0
  170. package/node/audits/AuditLogsState/interfaces.js +5 -0
  171. package/node/audits/AuditLogsState/saga.js +181 -0
  172. package/node/audits/AuditsMetadataState/index.js +33 -0
  173. package/node/audits/AuditsMetadataState/interfaces.js +5 -0
  174. package/node/audits/AuditsMetadataState/saga.js +67 -0
  175. package/node/audits/backward-compatibility/index.js +52 -12
  176. package/node/audits/backward-compatibility/initialState.js +27 -0
  177. package/node/audits/backward-compatibility/interfaces.js +5 -0
  178. package/node/audits/backward-compatibility/reducer.js +144 -0
  179. package/node/audits/backward-compatibility/saga.js +199 -0
  180. package/node/audits/dummy.js +204 -0
  181. package/node/audits/index.js +124 -364
  182. package/node/audits/initialState.js +16 -0
  183. package/node/audits/interfaces.js +5 -0
  184. package/node/audits/reducer.js +37 -0
  185. package/node/audits/saga.js +21 -0
  186. package/node/audits/utils.js +25 -0
  187. package/node/auth/AcceptInvitationState/index.js +33 -0
  188. package/node/auth/AcceptInvitationState/interfaces.js +16 -0
  189. package/node/auth/AcceptInvitationState/saga.js +51 -0
  190. package/node/auth/AccountSettingsState/index.js +34 -0
  191. package/node/auth/AccountSettingsState/interfaces.js +5 -0
  192. package/node/auth/AccountSettingsState/saga.js +145 -0
  193. package/node/auth/ActivateState/index.js +48 -0
  194. package/node/auth/ActivateState/interfaces.js +15 -0
  195. package/node/auth/ActivateState/saga.js +201 -0
  196. package/node/auth/ApiTokensState/index.js +66 -0
  197. package/node/auth/ApiTokensState/interfaces.js +14 -0
  198. package/node/auth/ApiTokensState/saga.js +424 -0
  199. package/node/auth/ForgotPasswordState/index.js +42 -0
  200. package/node/auth/ForgotPasswordState/interfaces.js +13 -0
  201. package/node/auth/ForgotPasswordState/saga.js +98 -0
  202. package/node/auth/LoginState/index.js +77 -0
  203. package/node/auth/LoginState/interfaces.js +31 -0
  204. package/node/auth/LoginState/saga.js +918 -0
  205. package/node/auth/MfaState/index.js +41 -0
  206. package/node/auth/MfaState/interfaces.js +13 -0
  207. package/node/auth/MfaState/saga.js +265 -0
  208. package/node/auth/ProfileState/index.js +36 -0
  209. package/node/auth/ProfileState/interfaces.js +5 -0
  210. package/node/auth/ProfileState/saga.js +245 -0
  211. package/node/auth/ResetPhoneNumberState/index.js +40 -0
  212. package/node/auth/ResetPhoneNumberState/interfaces.js +14 -0
  213. package/node/auth/ResetPhoneNumberState/saga.js +141 -0
  214. package/node/auth/RolesState/index.js +49 -0
  215. package/node/auth/RolesState/interfaces.js +5 -0
  216. package/node/auth/RolesState/saga.js +205 -0
  217. package/node/auth/SSOState/index.js +95 -0
  218. package/node/auth/SSOState/interfaces.js +36 -0
  219. package/node/auth/SSOState/saga.js +535 -0
  220. package/node/auth/SSOState/saga.v2.js +512 -0
  221. package/node/auth/SecurityPolicyState/index.js +76 -0
  222. package/node/auth/SecurityPolicyState/interfaces.js +5 -0
  223. package/node/auth/SecurityPolicyState/saga.js +472 -0
  224. package/node/auth/SignUp/index.js +38 -0
  225. package/node/auth/SignUp/interfaces.js +13 -0
  226. package/node/auth/SignUp/saga.js +173 -0
  227. package/node/auth/SocialLogins/index.js +38 -0
  228. package/node/auth/SocialLogins/interfaces.js +5 -0
  229. package/node/auth/SocialLogins/saga.js +162 -0
  230. package/node/auth/TeamState/index.js +123 -0
  231. package/node/auth/TeamState/interfaces.js +23 -0
  232. package/node/auth/TeamState/saga.js +1118 -0
  233. package/node/auth/TenantsState/index.js +43 -0
  234. package/node/auth/TenantsState/interfaces.js +5 -0
  235. package/node/auth/TenantsState/saga.js +149 -0
  236. package/node/auth/dummy.js +284 -0
  237. package/node/auth/index.js +528 -170
  238. package/node/auth/initialState.js +86 -0
  239. package/node/auth/interfaces.js +22 -0
  240. package/node/auth/reducer.js +68 -0
  241. package/node/auth/saga.js +51 -0
  242. package/node/auth/utils.js +104 -0
  243. package/node/connectivity/ConnectivityState/index.js +107 -0
  244. package/node/connectivity/consts.js +84 -0
  245. package/node/connectivity/index.js +64 -455
  246. package/node/connectivity/interfaces.js +5 -0
  247. package/node/connectivity/reducer.js +38 -0
  248. package/node/connectivity/saga.js +560 -0
  249. package/node/{constants-52e37c08.js → constants.js} +14 -11
  250. package/node/helpers.js +57 -0
  251. package/node/index.js +120 -293
  252. package/node/interfaces.js +5 -0
  253. package/node/subscriptions/Billing/Information/index.js +42 -0
  254. package/node/subscriptions/Billing/Information/interfaces.js +5 -0
  255. package/node/subscriptions/Billing/Information/saga.js +141 -0
  256. package/node/subscriptions/Billing/Invoices/index.js +55 -0
  257. package/node/subscriptions/Billing/Invoices/interfaces.js +5 -0
  258. package/node/subscriptions/Billing/Invoices/saga.js +92 -0
  259. package/node/subscriptions/Billing/PaymentMethod/index.js +51 -0
  260. package/node/subscriptions/Billing/PaymentMethod/interfaces.js +13 -0
  261. package/node/subscriptions/Billing/PaymentMethod/saga.js +98 -0
  262. package/node/subscriptions/Billing/Subscription/index.js +53 -0
  263. package/node/subscriptions/Billing/Subscription/interfaces.js +5 -0
  264. package/node/subscriptions/Billing/Subscription/saga.js +131 -0
  265. package/node/subscriptions/Billing/index.js +38 -0
  266. package/node/subscriptions/Billing/interfaces.js +57 -0
  267. package/node/subscriptions/Billing/saga.js +25 -0
  268. package/node/subscriptions/Checkout/index.js +47 -0
  269. package/node/subscriptions/Checkout/interfaces.js +5 -0
  270. package/node/subscriptions/Checkout/saga.js +129 -0
  271. package/node/subscriptions/Config/index.js +39 -0
  272. package/node/subscriptions/Config/interfaces.js +5 -0
  273. package/node/subscriptions/Config/saga.js +71 -0
  274. package/node/subscriptions/Plans/index.js +38 -0
  275. package/node/subscriptions/Plans/interfaces.js +5 -0
  276. package/node/subscriptions/Plans/saga.js +73 -0
  277. package/node/subscriptions/Stripe/index.js +39 -0
  278. package/node/subscriptions/Stripe/interfaces.js +5 -0
  279. package/node/subscriptions/Stripe/saga.js +44 -0
  280. package/node/subscriptions/dummy.js +84 -0
  281. package/node/subscriptions/general.interfaces.js +30 -0
  282. package/node/subscriptions/index.js +70 -906
  283. package/node/subscriptions/interfaces.js +83 -0
  284. package/node/subscriptions/mapper.js +51 -0
  285. package/node/subscriptions/reducer.js +52 -0
  286. package/node/subscriptions/saga.js +27 -0
  287. package/node/subscriptions/utils.js +68 -0
  288. package/node/toolkit/index.js +163 -99
  289. package/node/toolkit/redux-saga.js +59 -0
  290. package/node/toolkit/redux.js +43 -0
  291. package/node/vendor/VendorState/index.js +26 -0
  292. package/node/vendor/index.js +66 -13
  293. package/node/vendor/interfaces.js +5 -0
  294. package/node/vendor/reducer.js +32 -0
  295. package/node/vendor/saga.js +48 -0
  296. package/package.json +12 -11
  297. package/subscriptions/Billing/Information/index.d.ts +12 -12
  298. package/subscriptions/Billing/Information/index.js +30 -0
  299. package/subscriptions/Billing/Information/interfaces.d.ts +14 -14
  300. package/subscriptions/Billing/Information/interfaces.js +1 -0
  301. package/subscriptions/Billing/Information/saga.d.ts +52 -52
  302. package/subscriptions/Billing/Information/saga.js +118 -0
  303. package/subscriptions/Billing/Invoices/index.d.ts +18 -18
  304. package/subscriptions/Billing/Invoices/index.js +44 -0
  305. package/subscriptions/Billing/Invoices/interfaces.d.ts +19 -19
  306. package/subscriptions/Billing/Invoices/interfaces.js +1 -0
  307. package/subscriptions/Billing/Invoices/saga.d.ts +13 -13
  308. package/subscriptions/Billing/Invoices/saga.js +75 -0
  309. package/subscriptions/Billing/PaymentMethod/index.d.ts +20 -20
  310. package/subscriptions/Billing/PaymentMethod/index.js +40 -0
  311. package/subscriptions/Billing/PaymentMethod/interfaces.d.ts +46 -46
  312. package/subscriptions/Billing/PaymentMethod/interfaces.js +6 -0
  313. package/subscriptions/Billing/PaymentMethod/saga.d.ts +13 -13
  314. package/subscriptions/Billing/PaymentMethod/saga.js +81 -0
  315. package/subscriptions/Billing/Subscription/index.d.ts +16 -16
  316. package/subscriptions/Billing/Subscription/index.js +42 -0
  317. package/subscriptions/Billing/Subscription/interfaces.d.ts +18 -18
  318. package/subscriptions/Billing/Subscription/interfaces.js +1 -0
  319. package/subscriptions/Billing/Subscription/saga.d.ts +13 -13
  320. package/subscriptions/Billing/Subscription/saga.js +117 -0
  321. package/subscriptions/Billing/index.d.ts +54 -54
  322. package/subscriptions/Billing/index.js +23 -0
  323. package/subscriptions/Billing/interfaces.d.ts +20 -20
  324. package/subscriptions/Billing/interfaces.js +5 -0
  325. package/subscriptions/Billing/saga.d.ts +2 -2
  326. package/subscriptions/Billing/saga.js +11 -0
  327. package/subscriptions/Checkout/index.d.ts +14 -14
  328. package/subscriptions/Checkout/index.js +36 -0
  329. package/subscriptions/Checkout/interfaces.d.ts +17 -17
  330. package/subscriptions/Checkout/interfaces.js +1 -0
  331. package/subscriptions/Checkout/saga.d.ts +5 -5
  332. package/subscriptions/Checkout/saga.js +110 -0
  333. package/subscriptions/Config/index.d.ts +10 -10
  334. package/subscriptions/Config/index.js +28 -0
  335. package/subscriptions/Config/interfaces.d.ts +16 -16
  336. package/subscriptions/Config/interfaces.js +1 -0
  337. package/subscriptions/Config/saga.d.ts +2 -2
  338. package/subscriptions/Config/saga.js +59 -0
  339. package/subscriptions/Plans/index.d.ts +10 -10
  340. package/subscriptions/Plans/index.js +25 -0
  341. package/subscriptions/Plans/interfaces.d.ts +10 -10
  342. package/subscriptions/Plans/interfaces.js +1 -0
  343. package/subscriptions/Plans/saga.d.ts +2 -2
  344. package/subscriptions/Plans/saga.js +58 -0
  345. package/subscriptions/Stripe/index.d.ts +11 -11
  346. package/subscriptions/Stripe/index.js +28 -0
  347. package/subscriptions/Stripe/interfaces.d.ts +10 -10
  348. package/subscriptions/Stripe/interfaces.js +1 -0
  349. package/subscriptions/Stripe/saga.d.ts +1 -1
  350. package/subscriptions/Stripe/saga.js +34 -0
  351. package/subscriptions/dummy.d.ts +5 -5
  352. package/subscriptions/dummy.js +72 -0
  353. package/subscriptions/general.interfaces.d.ts +49 -49
  354. package/subscriptions/general.interfaces.js +21 -0
  355. package/subscriptions/index.d.ts +100 -100
  356. package/subscriptions/index.js +13 -906
  357. package/subscriptions/interfaces.d.ts +25 -25
  358. package/subscriptions/interfaces.js +7 -0
  359. package/subscriptions/mapper.d.ts +6 -6
  360. package/subscriptions/mapper.js +36 -0
  361. package/subscriptions/reducer.d.ts +92 -92
  362. package/subscriptions/reducer.js +29 -0
  363. package/subscriptions/saga.d.ts +2 -2
  364. package/subscriptions/saga.js +12 -0
  365. package/subscriptions/utils.d.ts +68 -68
  366. package/subscriptions/utils.js +52 -0
  367. package/toolkit/index.d.ts +24 -23
  368. package/toolkit/index.js +106 -94
  369. package/toolkit/redux-saga.d.ts +4 -4
  370. package/toolkit/redux-saga.js +3 -0
  371. package/toolkit/redux.d.ts +3 -2
  372. package/toolkit/redux.js +1 -0
  373. package/vendor/VendorState/index.d.ts +20 -20
  374. package/vendor/VendorState/index.js +13 -0
  375. package/vendor/index.d.ts +17 -17
  376. package/vendor/index.js +12 -18
  377. package/vendor/interfaces.d.ts +3 -3
  378. package/vendor/interfaces.js +1 -0
  379. package/vendor/reducer.d.ts +8 -8
  380. package/vendor/reducer.js +19 -0
  381. package/vendor/saga.d.ts +8 -8
  382. package/vendor/saga.js +34 -0
  383. package/audits/backward-compatibility/package.json +0 -6
  384. package/constants-4d9682b2.js +0 -9
  385. package/node/index-5642a636.js +0 -4131
  386. package/node/index-6906e508.js +0 -151
  387. package/node/saga-b0d1a607.js +0 -230
  388. package/saga-7a267fe0.js +0 -223
  389. package/saga-b6529ffb.js +0 -36
@@ -1,906 +1,13 @@
1
- import { s as subscriptionsStoreName } from '../constants-4d9682b2.js';
2
- export { s as subscriptionsStoreName } from '../constants-4d9682b2.js';
3
- import { createSlice, createAction, combineReducers } from '@reduxjs/toolkit';
4
- import { takeEvery, select, put, call, delay, all } from 'redux-saga/effects';
5
- import { ISubscriptionStatus, PaymentMethodType as PaymentMethodType$1, api, ISubscriptionCancellationPolicy, ProviderType } from '@frontegg/rest-api';
6
-
7
- function createModuleCaseReducers() {
8
- return {
9
- setLoading: {
10
- prepare: (payload) => ({ payload }),
11
- reducer: (state, action) => (Object.assign(Object.assign(Object.assign({}, state), { loading: action.payload }), (action.payload ? { error: null } : {}))),
12
- },
13
- setError: {
14
- prepare: (payload) => ({ payload }),
15
- reducer: (state, action) => (Object.assign(Object.assign({}, state), { error: action.payload, loading: false, fetching: false })),
16
- },
17
- setState: {
18
- prepare: (payload) => ({ payload }),
19
- reducer: (state, action) => (Object.assign(Object.assign({}, state), action.payload)),
20
- },
21
- };
22
- }
23
- function createKeyCaseReducer(key, setState) {
24
- return {
25
- prepare: (payload) => ({ payload }),
26
- reducer: (state, action) => (Object.assign(Object.assign({}, state), { [key]: setState(state[key], action) })),
27
- };
28
- }
29
- function createKeyCaseLoadingReducer(key) {
30
- return createKeyCaseReducer(key, (state, action) => (Object.assign(Object.assign({}, state), { loading: action.payload })));
31
- }
32
- function createKeyCaseErrorReducer(key) {
33
- return createKeyCaseReducer(key, (state, action) => (Object.assign(Object.assign({}, state), { error: action.payload, loading: false })));
34
- }
35
-
36
- const plansInitialState = {
37
- loading: false,
38
- error: null,
39
- fetching: true,
40
- plans: [],
41
- };
42
- const { actions: sliceActions$1, reducer: reducer$8, name: name$7 } = createSlice({
43
- name: `${subscriptionsStoreName}/plans`,
44
- initialState: plansInitialState,
45
- reducers: Object.assign({}, createModuleCaseReducers()),
46
- });
47
- const actions$8 = Object.assign({ loadPlans: createAction(`${name$7}/loadPlans`) }, sliceActions$1);
48
-
49
- const configInitialState = {
50
- loading: false,
51
- error: null,
52
- fetching: true,
53
- config: null,
54
- };
55
- const reducers$6 = Object.assign({}, createModuleCaseReducers());
56
- const { actions: configActions, reducer: reducer$7, name: name$6, } = createSlice({
57
- name: `${subscriptionsStoreName}/config`,
58
- initialState: configInitialState,
59
- reducers: reducers$6,
60
- });
61
- const actions$7 = Object.assign({ loadPaymentConfiguration: createAction(`${name$6}/loadPaymentConfiguration`) }, configActions);
62
-
63
- const initialSubscriptionState = {
64
- loading: false,
65
- error: null,
66
- fetching: true,
67
- cancellation: {
68
- loading: false,
69
- error: null,
70
- },
71
- renewal: {
72
- loading: false,
73
- error: null,
74
- },
75
- };
76
- const reducers$5 = Object.assign(Object.assign({}, createModuleCaseReducers()), { setCancellationLoading: createKeyCaseLoadingReducer('cancellation'), setCancellationError: createKeyCaseErrorReducer('cancellation'), setRenewalLoading: createKeyCaseLoadingReducer('renewal'), setRenewalError: createKeyCaseErrorReducer('renewal') });
77
- const { reducer: reducer$6, actions: overviewActions$1, name: name$5, } = createSlice({
78
- name: `${subscriptionsStoreName}/billing/subscription`,
79
- initialState: initialSubscriptionState,
80
- reducers: reducers$5,
81
- });
82
- const actions$6 = Object.assign({ load: createAction(`${name$5}/loadSubscription`), cancelSubscription: createAction(`${name$5}/cancelSubscription`), renewSubscription: createAction(`${name$5}/renewSubscription`) }, overviewActions$1);
83
-
84
- const initialBillingInformationState = {
85
- loading: false,
86
- error: null,
87
- fetching: true,
88
- };
89
- const reducers$4 = Object.assign({}, createModuleCaseReducers());
90
- const { reducer: reducer$5, actions: overviewActions, name: name$4, } = createSlice({
91
- name: `${subscriptionsStoreName}/billing/information`,
92
- initialState: initialBillingInformationState,
93
- reducers: reducers$4,
94
- });
95
- const actions$5 = Object.assign({ loadBillingInformation: createAction(`${name$4}/loadBillingInformation`), cancelSubscription: actions$6.cancelSubscription, renewSubscription: actions$6.renewSubscription }, overviewActions);
96
-
97
- const initialPaymentMethodState = {
98
- loading: false,
99
- error: null,
100
- fetching: true,
101
- };
102
- const reducers$3 = Object.assign(Object.assign({}, createModuleCaseReducers()), { setState: {
103
- prepare: (payload) => ({ payload }),
104
- reducer: (state, action) => (Object.assign(Object.assign({}, state), action.payload)),
105
- } });
106
- const { reducer: reducer$4, actions: paymentActions, name: name$3, } = createSlice({
107
- name: `${subscriptionsStoreName}/billing/payment`,
108
- initialState: initialPaymentMethodState,
109
- reducers: reducers$3,
110
- });
111
- const actions$4 = Object.assign({ loadPaymentMethod: createAction(`${name$3}/loadPaymentMethod`), submitPaymentMethod: createAction(`${name$3}/submitPaymentMethod`), submitPaymentMethodError: createAction(`${name$3}/submitPaymentMethodError`), submitPaymentMethodSuccess: createAction(`${name$3}/submitPaymentMethodSuccess`), updatePaymentMethodBillingDetails: createAction(`${name$3}/updateBillingDetails`, (payload) => ({ payload })) }, paymentActions);
112
-
113
- const initialInvoicesState = {
114
- loading: false,
115
- error: null,
116
- fetching: true,
117
- invoices: [],
118
- invoiceDownload: {
119
- loading: false,
120
- error: null
121
- }
122
- };
123
- const reducers$2 = Object.assign(Object.assign({}, createModuleCaseReducers()), { setInvoiceDownloadState: {
124
- prepare: (payload) => ({ payload }),
125
- reducer: (state, action) => (Object.assign(Object.assign({}, state), { invoiceDownload: Object.assign(Object.assign({}, state.invoiceDownload), action.payload) })),
126
- } });
127
- const { reducer: reducer$3, actions: sliceActions, name: name$2, } = createSlice({
128
- name: `${subscriptionsStoreName}/billing/invoices`,
129
- initialState: initialInvoicesState,
130
- reducers: reducers$2,
131
- });
132
- const actions$3 = Object.assign({ loadInvoices: createAction(`${name$2}/loadInvoices`), downloadInvoice: createAction(`${name$2}/downloadInvoice`, (payload) => ({ payload })) }, sliceActions);
133
-
134
- const billingInitialState = {
135
- information: initialBillingInformationState,
136
- invoices: initialInvoicesState,
137
- paymentMethod: initialPaymentMethodState,
138
- subscription: initialSubscriptionState,
139
- };
140
- const billingActions = {
141
- invoices: actions$3,
142
- information: actions$5,
143
- paymentMethod: actions$4,
144
- subscription: actions$6,
145
- };
146
- const billingReducer = combineReducers({
147
- invoices: reducer$3,
148
- information: reducer$5,
149
- paymentMethod: reducer$4,
150
- subscription: reducer$6,
151
- });
152
-
153
- const checkoutInitialState = {
154
- fetching: true,
155
- loading: false,
156
- error: null,
157
- confirmed: false,
158
- };
159
- const reducers$1 = Object.assign({}, createModuleCaseReducers());
160
- const { actions: checkoutActions, reducer: reducer$2, name: name$1 } = createSlice({
161
- name: `${subscriptionsStoreName}/checkout`,
162
- initialState: checkoutInitialState,
163
- reducers: reducers$1,
164
- });
165
- const actions$2 = Object.assign({ loadCheckout: createAction(`${name$1}/loadCheckout`), resetCheckout: createAction(`${name$1}/resetCheckout`), submitCheckout: createAction(`${name$1}/submitCheckout`), confirmCheckout: createAction(`${name$1}/confirmCheckout`, (payload) => ({ payload })), errorCheckout: createAction(`${name$1}/errorCheckout`, (payload) => ({ payload })) }, checkoutActions);
166
-
167
- const initialSubscriptionStripeState = {
168
- loading: false,
169
- error: null,
170
- cardSetupIntentSecret: null,
171
- };
172
- const reducers = Object.assign({}, createModuleCaseReducers());
173
- const { reducer: reducer$1, actions: reducerActions, name, } = createSlice({
174
- name: `${subscriptionsStoreName}/stripe`,
175
- initialState: initialSubscriptionStripeState,
176
- reducers,
177
- });
178
- const actions$1 = Object.assign({ loadCustomer: createAction(`${name}/loadCustomer`), createCardSetupIntentSecret: createAction(`${name}/createCardSetupIntentSecret`) }, reducerActions);
179
-
180
- const initialState = {
181
- config: configInitialState,
182
- plans: plansInitialState,
183
- checkout: checkoutInitialState,
184
- billing: billingInitialState,
185
- stripe: initialSubscriptionStripeState,
186
- };
187
- const actions = {
188
- config: actions$7,
189
- billing: billingActions,
190
- plans: actions$8,
191
- checkout: actions$2,
192
- stripe: actions$1,
193
- };
194
- const reducer = combineReducers({
195
- config: reducer$7,
196
- billing: billingReducer,
197
- plans: reducer$8,
198
- checkout: reducer$2,
199
- stripe: reducer$1,
200
- });
201
-
202
- var PaymentProvider;
203
- (function (PaymentProvider) {
204
- PaymentProvider["STRIPE"] = "Stripe";
205
- })(PaymentProvider || (PaymentProvider = {}));
206
- var SubscriptionStatus;
207
- (function (SubscriptionStatus) {
208
- SubscriptionStatus["ACTIVE"] = "ACTIVE";
209
- SubscriptionStatus["CANCELED"] = "CANCELED";
210
- SubscriptionStatus["INCOMPLETE"] = "INCOMPLETE";
211
- SubscriptionStatus["EXPIRED"] = "EXPIRED";
212
- SubscriptionStatus["TRIALING"] = "TRIALING";
213
- })(SubscriptionStatus || (SubscriptionStatus = {}));
214
- var SubscriptionCancellationPolicy;
215
- (function (SubscriptionCancellationPolicy) {
216
- SubscriptionCancellationPolicy["AT_PERIOD_END"] = "atPeriodEnd";
217
- })(SubscriptionCancellationPolicy || (SubscriptionCancellationPolicy = {}));
218
-
219
- function toSubscriptionCancellation({ policy }) {
220
- return {
221
- policy: toSubscriptionCancellationPolicy(),
222
- };
223
- }
224
- function toSubscriptionCancellationPolicy(policy) {
225
- return SubscriptionCancellationPolicy.AT_PERIOD_END;
226
- }
227
- function toSubscriptionStatus(status) {
228
- switch (status) {
229
- case ISubscriptionStatus.ACTIVE:
230
- return SubscriptionStatus.ACTIVE;
231
- case ISubscriptionStatus.INCOMPLETE:
232
- return SubscriptionStatus.INCOMPLETE;
233
- case ISubscriptionStatus.CANCELED:
234
- return SubscriptionStatus.CANCELED;
235
- case ISubscriptionStatus.EXPIRED:
236
- return SubscriptionStatus.EXPIRED;
237
- case ISubscriptionStatus.TRIALING:
238
- return SubscriptionStatus.TRIALING;
239
- default:
240
- return SubscriptionStatus.EXPIRED;
241
- }
242
- }
243
-
244
- const subscriptionResponseMock = {
245
- id: 'sub_1JbhYVEwsu4qiqnnfMhYAdY6',
246
- externalId: 'sub_1JbhYVEwsu4qiqnnfMhYAdY6',
247
- startDate: '2021-09-20T08:08:51.000Z',
248
- status: ISubscriptionStatus.ACTIVE,
249
- externallyManaged: false,
250
- cancellation: null,
251
- currentPeriodStart: '2021-09-20T08:08:51.000Z',
252
- currentPeriodEnd: '2021-10-20T08:08:51.000Z',
253
- plan: {
254
- // TODO: fix dummy data
255
- slug: 'test'
256
- }
257
- // items: [
258
- // {
259
- // id: 'si_KGE0p5himocPXH',
260
- // externalId: 'prod_J60fUEvI7qV1eL',
261
- // planId: 'prod_J60fUEvI7qV1eL',
262
- // price: {
263
- // id: 'price_1IToe8Ewsu4qiqnndAV76J69',
264
- // externalId: 'price_1IToe8Ewsu4qiqnndAV76J69',
265
- // currency: 'usd',
266
- // amount: 10000,
267
- // },
268
- // },
269
- // ],
270
- };
271
- const planResponseMock = [
272
- {
273
- id: 'prod_J60fUEvI7qV1eL',
274
- externalId: 'prod_J60fUEvI7qV1eL',
275
- name: 'Premium',
276
- description: '',
277
- price: {
278
- id: 'price_1IToe8Ewsu4qiqnndAV76J69',
279
- externalId: 'price_1IToe8Ewsu4qiqnndAV76J69',
280
- currency: 'usd',
281
- amount: 10000,
282
- },
283
- slug: 'premium',
284
- },
285
- {
286
- id: 'prod_J60duauCpXfcur',
287
- externalId: 'prod_J60duauCpXfcur',
288
- name: 'Free',
289
- description: 'Totally free plan. Nothing to pay.',
290
- price: {
291
- id: 'price_1ITocfEwsu4qiqnnnBHDx9fQ',
292
- externalId: 'price_1ITocfEwsu4qiqnnnBHDx9fQ',
293
- currency: 'usd',
294
- amount: 0,
295
- },
296
- slug: 'free',
297
- },
298
- ];
299
- const invoicesMock = [
300
- {
301
- id: 'in_1JbhYWEwsu4qiqnnrUh6hsHa',
302
- externalId: 'in_1JbhYWEwsu4qiqnnrUh6hsHa',
303
- subscriptionId: 'sub_1JbhYVEwsu4qiqnnfMhYAdY6',
304
- paymentDate: '2021-09-20T08:08:51.000Z',
305
- totalAmount: 10000,
306
- currency: 'usd',
307
- paid: true,
308
- receiptNumber: '',
309
- },
310
- {
311
- id: 'in_1JbhYWEwsu4qiqnnrUh6hsHa',
312
- externalId: 'in_1JbhYWEwsu4qiqnnrUh6hsHa',
313
- subscriptionId: 'sub_1JbhYVEwsu4qiqnnfMhYAdY6',
314
- paymentDate: '2021-08-20T08:08:51.000Z',
315
- totalAmount: 10000,
316
- currency: 'usd',
317
- paid: true,
318
- receiptNumber: '',
319
- },
320
- ];
321
- const paymentMethodsMock = [
322
- {
323
- id: 'id',
324
- externalId: 'externalId',
325
- type: PaymentMethodType$1.CARD,
326
- isDefault: true,
327
- last4: '4242',
328
- expMonth: 11,
329
- expYear: 25,
330
- brand: 'visa',
331
- billingDetails: {
332
- name: 'Dummy',
333
- email: 'dummy@email.com',
334
- },
335
- },
336
- ];
337
-
338
- function* subscriptionSagas() {
339
- yield takeEvery(actions$6.load, loadSubscriptionTenant);
340
- yield takeEvery(actions$6.cancelSubscription, cancelSubscription);
341
- yield takeEvery(actions$6.renewSubscription, renewSubscription);
342
- }
343
- function* loadSubscriptionTenant() {
344
- const tenantId = yield select((state) => { var _a, _b; return (_b = (_a = state.auth) === null || _a === void 0 ? void 0 : _a.user) === null || _b === void 0 ? void 0 : _b.tenantId; });
345
- yield loadSummaries(tenantId);
346
- }
347
- function* loadSubscription() {
348
- yield put(actions$6.setLoading(true));
349
- try {
350
- const [subscription] = yield call(api.subscriptions.getManagedSubscriptions);
351
- yield put(actions$6.setState({
352
- subscription,
353
- fetching: false,
354
- loading: false,
355
- error: null,
356
- }));
357
- }
358
- catch (e) {
359
- yield put(actions$6.setError(e));
360
- }
361
- }
362
- function* cancelSubscription() {
363
- const { subscription } = yield select((state) => state.subscriptions.billing.subscription);
364
- if (!subscription) {
365
- yield put(actions$6.setCancellationError('Subscription not found.'));
366
- return;
367
- }
368
- if (subscription === null || subscription === void 0 ? void 0 : subscription.externallyManaged) {
369
- yield put(actions$6.setCancellationError('Billing is externally managed.'));
370
- return;
371
- }
372
- const { id: subscriptionId, cancellation, status } = subscription || {};
373
- const isCancellable = !cancellation && status === ISubscriptionStatus.ACTIVE;
374
- if (isCancellable) {
375
- try {
376
- yield put(actions$6.setCancellationLoading(true));
377
- yield call(api.subscriptions.cancelManagedSubscription, subscriptionId);
378
- yield loadSubscription();
379
- yield put(actions$6.setCancellationLoading(false));
380
- }
381
- catch (e) {
382
- yield put(actions$6.setCancellationError(e.message));
383
- }
384
- }
385
- }
386
- function* renewSubscription() {
387
- const { subscription } = yield select((state) => state.subscriptions.billing.subscription);
388
- if (!subscription) {
389
- yield put(actions$6.setCancellationError('Subscription not found.'));
390
- return;
391
- }
392
- if (subscription === null || subscription === void 0 ? void 0 : subscription.externallyManaged) {
393
- yield put(actions$6.setCancellationError('Billing is externally managed'));
394
- return;
395
- }
396
- const { id: subscriptionId, cancellation } = subscription || {};
397
- const renewable = (cancellation === null || cancellation === void 0 ? void 0 : cancellation.policy) === ISubscriptionCancellationPolicy.AT_PERIOD_END;
398
- if (renewable) {
399
- try {
400
- yield put(actions$6.setRenewalLoading(true));
401
- yield call(api.subscriptions.renewManagedSubscription, subscriptionId);
402
- yield loadSubscription();
403
- yield put(actions$6.setRenewalLoading(false));
404
- }
405
- catch (e) {
406
- yield put(actions$6.setCancellationError(e.message));
407
- }
408
- }
409
- }
410
- /*********************************
411
- * Preview Sagas
412
- *********************************/
413
- function* loadMock() {
414
- yield put(actions$6.setLoading(true));
415
- yield delay(500);
416
- yield put(actions$6.setState({
417
- subscription: subscriptionResponseMock,
418
- fetching: false,
419
- loading: false,
420
- error: null,
421
- }));
422
- }
423
- function* subscriptionSagasMock() {
424
- yield takeEvery(actions$6.load, loadMock);
425
- }
426
-
427
- function* subscriptionBillingInformationSagas() {
428
- yield takeEvery(actions$5.loadBillingInformation, loadBillingInformation);
429
- }
430
- function* loadBillingInformation() {
431
- yield loadBillingInformationAction(false);
432
- }
433
- function* loadBillingInformationAction(forceActive) {
434
- const paymentProvider = yield select((state) => { var _a; return (_a = state.subscriptions.config.config) === null || _a === void 0 ? void 0 : _a.paymentProvider; });
435
- const tenantId = yield select((state) => { var _a, _b; return (_b = (_a = state.auth) === null || _a === void 0 ? void 0 : _a.user) === null || _b === void 0 ? void 0 : _b.tenantId; });
436
- if (!paymentProvider || !tenantId) {
437
- yield put(actions$5.setError(!paymentProvider ? 'Internal feature failure' : 'Not authorized'));
438
- return;
439
- }
440
- yield loadSummaries(tenantId, forceActive);
441
- }
442
- function* loadSummaries(tenantId, forceActive) {
443
- var _a, _b;
444
- yield put(actions$5.setLoading(true));
445
- try {
446
- const summary = yield call(api.subscriptions.getSubscriptionSummaries, tenantId);
447
- const { currentPlanId, externallyManaged } = summary;
448
- let subscriptionResponse = null;
449
- let planResponse;
450
- if (!externallyManaged) {
451
- [, planResponse] = yield all([
452
- yield loadSubscription(),
453
- call(api.subscriptions.getSubscriptionPlan, currentPlanId),
454
- ]);
455
- subscriptionResponse = yield select((state) => state.subscriptions.billing.subscription.subscription || null);
456
- }
457
- else {
458
- planResponse = yield call(api.subscriptions.getSubscriptionPlan, currentPlanId);
459
- }
460
- yield put(actions$5.setState(Object.assign(Object.assign({ loading: false, fetching: false, summary }, (subscriptionResponse
461
- ? {
462
- subscription: {
463
- id: subscriptionResponse.id,
464
- externalId: subscriptionResponse.externalId,
465
- startDate: subscriptionResponse.startDate,
466
- currentPeriodStart: subscriptionResponse.currentPeriodStart,
467
- currentPeriodEnd: subscriptionResponse.currentPeriodEnd,
468
- status: forceActive ? SubscriptionStatus.ACTIVE : toSubscriptionStatus(subscriptionResponse.status),
469
- cancellation: subscriptionResponse.cancellation && toSubscriptionCancellation(subscriptionResponse.cancellation),
470
- trialEnd: subscriptionResponse.trialEnd ? subscriptionResponse.trialEnd : null,
471
- },
472
- }
473
- : {})), (planResponse
474
- ? {
475
- plan: {
476
- id: planResponse.id,
477
- name: planResponse.name,
478
- description: planResponse.description,
479
- price: ((_a = planResponse.price) === null || _a === void 0 ? void 0 : _a.amount) || 0,
480
- currency: ((_b = planResponse.price) === null || _b === void 0 ? void 0 : _b.currency) || 'usd',
481
- recurringInterval: 'month',
482
- slug: planResponse.slug,
483
- },
484
- }
485
- : {}))));
486
- }
487
- catch (e) {
488
- yield put(actions$5.setError(e.message));
489
- }
490
- }
491
- /*********************************
492
- * Preview Sagas
493
- *********************************/
494
- function* loadBillingInformationMock() {
495
- yield loadSummariesMock();
496
- }
497
- function* loadSummariesMock() {
498
- var _a, _b;
499
- yield put(actions$5.setLoading(true));
500
- yield delay(500);
501
- yield put(actions$5.setState({
502
- loading: false,
503
- fetching: false,
504
- summary: {
505
- subscriptionId: subscriptionResponseMock.id,
506
- paymentMethodId: 'mockPaymentMethodId',
507
- tenantConfigurationId: 'mockTenantConfigurationId',
508
- providerType: ProviderType.Stripe,
509
- externallyManaged: false,
510
- currentPlanId: planResponseMock[0].id,
511
- defaultPlanId: planResponseMock[0].id,
512
- },
513
- plan: Object.assign(Object.assign({}, planResponseMock[0]), { price: (_a = planResponseMock[0].price) === null || _a === void 0 ? void 0 : _a.amount, currency: (_b = planResponseMock[0].price) === null || _b === void 0 ? void 0 : _b.currency, recurringInterval: 'month' }),
514
- }));
515
- }
516
- function* subscriptionBillingInformationSagasMock() {
517
- yield takeEvery(actions$5.loadBillingInformation, loadBillingInformationMock);
518
- }
519
-
520
- function* subscriptionsPaymentMethodSagas() {
521
- yield takeEvery(actions$4.loadPaymentMethod, loadPaymentMethod);
522
- yield takeEvery(actions$4.submitPaymentMethod, submitPaymentMethod);
523
- yield takeEvery(actions$4.submitPaymentMethodError, submitPaymentMethodError);
524
- yield takeEvery(actions$4.submitPaymentMethodSuccess, submitPaymentMethodSuccess);
525
- yield takeEvery(actions$4.updatePaymentMethodBillingDetails, updateBillingDetails);
526
- }
527
- function* loadPaymentMethod() {
528
- yield put(actions$4.setLoading(true));
529
- try {
530
- const paymentMethods = yield call(api.subscriptions.getPaymentMethods);
531
- const paymentMethod = paymentMethods[0];
532
- yield put(actions$4.setState({
533
- paymentMethod,
534
- loading: false,
535
- fetching: false,
536
- }));
537
- }
538
- catch (e) {
539
- yield put(actions$4.setError(e.message));
540
- }
541
- }
542
- function* updateBillingDetails({ payload, }) {
543
- yield put(actions$4.setLoading(true));
544
- const { id, email, address, callback } = payload;
545
- try {
546
- yield call(api.subscriptions.updatePaymentMethodBillingDetails, id, Object.assign({ email }, address));
547
- yield call(loadPaymentMethod);
548
- callback === null || callback === void 0 ? void 0 : callback(true);
549
- }
550
- catch (e) {
551
- yield put(actions$4.setError(e.message));
552
- callback === null || callback === void 0 ? void 0 : callback(false);
553
- }
554
- yield put(actions$4.setLoading(false));
555
- }
556
- function* submitPaymentMethod() {
557
- yield put(actions$4.setLoading(true));
558
- }
559
- function* submitPaymentMethodError({ payload: error }) {
560
- yield put(actions$4.setError(error));
561
- }
562
- function* submitPaymentMethodSuccess() {
563
- yield put(actions$4.loadPaymentMethod());
564
- }
565
- /*********************************
566
- * Preview Sagas
567
- *********************************/
568
- function* loadPaymentMethodMock() {
569
- yield put(actions$4.setLoading(true));
570
- yield delay(500);
571
- const paymentMethod = paymentMethodsMock[0];
572
- yield put(actions$4.setState({
573
- paymentMethod,
574
- loading: false,
575
- fetching: false,
576
- }));
577
- }
578
- function* subscriptionsPaymentMethodSagasMock() {
579
- yield takeEvery(actions$4.loadPaymentMethod, loadPaymentMethodMock);
580
- }
581
-
582
- function* subscriptionInvoicesSagas() {
583
- yield takeEvery(actions$3.loadInvoices, loadInvoices);
584
- yield takeEvery(actions$3.downloadInvoice, downloadInvoice);
585
- }
586
- function* loadInvoices() {
587
- yield put(actions$3.setLoading(true));
588
- try {
589
- const responseInvoices = yield call(api.subscriptions.getSubscriptionInvoices);
590
- const invoices = responseInvoices.map((invoice) => ({
591
- id: invoice.id,
592
- externalId: invoice.externalId,
593
- subscriptionId: invoice.subscriptionId,
594
- paymentDate: new Date(Date.parse(invoice.paymentDate)),
595
- totalAmount: +((invoice.totalAmount || 0) / 100).toFixed(2),
596
- currency: invoice.currency || 'usd',
597
- paid: invoice.paid || false,
598
- receiptNumber: invoice.receiptNumber,
599
- }));
600
- yield put(actions$3.setState({
601
- loading: false,
602
- fetching: false,
603
- invoices,
604
- }));
605
- }
606
- catch (e) {
607
- yield put(actions$3.setError(e.message));
608
- }
609
- }
610
- function* downloadInvoice({ payload }) {
611
- yield put(actions$3.setInvoiceDownloadState({ loading: true, error: null }));
612
- try {
613
- yield call(api.subscriptions.getSubscriptionInvoicePdf, payload.invoiceId, payload.filename);
614
- yield put(actions$3.setInvoiceDownloadState({ loading: false, error: null }));
615
- }
616
- catch (e) {
617
- yield put(actions$3.setInvoiceDownloadState({ loading: false, error: e.message || null }));
618
- }
619
- }
620
- /*********************************
621
- * Preview Sagas
622
- *********************************/
623
- function* loadInvoicesMock() {
624
- yield put(actions$3.setLoading(true));
625
- yield delay(500);
626
- const selectPlanTitle = 'Premium';
627
- yield put(actions$3.setState({
628
- loading: false,
629
- fetching: false,
630
- invoices: invoicesMock.map((invoice) => (Object.assign(Object.assign({}, invoice), { selectedPlan: selectPlanTitle, paymentDate: new Date(Date.parse(invoice.paymentDate)), totalAmount: +((invoice.totalAmount || 0) / 100).toFixed(2) }))),
631
- }));
632
- yield put(actions$3.setLoading(false));
633
- }
634
- function* subscriptionInvoicesSagasMock() {
635
- yield takeEvery(actions$3.loadInvoices, loadInvoicesMock);
636
- }
637
-
638
- function* billingSagas() {
639
- yield all([
640
- call(subscriptionBillingInformationSagas),
641
- call(subscriptionsPaymentMethodSagas),
642
- call(subscriptionInvoicesSagas),
643
- call(subscriptionSagas),
644
- ]);
645
- }
646
- function* billingSagasMock() {
647
- yield all([
648
- call(subscriptionBillingInformationSagasMock),
649
- call(subscriptionsPaymentMethodSagasMock),
650
- call(subscriptionInvoicesSagasMock),
651
- call(subscriptionSagasMock),
652
- ]);
653
- }
654
-
655
- function* checkoutSagas() {
656
- yield takeEvery(actions$2.loadCheckout, loadCheckout);
657
- yield takeEvery(actions$2.resetCheckout, resetCheckout);
658
- yield takeEvery(actions$2.submitCheckout, submitCheckout);
659
- yield takeEvery(actions$2.confirmCheckout, confirmPlan);
660
- yield takeEvery(actions$2.errorCheckout, errorCheckout);
661
- }
662
- function* loadCheckout() {
663
- yield put(actions$2.setState({
664
- fetching: false,
665
- loading: false,
666
- error: null,
667
- confirmed: false,
668
- }));
669
- }
670
- function* resetCheckout() {
671
- yield put(actions$2.setState({
672
- loading: false,
673
- error: null,
674
- confirmed: false,
675
- }));
676
- }
677
- /**
678
- * Based on payment provider type
679
- */
680
- function* submitCheckout() {
681
- yield put(actions$2.setState({
682
- loading: true,
683
- error: null,
684
- }));
685
- }
686
- function* confirmPlan({ payload: { paymentMethodId, planId } }) {
687
- const subscription = yield select((state) => state.subscriptions.billing.subscription.subscription);
688
- const summary = yield select((state) => state.subscriptions.billing.information.summary);
689
- const isTrialing = (subscription === null || subscription === void 0 ? void 0 : subscription.status) === SubscriptionStatus.TRIALING;
690
- const hasPaymentMethod = !!(summary === null || summary === void 0 ? void 0 : summary.paymentMethodId);
691
- if (!subscription) {
692
- yield put(actions$2.setState({
693
- loading: false,
694
- error: 'Subscription not found',
695
- }));
696
- return;
697
- }
698
- yield put(actions$2.setState({
699
- loading: true,
700
- error: null,
701
- }));
702
- if (isTrialing && hasPaymentMethod) {
703
- yield confirmCheckout();
704
- yield put(actions$6.setState({
705
- subscription: Object.assign(Object.assign({}, subscription), { status: ISubscriptionStatus.ACTIVE }),
706
- }));
707
- return;
708
- }
709
- try {
710
- yield call(api.subscriptions.updateManagedSubscription, subscription.id, {
711
- paymentMethodId,
712
- planId,
713
- });
714
- yield all([
715
- loadBillingInformation(),
716
- loadPaymentMethod(),
717
- loadInvoices(),
718
- ]);
719
- yield confirmCheckout();
720
- }
721
- catch (e) {
722
- yield put(actions$2.setState({
723
- loading: false,
724
- error: e.message,
725
- }));
726
- }
727
- }
728
- function* confirmCheckout() {
729
- yield put(actions$2.setState({
730
- loading: false,
731
- error: null,
732
- confirmed: true,
733
- }));
734
- }
735
- function* errorCheckout({ payload }) {
736
- yield put(actions$2.setState({
737
- loading: false,
738
- error: payload,
739
- }));
740
- }
741
- /*********************************
742
- * Preview Sagas
743
- *********************************/
744
- function* checkoutSagasMock() {
745
- yield takeEvery(actions$2.resetCheckout, resetCheckout);
746
- }
747
-
748
- function* plansSagas() {
749
- yield takeEvery(actions$8.loadPlans, loadPlans);
750
- }
751
- function* loadPlans() {
752
- yield put(actions$8.setLoading(true));
753
- try {
754
- const products = yield call(api.subscriptions.getSubscriptionPlans);
755
- const plans = products.map((item) => {
756
- var _a, _b;
757
- return ({
758
- id: item.id,
759
- name: item.name,
760
- description: item.description,
761
- price: ((_a = item.price) === null || _a === void 0 ? void 0 : _a.amount) || 0,
762
- currency: ((_b = item.price) === null || _b === void 0 ? void 0 : _b.currency) || 'usd',
763
- recurringInterval: 'month',
764
- slug: item.slug,
765
- });
766
- });
767
- yield put(actions$8.setState({
768
- fetching: false,
769
- loading: false,
770
- plans,
771
- }));
772
- }
773
- catch (e) {
774
- yield put(actions$8.setError(e.message));
775
- }
776
- }
777
- /*********************************
778
- * Preview Sagas
779
- *********************************/
780
- function* loadPlansMock() {
781
- yield put(actions$8.setLoading(true));
782
- yield delay(500);
783
- yield put(actions$8.setState({
784
- fetching: false,
785
- loading: false,
786
- plans: planResponseMock.map((item) => {
787
- var _a, _b;
788
- return (Object.assign(Object.assign({}, item), { price: ((_a = item.price) === null || _a === void 0 ? void 0 : _a.amount) || 0, currency: ((_b = item.price) === null || _b === void 0 ? void 0 : _b.currency) || 'usd', recurringInterval: 'month' }));
789
- }),
790
- }));
791
- }
792
- function* plansSagasMock() {
793
- yield takeEvery(actions$8.loadPlans, loadPlansMock);
794
- }
795
-
796
- var PaymentMethodType;
797
- (function (PaymentMethodType) {
798
- PaymentMethodType["UNKNWON"] = "unknown";
799
- PaymentMethodType["CARD"] = "card";
800
- })(PaymentMethodType || (PaymentMethodType = {}));
801
-
802
- function* configSagas() {
803
- yield takeEvery(actions$7.loadPaymentConfiguration, loadPaymentConfiguration);
804
- }
805
- function* loadPaymentConfiguration() {
806
- yield put(actions$7.setLoading(true));
807
- try {
808
- const response = yield call(api.subscriptions.getPaymentProviders) || [];
809
- const stripePaymentProvider = response.find((paymentProvider) => paymentProvider.status === '1' && paymentProvider.providerType === ProviderType.Stripe);
810
- if (stripePaymentProvider) {
811
- yield loadStripePaymentConfiguration();
812
- }
813
- else {
814
- yield put(actions$7.setError('Payment provider not configured'));
815
- }
816
- }
817
- catch (e) {
818
- yield put(actions$7.setError(e.message));
819
- }
820
- }
821
- function* loadStripePaymentConfiguration() {
822
- yield put(actions$7.setLoading(true));
823
- try {
824
- const response = yield call(api.subscriptions.getStripePaymentProviderConfiguration);
825
- yield put(actions$7.setState({
826
- loading: false,
827
- fetching: false,
828
- config: {
829
- paymentProvider: PaymentProvider.STRIPE,
830
- apiKey: response.publishableKey
831
- }
832
- }));
833
- }
834
- catch (e) {
835
- yield put(actions$7.setError(e.message));
836
- }
837
- }
838
- /*********************************
839
- * Preview Sagas
840
- *********************************/
841
- function* loadPaymentConfigurationMock() {
842
- yield put(actions$7.setLoading(true));
843
- yield delay(500);
844
- yield put(actions$7.setState({
845
- loading: false,
846
- fetching: false,
847
- config: {
848
- paymentProvider: PaymentProvider.STRIPE,
849
- apiKey: ''
850
- },
851
- }));
852
- }
853
- function* configSagasMock() {
854
- yield takeEvery(actions$7.loadPaymentConfiguration, loadPaymentConfigurationMock);
855
- }
856
-
857
- function* subscriptionStripeSagas() {
858
- yield takeEvery(actions$1.createCardSetupIntentSecret, createCardSetupIntentSecret);
859
- }
860
- function* createCardSetupIntentSecret({ payload }) {
861
- yield put(actions$1.setState({
862
- loading: true,
863
- error: null,
864
- cardSetupIntentSecret: null,
865
- }));
866
- try {
867
- const request = {};
868
- if (payload) {
869
- request.paymentMethodId = payload;
870
- }
871
- const { setupIntentSecret } = yield call(api.subscriptions.createStripePaymentMethodSetupIntentSecret, request);
872
- yield put(actions$1.setState({
873
- cardSetupIntentSecret: setupIntentSecret,
874
- loading: false,
875
- }));
876
- }
877
- catch (e) {
878
- yield put(actions$1.setError(e.message));
879
- }
880
- }
881
-
882
- function* sagas() {
883
- yield all([
884
- call(billingSagas),
885
- call(checkoutSagas),
886
- call(plansSagas),
887
- call(configSagas),
888
- call(subscriptionStripeSagas),
889
- ]);
890
- }
891
- function* mockSagas() {
892
- yield all([call(billingSagasMock), call(checkoutSagasMock), call(plansSagasMock), call(configSagasMock)]);
893
- }
894
-
895
- // export store
896
- // export store
897
- var subscriptionsStore = {
898
- sagas,
899
- mockSagas,
900
- reducer,
901
- actions,
902
- initialState,
903
- storeName: subscriptionsStoreName,
904
- };
905
-
906
- export { PaymentMethodType, PaymentProvider, SubscriptionCancellationPolicy, SubscriptionStatus, subscriptionsStore as default, actions as subscriptionActions, initialState as subscriptionInitialState, reducer as subscriptionReducers, sagas as subscriptionSagas, mockSagas as subscriptionSagasMock };
1
+ import { subscriptionsStoreName as storeName } from '../constants';
2
+ import { actions, initialState, reducer } from './reducer';
3
+ import { sagas, mockSagas } from './saga';
4
+ export * from './interfaces';
5
+ export { sagas as subscriptionSagas, mockSagas as subscriptionSagasMock, reducer as subscriptionReducers, actions as subscriptionActions, initialState as subscriptionInitialState, storeName as subscriptionsStoreName };
6
+ export default {
7
+ sagas,
8
+ mockSagas,
9
+ reducer,
10
+ actions,
11
+ initialState,
12
+ storeName
13
+ };