@zeniai/client-epic-state 5.0.69-beta0RJ → 5.0.69-beta2RJ
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.
- package/lib/entity/scheduleActivityLog/scheduleActivityLogPayload.d.ts +51 -19
- package/lib/entity/scheduleActivityLog/scheduleActivityLogPayload.js +87 -37
- package/lib/entity/scheduleActivityLog/scheduleActivityLogState.d.ts +43 -32
- package/lib/entity/scheduleActivityLog/scheduleActivityLogState.js +30 -14
- package/lib/esm/entity/scheduleActivityLog/scheduleActivityLogPayload.js +87 -37
- package/lib/esm/entity/scheduleActivityLog/scheduleActivityLogState.js +30 -14
- package/lib/esm/view/scheduleActivityLogView/scheduleActivityLogViewReducer.js +4 -1
- package/lib/esm/view/scheduleActivityLogView/scheduleActivityLogViewSelector.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/view/scheduleActivityLogView/scheduleActivityLogViewReducer.js +4 -1
- package/lib/view/scheduleActivityLogView/scheduleActivityLogViewSelector.js +1 -1
- package/package.json +1 -1
|
@@ -1,36 +1,68 @@
|
|
|
1
1
|
import { AccountBasePayload } from '../account/accountPayload';
|
|
2
2
|
import { ClassBasePayload } from '../class/classPayload';
|
|
3
|
-
import { AISummaryPayload } from '../transaction/payloadTypes/transactionLinePayload';
|
|
4
3
|
import { VendorBasePayload } from '../vendor/vendorPayload';
|
|
5
4
|
import { ScheduleActivityLog, ScheduleActivityLogData } from './scheduleActivityLogState';
|
|
6
|
-
export interface
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export interface ScheduleActivityLogTransactionNodePayload {
|
|
6
|
+
attachment_count?: number;
|
|
7
|
+
creation_source?: string;
|
|
8
|
+
is_deleted?: boolean;
|
|
9
|
+
lines_count?: number;
|
|
10
|
+
sync_token?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ScheduleActivityLogLineDetailPayload {
|
|
13
|
+
account?: AccountBasePayload | null;
|
|
14
|
+
accounting_class?: ClassBasePayload | null;
|
|
15
|
+
billable_status?: string | null;
|
|
16
|
+
posting_type?: string | null;
|
|
17
|
+
vendor?: VendorBasePayload | null;
|
|
18
|
+
}
|
|
19
|
+
export interface ScheduleActivityLogLineNodePayload {
|
|
20
|
+
amount?: number;
|
|
21
|
+
categorization_status?: string;
|
|
9
22
|
line_description?: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
23
|
+
line_detail?: ScheduleActivityLogLineDetailPayload;
|
|
24
|
+
line_detail_type?: string;
|
|
25
|
+
line_id?: string;
|
|
26
|
+
line_type?: string;
|
|
27
|
+
linked_transactions?: unknown[];
|
|
28
|
+
}
|
|
29
|
+
export interface ScheduleActivityLogScheduleNodePayload {
|
|
30
|
+
balance?: number;
|
|
31
|
+
base_transaction_amount?: number;
|
|
32
|
+
base_transaction_id?: string;
|
|
33
|
+
je_schedule_id?: string;
|
|
34
|
+
je_schedule_type?: string;
|
|
35
|
+
period?: number;
|
|
36
|
+
status_code?: string;
|
|
37
|
+
vendor_id?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface ScheduleActivityLogAISummaryPayload {
|
|
40
|
+
confidence_score?: number;
|
|
41
|
+
reasoning?: string;
|
|
42
|
+
schedule_type?: string;
|
|
43
|
+
status_code?: string;
|
|
13
44
|
}
|
|
14
|
-
export interface
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
schedule_id?: string;
|
|
19
|
-
transaction_id?: string;
|
|
45
|
+
export interface ScheduleActivityLogInferenceParamPayload {
|
|
46
|
+
key: string;
|
|
47
|
+
value: string;
|
|
48
|
+
reasoning?: string;
|
|
20
49
|
}
|
|
21
50
|
export interface ScheduleActivityLogDataPayload {
|
|
22
|
-
|
|
23
|
-
|
|
51
|
+
ai_summaries?: ScheduleActivityLogAISummaryPayload[];
|
|
52
|
+
inference_params?: ScheduleActivityLogInferenceParamPayload[];
|
|
53
|
+
line_node?: ScheduleActivityLogLineNodePayload;
|
|
54
|
+
schedule_node?: ScheduleActivityLogScheduleNodePayload;
|
|
55
|
+
transaction_node?: ScheduleActivityLogTransactionNodePayload;
|
|
24
56
|
user_id?: string;
|
|
25
57
|
}
|
|
26
58
|
export interface ScheduleActivityLogPayload {
|
|
27
59
|
correlation_id: string;
|
|
28
60
|
create_time: string;
|
|
29
|
-
data: ScheduleActivityLogDataPayload | null;
|
|
30
61
|
event_type: string;
|
|
31
|
-
|
|
32
|
-
|
|
62
|
+
data?: ScheduleActivityLogDataPayload | null;
|
|
63
|
+
processing_time_ms?: number;
|
|
64
|
+
status_code?: string;
|
|
33
65
|
}
|
|
34
|
-
export declare const toScheduleActivityLogId: (correlationId: string, eventType: string,
|
|
66
|
+
export declare const toScheduleActivityLogId: (correlationId: string, eventType: string, createTime?: string) => string;
|
|
35
67
|
export declare const toScheduleActivityLogData: (data: ScheduleActivityLogDataPayload, correlationId: string, eventType?: string) => ScheduleActivityLogData;
|
|
36
68
|
export declare const toScheduleActivityLog: (payload: ScheduleActivityLogPayload) => ScheduleActivityLog;
|
|
@@ -4,14 +4,18 @@ exports.toScheduleActivityLog = exports.toScheduleActivityLogData = exports.toSc
|
|
|
4
4
|
const zeniDayJS_1 = require("../../zeniDayJS");
|
|
5
5
|
const accountPayload_1 = require("../account/accountPayload");
|
|
6
6
|
const classPayload_1 = require("../class/classPayload");
|
|
7
|
-
const transactionLinePayload_1 = require("../transaction/payloadTypes/transactionLinePayload");
|
|
8
7
|
const vendorPayload_1 = require("../vendor/vendorPayload");
|
|
9
8
|
const scheduleActivityLogState_1 = require("./scheduleActivityLogState");
|
|
10
|
-
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// ID generation
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
const toScheduleActivityLogId = (correlationId, eventType, createTime) => createTime != null
|
|
13
|
+
? `${correlationId}-${eventType}-${createTime}`
|
|
14
|
+
: `${correlationId}-${eventType}`;
|
|
11
15
|
exports.toScheduleActivityLogId = toScheduleActivityLogId;
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Deduped one-time warns
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
15
19
|
const warnedPayloadKeys = new Set();
|
|
16
20
|
const warnPayloadOnce = (key, message, payload) => {
|
|
17
21
|
if (warnedPayloadKeys.has(key)) {
|
|
@@ -20,63 +24,109 @@ const warnPayloadOnce = (key, message, payload) => {
|
|
|
20
24
|
warnedPayloadKeys.add(key);
|
|
21
25
|
console.warn(message, payload);
|
|
22
26
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// Mappers — payload → domain
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
const toTransactionNode = (payload) => {
|
|
31
|
+
if (payload == null) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
attachmentCount: payload.attachment_count,
|
|
36
|
+
creationSource: payload.creation_source,
|
|
37
|
+
isDeleted: payload.is_deleted,
|
|
38
|
+
linesCount: payload.lines_count,
|
|
39
|
+
syncToken: payload.sync_token,
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
const toLineNode = (payload) => {
|
|
43
|
+
if (payload == null) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const detail = payload.line_detail;
|
|
29
47
|
return {
|
|
30
|
-
|
|
31
|
-
|
|
48
|
+
amount: payload.amount,
|
|
49
|
+
categorizationStatus: payload.categorization_status,
|
|
50
|
+
lineDescription: payload.line_description,
|
|
51
|
+
lineId: payload.line_id,
|
|
52
|
+
account: detail?.account
|
|
53
|
+
? (0, accountPayload_1.mapAccountBasePayloadToAccountBase)(detail.account)
|
|
32
54
|
: undefined,
|
|
33
|
-
class:
|
|
34
|
-
? (0, classPayload_1.mapClassBasePayloadToClassBase)(
|
|
55
|
+
class: detail?.accounting_class
|
|
56
|
+
? (0, classPayload_1.mapClassBasePayloadToClassBase)(detail.accounting_class)
|
|
35
57
|
: undefined,
|
|
36
|
-
vendor:
|
|
37
|
-
? (0, vendorPayload_1.mapVendorBasePayloadToVendorBase)(
|
|
58
|
+
vendor: detail?.vendor
|
|
59
|
+
? (0, vendorPayload_1.mapVendorBasePayloadToVendorBase)(detail.vendor)
|
|
38
60
|
: undefined,
|
|
39
|
-
memo,
|
|
40
|
-
description: safe.line_description,
|
|
41
61
|
};
|
|
42
62
|
};
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
63
|
+
const toScheduleNode = (payload) => {
|
|
64
|
+
if (payload == null) {
|
|
45
65
|
return undefined;
|
|
46
66
|
}
|
|
47
|
-
if (transaction.original_line == null) {
|
|
48
|
-
warnPayloadOnce(`missingLine:${correlationId}:original_line`, '[scheduleActivityLog] missing line payload', { correlationId, side: 'original_line' });
|
|
49
|
-
}
|
|
50
|
-
if (transaction.updated_line == null) {
|
|
51
|
-
warnPayloadOnce(`missingLine:${correlationId}:updated_line`, '[scheduleActivityLog] missing line payload', { correlationId, side: 'updated_line' });
|
|
52
|
-
}
|
|
53
67
|
return {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
68
|
+
balance: payload.balance,
|
|
69
|
+
baseTransactionAmount: payload.base_transaction_amount,
|
|
70
|
+
baseTransactionId: payload.base_transaction_id,
|
|
71
|
+
jeScheduleId: payload.je_schedule_id,
|
|
72
|
+
jeScheduleType: payload.je_schedule_type,
|
|
73
|
+
period: payload.period,
|
|
74
|
+
statusCode: payload.status_code,
|
|
75
|
+
vendorId: payload.vendor_id,
|
|
59
76
|
};
|
|
60
77
|
};
|
|
78
|
+
const toAISummaries = (payload) => {
|
|
79
|
+
if (payload == null || payload.length === 0) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
return payload.map((item) => ({
|
|
83
|
+
confidenceScore: item.confidence_score,
|
|
84
|
+
reasoning: item.reasoning,
|
|
85
|
+
scheduleType: item.schedule_type,
|
|
86
|
+
statusCode: item.status_code,
|
|
87
|
+
}));
|
|
88
|
+
};
|
|
89
|
+
const toInferenceParams = (payload) => {
|
|
90
|
+
if (payload == null || payload.length === 0) {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
return payload.map((item) => ({
|
|
94
|
+
key: item.key,
|
|
95
|
+
reasoning: item.reasoning,
|
|
96
|
+
value: item.value,
|
|
97
|
+
}));
|
|
98
|
+
};
|
|
61
99
|
const toScheduleActivityLogData = (data, correlationId, eventType) => {
|
|
62
|
-
|
|
63
|
-
|
|
100
|
+
const hasAnyNode = data.transaction_node != null ||
|
|
101
|
+
data.line_node != null ||
|
|
102
|
+
data.schedule_node != null ||
|
|
103
|
+
data.ai_summaries != null ||
|
|
104
|
+
data.inference_params != null;
|
|
105
|
+
if (!hasAnyNode) {
|
|
106
|
+
warnPayloadOnce(`emptyData:${correlationId}`, '[scheduleActivityLog] data present but contains no known nodes', { correlationId, eventType });
|
|
64
107
|
}
|
|
65
108
|
return {
|
|
66
|
-
|
|
67
|
-
|
|
109
|
+
transactionNode: toTransactionNode(data.transaction_node),
|
|
110
|
+
lineNode: toLineNode(data.line_node),
|
|
111
|
+
scheduleNode: toScheduleNode(data.schedule_node),
|
|
112
|
+
aiSummaries: toAISummaries(data.ai_summaries),
|
|
113
|
+
inferenceParams: toInferenceParams(data.inference_params),
|
|
114
|
+
userId: data.user_id,
|
|
68
115
|
user: undefined,
|
|
69
116
|
};
|
|
70
117
|
};
|
|
71
118
|
exports.toScheduleActivityLogData = toScheduleActivityLogData;
|
|
72
119
|
const toScheduleActivityLog = (payload) => {
|
|
73
120
|
return {
|
|
74
|
-
id: (0, exports.toScheduleActivityLogId)(payload.correlation_id, payload.event_type, payload.
|
|
121
|
+
id: (0, exports.toScheduleActivityLogId)(payload.correlation_id, payload.event_type, payload.create_time),
|
|
122
|
+
correlationId: payload.correlation_id,
|
|
75
123
|
data: payload.data != null
|
|
76
124
|
? (0, exports.toScheduleActivityLogData)(payload.data, payload.correlation_id, payload.event_type)
|
|
77
125
|
: null,
|
|
78
126
|
eventType: (0, scheduleActivityLogState_1.toScheduleActivityLogEventType)(payload.event_type),
|
|
79
127
|
createTime: (0, zeniDayJS_1.date)(payload.create_time),
|
|
128
|
+
processingTimeMs: payload.processing_time_ms,
|
|
129
|
+
statusCode: payload.status_code,
|
|
80
130
|
};
|
|
81
131
|
};
|
|
82
132
|
exports.toScheduleActivityLog = toScheduleActivityLog;
|
|
@@ -2,54 +2,65 @@ import { ID } from '../../commonStateTypes/common';
|
|
|
2
2
|
import { ZeniDate } from '../../zeniDayJS';
|
|
3
3
|
import { AccountBase } from '../account/accountState';
|
|
4
4
|
import { ClassBase } from '../class/classState';
|
|
5
|
-
import { AISummary } from '../transaction/stateTypes/transactionLine';
|
|
6
5
|
import { User } from '../user/userState';
|
|
7
6
|
import { VendorBase } from '../vendor/vendorState';
|
|
8
|
-
|
|
9
|
-
|
|
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";
|
|
7
|
+
export declare const ALL_SCHEDULE_ACTIVITY_LOG_EVENT_TYPE: readonly ["transaction.schedule_processing_starts", "transaction.schedule_processing_completed", "schedule.line.processing_started", "schedule.draft_created", "schedule.ongoing_created", "schedule.user_update", "schedule.user_read", "schedule.candidature.prepaid_expense.success", "schedule.candidature.fixed_asset.success", "schedule.candidature.accrual_expense.success", "schedule.inference.failure", "schedule.inference.prepaid_expense.success", "schedule.inference.fixed_asset.success", "schedule.inference.accrual_expense.success", "monthly_journal_entry.posted", "monthly_journal_entry.posting_failed", "schedule.reconcile.cleanup.draft_deleted", "schedule.reconcile.cleanup.nondraft_tampered", "schedule.reconcile.ongoing_schedule.deleted", "schedule.reconcile.schedule.tampered", "schedule.line.pending_review.draft_deleted", "schedule.line.pending_review.ongoing_deleted", "schedule.line.pending_review.ongoing_tampered"];
|
|
8
|
+
export declare const toScheduleActivityLogEventType: (v: string) => "transaction.schedule_processing_starts" | "transaction.schedule_processing_completed" | "schedule.line.processing_started" | "schedule.draft_created" | "schedule.ongoing_created" | "schedule.user_update" | "schedule.user_read" | "schedule.candidature.prepaid_expense.success" | "schedule.candidature.fixed_asset.success" | "schedule.candidature.accrual_expense.success" | "schedule.inference.failure" | "schedule.inference.prepaid_expense.success" | "schedule.inference.fixed_asset.success" | "schedule.inference.accrual_expense.success" | "monthly_journal_entry.posted" | "monthly_journal_entry.posting_failed" | "schedule.reconcile.cleanup.draft_deleted" | "schedule.reconcile.cleanup.nondraft_tampered" | "schedule.reconcile.ongoing_schedule.deleted" | "schedule.reconcile.schedule.tampered" | "schedule.line.pending_review.draft_deleted" | "schedule.line.pending_review.ongoing_deleted" | "schedule.line.pending_review.ongoing_tampered";
|
|
17
9
|
export type ScheduleActivityLogEventType = ReturnType<typeof toScheduleActivityLogEventType>;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
export interface ScheduleActivityTransactionNode {
|
|
11
|
+
attachmentCount?: number;
|
|
12
|
+
creationSource?: string;
|
|
13
|
+
isDeleted?: boolean;
|
|
14
|
+
linesCount?: number;
|
|
15
|
+
syncToken?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface ScheduleActivityLineNode {
|
|
25
18
|
account?: AccountBase;
|
|
19
|
+
amount?: number;
|
|
20
|
+
categorizationStatus?: string;
|
|
26
21
|
class?: ClassBase;
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
lineDescription?: string;
|
|
23
|
+
lineId?: string;
|
|
29
24
|
vendor?: VendorBase;
|
|
30
25
|
}
|
|
31
|
-
export interface
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
export interface ScheduleActivityScheduleNode {
|
|
27
|
+
balance?: number;
|
|
28
|
+
baseTransactionAmount?: number;
|
|
29
|
+
baseTransactionId?: string;
|
|
30
|
+
jeScheduleId?: string;
|
|
31
|
+
jeScheduleType?: string;
|
|
32
|
+
period?: number;
|
|
33
|
+
statusCode?: string;
|
|
34
|
+
vendorId?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface ScheduleActivityAISummary {
|
|
37
|
+
confidenceScore?: number;
|
|
38
|
+
reasoning?: string;
|
|
39
|
+
scheduleType?: string;
|
|
40
|
+
statusCode?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ScheduleActivityInferenceParam {
|
|
43
|
+
key: string;
|
|
44
|
+
value: string;
|
|
45
|
+
reasoning?: string;
|
|
37
46
|
}
|
|
38
47
|
export interface ScheduleActivityLogData {
|
|
39
|
-
aiSummaries
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
*/
|
|
45
|
-
transaction?: ScheduleActivityLogTransaction;
|
|
48
|
+
aiSummaries?: ScheduleActivityAISummary[];
|
|
49
|
+
inferenceParams?: ScheduleActivityInferenceParam[];
|
|
50
|
+
lineNode?: ScheduleActivityLineNode;
|
|
51
|
+
scheduleNode?: ScheduleActivityScheduleNode;
|
|
52
|
+
transactionNode?: ScheduleActivityTransactionNode;
|
|
46
53
|
user?: User;
|
|
54
|
+
userId?: string;
|
|
47
55
|
}
|
|
48
56
|
export interface ScheduleActivityLog {
|
|
57
|
+
correlationId: string;
|
|
49
58
|
createTime: ZeniDate;
|
|
50
59
|
data: ScheduleActivityLogData | null;
|
|
51
60
|
eventType: ScheduleActivityLogEventType;
|
|
52
61
|
id: ID;
|
|
62
|
+
processingTimeMs?: number;
|
|
63
|
+
statusCode?: string;
|
|
53
64
|
}
|
|
54
65
|
export interface ScheduleActivityLogState {
|
|
55
66
|
scheduleActivityLogById: Record<ID, ScheduleActivityLog>;
|
|
@@ -2,22 +2,38 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toScheduleActivityLogEventType = exports.ALL_SCHEDULE_ACTIVITY_LOG_EVENT_TYPE = void 0;
|
|
4
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
5
|
exports.ALL_SCHEDULE_ACTIVITY_LOG_EVENT_TYPE = [
|
|
13
|
-
|
|
6
|
+
// Transaction processing
|
|
7
|
+
'transaction.schedule_processing_starts',
|
|
8
|
+
'transaction.schedule_processing_completed',
|
|
9
|
+
// Line processing
|
|
10
|
+
'schedule.line.processing_started',
|
|
11
|
+
// Schedule lifecycle
|
|
12
|
+
'schedule.draft_created',
|
|
13
|
+
'schedule.ongoing_created',
|
|
14
|
+
// Human actions
|
|
14
15
|
'schedule.user_update',
|
|
15
|
-
'
|
|
16
|
-
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
|
|
16
|
+
'schedule.user_read',
|
|
17
|
+
// Candidature / eligibility
|
|
18
|
+
'schedule.candidature.prepaid_expense.success',
|
|
19
|
+
'schedule.candidature.fixed_asset.success',
|
|
20
|
+
'schedule.candidature.accrual_expense.success',
|
|
21
|
+
// Inference
|
|
22
|
+
'schedule.inference.failure',
|
|
23
|
+
'schedule.inference.prepaid_expense.success',
|
|
24
|
+
'schedule.inference.fixed_asset.success',
|
|
25
|
+
'schedule.inference.accrual_expense.success',
|
|
26
|
+
// JE posting
|
|
27
|
+
'monthly_journal_entry.posted',
|
|
28
|
+
'monthly_journal_entry.posting_failed',
|
|
29
|
+
// Deletion and tampering
|
|
30
|
+
'schedule.reconcile.cleanup.draft_deleted',
|
|
31
|
+
'schedule.reconcile.cleanup.nondraft_tampered',
|
|
32
|
+
'schedule.reconcile.ongoing_schedule.deleted',
|
|
33
|
+
'schedule.reconcile.schedule.tampered',
|
|
34
|
+
'schedule.line.pending_review.draft_deleted',
|
|
35
|
+
'schedule.line.pending_review.ongoing_deleted',
|
|
36
|
+
'schedule.line.pending_review.ongoing_tampered',
|
|
21
37
|
];
|
|
22
38
|
const toScheduleActivityLogEventType = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_SCHEDULE_ACTIVITY_LOG_EVENT_TYPE);
|
|
23
39
|
exports.toScheduleActivityLogEventType = toScheduleActivityLogEventType;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { date } from '../../zeniDayJS';
|
|
2
2
|
import { mapAccountBasePayloadToAccountBase, } from '../account/accountPayload';
|
|
3
3
|
import { mapClassBasePayloadToClassBase, } from '../class/classPayload';
|
|
4
|
-
import { toAISummary, } from '../transaction/payloadTypes/transactionLinePayload';
|
|
5
4
|
import { mapVendorBasePayloadToVendorBase, } from '../vendor/vendorPayload';
|
|
6
5
|
import { toScheduleActivityLogEventType, } from './scheduleActivityLogState';
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// ID generation
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
export const toScheduleActivityLogId = (correlationId, eventType, createTime) => createTime != null
|
|
10
|
+
? `${correlationId}-${eventType}-${createTime}`
|
|
11
|
+
: `${correlationId}-${eventType}`;
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Deduped one-time warns
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
11
15
|
const warnedPayloadKeys = new Set();
|
|
12
16
|
const warnPayloadOnce = (key, message, payload) => {
|
|
13
17
|
if (warnedPayloadKeys.has(key)) {
|
|
@@ -16,61 +20,107 @@ const warnPayloadOnce = (key, message, payload) => {
|
|
|
16
20
|
warnedPayloadKeys.add(key);
|
|
17
21
|
console.warn(message, payload);
|
|
18
22
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// Mappers — payload → domain
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
const toTransactionNode = (payload) => {
|
|
27
|
+
if (payload == null) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
attachmentCount: payload.attachment_count,
|
|
32
|
+
creationSource: payload.creation_source,
|
|
33
|
+
isDeleted: payload.is_deleted,
|
|
34
|
+
linesCount: payload.lines_count,
|
|
35
|
+
syncToken: payload.sync_token,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
const toLineNode = (payload) => {
|
|
39
|
+
if (payload == null) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
const detail = payload.line_detail;
|
|
25
43
|
return {
|
|
26
|
-
|
|
27
|
-
|
|
44
|
+
amount: payload.amount,
|
|
45
|
+
categorizationStatus: payload.categorization_status,
|
|
46
|
+
lineDescription: payload.line_description,
|
|
47
|
+
lineId: payload.line_id,
|
|
48
|
+
account: detail?.account
|
|
49
|
+
? mapAccountBasePayloadToAccountBase(detail.account)
|
|
28
50
|
: undefined,
|
|
29
|
-
class:
|
|
30
|
-
? mapClassBasePayloadToClassBase(
|
|
51
|
+
class: detail?.accounting_class
|
|
52
|
+
? mapClassBasePayloadToClassBase(detail.accounting_class)
|
|
31
53
|
: undefined,
|
|
32
|
-
vendor:
|
|
33
|
-
? mapVendorBasePayloadToVendorBase(
|
|
54
|
+
vendor: detail?.vendor
|
|
55
|
+
? mapVendorBasePayloadToVendorBase(detail.vendor)
|
|
34
56
|
: undefined,
|
|
35
|
-
memo,
|
|
36
|
-
description: safe.line_description,
|
|
37
57
|
};
|
|
38
58
|
};
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
59
|
+
const toScheduleNode = (payload) => {
|
|
60
|
+
if (payload == null) {
|
|
41
61
|
return undefined;
|
|
42
62
|
}
|
|
43
|
-
if (transaction.original_line == null) {
|
|
44
|
-
warnPayloadOnce(`missingLine:${correlationId}:original_line`, '[scheduleActivityLog] missing line payload', { correlationId, side: 'original_line' });
|
|
45
|
-
}
|
|
46
|
-
if (transaction.updated_line == null) {
|
|
47
|
-
warnPayloadOnce(`missingLine:${correlationId}:updated_line`, '[scheduleActivityLog] missing line payload', { correlationId, side: 'updated_line' });
|
|
48
|
-
}
|
|
49
63
|
return {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
64
|
+
balance: payload.balance,
|
|
65
|
+
baseTransactionAmount: payload.base_transaction_amount,
|
|
66
|
+
baseTransactionId: payload.base_transaction_id,
|
|
67
|
+
jeScheduleId: payload.je_schedule_id,
|
|
68
|
+
jeScheduleType: payload.je_schedule_type,
|
|
69
|
+
period: payload.period,
|
|
70
|
+
statusCode: payload.status_code,
|
|
71
|
+
vendorId: payload.vendor_id,
|
|
55
72
|
};
|
|
56
73
|
};
|
|
74
|
+
const toAISummaries = (payload) => {
|
|
75
|
+
if (payload == null || payload.length === 0) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
return payload.map((item) => ({
|
|
79
|
+
confidenceScore: item.confidence_score,
|
|
80
|
+
reasoning: item.reasoning,
|
|
81
|
+
scheduleType: item.schedule_type,
|
|
82
|
+
statusCode: item.status_code,
|
|
83
|
+
}));
|
|
84
|
+
};
|
|
85
|
+
const toInferenceParams = (payload) => {
|
|
86
|
+
if (payload == null || payload.length === 0) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
return payload.map((item) => ({
|
|
90
|
+
key: item.key,
|
|
91
|
+
reasoning: item.reasoning,
|
|
92
|
+
value: item.value,
|
|
93
|
+
}));
|
|
94
|
+
};
|
|
57
95
|
export const toScheduleActivityLogData = (data, correlationId, eventType) => {
|
|
58
|
-
|
|
59
|
-
|
|
96
|
+
const hasAnyNode = data.transaction_node != null ||
|
|
97
|
+
data.line_node != null ||
|
|
98
|
+
data.schedule_node != null ||
|
|
99
|
+
data.ai_summaries != null ||
|
|
100
|
+
data.inference_params != null;
|
|
101
|
+
if (!hasAnyNode) {
|
|
102
|
+
warnPayloadOnce(`emptyData:${correlationId}`, '[scheduleActivityLog] data present but contains no known nodes', { correlationId, eventType });
|
|
60
103
|
}
|
|
61
104
|
return {
|
|
62
|
-
|
|
63
|
-
|
|
105
|
+
transactionNode: toTransactionNode(data.transaction_node),
|
|
106
|
+
lineNode: toLineNode(data.line_node),
|
|
107
|
+
scheduleNode: toScheduleNode(data.schedule_node),
|
|
108
|
+
aiSummaries: toAISummaries(data.ai_summaries),
|
|
109
|
+
inferenceParams: toInferenceParams(data.inference_params),
|
|
110
|
+
userId: data.user_id,
|
|
64
111
|
user: undefined,
|
|
65
112
|
};
|
|
66
113
|
};
|
|
67
114
|
export const toScheduleActivityLog = (payload) => {
|
|
68
115
|
return {
|
|
69
|
-
id: toScheduleActivityLogId(payload.correlation_id, payload.event_type, payload.
|
|
116
|
+
id: toScheduleActivityLogId(payload.correlation_id, payload.event_type, payload.create_time),
|
|
117
|
+
correlationId: payload.correlation_id,
|
|
70
118
|
data: payload.data != null
|
|
71
119
|
? toScheduleActivityLogData(payload.data, payload.correlation_id, payload.event_type)
|
|
72
120
|
: null,
|
|
73
121
|
eventType: toScheduleActivityLogEventType(payload.event_type),
|
|
74
122
|
createTime: date(payload.create_time),
|
|
123
|
+
processingTimeMs: payload.processing_time_ms,
|
|
124
|
+
statusCode: payload.status_code,
|
|
75
125
|
};
|
|
76
126
|
};
|
|
@@ -1,19 +1,35 @@
|
|
|
1
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
2
|
export const ALL_SCHEDULE_ACTIVITY_LOG_EVENT_TYPE = [
|
|
10
|
-
|
|
3
|
+
// Transaction processing
|
|
4
|
+
'transaction.schedule_processing_starts',
|
|
5
|
+
'transaction.schedule_processing_completed',
|
|
6
|
+
// Line processing
|
|
7
|
+
'schedule.line.processing_started',
|
|
8
|
+
// Schedule lifecycle
|
|
9
|
+
'schedule.draft_created',
|
|
10
|
+
'schedule.ongoing_created',
|
|
11
|
+
// Human actions
|
|
11
12
|
'schedule.user_update',
|
|
12
|
-
'
|
|
13
|
-
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
|
|
13
|
+
'schedule.user_read',
|
|
14
|
+
// Candidature / eligibility
|
|
15
|
+
'schedule.candidature.prepaid_expense.success',
|
|
16
|
+
'schedule.candidature.fixed_asset.success',
|
|
17
|
+
'schedule.candidature.accrual_expense.success',
|
|
18
|
+
// Inference
|
|
19
|
+
'schedule.inference.failure',
|
|
20
|
+
'schedule.inference.prepaid_expense.success',
|
|
21
|
+
'schedule.inference.fixed_asset.success',
|
|
22
|
+
'schedule.inference.accrual_expense.success',
|
|
23
|
+
// JE posting
|
|
24
|
+
'monthly_journal_entry.posted',
|
|
25
|
+
'monthly_journal_entry.posting_failed',
|
|
26
|
+
// Deletion and tampering
|
|
27
|
+
'schedule.reconcile.cleanup.draft_deleted',
|
|
28
|
+
'schedule.reconcile.cleanup.nondraft_tampered',
|
|
29
|
+
'schedule.reconcile.ongoing_schedule.deleted',
|
|
30
|
+
'schedule.reconcile.schedule.tampered',
|
|
31
|
+
'schedule.line.pending_review.draft_deleted',
|
|
32
|
+
'schedule.line.pending_review.ongoing_deleted',
|
|
33
|
+
'schedule.line.pending_review.ongoing_tampered',
|
|
18
34
|
];
|
|
19
35
|
export const toScheduleActivityLogEventType = (v) => stringToUnion(v, ALL_SCHEDULE_ACTIVITY_LOG_EVENT_TYPE);
|
|
@@ -29,7 +29,10 @@ const scheduleActivityLogView = createSlice({
|
|
|
29
29
|
fetchState: 'Completed',
|
|
30
30
|
error: undefined,
|
|
31
31
|
};
|
|
32
|
-
|
|
32
|
+
const ids = data.map((scheduleActivityLog) => toScheduleActivityLogId(scheduleActivityLog.correlation_id, scheduleActivityLog.event_type, scheduleActivityLog.create_time));
|
|
33
|
+
draft.scheduleActivityLogIdsByScheduleId[scheduleId] = [
|
|
34
|
+
...new Set(ids),
|
|
35
|
+
];
|
|
33
36
|
},
|
|
34
37
|
updateScheduleActivityLogViewFetchStatus(draft, action) {
|
|
35
38
|
const { fetchState, scheduleId, error } = action.payload;
|
|
@@ -10,7 +10,7 @@ export const getScheduleActivityLogView = createSelector((state) => state.schedu
|
|
|
10
10
|
const scheduleActivityLogIds = scheduleActivityLogViewState.scheduleActivityLogIdsByScheduleId[scheduleId] ?? [];
|
|
11
11
|
const rawLogs = getScheduleActivityLogsByIds(scheduleActivityLogState, scheduleActivityLogIds);
|
|
12
12
|
const scheduleActivityLogs = rawLogs.map((log) => {
|
|
13
|
-
const userId = log.data?.
|
|
13
|
+
const userId = log.data?.userId;
|
|
14
14
|
if (userId == null || log.data == null) {
|
|
15
15
|
return log;
|
|
16
16
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -930,6 +930,7 @@ export { BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS, BULK_UPLOAD_BAR_COMPLETE_HOLD_MS,
|
|
|
930
930
|
export { fetchTransactionActivityLog } from './view/transactionActivityLogView/transactionActivityLogViewReducer';
|
|
931
931
|
export { TransactionActivityLogViewSelectorView, getTransactionActivityLogView, } from './view/transactionActivityLogView/transactionActivityLogViewSelector';
|
|
932
932
|
export type { ScheduleActivityLog } from './entity/scheduleActivityLog/scheduleActivityLogState';
|
|
933
|
+
export type { ScheduleActivityAISummary, ScheduleActivityInferenceParam, ScheduleActivityLineNode, ScheduleActivityLogData, ScheduleActivityScheduleNode, ScheduleActivityTransactionNode, } from './entity/scheduleActivityLog/scheduleActivityLogState';
|
|
933
934
|
export { fetchScheduleActivityLog, clearScheduleActivityLogView, } from './view/scheduleActivityLogView/scheduleActivityLogViewReducer';
|
|
934
935
|
export { ScheduleActivityLogViewSelectorView, getScheduleActivityLogView, } from './view/scheduleActivityLogView/scheduleActivityLogViewSelector';
|
|
935
936
|
export { UserGroup } from './entity/userGroups/userGroupsState';
|
|
@@ -33,7 +33,10 @@ const scheduleActivityLogView = (0, toolkit_1.createSlice)({
|
|
|
33
33
|
fetchState: 'Completed',
|
|
34
34
|
error: undefined,
|
|
35
35
|
};
|
|
36
|
-
|
|
36
|
+
const ids = data.map((scheduleActivityLog) => (0, scheduleActivityLogPayload_1.toScheduleActivityLogId)(scheduleActivityLog.correlation_id, scheduleActivityLog.event_type, scheduleActivityLog.create_time));
|
|
37
|
+
draft.scheduleActivityLogIdsByScheduleId[scheduleId] = [
|
|
38
|
+
...new Set(ids),
|
|
39
|
+
];
|
|
37
40
|
},
|
|
38
41
|
updateScheduleActivityLogViewFetchStatus(draft, action) {
|
|
39
42
|
const { fetchState, scheduleId, error } = action.payload;
|
|
@@ -13,7 +13,7 @@ exports.getScheduleActivityLogView = (0, toolkit_1.createSelector)((state) => st
|
|
|
13
13
|
const scheduleActivityLogIds = scheduleActivityLogViewState.scheduleActivityLogIdsByScheduleId[scheduleId] ?? [];
|
|
14
14
|
const rawLogs = (0, scheduleActivityLogSelector_1.getScheduleActivityLogsByIds)(scheduleActivityLogState, scheduleActivityLogIds);
|
|
15
15
|
const scheduleActivityLogs = rawLogs.map((log) => {
|
|
16
|
-
const userId = log.data?.
|
|
16
|
+
const userId = log.data?.userId;
|
|
17
17
|
if (userId == null || log.data == null) {
|
|
18
18
|
return log;
|
|
19
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.0.69-
|
|
3
|
+
"version": "5.0.69-beta2RJ",
|
|
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",
|