@robosystems/client 0.2.48 → 0.3.0
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/extensions/InvestorClient.d.ts +91 -0
- package/extensions/InvestorClient.js +223 -0
- package/extensions/InvestorClient.ts +501 -0
- package/extensions/LedgerClient.d.ts +213 -165
- package/extensions/LedgerClient.js +315 -393
- package/extensions/LedgerClient.ts +887 -564
- package/extensions/ReportClient.d.ts +77 -115
- package/extensions/ReportClient.js +124 -211
- package/extensions/ReportClient.ts +298 -358
- package/extensions/config.js +1 -1
- package/extensions/config.ts +1 -1
- package/extensions/graphql/client.d.ts +46 -0
- package/extensions/graphql/client.js +75 -0
- package/extensions/graphql/client.ts +82 -0
- package/extensions/graphql/generated/graphql.d.ts +1786 -0
- package/extensions/graphql/generated/graphql.js +2671 -0
- package/extensions/graphql/generated/graphql.ts +4491 -0
- package/extensions/graphql/queries/investor/holdings.d.ts +8 -0
- package/extensions/graphql/queries/investor/holdings.js +36 -0
- package/extensions/graphql/queries/investor/holdings.ts +34 -0
- package/extensions/graphql/queries/investor/portfolio.d.ts +4 -0
- package/extensions/graphql/queries/investor/portfolio.js +21 -0
- package/extensions/graphql/queries/investor/portfolio.ts +19 -0
- package/extensions/graphql/queries/investor/portfolios.d.ts +4 -0
- package/extensions/graphql/queries/investor/portfolios.js +29 -0
- package/extensions/graphql/queries/investor/portfolios.ts +27 -0
- package/extensions/graphql/queries/investor/position.d.ts +4 -0
- package/extensions/graphql/queries/investor/position.js +33 -0
- package/extensions/graphql/queries/investor/position.ts +31 -0
- package/extensions/graphql/queries/investor/positions.d.ts +8 -0
- package/extensions/graphql/queries/investor/positions.js +57 -0
- package/extensions/graphql/queries/investor/positions.ts +55 -0
- package/extensions/graphql/queries/investor/securities.d.ts +8 -0
- package/extensions/graphql/queries/investor/securities.js +50 -0
- package/extensions/graphql/queries/investor/securities.ts +48 -0
- package/extensions/graphql/queries/investor/security.d.ts +4 -0
- package/extensions/graphql/queries/investor/security.js +26 -0
- package/extensions/graphql/queries/investor/security.ts +24 -0
- package/extensions/graphql/queries/ledger/accountRollups.d.ts +7 -0
- package/extensions/graphql/queries/ledger/accountRollups.js +36 -0
- package/extensions/graphql/queries/ledger/accountRollups.ts +34 -0
- package/extensions/graphql/queries/ledger/accountTree.d.ts +11 -0
- package/extensions/graphql/queries/ledger/accountTree.js +61 -0
- package/extensions/graphql/queries/ledger/accountTree.ts +59 -0
- package/extensions/graphql/queries/ledger/accounts.d.ts +8 -0
- package/extensions/graphql/queries/ledger/accounts.js +45 -0
- package/extensions/graphql/queries/ledger/accounts.ts +43 -0
- package/extensions/graphql/queries/ledger/closingBookStructures.d.ts +6 -0
- package/extensions/graphql/queries/ledger/closingBookStructures.js +27 -0
- package/extensions/graphql/queries/ledger/closingBookStructures.ts +25 -0
- package/extensions/graphql/queries/ledger/elements.d.ts +6 -0
- package/extensions/graphql/queries/ledger/elements.js +56 -0
- package/extensions/graphql/queries/ledger/elements.ts +54 -0
- package/extensions/graphql/queries/ledger/entities.d.ts +7 -0
- package/extensions/graphql/queries/ledger/entities.js +31 -0
- package/extensions/graphql/queries/ledger/entities.ts +29 -0
- package/extensions/graphql/queries/ledger/entity.d.ts +14 -0
- package/extensions/graphql/queries/ledger/entity.js +55 -0
- package/extensions/graphql/queries/ledger/entity.ts +54 -0
- package/extensions/graphql/queries/ledger/fiscalCalendar.d.ts +8 -0
- package/extensions/graphql/queries/ledger/fiscalCalendar.js +35 -0
- package/extensions/graphql/queries/ledger/fiscalCalendar.ts +33 -0
- package/extensions/graphql/queries/ledger/mappedTrialBalance.d.ts +9 -0
- package/extensions/graphql/queries/ledger/mappedTrialBalance.js +29 -0
- package/extensions/graphql/queries/ledger/mappedTrialBalance.ts +27 -0
- package/extensions/graphql/queries/ledger/mapping.d.ts +5 -0
- package/extensions/graphql/queries/ledger/mapping.js +35 -0
- package/extensions/graphql/queries/ledger/mapping.ts +33 -0
- package/extensions/graphql/queries/ledger/mappingCoverage.d.ts +5 -0
- package/extensions/graphql/queries/ledger/mappingCoverage.js +22 -0
- package/extensions/graphql/queries/ledger/mappingCoverage.ts +20 -0
- package/extensions/graphql/queries/ledger/mappings.d.ts +6 -0
- package/extensions/graphql/queries/ledger/mappings.js +23 -0
- package/extensions/graphql/queries/ledger/mappings.ts +21 -0
- package/extensions/graphql/queries/ledger/periodCloseStatus.d.ts +6 -0
- package/extensions/graphql/queries/ledger/periodCloseStatus.js +29 -0
- package/extensions/graphql/queries/ledger/periodCloseStatus.ts +27 -0
- package/extensions/graphql/queries/ledger/periodDrafts.d.ts +8 -0
- package/extensions/graphql/queries/ledger/periodDrafts.js +45 -0
- package/extensions/graphql/queries/ledger/periodDrafts.ts +43 -0
- package/extensions/graphql/queries/ledger/publishList.d.ts +5 -0
- package/extensions/graphql/queries/ledger/publishList.js +29 -0
- package/extensions/graphql/queries/ledger/publishList.ts +27 -0
- package/extensions/graphql/queries/ledger/publishLists.d.ts +5 -0
- package/extensions/graphql/queries/ledger/publishLists.js +29 -0
- package/extensions/graphql/queries/ledger/publishLists.ts +27 -0
- package/extensions/graphql/queries/ledger/report.d.ts +5 -0
- package/extensions/graphql/queries/ledger/report.js +40 -0
- package/extensions/graphql/queries/ledger/report.ts +38 -0
- package/extensions/graphql/queries/ledger/reportingTaxonomy.d.ts +6 -0
- package/extensions/graphql/queries/ledger/reportingTaxonomy.js +27 -0
- package/extensions/graphql/queries/ledger/reportingTaxonomy.ts +25 -0
- package/extensions/graphql/queries/ledger/reports.d.ts +8 -0
- package/extensions/graphql/queries/ledger/reports.js +45 -0
- package/extensions/graphql/queries/ledger/reports.ts +43 -0
- package/extensions/graphql/queries/ledger/scheduleFacts.d.ts +7 -0
- package/extensions/graphql/queries/ledger/scheduleFacts.js +24 -0
- package/extensions/graphql/queries/ledger/scheduleFacts.ts +22 -0
- package/extensions/graphql/queries/ledger/schedules.d.ts +6 -0
- package/extensions/graphql/queries/ledger/schedules.js +24 -0
- package/extensions/graphql/queries/ledger/schedules.ts +22 -0
- package/extensions/graphql/queries/ledger/statement.d.ts +9 -0
- package/extensions/graphql/queries/ledger/statement.js +43 -0
- package/extensions/graphql/queries/ledger/statement.ts +41 -0
- package/extensions/graphql/queries/ledger/structures.d.ts +5 -0
- package/extensions/graphql/queries/ledger/structures.js +22 -0
- package/extensions/graphql/queries/ledger/structures.ts +20 -0
- package/extensions/graphql/queries/ledger/summary.d.ts +7 -0
- package/extensions/graphql/queries/ledger/summary.js +25 -0
- package/extensions/graphql/queries/ledger/summary.ts +23 -0
- package/extensions/graphql/queries/ledger/taxonomies.d.ts +5 -0
- package/extensions/graphql/queries/ledger/taxonomies.js +28 -0
- package/extensions/graphql/queries/ledger/taxonomies.ts +26 -0
- package/extensions/graphql/queries/ledger/transaction.d.ts +6 -0
- package/extensions/graphql/queries/ledger/transaction.js +49 -0
- package/extensions/graphql/queries/ledger/transaction.ts +47 -0
- package/extensions/graphql/queries/ledger/transactions.d.ts +7 -0
- package/extensions/graphql/queries/ledger/transactions.js +49 -0
- package/extensions/graphql/queries/ledger/transactions.ts +47 -0
- package/extensions/graphql/queries/ledger/trialBalance.d.ts +7 -0
- package/extensions/graphql/queries/ledger/trialBalance.js +28 -0
- package/extensions/graphql/queries/ledger/trialBalance.ts +26 -0
- package/extensions/graphql/queries/ledger/unmappedElements.d.ts +8 -0
- package/extensions/graphql/queries/ledger/unmappedElements.js +29 -0
- package/extensions/graphql/queries/ledger/unmappedElements.ts +27 -0
- package/extensions/hooks.d.ts +1 -1
- package/extensions/index.d.ts +5 -1
- package/extensions/index.js +13 -1
- package/extensions/index.ts +14 -0
- package/index.ts +2 -2
- package/package.json +14 -5
- package/sdk/index.d.ts +2 -2
- package/sdk/index.js +38 -65
- package/sdk/index.ts +2 -2
- package/sdk/sdk.gen.d.ts +101 -220
- package/sdk/sdk.gen.js +251 -445
- package/sdk/sdk.gen.ts +216 -409
- package/sdk/types.gen.d.ts +4586 -7045
- package/sdk/types.gen.ts +4702 -7334
- package/sdk.gen.d.ts +101 -220
- package/sdk.gen.js +251 -445
- package/sdk.gen.ts +216 -409
- package/types.gen.d.ts +4586 -7045
- package/types.gen.ts +4702 -7334
- package/extensions/AgentClient.test.ts +0 -403
- package/extensions/LedgerClient.test.ts +0 -1138
- package/extensions/OperationClient.test.ts +0 -365
- package/extensions/QueryClient.test.ts +0 -432
- package/extensions/ReportClient.test.ts +0 -828
- package/extensions/SSEClient.test.ts +0 -375
- package/extensions/config.test.ts +0 -199
- package/extensions/hooks.test.ts +0 -373
- package/extensions/index.test.ts +0 -420
- package/sdk-extensions/AgentClient.d.ts +0 -82
- package/sdk-extensions/AgentClient.js +0 -218
- package/sdk-extensions/AgentClient.test.ts +0 -403
- package/sdk-extensions/AgentClient.ts +0 -321
- package/sdk-extensions/LedgerClient.d.ts +0 -242
- package/sdk-extensions/LedgerClient.js +0 -496
- package/sdk-extensions/LedgerClient.test.ts +0 -1138
- package/sdk-extensions/LedgerClient.ts +0 -800
- package/sdk-extensions/OperationClient.d.ts +0 -65
- package/sdk-extensions/OperationClient.js +0 -251
- package/sdk-extensions/OperationClient.test.ts +0 -365
- package/sdk-extensions/OperationClient.ts +0 -324
- package/sdk-extensions/QueryClient.d.ts +0 -52
- package/sdk-extensions/QueryClient.js +0 -313
- package/sdk-extensions/QueryClient.test.ts +0 -432
- package/sdk-extensions/QueryClient.ts +0 -420
- package/sdk-extensions/README.md +0 -901
- package/sdk-extensions/ReportClient.d.ts +0 -151
- package/sdk-extensions/ReportClient.js +0 -278
- package/sdk-extensions/ReportClient.test.ts +0 -828
- package/sdk-extensions/ReportClient.ts +0 -486
- package/sdk-extensions/SSEClient.d.ts +0 -62
- package/sdk-extensions/SSEClient.js +0 -154
- package/sdk-extensions/SSEClient.test.ts +0 -375
- package/sdk-extensions/SSEClient.ts +0 -210
- package/sdk-extensions/config.d.ts +0 -57
- package/sdk-extensions/config.js +0 -152
- package/sdk-extensions/config.test.ts +0 -199
- package/sdk-extensions/config.ts +0 -175
- package/sdk-extensions/hooks.d.ts +0 -110
- package/sdk-extensions/hooks.js +0 -384
- package/sdk-extensions/hooks.test.ts +0 -373
- package/sdk-extensions/hooks.ts +0 -459
- package/sdk-extensions/index.d.ts +0 -63
- package/sdk-extensions/index.js +0 -164
- package/sdk-extensions/index.test.ts +0 -420
- package/sdk-extensions/index.ts +0 -203
|
@@ -1,496 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.LedgerClient = void 0;
|
|
5
|
-
/**
|
|
6
|
-
* Ledger Client for RoboSystems API
|
|
7
|
-
*
|
|
8
|
-
* High-level client for all ledger concerns: chart of accounts, transactions,
|
|
9
|
-
* trial balance, taxonomy, mappings, and AI auto-mapping. This is the
|
|
10
|
-
* operational backbone — reports consume these as inputs.
|
|
11
|
-
*/
|
|
12
|
-
const sdk_gen_1 = require("../sdk/sdk.gen");
|
|
13
|
-
// ── Client ──────────────────────────────────────────────────────────────
|
|
14
|
-
class LedgerClient {
|
|
15
|
-
constructor(config) {
|
|
16
|
-
this.config = config;
|
|
17
|
-
}
|
|
18
|
-
// ── Entity ──────────────────────────────────────────────────────────
|
|
19
|
-
/**
|
|
20
|
-
* Get the entity (company/organization) for this graph.
|
|
21
|
-
*/
|
|
22
|
-
async getEntity(graphId) {
|
|
23
|
-
const response = await (0, sdk_gen_1.getLedgerEntity)({
|
|
24
|
-
path: { graph_id: graphId },
|
|
25
|
-
});
|
|
26
|
-
if (response.response.status === 404)
|
|
27
|
-
return null;
|
|
28
|
-
if (response.error) {
|
|
29
|
-
throw new Error(`Get entity failed: ${JSON.stringify(response.error)}`);
|
|
30
|
-
}
|
|
31
|
-
const data = response.data;
|
|
32
|
-
return {
|
|
33
|
-
id: data.id,
|
|
34
|
-
name: data.name,
|
|
35
|
-
legalName: data.legal_name ?? null,
|
|
36
|
-
entityType: data.entity_type ?? null,
|
|
37
|
-
industry: data.industry ?? null,
|
|
38
|
-
status: data.status ?? null,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
// ── Accounts (Chart of Accounts) ───────────────────────────────────
|
|
42
|
-
/**
|
|
43
|
-
* List accounts (flat).
|
|
44
|
-
*/
|
|
45
|
-
async listAccounts(graphId) {
|
|
46
|
-
const response = await (0, sdk_gen_1.listLedgerAccounts)({
|
|
47
|
-
path: { graph_id: graphId },
|
|
48
|
-
});
|
|
49
|
-
if (response.error) {
|
|
50
|
-
throw new Error(`List accounts failed: ${JSON.stringify(response.error)}`);
|
|
51
|
-
}
|
|
52
|
-
return response.data;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Get the account tree (hierarchical).
|
|
56
|
-
*/
|
|
57
|
-
async getAccountTree(graphId) {
|
|
58
|
-
const response = await (0, sdk_gen_1.getLedgerAccountTree)({
|
|
59
|
-
path: { graph_id: graphId },
|
|
60
|
-
});
|
|
61
|
-
if (response.error) {
|
|
62
|
-
throw new Error(`Get account tree failed: ${JSON.stringify(response.error)}`);
|
|
63
|
-
}
|
|
64
|
-
return response.data;
|
|
65
|
-
}
|
|
66
|
-
// ── Transactions ────────────────────────────────────────────────────
|
|
67
|
-
/**
|
|
68
|
-
* List transactions with optional date filters.
|
|
69
|
-
*/
|
|
70
|
-
async listTransactions(graphId, options) {
|
|
71
|
-
const response = await (0, sdk_gen_1.listLedgerTransactions)({
|
|
72
|
-
path: { graph_id: graphId },
|
|
73
|
-
query: {
|
|
74
|
-
start_date: options?.startDate,
|
|
75
|
-
end_date: options?.endDate,
|
|
76
|
-
limit: options?.limit,
|
|
77
|
-
offset: options?.offset,
|
|
78
|
-
},
|
|
79
|
-
});
|
|
80
|
-
if (response.error) {
|
|
81
|
-
throw new Error(`List transactions failed: ${JSON.stringify(response.error)}`);
|
|
82
|
-
}
|
|
83
|
-
return response.data;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Get transaction detail with entries and line items.
|
|
87
|
-
*/
|
|
88
|
-
async getTransaction(graphId, transactionId) {
|
|
89
|
-
const response = await (0, sdk_gen_1.getLedgerTransaction)({
|
|
90
|
-
path: { graph_id: graphId, transaction_id: transactionId },
|
|
91
|
-
});
|
|
92
|
-
if (response.error) {
|
|
93
|
-
throw new Error(`Get transaction failed: ${JSON.stringify(response.error)}`);
|
|
94
|
-
}
|
|
95
|
-
return response.data;
|
|
96
|
-
}
|
|
97
|
-
// ── Trial Balance ──────────────────────────────────────────────────
|
|
98
|
-
/**
|
|
99
|
-
* Get trial balance (CoA-level debits/credits).
|
|
100
|
-
*/
|
|
101
|
-
async getTrialBalance(graphId, options) {
|
|
102
|
-
const response = await (0, sdk_gen_1.getLedgerTrialBalance)({
|
|
103
|
-
path: { graph_id: graphId },
|
|
104
|
-
query: {
|
|
105
|
-
start_date: options?.startDate,
|
|
106
|
-
end_date: options?.endDate,
|
|
107
|
-
},
|
|
108
|
-
});
|
|
109
|
-
if (response.error) {
|
|
110
|
-
throw new Error(`Get trial balance failed: ${JSON.stringify(response.error)}`);
|
|
111
|
-
}
|
|
112
|
-
return response.data;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Get mapped trial balance (CoA rolled up to GAAP concepts).
|
|
116
|
-
*/
|
|
117
|
-
async getMappedTrialBalance(graphId, options) {
|
|
118
|
-
const response = await (0, sdk_gen_1.getMappedTrialBalance)({
|
|
119
|
-
path: { graph_id: graphId },
|
|
120
|
-
query: {
|
|
121
|
-
mapping_id: options?.mappingId,
|
|
122
|
-
start_date: options?.startDate,
|
|
123
|
-
end_date: options?.endDate,
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
if (response.error) {
|
|
127
|
-
throw new Error(`Get mapped trial balance failed: ${JSON.stringify(response.error)}`);
|
|
128
|
-
}
|
|
129
|
-
return response.data;
|
|
130
|
-
}
|
|
131
|
-
// ── Summary ────────────────────────────────────────────────────────
|
|
132
|
-
/**
|
|
133
|
-
* Get ledger summary (account count, transaction count, date range).
|
|
134
|
-
*/
|
|
135
|
-
async getSummary(graphId) {
|
|
136
|
-
const response = await (0, sdk_gen_1.getLedgerSummary)({
|
|
137
|
-
path: { graph_id: graphId },
|
|
138
|
-
});
|
|
139
|
-
if (response.error) {
|
|
140
|
-
throw new Error(`Get summary failed: ${JSON.stringify(response.error)}`);
|
|
141
|
-
}
|
|
142
|
-
return response.data;
|
|
143
|
-
}
|
|
144
|
-
// ── Taxonomy ────────────────────────────────────────────────────────
|
|
145
|
-
/**
|
|
146
|
-
* Get the reporting taxonomy (US GAAP seed).
|
|
147
|
-
*/
|
|
148
|
-
async getReportingTaxonomy(graphId) {
|
|
149
|
-
const response = await (0, sdk_gen_1.getReportingTaxonomy)({
|
|
150
|
-
path: { graph_id: graphId },
|
|
151
|
-
});
|
|
152
|
-
if (response.error) {
|
|
153
|
-
throw new Error(`Get reporting taxonomy failed: ${JSON.stringify(response.error)}`);
|
|
154
|
-
}
|
|
155
|
-
return response.data;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* List reporting structures (IS, BS, CF) for a taxonomy.
|
|
159
|
-
*/
|
|
160
|
-
async listStructures(graphId, taxonomyId) {
|
|
161
|
-
const response = await (0, sdk_gen_1.listStructures)({
|
|
162
|
-
path: { graph_id: graphId },
|
|
163
|
-
query: taxonomyId ? { taxonomy_id: taxonomyId } : undefined,
|
|
164
|
-
});
|
|
165
|
-
if (response.error) {
|
|
166
|
-
throw new Error(`List structures failed: ${JSON.stringify(response.error)}`);
|
|
167
|
-
}
|
|
168
|
-
const data = response.data;
|
|
169
|
-
return (data.structures ?? []).map((s) => ({
|
|
170
|
-
id: s.id,
|
|
171
|
-
name: s.name,
|
|
172
|
-
structureType: s.structure_type,
|
|
173
|
-
}));
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* List elements (CoA accounts, GAAP concepts, etc.).
|
|
177
|
-
*/
|
|
178
|
-
async listElements(graphId, options) {
|
|
179
|
-
const response = await (0, sdk_gen_1.listElements)({
|
|
180
|
-
path: { graph_id: graphId },
|
|
181
|
-
query: {
|
|
182
|
-
taxonomy_id: options?.taxonomyId,
|
|
183
|
-
source: options?.source,
|
|
184
|
-
classification: options?.classification,
|
|
185
|
-
is_abstract: options?.isAbstract,
|
|
186
|
-
limit: options?.limit,
|
|
187
|
-
offset: options?.offset,
|
|
188
|
-
},
|
|
189
|
-
});
|
|
190
|
-
if (response.error) {
|
|
191
|
-
throw new Error(`List elements failed: ${JSON.stringify(response.error)}`);
|
|
192
|
-
}
|
|
193
|
-
return response.data;
|
|
194
|
-
}
|
|
195
|
-
// ── Mappings ────────────────────────────────────────────────────────
|
|
196
|
-
/**
|
|
197
|
-
* Create a new CoA→GAAP mapping structure.
|
|
198
|
-
* Returns the created mapping info.
|
|
199
|
-
*/
|
|
200
|
-
async createMappingStructure(graphId, options) {
|
|
201
|
-
const response = await (0, sdk_gen_1.createStructure)({
|
|
202
|
-
path: { graph_id: graphId },
|
|
203
|
-
body: {
|
|
204
|
-
name: options?.name ?? 'CoA to Reporting',
|
|
205
|
-
description: options?.description ?? 'Map Chart of Accounts to US GAAP reporting concepts',
|
|
206
|
-
structure_type: 'coa_mapping',
|
|
207
|
-
taxonomy_id: options?.taxonomyId ?? 'tax_usgaap_reporting',
|
|
208
|
-
},
|
|
209
|
-
});
|
|
210
|
-
if (response.error) {
|
|
211
|
-
throw new Error(`Create mapping structure failed: ${JSON.stringify(response.error)}`);
|
|
212
|
-
}
|
|
213
|
-
const data = response.data;
|
|
214
|
-
return {
|
|
215
|
-
id: data.id,
|
|
216
|
-
name: data.name,
|
|
217
|
-
description: data.description ?? null,
|
|
218
|
-
structureType: data.structure_type,
|
|
219
|
-
taxonomyId: data.taxonomy_id,
|
|
220
|
-
isActive: data.is_active ?? true,
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* List available CoA→GAAP mapping structures.
|
|
225
|
-
*/
|
|
226
|
-
async listMappings(graphId) {
|
|
227
|
-
const response = await (0, sdk_gen_1.listMappings)({
|
|
228
|
-
path: { graph_id: graphId },
|
|
229
|
-
});
|
|
230
|
-
if (response.error) {
|
|
231
|
-
throw new Error(`List mappings failed: ${JSON.stringify(response.error)}`);
|
|
232
|
-
}
|
|
233
|
-
const data = response.data;
|
|
234
|
-
return (data.structures ?? []).map((s) => ({
|
|
235
|
-
id: s.id,
|
|
236
|
-
name: s.name,
|
|
237
|
-
description: s.description ?? null,
|
|
238
|
-
structureType: s.structure_type,
|
|
239
|
-
taxonomyId: s.taxonomy_id,
|
|
240
|
-
isActive: s.is_active ?? true,
|
|
241
|
-
}));
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Get mapping detail — all associations with element names.
|
|
245
|
-
*/
|
|
246
|
-
async getMappingDetail(graphId, mappingId) {
|
|
247
|
-
const response = await (0, sdk_gen_1.getMappingDetail)({
|
|
248
|
-
path: { graph_id: graphId, mapping_id: mappingId },
|
|
249
|
-
});
|
|
250
|
-
if (response.error) {
|
|
251
|
-
throw new Error(`Get mapping detail failed: ${JSON.stringify(response.error)}`);
|
|
252
|
-
}
|
|
253
|
-
return response.data;
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Get mapping coverage — how many CoA elements are mapped.
|
|
257
|
-
*/
|
|
258
|
-
async getMappingCoverage(graphId, mappingId) {
|
|
259
|
-
const response = await (0, sdk_gen_1.getMappingCoverage)({
|
|
260
|
-
path: { graph_id: graphId, mapping_id: mappingId },
|
|
261
|
-
});
|
|
262
|
-
if (response.error) {
|
|
263
|
-
throw new Error(`Get mapping coverage failed: ${JSON.stringify(response.error)}`);
|
|
264
|
-
}
|
|
265
|
-
const data = response.data;
|
|
266
|
-
return {
|
|
267
|
-
totalCoaElements: data.total_coa_elements ?? 0,
|
|
268
|
-
mappedCount: data.mapped_count ?? 0,
|
|
269
|
-
unmappedCount: data.unmapped_count ?? 0,
|
|
270
|
-
coveragePercent: data.coverage_percent ?? 0,
|
|
271
|
-
highConfidence: data.high_confidence ?? 0,
|
|
272
|
-
mediumConfidence: data.medium_confidence ?? 0,
|
|
273
|
-
lowConfidence: data.low_confidence ?? 0,
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Create a manual mapping association (CoA element → GAAP element).
|
|
278
|
-
*/
|
|
279
|
-
async createMapping(graphId, mappingId, fromElementId, toElementId, confidence) {
|
|
280
|
-
const response = await (0, sdk_gen_1.createMappingAssociation)({
|
|
281
|
-
path: { graph_id: graphId, mapping_id: mappingId },
|
|
282
|
-
body: {
|
|
283
|
-
from_element_id: fromElementId,
|
|
284
|
-
to_element_id: toElementId,
|
|
285
|
-
confidence: confidence ?? 1.0,
|
|
286
|
-
},
|
|
287
|
-
});
|
|
288
|
-
if (response.error) {
|
|
289
|
-
throw new Error(`Create mapping failed: ${JSON.stringify(response.error)}`);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Delete a mapping association.
|
|
294
|
-
*/
|
|
295
|
-
async deleteMapping(graphId, mappingId, associationId) {
|
|
296
|
-
const response = await (0, sdk_gen_1.deleteMappingAssociation)({
|
|
297
|
-
path: { graph_id: graphId, mapping_id: mappingId, association_id: associationId },
|
|
298
|
-
});
|
|
299
|
-
if (response.error) {
|
|
300
|
-
throw new Error(`Delete mapping failed: ${JSON.stringify(response.error)}`);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Trigger AI auto-mapping (MappingAgent).
|
|
305
|
-
* Returns immediately — the agent runs in the background.
|
|
306
|
-
*/
|
|
307
|
-
async autoMap(graphId, mappingId) {
|
|
308
|
-
const response = await (0, sdk_gen_1.autoMapElements)({
|
|
309
|
-
path: { graph_id: graphId, mapping_id: mappingId },
|
|
310
|
-
});
|
|
311
|
-
if (response.error) {
|
|
312
|
-
throw new Error(`Auto-map failed: ${JSON.stringify(response.error)}`);
|
|
313
|
-
}
|
|
314
|
-
const data = response.data;
|
|
315
|
-
return {
|
|
316
|
-
operationId: data?.operation_id,
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
// ── Schedules ──────────────────────────────────────────────────────
|
|
320
|
-
/**
|
|
321
|
-
* Create a schedule with pre-generated monthly facts.
|
|
322
|
-
*/
|
|
323
|
-
async createSchedule(graphId, options) {
|
|
324
|
-
const body = {
|
|
325
|
-
name: options.name,
|
|
326
|
-
element_ids: options.elementIds,
|
|
327
|
-
period_start: options.periodStart,
|
|
328
|
-
period_end: options.periodEnd,
|
|
329
|
-
monthly_amount: options.monthlyAmount,
|
|
330
|
-
entry_template: {
|
|
331
|
-
debit_element_id: options.entryTemplate.debitElementId,
|
|
332
|
-
credit_element_id: options.entryTemplate.creditElementId,
|
|
333
|
-
entry_type: options.entryTemplate.entryType,
|
|
334
|
-
memo_template: options.entryTemplate.memoTemplate,
|
|
335
|
-
},
|
|
336
|
-
taxonomy_id: options.taxonomyId,
|
|
337
|
-
schedule_metadata: options.scheduleMetadata
|
|
338
|
-
? {
|
|
339
|
-
method: options.scheduleMetadata.method,
|
|
340
|
-
original_amount: options.scheduleMetadata.originalAmount,
|
|
341
|
-
residual_value: options.scheduleMetadata.residualValue,
|
|
342
|
-
useful_life_months: options.scheduleMetadata.usefulLifeMonths,
|
|
343
|
-
asset_element_id: options.scheduleMetadata.assetElementId,
|
|
344
|
-
}
|
|
345
|
-
: undefined,
|
|
346
|
-
};
|
|
347
|
-
const response = await (0, sdk_gen_1.createSchedule)({
|
|
348
|
-
path: { graph_id: graphId },
|
|
349
|
-
body,
|
|
350
|
-
});
|
|
351
|
-
if (response.error) {
|
|
352
|
-
throw new Error(`Create schedule failed: ${JSON.stringify(response.error)}`);
|
|
353
|
-
}
|
|
354
|
-
const data = response.data;
|
|
355
|
-
return {
|
|
356
|
-
structureId: data.structure_id,
|
|
357
|
-
name: data.name,
|
|
358
|
-
taxonomyId: data.taxonomy_id,
|
|
359
|
-
totalPeriods: data.total_periods,
|
|
360
|
-
totalFacts: data.total_facts,
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
/**
|
|
364
|
-
* List all schedules for a graph.
|
|
365
|
-
*/
|
|
366
|
-
async listSchedules(graphId) {
|
|
367
|
-
const response = await (0, sdk_gen_1.listSchedules)({
|
|
368
|
-
path: { graph_id: graphId },
|
|
369
|
-
});
|
|
370
|
-
if (response.error) {
|
|
371
|
-
throw new Error(`List schedules failed: ${JSON.stringify(response.error)}`);
|
|
372
|
-
}
|
|
373
|
-
const data = response.data;
|
|
374
|
-
return (data.schedules ?? []).map((s) => ({
|
|
375
|
-
structureId: s.structure_id,
|
|
376
|
-
name: s.name,
|
|
377
|
-
taxonomyName: s.taxonomy_name,
|
|
378
|
-
entryTemplate: s.entry_template ?? null,
|
|
379
|
-
scheduleMetadata: s.schedule_metadata ?? null,
|
|
380
|
-
totalPeriods: s.total_periods,
|
|
381
|
-
periodsWithEntries: s.periods_with_entries,
|
|
382
|
-
}));
|
|
383
|
-
}
|
|
384
|
-
/**
|
|
385
|
-
* Get facts for a schedule, optionally filtered by period.
|
|
386
|
-
*/
|
|
387
|
-
async getScheduleFacts(graphId, structureId, periodStart, periodEnd) {
|
|
388
|
-
const response = await (0, sdk_gen_1.getScheduleFacts)({
|
|
389
|
-
path: { graph_id: graphId, structure_id: structureId },
|
|
390
|
-
query: {
|
|
391
|
-
period_start: periodStart ?? null,
|
|
392
|
-
period_end: periodEnd ?? null,
|
|
393
|
-
},
|
|
394
|
-
});
|
|
395
|
-
if (response.error) {
|
|
396
|
-
throw new Error(`Get schedule facts failed: ${JSON.stringify(response.error)}`);
|
|
397
|
-
}
|
|
398
|
-
const data = response.data;
|
|
399
|
-
return (data.facts ?? []).map((f) => ({
|
|
400
|
-
elementId: f.element_id,
|
|
401
|
-
elementName: f.element_name,
|
|
402
|
-
value: f.value,
|
|
403
|
-
periodStart: f.period_start,
|
|
404
|
-
periodEnd: f.period_end,
|
|
405
|
-
}));
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Get close status for all schedules in a fiscal period.
|
|
409
|
-
*/
|
|
410
|
-
async getPeriodCloseStatus(graphId, periodStart, periodEnd) {
|
|
411
|
-
const response = await (0, sdk_gen_1.getPeriodCloseStatus)({
|
|
412
|
-
path: { graph_id: graphId },
|
|
413
|
-
query: { period_start: periodStart, period_end: periodEnd },
|
|
414
|
-
});
|
|
415
|
-
if (response.error) {
|
|
416
|
-
throw new Error(`Get period close status failed: ${JSON.stringify(response.error)}`);
|
|
417
|
-
}
|
|
418
|
-
const data = response.data;
|
|
419
|
-
return {
|
|
420
|
-
fiscalPeriodStart: data.fiscal_period_start,
|
|
421
|
-
fiscalPeriodEnd: data.fiscal_period_end,
|
|
422
|
-
periodStatus: data.period_status,
|
|
423
|
-
schedules: (data.schedules ?? []).map((s) => ({
|
|
424
|
-
structureId: s.structure_id,
|
|
425
|
-
structureName: s.structure_name,
|
|
426
|
-
amount: s.amount,
|
|
427
|
-
status: s.status,
|
|
428
|
-
entryId: s.entry_id ?? null,
|
|
429
|
-
})),
|
|
430
|
-
totalDraft: data.total_draft,
|
|
431
|
-
totalPosted: data.total_posted,
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* Create a draft closing entry from a schedule's facts for a period.
|
|
436
|
-
*/
|
|
437
|
-
async createClosingEntry(graphId, structureId, postingDate, periodStart, periodEnd, memo) {
|
|
438
|
-
const body = {
|
|
439
|
-
posting_date: postingDate,
|
|
440
|
-
period_start: periodStart,
|
|
441
|
-
period_end: periodEnd,
|
|
442
|
-
memo: memo ?? undefined,
|
|
443
|
-
};
|
|
444
|
-
const response = await (0, sdk_gen_1.createClosingEntry)({
|
|
445
|
-
path: { graph_id: graphId, structure_id: structureId },
|
|
446
|
-
body,
|
|
447
|
-
});
|
|
448
|
-
if (response.error) {
|
|
449
|
-
throw new Error(`Create closing entry failed: ${JSON.stringify(response.error)}`);
|
|
450
|
-
}
|
|
451
|
-
const data = response.data;
|
|
452
|
-
return {
|
|
453
|
-
entryId: data.entry_id,
|
|
454
|
-
status: data.status,
|
|
455
|
-
postingDate: data.posting_date,
|
|
456
|
-
memo: data.memo,
|
|
457
|
-
debitElementId: data.debit_element_id,
|
|
458
|
-
creditElementId: data.credit_element_id,
|
|
459
|
-
amount: data.amount,
|
|
460
|
-
};
|
|
461
|
-
}
|
|
462
|
-
// ── Closing Book ─────────────────────────────────────────────────────
|
|
463
|
-
/**
|
|
464
|
-
* Get all closing book structure categories for the sidebar.
|
|
465
|
-
* Returns statements, account rollups, schedules, trial balance,
|
|
466
|
-
* and period close grouped into categories.
|
|
467
|
-
*/
|
|
468
|
-
async getClosingBookStructures(graphId) {
|
|
469
|
-
const response = await (0, sdk_gen_1.getClosingBookStructures)({
|
|
470
|
-
path: { graph_id: graphId },
|
|
471
|
-
});
|
|
472
|
-
if (response.error) {
|
|
473
|
-
throw new Error(`Get closing book structures failed: ${JSON.stringify(response.error)}`);
|
|
474
|
-
}
|
|
475
|
-
return response.data;
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* Get account rollups — CoA accounts grouped by reporting element with balances.
|
|
479
|
-
* Shows how company-specific accounts roll up to standardized reporting lines.
|
|
480
|
-
*/
|
|
481
|
-
async getAccountRollups(graphId, options) {
|
|
482
|
-
const response = await (0, sdk_gen_1.getAccountRollups)({
|
|
483
|
-
path: { graph_id: graphId },
|
|
484
|
-
query: {
|
|
485
|
-
mapping_id: options?.mappingId,
|
|
486
|
-
start_date: options?.startDate,
|
|
487
|
-
end_date: options?.endDate,
|
|
488
|
-
},
|
|
489
|
-
});
|
|
490
|
-
if (response.error) {
|
|
491
|
-
throw new Error(`Get account rollups failed: ${JSON.stringify(response.error)}`);
|
|
492
|
-
}
|
|
493
|
-
return response.data;
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
exports.LedgerClient = LedgerClient;
|