@frontegg/redux-store 5.19.0 → 5.22.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 (39) hide show
  1. package/auth/AcceptInvitationState/index.d.ts +2 -0
  2. package/auth/AccountSettingsState/index.d.ts +10 -0
  3. package/auth/ActivateState/index.d.ts +6 -1
  4. package/auth/ActivateState/interfaces.d.ts +6 -1
  5. package/auth/ApiTokensState/index.d.ts +2 -0
  6. package/auth/ForgotPasswordState/index.d.ts +2 -0
  7. package/auth/LoginState/index.d.ts +2 -0
  8. package/auth/LoginState/interfaces.d.ts +2 -0
  9. package/auth/LoginState/saga.d.ts +2 -0
  10. package/auth/MfaState/index.d.ts +6 -6
  11. package/auth/ProfileState/index.d.ts +2 -0
  12. package/auth/ResetPhoneNumberState/index.d.ts +96 -0
  13. package/auth/ResetPhoneNumberState/interfaces.d.ts +18 -0
  14. package/auth/ResetPhoneNumberState/saga.d.ts +17 -0
  15. package/auth/RolesState/index.d.ts +2 -0
  16. package/auth/SSOState/index.d.ts +2 -0
  17. package/auth/SecurityPolicyState/index.d.ts +9 -0
  18. package/auth/SignUp/index.d.ts +2 -0
  19. package/auth/SocialLogins/index.d.ts +2 -8
  20. package/auth/TeamState/index.d.ts +2 -0
  21. package/auth/TenantsState/index.d.ts +2 -8
  22. package/auth/index.d.ts +14 -0
  23. package/auth/index.js +127 -17
  24. package/auth/interfaces.d.ts +15 -1
  25. package/auth/reducer.d.ts +14 -1
  26. package/auth/utils.d.ts +4 -0
  27. package/index.js +2 -2
  28. package/node/auth/index.js +137 -24
  29. package/node/index.js +15 -0
  30. package/node/subscriptions/index.js +167 -127
  31. package/package.json +2 -2
  32. package/subscriptions/ManagedSubscriptions/index.d.ts +10 -0
  33. package/subscriptions/ManagedSubscriptions/interfaces.d.ts +28 -0
  34. package/subscriptions/ManagedSubscriptions/saga.d.ts +1 -0
  35. package/subscriptions/index.d.ts +7 -0
  36. package/subscriptions/index.js +168 -128
  37. package/subscriptions/interfaces.d.ts +4 -0
  38. package/subscriptions/reducer.d.ts +7 -0
  39. package/toolkit/index.d.ts +1 -1
@@ -42,12 +42,12 @@ const plansInitialState = {
42
42
  fetching: true,
43
43
  plans: [],
44
44
  };
45
- const { actions: sliceActions$1, reducer: reducer$7, name: name$6 } = toolkit.createSlice({
45
+ const { actions: sliceActions$2, reducer: reducer$8, name: name$7 } = toolkit.createSlice({
46
46
  name: `${constants.subscriptionsStoreName}/plans`,
47
47
  initialState: plansInitialState,
48
48
  reducers: Object.assign({}, createModuleCaseReducers()),
49
49
  });
50
- const actions$7 = Object.assign({ loadPlans: toolkit.createAction(`${name$6}/loadPlans`) }, sliceActions$1);
50
+ const actions$8 = Object.assign({ loadPlans: toolkit.createAction(`${name$7}/loadPlans`) }, sliceActions$2);
51
51
 
52
52
  const configInitialState = {
53
53
  loading: false,
@@ -56,12 +56,12 @@ const configInitialState = {
56
56
  config: null,
57
57
  };
58
58
  const reducers$5 = Object.assign({}, createModuleCaseReducers());
59
- const { actions: configActions, reducer: reducer$6, name: name$5, } = toolkit.createSlice({
59
+ const { actions: configActions, reducer: reducer$7, name: name$6, } = toolkit.createSlice({
60
60
  name: `${constants.subscriptionsStoreName}/config`,
61
61
  initialState: configInitialState,
62
62
  reducers: reducers$5,
63
63
  });
64
- const actions$6 = Object.assign({ loadPaymentConfiguration: toolkit.createAction(`${name$5}/loadPaymentConfiguration`) }, configActions);
64
+ const actions$7 = Object.assign({ loadPaymentConfiguration: toolkit.createAction(`${name$6}/loadPaymentConfiguration`) }, configActions);
65
65
 
66
66
  const initialBillingInformationState = {
67
67
  loading: false,
@@ -82,12 +82,12 @@ const reducers$4 = Object.assign(Object.assign({}, createModuleCaseReducers()),
82
82
  prepare: (payload) => ({ payload }),
83
83
  reducer: (state, action) => (Object.assign(Object.assign({}, state), action.payload)),
84
84
  }, setCancellationLoading: createKeyCaseLoadingReducer('cancellation'), setCancellationError: createKeyCaseErrorReducer('cancellation'), setRenewalLoading: createKeyCaseLoadingReducer('renewal'), setRenewalError: createKeyCaseErrorReducer('renewal') });
85
- const { reducer: reducer$5, actions: overviewActions, name: name$4, } = toolkit.createSlice({
85
+ const { reducer: reducer$6, actions: overviewActions, name: name$5, } = toolkit.createSlice({
86
86
  name: `${constants.subscriptionsStoreName}/billing/information`,
87
87
  initialState: initialBillingInformationState,
88
88
  reducers: reducers$4,
89
89
  });
90
- const actions$5 = Object.assign({ loadBillingInformation: toolkit.createAction(`${name$4}/loadBillingInformation`), cancelSubscription: toolkit.createAction(`${name$4}/cancelSubscription`), renewSubscription: toolkit.createAction(`${name$4}/renewSubscription`) }, overviewActions);
90
+ const actions$6 = Object.assign({ loadBillingInformation: toolkit.createAction(`${name$5}/loadBillingInformation`), cancelSubscription: toolkit.createAction(`${name$5}/cancelSubscription`), renewSubscription: toolkit.createAction(`${name$5}/renewSubscription`) }, overviewActions);
91
91
 
92
92
  const initialPaymentMethodState = {
93
93
  loading: false,
@@ -98,12 +98,12 @@ const reducers$3 = Object.assign(Object.assign({}, createModuleCaseReducers()),
98
98
  prepare: (payload) => ({ payload }),
99
99
  reducer: (state, action) => (Object.assign(Object.assign({}, state), action.payload)),
100
100
  } });
101
- const { reducer: reducer$4, actions: paymentActions, name: name$3, } = toolkit.createSlice({
101
+ const { reducer: reducer$5, actions: paymentActions, name: name$4, } = toolkit.createSlice({
102
102
  name: `${constants.subscriptionsStoreName}/billing/payment`,
103
103
  initialState: initialPaymentMethodState,
104
104
  reducers: reducers$3,
105
105
  });
106
- 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);
106
+ const actions$5 = Object.assign({ loadPaymentMethod: toolkit.createAction(`${name$4}/loadPaymentMethod`), submitPaymentMethod: toolkit.createAction(`${name$4}/submitPaymentMethod`), submitPaymentMethodError: toolkit.createAction(`${name$4}/submitPaymentMethodError`), submitPaymentMethodSuccess: toolkit.createAction(`${name$4}/submitPaymentMethodSuccess`), updatePaymentMethodBillingDetails: toolkit.createAction(`${name$4}/updateBillingDetails`, (payload) => ({ payload })) }, paymentActions);
107
107
 
108
108
  const initialInvoicesState = {
109
109
  loading: false,
@@ -119,12 +119,12 @@ const reducers$2 = Object.assign(Object.assign({}, createModuleCaseReducers()),
119
119
  prepare: (payload) => ({ payload }),
120
120
  reducer: (state, action) => (Object.assign(Object.assign({}, state), { invoiceDownload: Object.assign(Object.assign({}, state.invoiceDownload), action.payload) })),
121
121
  } });
122
- const { reducer: reducer$3, actions: sliceActions, name: name$2, } = toolkit.createSlice({
122
+ const { reducer: reducer$4, actions: sliceActions$1, name: name$3, } = toolkit.createSlice({
123
123
  name: `${constants.subscriptionsStoreName}/billing/invoices`,
124
124
  initialState: initialInvoicesState,
125
125
  reducers: reducers$2,
126
126
  });
127
- const actions$3 = Object.assign({ loadInvoices: toolkit.createAction(`${name$2}/loadInvoices`), downloadInvoice: toolkit.createAction(`${name$2}/downloadInvoice`, (payload) => ({ payload })) }, sliceActions);
127
+ const actions$4 = Object.assign({ loadInvoices: toolkit.createAction(`${name$3}/loadInvoices`), downloadInvoice: toolkit.createAction(`${name$3}/downloadInvoice`, (payload) => ({ payload })) }, sliceActions$1);
128
128
 
129
129
  const billingInitialState = {
130
130
  information: initialBillingInformationState,
@@ -132,14 +132,14 @@ const billingInitialState = {
132
132
  paymentMethod: initialPaymentMethodState,
133
133
  };
134
134
  const billingActions = {
135
- invoices: actions$3,
136
- information: actions$5,
137
- paymentMethod: actions$4,
135
+ invoices: actions$4,
136
+ information: actions$6,
137
+ paymentMethod: actions$5,
138
138
  };
139
139
  const billingReducer = toolkit.combineReducers({
140
- invoices: reducer$3,
141
- information: reducer$5,
142
- paymentMethod: reducer$4,
140
+ invoices: reducer$4,
141
+ information: reducer$6,
142
+ paymentMethod: reducer$5,
143
143
  });
144
144
 
145
145
  exports.CheckoutStatus = void 0;
@@ -172,12 +172,12 @@ const reducers$1 = Object.assign(Object.assign({}, createModuleCaseReducers()),
172
172
  prepare: (payload) => ({ payload }),
173
173
  reducer: (state, action) => (Object.assign(Object.assign({}, state), { checkoutPlanId: action.payload })),
174
174
  } });
175
- const { actions: checkoutActions, reducer: reducer$2, name: name$1 } = toolkit.createSlice({
175
+ const { actions: checkoutActions, reducer: reducer$3, name: name$2 } = toolkit.createSlice({
176
176
  name: `${constants.subscriptionsStoreName}/checkout`,
177
177
  initialState: checkoutInitialState,
178
178
  reducers: reducers$1,
179
179
  });
180
- const actions$2 = Object.assign({ checkoutPlan: toolkit.createAction(`${name$1}/checkoutPlan`, (payload) => ({ payload })), resetCheckout: toolkit.createAction(`${name$1}/resetCheckout`), confirmCheckout: toolkit.createAction(`${name$1}/confirmCheckout`, (payload) => ({ payload, })), cancelCheckout: toolkit.createAction(`${name$1}/cancelCheckout`), submitCheckout: toolkit.createAction(`${name$1}/submitCheckout`), errorCheckout: toolkit.createAction(`${name$1}/errorCheckout`, (payload) => ({ payload, })), checkoutEvent: toolkit.createAction(`${name$1}/checkoutEvent`, (payload) => ({ payload, })) }, checkoutActions);
180
+ const actions$3 = Object.assign({ checkoutPlan: toolkit.createAction(`${name$2}/checkoutPlan`, (payload) => ({ payload })), resetCheckout: toolkit.createAction(`${name$2}/resetCheckout`), confirmCheckout: toolkit.createAction(`${name$2}/confirmCheckout`, (payload) => ({ payload, })), cancelCheckout: toolkit.createAction(`${name$2}/cancelCheckout`), submitCheckout: toolkit.createAction(`${name$2}/submitCheckout`), errorCheckout: toolkit.createAction(`${name$2}/errorCheckout`, (payload) => ({ payload, })), checkoutEvent: toolkit.createAction(`${name$2}/checkoutEvent`, (payload) => ({ payload, })) }, checkoutActions);
181
181
 
182
182
  const initialSubscriptionStripeState = {
183
183
  loading: false,
@@ -188,12 +188,26 @@ const reducers = Object.assign(Object.assign({}, createModuleCaseReducers()), {
188
188
  prepare: (payload) => ({ payload }),
189
189
  reducer: (state, action) => (Object.assign(Object.assign({}, state), action.payload)),
190
190
  } });
191
- const { reducer: reducer$1, actions: reducerActions, name, } = toolkit.createSlice({
191
+ const { reducer: reducer$2, actions: reducerActions, name: name$1, } = toolkit.createSlice({
192
192
  name: `${constants.subscriptionsStoreName}/stripe`,
193
193
  initialState: initialSubscriptionStripeState,
194
194
  reducers,
195
195
  });
196
- const actions$1 = Object.assign({ loadCustomer: toolkit.createAction(`${name}/loadCustomer`), createCardSetupIntentSecret: toolkit.createAction(`${name}/createCardSetupIntentSecret`) }, reducerActions);
196
+ const actions$2 = Object.assign({ loadCustomer: toolkit.createAction(`${name$1}/loadCustomer`), createCardSetupIntentSecret: toolkit.createAction(`${name$1}/createCardSetupIntentSecret`) }, reducerActions);
197
+
198
+ const managedSubscriptionsInitialState = {
199
+ loading: false,
200
+ error: null,
201
+ fetching: true,
202
+ managedSubscriptions: [],
203
+ };
204
+ Object.assign({}, createModuleCaseReducers());
205
+ const { reducer: reducer$1, actions: sliceActions, name } = toolkit.createSlice({
206
+ name: `${constants.subscriptionsStoreName}/managedSubscriptions`,
207
+ initialState: managedSubscriptionsInitialState,
208
+ reducers: Object.assign({}, createModuleCaseReducers()),
209
+ });
210
+ const actions$1 = Object.assign({ loadManagedSubscriptions: toolkit.createAction(`${name}/loadManagedSubscriptions`) }, sliceActions);
197
211
 
198
212
  const initialState = {
199
213
  config: configInitialState,
@@ -201,20 +215,23 @@ const initialState = {
201
215
  checkout: checkoutInitialState,
202
216
  billing: billingInitialState,
203
217
  stripe: initialSubscriptionStripeState,
218
+ managedSubscriptions: managedSubscriptionsInitialState,
204
219
  };
205
220
  const actions = {
206
- config: actions$6,
221
+ config: actions$7,
207
222
  billing: billingActions,
208
- plans: actions$7,
209
- checkout: actions$2,
210
- stripe: actions$1,
223
+ plans: actions$8,
224
+ checkout: actions$3,
225
+ stripe: actions$2,
226
+ managedSubscriptions: actions$1,
211
227
  };
212
228
  const reducer = toolkit.combineReducers({
213
- config: reducer$6,
229
+ config: reducer$7,
214
230
  billing: billingReducer,
215
- plans: reducer$7,
216
- checkout: reducer$2,
217
- stripe: reducer$1,
231
+ plans: reducer$8,
232
+ checkout: reducer$3,
233
+ stripe: reducer$2,
234
+ managedSubscriptions: reducer$1,
218
235
  });
219
236
 
220
237
  exports.PaymentProvider = void 0;
@@ -347,34 +364,34 @@ const paymentMethodsMock = [
347
364
  ];
348
365
 
349
366
  function* subscriptionBillingInformationSagas() {
350
- yield effects.takeEvery(actions$5.loadBillingInformation, loadBillingInformation);
351
- yield effects.takeEvery(actions$5.cancelSubscription, cancelSubscription);
352
- yield effects.takeEvery(actions$5.renewSubscription, renewSubscription);
353
- yield effects.takeEvery(actions$2.checkoutEvent, checkoutEvent$2);
367
+ yield effects.takeEvery(actions$6.loadBillingInformation, loadBillingInformation);
368
+ yield effects.takeEvery(actions$6.cancelSubscription, cancelSubscription);
369
+ yield effects.takeEvery(actions$6.renewSubscription, renewSubscription);
370
+ yield effects.takeEvery(actions$3.checkoutEvent, checkoutEvent$2);
354
371
  }
355
372
  function* loadBillingInformation() {
356
373
  const paymentProvider = yield effects.select((state) => { var _a; return (_a = state.subscriptions.config.config) === null || _a === void 0 ? void 0 : _a.paymentProvider; });
357
374
  const tenantId = yield effects.select((state) => { var _a, _b, _c; return (_c = (_b = (_a = state.auth) === null || _a === void 0 ? void 0 : _a.profileState) === null || _b === void 0 ? void 0 : _b.profile) === null || _c === void 0 ? void 0 : _c.tenantId; });
358
- yield effects.put(actions$5.setLoading(true));
375
+ yield effects.put(actions$6.setLoading(true));
359
376
  if (!paymentProvider || !tenantId) {
360
- yield effects.put(actions$5.setError(!paymentProvider ? 'Internal feature failure' : 'Not authorized'));
377
+ yield effects.put(actions$6.setError(!paymentProvider ? 'Internal feature failure' : 'Not authorized'));
361
378
  return;
362
379
  }
363
380
  try {
364
381
  yield loadSummaries(tenantId);
365
382
  }
366
383
  catch (e) {
367
- yield effects.put(actions$5.setError(e.message));
384
+ yield effects.put(actions$6.setError(e.message));
368
385
  }
369
386
  }
370
387
  function* loadSummaries(tenantId) {
371
388
  var _a, _b;
372
- yield effects.put(actions$5.setLoading(true));
389
+ yield effects.put(actions$6.setLoading(true));
373
390
  try {
374
391
  const { currentPlanId, subscriptionId, externallyManaged, defaultPlanId } = yield effects.call(restApi.api.subscriptions.getSubscriptionSummaries, tenantId);
375
392
  const subscriptionResponse = yield effects.call(restApi.api.subscriptions.getSubscription, subscriptionId);
376
393
  const planResponse = yield effects.call(restApi.api.subscriptions.getSubscriptionPlan, currentPlanId);
377
- yield effects.put(actions$5.setBillingInformation(Object.assign(Object.assign({ loading: false, fetching: false, externallyManaged,
394
+ yield effects.put(actions$6.setBillingInformation(Object.assign(Object.assign({ loading: false, fetching: false, externallyManaged,
378
395
  defaultPlanId }, (subscriptionResponse
379
396
  ? {
380
397
  subscription: {
@@ -405,7 +422,7 @@ function* loadSummaries(tenantId) {
405
422
  : {}))));
406
423
  }
407
424
  catch (e) {
408
- yield effects.put(actions$5.setError(e.message));
425
+ yield effects.put(actions$6.setError(e.message));
409
426
  }
410
427
  }
411
428
  function* cancelSubscription() {
@@ -414,24 +431,24 @@ function* cancelSubscription() {
414
431
  return;
415
432
  }
416
433
  if (overview.externallyManaged) {
417
- yield effects.put(actions$5.setCancellationError('Billing is externally managed'));
434
+ yield effects.put(actions$6.setCancellationError('Billing is externally managed'));
418
435
  return;
419
436
  }
420
437
  const { id: subscriptionId, cancellation, status } = overview.subscription || {};
421
438
  const isCancellable = !cancellation && status === exports.SubscriptionStatus.ACTIVE;
422
439
  if (isCancellable) {
423
440
  try {
424
- yield effects.put(actions$5.setCancellationLoading(true));
441
+ yield effects.put(actions$6.setCancellationLoading(true));
425
442
  yield effects.call(restApi.api.subscriptions.cancelSubscription, subscriptionId);
426
- yield effects.put(actions$5.setBillingInformation({
443
+ yield effects.put(actions$6.setBillingInformation({
427
444
  subscription: Object.assign(Object.assign({}, overview.subscription), { cancellation: {
428
445
  policy: exports.SubscriptionCancellationPolicy.AT_PERIOD_END,
429
446
  } }),
430
447
  }));
431
- yield effects.put(actions$5.setCancellationLoading(false));
448
+ yield effects.put(actions$6.setCancellationLoading(false));
432
449
  }
433
450
  catch (e) {
434
- yield effects.put(actions$5.setCancellationError(e.message));
451
+ yield effects.put(actions$6.setCancellationError(e.message));
435
452
  }
436
453
  }
437
454
  }
@@ -441,22 +458,22 @@ function* renewSubscription() {
441
458
  return;
442
459
  }
443
460
  if (overview.externallyManaged) {
444
- yield effects.put(actions$5.setCancellationError('Billing is externally managed'));
461
+ yield effects.put(actions$6.setCancellationError('Billing is externally managed'));
445
462
  return;
446
463
  }
447
464
  const { id: subscriptionId, cancellation } = overview.subscription || {};
448
465
  const renewable = (cancellation === null || cancellation === void 0 ? void 0 : cancellation.policy) === exports.SubscriptionCancellationPolicy.AT_PERIOD_END;
449
466
  if (renewable) {
450
467
  try {
451
- yield effects.put(actions$5.setRenewalLoading(true));
468
+ yield effects.put(actions$6.setRenewalLoading(true));
452
469
  yield effects.call(restApi.api.subscriptions.renewSubscription, subscriptionId);
453
- yield effects.put(actions$5.setBillingInformation({
470
+ yield effects.put(actions$6.setBillingInformation({
454
471
  subscription: Object.assign(Object.assign({}, overview.subscription), { cancellation: null }),
455
472
  }));
456
- yield effects.put(actions$5.setRenewalLoading(false));
473
+ yield effects.put(actions$6.setRenewalLoading(false));
457
474
  }
458
475
  catch (e) {
459
- yield effects.put(actions$5.setCancellationError(e.message));
476
+ yield effects.put(actions$6.setCancellationError(e.message));
460
477
  }
461
478
  }
462
479
  }
@@ -469,14 +486,14 @@ function* checkoutEvent$2({ payload }) {
469
486
  * Preview Sagas
470
487
  *********************************/
471
488
  function* loadBillingInformationMock() {
472
- yield effects.put(actions$5.setLoading(true));
489
+ yield effects.put(actions$6.setLoading(true));
473
490
  yield loadSummariesMock();
474
491
  }
475
492
  function* loadSummariesMock() {
476
493
  var _a, _b;
477
- yield effects.put(actions$5.setLoading(true));
494
+ yield effects.put(actions$6.setLoading(true));
478
495
  yield effects.delay(500);
479
- yield effects.put(actions$5.setBillingInformation({
496
+ yield effects.put(actions$6.setBillingInformation({
480
497
  loading: false,
481
498
  fetching: false,
482
499
  externallyManaged: false,
@@ -485,30 +502,30 @@ function* loadSummariesMock() {
485
502
  }));
486
503
  }
487
504
  function* subscriptionBillingInformationSagasMock() {
488
- yield effects.takeEvery(actions$5.loadBillingInformation, loadBillingInformationMock);
505
+ yield effects.takeEvery(actions$6.loadBillingInformation, loadBillingInformationMock);
489
506
  }
490
507
 
491
508
  function* subscriptionsPaymentMethodSagas() {
492
- yield effects.takeEvery(actions$4.loadPaymentMethod, loadPaymentMethod);
493
- yield effects.takeEvery(actions$4.submitPaymentMethod, submitPaymentMethod);
494
- yield effects.takeEvery(actions$4.submitPaymentMethodError, submitPaymentMethodError);
495
- yield effects.takeEvery(actions$4.submitPaymentMethodSuccess, submitPaymentMethodSuccess);
496
- yield effects.takeEvery(actions$4.updatePaymentMethodBillingDetails, updateBillingDetails);
497
- yield effects.takeEvery(actions$2.checkoutEvent, checkoutEvent$1);
509
+ yield effects.takeEvery(actions$5.loadPaymentMethod, loadPaymentMethod);
510
+ yield effects.takeEvery(actions$5.submitPaymentMethod, submitPaymentMethod);
511
+ yield effects.takeEvery(actions$5.submitPaymentMethodError, submitPaymentMethodError);
512
+ yield effects.takeEvery(actions$5.submitPaymentMethodSuccess, submitPaymentMethodSuccess);
513
+ yield effects.takeEvery(actions$5.updatePaymentMethodBillingDetails, updateBillingDetails);
514
+ yield effects.takeEvery(actions$3.checkoutEvent, checkoutEvent$1);
498
515
  }
499
516
  function* loadPaymentMethod() {
500
- yield effects.put(actions$4.setLoading(true));
517
+ yield effects.put(actions$5.setLoading(true));
501
518
  try {
502
519
  const paymentMethods = yield effects.call(restApi.api.subscriptions.getPaymentMethods);
503
520
  const paymentMethod = paymentMethods[0];
504
- yield effects.put(actions$4.setState({
521
+ yield effects.put(actions$5.setState({
505
522
  paymentMethod,
506
523
  loading: false,
507
524
  fetching: false,
508
525
  }));
509
526
  }
510
527
  catch (e) {
511
- yield effects.put(actions$4.setError(e.message));
528
+ yield effects.put(actions$5.setError(e.message));
512
529
  }
513
530
  }
514
531
  function* checkoutEvent$1({ payload }) {
@@ -517,7 +534,7 @@ function* checkoutEvent$1({ payload }) {
517
534
  }
518
535
  }
519
536
  function* updateBillingDetails({ payload, }) {
520
- yield effects.put(actions$4.setLoading(true));
537
+ yield effects.put(actions$5.setLoading(true));
521
538
  const { id, email, address, callback } = payload;
522
539
  try {
523
540
  yield effects.call(restApi.api.subscriptions.updatePaymentMethodBillingDetails, id, Object.assign({ email }, address));
@@ -525,44 +542,44 @@ function* updateBillingDetails({ payload, }) {
525
542
  callback === null || callback === void 0 ? void 0 : callback(true);
526
543
  }
527
544
  catch (e) {
528
- yield effects.put(actions$4.setError(e.message));
545
+ yield effects.put(actions$5.setError(e.message));
529
546
  callback === null || callback === void 0 ? void 0 : callback(false);
530
547
  }
531
- yield effects.put(actions$4.setLoading(false));
548
+ yield effects.put(actions$5.setLoading(false));
532
549
  }
533
550
  function* submitPaymentMethod() {
534
- yield effects.put(actions$4.setLoading(true));
551
+ yield effects.put(actions$5.setLoading(true));
535
552
  }
536
553
  function* submitPaymentMethodError({ payload: error }) {
537
- yield effects.put(actions$4.setError(error));
554
+ yield effects.put(actions$5.setError(error));
538
555
  }
539
556
  function* submitPaymentMethodSuccess() {
540
- yield effects.put(actions$4.loadPaymentMethod());
557
+ yield effects.put(actions$5.loadPaymentMethod());
541
558
  }
542
559
  /*********************************
543
560
  * Preview Sagas
544
561
  *********************************/
545
562
  function* loadPaymentMethodMock() {
546
- yield effects.put(actions$4.setLoading(true));
563
+ yield effects.put(actions$5.setLoading(true));
547
564
  yield effects.delay(500);
548
565
  const paymentMethod = paymentMethodsMock[0];
549
- yield effects.put(actions$4.setState({
566
+ yield effects.put(actions$5.setState({
550
567
  paymentMethod,
551
568
  loading: false,
552
569
  fetching: false,
553
570
  }));
554
571
  }
555
572
  function* subscriptionsPaymentMethodSagasMock() {
556
- yield effects.takeEvery(actions$4.loadPaymentMethod, loadPaymentMethodMock);
573
+ yield effects.takeEvery(actions$5.loadPaymentMethod, loadPaymentMethodMock);
557
574
  }
558
575
 
559
576
  function* subscriptionInvoicesSagas() {
560
- yield effects.takeEvery(actions$3.loadInvoices, loadInvoices);
561
- yield effects.takeEvery(actions$3.downloadInvoice, downloadInvoice);
562
- yield effects.takeEvery(actions$2.checkoutEvent, checkoutEvent);
577
+ yield effects.takeEvery(actions$4.loadInvoices, loadInvoices);
578
+ yield effects.takeEvery(actions$4.downloadInvoice, downloadInvoice);
579
+ yield effects.takeEvery(actions$3.checkoutEvent, checkoutEvent);
563
580
  }
564
581
  function* loadInvoices() {
565
- yield effects.put(actions$3.setLoading(true));
582
+ yield effects.put(actions$4.setLoading(true));
566
583
  try {
567
584
  const responseInvoices = yield effects.call(restApi.api.subscriptions.getSubscriptionInvoices);
568
585
  const invoices = responseInvoices.map((invoice) => ({
@@ -575,24 +592,24 @@ function* loadInvoices() {
575
592
  paid: invoice.paid || false,
576
593
  receiptNumber: invoice.receiptNumber,
577
594
  }));
578
- yield effects.put(actions$3.setState({
595
+ yield effects.put(actions$4.setState({
579
596
  loading: false,
580
597
  fetching: false,
581
598
  invoices,
582
599
  }));
583
600
  }
584
601
  catch (e) {
585
- yield effects.put(actions$3.setError(e.message));
602
+ yield effects.put(actions$4.setError(e.message));
586
603
  }
587
604
  }
588
605
  function* downloadInvoice({ payload }) {
589
- yield effects.put(actions$3.setInvoiceDownloadState({ loading: true, error: null }));
606
+ yield effects.put(actions$4.setInvoiceDownloadState({ loading: true, error: null }));
590
607
  try {
591
608
  yield effects.call(restApi.api.subscriptions.getSubscriptionInvoicePdf, payload.invoiceId, payload.filename);
592
- yield effects.put(actions$3.setInvoiceDownloadState({ loading: false, error: null }));
609
+ yield effects.put(actions$4.setInvoiceDownloadState({ loading: false, error: null }));
593
610
  }
594
611
  catch (e) {
595
- yield effects.put(actions$3.setInvoiceDownloadState({ loading: false, error: e.message || null }));
612
+ yield effects.put(actions$4.setInvoiceDownloadState({ loading: false, error: e.message || null }));
596
613
  }
597
614
  }
598
615
  function* checkoutEvent({ payload }) {
@@ -604,18 +621,18 @@ function* checkoutEvent({ payload }) {
604
621
  * Preview Sagas
605
622
  *********************************/
606
623
  function* loadInvoicesMock() {
607
- yield effects.put(actions$3.setLoading(true));
624
+ yield effects.put(actions$4.setLoading(true));
608
625
  yield effects.delay(500);
609
626
  const selectPlanTitle = 'Premium';
610
- yield effects.put(actions$3.setState({
627
+ yield effects.put(actions$4.setState({
611
628
  loading: false,
612
629
  fetching: false,
613
630
  invoices: invoicesMock.map((invoice) => (Object.assign(Object.assign({}, invoice), { selectedPlan: selectPlanTitle, paymentDate: new Date(Date.parse(invoice.paymentDate)), totalAmount: +((invoice.totalAmount || 0) / 100).toFixed(2) }))),
614
631
  }));
615
- yield effects.put(actions$3.setLoading(false));
632
+ yield effects.put(actions$4.setLoading(false));
616
633
  }
617
634
  function* subscriptionInvoicesSagasMock() {
618
- yield effects.takeEvery(actions$3.loadInvoices, loadInvoicesMock);
635
+ yield effects.takeEvery(actions$4.loadInvoices, loadInvoicesMock);
619
636
  }
620
637
 
621
638
  function* billingSagas() {
@@ -634,15 +651,15 @@ function* billingSagasMock() {
634
651
  }
635
652
 
636
653
  function* checkoutSagas() {
637
- yield effects.takeEvery(actions$2.checkoutPlan, checkoutPlan);
638
- yield effects.takeEvery(actions$2.resetCheckout, resetCheckout);
639
- yield effects.takeEvery(actions$2.confirmCheckout, confirmPlan);
640
- yield effects.takeEvery(actions$2.cancelCheckout, cancelPlan);
641
- yield effects.takeEvery(actions$2.submitCheckout, submitCheckout);
642
- yield effects.takeEvery(actions$2.errorCheckout, errorCheckout);
654
+ yield effects.takeEvery(actions$3.checkoutPlan, checkoutPlan);
655
+ yield effects.takeEvery(actions$3.resetCheckout, resetCheckout);
656
+ yield effects.takeEvery(actions$3.confirmCheckout, confirmPlan);
657
+ yield effects.takeEvery(actions$3.cancelCheckout, cancelPlan);
658
+ yield effects.takeEvery(actions$3.submitCheckout, submitCheckout);
659
+ yield effects.takeEvery(actions$3.errorCheckout, errorCheckout);
643
660
  }
644
661
  function* checkoutPlan({ payload: planId }) {
645
- yield effects.put(actions$2.setState({
662
+ yield effects.put(actions$3.setState({
646
663
  checkoutPlanId: planId,
647
664
  loading: false,
648
665
  error: null,
@@ -650,7 +667,7 @@ function* checkoutPlan({ payload: planId }) {
650
667
  }));
651
668
  }
652
669
  function* resetCheckout() {
653
- yield effects.put(actions$2.setState({
670
+ yield effects.put(actions$3.setState({
654
671
  checkoutPlanId: null,
655
672
  loading: false,
656
673
  status: exports.CheckoutStatus.SELECTION,
@@ -666,14 +683,14 @@ function* confirmPlan({ payload: paymentMethodId }) {
666
683
  const subscriptionId = subscription === null || subscription === void 0 ? void 0 : subscription.id;
667
684
  const subscriptionItemId = (_a = subscription === null || subscription === void 0 ? void 0 : subscription.items[0]) === null || _a === void 0 ? void 0 : _a.id;
668
685
  if (!checkoutPlanId || !subscriptionId || !subscriptionItemId) {
669
- yield effects.put(actions$2.setState({
686
+ yield effects.put(actions$3.setState({
670
687
  loading: false,
671
688
  status: exports.CheckoutStatus.ERROR,
672
689
  }));
673
690
  return;
674
691
  }
675
692
  if (status === exports.CheckoutStatus.CHECKOUT) {
676
- yield effects.put(actions$2.setState({
693
+ yield effects.put(actions$3.setState({
677
694
  loading: true,
678
695
  error: null,
679
696
  }));
@@ -687,33 +704,33 @@ function* confirmPlan({ payload: paymentMethodId }) {
687
704
  },
688
705
  ],
689
706
  });
690
- yield effects.put(actions$2.setState({
707
+ yield effects.put(actions$3.setState({
691
708
  checkoutPlanId: null,
692
709
  loading: false,
693
710
  status: exports.CheckoutStatus.CONFIRM,
694
711
  }));
695
- yield effects.put(actions$2.checkoutEvent(exports.CheckoutEvent.CONFIRMED));
712
+ yield effects.put(actions$3.checkoutEvent(exports.CheckoutEvent.CONFIRMED));
696
713
  }
697
714
  catch (e) {
698
- yield effects.put(actions$2.setState({
715
+ yield effects.put(actions$3.setState({
699
716
  loading: false,
700
717
  error: e.message,
701
718
  status: exports.CheckoutStatus.ERROR,
702
719
  }));
703
- yield effects.put(actions$2.checkoutEvent(exports.CheckoutEvent.ERROR));
720
+ yield effects.put(actions$3.checkoutEvent(exports.CheckoutEvent.ERROR));
704
721
  }
705
722
  }
706
723
  }
707
724
  function* cancelPlan() {
708
725
  const { status } = yield effects.select((state) => state.subscriptions.checkout);
709
726
  if (status === exports.CheckoutStatus.CHECKOUT) {
710
- yield effects.put(actions$2.setState({
727
+ yield effects.put(actions$3.setState({
711
728
  checkoutPlanId: null,
712
729
  loading: false,
713
730
  error: null,
714
731
  status: exports.CheckoutStatus.CANCEL,
715
732
  }));
716
- yield effects.put(actions$2.checkoutEvent(exports.CheckoutEvent.CANCEL));
733
+ yield effects.put(actions$3.checkoutEvent(exports.CheckoutEvent.CANCEL));
717
734
  }
718
735
  }
719
736
  /**
@@ -722,35 +739,35 @@ function* cancelPlan() {
722
739
  function* submitCheckout() {
723
740
  const { paymentProvider } = yield effects.select((state) => state.subscriptions.config.config);
724
741
  if (paymentProvider === exports.PaymentProvider.STRIPE) {
725
- yield effects.put(actions$2.setState({
742
+ yield effects.put(actions$3.setState({
726
743
  loading: true,
727
744
  error: null,
728
745
  }));
729
- yield effects.put(actions$2.checkoutEvent(exports.CheckoutEvent.SUBMITTED));
746
+ yield effects.put(actions$3.checkoutEvent(exports.CheckoutEvent.SUBMITTED));
730
747
  }
731
748
  }
732
749
  function* errorCheckout({ payload }) {
733
- yield effects.put(actions$2.setState({
750
+ yield effects.put(actions$3.setState({
734
751
  loading: false,
735
752
  error: payload,
736
753
  status: exports.CheckoutStatus.ERROR,
737
754
  }));
738
- yield effects.put(actions$2.checkoutEvent(exports.CheckoutEvent.ERROR));
755
+ yield effects.put(actions$3.checkoutEvent(exports.CheckoutEvent.ERROR));
739
756
  }
740
757
  /*********************************
741
758
  * Preview Sagas
742
759
  *********************************/
743
760
  function* checkoutSagasMock() {
744
- yield effects.takeEvery(actions$2.checkoutPlan, checkoutPlan);
745
- yield effects.takeEvery(actions$2.resetCheckout, resetCheckout);
746
- yield effects.takeEvery(actions$2.cancelCheckout, cancelPlan);
761
+ yield effects.takeEvery(actions$3.checkoutPlan, checkoutPlan);
762
+ yield effects.takeEvery(actions$3.resetCheckout, resetCheckout);
763
+ yield effects.takeEvery(actions$3.cancelCheckout, cancelPlan);
747
764
  }
748
765
 
749
766
  function* plansSagas() {
750
- yield effects.takeEvery(actions$7.loadPlans, loadPlans);
767
+ yield effects.takeEvery(actions$8.loadPlans, loadPlans);
751
768
  }
752
769
  function* loadPlans() {
753
- yield effects.put(actions$7.setLoading(true));
770
+ yield effects.put(actions$8.setLoading(true));
754
771
  try {
755
772
  const products = yield effects.call(restApi.api.subscriptions.getSubscriptionPlans);
756
773
  const plans = products.map((item) => {
@@ -764,23 +781,23 @@ function* loadPlans() {
764
781
  recurringInterval: 'month',
765
782
  });
766
783
  });
767
- yield effects.put(actions$7.setState({
784
+ yield effects.put(actions$8.setState({
768
785
  fetching: false,
769
786
  loading: false,
770
787
  plans,
771
788
  }));
772
789
  }
773
790
  catch (e) {
774
- yield effects.put(actions$7.setError(e.message));
791
+ yield effects.put(actions$8.setError(e.message));
775
792
  }
776
793
  }
777
794
  /*********************************
778
795
  * Preview Sagas
779
796
  *********************************/
780
797
  function* loadPlansMock() {
781
- yield effects.put(actions$7.setLoading(true));
798
+ yield effects.put(actions$8.setLoading(true));
782
799
  yield effects.delay(500);
783
- yield effects.put(actions$7.setState({
800
+ yield effects.put(actions$8.setState({
784
801
  fetching: false,
785
802
  loading: false,
786
803
  plans: planResponseMock.map((item) => {
@@ -790,7 +807,7 @@ function* loadPlansMock() {
790
807
  }));
791
808
  }
792
809
  function* plansSagasMock() {
793
- yield effects.takeEvery(actions$7.loadPlans, loadPlansMock);
810
+ yield effects.takeEvery(actions$8.loadPlans, loadPlansMock);
794
811
  }
795
812
 
796
813
  exports.PaymentMethodType = void 0;
@@ -799,11 +816,20 @@ exports.PaymentMethodType = void 0;
799
816
  PaymentMethodType["CARD"] = "card";
800
817
  })(exports.PaymentMethodType || (exports.PaymentMethodType = {}));
801
818
 
819
+ exports.ManagedSubscriptionStatus = void 0;
820
+ (function (ManagedSubscriptionStatus) {
821
+ ManagedSubscriptionStatus["ACTIVE"] = "ACTIVE";
822
+ ManagedSubscriptionStatus["CANCELED"] = "CANCELED";
823
+ ManagedSubscriptionStatus["INCOMPLETE"] = "INCOMPLETE";
824
+ ManagedSubscriptionStatus["EXPIRED"] = "EXPIRED";
825
+ ManagedSubscriptionStatus["TRIALING"] = "TRIALING";
826
+ })(exports.ManagedSubscriptionStatus || (exports.ManagedSubscriptionStatus = {}));
827
+
802
828
  function* configSagas() {
803
- yield effects.takeEvery(actions$6.loadPaymentConfiguration, loadPaymentConfiguration);
829
+ yield effects.takeEvery(actions$7.loadPaymentConfiguration, loadPaymentConfiguration);
804
830
  }
805
831
  function* loadPaymentConfiguration() {
806
- yield effects.put(actions$6.setLoading(true));
832
+ yield effects.put(actions$7.setLoading(true));
807
833
  try {
808
834
  const response = yield effects.call(restApi.api.subscriptions.getPaymentProviders) || [];
809
835
  const stripePaymentProvider = response.find((paymentProvider) => paymentProvider.status === '1' && paymentProvider.providerType === restApi.ProviderType.Stripe);
@@ -811,18 +837,18 @@ function* loadPaymentConfiguration() {
811
837
  yield loadStripePaymentConfiguration();
812
838
  }
813
839
  else {
814
- yield effects.put(actions$6.setError('Payment provider not configured'));
840
+ yield effects.put(actions$7.setError('Payment provider not configured'));
815
841
  }
816
842
  }
817
843
  catch (e) {
818
- yield effects.put(actions$6.setError(e.message));
844
+ yield effects.put(actions$7.setError(e.message));
819
845
  }
820
846
  }
821
847
  function* loadStripePaymentConfiguration() {
822
- yield effects.put(actions$6.setLoading(true));
848
+ yield effects.put(actions$7.setLoading(true));
823
849
  try {
824
850
  const response = yield effects.call(restApi.api.subscriptions.getStripePaymentProviderConfiguration);
825
- yield effects.put(actions$6.setState({
851
+ yield effects.put(actions$7.setState({
826
852
  loading: false,
827
853
  fetching: false,
828
854
  config: {
@@ -832,16 +858,16 @@ function* loadStripePaymentConfiguration() {
832
858
  }));
833
859
  }
834
860
  catch (e) {
835
- yield effects.put(actions$6.setError(e.message));
861
+ yield effects.put(actions$7.setError(e.message));
836
862
  }
837
863
  }
838
864
  /*********************************
839
865
  * Preview Sagas
840
866
  *********************************/
841
867
  function* loadPaymentConfigurationMock() {
842
- yield effects.put(actions$6.setLoading(true));
868
+ yield effects.put(actions$7.setLoading(true));
843
869
  yield effects.delay(500);
844
- yield effects.put(actions$6.setState({
870
+ yield effects.put(actions$7.setState({
845
871
  loading: false,
846
872
  fetching: false,
847
873
  config: {
@@ -851,14 +877,14 @@ function* loadPaymentConfigurationMock() {
851
877
  }));
852
878
  }
853
879
  function* configSagasMock() {
854
- yield effects.takeEvery(actions$6.loadPaymentConfiguration, loadPaymentConfigurationMock);
880
+ yield effects.takeEvery(actions$7.loadPaymentConfiguration, loadPaymentConfigurationMock);
855
881
  }
856
882
 
857
883
  function* subscriptionStripeSagas() {
858
- yield effects.takeEvery(actions$1.createCardSetupIntentSecret, createCardSetupIntentSecret);
884
+ yield effects.takeEvery(actions$2.createCardSetupIntentSecret, createCardSetupIntentSecret);
859
885
  }
860
886
  function* createCardSetupIntentSecret({ payload }) {
861
- yield effects.put(actions$1.setStripeState({
887
+ yield effects.put(actions$2.setStripeState({
862
888
  loading: true,
863
889
  error: null,
864
890
  cardSetupIntentSecret: null
@@ -867,18 +893,32 @@ function* createCardSetupIntentSecret({ payload }) {
867
893
  const { setupIntentSecret } = yield effects.call(restApi.api.subscriptions.createStripePaymentMethodSetupIntentSecret, {
868
894
  paymentMethodId: payload || undefined
869
895
  });
870
- yield effects.put(actions$1.setStripeState({
896
+ yield effects.put(actions$2.setStripeState({
871
897
  cardSetupIntentSecret: setupIntentSecret,
872
898
  loading: false
873
899
  }));
874
900
  }
901
+ catch (e) {
902
+ yield effects.put(actions$2.setError(e.message));
903
+ }
904
+ }
905
+
906
+ function* loadManagedSubscriptions() {
907
+ yield effects.put(actions$1.setLoading(true));
908
+ try {
909
+ const managedSubscriptionsResponse = yield effects.call(restApi.api.subscriptions.getManagedSubscriptions);
910
+ yield effects.put(actions$1.setState(managedSubscriptionsResponse));
911
+ }
875
912
  catch (e) {
876
913
  yield effects.put(actions$1.setError(e.message));
877
914
  }
915
+ }
916
+ function* managedSubscriptionsSagas() {
917
+ yield effects.takeEvery(actions$1.loadManagedSubscriptions, loadManagedSubscriptions);
878
918
  }
879
919
 
880
920
  function* sagas() {
881
- yield effects.all([effects.call(billingSagas), effects.call(checkoutSagas), effects.call(plansSagas), effects.call(configSagas), effects.call(subscriptionStripeSagas)]);
921
+ yield effects.all([effects.call(billingSagas), effects.call(checkoutSagas), effects.call(plansSagas), effects.call(configSagas), effects.call(subscriptionStripeSagas), effects.call(managedSubscriptionsSagas)]);
882
922
  }
883
923
  function* mockSagas() {
884
924
  yield effects.all([effects.call(billingSagasMock), effects.call(checkoutSagasMock), effects.call(plansSagasMock), effects.call(configSagasMock)]);