@zeniai/client-epic-state 4.14.13 → 4.14.15

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.
@@ -16,6 +16,7 @@ export declare const doSignInEpic: (actions$: ActionsObservable<ActionType>, _:
16
16
  payload: {
17
17
  userPayload: import("../tenantPayload").LoggedInUserPayload;
18
18
  zeniSessionId: string;
19
+ authProvider: import("../tenantReducer").AuthProvider;
19
20
  };
20
21
  type: string;
21
22
  }>;
@@ -29,8 +29,8 @@ const doSignInEpic = (actions$, _, zeniAPI) => actions$.pipe((0, operators_1.fil
29
29
  const signInResponse = responseJson;
30
30
  if (response.ok && (0, responsePayload_1.isSuccessResponse)(signInResponse)) {
31
31
  return (0, rxjs_1.of)((0, tenantReducer_1.updateLoggedInUser)(signInResponse.data.user, // eslint-disable-line @typescript-eslint/no-non-null-assertion
32
- response.headers.get('zeni-session-id') // eslint-disable-line @typescript-eslint/no-non-null-assertion
33
- ), (0, tenantReducer_1.fetchAllTenants)(signInResponse.data.user.user_id, // eslint-disable-line @typescript-eslint/no-non-null-assertion
32
+ response.headers.get('zeni-session-id'), // eslint-disable-line @typescript-eslint/no-non-null-assertion,
33
+ action.payload.oauthProvider), (0, tenantReducer_1.fetchAllTenants)(signInResponse.data.user.user_id, // eslint-disable-line @typescript-eslint/no-non-null-assertion
34
34
  (_a = response.headers.get('zeni-session-id')) !== null && _a !== void 0 ? _a : undefined));
35
35
  }
36
36
  else {
@@ -6,9 +6,10 @@ import { ZeniAPIStatus } from '../../responsePayload';
6
6
  import ZeniUrl from '../../zeniUrl';
7
7
  import { UserRolePayload } from '../userRole/userRolePayload';
8
8
  import { SubscriptionSummaryPayload } from '../subscription/subscriptionSummary/subscriptionSummaryPayload';
9
+ export declare type AuthProvider = "google" | "microsoft";
9
10
  export interface DoSignInPayload {
10
11
  authCode: string;
11
- oauthProvider: string;
12
+ oauthProvider: AuthProvider;
12
13
  appType: 'web' | 'mobile';
13
14
  redirectUri: ZeniUrl;
14
15
  sourceUri: ZeniUrl;
@@ -34,9 +35,10 @@ export declare const updateTenants: import("@reduxjs/toolkit").ActionCreatorWith
34
35
  }, string, never, never>, updateExcludedResourcesFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tenantId: string, status: ZeniAPIStatus<Record<string, unknown>>], {
35
36
  tenantId: string;
36
37
  status: ZeniAPIStatus<Record<string, unknown>>;
37
- }, string, never, never>, doSignIn: import("@reduxjs/toolkit").ActionCreatorWithPayload<DoSignInPayload, string>, updateSignInState: import("@reduxjs/toolkit").ActionCreatorWithPayload<FetchState, string>, doSignOut: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, signOutSuccess: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, updateLoggedInUser: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[userPayload: LoggedInUserPayload, zeniSessionId: string], {
38
+ }, string, never, never>, doSignIn: import("@reduxjs/toolkit").ActionCreatorWithPayload<DoSignInPayload, string>, updateSignInState: import("@reduxjs/toolkit").ActionCreatorWithPayload<FetchState, string>, doSignOut: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, signOutSuccess: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, updateLoggedInUser: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[userPayload: LoggedInUserPayload, zeniSessionId: string, authProvider: AuthProvider], {
38
39
  userPayload: LoggedInUserPayload;
39
40
  zeniSessionId: string;
41
+ authProvider: AuthProvider;
40
42
  }, string, never, never>, fetchExternalConnections: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[userId: string, tenantId: string], {
41
43
  userId: string;
42
44
  tenantId: string;
@@ -178,14 +178,14 @@ const tenant = (0, toolkit_1.createSlice)({
178
178
  draft.signInState = action.payload;
179
179
  },
180
180
  updateLoggedInUser: {
181
- prepare(userPayload, zeniSessionId) {
182
- return { payload: { userPayload, zeniSessionId } };
181
+ prepare(userPayload, zeniSessionId, authProvider) {
182
+ return { payload: { userPayload, zeniSessionId, authProvider } };
183
183
  },
184
184
  reducer(draft, action) {
185
185
  var _a;
186
186
  draft.fetchState = 'In-Progress'; // Why in progress ? Sign in is complete only after tenants are retrieved successfully.
187
187
  draft.error = undefined;
188
- const user = mapLoggedInUserPayloadToLoggedInUser(action.payload.userPayload, action.payload.zeniSessionId);
188
+ const user = mapLoggedInUserPayloadToLoggedInUser(action.payload.userPayload, action.payload.zeniSessionId, action.payload.authProvider);
189
189
  draft.loggedInUser = (0, assignWith_1.default)((_a = draft.loggedInUser) !== null && _a !== void 0 ? _a : {}, user, (objValue, srcValue) => srcValue !== null && srcValue !== void 0 ? srcValue : objValue);
190
190
  },
191
191
  },
@@ -418,7 +418,7 @@ function mapTenantPayloadToUser(payload) {
418
418
  };
419
419
  return user;
420
420
  }
421
- function mapLoggedInUserPayloadToLoggedInUser(payload, zeniSessionId) {
421
+ function mapLoggedInUserPayloadToLoggedInUser(payload, zeniSessionId, authProvider) {
422
422
  var _a, _b;
423
423
  return {
424
424
  userId: payload.user_id,
@@ -426,6 +426,7 @@ function mapLoggedInUserPayloadToLoggedInUser(payload, zeniSessionId) {
426
426
  firstName: (_a = payload.first_name) === null || _a === void 0 ? void 0 : _a.trim(),
427
427
  lastName: (_b = payload.last_name) === null || _b === void 0 ? void 0 : _b.trim(),
428
428
  photo: (0, urlPayload_1.toURL)(payload.photo),
429
+ authProvider: authProvider,
429
430
  };
430
431
  }
431
432
  const toRoleResource = (payload) => ({
@@ -8,6 +8,7 @@ import { UserReimbursementInfo } from '../company/companyStateTypes';
8
8
  import { SubscriptionSummary } from '../subscription/subscriptionSummary/subscriptionSummaryState';
9
9
  import { InvitationStatus } from '../userRole/userRoleState';
10
10
  import { UserRoleType } from '../userRole/userRoleType';
11
+ import { AuthProvider } from './tenantReducer';
11
12
  export interface TenantExternalConnections {
12
13
  fetchState: FetchState;
13
14
  accounting: Connection[];
@@ -82,6 +83,7 @@ export interface LoggedInUser {
82
83
  firstName?: string;
83
84
  lastName?: string;
84
85
  photo?: ZeniUrl;
86
+ authProvider?: AuthProvider;
85
87
  }
86
88
  export interface RoleResource {
87
89
  roleResourceId: ID;
@@ -7,7 +7,7 @@ export declare const toAuditRuleEntityType: (v: string) => "dashboard" | "transa
7
7
  export declare type AuditRuleEntityType = ReturnType<typeof toAuditRuleEntityType>;
8
8
  declare const toAuditRuleEntityIdType: (v: string) => "cash_balance" | "card_balance" | "expense_automation_card" | "operating_expenses" | "operating_expenses_by_classes" | "revenue" | "revenue_by_classes" | "net_burn_or_income" | "net_burn_or_income_story_card" | "net_burn_or_income_by_classes" | "cash_position" | "top_expenses" | "profit_and_loss" | "profit_and_loss_by_classes" | "balance_sheet" | "cash_flow" | "dashboard" | "finance_statement" | "transaction_list_of_account" | "transaction_list_missing_receipt" | "transaction_list_of_account_by_class" | "transaction_detail" | "cash_in_cash_out" | "insights_dashboard" | "company_details" | "class_list" | "account_list" | "account_list_by_type" | "vendor" | "task_card" | "bill_pay" | "reimbursement" | "bill_pay_card" | "reimbursement_card" | "bill_pay_promo_card" | "zeni_accounts" | "zeni_accounts_promo_card" | "charge_cards" | "reimbursement_promo_card" | "onboarding" | "operating_expenses_by_vendor" | "operating_expenses_by_vendor_summary" | "vendors_tab" | "accounts_payable_aging" | "accounts_receivable_aging" | "vendor_global_review" | "prepaid_expenses" | "fixed_assets" | "notification" | "rewards_card" | "billing" | "flux_analysis_operating_expense" | "uncategorized-expense" | "uncategorized-income";
9
9
  export declare type AuditRuleEntityIdType = ReturnType<typeof toAuditRuleEntityIdType>;
10
- export declare const toAuditRuleTypeIdType: (v: string) => "business" | "accounting";
10
+ export declare const toAuditRuleTypeIdType: (v: string) => "accounting" | "business";
11
11
  declare type AuditRuleTypeIdType = ReturnType<typeof toAuditRuleTypeIdType>;
12
12
  export declare const AUDIT_REPORT_ACTION_TYPES: readonly ["generate", "view"];
13
13
  export declare const toAuditReportActionType: (v: string) => "view" | "generate";
@@ -5,7 +5,7 @@ import { FilterCategoryValueType } from '../helpers/cockpitHelpers';
5
5
  import { CockpitDownloadTabsID, CockpitTabsFileType } from './cockpitTabsID';
6
6
  export declare const toPortfolioSortKeyType: (v: string) => "expenses" | "runway" | "cashBalance" | "netIncome" | "companyName" | "revenues";
7
7
  export declare const toManagementSortKeyType: (v: string) => "status" | "group" | "bookCloseDate" | "controller" | "preparer" | "reviewer" | "companyName" | "monthlyRecurringRevenue" | "annualRecurringRevenue" | "taxStatus" | "notes" | "plans" | "customerSuccessManager" | "task" | "apAnalyst" | "reportSent" | "taxLead" | "satisfaction";
8
- export declare const toOnboardingSortKeyType: (v: string) => "companyName" | "notes" | "bankAccountLinked" | "qboLinked" | "identityVerified" | "businessVerified" | "groupCreated" | "customerCreated" | "enroller" | "invite" | "latestCreated";
8
+ export declare const toOnboardingSortKeyType: (v: string) => "companyName" | "identityVerified" | "businessVerified" | "bankAccountLinked" | "qboLinked" | "groupCreated" | "customerCreated" | "notes" | "enroller" | "invite" | "latestCreated";
9
9
  export declare const toHealthSortKeyType: (v: string) => "group" | "runway" | "controller" | "companyName" | "monthlyRecurringRevenue" | "customerSatisfactionScore" | "netPromoterScore" | "customerSuccessManager" | "lastReportSent" | "externalProductServiceExposure" | "finOpsEngagementFrequency" | "companyEngagementMetricsUpdatedAt" | "issues" | "productVerticals" | "churnProbability" | "subscriptionDate" | "renewalDate";
10
10
  export declare const toTaskManagerSortKeyType: (v: string) => "priority" | "name" | "status" | "dueDate" | "taskName" | "assignee" | "tags" | "createdBy";
11
11
  export declare type PortfolioViewSortKey = ReturnType<typeof toPortfolioSortKeyType>;
@@ -30,8 +30,9 @@ const zeniAccountsPromoCardReducer_1 = require("../zeniAccountsPromoCard/zeniAcc
30
30
  const referralReducer_1 = require("../referralView/referralReducer");
31
31
  const monthEndCloseChecksViewReducer_1 = require("../monthEndCloseChecksView/monthEndCloseChecksViewReducer");
32
32
  const timePeriod_1 = require("../../commonStateTypes/timePeriod");
33
+ const fetchAllTenantsEpic_1 = require("../../entity/tenant/epic/fetchAllTenantsEpic");
33
34
  const fetchDashboardEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(dashboardReducer_1.fetchDashboard.match), (0, operators_1.switchMap)((action) => {
34
- var _a, _b, _c, _d, _e, _f, _g, _h;
35
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
35
36
  const { userId, companyId, fetchFullReport, cacheOverride, excludeResources, tenantId, } = action.payload;
36
37
  const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state$.value);
37
38
  const isReimbursementFeatureEnabled = (_a = currentTenant.company) === null || _a === void 0 ? void 0 : _a.featuresActivationInfo.isReimbursementFeatureEnabled;
@@ -42,7 +43,7 @@ const fetchDashboardEpic = (actions$, state$) => actions$.pipe((0, operators_1.f
42
43
  const arAgingDate = state$.value.arAgingState.uiState.selectedDate;
43
44
  const apAgingDate = state$.value.apAgingState.uiState.selectedDate;
44
45
  const selectedPeriodByTenantId = state$.value.expenseAutomationViewState.selectedPeriodByTenantId;
45
- const monthEndChecksPeriod = selectedPeriodByTenantId[tenantId];
46
+ const monthEndChecksPeriod = (_b = selectedPeriodByTenantId[tenantId]) !== null && _b !== void 0 ? _b : fetchAllTenantsEpic_1.defaultMonthYearPeriod;
46
47
  if (cacheOverride === true) {
47
48
  const actions = [
48
49
  (0, tenantReducer_1.fetchAllTenants)(userId),
@@ -89,9 +90,9 @@ const fetchDashboardEpic = (actions$, state$) => actions$.pipe((0, operators_1.f
89
90
  else {
90
91
  const state = state$.value;
91
92
  const fetchActions = [];
92
- const revenueState = (0, revenueSelector_1.getRevenueReportFetchState)((_b = state.revenueState.uiState.selectedForecast) === null || _b === void 0 ? void 0 : _b.id, state.revenueState);
93
- const opExState = (0, opExSelector_1.getOperatingExpensesReportFetchState)((_c = state.opExState.uiState.selectedForecast) === null || _c === void 0 ? void 0 : _c.id, state.opExState);
94
- const netBurnOrIncomeReportFetchState = (0, netBurnOrIncomeSelector_1.getNetBurnOrIncomeReportFetchState)((_d = state.netBurnOrIncomeState.uiState.selectedForecast) === null || _d === void 0 ? void 0 : _d.id, state.netBurnOrIncomeState);
93
+ const revenueState = (0, revenueSelector_1.getRevenueReportFetchState)((_c = state.revenueState.uiState.selectedForecast) === null || _c === void 0 ? void 0 : _c.id, state.revenueState);
94
+ const opExState = (0, opExSelector_1.getOperatingExpensesReportFetchState)((_d = state.opExState.uiState.selectedForecast) === null || _d === void 0 ? void 0 : _d.id, state.opExState);
95
+ const netBurnOrIncomeReportFetchState = (0, netBurnOrIncomeSelector_1.getNetBurnOrIncomeReportFetchState)((_e = state.netBurnOrIncomeState.uiState.selectedForecast) === null || _e === void 0 ? void 0 : _e.id, state.netBurnOrIncomeState);
95
96
  if (state.tenantState.fetchState !== 'In-Progress' &&
96
97
  !state.tenantState.hasValidState()) {
97
98
  fetchActions.push((0, tenantReducer_1.fetchAllTenants)(userId));
@@ -182,8 +183,8 @@ const fetchDashboardEpic = (actions$, state$) => actions$.pipe((0, operators_1.f
182
183
  fetchActions.push((0, referralReducer_1.fetchRewardsPlan)(true));
183
184
  }
184
185
  const monthEndChecksId = (0, timePeriod_1.toMonthYearPeriodId)(monthEndChecksPeriod);
185
- if (((_f = (_e = state.monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[currentTenant.tenantId]) === null || _e === void 0 ? void 0 : _e[monthEndChecksId]) === null || _f === void 0 ? void 0 : _f.fetchState) !== 'In-Progress' &&
186
- ((_h = (_g = state.monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[currentTenant.tenantId]) === null || _g === void 0 ? void 0 : _g[monthEndChecksId]) === null || _h === void 0 ? void 0 : _h.fetchState) !== 'Completed' &&
186
+ if (((_g = (_f = state.monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[currentTenant.tenantId]) === null || _f === void 0 ? void 0 : _f[monthEndChecksId]) === null || _g === void 0 ? void 0 : _g.fetchState) !== 'In-Progress' &&
187
+ ((_j = (_h = state.monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[currentTenant.tenantId]) === null || _h === void 0 ? void 0 : _h[monthEndChecksId]) === null || _j === void 0 ? void 0 : _j.fetchState) !== 'Completed' &&
187
188
  excludeResources.includes('expense_automation_card') === false) {
188
189
  fetchActions.push((0, monthEndCloseChecksViewReducer_1.fetchMonthEndCloseChecks)({
189
190
  tenantId,
@@ -8,14 +8,14 @@ import { fetchCashFlow } from '../cashFlow/cashFlowReducer';
8
8
  export declare type ActionType = ReturnType<typeof fetchFinanceStatement> | ReturnType<typeof fetchAllTenants> | ReturnType<typeof fetchProfitAndLoss> | ReturnType<typeof fetchBalanceSheet> | ReturnType<typeof fetchCashFlow>;
9
9
  export declare const fetchFinanceStatementEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => import("rxjs").Observable<{
10
10
  payload: {
11
- timeframe: "month" | "year" | "quarter";
12
- fetchFullReport: boolean;
11
+ userId: string;
12
+ zeniSessionId: string | undefined;
13
13
  };
14
14
  type: string;
15
15
  } | {
16
16
  payload: {
17
- userId: string;
18
- zeniSessionId: string | undefined;
17
+ timeframe: "month" | "year" | "quarter";
18
+ fetchFullReport: boolean;
19
19
  };
20
20
  type: string;
21
21
  } | {
@@ -11,6 +11,7 @@ const timePeriod_1 = require("../../commonStateTypes/timePeriod");
11
11
  const zeniDayJS_1 = require("../../zeniDayJS");
12
12
  const tenantSelector_1 = require("../../entity/tenant/tenantSelector");
13
13
  const formatZeniDateFY_1 = require("../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
14
+ const fetchAllTenantsEpic_1 = require("../../entity/tenant/epic/fetchAllTenantsEpic");
14
15
  const isMonthEndInsightDisabled = (currentTenant, selectedPeriod, userAllowedToAccessMonthEndInsights, auditSummary) => {
15
16
  if (auditSummary != null) {
16
17
  if (auditSummary.auditScorePercentage < 75 &&
@@ -39,14 +40,14 @@ const isMonthEndInsightDisabled = (currentTenant, selectedPeriod, userAllowedToA
39
40
  };
40
41
  exports.isMonthEndInsightDisabled = isMonthEndInsightDisabled;
41
42
  exports.getMonthEndCloseChecksViewByTenantId = (0, toolkit_1.createSelector)((state) => state.monthEndCloseChecksState, (state) => state.monthEndCloseChecksViewState, (state) => state.expenseAutomationViewState, (state) => (0, tenantSelector_1.getCurrentTenant)(state), (state) => state.companyState, (state) => state.tenantState, (_state, tenantId) => tenantId, (monthEndCloseChecksState, monthEndCloseChecksViewState, expenseAutomationViewState, currentTenant, companyState, tenantState, tenantId) => {
42
- var _a, _b;
43
+ var _a, _b, _c;
43
44
  const { refreshStatus } = monthEndCloseChecksViewState;
44
45
  const { loggedInUser } = tenantState;
45
- const selectedPeriod = expenseAutomationViewState.selectedPeriodByTenantId[tenantId];
46
+ const selectedPeriod = (_a = expenseAutomationViewState.selectedPeriodByTenantId[tenantId]) !== null && _a !== void 0 ? _a : fetchAllTenantsEpic_1.defaultMonthYearPeriod;
46
47
  const { monthEndCloseChecksViewByTenantId } = monthEndCloseChecksViewState;
47
48
  const monthYearPeriodId = selectedPeriod != null ? (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod) : null;
48
49
  const monthEndCloseChecksView = monthYearPeriodId != null
49
- ? (_a = monthEndCloseChecksViewByTenantId[tenantId]) === null || _a === void 0 ? void 0 : _a[monthYearPeriodId]
50
+ ? (_b = monthEndCloseChecksViewByTenantId[tenantId]) === null || _b === void 0 ? void 0 : _b[monthYearPeriodId]
50
51
  : undefined;
51
52
  const monthEndCloseChecks = monthYearPeriodId != null
52
53
  ? (0, monthEndCloseChecksSelector_1.getMonthEndCloseChecksByTenantId)(monthEndCloseChecksState, tenantId, monthYearPeriodId)
@@ -58,7 +59,7 @@ exports.getMonthEndCloseChecksViewByTenantId = (0, toolkit_1.createSelector)((st
58
59
  const currentCompany = companyState.companiesById[currentTenant.companyId];
59
60
  const managementInfo = currentCompany === null || currentCompany === void 0 ? void 0 : currentCompany.managementInfo;
60
61
  const preparerUserIds = managementInfo != null ? managementInfo.preparerUserIds : [];
61
- const isZeniUser = Boolean((_b = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.userEmail) === null || _b === void 0 ? void 0 : _b.includes('zeni.ai'));
62
+ const isZeniUser = Boolean((_c = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.userEmail) === null || _c === void 0 ? void 0 : _c.includes('zeni.ai'));
62
63
  const isPreparer = loggedInUser != null && preparerUserIds.includes(loggedInUser.userId);
63
64
  const userAllowedToAccessMonthEndInsights = isZeniUser === false || isPreparer === false;
64
65
  const monthEndCloseCheckListWithDisabledState = sortedMonthEndCloseCheckList.map((check) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.14.13",
3
+ "version": "4.14.15",
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
  "types": "lib/index.d.ts",