@zeniai/client-epic-state 5.0.85-betaAS2 → 5.0.85-betaAS3

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.
@@ -120,18 +120,10 @@ const tenant = (0, toolkit_1.createSlice)({
120
120
  draft.fetchState = 'Completed';
121
121
  draft.error = undefined;
122
122
  const [tenantsbyId, tenantIds, firstUser] = mapTenantsPayloadToState(tenants, user);
123
- // Preserve existing isTreasuryVideoViewed values
124
123
  tenantIds.forEach((tenantId) => {
125
124
  const existingTenant = draft.tenantsById[tenantId];
126
125
  if (existingTenant != null) {
127
- tenantsbyId[tenantId].isTreasuryPromoVideoPlayed =
128
- existingTenant.isTreasuryPromoVideoPlayed;
129
- tenantsbyId[tenantId].isTreasuryPromoVideoRemindMeLaterClicked =
130
- existingTenant.isTreasuryPromoVideoRemindMeLaterClicked;
131
- tenantsbyId[tenantId].loginCounterForTreasuryPromoVideo =
132
- existingTenant.loginCounterForTreasuryPromoVideo;
133
- tenantsbyId[tenantId].isTreasuryPromoIntroClosedByOutsideClick =
134
- existingTenant.isTreasuryPromoIntroClosedByOutsideClick;
126
+ tenantsbyId[tenantId] = preserveTreasuryPromoFlags(existingTenant, tenantsbyId[tenantId]);
135
127
  }
136
128
  });
137
129
  draft.tenantsById = tenantsbyId;
@@ -150,6 +142,12 @@ const tenant = (0, toolkit_1.createSlice)({
150
142
  draft.activeTenantFetchState.fetchState = 'Completed';
151
143
  draft.activeTenantFetchState.error = undefined;
152
144
  const [tenantsbyId, tenantIds, firstUser] = mapTenantsPayloadToState(tenants, user);
145
+ tenantIds.forEach((tenantId) => {
146
+ const existingTenant = draft.tenantsById[tenantId];
147
+ if (existingTenant != null) {
148
+ tenantsbyId[tenantId] = preserveTreasuryPromoFlags(existingTenant, tenantsbyId[tenantId]);
149
+ }
150
+ });
153
151
  draft.tenantsById = { ...draft.tenantsById, ...tenantsbyId };
154
152
  draft.tenantIds = [...new Set([...draft.tenantIds, ...tenantIds])];
155
153
  draft.loggedInUser = (0, assignWith_1.default)(draft.loggedInUser ?? {}, firstUser, (objValue, srcValue) => srcValue ?? objValue);
@@ -768,6 +766,8 @@ const tenant = (0, toolkit_1.createSlice)({
768
766
  },
769
767
  updateTreasuryPromoRemindMeLaterClickedForLoggedInUser(draft) {
770
768
  if (draft.currentTenantId != null) {
769
+ // Login counter increments server-side on each login; preserve the
770
+ // existing local value until the next tenant fetch returns user/self.
771
771
  draft.tenantsById[draft.currentTenantId].isTreasuryPromoVideoRemindMeLaterClicked = true;
772
772
  }
773
773
  },
@@ -837,6 +837,18 @@ const tenant = (0, toolkit_1.createSlice)({
837
837
  });
838
838
  _a = tenant.actions, exports.updateTenants = _a.updateTenants, exports.fetchAllTenants = _a.fetchAllTenants, exports.updateTenantsSuccess = _a.updateTenantsSuccess, exports.updateTenantsFailure = _a.updateTenantsFailure, exports.fetchActiveTenant = _a.fetchActiveTenant, exports.updateTenantSuccess = _a.updateTenantSuccess, exports.updateTenantFailure = _a.updateTenantFailure, exports.updateCurrentTenant = _a.updateCurrentTenant, exports.fetchExcludedResources = _a.fetchExcludedResources, exports.updateExcludedResourcesSuccess = _a.updateExcludedResourcesSuccess, exports.updateExcludedResourcesFailure = _a.updateExcludedResourcesFailure, exports.doSignIn = _a.doSignIn, exports.doMagicLinkSignIn = _a.doMagicLinkSignIn, exports.magicLinkSignInSuccess = _a.magicLinkSignInSuccess, exports.magicLinkSignInFailure = _a.magicLinkSignInFailure, exports.sendEmailMagicLinkToUser = _a.sendEmailMagicLinkToUser, exports.sendEmailMagicLinkToUserSuccess = _a.sendEmailMagicLinkToUserSuccess, exports.sendEmailMagicLinkToUserFailure = _a.sendEmailMagicLinkToUserFailure, exports.updateSignInState = _a.updateSignInState, exports.doSignOut = _a.doSignOut, exports.signOutSuccess = _a.signOutSuccess, exports.sendSessionHeartbeat = _a.sendSessionHeartbeat, exports.sessionHeartbeatSuccess = _a.sessionHeartbeatSuccess, exports.sessionHeartbeatFailure = _a.sessionHeartbeatFailure, exports.updateLoggedInUser = _a.updateLoggedInUser, exports.fetchExternalConnections = _a.fetchExternalConnections, exports.saveExternalConnection = _a.saveExternalConnection, exports.saveExternalConnectionSuccess = _a.saveExternalConnectionSuccess, exports.saveExternalConnectionFailure = _a.saveExternalConnectionFailure, exports.fetchExternalConnectionsFailure = _a.fetchExternalConnectionsFailure, exports.fetchExternalConnectionsSuccess = _a.fetchExternalConnectionsSuccess, exports.saveAPIKeyConnection = _a.saveAPIKeyConnection, exports.saveAPIKeyConnectionSuccess = _a.saveAPIKeyConnectionSuccess, exports.saveAPIKeyConnectionFailure = _a.saveAPIKeyConnectionFailure, exports.saveOAuthConnection = _a.saveOAuthConnection, exports.saveOAuthConnectionSuccess = _a.saveOAuthConnectionSuccess, exports.saveOAuthConnectionFailure = _a.saveOAuthConnectionFailure, exports.saveConnectorCredentials = _a.saveConnectorCredentials, exports.saveConnectorCredentialsSuccess = _a.saveConnectorCredentialsSuccess, exports.saveConnectorCredentialsFailure = _a.saveConnectorCredentialsFailure, exports.deleteConnection = _a.deleteConnection, exports.deleteConnectionSuccess = _a.deleteConnectionSuccess, exports.deleteConnectionFailure = _a.deleteConnectionFailure, exports.clearAll = _a.clearAll, exports.fetchSubscriptionSummaryForTenant = _a.fetchSubscriptionSummaryForTenant, exports.updateSubscriptionSummaryForTenantSuccess = _a.updateSubscriptionSummaryForTenantSuccess, exports.updateSubscriptionSummaryForTenantFailure = _a.updateSubscriptionSummaryForTenantFailure, exports.updateOnboardingTenants = _a.updateOnboardingTenants, exports.removeOnboardingTenant = _a.removeOnboardingTenant, exports.updateTenantReimbursementInfo = _a.updateTenantReimbursementInfo, exports.updateReferViewedForLoggedInUser = _a.updateReferViewedForLoggedInUser, exports.resetSignInState = _a.resetSignInState, exports.trigger2FA = _a.trigger2FA, exports.updateTenantAccountingClassesEnabled = _a.updateTenantAccountingClassesEnabled, exports.updateTenantCapitalizationOnboardingDismissed = _a.updateTenantCapitalizationOnboardingDismissed, exports.updateTenantCapitalizationThreshold = _a.updateTenantCapitalizationThreshold, exports.updateTenantMasterTOSInfo = _a.updateTenantMasterTOSInfo, exports.verifyDeviceWithTwoFA = _a.verifyDeviceWithTwoFA, exports.verifyDeviceWithTwoFASuccess = _a.verifyDeviceWithTwoFASuccess, exports.verifyDeviceWithTwoFAFailure = _a.verifyDeviceWithTwoFAFailure, exports.updateTreasuryVideoViewedForLoggedInUser = _a.updateTreasuryVideoViewedForLoggedInUser, exports.updateTreasuryPromoRemindMeLaterClickedForLoggedInUser = _a.updateTreasuryPromoRemindMeLaterClickedForLoggedInUser, exports.updateTreasuryPromoIntroClosedByOutsideClickForLoggedInUser = _a.updateTreasuryPromoIntroClosedByOutsideClickForLoggedInUser, exports.resendVerifyDeviceOTP = _a.resendVerifyDeviceOTP, exports.resendVerifyDeviceOTPSuccess = _a.resendVerifyDeviceOTPSuccess, exports.resendVerifyDeviceOTPFailure = _a.resendVerifyDeviceOTPFailure;
839
839
  exports.default = tenant.reducer;
840
+ /**
841
+ * Keeps optimistic/local treasury promo flags when tenant payloads are refetched.
842
+ */
843
+ function preserveTreasuryPromoFlags(existingTenant, nextTenant) {
844
+ return {
845
+ ...nextTenant,
846
+ isTreasuryPromoVideoPlayed: existingTenant.isTreasuryPromoVideoPlayed,
847
+ isTreasuryPromoVideoRemindMeLaterClicked: existingTenant.isTreasuryPromoVideoRemindMeLaterClicked,
848
+ loginCounterForTreasuryPromoVideo: existingTenant.loginCounterForTreasuryPromoVideo,
849
+ isTreasuryPromoIntroClosedByOutsideClick: existingTenant.isTreasuryPromoIntroClosedByOutsideClick,
850
+ };
851
+ }
840
852
  /**
841
853
  * Converts tenants payload to Tenant and User State
842
854
  * @param payload tenants payload as received from backend API response
@@ -108,18 +108,10 @@ const tenant = createSlice({
108
108
  draft.fetchState = 'Completed';
109
109
  draft.error = undefined;
110
110
  const [tenantsbyId, tenantIds, firstUser] = mapTenantsPayloadToState(tenants, user);
111
- // Preserve existing isTreasuryVideoViewed values
112
111
  tenantIds.forEach((tenantId) => {
113
112
  const existingTenant = draft.tenantsById[tenantId];
114
113
  if (existingTenant != null) {
115
- tenantsbyId[tenantId].isTreasuryPromoVideoPlayed =
116
- existingTenant.isTreasuryPromoVideoPlayed;
117
- tenantsbyId[tenantId].isTreasuryPromoVideoRemindMeLaterClicked =
118
- existingTenant.isTreasuryPromoVideoRemindMeLaterClicked;
119
- tenantsbyId[tenantId].loginCounterForTreasuryPromoVideo =
120
- existingTenant.loginCounterForTreasuryPromoVideo;
121
- tenantsbyId[tenantId].isTreasuryPromoIntroClosedByOutsideClick =
122
- existingTenant.isTreasuryPromoIntroClosedByOutsideClick;
114
+ tenantsbyId[tenantId] = preserveTreasuryPromoFlags(existingTenant, tenantsbyId[tenantId]);
123
115
  }
124
116
  });
125
117
  draft.tenantsById = tenantsbyId;
@@ -138,6 +130,12 @@ const tenant = createSlice({
138
130
  draft.activeTenantFetchState.fetchState = 'Completed';
139
131
  draft.activeTenantFetchState.error = undefined;
140
132
  const [tenantsbyId, tenantIds, firstUser] = mapTenantsPayloadToState(tenants, user);
133
+ tenantIds.forEach((tenantId) => {
134
+ const existingTenant = draft.tenantsById[tenantId];
135
+ if (existingTenant != null) {
136
+ tenantsbyId[tenantId] = preserveTreasuryPromoFlags(existingTenant, tenantsbyId[tenantId]);
137
+ }
138
+ });
141
139
  draft.tenantsById = { ...draft.tenantsById, ...tenantsbyId };
142
140
  draft.tenantIds = [...new Set([...draft.tenantIds, ...tenantIds])];
143
141
  draft.loggedInUser = assignWith(draft.loggedInUser ?? {}, firstUser, (objValue, srcValue) => srcValue ?? objValue);
@@ -756,6 +754,8 @@ const tenant = createSlice({
756
754
  },
757
755
  updateTreasuryPromoRemindMeLaterClickedForLoggedInUser(draft) {
758
756
  if (draft.currentTenantId != null) {
757
+ // Login counter increments server-side on each login; preserve the
758
+ // existing local value until the next tenant fetch returns user/self.
759
759
  draft.tenantsById[draft.currentTenantId].isTreasuryPromoVideoRemindMeLaterClicked = true;
760
760
  }
761
761
  },
@@ -825,6 +825,18 @@ const tenant = createSlice({
825
825
  });
826
826
  export const { updateTenants, fetchAllTenants, updateTenantsSuccess, updateTenantsFailure, fetchActiveTenant, updateTenantSuccess, updateTenantFailure, updateCurrentTenant, fetchExcludedResources, updateExcludedResourcesSuccess, updateExcludedResourcesFailure, doSignIn, doMagicLinkSignIn, magicLinkSignInSuccess, magicLinkSignInFailure, sendEmailMagicLinkToUser, sendEmailMagicLinkToUserSuccess, sendEmailMagicLinkToUserFailure, updateSignInState, doSignOut, signOutSuccess, sendSessionHeartbeat, sessionHeartbeatSuccess, sessionHeartbeatFailure, updateLoggedInUser, fetchExternalConnections, saveExternalConnection, saveExternalConnectionSuccess, saveExternalConnectionFailure, fetchExternalConnectionsFailure, fetchExternalConnectionsSuccess, saveAPIKeyConnection, saveAPIKeyConnectionSuccess, saveAPIKeyConnectionFailure, saveOAuthConnection, saveOAuthConnectionSuccess, saveOAuthConnectionFailure, saveConnectorCredentials, saveConnectorCredentialsSuccess, saveConnectorCredentialsFailure, deleteConnection, deleteConnectionSuccess, deleteConnectionFailure, clearAll, fetchSubscriptionSummaryForTenant, updateSubscriptionSummaryForTenantSuccess, updateSubscriptionSummaryForTenantFailure, updateOnboardingTenants, removeOnboardingTenant, updateTenantReimbursementInfo, updateReferViewedForLoggedInUser, resetSignInState, trigger2FA, updateTenantAccountingClassesEnabled, updateTenantCapitalizationOnboardingDismissed, updateTenantCapitalizationThreshold, updateTenantMasterTOSInfo, verifyDeviceWithTwoFA, verifyDeviceWithTwoFASuccess, verifyDeviceWithTwoFAFailure, updateTreasuryVideoViewedForLoggedInUser, updateTreasuryPromoRemindMeLaterClickedForLoggedInUser, updateTreasuryPromoIntroClosedByOutsideClickForLoggedInUser, resendVerifyDeviceOTP, resendVerifyDeviceOTPSuccess, resendVerifyDeviceOTPFailure, } = tenant.actions;
827
827
  export default tenant.reducer;
828
+ /**
829
+ * Keeps optimistic/local treasury promo flags when tenant payloads are refetched.
830
+ */
831
+ function preserveTreasuryPromoFlags(existingTenant, nextTenant) {
832
+ return {
833
+ ...nextTenant,
834
+ isTreasuryPromoVideoPlayed: existingTenant.isTreasuryPromoVideoPlayed,
835
+ isTreasuryPromoVideoRemindMeLaterClicked: existingTenant.isTreasuryPromoVideoRemindMeLaterClicked,
836
+ loginCounterForTreasuryPromoVideo: existingTenant.loginCounterForTreasuryPromoVideo,
837
+ isTreasuryPromoIntroClosedByOutsideClick: existingTenant.isTreasuryPromoIntroClosedByOutsideClick,
838
+ };
839
+ }
828
840
  /**
829
841
  * Converts tenants payload to Tenant and User State
830
842
  * @param payload tenants payload as received from backend API response
@@ -105,12 +105,18 @@ export const createTransferEntryEpic = (actions$, _state$, zeniAPI) => actions$.
105
105
  id: transactionId,
106
106
  type: sourceTransactionType,
107
107
  };
108
+ // The server contract for `transaction-type-update` expects
109
+ // `transaction_memo`, but the client-side action payload field is named
110
+ // `memo` (callers in web-components dispatch with `memo`). The names are
111
+ // intentionally kept separate: `memo` is the internal client model and
112
+ // `transaction_memo` is the wire format. Don't unify them without
113
+ // updating the action contract and all dispatchers in lockstep.
108
114
  const payload = {
109
115
  transaction_type: transactionType,
110
116
  transaction_id: transactionId,
111
117
  to_account_integration_id: creditAccountIntegrationId,
112
118
  from_account_integration_id: debitAccountIntegrationId,
113
- memo: memo ?? '',
119
+ transaction_memo: memo ?? '',
114
120
  };
115
121
  return zeniAPI
116
122
  .postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/transaction-type-update`, payload)
@@ -14,5 +14,5 @@ export const updateTreasuryVideoViewedEpic = (actions$, _state$, zeniAPI) => act
14
14
  return of(updateTreasuryVideoViewedFailure(response.status));
15
15
  }
16
16
  }), catchError((error) => of(updateTreasuryVideoViewedFailure(createZeniAPIStatus('Unexpected error', 'Update treasury video viewed REST API call errored out' +
17
- JSON.stringify(error))))));
17
+ (error?.message ?? JSON.stringify(error)))))));
18
18
  }));
@@ -108,12 +108,18 @@ const createTransferEntryEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0
108
108
  id: transactionId,
109
109
  type: sourceTransactionType,
110
110
  };
111
+ // The server contract for `transaction-type-update` expects
112
+ // `transaction_memo`, but the client-side action payload field is named
113
+ // `memo` (callers in web-components dispatch with `memo`). The names are
114
+ // intentionally kept separate: `memo` is the internal client model and
115
+ // `transaction_memo` is the wire format. Don't unify them without
116
+ // updating the action contract and all dispatchers in lockstep.
111
117
  const payload = {
112
118
  transaction_type: transactionType,
113
119
  transaction_id: transactionId,
114
120
  to_account_integration_id: creditAccountIntegrationId,
115
121
  from_account_integration_id: debitAccountIntegrationId,
116
- memo: memo ?? '',
122
+ transaction_memo: memo ?? '',
117
123
  };
118
124
  return zeniAPI
119
125
  .postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/transaction-type-update`, payload)
@@ -17,6 +17,6 @@ const updateTreasuryVideoViewedEpic = (actions$, _state$, zeniAPI) => actions$.p
17
17
  return (0, rxjs_1.of)((0, treasurySetupViewReducer_1.updateTreasuryVideoViewedFailure)(response.status));
18
18
  }
19
19
  }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, treasurySetupViewReducer_1.updateTreasuryVideoViewedFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected error', 'Update treasury video viewed REST API call errored out' +
20
- JSON.stringify(error))))));
20
+ (error?.message ?? JSON.stringify(error)))))));
21
21
  }));
22
22
  exports.updateTreasuryVideoViewedEpic = updateTreasuryVideoViewedEpic;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.85-betaAS2",
3
+ "version": "5.0.85-betaAS3",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",