@zeniai/client-epic-state 5.0.67-beta0ND → 5.0.68

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 (107) hide show
  1. package/lib/commonStateTypes/cacheOverrideFetchReducer.d.ts +1 -1
  2. package/lib/commonStateTypes/pusherActions.d.ts +1 -1
  3. package/lib/coreEpics.js +1 -1
  4. package/lib/entity/account/accountSelector.d.ts +1 -1
  5. package/lib/entity/account/accountState.d.ts +1 -1
  6. package/lib/entity/account/subAccountSelector.d.ts +1 -1
  7. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +1 -3
  8. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +1 -2
  9. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerSelector.d.ts +1 -1
  10. package/lib/entity/chargeCardRepayment/chargeCardRepayment.d.ts +1 -1
  11. package/lib/entity/chargeCardTransaction/chargeCardTransactionReducer.js +1 -1
  12. package/lib/entity/creditAgent/creditAgentState.d.ts +1 -1
  13. package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +1 -1
  14. package/lib/entity/sectionProjectView/sectionProjectViewSelector.js +1 -1
  15. package/lib/entity/tenant/SessionManager.js +6 -3
  16. package/lib/entity/tenant/clearAllEpic.d.ts +2 -2
  17. package/lib/entity/tenant/clearAllEpic.js +2 -2
  18. package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.js +6 -2
  19. package/lib/entity/tenant/epic/saveOAuthConnectionEpic.js +6 -2
  20. package/lib/entity/tenant/tenantReducer.js +6 -1
  21. package/lib/entity/transaction/payloadTypes/transactionLinePayload.js +3 -1
  22. package/lib/epic.d.ts +1 -2
  23. package/lib/epic.js +1 -2
  24. package/lib/esm/coreEpics.js +1 -1
  25. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +1 -3
  26. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +1 -2
  27. package/lib/esm/entity/chargeCardTransaction/chargeCardTransactionReducer.js +1 -1
  28. package/lib/esm/entity/sectionProjectView/sectionProjectViewSelector.js +1 -1
  29. package/lib/esm/entity/tenant/SessionManager.js +4 -1
  30. package/lib/esm/entity/tenant/clearAllEpic.js +2 -2
  31. package/lib/esm/entity/tenant/epic/saveAPIKeyConnectionEpic.js +6 -2
  32. package/lib/esm/entity/tenant/epic/saveOAuthConnectionEpic.js +6 -2
  33. package/lib/esm/entity/tenant/tenantReducer.js +6 -1
  34. package/lib/esm/entity/transaction/payloadTypes/transactionLinePayload.js +3 -1
  35. package/lib/esm/epic.js +1 -2
  36. package/lib/esm/index.js +0 -2
  37. package/lib/esm/reducer.js +0 -6
  38. package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +2 -5
  39. package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +2 -5
  40. package/lib/esm/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +4 -1
  41. package/lib/esm/view/companyTaskManagerView/companyTaskManagerViewSelector.js +1 -1
  42. package/lib/esm/view/companyTaskManagerView/epics/fetchTaskManagerMetricsEpic.js +1 -1
  43. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +2 -2
  44. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +8 -6
  45. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +1 -1
  46. package/lib/esm/view/financeStatement/financeStatementSelector.js +1 -1
  47. package/lib/esm/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsPageEpic.js +0 -4
  48. package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +1 -1
  49. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +1 -3
  50. package/lib/esm/view/taskManager/cannedResponsesView/epics/fetchCannedResponsesEpic.js +1 -1
  51. package/lib/esm/view/taskManager/cannedResponsesView/epics/saveCannedResponseEpic.js +1 -1
  52. package/lib/esm/view/taskManager/taskDetailView/epics/unsnoozeTaskEpic.js +1 -1
  53. package/lib/esm/view/transactionDetail/transactionDetailSelector.js +7 -1
  54. package/lib/index.d.ts +0 -3
  55. package/lib/index.js +1 -6
  56. package/lib/reducer.d.ts +0 -6
  57. package/lib/reducer.js +0 -6
  58. package/lib/view/aiAccountantView/aiAccountantViewPayload.d.ts +2 -2
  59. package/lib/view/aiAccountantView/aiAccountantViewReducer.d.ts +1 -1
  60. package/lib/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +2 -5
  61. package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +2 -5
  62. package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +4 -1
  63. package/lib/view/companyTaskManagerView/companyTaskManagerViewSelector.d.ts +1 -1
  64. package/lib/view/companyTaskManagerView/companyTaskManagerViewSelector.js +1 -1
  65. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +2 -2
  66. package/lib/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +8 -6
  67. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +1 -1
  68. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  69. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +1 -1
  70. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +1 -1
  71. package/lib/view/financeStatement/financeStatementSelector.js +1 -1
  72. package/lib/view/profitAndLossProjectView/profitAndLossProjectViewSelectorTypes.d.ts +1 -1
  73. package/lib/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsPageEpic.d.ts +1 -2
  74. package/lib/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsPageEpic.js +0 -4
  75. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +1 -1
  76. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +1 -3
  77. package/lib/view/transactionDetail/transactionDetailSelector.js +7 -1
  78. package/lib/view/zeniOAuthView/zeniOAuthSelector.d.ts +1 -1
  79. package/package.json +9 -4
  80. package/lib/entity/scheduleActivityLog/scheduleActivityLogPayload.d.ts +0 -36
  81. package/lib/entity/scheduleActivityLog/scheduleActivityLogPayload.js +0 -55
  82. package/lib/entity/scheduleActivityLog/scheduleActivityLogReducer.d.ts +0 -6
  83. package/lib/entity/scheduleActivityLog/scheduleActivityLogReducer.js +0 -27
  84. package/lib/entity/scheduleActivityLog/scheduleActivityLogSelector.d.ts +0 -4
  85. package/lib/entity/scheduleActivityLog/scheduleActivityLogSelector.js +0 -17
  86. package/lib/entity/scheduleActivityLog/scheduleActivityLogState.d.ts +0 -51
  87. package/lib/entity/scheduleActivityLog/scheduleActivityLogState.js +0 -23
  88. package/lib/esm/entity/scheduleActivityLog/scheduleActivityLogPayload.js +0 -49
  89. package/lib/esm/entity/scheduleActivityLog/scheduleActivityLogReducer.js +0 -23
  90. package/lib/esm/entity/scheduleActivityLog/scheduleActivityLogSelector.js +0 -10
  91. package/lib/esm/entity/scheduleActivityLog/scheduleActivityLogState.js +0 -19
  92. package/lib/esm/view/scheduleActivityLogView/fetchScheduleActivityLogEpic.js +0 -43
  93. package/lib/esm/view/scheduleActivityLogView/scheduleActivityLogViewPayload.js +0 -1
  94. package/lib/esm/view/scheduleActivityLogView/scheduleActivityLogViewReducer.js +0 -47
  95. package/lib/esm/view/scheduleActivityLogView/scheduleActivityLogViewSelector.js +0 -33
  96. package/lib/esm/view/scheduleActivityLogView/scheduleActivityLogViewState.js +0 -1
  97. package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
  98. package/lib/view/scheduleActivityLogView/fetchScheduleActivityLogEpic.d.ts +0 -9
  99. package/lib/view/scheduleActivityLogView/fetchScheduleActivityLogEpic.js +0 -47
  100. package/lib/view/scheduleActivityLogView/scheduleActivityLogViewPayload.d.ts +0 -8
  101. package/lib/view/scheduleActivityLogView/scheduleActivityLogViewPayload.js +0 -2
  102. package/lib/view/scheduleActivityLogView/scheduleActivityLogViewReducer.d.ts +0 -17
  103. package/lib/view/scheduleActivityLogView/scheduleActivityLogViewReducer.js +0 -51
  104. package/lib/view/scheduleActivityLogView/scheduleActivityLogViewSelector.d.ts +0 -8
  105. package/lib/view/scheduleActivityLogView/scheduleActivityLogViewSelector.js +0 -36
  106. package/lib/view/scheduleActivityLogView/scheduleActivityLogViewState.d.ts +0 -5
  107. package/lib/view/scheduleActivityLogView/scheduleActivityLogViewState.js +0 -2
@@ -63,7 +63,13 @@ const getTransactionDetail = (state, transactionId, fetchLinkedTransactions = tr
63
63
  const isAccountingClassesEnabled = (0, tenantSelector_1.getIsAccountingClassesEnabled)(state);
64
64
  const classList = isAccountingClassesEnabled
65
65
  ? (0, classListSelector_1.getClassList)(classState, classListState)
66
- : { classes: [], nestedClassHierarchy: [], fetchState: 'Completed', error: undefined, version: 0 };
66
+ : {
67
+ classes: [],
68
+ nestedClassHierarchy: [],
69
+ fetchState: 'Completed',
70
+ error: undefined,
71
+ version: 0,
72
+ };
67
73
  const isAccountingProjectsEnabled = (0, tenantSelector_1.getIsAccountingProjectsEnabled)(state);
68
74
  const projectList = isAccountingProjectsEnabled
69
75
  ? (0, projectListSelector_1.getProjectList)(projectState, projectListState)
@@ -1,5 +1,5 @@
1
- import { RootState } from '../../reducer';
2
1
  import { FetchState } from '../../commonStateTypes/common';
2
+ import { RootState } from '../../reducer';
3
3
  export declare const getZeniOAuthApproveFetchState: (state: RootState) => FetchState;
4
4
  export declare const getZeniOAuthApproveRedirectUrl: (state: RootState) => string | undefined;
5
5
  export declare const getZeniOAuthApproveError: (state: RootState) => string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.67-beta0ND",
3
+ "version": "5.0.68",
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",
@@ -106,12 +106,17 @@
106
106
  "scripts": {
107
107
  "clean": "rimraf lib",
108
108
  "test:typecheck": "echo 'Typechecking test files...' && NODE_OPTIONS=--max-old-space-size=4096 time tsc -p tsconfig.typecheck.json",
109
- "test": "pnpm test:typecheck && vitest run --typecheck",
110
- "lint": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
109
+ "test:typecheck-modified-files": "chmod +x ./scripts/tsc-modified-files.sh && ./scripts/tsc-modified-files.sh master tsconfig.typecheck.json",
110
+ "test": "pnpm lint-modified-files && pnpm test:typecheck-modified-files && vitest run --typecheck",
111
+ "lint": "eslint . --ext .js,.jsx,.ts,.tsx --max-warnings 0 --fix",
112
+ "lint-modified-files": "chmod +x ./scripts/lint-modified-files.sh && ./scripts/lint-modified-files.sh",
113
+ "lint:fix-modified-files": "chmod +x ./scripts/lint-modified-files.sh && LINT_FIX=true ./scripts/lint-modified-files.sh",
114
+ "tsc-modified-files": "chmod +x ./scripts/tsc-modified-files.sh && ./scripts/tsc-modified-files.sh",
115
+ "typecheck": "tsc --noEmit",
111
116
  "find-dead-code": "ts-prune | grep -v '(used in module)'",
112
117
  "find-unused-exports": "ts-unused-exports ./tsconfig.json",
113
118
  "circular-dependency": "npx madge --circular --extensions ts ./src",
114
- "build": "concurrently --kill-others-on-fail --handle-input \"echo 'Running ESLint...' && eslint . --ext .js,.jsx,.ts,.tsx\" \"echo 'TypeScript build in progress...' && time tsc && echo 'ESM build...' && tsc -p tsconfig.esm.json\" \"echo 'Running tests and typecheck...' && pnpm test\" && rimraf \"lib/**/__mocks__\" \"lib/**/__testHelpers__\"",
119
+ "build": "echo 'Running full ESLint...' && pnpm lint && concurrently --kill-others-on-fail --handle-input \"echo 'TypeScript build in progress...' && time tsc && echo 'ESM build...' && tsc -p tsconfig.esm.json\" \"echo 'Running tests and typecheck...' && pnpm test\" && rimraf \"lib/**/__mocks__\" \"lib/**/__testHelpers__\"",
115
120
  "only-build": "eslint . --ext .js,.jsx,.ts,.tsx && time tsc && tsc -p tsconfig.esm.json && rimraf \"lib/**/__mocks__\" \"lib/**/__testHelpers__\"",
116
121
  "only-build-dev": "eslint . --ext .js,.jsx,.ts,.tsx && time tsc -p tsconfig.dev.json && tsc -p tsconfig.esm.dev.json && rimraf \"lib/**/__mocks__\" \"lib/**/__testHelpers__\"",
117
122
  "format": "prettier --write --ignore-unknown \"src/**/*\" && pnpm lint",
@@ -1,36 +0,0 @@
1
- import { AccountBasePayload } from '../account/accountPayload';
2
- import { ClassBasePayload } from '../class/classPayload';
3
- import { AISummaryPayload } from '../transaction/payloadTypes/transactionLinePayload';
4
- import { VendorBasePayload } from '../vendor/vendorPayload';
5
- import { ScheduleActivityLog, ScheduleActivityLogData } from './scheduleActivityLogState';
6
- export interface ScheduleActivityLogLinePayload {
7
- account?: AccountBasePayload;
8
- accounting_class?: ClassBasePayload;
9
- line_description?: string;
10
- schedule_memo?: string;
11
- transaction_memo?: string;
12
- vendor?: VendorBasePayload;
13
- }
14
- export interface ScheduleActivityLogTransactionPayload {
15
- line_id: string;
16
- original_line: ScheduleActivityLogLinePayload;
17
- updated_line: ScheduleActivityLogLinePayload;
18
- schedule_id?: string;
19
- transaction_id?: string;
20
- }
21
- export interface ScheduleActivityLogDataPayload {
22
- transaction: ScheduleActivityLogTransactionPayload;
23
- ai_summaries?: AISummaryPayload[];
24
- user_id?: string;
25
- }
26
- export interface ScheduleActivityLogPayload {
27
- correlation_id: string;
28
- create_time: string;
29
- data: ScheduleActivityLogDataPayload | null;
30
- event_type: string;
31
- processing_time_ms: number;
32
- status_code: string;
33
- }
34
- export declare const toScheduleActivityLogId: (correlationId: string, eventType: string, lineId: string | null | undefined) => string;
35
- export declare const toScheduleActivityLogData: (data: ScheduleActivityLogDataPayload, correlationId: string) => ScheduleActivityLogData;
36
- export declare const toScheduleActivityLog: (payload: ScheduleActivityLogPayload) => ScheduleActivityLog;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toScheduleActivityLog = exports.toScheduleActivityLogData = exports.toScheduleActivityLogId = void 0;
4
- const zeniDayJS_1 = require("../../zeniDayJS");
5
- const accountPayload_1 = require("../account/accountPayload");
6
- const classPayload_1 = require("../class/classPayload");
7
- const transactionLinePayload_1 = require("../transaction/payloadTypes/transactionLinePayload");
8
- const vendorPayload_1 = require("../vendor/vendorPayload");
9
- const scheduleActivityLogState_1 = require("./scheduleActivityLogState");
10
- const toScheduleActivityLogId = (correlationId, eventType, lineId) => `${correlationId}-${eventType}-${lineId ?? '1'}`;
11
- exports.toScheduleActivityLogId = toScheduleActivityLogId;
12
- const toScheduleActivityLogLine = (line) => {
13
- const memo = line.schedule_memo ?? line.transaction_memo;
14
- return {
15
- account: line.account
16
- ? (0, accountPayload_1.mapAccountBasePayloadToAccountBase)(line.account)
17
- : undefined,
18
- class: line.accounting_class
19
- ? (0, classPayload_1.mapClassBasePayloadToClassBase)(line.accounting_class)
20
- : undefined,
21
- vendor: line.vendor
22
- ? (0, vendorPayload_1.mapVendorBasePayloadToVendorBase)(line.vendor)
23
- : undefined,
24
- memo,
25
- description: line.line_description,
26
- };
27
- };
28
- const toTransaction = (transaction, correlationId, userId) => {
29
- return {
30
- lineId: transaction.line_id,
31
- originalLine: toScheduleActivityLogLine(transaction.original_line),
32
- updatedLine: toScheduleActivityLogLine(transaction.updated_line),
33
- correlationId,
34
- userId,
35
- };
36
- };
37
- const toScheduleActivityLogData = (data, correlationId) => {
38
- return {
39
- aiSummaries: (data.ai_summaries ?? []).map(transactionLinePayload_1.toAISummary),
40
- transaction: toTransaction(data.transaction, correlationId, data.user_id),
41
- user: undefined,
42
- };
43
- };
44
- exports.toScheduleActivityLogData = toScheduleActivityLogData;
45
- const toScheduleActivityLog = (payload) => {
46
- return {
47
- id: (0, exports.toScheduleActivityLogId)(payload.correlation_id, payload.event_type, payload.data?.transaction?.line_id),
48
- data: payload.data != null
49
- ? (0, exports.toScheduleActivityLogData)(payload.data, payload.correlation_id)
50
- : null,
51
- eventType: (0, scheduleActivityLogState_1.toScheduleActivityLogEventType)(payload.event_type),
52
- createTime: (0, zeniDayJS_1.date)(payload.create_time),
53
- };
54
- };
55
- exports.toScheduleActivityLog = toScheduleActivityLog;
@@ -1,6 +0,0 @@
1
- import { ScheduleActivityLogPayload } from './scheduleActivityLogPayload';
2
- import { ScheduleActivityLogState } from './scheduleActivityLogState';
3
- export declare const initialState: ScheduleActivityLogState;
4
- export declare const updateScheduleActivityLogs: import("@reduxjs/toolkit").ActionCreatorWithPayload<ScheduleActivityLogPayload[], "scheduleActivityLog/updateScheduleActivityLogs">, clearAllScheduleActivityLogs: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"scheduleActivityLog/clearAllScheduleActivityLogs">;
5
- declare const _default: import("redux").Reducer<ScheduleActivityLogState>;
6
- export default _default;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.clearAllScheduleActivityLogs = exports.updateScheduleActivityLogs = exports.initialState = void 0;
5
- const toolkit_1 = require("@reduxjs/toolkit");
6
- const scheduleActivityLogPayload_1 = require("./scheduleActivityLogPayload");
7
- exports.initialState = {
8
- scheduleActivityLogById: {},
9
- };
10
- const scheduleActivityLog = (0, toolkit_1.createSlice)({
11
- name: 'scheduleActivityLog',
12
- initialState: exports.initialState,
13
- reducers: {
14
- updateScheduleActivityLogs(draft, action) {
15
- action.payload.forEach((scheduleActivityLogPayload) => {
16
- const scheduleActivityLog = (0, scheduleActivityLogPayload_1.toScheduleActivityLog)(scheduleActivityLogPayload);
17
- draft.scheduleActivityLogById[scheduleActivityLog.id] =
18
- scheduleActivityLog;
19
- });
20
- },
21
- clearAllScheduleActivityLogs(draft) {
22
- draft.scheduleActivityLogById = {};
23
- },
24
- },
25
- });
26
- _a = scheduleActivityLog.actions, exports.updateScheduleActivityLogs = _a.updateScheduleActivityLogs, exports.clearAllScheduleActivityLogs = _a.clearAllScheduleActivityLogs;
27
- exports.default = scheduleActivityLog.reducer;
@@ -1,4 +0,0 @@
1
- import { ID } from '../../commonStateTypes/common';
2
- import { ScheduleActivityLog, ScheduleActivityLogState } from './scheduleActivityLogState';
3
- export declare function getScheduleActivityLogsByIds(scheduleActivityLogState: ScheduleActivityLogState, scheduleActivityLogIds: ID[]): ScheduleActivityLog[];
4
- export declare function getScheduleActivityLogById(scheduleActivityLogState: ScheduleActivityLogState, scheduleActivityLogId: ID): ScheduleActivityLog | undefined;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getScheduleActivityLogsByIds = getScheduleActivityLogsByIds;
7
- exports.getScheduleActivityLogById = getScheduleActivityLogById;
8
- const get_1 = __importDefault(require("lodash/get"));
9
- function getScheduleActivityLogsByIds(scheduleActivityLogState, scheduleActivityLogIds) {
10
- const scheduleActivityLogs = scheduleActivityLogIds
11
- .map((scheduleActivityLogId) => getScheduleActivityLogById(scheduleActivityLogState, scheduleActivityLogId))
12
- .filter((value) => value != null);
13
- return scheduleActivityLogs;
14
- }
15
- function getScheduleActivityLogById(scheduleActivityLogState, scheduleActivityLogId) {
16
- return (0, get_1.default)(scheduleActivityLogState.scheduleActivityLogById, scheduleActivityLogId, undefined);
17
- }
@@ -1,51 +0,0 @@
1
- import { ID } from '../../commonStateTypes/common';
2
- import { ZeniDate } from '../../zeniDayJS';
3
- import { AccountBase } from '../account/accountState';
4
- import { ClassBase } from '../class/classState';
5
- import { AISummary } from '../transaction/stateTypes/transactionLine';
6
- import { User } from '../user/userState';
7
- import { VendorBase } from '../vendor/vendorState';
8
- /**
9
- * Phase 1 retains a small placeholder union; Phase 2 will extend with real
10
- * schedule event types (schedule.created, agent_je.detected, agent_je.drafted,
11
- * je.posted, schedule.user_update.<field>, etc.) once the backend contract is
12
- * finalised. Keeping the union narrow lets `toScheduleActivityLogEventType`
13
- * fall back to the raw string for unknown events without throwing.
14
- */
15
- export declare const ALL_SCHEDULE_ACTIVITY_LOG_EVENT_TYPE: readonly ["schedule.created", "schedule.user_update", "agent_je.detected", "agent_je.eligible", "agent_je.deleted", "agent_je.drafted", "je.posted", "transaction.sync_database"];
16
- export declare const toScheduleActivityLogEventType: (v: string) => "schedule.created" | "schedule.user_update" | "agent_je.detected" | "agent_je.eligible" | "agent_je.deleted" | "agent_je.drafted" | "je.posted" | "transaction.sync_database";
17
- export type ScheduleActivityLogEventType = ReturnType<typeof toScheduleActivityLogEventType>;
18
- /**
19
- * Per-line snapshot fields the backend may include in original/updated_line.
20
- * Phase 1 keeps this aligned with the transaction activity log shape so the
21
- * fetcher and reducer don't need any payload-specific work; Phase 3 will use
22
- * this structure to render the per-event detail cards.
23
- */
24
- export interface ScheduleActivityLogLine {
25
- account?: AccountBase;
26
- class?: ClassBase;
27
- description?: string;
28
- memo?: string;
29
- vendor?: VendorBase;
30
- }
31
- export interface ScheduleActivityLogTransaction {
32
- lineId: ID;
33
- originalLine: ScheduleActivityLogLine;
34
- updatedLine: ScheduleActivityLogLine;
35
- correlationId?: string;
36
- userId?: string;
37
- }
38
- export interface ScheduleActivityLogData {
39
- aiSummaries: AISummary[];
40
- transaction: ScheduleActivityLogTransaction;
41
- user?: User;
42
- }
43
- export interface ScheduleActivityLog {
44
- createTime: ZeniDate;
45
- data: ScheduleActivityLogData | null;
46
- eventType: ScheduleActivityLogEventType;
47
- id: ID;
48
- }
49
- export interface ScheduleActivityLogState {
50
- scheduleActivityLogById: Record<ID, ScheduleActivityLog>;
51
- }
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toScheduleActivityLogEventType = exports.ALL_SCHEDULE_ACTIVITY_LOG_EVENT_TYPE = void 0;
4
- const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
5
- /**
6
- * Phase 1 retains a small placeholder union; Phase 2 will extend with real
7
- * schedule event types (schedule.created, agent_je.detected, agent_je.drafted,
8
- * je.posted, schedule.user_update.<field>, etc.) once the backend contract is
9
- * finalised. Keeping the union narrow lets `toScheduleActivityLogEventType`
10
- * fall back to the raw string for unknown events without throwing.
11
- */
12
- exports.ALL_SCHEDULE_ACTIVITY_LOG_EVENT_TYPE = [
13
- 'schedule.created',
14
- 'schedule.user_update',
15
- 'agent_je.detected',
16
- 'agent_je.eligible',
17
- 'agent_je.deleted',
18
- 'agent_je.drafted',
19
- 'je.posted',
20
- 'transaction.sync_database',
21
- ];
22
- const toScheduleActivityLogEventType = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_SCHEDULE_ACTIVITY_LOG_EVENT_TYPE);
23
- exports.toScheduleActivityLogEventType = toScheduleActivityLogEventType;
@@ -1,49 +0,0 @@
1
- import { date } from '../../zeniDayJS';
2
- import { mapAccountBasePayloadToAccountBase, } from '../account/accountPayload';
3
- import { mapClassBasePayloadToClassBase, } from '../class/classPayload';
4
- import { toAISummary, } from '../transaction/payloadTypes/transactionLinePayload';
5
- import { mapVendorBasePayloadToVendorBase, } from '../vendor/vendorPayload';
6
- import { toScheduleActivityLogEventType, } from './scheduleActivityLogState';
7
- export const toScheduleActivityLogId = (correlationId, eventType, lineId) => `${correlationId}-${eventType}-${lineId ?? '1'}`;
8
- const toScheduleActivityLogLine = (line) => {
9
- const memo = line.schedule_memo ?? line.transaction_memo;
10
- return {
11
- account: line.account
12
- ? mapAccountBasePayloadToAccountBase(line.account)
13
- : undefined,
14
- class: line.accounting_class
15
- ? mapClassBasePayloadToClassBase(line.accounting_class)
16
- : undefined,
17
- vendor: line.vendor
18
- ? mapVendorBasePayloadToVendorBase(line.vendor)
19
- : undefined,
20
- memo,
21
- description: line.line_description,
22
- };
23
- };
24
- const toTransaction = (transaction, correlationId, userId) => {
25
- return {
26
- lineId: transaction.line_id,
27
- originalLine: toScheduleActivityLogLine(transaction.original_line),
28
- updatedLine: toScheduleActivityLogLine(transaction.updated_line),
29
- correlationId,
30
- userId,
31
- };
32
- };
33
- export const toScheduleActivityLogData = (data, correlationId) => {
34
- return {
35
- aiSummaries: (data.ai_summaries ?? []).map(toAISummary),
36
- transaction: toTransaction(data.transaction, correlationId, data.user_id),
37
- user: undefined,
38
- };
39
- };
40
- export const toScheduleActivityLog = (payload) => {
41
- return {
42
- id: toScheduleActivityLogId(payload.correlation_id, payload.event_type, payload.data?.transaction?.line_id),
43
- data: payload.data != null
44
- ? toScheduleActivityLogData(payload.data, payload.correlation_id)
45
- : null,
46
- eventType: toScheduleActivityLogEventType(payload.event_type),
47
- createTime: date(payload.create_time),
48
- };
49
- };
@@ -1,23 +0,0 @@
1
- import { createSlice } from '@reduxjs/toolkit';
2
- import { toScheduleActivityLog, } from './scheduleActivityLogPayload';
3
- export const initialState = {
4
- scheduleActivityLogById: {},
5
- };
6
- const scheduleActivityLog = createSlice({
7
- name: 'scheduleActivityLog',
8
- initialState,
9
- reducers: {
10
- updateScheduleActivityLogs(draft, action) {
11
- action.payload.forEach((scheduleActivityLogPayload) => {
12
- const scheduleActivityLog = toScheduleActivityLog(scheduleActivityLogPayload);
13
- draft.scheduleActivityLogById[scheduleActivityLog.id] =
14
- scheduleActivityLog;
15
- });
16
- },
17
- clearAllScheduleActivityLogs(draft) {
18
- draft.scheduleActivityLogById = {};
19
- },
20
- },
21
- });
22
- export const { updateScheduleActivityLogs, clearAllScheduleActivityLogs } = scheduleActivityLog.actions;
23
- export default scheduleActivityLog.reducer;
@@ -1,10 +0,0 @@
1
- import recordGet from 'lodash/get';
2
- export function getScheduleActivityLogsByIds(scheduleActivityLogState, scheduleActivityLogIds) {
3
- const scheduleActivityLogs = scheduleActivityLogIds
4
- .map((scheduleActivityLogId) => getScheduleActivityLogById(scheduleActivityLogState, scheduleActivityLogId))
5
- .filter((value) => value != null);
6
- return scheduleActivityLogs;
7
- }
8
- export function getScheduleActivityLogById(scheduleActivityLogState, scheduleActivityLogId) {
9
- return recordGet(scheduleActivityLogState.scheduleActivityLogById, scheduleActivityLogId, undefined);
10
- }
@@ -1,19 +0,0 @@
1
- import { stringToUnion } from '../../commonStateTypes/stringToUnion';
2
- /**
3
- * Phase 1 retains a small placeholder union; Phase 2 will extend with real
4
- * schedule event types (schedule.created, agent_je.detected, agent_je.drafted,
5
- * je.posted, schedule.user_update.<field>, etc.) once the backend contract is
6
- * finalised. Keeping the union narrow lets `toScheduleActivityLogEventType`
7
- * fall back to the raw string for unknown events without throwing.
8
- */
9
- export const ALL_SCHEDULE_ACTIVITY_LOG_EVENT_TYPE = [
10
- 'schedule.created',
11
- 'schedule.user_update',
12
- 'agent_je.detected',
13
- 'agent_je.eligible',
14
- 'agent_je.deleted',
15
- 'agent_je.drafted',
16
- 'je.posted',
17
- 'transaction.sync_database',
18
- ];
19
- export const toScheduleActivityLogEventType = (v) => stringToUnion(v, ALL_SCHEDULE_ACTIVITY_LOG_EVENT_TYPE);
@@ -1,43 +0,0 @@
1
- import { from, of } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { updateScheduleActivityLogs } from '../../entity/scheduleActivityLog/scheduleActivityLogReducer';
4
- import { updateAllUsers } from '../../entity/user/userReducer';
5
- import { createZeniAPIStatus, isSuccessResponse } from '../../responsePayload';
6
- import { fetchScheduleActivityLog, updateScheduleActivityLogViewFetchStatus, updateScheduleActivityLogViewOnSuccess, } from './scheduleActivityLogViewReducer';
7
- export const fetchScheduleActivityLogEpic = (actions$, _, zeniAPI) => actions$.pipe(filter(fetchScheduleActivityLog.match), switchMap((action) => {
8
- const { scheduleId } = action.payload;
9
- return zeniAPI
10
- .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${scheduleId}/activity`)
11
- .pipe(mergeMap((response) => {
12
- if (isSuccessResponse(response) &&
13
- response.data != null &&
14
- response.data.activity != null) {
15
- const updateActions = [];
16
- if (response.data.users != null &&
17
- response.data.users.length > 0) {
18
- updateActions.push(updateAllUsers({
19
- users: response.data.users,
20
- updateType: 'merge',
21
- }));
22
- }
23
- updateActions.push(updateScheduleActivityLogs(response.data.activity));
24
- updateActions.push(updateScheduleActivityLogViewOnSuccess({
25
- data: response.data.activity,
26
- scheduleId,
27
- }));
28
- return from(updateActions);
29
- }
30
- else {
31
- return of(updateScheduleActivityLogViewFetchStatus({
32
- fetchState: 'Error',
33
- error: response.status,
34
- scheduleId,
35
- }));
36
- }
37
- }), catchError((error) => of(updateScheduleActivityLogViewFetchStatus({
38
- scheduleId,
39
- fetchState: 'Error',
40
- error: createZeniAPIStatus('Unexpected Error', 'fetch schedule activity log REST API call errored out' +
41
- JSON.stringify(error)),
42
- }))));
43
- }));
@@ -1,47 +0,0 @@
1
- import { createSlice } from '@reduxjs/toolkit';
2
- import { toScheduleActivityLogId, } from '../../entity/scheduleActivityLog/scheduleActivityLogPayload';
3
- export const initialState = {
4
- scheduleActivityLogIdsByScheduleId: {},
5
- scheduleActivityLogFetchStateByScheduleId: {},
6
- };
7
- const scheduleActivityLogView = createSlice({
8
- name: 'scheduleActivityLogView',
9
- initialState,
10
- reducers: {
11
- fetchScheduleActivityLog: {
12
- prepare(scheduleId) {
13
- return {
14
- payload: { scheduleId },
15
- };
16
- },
17
- reducer(draft, action) {
18
- const { scheduleId } = action.payload;
19
- draft.scheduleActivityLogFetchStateByScheduleId[scheduleId] = {
20
- fetchState: 'In-Progress',
21
- error: undefined,
22
- };
23
- draft.scheduleActivityLogIdsByScheduleId[scheduleId] = [];
24
- },
25
- },
26
- updateScheduleActivityLogViewOnSuccess(draft, action) {
27
- const { data, scheduleId } = action.payload;
28
- draft.scheduleActivityLogFetchStateByScheduleId[scheduleId] = {
29
- fetchState: 'Completed',
30
- error: undefined,
31
- };
32
- draft.scheduleActivityLogIdsByScheduleId[scheduleId] = data.map((scheduleActivityLog) => toScheduleActivityLogId(scheduleActivityLog.correlation_id, scheduleActivityLog.event_type, scheduleActivityLog.data?.transaction?.line_id));
33
- },
34
- updateScheduleActivityLogViewFetchStatus(draft, action) {
35
- const { fetchState, scheduleId, error } = action.payload;
36
- draft.scheduleActivityLogFetchStateByScheduleId[scheduleId] = {
37
- fetchState,
38
- error,
39
- };
40
- },
41
- clearScheduleActivityLogView(draft) {
42
- Object.assign(draft, initialState);
43
- },
44
- },
45
- });
46
- export const { fetchScheduleActivityLog, updateScheduleActivityLogViewOnSuccess, clearScheduleActivityLogView, updateScheduleActivityLogViewFetchStatus, } = scheduleActivityLogView.actions;
47
- export default scheduleActivityLogView.reducer;
@@ -1,33 +0,0 @@
1
- import { createSelector } from '@reduxjs/toolkit';
2
- import { reduceFetchState } from '../../commonStateTypes/reduceFetchState';
3
- import { getScheduleActivityLogsByIds } from '../../entity/scheduleActivityLog/scheduleActivityLogSelector';
4
- export const getScheduleActivityLogView = createSelector((state) => state.scheduleActivityLogViewState, (state) => state.scheduleActivityLogState, (state) => state.userState, (_state, scheduleId) => scheduleId, (scheduleActivityLogViewState, scheduleActivityLogState, userState, scheduleId) => {
5
- const fetchStateAndError = scheduleActivityLogViewState
6
- .scheduleActivityLogFetchStateByScheduleId[scheduleId] ?? {
7
- fetchState: 'Not-Started',
8
- error: undefined,
9
- };
10
- const scheduleActivityLogIds = scheduleActivityLogViewState.scheduleActivityLogIdsByScheduleId[scheduleId] ?? [];
11
- const rawLogs = getScheduleActivityLogsByIds(scheduleActivityLogState, scheduleActivityLogIds);
12
- const scheduleActivityLogs = rawLogs.map((log) => {
13
- const userId = log.data?.transaction?.userId;
14
- if (userId == null || log.data == null) {
15
- return log;
16
- }
17
- const user = userState.userByUserId[userId];
18
- if (user == null) {
19
- return log;
20
- }
21
- return {
22
- ...log,
23
- data: {
24
- ...log.data,
25
- user,
26
- },
27
- };
28
- });
29
- return {
30
- ...reduceFetchState([fetchStateAndError]),
31
- scheduleActivityLogs,
32
- };
33
- });