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