@zeniai/client-epic-state 5.0.8 → 5.0.9-beta0ND

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 (32) hide show
  1. package/lib/coreEpics.js +2 -1
  2. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  3. package/lib/entity/snackbar/snackbarTypes.js +1 -0
  4. package/lib/entity/tenant/SessionManager.d.ts +38 -0
  5. package/lib/entity/tenant/SessionManager.js +171 -0
  6. package/lib/entity/tenant/epic/sessionHeartbeatEpic.d.ts +16 -0
  7. package/lib/entity/tenant/epic/sessionHeartbeatEpic.js +16 -0
  8. package/lib/entity/tenant/sessionTypes.d.ts +26 -0
  9. package/lib/entity/tenant/sessionTypes.js +12 -0
  10. package/lib/entity/tenant/tenantReducer.d.ts +5 -1
  11. package/lib/entity/tenant/tenantReducer.js +23 -2
  12. package/lib/entity/tenant/tenantState.d.ts +1 -0
  13. package/lib/esm/coreEpics.js +2 -1
  14. package/lib/esm/entity/snackbar/snackbarTypes.js +1 -0
  15. package/lib/esm/entity/tenant/SessionManager.js +167 -0
  16. package/lib/esm/entity/tenant/epic/sessionHeartbeatEpic.js +12 -0
  17. package/lib/esm/entity/tenant/sessionTypes.js +9 -0
  18. package/lib/esm/entity/tenant/tenantReducer.js +21 -1
  19. package/lib/esm/index.js +5 -2
  20. package/lib/esm/view/aiAccountantView/aiAccountantViewReducer.js +3 -0
  21. package/lib/esm/view/aiAccountantView/aiAccountantViewSelector.js +5 -0
  22. package/lib/esm/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +29 -5
  23. package/lib/index.d.ts +5 -2
  24. package/lib/index.js +36 -30
  25. package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
  26. package/lib/view/aiAccountantView/aiAccountantViewPayload.d.ts +2 -0
  27. package/lib/view/aiAccountantView/aiAccountantViewReducer.js +3 -0
  28. package/lib/view/aiAccountantView/aiAccountantViewSelector.d.ts +3 -1
  29. package/lib/view/aiAccountantView/aiAccountantViewSelector.js +5 -0
  30. package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +29 -5
  31. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  32. package/package.json +1 -1
@@ -15,6 +15,8 @@ export interface AiAccountantJobsResponseData {
15
15
  export interface AiAccountantTriggerJobResponseData {
16
16
  job_ids: string[];
17
17
  queued_count: number;
18
+ /** Present on failures (e.g. "no valid customers for this operation"). */
19
+ error?: string;
18
20
  skipped?: Array<{
19
21
  reason: string;
20
22
  tenant_id: string;
@@ -83,6 +83,9 @@ const aiAccountantView = (0, toolkit_1.createSlice)({
83
83
  },
84
84
  triggerAiAccountantJobSuccess(draft) {
85
85
  draft.triggerJobStatus = { fetchState: 'Completed' };
86
+ // Bulk selection resets after a successful fire so checkboxes
87
+ // return to an empty state along with the customer-list refresh.
88
+ draft.selectedTenantIdsForJobTrigger = [];
86
89
  },
87
90
  triggerAiAccountantJobFailure(draft, action) {
88
91
  draft.triggerJobStatus = { fetchState: 'Error', error: action.payload };
@@ -1,4 +1,4 @@
1
- import { FetchStateAndError } from '../../commonStateTypes/common';
1
+ import { FetchStateAndError, ID } from '../../commonStateTypes/common';
2
2
  import { SelectorView } from '../../commonStateTypes/viewAndReport/viewAndReport';
3
3
  import { AiAccountantCustomerView } from '../../entity/aiAccountantCustomer/aiAccountantCustomerSelector';
4
4
  import { RootState } from '../../reducer';
@@ -8,7 +8,9 @@ export interface AiAccountantCockpitView extends SelectorView {
8
8
  customers: AiAccountantCustomerView[];
9
9
  customerViewStateByTenantId: Record<string, AiAccountantCustomerViewState>;
10
10
  selectedCustomersForJobTrigger: AiAccountantCustomerView[];
11
+ selectedTenantIds: ID[];
11
12
  triggerJobStatus: FetchStateAndError;
12
13
  uiState: AiAccountantUIState;
14
+ unonboardedTenantIds: ID[];
13
15
  }
14
16
  export declare const getAiAccountantCockpitView: (state: RootState) => AiAccountantCockpitView;
@@ -33,6 +33,9 @@ exports.getAiAccountantCockpitView = (0, toolkit_1.createSelector)((state) => st
33
33
  // Sorting
34
34
  const sortedCustomers = getSortedCustomers(filteredCustomers, uiState.sortKey, uiState.sortOrder);
35
35
  const selectedCustomersForJobTrigger = allCustomers.filter((customer) => selectedTenantIdsForJobTrigger.includes(customer.tenantId));
36
+ const unonboardedTenantIds = allCustomers
37
+ .filter((customer) => customer.enrollment == null)
38
+ .map((customer) => customer.tenantId);
36
39
  return {
37
40
  averageAccuracy: calcOverallAverageAccuracy(allCustomers),
38
41
  fetchState: customersFetchStatus.fetchState,
@@ -40,8 +43,10 @@ exports.getAiAccountantCockpitView = (0, toolkit_1.createSelector)((state) => st
40
43
  customers: sortedCustomers,
41
44
  customerViewStateByTenantId: customersByTenantId,
42
45
  selectedCustomersForJobTrigger,
46
+ selectedTenantIds: selectedTenantIdsForJobTrigger,
43
47
  triggerJobStatus,
44
48
  uiState,
49
+ unonboardedTenantIds,
45
50
  };
46
51
  });
47
52
  // ── Helpers ──
@@ -27,30 +27,54 @@ const triggerAiAccountantJobEpic = (actions$, state$, zeniAPI) => actions$.pipe(
27
27
  (0, aiAccountantViewReducer_1.triggerAiAccountantJobSuccess)(),
28
28
  (0, aiAccountantViewReducer_1.fetchAiAccountantCustomers)(),
29
29
  (0, snackbarReducer_1.openSnackbar)({
30
- messageSection: 'common',
30
+ messageSection: 'ai_accountant_trigger_job',
31
31
  messageText: 'success',
32
32
  type: 'success',
33
33
  }),
34
34
  ]);
35
35
  }
36
36
  else {
37
+ const reason = resolveTriggerFailureReason(response);
37
38
  return (0, rxjs_1.from)([
38
39
  (0, aiAccountantViewReducer_1.triggerAiAccountantJobFailure)(response.status),
39
40
  (0, snackbarReducer_1.openSnackbar)({
40
- messageSection: 'common',
41
+ messageSection: 'ai_accountant_trigger_job',
41
42
  messageText: 'failed',
42
43
  type: 'error',
44
+ variables: [
45
+ { variableName: '__reason__', variableValue: reason },
46
+ ],
43
47
  }),
44
48
  ]);
45
49
  }
46
50
  }), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
47
- (0, aiAccountantViewReducer_1.triggerAiAccountantJobFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected error', 'AI Accountant trigger job failed: ' +
48
- JSON.stringify(error))),
51
+ (0, aiAccountantViewReducer_1.triggerAiAccountantJobFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected error', 'AI Accountant trigger job failed: ' + JSON.stringify(error))),
49
52
  (0, snackbarReducer_1.openSnackbar)({
50
- messageSection: 'common',
53
+ messageSection: 'ai_accountant_trigger_job',
51
54
  messageText: 'failed',
52
55
  type: 'error',
56
+ variables: [
57
+ { variableName: '__reason__', variableValue: 'Unexpected error' },
58
+ ],
53
59
  }),
54
60
  ])));
55
61
  }));
56
62
  exports.triggerAiAccountantJobEpic = triggerAiAccountantJobEpic;
63
+ /**
64
+ * Pick the most useful failure reason from the trigger response:
65
+ * prefer the first `skipped[].reason`, then `data.error`, then the
66
+ * status message. Falls back to empty so the snackbar template can
67
+ * still render.
68
+ */
69
+ const resolveTriggerFailureReason = (response) => {
70
+ if (response.data?.skipped != null && response.data.skipped.length > 0) {
71
+ return response.data.skipped[0].reason;
72
+ }
73
+ if (response.data?.error != null && response.data.error.length > 0) {
74
+ return response.data.error;
75
+ }
76
+ if (response.status.message.length > 0) {
77
+ return response.status.message;
78
+ }
79
+ return '';
80
+ };
@@ -37,7 +37,7 @@ export declare const getLineItemsByTransactionsIdsFromResponse: (transactions: S
37
37
  export declare const getLineItemsByTransactionIdsFromLocalData: (transactionLocalData: TransactionReviewLocalDataSelectorView[], selectedTab: TransactionsTab) => Record<ID, string[]>;
38
38
  export declare const mergeTabSpecificLineItems: (currentTabSpecificLineItems: TabSpecificLineItems, selectedTab: TransactionsTab, newLineItems: TabSpecificLineItems) => TabSpecificLineItems;
39
39
  export declare const getSnackbarMessageForTransactionReview: (updatedCount: number, failedCount: number, categorizedCount: number) => {
40
- messageSection: "common" | "transactionDetails_updatingPastTransactions" | "transactionDetails_transactionUpdated" | "cockpit_month_end_email_sent" | "cockpit_month_end_email_save" | "cockpit_month_end_email_attachment_upload" | "je_bill_link" | "je_posted" | "audit_score_updated" | "people_invite_people" | "people_invite_multiple_people" | "people_delete_person" | "people_update_person" | "reimbursement_updated" | "reimbursement_deleted" | "reimbursement_cancelled_deleted" | "reimbursement_cancelled" | "reimbursement_approved" | "reimbursement_rejected" | "reimbursement_sent_for_approval" | "account_added" | "business_verification_save" | "business_verification_submit" | "business_verification_from_bills_submit" | "plaid_connection" | "unlink_deposit_account" | "reimbursement_setup" | "reimbursement_approval_create" | "reimbursement_duplicate_approval_create" | "reimbursement_approval_update" | "reimbursement_duplicate_approval_update" | "reimbursement_approval_delete" | "reimbursement_create_mileage" | "reimbursement_update_mileage" | "reimbursement_accept_term" | "reimbursement_accept_employee_term" | "reimbursement_bulk_submit" | "reimbursement_bulk_processed" | "bill_pay_setup" | "zeni_accounts_setup" | "bill_pay_approval_create" | "bill_pay_duplicate_approval_create" | "bill_pay_approval_update" | "bill_pay_duplicate_approval_update" | "bill_pay_approval_delete" | "bill_pay_updated" | "bill_pay_deleted" | "bill_pay_cancelled_deleted" | "bill_pay_cancelled" | "bill_pay_approved" | "real_time_approver_added" | "bill_pay_rejected" | "bill_pay_sent_for_approval" | "bill_pay_accept_term" | "bill_pay_bulk_submit" | "bill_pay_bulk_processed" | "bill_pay_refund" | "bill_pay_retry" | "bill_pay_marked_as_paid" | "zeni_account_accept_term" | "update_vendor" | "data_refresh_update" | "delete_bank_account" | "create_bank_account" | "create_bank_account_ach" | "create_bank_account_wire" | "create_bank_account_international" | "transfer_money" | "update_zeni_account_nickname" | "create_checking_account" | "deposit_check" | "create_vendor" | "onboarding_customer_view" | "onboarding_customer_view_complete" | "onboarding_customer_identity_verification_save" | "onboarding_customer_identity_verification_submit" | "onboarding_customer_business_verification_save" | "onboarding_customer_business_verification_submit" | "retry_bank_account_connection" | "dashboard_invite_sent" | "onboarding_info_saved" | "approve_original_merchant" | "approve_global_merchant" | "reject_global_merchant" | "create_global_merchant" | "fetch_global_merchant_no_recommendation" | "save_vendor_renamed" | "save_vendor_sent_for_review" | "save_vendor_marked_as_employee" | "save_vendor_marked_as_local_contractor" | "charge_card_setup" | "charge_card_accept_term" | "charge_card_receipt_upload" | "charge_card_resend_invite" | "charge_card_revoke_invite" | "charge_card_update_limit" | "charge_cards_update_limit" | "close_charge_card" | "lock_charge_card" | "lock_charge_card_card_user" | "lock_charge_cards" | "unlock_charge_card" | "unlock_charge_card_card_user" | "unlock_charge_cards" | "close_charge_cards" | "revoke_invite_charge_cards" | "charge_card_express_interest" | "create_schedule" | "save_schedule" | "delete_schedule" | "ignore_schedule" | "save_task_detail" | "fetch_task_detail" | "delete_task" | "archive_task" | "create_tag" | "delete_tag" | "update_charge_card" | "update_charge_card_name" | "update_charge_card_name_card_user" | "issue_charge_card" | "issue_charge_cards" | "notification_settings_saved" | "referral_invite_sent" | "notification_mark_as_read" | "mark_as_complete_schedule" | "cancel_journal_entry" | "settings_accounting_accounts_updated" | "create_card_setup" | "confirm_card_setup" | "add_card_payment_source" | "fetch_payment_sources" | "task_assigned_toast_notification" | "task_due_tomorrow_toast_notification" | "task_deleted_toast_notification" | "task_archived_toast_notification" | "task_overdue_toast_notification" | "task_overdue_toast_notification_creator" | "task_notification_count" | "task_activities_toast_notification" | "task_created_toast_notification" | "task_group_creation_success" | "task_group_deletion_success" | "task_group_update_success" | "primary_funding_account_updated" | "task_time_spent_validation" | "missing_receipts_attachment" | "flux_analysis_unreviewed" | "flux_analysis_reviewed" | "receipt_match" | "receipts_upload" | "receipts_bulk_match" | "billing_address_view" | "express_pay_submit" | "exclude_transaction" | "reconcile" | "save_reconcile_for_later" | "recon_transaction_categorize" | "recon_transaction_match" | "update_debit_card_pin_attempt" | "set_debit_card_pin" | "ai_cfo_create_session_and_submit" | "ai_cfo_chat_session_deleted" | "charge_card_auto_pay_enable" | "charge_card_auto_pay_disable" | "treasury_setup" | "treasury_accept_term" | "treasury_transfer_money" | "treasury_transfer_money_failed" | "auto_transfer_rule_create" | "auto_transfer_rule_update" | "auto_transfer_rule_delete" | "auto_transfer_rule_pause" | "auto_transfer_rule_resume" | "treasury_update_portfolio_allocation" | "send_email_magic_link_to_user" | "complete_profile_done" | "reports_resync" | "invalid_phone_number" | "transactions_categorized_updated_failed" | "transaction_categorized_updated_failed" | "transactionsCategorized_transactionsUpdated" | "transactionsCategorized_transactionUpdated" | "transactionCategorized_transactionsUpdated" | "transactionCategorized_transactionUpdated" | "transactionsCategorized_transactionsFailed" | "transactionsCategorized_transactionFailed" | "transactionCategorized_transactionsFailed" | "transactionCategorized_transactionFailed" | "transactionsUpdated_transactionsFailed" | "transactionsUpdated_transactionFailed" | "transactionUpdated_transactionsFailed" | "transactionUpdated_transactionFailed" | "transactionsCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionsUpdated_transactionFailed" | "transactionsCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionUpdated_transactionFailed" | "transactionCategorized_transactionsUpdated_transactionFailed" | "transactionCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionUpdated_transactionFailed" | "accounting_classes_enabled_update" | "account_excluded_from_reconciliation" | "account_included_in_reconciliation";
40
+ messageSection: "common" | "transactionDetails_updatingPastTransactions" | "transactionDetails_transactionUpdated" | "cockpit_month_end_email_sent" | "cockpit_month_end_email_save" | "cockpit_month_end_email_attachment_upload" | "je_bill_link" | "je_posted" | "audit_score_updated" | "people_invite_people" | "people_invite_multiple_people" | "people_delete_person" | "people_update_person" | "reimbursement_updated" | "reimbursement_deleted" | "reimbursement_cancelled_deleted" | "reimbursement_cancelled" | "reimbursement_approved" | "reimbursement_rejected" | "reimbursement_sent_for_approval" | "account_added" | "business_verification_save" | "business_verification_submit" | "business_verification_from_bills_submit" | "plaid_connection" | "unlink_deposit_account" | "reimbursement_setup" | "reimbursement_approval_create" | "reimbursement_duplicate_approval_create" | "reimbursement_approval_update" | "reimbursement_duplicate_approval_update" | "reimbursement_approval_delete" | "reimbursement_create_mileage" | "reimbursement_update_mileage" | "reimbursement_accept_term" | "reimbursement_accept_employee_term" | "reimbursement_bulk_submit" | "reimbursement_bulk_processed" | "bill_pay_setup" | "zeni_accounts_setup" | "bill_pay_approval_create" | "bill_pay_duplicate_approval_create" | "bill_pay_approval_update" | "bill_pay_duplicate_approval_update" | "bill_pay_approval_delete" | "bill_pay_updated" | "bill_pay_deleted" | "bill_pay_cancelled_deleted" | "bill_pay_cancelled" | "bill_pay_approved" | "real_time_approver_added" | "bill_pay_rejected" | "bill_pay_sent_for_approval" | "bill_pay_accept_term" | "bill_pay_bulk_submit" | "bill_pay_bulk_processed" | "bill_pay_refund" | "bill_pay_retry" | "bill_pay_marked_as_paid" | "zeni_account_accept_term" | "update_vendor" | "data_refresh_update" | "delete_bank_account" | "create_bank_account" | "create_bank_account_ach" | "create_bank_account_wire" | "create_bank_account_international" | "transfer_money" | "update_zeni_account_nickname" | "create_checking_account" | "deposit_check" | "create_vendor" | "onboarding_customer_view" | "onboarding_customer_view_complete" | "onboarding_customer_identity_verification_save" | "onboarding_customer_identity_verification_submit" | "onboarding_customer_business_verification_save" | "onboarding_customer_business_verification_submit" | "retry_bank_account_connection" | "dashboard_invite_sent" | "onboarding_info_saved" | "approve_original_merchant" | "approve_global_merchant" | "reject_global_merchant" | "create_global_merchant" | "fetch_global_merchant_no_recommendation" | "save_vendor_renamed" | "save_vendor_sent_for_review" | "save_vendor_marked_as_employee" | "save_vendor_marked_as_local_contractor" | "charge_card_setup" | "charge_card_accept_term" | "charge_card_receipt_upload" | "charge_card_resend_invite" | "charge_card_revoke_invite" | "charge_card_update_limit" | "charge_cards_update_limit" | "close_charge_card" | "lock_charge_card" | "lock_charge_card_card_user" | "lock_charge_cards" | "unlock_charge_card" | "unlock_charge_card_card_user" | "unlock_charge_cards" | "close_charge_cards" | "revoke_invite_charge_cards" | "charge_card_express_interest" | "create_schedule" | "save_schedule" | "delete_schedule" | "ignore_schedule" | "save_task_detail" | "fetch_task_detail" | "delete_task" | "archive_task" | "create_tag" | "delete_tag" | "update_charge_card" | "update_charge_card_name" | "update_charge_card_name_card_user" | "issue_charge_card" | "issue_charge_cards" | "notification_settings_saved" | "referral_invite_sent" | "notification_mark_as_read" | "mark_as_complete_schedule" | "cancel_journal_entry" | "settings_accounting_accounts_updated" | "create_card_setup" | "confirm_card_setup" | "add_card_payment_source" | "fetch_payment_sources" | "task_assigned_toast_notification" | "task_due_tomorrow_toast_notification" | "task_deleted_toast_notification" | "task_archived_toast_notification" | "task_overdue_toast_notification" | "task_overdue_toast_notification_creator" | "task_notification_count" | "task_activities_toast_notification" | "task_created_toast_notification" | "task_group_creation_success" | "task_group_deletion_success" | "task_group_update_success" | "primary_funding_account_updated" | "task_time_spent_validation" | "missing_receipts_attachment" | "flux_analysis_unreviewed" | "flux_analysis_reviewed" | "receipt_match" | "receipts_upload" | "receipts_bulk_match" | "billing_address_view" | "express_pay_submit" | "exclude_transaction" | "reconcile" | "save_reconcile_for_later" | "recon_transaction_categorize" | "recon_transaction_match" | "update_debit_card_pin_attempt" | "set_debit_card_pin" | "ai_cfo_create_session_and_submit" | "ai_cfo_chat_session_deleted" | "charge_card_auto_pay_enable" | "charge_card_auto_pay_disable" | "treasury_setup" | "treasury_accept_term" | "treasury_transfer_money" | "treasury_transfer_money_failed" | "auto_transfer_rule_create" | "auto_transfer_rule_update" | "auto_transfer_rule_delete" | "auto_transfer_rule_pause" | "auto_transfer_rule_resume" | "treasury_update_portfolio_allocation" | "send_email_magic_link_to_user" | "complete_profile_done" | "reports_resync" | "invalid_phone_number" | "transactions_categorized_updated_failed" | "transaction_categorized_updated_failed" | "transactionsCategorized_transactionsUpdated" | "transactionsCategorized_transactionUpdated" | "transactionCategorized_transactionsUpdated" | "transactionCategorized_transactionUpdated" | "transactionsCategorized_transactionsFailed" | "transactionsCategorized_transactionFailed" | "transactionCategorized_transactionsFailed" | "transactionCategorized_transactionFailed" | "transactionsUpdated_transactionsFailed" | "transactionsUpdated_transactionFailed" | "transactionUpdated_transactionsFailed" | "transactionUpdated_transactionFailed" | "transactionsCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionsUpdated_transactionFailed" | "transactionsCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionUpdated_transactionFailed" | "transactionCategorized_transactionsUpdated_transactionFailed" | "transactionCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionUpdated_transactionFailed" | "accounting_classes_enabled_update" | "account_excluded_from_reconciliation" | "account_included_in_reconciliation" | "ai_accountant_trigger_job";
41
41
  messageText: "notification" | "failed" | "success";
42
42
  type: "error" | "success" | "info";
43
43
  variables: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.8",
3
+ "version": "5.0.9-beta0ND",
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",