@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
|
@@ -3,135 +3,74 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Report Client for RoboSystems API
|
|
5
5
|
*
|
|
6
|
-
* High-level
|
|
7
|
-
* regenerate
|
|
8
|
-
*
|
|
6
|
+
* High-level facade for the report + publish-list surface:
|
|
7
|
+
* create/list/view/regenerate/share/delete reports, render financial
|
|
8
|
+
* statements, and manage publish lists (distribution lists for shared
|
|
9
|
+
* reports). Reports consume ledger data (mappings, trial balance) as
|
|
10
|
+
* inputs — use `LedgerClient` for those concerns.
|
|
11
|
+
*
|
|
12
|
+
* **Transport split:**
|
|
13
|
+
* - **Reads** (listReports, getReport, getStatement, listPublishLists,
|
|
14
|
+
* getPublishList) go through GraphQL at
|
|
15
|
+
* `/extensions/{graph_id}/graphql`.
|
|
16
|
+
* - **Writes** (createReport, regenerateReport, deleteReport, shareReport,
|
|
17
|
+
* and the publish-list CRUD) go through named operations at
|
|
18
|
+
* `/extensions/roboledger/{graph_id}/operations/{operation_name}`.
|
|
19
|
+
*
|
|
20
|
+
* Every write returns an `OperationEnvelope`; this facade unwraps
|
|
21
|
+
* `envelope.result` for sync commands, or returns `{ operationId, status }`
|
|
22
|
+
* for async dispatches (createReport, regenerateReport, shareReport).
|
|
9
23
|
*/
|
|
10
24
|
|
|
25
|
+
import type { TypedDocumentNode } from '@graphql-typed-document-node/core'
|
|
26
|
+
import { ClientError } from 'graphql-request'
|
|
11
27
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
listReports,
|
|
22
|
-
regenerateReport,
|
|
23
|
-
removePublishListMember,
|
|
24
|
-
shareReport,
|
|
25
|
-
updatePublishList,
|
|
28
|
+
opAddPublishListMembers,
|
|
29
|
+
opCreatePublishList,
|
|
30
|
+
opCreateReport,
|
|
31
|
+
opDeletePublishList,
|
|
32
|
+
opDeleteReport,
|
|
33
|
+
opRegenerateReport,
|
|
34
|
+
opRemovePublishListMember,
|
|
35
|
+
opShareReport,
|
|
36
|
+
opUpdatePublishList,
|
|
26
37
|
} from '../sdk.gen'
|
|
27
38
|
import type {
|
|
39
|
+
AddPublishListMembersOperation,
|
|
40
|
+
CreatePublishListRequest,
|
|
28
41
|
CreateReportRequest,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
PublishListListResponse,
|
|
32
|
-
PublishListMemberResponse,
|
|
33
|
-
PublishListResponse,
|
|
34
|
-
RegenerateReportRequest,
|
|
35
|
-
ReportListResponse,
|
|
36
|
-
ReportResponse,
|
|
37
|
-
ShareReportResponse,
|
|
38
|
-
StatementResponse,
|
|
39
|
-
StructureSummary,
|
|
40
|
-
ValidationCheckResponse,
|
|
42
|
+
OperationEnvelope,
|
|
43
|
+
UpdatePublishListOperation,
|
|
41
44
|
} from '../types.gen'
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
export interface StatementPeriod {
|
|
72
|
-
start: string
|
|
73
|
-
end: string
|
|
74
|
-
label: string
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export interface StatementRow {
|
|
78
|
-
elementId: string
|
|
79
|
-
elementQname: string
|
|
80
|
-
elementName: string
|
|
81
|
-
classification: string
|
|
82
|
-
values: (number | null)[]
|
|
83
|
-
isSubtotal: boolean
|
|
84
|
-
depth: number
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export interface StatementData {
|
|
88
|
-
reportId: string
|
|
89
|
-
structureId: string
|
|
90
|
-
structureName: string
|
|
91
|
-
structureType: string
|
|
92
|
-
periods: StatementPeriod[]
|
|
93
|
-
rows: StatementRow[]
|
|
94
|
-
validation: {
|
|
95
|
-
passed: boolean
|
|
96
|
-
checks: string[]
|
|
97
|
-
failures: string[]
|
|
98
|
-
warnings: string[]
|
|
99
|
-
} | null
|
|
100
|
-
unmappedCount: number
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export interface ShareResult {
|
|
104
|
-
reportId: string
|
|
105
|
-
results: Array<{
|
|
106
|
-
targetGraphId: string
|
|
107
|
-
status: 'shared' | 'error'
|
|
108
|
-
error: string | null
|
|
109
|
-
factCount: number
|
|
110
|
-
}>
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface PublishList {
|
|
114
|
-
id: string
|
|
115
|
-
name: string
|
|
116
|
-
description: string | null
|
|
117
|
-
memberCount: number
|
|
118
|
-
createdBy: string
|
|
119
|
-
createdAt: string
|
|
120
|
-
updatedAt: string
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export interface PublishListDetail extends PublishList {
|
|
124
|
-
members: PublishListMember[]
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export interface PublishListMember {
|
|
128
|
-
id: string
|
|
129
|
-
targetGraphId: string
|
|
130
|
-
targetGraphName: string | null
|
|
131
|
-
targetOrgName: string | null
|
|
132
|
-
addedBy: string
|
|
133
|
-
addedAt: string
|
|
134
|
-
}
|
|
45
|
+
import { GraphQLClientCache } from './graphql/client'
|
|
46
|
+
import {
|
|
47
|
+
GetLedgerPublishListDocument,
|
|
48
|
+
GetLedgerReportDocument,
|
|
49
|
+
GetLedgerStatementDocument,
|
|
50
|
+
ListLedgerPublishListsDocument,
|
|
51
|
+
ListLedgerReportsDocument,
|
|
52
|
+
type GetLedgerPublishListQuery,
|
|
53
|
+
type GetLedgerReportQuery,
|
|
54
|
+
type GetLedgerStatementQuery,
|
|
55
|
+
type ListLedgerPublishListsQuery,
|
|
56
|
+
type ListLedgerReportsQuery,
|
|
57
|
+
} from './graphql/generated/graphql'
|
|
58
|
+
|
|
59
|
+
// ── Types derived from GraphQL codegen ──────────────────────────────────
|
|
60
|
+
|
|
61
|
+
export type Report = NonNullable<GetLedgerReportQuery['report']>
|
|
62
|
+
export type ReportListItem = NonNullable<ListLedgerReportsQuery['reports']>['reports'][number]
|
|
63
|
+
export type StatementData = NonNullable<GetLedgerStatementQuery['statement']>
|
|
64
|
+
export type StatementPeriod = StatementData['periods'][number]
|
|
65
|
+
export type StatementRow = StatementData['rows'][number]
|
|
66
|
+
|
|
67
|
+
export type PublishList = NonNullable<
|
|
68
|
+
ListLedgerPublishListsQuery['publishLists']
|
|
69
|
+
>['publishLists'][number]
|
|
70
|
+
export type PublishListDetail = NonNullable<GetLedgerPublishListQuery['publishList']>
|
|
71
|
+
export type PublishListMember = PublishListDetail['members'][number]
|
|
72
|
+
|
|
73
|
+
// ── Caller-facing option interfaces ─────────────────────────────────────
|
|
135
74
|
|
|
136
75
|
export interface PeriodSpecInput {
|
|
137
76
|
start: string
|
|
@@ -151,29 +90,54 @@ export interface CreateReportOptions {
|
|
|
151
90
|
periods?: PeriodSpecInput[]
|
|
152
91
|
}
|
|
153
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Envelope around a report operation. `status === "completed"` means the
|
|
95
|
+
* backend produced the report synchronously — `result` contains the
|
|
96
|
+
* freshly-created report shape (same fields as `ReportListItem`), so
|
|
97
|
+
* consumers can read `result?.id` immediately. For pending/failed
|
|
98
|
+
* dispatches, `result` is null and consumers should subscribe to
|
|
99
|
+
* `/v1/operations/{operationId}/stream` for progress.
|
|
100
|
+
*
|
|
101
|
+
* The loose `{ id; name; ... }` shape here intentionally mirrors the
|
|
102
|
+
* GraphQL `report` field without pulling in every nullable child relation
|
|
103
|
+
* — `create_report` and `regenerate_report` return a freshly-generated
|
|
104
|
+
* row, not a fully-resolved GraphQL projection.
|
|
105
|
+
*/
|
|
106
|
+
export interface ReportOperationAck {
|
|
107
|
+
operationId: string
|
|
108
|
+
status: OperationEnvelope['status']
|
|
109
|
+
/**
|
|
110
|
+
* Synchronous command result. Populated for `status === "completed"`
|
|
111
|
+
* dispatches where the backend produced the report inline.
|
|
112
|
+
*/
|
|
113
|
+
result: Record<string, unknown> | null
|
|
114
|
+
}
|
|
115
|
+
|
|
154
116
|
// ── Client ──────────────────────────────────────────────────────────────
|
|
155
117
|
|
|
118
|
+
interface ReportClientConfig {
|
|
119
|
+
baseUrl: string
|
|
120
|
+
credentials?: 'include' | 'same-origin' | 'omit'
|
|
121
|
+
headers?: Record<string, string>
|
|
122
|
+
token?: string
|
|
123
|
+
}
|
|
124
|
+
|
|
156
125
|
export class ReportClient {
|
|
157
|
-
private config:
|
|
158
|
-
|
|
159
|
-
credentials?: 'include' | 'same-origin' | 'omit'
|
|
160
|
-
headers?: Record<string, string>
|
|
161
|
-
token?: string
|
|
162
|
-
}
|
|
126
|
+
private config: ReportClientConfig
|
|
127
|
+
private gql: GraphQLClientCache
|
|
163
128
|
|
|
164
|
-
constructor(config: {
|
|
165
|
-
baseUrl: string
|
|
166
|
-
credentials?: 'include' | 'same-origin' | 'omit'
|
|
167
|
-
headers?: Record<string, string>
|
|
168
|
-
token?: string
|
|
169
|
-
}) {
|
|
129
|
+
constructor(config: ReportClientConfig) {
|
|
170
130
|
this.config = config
|
|
131
|
+
this.gql = new GraphQLClientCache(config)
|
|
171
132
|
}
|
|
172
133
|
|
|
134
|
+
// ── Reports ─────────────────────────────────────────────────────────
|
|
135
|
+
|
|
173
136
|
/**
|
|
174
|
-
*
|
|
137
|
+
* Kick off report creation (async). Use the returned `operationId` to
|
|
138
|
+
* subscribe to progress via SSE, then call `get()` once finished.
|
|
175
139
|
*/
|
|
176
|
-
async create(graphId: string, options: CreateReportOptions): Promise<
|
|
140
|
+
async create(graphId: string, options: CreateReportOptions): Promise<ReportOperationAck> {
|
|
177
141
|
const body: CreateReportRequest = {
|
|
178
142
|
name: options.name,
|
|
179
143
|
mapping_id: options.mappingId,
|
|
@@ -183,52 +147,41 @@ export class ReportClient {
|
|
|
183
147
|
period_type: options.periodType ?? 'quarterly',
|
|
184
148
|
comparative: options.comparative ?? true,
|
|
185
149
|
}
|
|
186
|
-
|
|
187
150
|
if (options.periods && options.periods.length > 0) {
|
|
188
151
|
body.periods = options.periods
|
|
189
152
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
path: { graph_id: graphId },
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
153
|
+
const envelope = await this.callOperation(
|
|
154
|
+
'Create report',
|
|
155
|
+
opCreateReport({ path: { graph_id: graphId }, body })
|
|
156
|
+
)
|
|
157
|
+
return {
|
|
158
|
+
operationId: envelope.operationId,
|
|
159
|
+
status: envelope.status,
|
|
160
|
+
result: (envelope.result as Record<string, unknown> | null) ?? null,
|
|
198
161
|
}
|
|
199
|
-
|
|
200
|
-
return this._toReport(response.data as ReportResponse)
|
|
201
162
|
}
|
|
202
163
|
|
|
203
|
-
/**
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
const data = response.data as ReportListResponse
|
|
216
|
-
return (data.reports ?? []).map((r) => this._toReport(r))
|
|
164
|
+
/** List all reports for a graph (includes received shared reports). */
|
|
165
|
+
async list(graphId: string): Promise<ReportListItem[]> {
|
|
166
|
+
const list = await this.gqlQuery(
|
|
167
|
+
graphId,
|
|
168
|
+
ListLedgerReportsDocument,
|
|
169
|
+
undefined,
|
|
170
|
+
'List reports',
|
|
171
|
+
(data) => data.reports
|
|
172
|
+
)
|
|
173
|
+
return list?.reports ?? []
|
|
217
174
|
}
|
|
218
175
|
|
|
219
|
-
/**
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
throw new Error(`Get report failed: ${JSON.stringify(response.error)}`)
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
return this._toReport(response.data as ReportResponse)
|
|
176
|
+
/** Get a single report with its period list + available structures. */
|
|
177
|
+
async get(graphId: string, reportId: string): Promise<Report | null> {
|
|
178
|
+
return this.gqlQuery(
|
|
179
|
+
graphId,
|
|
180
|
+
GetLedgerReportDocument,
|
|
181
|
+
{ reportId },
|
|
182
|
+
'Get report',
|
|
183
|
+
(data) => data.report
|
|
184
|
+
)
|
|
232
185
|
}
|
|
233
186
|
|
|
234
187
|
/**
|
|
@@ -240,103 +193,78 @@ export class ReportClient {
|
|
|
240
193
|
graphId: string,
|
|
241
194
|
reportId: string,
|
|
242
195
|
structureType: string
|
|
243
|
-
): Promise<StatementData> {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
const data = response.data as StatementResponse
|
|
253
|
-
return {
|
|
254
|
-
reportId: data.report_id,
|
|
255
|
-
structureId: data.structure_id,
|
|
256
|
-
structureName: data.structure_name,
|
|
257
|
-
structureType: data.structure_type,
|
|
258
|
-
periods: (data.periods ?? []).map((p) => ({
|
|
259
|
-
start: p.start,
|
|
260
|
-
end: p.end,
|
|
261
|
-
label: p.label,
|
|
262
|
-
})),
|
|
263
|
-
rows: (data.rows ?? []).map((r: FactRowResponse) => ({
|
|
264
|
-
elementId: r.element_id,
|
|
265
|
-
elementQname: r.element_qname,
|
|
266
|
-
elementName: r.element_name,
|
|
267
|
-
classification: r.classification,
|
|
268
|
-
values: r.values ?? [],
|
|
269
|
-
isSubtotal: r.is_subtotal ?? false,
|
|
270
|
-
depth: r.depth ?? 0,
|
|
271
|
-
})),
|
|
272
|
-
validation: data.validation
|
|
273
|
-
? {
|
|
274
|
-
passed: (data.validation as ValidationCheckResponse).passed,
|
|
275
|
-
checks: (data.validation as ValidationCheckResponse).checks,
|
|
276
|
-
failures: (data.validation as ValidationCheckResponse).failures,
|
|
277
|
-
warnings: (data.validation as ValidationCheckResponse).warnings,
|
|
278
|
-
}
|
|
279
|
-
: null,
|
|
280
|
-
unmappedCount: data.unmapped_count ?? 0,
|
|
281
|
-
}
|
|
196
|
+
): Promise<StatementData | null> {
|
|
197
|
+
return this.gqlQuery(
|
|
198
|
+
graphId,
|
|
199
|
+
GetLedgerStatementDocument,
|
|
200
|
+
{ reportId, structureType },
|
|
201
|
+
'Get statement',
|
|
202
|
+
(data) => data.statement
|
|
203
|
+
)
|
|
282
204
|
}
|
|
283
205
|
|
|
284
206
|
/**
|
|
285
|
-
* Regenerate
|
|
207
|
+
* Regenerate an existing report (async). Returns an operation id;
|
|
208
|
+
* subscribe via SSE for progress.
|
|
286
209
|
*/
|
|
287
210
|
async regenerate(
|
|
288
211
|
graphId: string,
|
|
289
212
|
reportId: string,
|
|
290
|
-
periodStart
|
|
291
|
-
periodEnd
|
|
292
|
-
): Promise<
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
213
|
+
periodStart?: string,
|
|
214
|
+
periodEnd?: string
|
|
215
|
+
): Promise<ReportOperationAck> {
|
|
216
|
+
const envelope = await this.callOperation(
|
|
217
|
+
'Regenerate report',
|
|
218
|
+
opRegenerateReport({
|
|
219
|
+
path: { graph_id: graphId },
|
|
220
|
+
body: {
|
|
221
|
+
report_id: reportId,
|
|
222
|
+
period_start: periodStart,
|
|
223
|
+
period_end: periodEnd,
|
|
224
|
+
} as Parameters<typeof opRegenerateReport>[0]['body'],
|
|
225
|
+
})
|
|
226
|
+
)
|
|
227
|
+
return {
|
|
228
|
+
operationId: envelope.operationId,
|
|
229
|
+
status: envelope.status,
|
|
230
|
+
result: (envelope.result as Record<string, unknown> | null) ?? null,
|
|
300
231
|
}
|
|
301
|
-
|
|
302
|
-
return this._toReport(response.data as ReportResponse)
|
|
303
232
|
}
|
|
304
233
|
|
|
305
|
-
/**
|
|
306
|
-
* Delete a report and its generated facts.
|
|
307
|
-
*/
|
|
234
|
+
/** Delete a report and its generated facts. */
|
|
308
235
|
async delete(graphId: string, reportId: string): Promise<void> {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
236
|
+
await this.callOperation(
|
|
237
|
+
'Delete report',
|
|
238
|
+
opDeleteReport({
|
|
239
|
+
path: { graph_id: graphId },
|
|
240
|
+
body: { report_id: reportId },
|
|
241
|
+
})
|
|
242
|
+
)
|
|
316
243
|
}
|
|
317
244
|
|
|
318
245
|
/**
|
|
319
|
-
* Share a published report to
|
|
246
|
+
* Share a published report to every member of a publish list (async).
|
|
247
|
+
* Each target graph receives a snapshot copy of the report's facts.
|
|
320
248
|
*/
|
|
321
|
-
async share(
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
249
|
+
async share(
|
|
250
|
+
graphId: string,
|
|
251
|
+
reportId: string,
|
|
252
|
+
publishListId: string
|
|
253
|
+
): Promise<ReportOperationAck> {
|
|
254
|
+
const envelope = await this.callOperation(
|
|
255
|
+
'Share report',
|
|
256
|
+
opShareReport({
|
|
257
|
+
path: { graph_id: graphId },
|
|
258
|
+
body: {
|
|
259
|
+
report_id: reportId,
|
|
260
|
+
publish_list_id: publishListId,
|
|
261
|
+
} as Parameters<typeof opShareReport>[0]['body'],
|
|
262
|
+
})
|
|
263
|
+
)
|
|
332
264
|
return {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
status: r.status as 'shared' | 'error',
|
|
337
|
-
error: r.error ?? null,
|
|
338
|
-
factCount: r.fact_count ?? 0,
|
|
339
|
-
})),
|
|
265
|
+
operationId: envelope.operationId,
|
|
266
|
+
status: envelope.status,
|
|
267
|
+
result: (envelope.result as Record<string, unknown> | null) ?? null,
|
|
340
268
|
}
|
|
341
269
|
}
|
|
342
270
|
|
|
@@ -347,140 +275,152 @@ export class ReportClient {
|
|
|
347
275
|
|
|
348
276
|
// ── Publish Lists ────────────────────────────────────────────────────
|
|
349
277
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
278
|
+
/** List publish lists with pagination. */
|
|
279
|
+
async listPublishLists(
|
|
280
|
+
graphId: string,
|
|
281
|
+
options?: { limit?: number; offset?: number }
|
|
282
|
+
): Promise<PublishList[]> {
|
|
283
|
+
const list = await this.gqlQuery(
|
|
284
|
+
graphId,
|
|
285
|
+
ListLedgerPublishListsDocument,
|
|
286
|
+
{
|
|
287
|
+
limit: options?.limit ?? 100,
|
|
288
|
+
offset: options?.offset ?? 0,
|
|
289
|
+
},
|
|
290
|
+
'List publish lists',
|
|
291
|
+
(data) => data.publishLists
|
|
292
|
+
)
|
|
293
|
+
return list?.publishLists ?? []
|
|
359
294
|
}
|
|
360
295
|
|
|
296
|
+
/** Create a new publish list. */
|
|
361
297
|
async createPublishList(
|
|
362
298
|
graphId: string,
|
|
363
299
|
name: string,
|
|
364
300
|
description?: string
|
|
365
|
-
): Promise<
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
})
|
|
370
|
-
if (response.error) {
|
|
371
|
-
throw new Error(`Create publish list failed: ${JSON.stringify(response.error)}`)
|
|
301
|
+
): Promise<Record<string, unknown>> {
|
|
302
|
+
const body: CreatePublishListRequest = {
|
|
303
|
+
name,
|
|
304
|
+
description: description ?? null,
|
|
372
305
|
}
|
|
373
|
-
|
|
306
|
+
const envelope = await this.callOperation(
|
|
307
|
+
'Create publish list',
|
|
308
|
+
opCreatePublishList({ path: { graph_id: graphId }, body })
|
|
309
|
+
)
|
|
310
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
374
311
|
}
|
|
375
312
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
...this._toPublishList(data),
|
|
386
|
-
members: (data.members ?? []).map((m) => this._toMember(m)),
|
|
387
|
-
}
|
|
313
|
+
/** Get a single publish list with its full member list. */
|
|
314
|
+
async getPublishList(graphId: string, listId: string): Promise<PublishListDetail | null> {
|
|
315
|
+
return this.gqlQuery(
|
|
316
|
+
graphId,
|
|
317
|
+
GetLedgerPublishListDocument,
|
|
318
|
+
{ listId },
|
|
319
|
+
'Get publish list',
|
|
320
|
+
(data) => data.publishList
|
|
321
|
+
)
|
|
388
322
|
}
|
|
389
323
|
|
|
324
|
+
/** Update a publish list's name or description. */
|
|
390
325
|
async updatePublishList(
|
|
391
326
|
graphId: string,
|
|
392
327
|
listId: string,
|
|
393
|
-
updates: { name?: string; description?: string }
|
|
394
|
-
): Promise<
|
|
395
|
-
const
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
328
|
+
updates: { name?: string; description?: string | null }
|
|
329
|
+
): Promise<Record<string, unknown>> {
|
|
330
|
+
const envelope = await this.callOperation(
|
|
331
|
+
'Update publish list',
|
|
332
|
+
opUpdatePublishList({
|
|
333
|
+
path: { graph_id: graphId },
|
|
334
|
+
body: {
|
|
335
|
+
list_id: listId,
|
|
336
|
+
name: updates.name,
|
|
337
|
+
description: updates.description ?? null,
|
|
338
|
+
} as UpdatePublishListOperation,
|
|
339
|
+
})
|
|
340
|
+
)
|
|
341
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
403
342
|
}
|
|
404
343
|
|
|
344
|
+
/** Delete a publish list. */
|
|
405
345
|
async deletePublishList(graphId: string, listId: string): Promise<void> {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
346
|
+
await this.callOperation(
|
|
347
|
+
'Delete publish list',
|
|
348
|
+
opDeletePublishList({
|
|
349
|
+
path: { graph_id: graphId },
|
|
350
|
+
body: { list_id: listId },
|
|
351
|
+
})
|
|
352
|
+
)
|
|
412
353
|
}
|
|
413
354
|
|
|
355
|
+
/** Add target graphs as members of a publish list. */
|
|
414
356
|
async addMembers(
|
|
415
357
|
graphId: string,
|
|
416
358
|
listId: string,
|
|
417
359
|
targetGraphIds: string[]
|
|
418
|
-
): Promise<
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
360
|
+
): Promise<Record<string, unknown>> {
|
|
361
|
+
const envelope = await this.callOperation(
|
|
362
|
+
'Add publish list members',
|
|
363
|
+
opAddPublishListMembers({
|
|
364
|
+
path: { graph_id: graphId },
|
|
365
|
+
body: {
|
|
366
|
+
list_id: listId,
|
|
367
|
+
target_graph_ids: targetGraphIds,
|
|
368
|
+
} as AddPublishListMembersOperation,
|
|
369
|
+
})
|
|
370
|
+
)
|
|
371
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
427
372
|
}
|
|
428
373
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
374
|
+
/** Remove a single member from a publish list. */
|
|
375
|
+
async removeMember(
|
|
376
|
+
graphId: string,
|
|
377
|
+
listId: string,
|
|
378
|
+
memberId: string
|
|
379
|
+
): Promise<{ deleted: boolean }> {
|
|
380
|
+
const envelope = await this.callOperation(
|
|
381
|
+
'Remove publish list member',
|
|
382
|
+
opRemovePublishListMember({
|
|
383
|
+
path: { graph_id: graphId },
|
|
384
|
+
body: { list_id: listId, member_id: memberId },
|
|
385
|
+
})
|
|
386
|
+
)
|
|
387
|
+
return (envelope.result ?? { deleted: true }) as { deleted: boolean }
|
|
436
388
|
}
|
|
437
389
|
|
|
438
|
-
|
|
439
|
-
return {
|
|
440
|
-
id: pl.id,
|
|
441
|
-
name: pl.name,
|
|
442
|
-
description: pl.description ?? null,
|
|
443
|
-
memberCount: pl.member_count ?? 0,
|
|
444
|
-
createdBy: pl.created_by,
|
|
445
|
-
createdAt: pl.created_at,
|
|
446
|
-
updatedAt: pl.updated_at,
|
|
447
|
-
}
|
|
448
|
-
}
|
|
390
|
+
// ── Internal helpers ────────────────────────────────────────────────
|
|
449
391
|
|
|
450
|
-
private
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
392
|
+
private async gqlQuery<TData, TVars extends object, TResult>(
|
|
393
|
+
graphId: string,
|
|
394
|
+
document: TypedDocumentNode<TData, TVars>,
|
|
395
|
+
variables: TVars | undefined,
|
|
396
|
+
label: string,
|
|
397
|
+
pick: (data: TData) => TResult
|
|
398
|
+
): Promise<TResult> {
|
|
399
|
+
try {
|
|
400
|
+
const client = this.gql.get(graphId)
|
|
401
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
402
|
+
const raw = client.request as (doc: unknown, vars?: unknown) => Promise<any>
|
|
403
|
+
const data = (await raw.call(client, document, variables)) as TData
|
|
404
|
+
return pick(data)
|
|
405
|
+
} catch (err) {
|
|
406
|
+
if (err instanceof ClientError) {
|
|
407
|
+
throw new Error(`${label} failed: ${JSON.stringify(err.response.errors ?? err.message)}`)
|
|
408
|
+
}
|
|
409
|
+
throw err
|
|
458
410
|
}
|
|
459
411
|
}
|
|
460
412
|
|
|
461
|
-
private
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
mappingId: r.mapping_id ?? null,
|
|
472
|
-
aiGenerated: r.ai_generated ?? false,
|
|
473
|
-
createdAt: r.created_at,
|
|
474
|
-
lastGenerated: r.last_generated ?? null,
|
|
475
|
-
structures: (r.structures ?? []).map((s: StructureSummary) => ({
|
|
476
|
-
id: s.id,
|
|
477
|
-
name: s.name,
|
|
478
|
-
structureType: s.structure_type,
|
|
479
|
-
})),
|
|
480
|
-
entityName: r.entity_name ?? null,
|
|
481
|
-
sourceGraphId: r.source_graph_id ?? null,
|
|
482
|
-
sourceReportId: r.source_report_id ?? null,
|
|
483
|
-
sharedAt: r.shared_at ?? null,
|
|
413
|
+
private async callOperation(
|
|
414
|
+
label: string,
|
|
415
|
+
call: Promise<{ data?: OperationEnvelope; error?: unknown }>
|
|
416
|
+
): Promise<OperationEnvelope> {
|
|
417
|
+
const response = await call
|
|
418
|
+
if (response.error !== undefined) {
|
|
419
|
+
throw new Error(`${label} failed: ${JSON.stringify(response.error)}`)
|
|
420
|
+
}
|
|
421
|
+
if (response.data === undefined) {
|
|
422
|
+
throw new Error(`${label} failed: empty response`)
|
|
484
423
|
}
|
|
424
|
+
return response.data
|
|
485
425
|
}
|
|
486
426
|
}
|