@burdenoff/microfe-bigconsole 2026.1118.1 → 2026.1118.3

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.
@@ -0,0 +1,136 @@
1
+ import { KpiReconciliationItemsDocument as e, ReconcileKpiCardsDocument as t } from "../../../generated/wspace-operations.js";
2
+ import { useBigConsole as n } from "../../context/BigConsoleContext.js";
3
+ import "../../context/index.js";
4
+ import { createReconcileAgentTool as r } from "./reconcileAgentTool.js";
5
+ import { useEffect as i, useMemo as a, useRef as o } from "react";
6
+ import { useApolloClient as s } from "@apollo/client/react";
7
+ import { useAgentTools as c } from "@burdenoff/fe-libs/shared/agent-tools";
8
+ // src/bigconsole/components/reconcile/useReconcileAgentTool.ts
9
+ var l = (e) => ({
10
+ requiredWorkspaceAuth: !0,
11
+ requiredWorkspaceId: e,
12
+ queryDeduplication: !1
13
+ });
14
+ function u(e) {
15
+ return {
16
+ status: e.status,
17
+ direction: e.direction,
18
+ currency: e.currency,
19
+ period: e.period ? {
20
+ start: e.period.start,
21
+ end: e.period.end,
22
+ timezone: e.period.timezone
23
+ } : null,
24
+ left: e.left ? {
25
+ title: e.left.title,
26
+ total: e.left.total?.display ?? null,
27
+ records: e.left.recordCount,
28
+ tiesToCard: e.left.tieOut?.ties ?? null
29
+ } : null,
30
+ right: e.right ? {
31
+ title: e.right.title,
32
+ total: e.right.total?.display ?? null,
33
+ records: e.right.recordCount,
34
+ tiesToCard: e.right.tieOut?.ties ?? null
35
+ } : null,
36
+ gap: e.gap?.display ?? null,
37
+ explained: e.explained?.display ?? null,
38
+ unexplained: e.unexplained?.display ?? null,
39
+ groups: e.groups.map((e) => ({
40
+ group: e.group,
41
+ label: e.label,
42
+ total: e.total?.display ?? null,
43
+ amount: e.total?.amount ?? null,
44
+ items: e.itemCount
45
+ })),
46
+ limitations: e.limitations,
47
+ problems: e.problems.map((e) => ({
48
+ code: e.code,
49
+ side: e.side ?? null,
50
+ message: e.message
51
+ }))
52
+ };
53
+ }
54
+ function d(e) {
55
+ return {
56
+ status: e.status,
57
+ problems: e.problems.map((e) => ({
58
+ code: e.code,
59
+ side: e.side ?? null,
60
+ message: e.message
61
+ })),
62
+ group: e.group,
63
+ totalCount: e.totalCount,
64
+ offset: e.offset,
65
+ hasMore: e.hasMore,
66
+ items: e.items.map((e) => ({
67
+ key: e.key,
68
+ status: e.status,
69
+ amount: e.contribution?.display ?? null,
70
+ why: e.evidence
71
+ }))
72
+ };
73
+ }
74
+ function f(e) {
75
+ let t = (e) => ({
76
+ widgetId: e.widgetId,
77
+ keyField: e.keyField,
78
+ amountField: e.amountField,
79
+ dateField: e.dateField,
80
+ currency: e.currency,
81
+ refundEvidenceField: e.refundEvidenceField?.trim() || null,
82
+ recordsPath: e.recordsPath?.trim() || null
83
+ });
84
+ return {
85
+ left: t(e.left),
86
+ right: t(e.right),
87
+ periodStart: e.periodStart,
88
+ periodEnd: e.periodEnd,
89
+ timezone: e.timezone,
90
+ cutoffWindowDays: e.cutoffWindowDays
91
+ };
92
+ }
93
+ function p() {
94
+ let p = s(), { workspaceId: m } = n(), h = o({
95
+ client: p,
96
+ workspaceId: m
97
+ });
98
+ i(() => {
99
+ h.current = {
100
+ client: p,
101
+ workspaceId: m
102
+ };
103
+ });
104
+ let g = a(() => r(() => {
105
+ let { client: n, workspaceId: r } = h.current;
106
+ return {
107
+ async reconcile(e) {
108
+ let i = (await n.query({
109
+ query: t,
110
+ variables: { input: f(e) },
111
+ fetchPolicy: "network-only",
112
+ context: l(r)
113
+ })).data?.reconcileKpiCards;
114
+ if (!i) throw Error("The comparison returned no result.");
115
+ return u(i);
116
+ },
117
+ async items(t, i, a) {
118
+ let o = (await n.query({
119
+ query: e,
120
+ variables: {
121
+ input: f(t),
122
+ group: i,
123
+ first: a.first,
124
+ offset: a.offset
125
+ },
126
+ fetchPolicy: "network-only",
127
+ context: l(r)
128
+ })).data?.kpiReconciliationItems;
129
+ if (!o) throw Error("No records were returned.");
130
+ return d(o);
131
+ }
132
+ };
133
+ }), []);
134
+ c([g]);
135
+ }
136
+ export { p as useReconcileAgentTool };