@robosystems/client 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{extensions → artifacts}/InvestorClient.js +0 -1
- package/{extensions → artifacts}/InvestorClient.ts +1 -1
- package/{extensions → artifacts}/LedgerClient.d.ts +168 -2
- package/{extensions → artifacts}/LedgerClient.js +301 -2
- package/{extensions → artifacts}/LedgerClient.ts +645 -2
- package/{extensions → artifacts}/config.d.ts +11 -11
- package/{extensions → artifacts}/config.js +11 -11
- package/{extensions → artifacts}/config.ts +16 -16
- package/{extensions → artifacts}/graphql/client.d.ts +1 -1
- package/{extensions → artifacts}/graphql/client.js +1 -2
- package/{extensions → artifacts}/graphql/client.ts +2 -2
- package/{extensions → artifacts}/hooks.js +6 -6
- package/{extensions → artifacts}/hooks.ts +7 -7
- package/{extensions → artifacts}/index.d.ts +21 -18
- package/{extensions → artifacts}/index.js +43 -53
- package/{extensions → artifacts}/index.ts +47 -60
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/index.ts +2 -2
- package/package.json +38 -8
- package/sdk/index.d.ts +2 -2
- package/sdk/index.js +27 -9
- package/sdk/index.ts +2 -2
- package/sdk/sdk.gen.d.ts +272 -274
- package/sdk/sdk.gen.js +468 -312
- package/sdk/sdk.gen.ts +464 -309
- package/sdk/types.gen.d.ts +2962 -440
- package/sdk/types.gen.ts +3058 -430
- package/sdk.gen.d.ts +272 -274
- package/sdk.gen.js +468 -312
- package/sdk.gen.ts +464 -309
- package/types.gen.d.ts +2962 -440
- package/types.gen.ts +3058 -430
- package/extensions/ReportClient.d.ts +0 -120
- package/extensions/ReportClient.js +0 -191
- package/extensions/ReportClient.ts +0 -433
- /package/{extensions → artifacts}/AgentClient.d.ts +0 -0
- /package/{extensions → artifacts}/AgentClient.js +0 -0
- /package/{extensions → artifacts}/AgentClient.ts +0 -0
- /package/{extensions → artifacts}/InvestorClient.d.ts +0 -0
- /package/{extensions → artifacts}/OperationClient.d.ts +0 -0
- /package/{extensions → artifacts}/OperationClient.js +0 -0
- /package/{extensions → artifacts}/OperationClient.ts +0 -0
- /package/{extensions → artifacts}/QueryClient.d.ts +0 -0
- /package/{extensions → artifacts}/QueryClient.js +0 -0
- /package/{extensions → artifacts}/QueryClient.ts +0 -0
- /package/{extensions → artifacts}/SSEClient.d.ts +0 -0
- /package/{extensions → artifacts}/SSEClient.js +0 -0
- /package/{extensions → artifacts}/SSEClient.ts +0 -0
- /package/{extensions → artifacts}/graphql/generated/graphql.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/generated/graphql.js +0 -0
- /package/{extensions → artifacts}/graphql/generated/graphql.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/holdings.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/holdings.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/holdings.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/portfolio.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/portfolio.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/portfolio.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/portfolios.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/portfolios.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/portfolios.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/position.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/position.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/position.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/positions.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/positions.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/positions.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/securities.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/securities.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/securities.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/security.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/security.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/security.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/accountRollups.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/accountRollups.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/accountRollups.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/accountTree.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/accountTree.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/accountTree.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/accounts.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/accounts.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/accounts.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/closingBookStructures.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/closingBookStructures.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/closingBookStructures.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/elements.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/elements.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/elements.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/entities.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/entities.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/entities.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/entity.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/entity.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/entity.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/fiscalCalendar.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/fiscalCalendar.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/fiscalCalendar.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mappedTrialBalance.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mappedTrialBalance.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mappedTrialBalance.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mapping.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mapping.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mapping.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mappingCoverage.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mappingCoverage.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mappingCoverage.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mappings.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mappings.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mappings.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/periodCloseStatus.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/periodCloseStatus.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/periodCloseStatus.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/periodDrafts.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/periodDrafts.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/periodDrafts.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/publishList.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/publishList.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/publishList.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/publishLists.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/publishLists.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/publishLists.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/report.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/report.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/report.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/reportingTaxonomy.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/reportingTaxonomy.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/reportingTaxonomy.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/reports.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/reports.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/reports.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/scheduleFacts.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/scheduleFacts.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/scheduleFacts.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/schedules.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/schedules.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/schedules.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/statement.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/statement.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/statement.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/structures.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/structures.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/structures.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/summary.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/summary.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/summary.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/taxonomies.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/taxonomies.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/taxonomies.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/transaction.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/transaction.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/transaction.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/transactions.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/transactions.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/transactions.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/trialBalance.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/trialBalance.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/trialBalance.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/unmappedElements.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/unmappedElements.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/unmappedElements.ts +0 -0
- /package/{extensions → artifacts}/hooks.d.ts +0 -0
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Report Client for RoboSystems API
|
|
5
|
-
*
|
|
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).
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import type { TypedDocumentNode } from '@graphql-typed-document-node/core'
|
|
26
|
-
import { ClientError } from 'graphql-request'
|
|
27
|
-
import {
|
|
28
|
-
opAddPublishListMembers,
|
|
29
|
-
opCreatePublishList,
|
|
30
|
-
opCreateReport,
|
|
31
|
-
opDeletePublishList,
|
|
32
|
-
opDeleteReport,
|
|
33
|
-
opRegenerateReport,
|
|
34
|
-
opRemovePublishListMember,
|
|
35
|
-
opShareReport,
|
|
36
|
-
opUpdatePublishList,
|
|
37
|
-
} from '../sdk.gen'
|
|
38
|
-
import type {
|
|
39
|
-
AddPublishListMembersOperation,
|
|
40
|
-
CreatePublishListRequest,
|
|
41
|
-
CreateReportRequest,
|
|
42
|
-
OperationEnvelope,
|
|
43
|
-
UpdatePublishListOperation,
|
|
44
|
-
} from '../types.gen'
|
|
45
|
-
import type { TokenProvider } from './graphql/client'
|
|
46
|
-
import { GraphQLClientCache } from './graphql/client'
|
|
47
|
-
import {
|
|
48
|
-
GetLedgerPublishListDocument,
|
|
49
|
-
GetLedgerReportDocument,
|
|
50
|
-
GetLedgerStatementDocument,
|
|
51
|
-
ListLedgerPublishListsDocument,
|
|
52
|
-
ListLedgerReportsDocument,
|
|
53
|
-
type GetLedgerPublishListQuery,
|
|
54
|
-
type GetLedgerReportQuery,
|
|
55
|
-
type GetLedgerStatementQuery,
|
|
56
|
-
type ListLedgerPublishListsQuery,
|
|
57
|
-
type ListLedgerReportsQuery,
|
|
58
|
-
} from './graphql/generated/graphql'
|
|
59
|
-
|
|
60
|
-
// ── Types derived from GraphQL codegen ──────────────────────────────────
|
|
61
|
-
|
|
62
|
-
export type Report = NonNullable<GetLedgerReportQuery['report']>
|
|
63
|
-
export type ReportListItem = NonNullable<ListLedgerReportsQuery['reports']>['reports'][number]
|
|
64
|
-
export type StatementData = NonNullable<GetLedgerStatementQuery['statement']>
|
|
65
|
-
export type StatementPeriod = StatementData['periods'][number]
|
|
66
|
-
export type StatementRow = StatementData['rows'][number]
|
|
67
|
-
|
|
68
|
-
export type PublishList = NonNullable<
|
|
69
|
-
ListLedgerPublishListsQuery['publishLists']
|
|
70
|
-
>['publishLists'][number]
|
|
71
|
-
export type PublishListDetail = NonNullable<GetLedgerPublishListQuery['publishList']>
|
|
72
|
-
export type PublishListMember = PublishListDetail['members'][number]
|
|
73
|
-
|
|
74
|
-
// ── Caller-facing option interfaces ─────────────────────────────────────
|
|
75
|
-
|
|
76
|
-
export interface PeriodSpecInput {
|
|
77
|
-
start: string
|
|
78
|
-
end: string
|
|
79
|
-
label: string
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export interface CreateReportOptions {
|
|
83
|
-
name: string
|
|
84
|
-
mappingId: string
|
|
85
|
-
periodStart: string
|
|
86
|
-
periodEnd: string
|
|
87
|
-
taxonomyId?: string
|
|
88
|
-
periodType?: string
|
|
89
|
-
comparative?: boolean
|
|
90
|
-
/** When set, overrides periodStart/periodEnd/comparative with N explicit periods. */
|
|
91
|
-
periods?: PeriodSpecInput[]
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Envelope around a report operation. `status === "completed"` means the
|
|
96
|
-
* backend produced the report synchronously — `result` contains the
|
|
97
|
-
* freshly-created report shape (same fields as `ReportListItem`), so
|
|
98
|
-
* consumers can read `result?.id` immediately. For pending/failed
|
|
99
|
-
* dispatches, `result` is null and consumers should subscribe to
|
|
100
|
-
* `/v1/operations/{operationId}/stream` for progress.
|
|
101
|
-
*
|
|
102
|
-
* The loose `{ id; name; ... }` shape here intentionally mirrors the
|
|
103
|
-
* GraphQL `report` field without pulling in every nullable child relation
|
|
104
|
-
* — `create_report` and `regenerate_report` return a freshly-generated
|
|
105
|
-
* row, not a fully-resolved GraphQL projection.
|
|
106
|
-
*/
|
|
107
|
-
export interface ReportOperationAck {
|
|
108
|
-
operationId: string
|
|
109
|
-
status: OperationEnvelope['status']
|
|
110
|
-
/**
|
|
111
|
-
* Synchronous command result. Populated for `status === "completed"`
|
|
112
|
-
* dispatches where the backend produced the report inline.
|
|
113
|
-
*/
|
|
114
|
-
result: Record<string, unknown> | null
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// ── Client ──────────────────────────────────────────────────────────────
|
|
118
|
-
|
|
119
|
-
interface ReportClientConfig {
|
|
120
|
-
baseUrl: string
|
|
121
|
-
credentials?: 'include' | 'same-origin' | 'omit'
|
|
122
|
-
headers?: Record<string, string>
|
|
123
|
-
/** Static credential — use `tokenProvider` instead if the JWT rotates. */
|
|
124
|
-
token?: string
|
|
125
|
-
/**
|
|
126
|
-
* Dynamic credential callback. When set, invoked on every GraphQL
|
|
127
|
-
* request so refreshes flow through automatically.
|
|
128
|
-
*/
|
|
129
|
-
tokenProvider?: TokenProvider
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export class ReportClient {
|
|
133
|
-
private config: ReportClientConfig
|
|
134
|
-
private gql: GraphQLClientCache
|
|
135
|
-
|
|
136
|
-
constructor(config: ReportClientConfig) {
|
|
137
|
-
this.config = config
|
|
138
|
-
this.gql = new GraphQLClientCache(config)
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// ── Reports ─────────────────────────────────────────────────────────
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Kick off report creation (async). Use the returned `operationId` to
|
|
145
|
-
* subscribe to progress via SSE, then call `get()` once finished.
|
|
146
|
-
*/
|
|
147
|
-
async create(graphId: string, options: CreateReportOptions): Promise<ReportOperationAck> {
|
|
148
|
-
const body: CreateReportRequest = {
|
|
149
|
-
name: options.name,
|
|
150
|
-
mapping_id: options.mappingId,
|
|
151
|
-
period_start: options.periodStart,
|
|
152
|
-
period_end: options.periodEnd,
|
|
153
|
-
taxonomy_id: options.taxonomyId ?? 'tax_usgaap_reporting',
|
|
154
|
-
period_type: options.periodType ?? 'quarterly',
|
|
155
|
-
comparative: options.comparative ?? true,
|
|
156
|
-
}
|
|
157
|
-
if (options.periods && options.periods.length > 0) {
|
|
158
|
-
body.periods = options.periods
|
|
159
|
-
}
|
|
160
|
-
const envelope = await this.callOperation(
|
|
161
|
-
'Create report',
|
|
162
|
-
opCreateReport({ path: { graph_id: graphId }, body })
|
|
163
|
-
)
|
|
164
|
-
return {
|
|
165
|
-
operationId: envelope.operationId,
|
|
166
|
-
status: envelope.status,
|
|
167
|
-
result: (envelope.result as Record<string, unknown> | null) ?? null,
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/** List all reports for a graph (includes received shared reports). */
|
|
172
|
-
async list(graphId: string): Promise<ReportListItem[]> {
|
|
173
|
-
const list = await this.gqlQuery(
|
|
174
|
-
graphId,
|
|
175
|
-
ListLedgerReportsDocument,
|
|
176
|
-
undefined,
|
|
177
|
-
'List reports',
|
|
178
|
-
(data) => data.reports
|
|
179
|
-
)
|
|
180
|
-
return list?.reports ?? []
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/** Get a single report with its period list + available structures. */
|
|
184
|
-
async get(graphId: string, reportId: string): Promise<Report | null> {
|
|
185
|
-
return this.gqlQuery(
|
|
186
|
-
graphId,
|
|
187
|
-
GetLedgerReportDocument,
|
|
188
|
-
{ reportId },
|
|
189
|
-
'Get report',
|
|
190
|
-
(data) => data.report
|
|
191
|
-
)
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Render a financial statement — facts viewed through a structure.
|
|
196
|
-
*
|
|
197
|
-
* @param structureType - income_statement, balance_sheet, cash_flow_statement
|
|
198
|
-
*/
|
|
199
|
-
async statement(
|
|
200
|
-
graphId: string,
|
|
201
|
-
reportId: string,
|
|
202
|
-
structureType: string
|
|
203
|
-
): Promise<StatementData | null> {
|
|
204
|
-
return this.gqlQuery(
|
|
205
|
-
graphId,
|
|
206
|
-
GetLedgerStatementDocument,
|
|
207
|
-
{ reportId, structureType },
|
|
208
|
-
'Get statement',
|
|
209
|
-
(data) => data.statement
|
|
210
|
-
)
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Regenerate an existing report (async). Returns an operation id;
|
|
215
|
-
* subscribe via SSE for progress.
|
|
216
|
-
*/
|
|
217
|
-
async regenerate(
|
|
218
|
-
graphId: string,
|
|
219
|
-
reportId: string,
|
|
220
|
-
periodStart?: string,
|
|
221
|
-
periodEnd?: string
|
|
222
|
-
): Promise<ReportOperationAck> {
|
|
223
|
-
const envelope = await this.callOperation(
|
|
224
|
-
'Regenerate report',
|
|
225
|
-
opRegenerateReport({
|
|
226
|
-
path: { graph_id: graphId },
|
|
227
|
-
body: {
|
|
228
|
-
report_id: reportId,
|
|
229
|
-
period_start: periodStart,
|
|
230
|
-
period_end: periodEnd,
|
|
231
|
-
} as Parameters<typeof opRegenerateReport>[0]['body'],
|
|
232
|
-
})
|
|
233
|
-
)
|
|
234
|
-
return {
|
|
235
|
-
operationId: envelope.operationId,
|
|
236
|
-
status: envelope.status,
|
|
237
|
-
result: (envelope.result as Record<string, unknown> | null) ?? null,
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/** Delete a report and its generated facts. */
|
|
242
|
-
async delete(graphId: string, reportId: string): Promise<void> {
|
|
243
|
-
await this.callOperation(
|
|
244
|
-
'Delete report',
|
|
245
|
-
opDeleteReport({
|
|
246
|
-
path: { graph_id: graphId },
|
|
247
|
-
body: { report_id: reportId },
|
|
248
|
-
})
|
|
249
|
-
)
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Share a published report to every member of a publish list (async).
|
|
254
|
-
* Each target graph receives a snapshot copy of the report's facts.
|
|
255
|
-
*/
|
|
256
|
-
async share(
|
|
257
|
-
graphId: string,
|
|
258
|
-
reportId: string,
|
|
259
|
-
publishListId: string
|
|
260
|
-
): Promise<ReportOperationAck> {
|
|
261
|
-
const envelope = await this.callOperation(
|
|
262
|
-
'Share report',
|
|
263
|
-
opShareReport({
|
|
264
|
-
path: { graph_id: graphId },
|
|
265
|
-
body: {
|
|
266
|
-
report_id: reportId,
|
|
267
|
-
publish_list_id: publishListId,
|
|
268
|
-
} as Parameters<typeof opShareReport>[0]['body'],
|
|
269
|
-
})
|
|
270
|
-
)
|
|
271
|
-
return {
|
|
272
|
-
operationId: envelope.operationId,
|
|
273
|
-
status: envelope.status,
|
|
274
|
-
result: (envelope.result as Record<string, unknown> | null) ?? null,
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/** Check if a report was received via sharing (vs locally created). */
|
|
279
|
-
isSharedReport(report: Report): boolean {
|
|
280
|
-
return report.sourceGraphId !== null
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// ── Publish Lists ────────────────────────────────────────────────────
|
|
284
|
-
|
|
285
|
-
/** List publish lists with pagination. */
|
|
286
|
-
async listPublishLists(
|
|
287
|
-
graphId: string,
|
|
288
|
-
options?: { limit?: number; offset?: number }
|
|
289
|
-
): Promise<PublishList[]> {
|
|
290
|
-
const list = await this.gqlQuery(
|
|
291
|
-
graphId,
|
|
292
|
-
ListLedgerPublishListsDocument,
|
|
293
|
-
{
|
|
294
|
-
limit: options?.limit ?? 100,
|
|
295
|
-
offset: options?.offset ?? 0,
|
|
296
|
-
},
|
|
297
|
-
'List publish lists',
|
|
298
|
-
(data) => data.publishLists
|
|
299
|
-
)
|
|
300
|
-
return list?.publishLists ?? []
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
/** Create a new publish list. */
|
|
304
|
-
async createPublishList(
|
|
305
|
-
graphId: string,
|
|
306
|
-
name: string,
|
|
307
|
-
description?: string
|
|
308
|
-
): Promise<Record<string, unknown>> {
|
|
309
|
-
const body: CreatePublishListRequest = {
|
|
310
|
-
name,
|
|
311
|
-
description: description ?? null,
|
|
312
|
-
}
|
|
313
|
-
const envelope = await this.callOperation(
|
|
314
|
-
'Create publish list',
|
|
315
|
-
opCreatePublishList({ path: { graph_id: graphId }, body })
|
|
316
|
-
)
|
|
317
|
-
return (envelope.result ?? {}) as Record<string, unknown>
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
/** Get a single publish list with its full member list. */
|
|
321
|
-
async getPublishList(graphId: string, listId: string): Promise<PublishListDetail | null> {
|
|
322
|
-
return this.gqlQuery(
|
|
323
|
-
graphId,
|
|
324
|
-
GetLedgerPublishListDocument,
|
|
325
|
-
{ listId },
|
|
326
|
-
'Get publish list',
|
|
327
|
-
(data) => data.publishList
|
|
328
|
-
)
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/** Update a publish list's name or description. */
|
|
332
|
-
async updatePublishList(
|
|
333
|
-
graphId: string,
|
|
334
|
-
listId: string,
|
|
335
|
-
updates: { name?: string; description?: string | null }
|
|
336
|
-
): Promise<Record<string, unknown>> {
|
|
337
|
-
const envelope = await this.callOperation(
|
|
338
|
-
'Update publish list',
|
|
339
|
-
opUpdatePublishList({
|
|
340
|
-
path: { graph_id: graphId },
|
|
341
|
-
body: {
|
|
342
|
-
list_id: listId,
|
|
343
|
-
name: updates.name,
|
|
344
|
-
description: updates.description ?? null,
|
|
345
|
-
} as UpdatePublishListOperation,
|
|
346
|
-
})
|
|
347
|
-
)
|
|
348
|
-
return (envelope.result ?? {}) as Record<string, unknown>
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/** Delete a publish list. */
|
|
352
|
-
async deletePublishList(graphId: string, listId: string): Promise<void> {
|
|
353
|
-
await this.callOperation(
|
|
354
|
-
'Delete publish list',
|
|
355
|
-
opDeletePublishList({
|
|
356
|
-
path: { graph_id: graphId },
|
|
357
|
-
body: { list_id: listId },
|
|
358
|
-
})
|
|
359
|
-
)
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
/** Add target graphs as members of a publish list. */
|
|
363
|
-
async addMembers(
|
|
364
|
-
graphId: string,
|
|
365
|
-
listId: string,
|
|
366
|
-
targetGraphIds: string[]
|
|
367
|
-
): Promise<Record<string, unknown>> {
|
|
368
|
-
const envelope = await this.callOperation(
|
|
369
|
-
'Add publish list members',
|
|
370
|
-
opAddPublishListMembers({
|
|
371
|
-
path: { graph_id: graphId },
|
|
372
|
-
body: {
|
|
373
|
-
list_id: listId,
|
|
374
|
-
target_graph_ids: targetGraphIds,
|
|
375
|
-
} as AddPublishListMembersOperation,
|
|
376
|
-
})
|
|
377
|
-
)
|
|
378
|
-
return (envelope.result ?? {}) as Record<string, unknown>
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
/** Remove a single member from a publish list. */
|
|
382
|
-
async removeMember(
|
|
383
|
-
graphId: string,
|
|
384
|
-
listId: string,
|
|
385
|
-
memberId: string
|
|
386
|
-
): Promise<{ deleted: boolean }> {
|
|
387
|
-
const envelope = await this.callOperation(
|
|
388
|
-
'Remove publish list member',
|
|
389
|
-
opRemovePublishListMember({
|
|
390
|
-
path: { graph_id: graphId },
|
|
391
|
-
body: { list_id: listId, member_id: memberId },
|
|
392
|
-
})
|
|
393
|
-
)
|
|
394
|
-
return (envelope.result ?? { deleted: true }) as { deleted: boolean }
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
// ── Internal helpers ────────────────────────────────────────────────
|
|
398
|
-
|
|
399
|
-
private async gqlQuery<TData, TVars extends object, TResult>(
|
|
400
|
-
graphId: string,
|
|
401
|
-
document: TypedDocumentNode<TData, TVars>,
|
|
402
|
-
variables: TVars | undefined,
|
|
403
|
-
label: string,
|
|
404
|
-
pick: (data: TData) => TResult
|
|
405
|
-
): Promise<TResult> {
|
|
406
|
-
try {
|
|
407
|
-
const client = this.gql.get(graphId)
|
|
408
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
409
|
-
const raw = client.request as (doc: unknown, vars?: unknown) => Promise<any>
|
|
410
|
-
const data = (await raw.call(client, document, variables)) as TData
|
|
411
|
-
return pick(data)
|
|
412
|
-
} catch (err) {
|
|
413
|
-
if (err instanceof ClientError) {
|
|
414
|
-
throw new Error(`${label} failed: ${JSON.stringify(err.response.errors ?? err.message)}`)
|
|
415
|
-
}
|
|
416
|
-
throw err
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
private async callOperation(
|
|
421
|
-
label: string,
|
|
422
|
-
call: Promise<{ data?: OperationEnvelope; error?: unknown }>
|
|
423
|
-
): Promise<OperationEnvelope> {
|
|
424
|
-
const response = await call
|
|
425
|
-
if (response.error !== undefined) {
|
|
426
|
-
throw new Error(`${label} failed: ${JSON.stringify(response.error)}`)
|
|
427
|
-
}
|
|
428
|
-
if (response.data === undefined) {
|
|
429
|
-
throw new Error(`${label} failed: empty response`)
|
|
430
|
-
}
|
|
431
|
-
return response.data
|
|
432
|
-
}
|
|
433
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|