@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,84 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
aiGenerated: boolean;
|
|
12
|
-
createdAt: string;
|
|
13
|
-
lastGenerated: string | null;
|
|
14
|
-
structures: Structure[];
|
|
15
|
-
/** Entity name (source company for shared reports, own entity for native) */
|
|
16
|
-
entityName: string | null;
|
|
17
|
-
/** Non-null when this report was shared from another graph */
|
|
18
|
-
sourceGraphId: string | null;
|
|
19
|
-
sourceReportId: string | null;
|
|
20
|
-
sharedAt: string | null;
|
|
21
|
-
}
|
|
22
|
-
import type { Structure } from './LedgerClient';
|
|
23
|
-
export type { Structure } from './LedgerClient';
|
|
24
|
-
export interface StatementPeriod {
|
|
25
|
-
start: string;
|
|
26
|
-
end: string;
|
|
27
|
-
label: string;
|
|
28
|
-
}
|
|
29
|
-
export interface StatementRow {
|
|
30
|
-
elementId: string;
|
|
31
|
-
elementQname: string;
|
|
32
|
-
elementName: string;
|
|
33
|
-
classification: string;
|
|
34
|
-
values: (number | null)[];
|
|
35
|
-
isSubtotal: boolean;
|
|
36
|
-
depth: number;
|
|
37
|
-
}
|
|
38
|
-
export interface StatementData {
|
|
39
|
-
reportId: string;
|
|
40
|
-
structureId: string;
|
|
41
|
-
structureName: string;
|
|
42
|
-
structureType: string;
|
|
43
|
-
periods: StatementPeriod[];
|
|
44
|
-
rows: StatementRow[];
|
|
45
|
-
validation: {
|
|
46
|
-
passed: boolean;
|
|
47
|
-
checks: string[];
|
|
48
|
-
failures: string[];
|
|
49
|
-
warnings: string[];
|
|
50
|
-
} | null;
|
|
51
|
-
unmappedCount: number;
|
|
52
|
-
}
|
|
53
|
-
export interface ShareResult {
|
|
54
|
-
reportId: string;
|
|
55
|
-
results: Array<{
|
|
56
|
-
targetGraphId: string;
|
|
57
|
-
status: 'shared' | 'error';
|
|
58
|
-
error: string | null;
|
|
59
|
-
factCount: number;
|
|
60
|
-
}>;
|
|
61
|
-
}
|
|
62
|
-
export interface PublishList {
|
|
63
|
-
id: string;
|
|
64
|
-
name: string;
|
|
65
|
-
description: string | null;
|
|
66
|
-
memberCount: number;
|
|
67
|
-
createdBy: string;
|
|
68
|
-
createdAt: string;
|
|
69
|
-
updatedAt: string;
|
|
70
|
-
}
|
|
71
|
-
export interface PublishListDetail extends PublishList {
|
|
72
|
-
members: PublishListMember[];
|
|
73
|
-
}
|
|
74
|
-
export interface PublishListMember {
|
|
75
|
-
id: string;
|
|
76
|
-
targetGraphId: string;
|
|
77
|
-
targetGraphName: string | null;
|
|
78
|
-
targetOrgName: string | null;
|
|
79
|
-
addedBy: string;
|
|
80
|
-
addedAt: string;
|
|
81
|
-
}
|
|
1
|
+
import type { OperationEnvelope } from '../types.gen';
|
|
2
|
+
import { type GetLedgerPublishListQuery, type GetLedgerReportQuery, type GetLedgerStatementQuery, type ListLedgerPublishListsQuery, type ListLedgerReportsQuery } from './graphql/generated/graphql';
|
|
3
|
+
export type Report = NonNullable<GetLedgerReportQuery['report']>;
|
|
4
|
+
export type ReportListItem = NonNullable<ListLedgerReportsQuery['reports']>['reports'][number];
|
|
5
|
+
export type StatementData = NonNullable<GetLedgerStatementQuery['statement']>;
|
|
6
|
+
export type StatementPeriod = StatementData['periods'][number];
|
|
7
|
+
export type StatementRow = StatementData['rows'][number];
|
|
8
|
+
export type PublishList = NonNullable<ListLedgerPublishListsQuery['publishLists']>['publishLists'][number];
|
|
9
|
+
export type PublishListDetail = NonNullable<GetLedgerPublishListQuery['publishList']>;
|
|
10
|
+
export type PublishListMember = PublishListDetail['members'][number];
|
|
82
11
|
export interface PeriodSpecInput {
|
|
83
12
|
start: string;
|
|
84
13
|
end: string;
|
|
@@ -95,57 +24,90 @@ export interface CreateReportOptions {
|
|
|
95
24
|
/** When set, overrides periodStart/periodEnd/comparative with N explicit periods. */
|
|
96
25
|
periods?: PeriodSpecInput[];
|
|
97
26
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Envelope around a report operation. `status === "completed"` means the
|
|
29
|
+
* backend produced the report synchronously — `result` contains the
|
|
30
|
+
* freshly-created report shape (same fields as `ReportListItem`), so
|
|
31
|
+
* consumers can read `result?.id` immediately. For pending/failed
|
|
32
|
+
* dispatches, `result` is null and consumers should subscribe to
|
|
33
|
+
* `/v1/operations/{operationId}/stream` for progress.
|
|
34
|
+
*
|
|
35
|
+
* The loose `{ id; name; ... }` shape here intentionally mirrors the
|
|
36
|
+
* GraphQL `report` field without pulling in every nullable child relation
|
|
37
|
+
* — `create_report` and `regenerate_report` return a freshly-generated
|
|
38
|
+
* row, not a fully-resolved GraphQL projection.
|
|
39
|
+
*/
|
|
40
|
+
export interface ReportOperationAck {
|
|
41
|
+
operationId: string;
|
|
42
|
+
status: OperationEnvelope['status'];
|
|
106
43
|
/**
|
|
107
|
-
*
|
|
44
|
+
* Synchronous command result. Populated for `status === "completed"`
|
|
45
|
+
* dispatches where the backend produced the report inline.
|
|
108
46
|
*/
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
47
|
+
result: Record<string, unknown> | null;
|
|
48
|
+
}
|
|
49
|
+
interface ReportClientConfig {
|
|
50
|
+
baseUrl: string;
|
|
51
|
+
credentials?: 'include' | 'same-origin' | 'omit';
|
|
52
|
+
headers?: Record<string, string>;
|
|
53
|
+
token?: string;
|
|
54
|
+
}
|
|
55
|
+
export declare class ReportClient {
|
|
56
|
+
private config;
|
|
57
|
+
private gql;
|
|
58
|
+
constructor(config: ReportClientConfig);
|
|
114
59
|
/**
|
|
115
|
-
*
|
|
60
|
+
* Kick off report creation (async). Use the returned `operationId` to
|
|
61
|
+
* subscribe to progress via SSE, then call `get()` once finished.
|
|
116
62
|
*/
|
|
117
|
-
|
|
63
|
+
create(graphId: string, options: CreateReportOptions): Promise<ReportOperationAck>;
|
|
64
|
+
/** List all reports for a graph (includes received shared reports). */
|
|
65
|
+
list(graphId: string): Promise<ReportListItem[]>;
|
|
66
|
+
/** Get a single report with its period list + available structures. */
|
|
67
|
+
get(graphId: string, reportId: string): Promise<Report | null>;
|
|
118
68
|
/**
|
|
119
69
|
* Render a financial statement — facts viewed through a structure.
|
|
120
70
|
*
|
|
121
71
|
* @param structureType - income_statement, balance_sheet, cash_flow_statement
|
|
122
72
|
*/
|
|
123
|
-
statement(graphId: string, reportId: string, structureType: string): Promise<StatementData>;
|
|
73
|
+
statement(graphId: string, reportId: string, structureType: string): Promise<StatementData | null>;
|
|
124
74
|
/**
|
|
125
|
-
* Regenerate
|
|
126
|
-
|
|
127
|
-
regenerate(graphId: string, reportId: string, periodStart: string, periodEnd: string): Promise<Report>;
|
|
128
|
-
/**
|
|
129
|
-
* Delete a report and its generated facts.
|
|
75
|
+
* Regenerate an existing report (async). Returns an operation id;
|
|
76
|
+
* subscribe via SSE for progress.
|
|
130
77
|
*/
|
|
78
|
+
regenerate(graphId: string, reportId: string, periodStart?: string, periodEnd?: string): Promise<ReportOperationAck>;
|
|
79
|
+
/** Delete a report and its generated facts. */
|
|
131
80
|
delete(graphId: string, reportId: string): Promise<void>;
|
|
132
81
|
/**
|
|
133
|
-
* Share a published report to
|
|
82
|
+
* Share a published report to every member of a publish list (async).
|
|
83
|
+
* Each target graph receives a snapshot copy of the report's facts.
|
|
134
84
|
*/
|
|
135
|
-
share(graphId: string, reportId: string, publishListId: string): Promise<
|
|
85
|
+
share(graphId: string, reportId: string, publishListId: string): Promise<ReportOperationAck>;
|
|
136
86
|
/** Check if a report was received via sharing (vs locally created). */
|
|
137
87
|
isSharedReport(report: Report): boolean;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
88
|
+
/** List publish lists with pagination. */
|
|
89
|
+
listPublishLists(graphId: string, options?: {
|
|
90
|
+
limit?: number;
|
|
91
|
+
offset?: number;
|
|
92
|
+
}): Promise<PublishList[]>;
|
|
93
|
+
/** Create a new publish list. */
|
|
94
|
+
createPublishList(graphId: string, name: string, description?: string): Promise<Record<string, unknown>>;
|
|
95
|
+
/** Get a single publish list with its full member list. */
|
|
96
|
+
getPublishList(graphId: string, listId: string): Promise<PublishListDetail | null>;
|
|
97
|
+
/** Update a publish list's name or description. */
|
|
141
98
|
updatePublishList(graphId: string, listId: string, updates: {
|
|
142
99
|
name?: string;
|
|
143
|
-
description?: string;
|
|
144
|
-
}): Promise<
|
|
100
|
+
description?: string | null;
|
|
101
|
+
}): Promise<Record<string, unknown>>;
|
|
102
|
+
/** Delete a publish list. */
|
|
145
103
|
deletePublishList(graphId: string, listId: string): Promise<void>;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
104
|
+
/** Add target graphs as members of a publish list. */
|
|
105
|
+
addMembers(graphId: string, listId: string, targetGraphIds: string[]): Promise<Record<string, unknown>>;
|
|
106
|
+
/** Remove a single member from a publish list. */
|
|
107
|
+
removeMember(graphId: string, listId: string, memberId: string): Promise<{
|
|
108
|
+
deleted: boolean;
|
|
109
|
+
}>;
|
|
110
|
+
private gqlQuery;
|
|
111
|
+
private callOperation;
|
|
151
112
|
}
|
|
113
|
+
export {};
|
|
@@ -2,21 +2,19 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.ReportClient = void 0;
|
|
5
|
-
|
|
6
|
-
* Report Client for RoboSystems API
|
|
7
|
-
*
|
|
8
|
-
* High-level client for report lifecycle: create, list, view statements,
|
|
9
|
-
* regenerate, share, and delete. Reports consume ledger data (mappings,
|
|
10
|
-
* trial balance) as inputs — use LedgerClient for those concerns.
|
|
11
|
-
*/
|
|
5
|
+
const graphql_request_1 = require("graphql-request");
|
|
12
6
|
const sdk_gen_1 = require("../sdk.gen");
|
|
13
|
-
|
|
7
|
+
const client_1 = require("./graphql/client");
|
|
8
|
+
const graphql_1 = require("./graphql/generated/graphql");
|
|
14
9
|
class ReportClient {
|
|
15
10
|
constructor(config) {
|
|
16
11
|
this.config = config;
|
|
12
|
+
this.gql = new client_1.GraphQLClientCache(config);
|
|
17
13
|
}
|
|
14
|
+
// ── Reports ─────────────────────────────────────────────────────────
|
|
18
15
|
/**
|
|
19
|
-
*
|
|
16
|
+
* Kick off report creation (async). Use the returned `operationId` to
|
|
17
|
+
* subscribe to progress via SSE, then call `get()` once finished.
|
|
20
18
|
*/
|
|
21
19
|
async create(graphId, options) {
|
|
22
20
|
const body = {
|
|
@@ -31,39 +29,21 @@ class ReportClient {
|
|
|
31
29
|
if (options.periods && options.periods.length > 0) {
|
|
32
30
|
body.periods = options.periods;
|
|
33
31
|
}
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
return this._toReport(response.data);
|
|
32
|
+
const envelope = await this.callOperation('Create report', (0, sdk_gen_1.opCreateReport)({ path: { graph_id: graphId }, body }));
|
|
33
|
+
return {
|
|
34
|
+
operationId: envelope.operationId,
|
|
35
|
+
status: envelope.status,
|
|
36
|
+
result: envelope.result ?? null,
|
|
37
|
+
};
|
|
42
38
|
}
|
|
43
|
-
/**
|
|
44
|
-
* List all reports for a graph (includes received shared reports).
|
|
45
|
-
*/
|
|
39
|
+
/** List all reports for a graph (includes received shared reports). */
|
|
46
40
|
async list(graphId) {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
if (response.error) {
|
|
51
|
-
throw new Error(`List reports failed: ${JSON.stringify(response.error)}`);
|
|
52
|
-
}
|
|
53
|
-
const data = response.data;
|
|
54
|
-
return (data.reports ?? []).map((r) => this._toReport(r));
|
|
41
|
+
const list = await this.gqlQuery(graphId, graphql_1.ListLedgerReportsDocument, undefined, 'List reports', (data) => data.reports);
|
|
42
|
+
return list?.reports ?? [];
|
|
55
43
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Get a report with its available structures.
|
|
58
|
-
*/
|
|
44
|
+
/** Get a single report with its period list + available structures. */
|
|
59
45
|
async get(graphId, reportId) {
|
|
60
|
-
|
|
61
|
-
path: { graph_id: graphId, report_id: reportId },
|
|
62
|
-
});
|
|
63
|
-
if (response.error) {
|
|
64
|
-
throw new Error(`Get report failed: ${JSON.stringify(response.error)}`);
|
|
65
|
-
}
|
|
66
|
-
return this._toReport(response.data);
|
|
46
|
+
return this.gqlQuery(graphId, graphql_1.GetLedgerReportDocument, { reportId }, 'Get report', (data) => data.report);
|
|
67
47
|
}
|
|
68
48
|
/**
|
|
69
49
|
* Render a financial statement — facts viewed through a structure.
|
|
@@ -71,87 +51,50 @@ class ReportClient {
|
|
|
71
51
|
* @param structureType - income_statement, balance_sheet, cash_flow_statement
|
|
72
52
|
*/
|
|
73
53
|
async statement(graphId, reportId, structureType) {
|
|
74
|
-
|
|
75
|
-
path: { graph_id: graphId, report_id: reportId, structure_type: structureType },
|
|
76
|
-
});
|
|
77
|
-
if (response.error) {
|
|
78
|
-
throw new Error(`Get statement failed: ${JSON.stringify(response.error)}`);
|
|
79
|
-
}
|
|
80
|
-
const data = response.data;
|
|
81
|
-
return {
|
|
82
|
-
reportId: data.report_id,
|
|
83
|
-
structureId: data.structure_id,
|
|
84
|
-
structureName: data.structure_name,
|
|
85
|
-
structureType: data.structure_type,
|
|
86
|
-
periods: (data.periods ?? []).map((p) => ({
|
|
87
|
-
start: p.start,
|
|
88
|
-
end: p.end,
|
|
89
|
-
label: p.label,
|
|
90
|
-
})),
|
|
91
|
-
rows: (data.rows ?? []).map((r) => ({
|
|
92
|
-
elementId: r.element_id,
|
|
93
|
-
elementQname: r.element_qname,
|
|
94
|
-
elementName: r.element_name,
|
|
95
|
-
classification: r.classification,
|
|
96
|
-
values: r.values ?? [],
|
|
97
|
-
isSubtotal: r.is_subtotal ?? false,
|
|
98
|
-
depth: r.depth ?? 0,
|
|
99
|
-
})),
|
|
100
|
-
validation: data.validation
|
|
101
|
-
? {
|
|
102
|
-
passed: data.validation.passed,
|
|
103
|
-
checks: data.validation.checks,
|
|
104
|
-
failures: data.validation.failures,
|
|
105
|
-
warnings: data.validation.warnings,
|
|
106
|
-
}
|
|
107
|
-
: null,
|
|
108
|
-
unmappedCount: data.unmapped_count ?? 0,
|
|
109
|
-
};
|
|
54
|
+
return this.gqlQuery(graphId, graphql_1.GetLedgerStatementDocument, { reportId, structureType }, 'Get statement', (data) => data.statement);
|
|
110
55
|
}
|
|
111
56
|
/**
|
|
112
|
-
* Regenerate
|
|
57
|
+
* Regenerate an existing report (async). Returns an operation id;
|
|
58
|
+
* subscribe via SSE for progress.
|
|
113
59
|
*/
|
|
114
60
|
async regenerate(graphId, reportId, periodStart, periodEnd) {
|
|
115
|
-
const
|
|
116
|
-
path: { graph_id: graphId
|
|
117
|
-
body: {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
61
|
+
const envelope = await this.callOperation('Regenerate report', (0, sdk_gen_1.opRegenerateReport)({
|
|
62
|
+
path: { graph_id: graphId },
|
|
63
|
+
body: {
|
|
64
|
+
report_id: reportId,
|
|
65
|
+
period_start: periodStart,
|
|
66
|
+
period_end: periodEnd,
|
|
67
|
+
},
|
|
68
|
+
}));
|
|
69
|
+
return {
|
|
70
|
+
operationId: envelope.operationId,
|
|
71
|
+
status: envelope.status,
|
|
72
|
+
result: envelope.result ?? null,
|
|
73
|
+
};
|
|
123
74
|
}
|
|
124
|
-
/**
|
|
125
|
-
* Delete a report and its generated facts.
|
|
126
|
-
*/
|
|
75
|
+
/** Delete a report and its generated facts. */
|
|
127
76
|
async delete(graphId, reportId) {
|
|
128
|
-
|
|
129
|
-
path: { graph_id: graphId
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
throw new Error(`Delete report failed: ${JSON.stringify(response.error)}`);
|
|
133
|
-
}
|
|
77
|
+
await this.callOperation('Delete report', (0, sdk_gen_1.opDeleteReport)({
|
|
78
|
+
path: { graph_id: graphId },
|
|
79
|
+
body: { report_id: reportId },
|
|
80
|
+
}));
|
|
134
81
|
}
|
|
135
82
|
/**
|
|
136
|
-
* Share a published report to
|
|
83
|
+
* Share a published report to every member of a publish list (async).
|
|
84
|
+
* Each target graph receives a snapshot copy of the report's facts.
|
|
137
85
|
*/
|
|
138
86
|
async share(graphId, reportId, publishListId) {
|
|
139
|
-
const
|
|
140
|
-
path: { graph_id: graphId
|
|
141
|
-
body: {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
const data = response.data;
|
|
87
|
+
const envelope = await this.callOperation('Share report', (0, sdk_gen_1.opShareReport)({
|
|
88
|
+
path: { graph_id: graphId },
|
|
89
|
+
body: {
|
|
90
|
+
report_id: reportId,
|
|
91
|
+
publish_list_id: publishListId,
|
|
92
|
+
},
|
|
93
|
+
}));
|
|
147
94
|
return {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
status: r.status,
|
|
152
|
-
error: r.error ?? null,
|
|
153
|
-
factCount: r.fact_count ?? 0,
|
|
154
|
-
})),
|
|
95
|
+
operationId: envelope.operationId,
|
|
96
|
+
status: envelope.status,
|
|
97
|
+
result: envelope.result ?? null,
|
|
155
98
|
};
|
|
156
99
|
}
|
|
157
100
|
/** Check if a report was received via sharing (vs locally created). */
|
|
@@ -159,120 +102,90 @@ class ReportClient {
|
|
|
159
102
|
return report.sourceGraphId !== null;
|
|
160
103
|
}
|
|
161
104
|
// ── Publish Lists ────────────────────────────────────────────────────
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
105
|
+
/** List publish lists with pagination. */
|
|
106
|
+
async listPublishLists(graphId, options) {
|
|
107
|
+
const list = await this.gqlQuery(graphId, graphql_1.ListLedgerPublishListsDocument, {
|
|
108
|
+
limit: options?.limit ?? 100,
|
|
109
|
+
offset: options?.offset ?? 0,
|
|
110
|
+
}, 'List publish lists', (data) => data.publishLists);
|
|
111
|
+
return list?.publishLists ?? [];
|
|
112
|
+
}
|
|
113
|
+
/** Create a new publish list. */
|
|
172
114
|
async createPublishList(graphId, name, description) {
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
return this._toPublishList(response.data);
|
|
115
|
+
const body = {
|
|
116
|
+
name,
|
|
117
|
+
description: description ?? null,
|
|
118
|
+
};
|
|
119
|
+
const envelope = await this.callOperation('Create publish list', (0, sdk_gen_1.opCreatePublishList)({ path: { graph_id: graphId }, body }));
|
|
120
|
+
return (envelope.result ?? {});
|
|
181
121
|
}
|
|
122
|
+
/** Get a single publish list with its full member list. */
|
|
182
123
|
async getPublishList(graphId, listId) {
|
|
183
|
-
|
|
184
|
-
path: { graph_id: graphId, list_id: listId },
|
|
185
|
-
});
|
|
186
|
-
if (response.error) {
|
|
187
|
-
throw new Error(`Get publish list failed: ${JSON.stringify(response.error)}`);
|
|
188
|
-
}
|
|
189
|
-
const data = response.data;
|
|
190
|
-
return {
|
|
191
|
-
...this._toPublishList(data),
|
|
192
|
-
members: (data.members ?? []).map((m) => this._toMember(m)),
|
|
193
|
-
};
|
|
124
|
+
return this.gqlQuery(graphId, graphql_1.GetLedgerPublishListDocument, { listId }, 'Get publish list', (data) => data.publishList);
|
|
194
125
|
}
|
|
126
|
+
/** Update a publish list's name or description. */
|
|
195
127
|
async updatePublishList(graphId, listId, updates) {
|
|
196
|
-
const
|
|
197
|
-
path: { graph_id: graphId
|
|
198
|
-
body:
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
128
|
+
const envelope = await this.callOperation('Update publish list', (0, sdk_gen_1.opUpdatePublishList)({
|
|
129
|
+
path: { graph_id: graphId },
|
|
130
|
+
body: {
|
|
131
|
+
list_id: listId,
|
|
132
|
+
name: updates.name,
|
|
133
|
+
description: updates.description ?? null,
|
|
134
|
+
},
|
|
135
|
+
}));
|
|
136
|
+
return (envelope.result ?? {});
|
|
137
|
+
}
|
|
138
|
+
/** Delete a publish list. */
|
|
205
139
|
async deletePublishList(graphId, listId) {
|
|
206
|
-
|
|
207
|
-
path: { graph_id: graphId
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
throw new Error(`Delete publish list failed: ${JSON.stringify(response.error)}`);
|
|
211
|
-
}
|
|
140
|
+
await this.callOperation('Delete publish list', (0, sdk_gen_1.opDeletePublishList)({
|
|
141
|
+
path: { graph_id: graphId },
|
|
142
|
+
body: { list_id: listId },
|
|
143
|
+
}));
|
|
212
144
|
}
|
|
145
|
+
/** Add target graphs as members of a publish list. */
|
|
213
146
|
async addMembers(graphId, listId, targetGraphIds) {
|
|
214
|
-
const
|
|
215
|
-
path: { graph_id: graphId
|
|
216
|
-
body: {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
return (
|
|
222
|
-
}
|
|
147
|
+
const envelope = await this.callOperation('Add publish list members', (0, sdk_gen_1.opAddPublishListMembers)({
|
|
148
|
+
path: { graph_id: graphId },
|
|
149
|
+
body: {
|
|
150
|
+
list_id: listId,
|
|
151
|
+
target_graph_ids: targetGraphIds,
|
|
152
|
+
},
|
|
153
|
+
}));
|
|
154
|
+
return (envelope.result ?? {});
|
|
155
|
+
}
|
|
156
|
+
/** Remove a single member from a publish list. */
|
|
223
157
|
async removeMember(graphId, listId, memberId) {
|
|
224
|
-
const
|
|
225
|
-
path: { graph_id: graphId
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
158
|
+
const envelope = await this.callOperation('Remove publish list member', (0, sdk_gen_1.opRemovePublishListMember)({
|
|
159
|
+
path: { graph_id: graphId },
|
|
160
|
+
body: { list_id: listId, member_id: memberId },
|
|
161
|
+
}));
|
|
162
|
+
return (envelope.result ?? { deleted: true });
|
|
163
|
+
}
|
|
164
|
+
// ── Internal helpers ────────────────────────────────────────────────
|
|
165
|
+
async gqlQuery(graphId, document, variables, label, pick) {
|
|
166
|
+
try {
|
|
167
|
+
const client = this.gql.get(graphId);
|
|
168
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
169
|
+
const raw = client.request;
|
|
170
|
+
const data = (await raw.call(client, document, variables));
|
|
171
|
+
return pick(data);
|
|
172
|
+
}
|
|
173
|
+
catch (err) {
|
|
174
|
+
if (err instanceof graphql_request_1.ClientError) {
|
|
175
|
+
throw new Error(`${label} failed: ${JSON.stringify(err.response.errors ?? err.message)}`);
|
|
176
|
+
}
|
|
177
|
+
throw err;
|
|
229
178
|
}
|
|
230
179
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
_toMember(m) {
|
|
243
|
-
return {
|
|
244
|
-
id: m.id,
|
|
245
|
-
targetGraphId: m.target_graph_id,
|
|
246
|
-
targetGraphName: m.target_graph_name ?? null,
|
|
247
|
-
targetOrgName: m.target_org_name ?? null,
|
|
248
|
-
addedBy: m.added_by,
|
|
249
|
-
addedAt: m.added_at,
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
_toReport(r) {
|
|
253
|
-
return {
|
|
254
|
-
id: r.id,
|
|
255
|
-
name: r.name,
|
|
256
|
-
taxonomyId: r.taxonomy_id,
|
|
257
|
-
generationStatus: r.generation_status,
|
|
258
|
-
periodType: r.period_type,
|
|
259
|
-
periodStart: r.period_start ?? null,
|
|
260
|
-
periodEnd: r.period_end ?? null,
|
|
261
|
-
comparative: r.comparative,
|
|
262
|
-
mappingId: r.mapping_id ?? null,
|
|
263
|
-
aiGenerated: r.ai_generated ?? false,
|
|
264
|
-
createdAt: r.created_at,
|
|
265
|
-
lastGenerated: r.last_generated ?? null,
|
|
266
|
-
structures: (r.structures ?? []).map((s) => ({
|
|
267
|
-
id: s.id,
|
|
268
|
-
name: s.name,
|
|
269
|
-
structureType: s.structure_type,
|
|
270
|
-
})),
|
|
271
|
-
entityName: r.entity_name ?? null,
|
|
272
|
-
sourceGraphId: r.source_graph_id ?? null,
|
|
273
|
-
sourceReportId: r.source_report_id ?? null,
|
|
274
|
-
sharedAt: r.shared_at ?? null,
|
|
275
|
-
};
|
|
180
|
+
async callOperation(label, call) {
|
|
181
|
+
const response = await call;
|
|
182
|
+
if (response.error !== undefined) {
|
|
183
|
+
throw new Error(`${label} failed: ${JSON.stringify(response.error)}`);
|
|
184
|
+
}
|
|
185
|
+
if (response.data === undefined) {
|
|
186
|
+
throw new Error(`${label} failed: empty response`);
|
|
187
|
+
}
|
|
188
|
+
return response.data;
|
|
276
189
|
}
|
|
277
190
|
}
|
|
278
191
|
exports.ReportClient = ReportClient;
|