@frontegg/redux-store 6.69.0 → 6.70.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/audits/AuditLogsState/index.js +1 -1
  2. package/audits/AuditLogsState/saga.js +1 -18
  3. package/audits/AuditsMetadataState/index.js +1 -1
  4. package/audits/AuditsMetadataState/saga.js +1 -5
  5. package/audits/backward-compatibility/saga.js +0 -18
  6. package/audits/dummy.js +0 -16
  7. package/audits/index.js +4 -2
  8. package/audits/reducer.js +0 -2
  9. package/auth/AcceptInvitationState/index.d.ts +2 -0
  10. package/auth/AcceptInvitationState/index.js +1 -1
  11. package/auth/AcceptInvitationState/interfaces.js +0 -1
  12. package/auth/AcceptInvitationState/saga.js +0 -3
  13. package/auth/AccountSettingsState/index.d.ts +2 -0
  14. package/auth/AccountSettingsState/index.js +1 -1
  15. package/auth/AccountSettingsState/interfaces.d.ts +2 -0
  16. package/auth/AccountSettingsState/saga.js +1 -11
  17. package/auth/ActivateState/index.d.ts +3 -0
  18. package/auth/ActivateState/index.js +1 -1
  19. package/auth/ActivateState/interfaces.js +0 -1
  20. package/auth/ActivateState/saga.js +14 -34
  21. package/auth/ApiTokensState/index.d.ts +2 -0
  22. package/auth/ApiTokensState/index.js +1 -1
  23. package/auth/ApiTokensState/interfaces.d.ts +1 -0
  24. package/auth/ApiTokensState/interfaces.js +0 -1
  25. package/auth/ApiTokensState/saga.js +1 -44
  26. package/auth/ForgotPasswordState/index.d.ts +2 -0
  27. package/auth/ForgotPasswordState/index.js +1 -1
  28. package/auth/ForgotPasswordState/interfaces.js +0 -1
  29. package/auth/ForgotPasswordState/saga.js +5 -12
  30. package/auth/ImpersonationState/index.d.ts +2 -0
  31. package/auth/ImpersonationState/index.js +1 -1
  32. package/auth/ImpersonationState/interfaces.js +0 -1
  33. package/auth/ImpersonationState/saga.js +5 -9
  34. package/auth/LoginState/index.d.ts +2 -0
  35. package/auth/LoginState/index.js +1 -1
  36. package/auth/LoginState/interfaces.js +0 -6
  37. package/auth/LoginState/saga.d.ts +2 -38
  38. package/auth/LoginState/saga.js +132 -292
  39. package/auth/MfaState/index.d.ts +4 -2
  40. package/auth/MfaState/index.js +1 -1
  41. package/auth/MfaState/interfaces.d.ts +2 -2
  42. package/auth/MfaState/interfaces.js +0 -1
  43. package/auth/MfaState/saga.js +64 -143
  44. package/auth/ProfileState/index.d.ts +2 -0
  45. package/auth/ProfileState/index.js +1 -1
  46. package/auth/ProfileState/saga.js +22 -50
  47. package/auth/Provisioning/index.d.ts +2 -0
  48. package/auth/Provisioning/index.js +1 -1
  49. package/auth/Provisioning/saga.js +11 -23
  50. package/auth/ResetPhoneNumberState/index.d.ts +2 -0
  51. package/auth/ResetPhoneNumberState/index.js +1 -1
  52. package/auth/ResetPhoneNumberState/interfaces.js +0 -1
  53. package/auth/ResetPhoneNumberState/saga.js +17 -26
  54. package/auth/RestrictionsState/index.d.ts +3 -0
  55. package/auth/RestrictionsState/index.js +1 -1
  56. package/auth/RestrictionsState/saga.js +52 -105
  57. package/auth/RolesState/index.d.ts +2 -0
  58. package/auth/RolesState/index.js +1 -1
  59. package/auth/RolesState/saga.js +30 -51
  60. package/auth/SSOState/index.d.ts +2 -0
  61. package/auth/SSOState/index.js +1 -1
  62. package/auth/SSOState/interfaces.js +0 -3
  63. package/auth/SSOState/saga.js +10 -58
  64. package/auth/SSOState/saga.v2.js +13 -49
  65. package/auth/SecurityPolicyState/index.d.ts +13 -0
  66. package/auth/SecurityPolicyState/index.js +1 -1
  67. package/auth/SecurityPolicyState/saga.js +36 -90
  68. package/auth/SessionsPolicyState/index.d.ts +2 -0
  69. package/auth/SessionsPolicyState/index.js +1 -1
  70. package/auth/SessionsPolicyState/saga.js +7 -19
  71. package/auth/SessionsState/index.d.ts +2 -0
  72. package/auth/SessionsState/index.js +1 -1
  73. package/auth/SessionsState/saga.js +1 -15
  74. package/auth/SignUp/index.d.ts +2 -0
  75. package/auth/SignUp/index.js +1 -1
  76. package/auth/SignUp/interfaces.js +0 -1
  77. package/auth/SignUp/saga.js +6 -15
  78. package/auth/SocialLogins/index.d.ts +2 -0
  79. package/auth/SocialLogins/index.js +1 -1
  80. package/auth/SocialLogins/saga.js +10 -20
  81. package/auth/TeamState/index.d.ts +2 -0
  82. package/auth/TeamState/index.js +1 -1
  83. package/auth/TeamState/interfaces.js +0 -1
  84. package/auth/TeamState/saga.js +85 -205
  85. package/auth/TenantsState/index.d.ts +2 -0
  86. package/auth/TenantsState/index.js +1 -1
  87. package/auth/TenantsState/saga.js +1 -17
  88. package/auth/index.d.ts +2 -2
  89. package/auth/index.js +4 -3
  90. package/auth/interfaces.d.ts +2 -1
  91. package/auth/interfaces.js +0 -6
  92. package/auth/reducer.d.ts +2 -2
  93. package/auth/reducer.js +0 -2
  94. package/auth/saga.js +2 -1
  95. package/auth/utils.d.ts +4 -0
  96. package/auth/utils.js +7 -21
  97. package/connectivity/ConnectivityState/index.d.ts +9 -0
  98. package/connectivity/ConnectivityState/index.js +1 -1
  99. package/connectivity/consts.js +0 -5
  100. package/connectivity/index.js +4 -2
  101. package/connectivity/interfaces.d.ts +1 -0
  102. package/connectivity/reducer.js +0 -2
  103. package/connectivity/saga.js +48 -85
  104. package/helpers.js +4 -7
  105. package/index.js +1 -1
  106. package/node/audits/AuditLogsState/index.js +1 -8
  107. package/node/audits/AuditLogsState/saga.js +1 -26
  108. package/node/audits/AuditsMetadataState/index.js +1 -8
  109. package/node/audits/AuditsMetadataState/saga.js +1 -10
  110. package/node/audits/backward-compatibility/index.js +0 -8
  111. package/node/audits/backward-compatibility/reducer.js +0 -5
  112. package/node/audits/backward-compatibility/saga.js +0 -23
  113. package/node/audits/dummy.js +0 -19
  114. package/node/audits/index.js +0 -14
  115. package/node/audits/initialState.js +0 -3
  116. package/node/audits/reducer.js +0 -8
  117. package/node/audits/saga.js +0 -5
  118. package/node/audits/utils.js +0 -4
  119. package/node/auth/AcceptInvitationState/index.js +1 -7
  120. package/node/auth/AcceptInvitationState/interfaces.js +0 -1
  121. package/node/auth/AcceptInvitationState/saga.js +0 -7
  122. package/node/auth/AccountSettingsState/index.js +1 -6
  123. package/node/auth/AccountSettingsState/saga.js +1 -16
  124. package/node/auth/ActivateState/index.js +1 -7
  125. package/node/auth/ActivateState/interfaces.js +0 -1
  126. package/node/auth/ActivateState/saga.js +14 -41
  127. package/node/auth/ApiTokensState/index.js +1 -6
  128. package/node/auth/ApiTokensState/interfaces.js +0 -1
  129. package/node/auth/ApiTokensState/saga.js +1 -51
  130. package/node/auth/ForgotPasswordState/index.js +1 -7
  131. package/node/auth/ForgotPasswordState/interfaces.js +0 -1
  132. package/node/auth/ForgotPasswordState/saga.js +5 -19
  133. package/node/auth/ImpersonationState/index.js +1 -7
  134. package/node/auth/ImpersonationState/interfaces.js +0 -1
  135. package/node/auth/ImpersonationState/saga.js +5 -15
  136. package/node/auth/LoginState/index.js +1 -7
  137. package/node/auth/LoginState/interfaces.js +0 -7
  138. package/node/auth/LoginState/saga.js +132 -322
  139. package/node/auth/MfaState/index.js +1 -7
  140. package/node/auth/MfaState/interfaces.js +0 -1
  141. package/node/auth/MfaState/saga.js +64 -137
  142. package/node/auth/ProfileState/index.js +1 -6
  143. package/node/auth/ProfileState/saga.js +22 -58
  144. package/node/auth/Provisioning/index.js +1 -6
  145. package/node/auth/Provisioning/saga.js +11 -28
  146. package/node/auth/ResetPhoneNumberState/index.js +1 -7
  147. package/node/auth/ResetPhoneNumberState/interfaces.js +0 -1
  148. package/node/auth/ResetPhoneNumberState/saga.js +17 -32
  149. package/node/auth/RestrictionsState/index.js +1 -7
  150. package/node/auth/RestrictionsState/saga.js +52 -109
  151. package/node/auth/RolesState/index.js +1 -6
  152. package/node/auth/RolesState/saga.js +30 -54
  153. package/node/auth/SSOState/index.js +1 -6
  154. package/node/auth/SSOState/interfaces.js +0 -3
  155. package/node/auth/SSOState/saga.js +10 -63
  156. package/node/auth/SSOState/saga.v2.js +13 -53
  157. package/node/auth/SecurityPolicyState/index.js +1 -6
  158. package/node/auth/SecurityPolicyState/saga.js +36 -89
  159. package/node/auth/SessionsPolicyState/index.js +1 -6
  160. package/node/auth/SessionsPolicyState/saga.js +7 -24
  161. package/node/auth/SessionsState/index.js +1 -6
  162. package/node/auth/SessionsState/saga.js +1 -22
  163. package/node/auth/SignUp/index.js +1 -7
  164. package/node/auth/SignUp/interfaces.js +0 -1
  165. package/node/auth/SignUp/saga.js +6 -30
  166. package/node/auth/SocialLogins/index.js +1 -6
  167. package/node/auth/SocialLogins/saga.js +10 -33
  168. package/node/auth/TeamState/index.js +1 -6
  169. package/node/auth/TeamState/interfaces.js +0 -1
  170. package/node/auth/TeamState/saga.js +86 -190
  171. package/node/auth/TenantsState/index.js +1 -6
  172. package/node/auth/TenantsState/saga.js +1 -24
  173. package/node/auth/dummy.js +0 -5
  174. package/node/auth/index.js +0 -90
  175. package/node/auth/initialState.js +0 -23
  176. package/node/auth/interfaces.js +0 -6
  177. package/node/auth/reducer.js +0 -28
  178. package/node/auth/saga.js +2 -26
  179. package/node/auth/utils.js +7 -42
  180. package/node/connectivity/ConnectivityState/index.js +1 -7
  181. package/node/connectivity/consts.js +1 -7
  182. package/node/connectivity/index.js +0 -5
  183. package/node/connectivity/reducer.js +0 -6
  184. package/node/connectivity/saga.js +47 -91
  185. package/node/helpers.js +2 -14
  186. package/node/index.js +1 -17
  187. package/node/subscriptions/Billing/Information/index.js +0 -7
  188. package/node/subscriptions/Billing/Information/saga.js +1 -25
  189. package/node/subscriptions/Billing/Invoices/index.js +0 -6
  190. package/node/subscriptions/Billing/Invoices/saga.js +1 -13
  191. package/node/subscriptions/Billing/PaymentMethod/index.js +2 -8
  192. package/node/subscriptions/Billing/PaymentMethod/interfaces.js +0 -1
  193. package/node/subscriptions/Billing/PaymentMethod/saga.js +1 -17
  194. package/node/subscriptions/Billing/Subscription/index.js +0 -6
  195. package/node/subscriptions/Billing/Subscription/saga.js +3 -23
  196. package/node/subscriptions/Billing/index.js +0 -6
  197. package/node/subscriptions/Billing/interfaces.js +0 -8
  198. package/node/subscriptions/Billing/saga.js +0 -7
  199. package/node/subscriptions/Checkout/index.js +0 -6
  200. package/node/subscriptions/Checkout/saga.js +2 -22
  201. package/node/subscriptions/Config/index.js +0 -6
  202. package/node/subscriptions/Config/saga.js +1 -12
  203. package/node/subscriptions/Plans/index.js +0 -6
  204. package/node/subscriptions/Plans/saga.js +1 -13
  205. package/node/subscriptions/Stripe/index.js +0 -6
  206. package/node/subscriptions/Stripe/saga.js +0 -8
  207. package/node/subscriptions/VendorPublicConfig/index.js +0 -6
  208. package/node/subscriptions/VendorPublicConfig/saga.js +1 -9
  209. package/node/subscriptions/dummy.js +2 -4
  210. package/node/subscriptions/general.interfaces.js +0 -5
  211. package/node/subscriptions/index.js +0 -5
  212. package/node/subscriptions/interfaces.js +0 -14
  213. package/node/subscriptions/mapper.js +0 -11
  214. package/node/subscriptions/reducer.js +0 -9
  215. package/node/subscriptions/saga.js +0 -9
  216. package/node/subscriptions/utils.js +0 -6
  217. package/node/toolkit/index.js +0 -31
  218. package/node/toolkit/redux-saga.js +0 -3
  219. package/node/toolkit/redux.js +0 -1
  220. package/node/vendor/VendorState/index.js +1 -7
  221. package/node/vendor/index.js +0 -5
  222. package/node/vendor/reducer.js +0 -6
  223. package/node/vendor/saga.js +1 -9
  224. package/package.json +1 -1
  225. package/subscriptions/Billing/Information/index.js +0 -4
  226. package/subscriptions/Billing/Information/saga.js +1 -12
  227. package/subscriptions/Billing/Invoices/index.js +0 -4
  228. package/subscriptions/Billing/Invoices/saga.js +1 -5
  229. package/subscriptions/Billing/PaymentMethod/index.js +2 -6
  230. package/subscriptions/Billing/PaymentMethod/interfaces.js +1 -1
  231. package/subscriptions/Billing/PaymentMethod/saga.js +1 -9
  232. package/subscriptions/Billing/Subscription/index.js +0 -4
  233. package/subscriptions/Billing/Subscription/saga.js +3 -17
  234. package/subscriptions/Billing/interfaces.js +1 -0
  235. package/subscriptions/Checkout/index.js +0 -4
  236. package/subscriptions/Checkout/saga.js +2 -12
  237. package/subscriptions/Config/index.js +0 -4
  238. package/subscriptions/Config/saga.js +1 -7
  239. package/subscriptions/Plans/index.js +0 -2
  240. package/subscriptions/Plans/saga.js +1 -6
  241. package/subscriptions/Stripe/index.js +0 -4
  242. package/subscriptions/Stripe/saga.js +0 -4
  243. package/subscriptions/VendorPublicConfig/index.js +0 -2
  244. package/subscriptions/VendorPublicConfig/saga.js +1 -4
  245. package/subscriptions/dummy.js +3 -2
  246. package/subscriptions/general.interfaces.js +0 -5
  247. package/subscriptions/index.js +3 -1
  248. package/subscriptions/mapper.js +0 -5
  249. package/toolkit/index.d.ts +1 -1
  250. package/toolkit/index.js +0 -9
  251. package/vendor/VendorState/index.js +1 -0
  252. package/vendor/index.js +4 -2
  253. package/vendor/reducer.js +0 -2
  254. package/vendor/saga.js +1 -2
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -10,57 +9,39 @@ exports.loadSummaries = loadSummaries;
10
9
  exports.loadSummariesMock = loadSummariesMock;
11
10
  exports.subscriptionBillingInformationSagas = subscriptionBillingInformationSagas;
12
11
  exports.subscriptionBillingInformationSagasMock = subscriptionBillingInformationSagasMock;
13
-
14
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
15
-
16
13
  var _effects = require("redux-saga/effects");
17
-
18
14
  var _restApi = require("@frontegg/rest-api");
19
-
20
15
  var _index = require("./index");
21
-
22
16
  var _general = require("../../general.interfaces");
23
-
24
17
  var _mapper = require("../../mapper");
25
-
26
18
  var _dummy = require("../../dummy");
27
-
28
19
  var _saga = require("../Subscription/saga");
29
-
30
20
  function* subscriptionBillingInformationSagas() {
31
21
  yield (0, _effects.takeEvery)(_index.informationActions.loadBillingInformation, loadBillingInformation);
32
22
  }
33
-
34
23
  function* loadBillingInformation() {
35
24
  yield loadBillingInformationAction(false);
36
25
  }
37
-
38
26
  function* loadBillingInformationAction(forceActive) {
39
27
  const paymentProvider = yield (0, _effects.select)(state => {
40
28
  var _state$subscriptions$;
41
-
42
29
  return (_state$subscriptions$ = state.subscriptions.config.config) == null ? void 0 : _state$subscriptions$.paymentProvider;
43
30
  });
44
31
  const tenantId = yield (0, _effects.select)(state => {
45
32
  var _state$auth, _state$auth$user;
46
-
47
33
  return (_state$auth = state.auth) == null ? void 0 : (_state$auth$user = _state$auth.user) == null ? void 0 : _state$auth$user.tenantId;
48
34
  });
49
-
50
35
  if (!paymentProvider || !tenantId) {
51
36
  yield (0, _effects.put)(_index.informationActions.setError(!paymentProvider ? 'Internal feature failure' : 'Not authorized'));
52
37
  return;
53
38
  }
54
-
55
39
  yield loadSummaries(tenantId, forceActive);
56
40
  }
57
-
58
41
  function* loadSummaries(tenantId, forceActive) {
59
42
  yield (0, _effects.put)(_index.informationActions.setLoading(true));
60
-
61
43
  try {
62
44
  var _planResponse$price, _planResponse$price2;
63
-
64
45
  const summary = yield (0, _effects.call)(_restApi.api.subscriptions.getSubscriptionSummaries, tenantId);
65
46
  const {
66
47
  currentPlanId,
@@ -68,14 +49,12 @@ function* loadSummaries(tenantId, forceActive) {
68
49
  } = summary;
69
50
  let subscriptionResponse = null;
70
51
  let planResponse;
71
-
72
52
  if (!externallyManaged) {
73
53
  [, planResponse] = yield (0, _effects.all)([(0, _effects.call)(_saga.loadSubscription), (0, _effects.call)(_restApi.api.subscriptions.getSubscriptionPlan, currentPlanId)]);
74
54
  subscriptionResponse = yield (0, _effects.select)(state => state.subscriptions.billing.subscription.subscription || null);
75
55
  } else {
76
56
  planResponse = yield (0, _effects.call)(_restApi.api.subscriptions.getSubscriptionPlan, currentPlanId);
77
57
  }
78
-
79
58
  yield (0, _effects.put)(_index.informationActions.setState((0, _extends2.default)({
80
59
  loading: false,
81
60
  fetching: false,
@@ -106,18 +85,16 @@ function* loadSummaries(tenantId, forceActive) {
106
85
  yield (0, _effects.put)(_index.informationActions.setError(e.message));
107
86
  }
108
87
  }
88
+
109
89
  /*********************************
110
90
  * Preview Sagas
111
91
  *********************************/
112
92
 
113
-
114
93
  function* loadBillingInformationMock() {
115
94
  yield loadSummariesMock();
116
95
  }
117
-
118
96
  function* loadSummariesMock() {
119
97
  var _planResponseMock$0$p, _planResponseMock$0$p2;
120
-
121
98
  yield (0, _effects.put)(_index.informationActions.setLoading(true));
122
99
  yield (0, _effects.delay)(500);
123
100
  yield (0, _effects.put)(_index.informationActions.setState({
@@ -139,7 +116,6 @@ function* loadSummariesMock() {
139
116
  })
140
117
  }));
141
118
  }
142
-
143
119
  function* subscriptionBillingInformationSagasMock() {
144
120
  yield (0, _effects.takeEvery)(_index.informationActions.loadBillingInformation, loadBillingInformationMock);
145
121
  }
@@ -1,20 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.invoicesReducer = exports.invoicesActions = exports.initialInvoicesState = void 0;
9
-
10
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
-
12
9
  var _utils = require("../../utils");
13
-
14
10
  var _toolkit = require("@reduxjs/toolkit");
15
-
16
11
  var _constants = require("../../../constants");
17
-
18
12
  const initialInvoicesState = {
19
13
  loading: false,
20
14
  error: null,
@@ -1,32 +1,23 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.loadInvoices = loadInvoices;
9
8
  exports.subscriptionInvoicesSagas = subscriptionInvoicesSagas;
10
9
  exports.subscriptionInvoicesSagasMock = subscriptionInvoicesSagasMock;
11
-
12
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
-
14
11
  var _effects = require("redux-saga/effects");
15
-
16
12
  var _index = require("./index");
17
-
18
13
  var _restApi = require("@frontegg/rest-api");
19
-
20
14
  var _dummy = require("../../dummy");
21
-
22
15
  function* subscriptionInvoicesSagas() {
23
16
  yield (0, _effects.takeEvery)(_index.invoicesActions.loadInvoices, loadInvoices);
24
17
  yield (0, _effects.takeEvery)(_index.invoicesActions.downloadInvoice, downloadInvoice);
25
18
  }
26
-
27
19
  function* loadInvoices() {
28
20
  yield (0, _effects.put)(_index.invoicesActions.setLoading(true));
29
-
30
21
  try {
31
22
  const responseInvoices = yield (0, _effects.call)(_restApi.api.subscriptions.getSubscriptionInvoices);
32
23
  const invoices = responseInvoices.map(invoice => ({
@@ -48,7 +39,6 @@ function* loadInvoices() {
48
39
  yield (0, _effects.put)(_index.invoicesActions.setError(e.message));
49
40
  }
50
41
  }
51
-
52
42
  function* downloadInvoice({
53
43
  payload
54
44
  }) {
@@ -56,7 +46,6 @@ function* downloadInvoice({
56
46
  loading: true,
57
47
  error: null
58
48
  }));
59
-
60
49
  try {
61
50
  yield (0, _effects.call)(_restApi.api.subscriptions.getSubscriptionInvoicePdf, payload.invoiceId, payload.filename);
62
51
  yield (0, _effects.put)(_index.invoicesActions.setInvoiceDownloadState({
@@ -70,11 +59,11 @@ function* downloadInvoice({
70
59
  }));
71
60
  }
72
61
  }
62
+
73
63
  /*********************************
74
64
  * Preview Sagas
75
65
  *********************************/
76
66
 
77
-
78
67
  function* loadInvoicesMock() {
79
68
  yield (0, _effects.put)(_index.invoicesActions.setLoading(true));
80
69
  yield (0, _effects.delay)(500);
@@ -90,7 +79,6 @@ function* loadInvoicesMock() {
90
79
  }));
91
80
  yield (0, _effects.put)(_index.invoicesActions.setLoading(false));
92
81
  }
93
-
94
82
  function* subscriptionInvoicesSagasMock() {
95
83
  yield (0, _effects.takeEvery)(_index.invoicesActions.loadInvoices, loadInvoicesMock);
96
84
  }
@@ -1,20 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.subscriptionsPaymentMethodReducer = exports.subscriptionsPaymentMethodActions = exports.initialPaymentMethodState = void 0;
9
-
10
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
-
12
9
  var _utils = require("../../utils");
13
-
14
10
  var _constants = require("../../../constants");
15
-
16
11
  var _toolkit = require("@reduxjs/toolkit");
17
-
18
12
  const initialPaymentMethodState = {
19
13
  loading: false,
20
14
  error: null,
@@ -47,6 +41,6 @@ const actions = (0, _extends2.default)({
47
41
  updatePaymentMethodBillingDetails: (0, _toolkit.createAction)(`${name}/updateBillingDetails`, payload => ({
48
42
  payload
49
43
  }))
50
- }, paymentActions); //TODO: refactor to general code-style like export type ConnectivityActions = DispatchedActions;
51
-
44
+ }, paymentActions);
45
+ //TODO: refactor to general code-style like export type ConnectivityActions = DispatchedActions;
52
46
  exports.subscriptionsPaymentMethodActions = actions;
@@ -7,7 +7,6 @@ exports.PaymentMethodType = void 0;
7
7
  //TODO: consider use types from typescript-rest-api or duplicate them.
8
8
  let PaymentMethodType;
9
9
  exports.PaymentMethodType = PaymentMethodType;
10
-
11
10
  (function (PaymentMethodType) {
12
11
  PaymentMethodType["UNKNWON"] = "unknown";
13
12
  PaymentMethodType["CARD"] = "card";
@@ -1,24 +1,17 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.loadPaymentMethod = loadPaymentMethod;
9
8
  exports.subscriptionsPaymentMethodSagas = subscriptionsPaymentMethodSagas;
10
9
  exports.subscriptionsPaymentMethodSagasMock = subscriptionsPaymentMethodSagasMock;
11
-
12
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
-
14
11
  var _effects = require("redux-saga/effects");
15
-
16
12
  var _index = require("./index");
17
-
18
13
  var _restApi = require("@frontegg/rest-api");
19
-
20
14
  var _dummy = require("../../dummy");
21
-
22
15
  function* subscriptionsPaymentMethodSagas() {
23
16
  yield (0, _effects.takeEvery)(_index.subscriptionsPaymentMethodActions.loadPaymentMethod, loadPaymentMethod);
24
17
  yield (0, _effects.takeEvery)(_index.subscriptionsPaymentMethodActions.submitPaymentMethod, submitPaymentMethod);
@@ -26,10 +19,8 @@ function* subscriptionsPaymentMethodSagas() {
26
19
  yield (0, _effects.takeEvery)(_index.subscriptionsPaymentMethodActions.submitPaymentMethodSuccess, submitPaymentMethodSuccess);
27
20
  yield (0, _effects.takeEvery)(_index.subscriptionsPaymentMethodActions.updatePaymentMethodBillingDetails, updateBillingDetails);
28
21
  }
29
-
30
22
  function* loadPaymentMethod() {
31
23
  yield (0, _effects.put)(_index.subscriptionsPaymentMethodActions.setLoading(true));
32
-
33
24
  try {
34
25
  const paymentMethods = yield (0, _effects.call)(_restApi.api.subscriptions.getPaymentMethods);
35
26
  const paymentMethod = paymentMethods[0];
@@ -42,7 +33,6 @@ function* loadPaymentMethod() {
42
33
  yield (0, _effects.put)(_index.subscriptionsPaymentMethodActions.setError(e.message));
43
34
  }
44
35
  }
45
-
46
36
  function* updateBillingDetails({
47
37
  payload
48
38
  }) {
@@ -53,7 +43,6 @@ function* updateBillingDetails({
53
43
  address,
54
44
  callback
55
45
  } = payload;
56
-
57
46
  try {
58
47
  yield (0, _effects.call)(_restApi.api.subscriptions.updatePaymentMethodBillingDetails, id, (0, _extends2.default)({
59
48
  email
@@ -64,28 +53,24 @@ function* updateBillingDetails({
64
53
  yield (0, _effects.put)(_index.subscriptionsPaymentMethodActions.setError(e.message));
65
54
  callback == null ? void 0 : callback(false);
66
55
  }
67
-
68
56
  yield (0, _effects.put)(_index.subscriptionsPaymentMethodActions.setLoading(false));
69
57
  }
70
-
71
58
  function* submitPaymentMethod() {
72
59
  yield (0, _effects.put)(_index.subscriptionsPaymentMethodActions.setLoading(true));
73
60
  }
74
-
75
61
  function* submitPaymentMethodError({
76
62
  payload: error
77
63
  }) {
78
64
  yield (0, _effects.put)(_index.subscriptionsPaymentMethodActions.setError(error));
79
65
  }
80
-
81
66
  function* submitPaymentMethodSuccess() {
82
67
  yield (0, _effects.put)(_index.subscriptionsPaymentMethodActions.loadPaymentMethod());
83
68
  }
69
+
84
70
  /*********************************
85
71
  * Preview Sagas
86
72
  *********************************/
87
73
 
88
-
89
74
  function* loadPaymentMethodMock() {
90
75
  yield (0, _effects.put)(_index.subscriptionsPaymentMethodActions.setLoading(true));
91
76
  yield (0, _effects.delay)(500);
@@ -96,7 +81,6 @@ function* loadPaymentMethodMock() {
96
81
  fetching: false
97
82
  }));
98
83
  }
99
-
100
84
  function* subscriptionsPaymentMethodSagasMock() {
101
85
  yield (0, _effects.takeEvery)(_index.subscriptionsPaymentMethodActions.loadPaymentMethod, loadPaymentMethodMock);
102
86
  }
@@ -1,20 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.subscriptionReducer = exports.subscriptionActions = exports.initialSubscriptionState = void 0;
9
-
10
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
-
12
9
  var _toolkit = require("@reduxjs/toolkit");
13
-
14
10
  var _constants = require("../../../constants");
15
-
16
11
  var _utils = require("../../utils");
17
-
18
12
  const initialSubscriptionState = {
19
13
  loading: false,
20
14
  error: null,
@@ -6,36 +6,27 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.loadSubscription = loadSubscription;
7
7
  exports.subscriptionSagas = subscriptionSagas;
8
8
  exports.subscriptionSagasMock = subscriptionSagasMock;
9
-
10
9
  var _effects = require("redux-saga/effects");
11
-
12
10
  var _index = require("./index");
13
-
14
11
  var _restApi = require("@frontegg/rest-api");
15
-
16
12
  var _dummy = require("../../dummy");
17
-
18
13
  var _saga = require("../Information/saga");
19
-
20
14
  function* subscriptionSagas() {
21
15
  yield (0, _effects.takeEvery)(_index.subscriptionActions.load, loadSubscriptionTenant);
22
16
  yield (0, _effects.takeEvery)(_index.subscriptionActions.cancelSubscription, cancelSubscription);
23
17
  yield (0, _effects.takeEvery)(_index.subscriptionActions.renewSubscription, renewSubscription);
24
18
  }
25
-
26
19
  function* loadSubscriptionTenant() {
27
20
  const tenantId = yield (0, _effects.select)(state => {
28
21
  var _state$auth, _state$auth$user;
29
-
30
22
  return (_state$auth = state.auth) == null ? void 0 : (_state$auth$user = _state$auth.user) == null ? void 0 : _state$auth$user.tenantId;
31
23
  });
32
24
  yield (0, _saga.loadSummaries)(tenantId);
33
- } // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
-
25
+ }
35
26
 
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
28
  function* loadSubscription() {
37
29
  yield (0, _effects.put)(_index.subscriptionActions.setLoading(true));
38
-
39
30
  try {
40
31
  const [subscription] = yield (0, _effects.call)(_restApi.api.subscriptions.getManagedSubscriptions);
41
32
  yield (0, _effects.put)(_index.subscriptionActions.setState({
@@ -48,29 +39,24 @@ function* loadSubscription() {
48
39
  yield (0, _effects.put)(_index.subscriptionActions.setError(e));
49
40
  }
50
41
  }
51
-
52
42
  function* cancelSubscription() {
53
43
  const {
54
44
  subscription
55
45
  } = yield (0, _effects.select)(state => state.subscriptions.billing.subscription);
56
-
57
46
  if (!subscription) {
58
47
  yield (0, _effects.put)(_index.subscriptionActions.setCancellationError('Subscription not found.'));
59
48
  return;
60
49
  }
61
-
62
50
  if (subscription != null && subscription.externallyManaged) {
63
51
  yield (0, _effects.put)(_index.subscriptionActions.setCancellationError('Billing is externally managed.'));
64
52
  return;
65
53
  }
66
-
67
54
  const {
68
55
  id: subscriptionId,
69
56
  cancellation,
70
57
  status
71
58
  } = subscription || {};
72
59
  const isCancellable = !cancellation && status === _restApi.ISubscriptionStatus.ACTIVE;
73
-
74
60
  if (isCancellable) {
75
61
  try {
76
62
  yield (0, _effects.put)(_index.subscriptionActions.setCancellationLoading(true));
@@ -82,28 +68,23 @@ function* cancelSubscription() {
82
68
  }
83
69
  }
84
70
  }
85
-
86
71
  function* renewSubscription() {
87
72
  const {
88
73
  subscription
89
74
  } = yield (0, _effects.select)(state => state.subscriptions.billing.subscription);
90
-
91
75
  if (!subscription) {
92
76
  yield (0, _effects.put)(_index.subscriptionActions.setCancellationError('Subscription not found.'));
93
77
  return;
94
78
  }
95
-
96
79
  if (subscription != null && subscription.externallyManaged) {
97
80
  yield (0, _effects.put)(_index.subscriptionActions.setCancellationError('Billing is externally managed'));
98
81
  return;
99
82
  }
100
-
101
83
  const {
102
84
  id: subscriptionId,
103
85
  cancellation
104
86
  } = subscription || {};
105
87
  const renewable = (cancellation == null ? void 0 : cancellation.policy) === _restApi.ISubscriptionCancellationPolicy.AT_PERIOD_END;
106
-
107
88
  if (renewable) {
108
89
  try {
109
90
  yield (0, _effects.put)(_index.subscriptionActions.setRenewalLoading(true));
@@ -115,11 +96,11 @@ function* renewSubscription() {
115
96
  }
116
97
  }
117
98
  }
99
+
118
100
  /*********************************
119
101
  * Preview Sagas
120
102
  *********************************/
121
103
 
122
-
123
104
  function* loadMock() {
124
105
  yield (0, _effects.put)(_index.subscriptionActions.setLoading(true));
125
106
  yield (0, _effects.delay)(500);
@@ -130,7 +111,6 @@ function* loadMock() {
130
111
  error: null
131
112
  }));
132
113
  }
133
-
134
114
  function* subscriptionSagasMock() {
135
115
  yield (0, _effects.takeEvery)(_index.subscriptionActions.load, loadMock);
136
116
  }
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.billingReducer = exports.billingInitialState = exports.billingActions = void 0;
7
-
8
7
  var _toolkit = require("@reduxjs/toolkit");
9
-
10
8
  var _Information = require("./Information");
11
-
12
9
  var _PaymentMethod = require("./PaymentMethod");
13
-
14
10
  var _Invoices = require("./Invoices");
15
-
16
11
  var _Subscription = require("./Subscription");
17
-
18
12
  const billingInitialState = {
19
13
  information: _Information.initialBillingInformationState,
20
14
  invoices: _Invoices.initialInvoicesState,
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  var _interfaces = require("./Information/interfaces");
8
-
9
7
  Object.keys(_interfaces).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _interfaces[key]) return;
@@ -16,9 +14,7 @@ Object.keys(_interfaces).forEach(function (key) {
16
14
  }
17
15
  });
18
16
  });
19
-
20
17
  var _interfaces2 = require("./PaymentMethod/interfaces");
21
-
22
18
  Object.keys(_interfaces2).forEach(function (key) {
23
19
  if (key === "default" || key === "__esModule") return;
24
20
  if (key in exports && exports[key] === _interfaces2[key]) return;
@@ -29,9 +25,7 @@ Object.keys(_interfaces2).forEach(function (key) {
29
25
  }
30
26
  });
31
27
  });
32
-
33
28
  var _interfaces3 = require("./Invoices/interfaces");
34
-
35
29
  Object.keys(_interfaces3).forEach(function (key) {
36
30
  if (key === "default" || key === "__esModule") return;
37
31
  if (key in exports && exports[key] === _interfaces3[key]) return;
@@ -42,9 +36,7 @@ Object.keys(_interfaces3).forEach(function (key) {
42
36
  }
43
37
  });
44
38
  });
45
-
46
39
  var _interfaces4 = require("./Subscription/interfaces");
47
-
48
40
  Object.keys(_interfaces4).forEach(function (key) {
49
41
  if (key === "default" || key === "__esModule") return;
50
42
  if (key in exports && exports[key] === _interfaces4[key]) return;
@@ -5,21 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.billingSagas = billingSagas;
7
7
  exports.billingSagasMock = billingSagasMock;
8
-
9
8
  var _effects = require("redux-saga/effects");
10
-
11
9
  var _saga = require("./Information/saga");
12
-
13
10
  var _saga2 = require("./PaymentMethod/saga");
14
-
15
11
  var _saga3 = require("./Invoices/saga");
16
-
17
12
  var _saga4 = require("./Subscription/saga");
18
-
19
13
  function* billingSagas() {
20
14
  yield (0, _effects.all)([(0, _effects.call)(_saga.subscriptionBillingInformationSagas), (0, _effects.call)(_saga2.subscriptionsPaymentMethodSagas), (0, _effects.call)(_saga3.subscriptionInvoicesSagas), (0, _effects.call)(_saga4.subscriptionSagas)]);
21
15
  }
22
-
23
16
  function* billingSagasMock() {
24
17
  yield (0, _effects.all)([(0, _effects.call)(_saga.subscriptionBillingInformationSagasMock), (0, _effects.call)(_saga2.subscriptionsPaymentMethodSagasMock), (0, _effects.call)(_saga3.subscriptionInvoicesSagasMock), (0, _effects.call)(_saga4.subscriptionSagasMock)]);
25
18
  }
@@ -1,20 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.checkoutReducer = exports.checkoutInitialState = exports.checkoutActions = void 0;
9
-
10
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
-
12
9
  var _toolkit = require("@reduxjs/toolkit");
13
-
14
10
  var _utils = require("../utils");
15
-
16
11
  var _constants = require("../../constants");
17
-
18
12
  const checkoutInitialState = {
19
13
  fetching: true,
20
14
  loading: false,
@@ -1,29 +1,19 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.checkoutSagas = checkoutSagas;
9
8
  exports.checkoutSagasMock = checkoutSagasMock;
10
-
11
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
12
-
13
10
  var _effects = require("redux-saga/effects");
14
-
15
11
  var _index = require("./index");
16
-
17
12
  var _restApi = require("@frontegg/rest-api");
18
-
19
13
  var _Subscription = require("../Billing/Subscription");
20
-
21
14
  var _saga = require("../Billing/Information/saga");
22
-
23
15
  var _saga2 = require("../Billing/PaymentMethod/saga");
24
-
25
16
  var _saga3 = require("../Billing/Invoices/saga");
26
-
27
17
  function* checkoutSagas() {
28
18
  yield (0, _effects.takeEvery)(_index.checkoutActions.loadCheckout, loadCheckout);
29
19
  yield (0, _effects.takeEvery)(_index.checkoutActions.resetCheckout, resetCheckout);
@@ -31,7 +21,6 @@ function* checkoutSagas() {
31
21
  yield (0, _effects.takeEvery)(_index.checkoutActions.confirmCheckout, confirmPlan);
32
22
  yield (0, _effects.takeEvery)(_index.checkoutActions.errorCheckout, errorCheckout);
33
23
  }
34
-
35
24
  function* loadCheckout() {
36
25
  yield (0, _effects.put)(_index.checkoutActions.setState({
37
26
  fetching: false,
@@ -40,7 +29,6 @@ function* loadCheckout() {
40
29
  confirmed: false
41
30
  }));
42
31
  }
43
-
44
32
  function* resetCheckout() {
45
33
  yield (0, _effects.put)(_index.checkoutActions.setState({
46
34
  loading: false,
@@ -48,18 +36,16 @@ function* resetCheckout() {
48
36
  confirmed: false
49
37
  }));
50
38
  }
39
+
51
40
  /**
52
41
  * Based on payment provider type
53
42
  */
54
-
55
-
56
43
  function* submitCheckout() {
57
44
  yield (0, _effects.put)(_index.checkoutActions.setState({
58
45
  loading: true,
59
46
  error: null
60
47
  }));
61
48
  }
62
-
63
49
  function* confirmPlan({
64
50
  payload: {
65
51
  paymentMethodId,
@@ -70,7 +56,6 @@ function* confirmPlan({
70
56
  const summary = yield (0, _effects.select)(state => state.subscriptions.billing.information.summary);
71
57
  const isTrialing = (subscription == null ? void 0 : subscription.status) === _restApi.ISubscriptionStatus.TRIALING;
72
58
  const hasPaymentMethod = !!(summary != null && summary.paymentMethodId);
73
-
74
59
  if (!subscription) {
75
60
  yield (0, _effects.put)(_index.checkoutActions.setState({
76
61
  loading: false,
@@ -78,12 +63,10 @@ function* confirmPlan({
78
63
  }));
79
64
  return;
80
65
  }
81
-
82
66
  yield (0, _effects.put)(_index.checkoutActions.setState({
83
67
  loading: true,
84
68
  error: null
85
69
  }));
86
-
87
70
  if (isTrialing && hasPaymentMethod) {
88
71
  yield confirmCheckout();
89
72
  yield (0, _effects.put)(_Subscription.subscriptionActions.setState({
@@ -93,7 +76,6 @@ function* confirmPlan({
93
76
  }));
94
77
  return;
95
78
  }
96
-
97
79
  try {
98
80
  yield (0, _effects.call)(_restApi.api.subscriptions.updateManagedSubscription, subscription.id, {
99
81
  paymentMethodId,
@@ -108,7 +90,6 @@ function* confirmPlan({
108
90
  }));
109
91
  }
110
92
  }
111
-
112
93
  function* confirmCheckout() {
113
94
  yield (0, _effects.put)(_index.checkoutActions.setState({
114
95
  loading: false,
@@ -116,7 +97,6 @@ function* confirmCheckout() {
116
97
  confirmed: true
117
98
  }));
118
99
  }
119
-
120
100
  function* errorCheckout({
121
101
  payload
122
102
  }) {
@@ -125,11 +105,11 @@ function* errorCheckout({
125
105
  error: payload
126
106
  }));
127
107
  }
108
+
128
109
  /*********************************
129
110
  * Preview Sagas
130
111
  *********************************/
131
112
 
132
-
133
113
  function* checkoutSagasMock() {
134
114
  yield (0, _effects.takeEvery)(_index.checkoutActions.resetCheckout, resetCheckout);
135
115
  }