@robosystems/client 0.3.0 → 0.3.2
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.d.ts +7 -0
- package/{extensions → artifacts}/InvestorClient.js +0 -1
- package/{extensions → artifacts}/InvestorClient.ts +8 -1
- package/{extensions → artifacts}/LedgerClient.d.ts +175 -2
- package/{extensions → artifacts}/LedgerClient.js +301 -2
- package/{extensions → artifacts}/LedgerClient.ts +652 -2
- package/{extensions → artifacts}/config.d.ts +29 -10
- package/{extensions → artifacts}/config.js +11 -11
- package/{extensions → artifacts}/config.ts +36 -16
- package/artifacts/graphql/client.d.ts +82 -0
- package/artifacts/graphql/client.js +148 -0
- package/artifacts/graphql/client.ts +189 -0
- package/{extensions → artifacts}/hooks.js +6 -6
- package/{extensions → artifacts}/hooks.ts +7 -7
- package/{extensions → artifacts}/index.d.ts +34 -18
- package/{extensions → artifacts}/index.js +47 -44
- package/{extensions → artifacts}/index.ts +72 -52
- 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 +275 -274
- package/sdk/sdk.gen.js +469 -314
- package/sdk/sdk.gen.ts +465 -311
- package/sdk/types.gen.d.ts +2940 -466
- package/sdk/types.gen.ts +3053 -474
- package/sdk.gen.d.ts +275 -274
- package/sdk.gen.js +469 -314
- package/sdk.gen.ts +465 -311
- package/types.gen.d.ts +2940 -466
- package/types.gen.ts +3053 -474
- package/extensions/ReportClient.d.ts +0 -113
- package/extensions/ReportClient.js +0 -191
- package/extensions/ReportClient.ts +0 -426
- package/extensions/graphql/client.d.ts +0 -46
- package/extensions/graphql/client.js +0 -75
- package/extensions/graphql/client.ts +0 -82
- /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}/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
|
@@ -25,38 +25,90 @@
|
|
|
25
25
|
import type { TypedDocumentNode } from '@graphql-typed-document-node/core'
|
|
26
26
|
import { ClientError } from 'graphql-request'
|
|
27
27
|
import {
|
|
28
|
+
opAddPublishListMembers,
|
|
28
29
|
opAutoMapElements,
|
|
30
|
+
opBuildFactGrid,
|
|
29
31
|
opClosePeriod,
|
|
32
|
+
opCreateAssociations,
|
|
30
33
|
opCreateClosingEntry,
|
|
34
|
+
opCreateElement,
|
|
35
|
+
opCreateJournalEntry,
|
|
31
36
|
opCreateManualClosingEntry,
|
|
32
37
|
opCreateMappingAssociation,
|
|
38
|
+
opCreatePublishList,
|
|
39
|
+
opCreateReport,
|
|
33
40
|
opCreateSchedule,
|
|
34
41
|
opCreateStructure,
|
|
35
42
|
opCreateTaxonomy,
|
|
43
|
+
opDeleteAssociation,
|
|
44
|
+
opDeleteElement,
|
|
45
|
+
opDeleteJournalEntry,
|
|
36
46
|
opDeleteMappingAssociation,
|
|
47
|
+
opDeletePublishList,
|
|
48
|
+
opDeleteReport,
|
|
49
|
+
opDeleteSchedule,
|
|
50
|
+
opDeleteStructure,
|
|
51
|
+
opDeleteTaxonomy,
|
|
37
52
|
opInitializeLedger,
|
|
53
|
+
opLinkEntityTaxonomy,
|
|
54
|
+
opRegenerateReport,
|
|
55
|
+
opRemovePublishListMember,
|
|
38
56
|
opReopenPeriod,
|
|
57
|
+
opReverseJournalEntry,
|
|
39
58
|
opSetCloseTarget,
|
|
59
|
+
opShareReport,
|
|
40
60
|
opTruncateSchedule,
|
|
61
|
+
opUpdateAssociation,
|
|
62
|
+
opUpdateElement,
|
|
41
63
|
opUpdateEntity,
|
|
64
|
+
opUpdateJournalEntry,
|
|
65
|
+
opUpdatePublishList,
|
|
66
|
+
opUpdateSchedule,
|
|
67
|
+
opUpdateStructure,
|
|
68
|
+
opUpdateTaxonomy,
|
|
42
69
|
} from '../sdk.gen'
|
|
43
70
|
import type {
|
|
71
|
+
AddPublishListMembersOperation,
|
|
44
72
|
AutoMapElementsOperation,
|
|
73
|
+
BulkAssociationItem,
|
|
74
|
+
BulkCreateAssociationsRequest,
|
|
45
75
|
ClosePeriodOperation,
|
|
46
76
|
CreateClosingEntryOperation,
|
|
77
|
+
CreateElementRequest,
|
|
78
|
+
CreateJournalEntryRequest,
|
|
47
79
|
CreateManualClosingEntryRequest,
|
|
48
80
|
CreateMappingAssociationOperation,
|
|
81
|
+
CreatePublishListRequest,
|
|
82
|
+
CreateReportRequest,
|
|
49
83
|
CreateScheduleRequest,
|
|
50
84
|
CreateStructureRequest,
|
|
51
85
|
CreateTaxonomyRequest,
|
|
86
|
+
CreateViewRequest,
|
|
87
|
+
DeleteAssociationRequest,
|
|
88
|
+
DeleteElementRequest,
|
|
89
|
+
DeleteJournalEntryRequest,
|
|
52
90
|
DeleteMappingAssociationOperation,
|
|
91
|
+
DeleteScheduleRequest,
|
|
92
|
+
DeleteStructureRequest,
|
|
93
|
+
DeleteTaxonomyRequest,
|
|
53
94
|
InitializeLedgerRequest,
|
|
95
|
+
JournalEntryLineItemInput,
|
|
96
|
+
LinkEntityTaxonomyRequest,
|
|
54
97
|
OperationEnvelope,
|
|
55
98
|
ReopenPeriodOperation,
|
|
99
|
+
ReverseJournalEntryRequest,
|
|
56
100
|
SetCloseTargetOperation,
|
|
57
101
|
TruncateScheduleOperation,
|
|
102
|
+
UpdateAssociationRequest,
|
|
103
|
+
UpdateElementRequest,
|
|
58
104
|
UpdateEntityRequest,
|
|
105
|
+
UpdateJournalEntryRequest,
|
|
106
|
+
UpdatePublishListOperation,
|
|
107
|
+
UpdateScheduleRequest,
|
|
108
|
+
UpdateStructureRequest,
|
|
109
|
+
UpdateTaxonomyRequest,
|
|
59
110
|
} from '../types.gen'
|
|
111
|
+
import type { TokenProvider } from './graphql/client'
|
|
60
112
|
import { GraphQLClientCache } from './graphql/client'
|
|
61
113
|
import {
|
|
62
114
|
GetLedgerAccountRollupsDocument,
|
|
@@ -69,8 +121,11 @@ import {
|
|
|
69
121
|
GetLedgerMappingDocument,
|
|
70
122
|
GetLedgerPeriodCloseStatusDocument,
|
|
71
123
|
GetLedgerPeriodDraftsDocument,
|
|
124
|
+
GetLedgerPublishListDocument,
|
|
125
|
+
GetLedgerReportDocument,
|
|
72
126
|
GetLedgerReportingTaxonomyDocument,
|
|
73
127
|
GetLedgerScheduleFactsDocument,
|
|
128
|
+
GetLedgerStatementDocument,
|
|
74
129
|
GetLedgerSummaryDocument,
|
|
75
130
|
GetLedgerTransactionDocument,
|
|
76
131
|
GetLedgerTrialBalanceDocument,
|
|
@@ -78,6 +133,8 @@ import {
|
|
|
78
133
|
ListLedgerElementsDocument,
|
|
79
134
|
ListLedgerEntitiesDocument,
|
|
80
135
|
ListLedgerMappingsDocument,
|
|
136
|
+
ListLedgerPublishListsDocument,
|
|
137
|
+
ListLedgerReportsDocument,
|
|
81
138
|
ListLedgerSchedulesDocument,
|
|
82
139
|
ListLedgerStructuresDocument,
|
|
83
140
|
ListLedgerTaxonomiesDocument,
|
|
@@ -93,8 +150,11 @@ import {
|
|
|
93
150
|
type GetLedgerMappingQuery,
|
|
94
151
|
type GetLedgerPeriodCloseStatusQuery,
|
|
95
152
|
type GetLedgerPeriodDraftsQuery,
|
|
153
|
+
type GetLedgerPublishListQuery,
|
|
96
154
|
type GetLedgerReportingTaxonomyQuery,
|
|
155
|
+
type GetLedgerReportQuery,
|
|
97
156
|
type GetLedgerScheduleFactsQuery,
|
|
157
|
+
type GetLedgerStatementQuery,
|
|
98
158
|
type GetLedgerSummaryQuery,
|
|
99
159
|
type GetLedgerTransactionQuery,
|
|
100
160
|
type GetLedgerTrialBalanceQuery,
|
|
@@ -102,6 +162,8 @@ import {
|
|
|
102
162
|
type ListLedgerElementsQuery,
|
|
103
163
|
type ListLedgerEntitiesQuery,
|
|
104
164
|
type ListLedgerMappingsQuery,
|
|
165
|
+
type ListLedgerPublishListsQuery,
|
|
166
|
+
type ListLedgerReportsQuery,
|
|
105
167
|
type ListLedgerSchedulesQuery,
|
|
106
168
|
type ListLedgerStructuresQuery,
|
|
107
169
|
type ListLedgerTaxonomiesQuery,
|
|
@@ -173,6 +235,42 @@ export type LedgerClosingBookStructures = NonNullable<
|
|
|
173
235
|
export type LedgerFiscalCalendar = NonNullable<GetLedgerFiscalCalendarQuery['fiscalCalendar']>
|
|
174
236
|
export type LedgerFiscalPeriod = LedgerFiscalCalendar['periods'][number]
|
|
175
237
|
|
|
238
|
+
// Reports + publish lists + statements
|
|
239
|
+
export type Report = NonNullable<GetLedgerReportQuery['report']>
|
|
240
|
+
export type ReportListItem = NonNullable<ListLedgerReportsQuery['reports']>['reports'][number]
|
|
241
|
+
export type StatementData = NonNullable<GetLedgerStatementQuery['statement']>
|
|
242
|
+
export type StatementPeriod = StatementData['periods'][number]
|
|
243
|
+
export type StatementRow = StatementData['rows'][number]
|
|
244
|
+
|
|
245
|
+
export type PublishList = NonNullable<
|
|
246
|
+
ListLedgerPublishListsQuery['publishLists']
|
|
247
|
+
>['publishLists'][number]
|
|
248
|
+
export type PublishListDetail = NonNullable<GetLedgerPublishListQuery['publishList']>
|
|
249
|
+
export type PublishListMember = PublishListDetail['members'][number]
|
|
250
|
+
|
|
251
|
+
export interface PeriodSpecInput {
|
|
252
|
+
start: string
|
|
253
|
+
end: string
|
|
254
|
+
label: string
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export interface CreateReportOptions {
|
|
258
|
+
name: string
|
|
259
|
+
mappingId: string
|
|
260
|
+
periodStart: string
|
|
261
|
+
periodEnd: string
|
|
262
|
+
taxonomyId?: string
|
|
263
|
+
periodType?: string
|
|
264
|
+
comparative?: boolean
|
|
265
|
+
periods?: PeriodSpecInput[]
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export interface ReportOperationAck {
|
|
269
|
+
operationId: string
|
|
270
|
+
status: OperationEnvelope['status']
|
|
271
|
+
result: Record<string, unknown> | null
|
|
272
|
+
}
|
|
273
|
+
|
|
176
274
|
// ── Write result shapes (envelope.result payloads) ─────────────────────
|
|
177
275
|
//
|
|
178
276
|
// Backend Pydantic models serialize these write results in snake_case.
|
|
@@ -341,13 +439,36 @@ export interface CreateScheduleOptions {
|
|
|
341
439
|
}
|
|
342
440
|
}
|
|
343
441
|
|
|
442
|
+
export interface JournalEntryLineItem {
|
|
443
|
+
elementId: string
|
|
444
|
+
debitAmount?: number
|
|
445
|
+
creditAmount?: number
|
|
446
|
+
description?: string | null
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
export interface CreateJournalEntryOptions {
|
|
450
|
+
postingDate: string
|
|
451
|
+
memo: string
|
|
452
|
+
lineItems: JournalEntryLineItem[]
|
|
453
|
+
type?: LedgerEntryType
|
|
454
|
+
status?: 'draft' | 'posted'
|
|
455
|
+
transactionId?: string | null
|
|
456
|
+
idempotencyKey?: string | null
|
|
457
|
+
}
|
|
458
|
+
|
|
344
459
|
// ── Client ──────────────────────────────────────────────────────────────
|
|
345
460
|
|
|
346
461
|
interface LedgerClientConfig {
|
|
347
462
|
baseUrl: string
|
|
348
463
|
credentials?: 'include' | 'same-origin' | 'omit'
|
|
349
464
|
headers?: Record<string, string>
|
|
465
|
+
/** Static credential — use `tokenProvider` instead if the JWT rotates. */
|
|
350
466
|
token?: string
|
|
467
|
+
/**
|
|
468
|
+
* Dynamic credential callback. When set, invoked on every GraphQL
|
|
469
|
+
* request so refreshes flow through automatically.
|
|
470
|
+
*/
|
|
471
|
+
tokenProvider?: TokenProvider
|
|
351
472
|
}
|
|
352
473
|
|
|
353
474
|
export class LedgerClient {
|
|
@@ -595,6 +716,43 @@ export class LedgerClient {
|
|
|
595
716
|
return (envelope.result ?? {}) as Record<string, unknown>
|
|
596
717
|
}
|
|
597
718
|
|
|
719
|
+
/** Update mutable fields on a taxonomy. `taxonomy_type` is immutable. */
|
|
720
|
+
async updateTaxonomy(
|
|
721
|
+
graphId: string,
|
|
722
|
+
body: UpdateTaxonomyRequest
|
|
723
|
+
): Promise<Record<string, unknown>> {
|
|
724
|
+
const envelope = await this.callOperation(
|
|
725
|
+
'Update taxonomy',
|
|
726
|
+
opUpdateTaxonomy({ path: { graph_id: graphId }, body })
|
|
727
|
+
)
|
|
728
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
/** Soft-delete a taxonomy (`is_active=false`). */
|
|
732
|
+
async deleteTaxonomy(graphId: string, taxonomyId: string): Promise<Record<string, unknown>> {
|
|
733
|
+
const body: DeleteTaxonomyRequest = { taxonomy_id: taxonomyId }
|
|
734
|
+
const envelope = await this.callOperation(
|
|
735
|
+
'Delete taxonomy',
|
|
736
|
+
opDeleteTaxonomy({ path: { graph_id: graphId }, body })
|
|
737
|
+
)
|
|
738
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* Link the graph's entity to a taxonomy (ENTITY_HAS_TAXONOMY edge).
|
|
743
|
+
* Idempotent — returns existing linkage if already present.
|
|
744
|
+
*/
|
|
745
|
+
async linkEntityTaxonomy(
|
|
746
|
+
graphId: string,
|
|
747
|
+
body: LinkEntityTaxonomyRequest
|
|
748
|
+
): Promise<Record<string, unknown>> {
|
|
749
|
+
const envelope = await this.callOperation(
|
|
750
|
+
'Link entity taxonomy',
|
|
751
|
+
opLinkEntityTaxonomy({ path: { graph_id: graphId }, body })
|
|
752
|
+
)
|
|
753
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
754
|
+
}
|
|
755
|
+
|
|
598
756
|
/** List elements (CoA accounts, GAAP concepts, etc.) with filters. */
|
|
599
757
|
async listElements(
|
|
600
758
|
graphId: string,
|
|
@@ -637,6 +795,40 @@ export class LedgerClient {
|
|
|
637
795
|
)
|
|
638
796
|
}
|
|
639
797
|
|
|
798
|
+
/** Create a new element within a taxonomy (native CoA account, etc.). */
|
|
799
|
+
async createElement(
|
|
800
|
+
graphId: string,
|
|
801
|
+
body: CreateElementRequest
|
|
802
|
+
): Promise<Record<string, unknown>> {
|
|
803
|
+
const envelope = await this.callOperation(
|
|
804
|
+
'Create element',
|
|
805
|
+
opCreateElement({ path: { graph_id: graphId }, body })
|
|
806
|
+
)
|
|
807
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/** Update mutable fields on an element. `taxonomy_id` and `source` are immutable. */
|
|
811
|
+
async updateElement(
|
|
812
|
+
graphId: string,
|
|
813
|
+
body: UpdateElementRequest
|
|
814
|
+
): Promise<Record<string, unknown>> {
|
|
815
|
+
const envelope = await this.callOperation(
|
|
816
|
+
'Update element',
|
|
817
|
+
opUpdateElement({ path: { graph_id: graphId }, body })
|
|
818
|
+
)
|
|
819
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/** Soft-delete an element (`is_active=false`). */
|
|
823
|
+
async deleteElement(graphId: string, elementId: string): Promise<Record<string, unknown>> {
|
|
824
|
+
const body: DeleteElementRequest = { element_id: elementId }
|
|
825
|
+
const envelope = await this.callOperation(
|
|
826
|
+
'Delete element',
|
|
827
|
+
opDeleteElement({ path: { graph_id: graphId }, body })
|
|
828
|
+
)
|
|
829
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
830
|
+
}
|
|
831
|
+
|
|
640
832
|
// ── Structures ──────────────────────────────────────────────────────
|
|
641
833
|
|
|
642
834
|
/** List reporting structures (IS, BS, CF, schedules) with optional filters. */
|
|
@@ -669,6 +861,50 @@ export class LedgerClient {
|
|
|
669
861
|
return envelope.result as unknown as LedgerMappingInfo
|
|
670
862
|
}
|
|
671
863
|
|
|
864
|
+
/** Convenience wrapper — create a CoA→GAAP mapping structure. */
|
|
865
|
+
async createMappingStructure(
|
|
866
|
+
graphId: string,
|
|
867
|
+
options?: {
|
|
868
|
+
name?: string
|
|
869
|
+
description?: string | null
|
|
870
|
+
taxonomyId?: string
|
|
871
|
+
}
|
|
872
|
+
): Promise<LedgerMappingInfo> {
|
|
873
|
+
const body: CreateStructureRequest = {
|
|
874
|
+
name: options?.name ?? 'CoA to Reporting',
|
|
875
|
+
structure_type: 'coa_mapping',
|
|
876
|
+
taxonomy_id: options?.taxonomyId ?? 'tax_usgaap_reporting',
|
|
877
|
+
description: options?.description ?? 'Map Chart of Accounts to US GAAP reporting concepts',
|
|
878
|
+
}
|
|
879
|
+
const envelope = await this.callOperation(
|
|
880
|
+
'Create mapping structure',
|
|
881
|
+
opCreateStructure({ path: { graph_id: graphId }, body })
|
|
882
|
+
)
|
|
883
|
+
return envelope.result as unknown as LedgerMappingInfo
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
/** Update mutable fields on a structure. `structure_type` is immutable. */
|
|
887
|
+
async updateStructure(
|
|
888
|
+
graphId: string,
|
|
889
|
+
body: UpdateStructureRequest
|
|
890
|
+
): Promise<Record<string, unknown>> {
|
|
891
|
+
const envelope = await this.callOperation(
|
|
892
|
+
'Update structure',
|
|
893
|
+
opUpdateStructure({ path: { graph_id: graphId }, body })
|
|
894
|
+
)
|
|
895
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
/** Soft-delete a structure (`is_active=false`). */
|
|
899
|
+
async deleteStructure(graphId: string, structureId: string): Promise<Record<string, unknown>> {
|
|
900
|
+
const body: DeleteStructureRequest = { structure_id: structureId }
|
|
901
|
+
const envelope = await this.callOperation(
|
|
902
|
+
'Delete structure',
|
|
903
|
+
opDeleteStructure({ path: { graph_id: graphId }, body })
|
|
904
|
+
)
|
|
905
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
906
|
+
}
|
|
907
|
+
|
|
672
908
|
// ── Mappings ────────────────────────────────────────────────────────
|
|
673
909
|
|
|
674
910
|
/** List active CoA→reporting mapping structures. */
|
|
@@ -748,6 +984,42 @@ export class LedgerClient {
|
|
|
748
984
|
return { operationId: envelope.operationId, status: envelope.status }
|
|
749
985
|
}
|
|
750
986
|
|
|
987
|
+
/** Bulk create associations within a single structure, atomically. */
|
|
988
|
+
async createAssociations(
|
|
989
|
+
graphId: string,
|
|
990
|
+
structureId: string,
|
|
991
|
+
associations: BulkAssociationItem[]
|
|
992
|
+
): Promise<Record<string, unknown>> {
|
|
993
|
+
const body: BulkCreateAssociationsRequest = { structure_id: structureId, associations }
|
|
994
|
+
const envelope = await this.callOperation(
|
|
995
|
+
'Create associations',
|
|
996
|
+
opCreateAssociations({ path: { graph_id: graphId }, body })
|
|
997
|
+
)
|
|
998
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
/** Update mutable fields on an association (order, weight, confidence). */
|
|
1002
|
+
async updateAssociation(
|
|
1003
|
+
graphId: string,
|
|
1004
|
+
body: UpdateAssociationRequest
|
|
1005
|
+
): Promise<Record<string, unknown>> {
|
|
1006
|
+
const envelope = await this.callOperation(
|
|
1007
|
+
'Update association',
|
|
1008
|
+
opUpdateAssociation({ path: { graph_id: graphId }, body })
|
|
1009
|
+
)
|
|
1010
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
/** Hard-delete an association (any type: presentation, calculation, mapping). */
|
|
1014
|
+
async deleteAssociation(graphId: string, associationId: string): Promise<{ deleted: boolean }> {
|
|
1015
|
+
const body: DeleteAssociationRequest = { association_id: associationId }
|
|
1016
|
+
const envelope = await this.callOperation(
|
|
1017
|
+
'Delete association',
|
|
1018
|
+
opDeleteAssociation({ path: { graph_id: graphId }, body })
|
|
1019
|
+
)
|
|
1020
|
+
return (envelope.result ?? { deleted: true }) as { deleted: boolean }
|
|
1021
|
+
}
|
|
1022
|
+
|
|
751
1023
|
// ── Schedules ──────────────────────────────────────────────────────
|
|
752
1024
|
|
|
753
1025
|
/** List all schedule structures with metadata. */
|
|
@@ -821,6 +1093,28 @@ export class LedgerClient {
|
|
|
821
1093
|
}
|
|
822
1094
|
}
|
|
823
1095
|
|
|
1096
|
+
/** Update mutable fields on a schedule (name, entry_template, metadata). */
|
|
1097
|
+
async updateSchedule(
|
|
1098
|
+
graphId: string,
|
|
1099
|
+
body: UpdateScheduleRequest
|
|
1100
|
+
): Promise<Record<string, unknown>> {
|
|
1101
|
+
const envelope = await this.callOperation(
|
|
1102
|
+
'Update schedule',
|
|
1103
|
+
opUpdateSchedule({ path: { graph_id: graphId }, body })
|
|
1104
|
+
)
|
|
1105
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
/** Permanently delete a schedule (cascades through facts + associations). */
|
|
1109
|
+
async deleteSchedule(graphId: string, structureId: string): Promise<{ deleted: boolean }> {
|
|
1110
|
+
const body: DeleteScheduleRequest = { structure_id: structureId }
|
|
1111
|
+
const envelope = await this.callOperation(
|
|
1112
|
+
'Delete schedule',
|
|
1113
|
+
opDeleteSchedule({ path: { graph_id: graphId }, body })
|
|
1114
|
+
)
|
|
1115
|
+
return (envelope.result ?? { deleted: true }) as { deleted: boolean }
|
|
1116
|
+
}
|
|
1117
|
+
|
|
824
1118
|
/** Truncate a schedule — end it early at `newEndDate`. */
|
|
825
1119
|
async truncateSchedule(
|
|
826
1120
|
graphId: string,
|
|
@@ -1032,7 +1326,105 @@ export class LedgerClient {
|
|
|
1032
1326
|
return rawFiscalCalendarToCamel(envelope.result as unknown as RawFiscalCalendar)
|
|
1033
1327
|
}
|
|
1034
1328
|
|
|
1035
|
-
//
|
|
1329
|
+
// ── Journal entries (native accounting writes) ──────────────────────
|
|
1330
|
+
|
|
1331
|
+
/**
|
|
1332
|
+
* Create a journal entry with balanced line items (DR=CR enforced).
|
|
1333
|
+
*
|
|
1334
|
+
* Defaults to `status='draft'`. Pass `status='posted'` for historical
|
|
1335
|
+
* data import where entries represent already-happened business events.
|
|
1336
|
+
*
|
|
1337
|
+
* Supply `idempotencyKey` to make the call safe to retry — replays
|
|
1338
|
+
* within 24 hours return the same envelope. Reusing the key with a
|
|
1339
|
+
* different body returns HTTP 409.
|
|
1340
|
+
*/
|
|
1341
|
+
async createJournalEntry(
|
|
1342
|
+
graphId: string,
|
|
1343
|
+
options: CreateJournalEntryOptions
|
|
1344
|
+
): Promise<Record<string, unknown>> {
|
|
1345
|
+
const body: CreateJournalEntryRequest = {
|
|
1346
|
+
posting_date: options.postingDate,
|
|
1347
|
+
memo: options.memo,
|
|
1348
|
+
line_items: options.lineItems.map(
|
|
1349
|
+
(li): JournalEntryLineItemInput => ({
|
|
1350
|
+
element_id: li.elementId,
|
|
1351
|
+
debit_amount: li.debitAmount,
|
|
1352
|
+
credit_amount: li.creditAmount,
|
|
1353
|
+
description: li.description ?? null,
|
|
1354
|
+
})
|
|
1355
|
+
),
|
|
1356
|
+
type: options.type,
|
|
1357
|
+
status: options.status,
|
|
1358
|
+
transaction_id: options.transactionId ?? null,
|
|
1359
|
+
}
|
|
1360
|
+
const envelope = await this.callOperation(
|
|
1361
|
+
'Create journal entry',
|
|
1362
|
+
opCreateJournalEntry({ path: { graph_id: graphId }, body })
|
|
1363
|
+
)
|
|
1364
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
/** Update a draft journal entry. Posted entries are immutable. */
|
|
1368
|
+
async updateJournalEntry(
|
|
1369
|
+
graphId: string,
|
|
1370
|
+
body: UpdateJournalEntryRequest
|
|
1371
|
+
): Promise<Record<string, unknown>> {
|
|
1372
|
+
const envelope = await this.callOperation(
|
|
1373
|
+
'Update journal entry',
|
|
1374
|
+
opUpdateJournalEntry({ path: { graph_id: graphId }, body })
|
|
1375
|
+
)
|
|
1376
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
/** Hard-delete a draft journal entry. Posted entries must be reversed. */
|
|
1380
|
+
async deleteJournalEntry(graphId: string, entryId: string): Promise<{ deleted: boolean }> {
|
|
1381
|
+
const body: DeleteJournalEntryRequest = { entry_id: entryId }
|
|
1382
|
+
const envelope = await this.callOperation(
|
|
1383
|
+
'Delete journal entry',
|
|
1384
|
+
opDeleteJournalEntry({ path: { graph_id: graphId }, body })
|
|
1385
|
+
)
|
|
1386
|
+
return (envelope.result ?? { deleted: true }) as { deleted: boolean }
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
/**
|
|
1390
|
+
* Reverse a posted journal entry — creates an offsetting entry and marks
|
|
1391
|
+
* the original as reversed.
|
|
1392
|
+
*/
|
|
1393
|
+
async reverseJournalEntry(
|
|
1394
|
+
graphId: string,
|
|
1395
|
+
entryId: string,
|
|
1396
|
+
options?: { postingDate?: string | null; memo?: string | null }
|
|
1397
|
+
): Promise<Record<string, unknown>> {
|
|
1398
|
+
const body: ReverseJournalEntryRequest = {
|
|
1399
|
+
entry_id: entryId,
|
|
1400
|
+
posting_date: options?.postingDate ?? null,
|
|
1401
|
+
memo: options?.memo ?? null,
|
|
1402
|
+
}
|
|
1403
|
+
const envelope = await this.callOperation(
|
|
1404
|
+
'Reverse journal entry',
|
|
1405
|
+
opReverseJournalEntry({ path: { graph_id: graphId }, body })
|
|
1406
|
+
)
|
|
1407
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
// ── Fact grid (graph-backed analytical query) ─────────────────────
|
|
1411
|
+
|
|
1412
|
+
/**
|
|
1413
|
+
* Build a multi-dimensional fact grid against the graph schema.
|
|
1414
|
+
*
|
|
1415
|
+
* Runs against LadybugDB (not the extensions OLTP database) and returns
|
|
1416
|
+
* a deduplicated pivot table of XBRL facts. Works for both roboledger
|
|
1417
|
+
* tenant graphs (after materialization) and the SEC shared repository.
|
|
1418
|
+
*/
|
|
1419
|
+
async buildFactGrid(graphId: string, body: CreateViewRequest): Promise<Record<string, unknown>> {
|
|
1420
|
+
const envelope = await this.callOperation(
|
|
1421
|
+
'Build fact grid',
|
|
1422
|
+
opBuildFactGrid({ path: { graph_id: graphId }, body })
|
|
1423
|
+
)
|
|
1424
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
// ── Reports, statements, and publish lists ──────────────────────────────
|
|
1036
1428
|
|
|
1037
1429
|
// ── Internal helpers ────────────────────────────────────────────────
|
|
1038
1430
|
|
|
@@ -1049,7 +1441,7 @@ export class LedgerClient {
|
|
|
1049
1441
|
): Promise<TResult> {
|
|
1050
1442
|
try {
|
|
1051
1443
|
const client = this.gql.get(graphId)
|
|
1052
|
-
|
|
1444
|
+
|
|
1053
1445
|
const raw = client.request as (doc: unknown, vars?: unknown) => Promise<any>
|
|
1054
1446
|
// graphql-request's overloads don't cleanly resolve for generic
|
|
1055
1447
|
// helpers wrapping codegen's `Exact<>` var types, so we bypass
|
|
@@ -1064,6 +1456,264 @@ export class LedgerClient {
|
|
|
1064
1456
|
}
|
|
1065
1457
|
}
|
|
1066
1458
|
|
|
1459
|
+
// ── Reports ─────────────────────────────────────────────────────────
|
|
1460
|
+
|
|
1461
|
+
/**
|
|
1462
|
+
* Kick off report creation (async). Use the returned `operationId` to
|
|
1463
|
+
* subscribe to progress via SSE, then call `getReport()` once finished.
|
|
1464
|
+
*/
|
|
1465
|
+
async createReport(graphId: string, options: CreateReportOptions): Promise<ReportOperationAck> {
|
|
1466
|
+
const body: CreateReportRequest = {
|
|
1467
|
+
name: options.name,
|
|
1468
|
+
mapping_id: options.mappingId,
|
|
1469
|
+
period_start: options.periodStart,
|
|
1470
|
+
period_end: options.periodEnd,
|
|
1471
|
+
taxonomy_id: options.taxonomyId ?? 'tax_usgaap_reporting',
|
|
1472
|
+
period_type: options.periodType ?? 'quarterly',
|
|
1473
|
+
comparative: options.comparative ?? true,
|
|
1474
|
+
}
|
|
1475
|
+
if (options.periods && options.periods.length > 0) {
|
|
1476
|
+
body.periods = options.periods
|
|
1477
|
+
}
|
|
1478
|
+
const envelope = await this.callOperation(
|
|
1479
|
+
'Create report',
|
|
1480
|
+
opCreateReport({ path: { graph_id: graphId }, body })
|
|
1481
|
+
)
|
|
1482
|
+
return {
|
|
1483
|
+
operationId: envelope.operationId,
|
|
1484
|
+
status: envelope.status,
|
|
1485
|
+
result: (envelope.result as Record<string, unknown> | null) ?? null,
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
/** List all reports for a graph (includes received shared reports). */
|
|
1490
|
+
async listReports(graphId: string): Promise<ReportListItem[]> {
|
|
1491
|
+
const list = await this.gqlQuery(
|
|
1492
|
+
graphId,
|
|
1493
|
+
ListLedgerReportsDocument,
|
|
1494
|
+
undefined,
|
|
1495
|
+
'List reports',
|
|
1496
|
+
(data) => data.reports
|
|
1497
|
+
)
|
|
1498
|
+
return list?.reports ?? []
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
/** Get a single report with its period list + available structures. */
|
|
1502
|
+
async getReport(graphId: string, reportId: string): Promise<Report | null> {
|
|
1503
|
+
return this.gqlQuery(
|
|
1504
|
+
graphId,
|
|
1505
|
+
GetLedgerReportDocument,
|
|
1506
|
+
{ reportId },
|
|
1507
|
+
'Get report',
|
|
1508
|
+
(data) => data.report
|
|
1509
|
+
)
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
/**
|
|
1513
|
+
* Render a financial statement — facts viewed through a structure.
|
|
1514
|
+
*
|
|
1515
|
+
* @param structureType - income_statement, balance_sheet, cash_flow_statement
|
|
1516
|
+
*/
|
|
1517
|
+
async getStatement(
|
|
1518
|
+
graphId: string,
|
|
1519
|
+
reportId: string,
|
|
1520
|
+
structureType: string
|
|
1521
|
+
): Promise<StatementData | null> {
|
|
1522
|
+
return this.gqlQuery(
|
|
1523
|
+
graphId,
|
|
1524
|
+
GetLedgerStatementDocument,
|
|
1525
|
+
{ reportId, structureType },
|
|
1526
|
+
'Get statement',
|
|
1527
|
+
(data) => data.statement
|
|
1528
|
+
)
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
/**
|
|
1532
|
+
* Regenerate an existing report (async). Returns an operation id;
|
|
1533
|
+
* subscribe via SSE for progress.
|
|
1534
|
+
*/
|
|
1535
|
+
async regenerateReport(
|
|
1536
|
+
graphId: string,
|
|
1537
|
+
reportId: string,
|
|
1538
|
+
periodStart?: string,
|
|
1539
|
+
periodEnd?: string
|
|
1540
|
+
): Promise<ReportOperationAck> {
|
|
1541
|
+
const envelope = await this.callOperation(
|
|
1542
|
+
'Regenerate report',
|
|
1543
|
+
opRegenerateReport({
|
|
1544
|
+
path: { graph_id: graphId },
|
|
1545
|
+
body: {
|
|
1546
|
+
report_id: reportId,
|
|
1547
|
+
period_start: periodStart,
|
|
1548
|
+
period_end: periodEnd,
|
|
1549
|
+
} as Parameters<typeof opRegenerateReport>[0]['body'],
|
|
1550
|
+
})
|
|
1551
|
+
)
|
|
1552
|
+
return {
|
|
1553
|
+
operationId: envelope.operationId,
|
|
1554
|
+
status: envelope.status,
|
|
1555
|
+
result: (envelope.result as Record<string, unknown> | null) ?? null,
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
/** Delete a report and its generated facts. */
|
|
1560
|
+
async deleteReport(graphId: string, reportId: string): Promise<void> {
|
|
1561
|
+
await this.callOperation(
|
|
1562
|
+
'Delete report',
|
|
1563
|
+
opDeleteReport({
|
|
1564
|
+
path: { graph_id: graphId },
|
|
1565
|
+
body: { report_id: reportId },
|
|
1566
|
+
})
|
|
1567
|
+
)
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
/**
|
|
1571
|
+
* Share a published report to every member of a publish list (async).
|
|
1572
|
+
* Each target graph receives a snapshot copy of the report's facts.
|
|
1573
|
+
*/
|
|
1574
|
+
async shareReport(
|
|
1575
|
+
graphId: string,
|
|
1576
|
+
reportId: string,
|
|
1577
|
+
publishListId: string
|
|
1578
|
+
): Promise<ReportOperationAck> {
|
|
1579
|
+
const envelope = await this.callOperation(
|
|
1580
|
+
'Share report',
|
|
1581
|
+
opShareReport({
|
|
1582
|
+
path: { graph_id: graphId },
|
|
1583
|
+
body: {
|
|
1584
|
+
report_id: reportId,
|
|
1585
|
+
publish_list_id: publishListId,
|
|
1586
|
+
} as Parameters<typeof opShareReport>[0]['body'],
|
|
1587
|
+
})
|
|
1588
|
+
)
|
|
1589
|
+
return {
|
|
1590
|
+
operationId: envelope.operationId,
|
|
1591
|
+
status: envelope.status,
|
|
1592
|
+
result: (envelope.result as Record<string, unknown> | null) ?? null,
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
/** Check if a report was received via sharing (vs locally created). */
|
|
1597
|
+
isSharedReport(report: Report): boolean {
|
|
1598
|
+
return report.sourceGraphId !== null
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
// ── Publish Lists ────────────────────────────────────────────────────
|
|
1602
|
+
|
|
1603
|
+
/** List publish lists with pagination. */
|
|
1604
|
+
async listPublishLists(
|
|
1605
|
+
graphId: string,
|
|
1606
|
+
options?: { limit?: number; offset?: number }
|
|
1607
|
+
): Promise<PublishList[]> {
|
|
1608
|
+
const list = await this.gqlQuery(
|
|
1609
|
+
graphId,
|
|
1610
|
+
ListLedgerPublishListsDocument,
|
|
1611
|
+
{
|
|
1612
|
+
limit: options?.limit ?? 100,
|
|
1613
|
+
offset: options?.offset ?? 0,
|
|
1614
|
+
},
|
|
1615
|
+
'List publish lists',
|
|
1616
|
+
(data) => data.publishLists
|
|
1617
|
+
)
|
|
1618
|
+
return list?.publishLists ?? []
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
/** Create a new publish list. */
|
|
1622
|
+
async createPublishList(
|
|
1623
|
+
graphId: string,
|
|
1624
|
+
name: string,
|
|
1625
|
+
description?: string
|
|
1626
|
+
): Promise<Record<string, unknown>> {
|
|
1627
|
+
const body: CreatePublishListRequest = {
|
|
1628
|
+
name,
|
|
1629
|
+
description: description ?? null,
|
|
1630
|
+
}
|
|
1631
|
+
const envelope = await this.callOperation(
|
|
1632
|
+
'Create publish list',
|
|
1633
|
+
opCreatePublishList({ path: { graph_id: graphId }, body })
|
|
1634
|
+
)
|
|
1635
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
/** Get a single publish list with its full member list. */
|
|
1639
|
+
async getPublishList(graphId: string, listId: string): Promise<PublishListDetail | null> {
|
|
1640
|
+
return this.gqlQuery(
|
|
1641
|
+
graphId,
|
|
1642
|
+
GetLedgerPublishListDocument,
|
|
1643
|
+
{ listId },
|
|
1644
|
+
'Get publish list',
|
|
1645
|
+
(data) => data.publishList
|
|
1646
|
+
)
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
/** Update a publish list's name or description. */
|
|
1650
|
+
async updatePublishList(
|
|
1651
|
+
graphId: string,
|
|
1652
|
+
listId: string,
|
|
1653
|
+
updates: { name?: string; description?: string | null }
|
|
1654
|
+
): Promise<Record<string, unknown>> {
|
|
1655
|
+
const envelope = await this.callOperation(
|
|
1656
|
+
'Update publish list',
|
|
1657
|
+
opUpdatePublishList({
|
|
1658
|
+
path: { graph_id: graphId },
|
|
1659
|
+
body: {
|
|
1660
|
+
list_id: listId,
|
|
1661
|
+
name: updates.name,
|
|
1662
|
+
description: updates.description ?? null,
|
|
1663
|
+
} as UpdatePublishListOperation,
|
|
1664
|
+
})
|
|
1665
|
+
)
|
|
1666
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
/** Delete a publish list. */
|
|
1670
|
+
async deletePublishList(graphId: string, listId: string): Promise<void> {
|
|
1671
|
+
await this.callOperation(
|
|
1672
|
+
'Delete publish list',
|
|
1673
|
+
opDeletePublishList({
|
|
1674
|
+
path: { graph_id: graphId },
|
|
1675
|
+
body: { list_id: listId },
|
|
1676
|
+
})
|
|
1677
|
+
)
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
/** Add target graphs as members of a publish list. */
|
|
1681
|
+
async addPublishListMembers(
|
|
1682
|
+
graphId: string,
|
|
1683
|
+
listId: string,
|
|
1684
|
+
targetGraphIds: string[]
|
|
1685
|
+
): Promise<Record<string, unknown>> {
|
|
1686
|
+
const envelope = await this.callOperation(
|
|
1687
|
+
'Add publish list members',
|
|
1688
|
+
opAddPublishListMembers({
|
|
1689
|
+
path: { graph_id: graphId },
|
|
1690
|
+
body: {
|
|
1691
|
+
list_id: listId,
|
|
1692
|
+
target_graph_ids: targetGraphIds,
|
|
1693
|
+
} as AddPublishListMembersOperation,
|
|
1694
|
+
})
|
|
1695
|
+
)
|
|
1696
|
+
return (envelope.result ?? {}) as Record<string, unknown>
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
/** Remove a single member from a publish list. */
|
|
1700
|
+
async removePublishListMember(
|
|
1701
|
+
graphId: string,
|
|
1702
|
+
listId: string,
|
|
1703
|
+
memberId: string
|
|
1704
|
+
): Promise<{ deleted: boolean }> {
|
|
1705
|
+
const envelope = await this.callOperation(
|
|
1706
|
+
'Remove publish list member',
|
|
1707
|
+
opRemovePublishListMember({
|
|
1708
|
+
path: { graph_id: graphId },
|
|
1709
|
+
body: { list_id: listId, member_id: memberId },
|
|
1710
|
+
})
|
|
1711
|
+
)
|
|
1712
|
+
return (envelope.result ?? { deleted: true }) as { deleted: boolean }
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
// ── Internal helpers ────────────────────────────────────────────────
|
|
1716
|
+
|
|
1067
1717
|
/**
|
|
1068
1718
|
* Await an SDK-generated `opXxx(...)` call, throw a readable error on
|
|
1069
1719
|
* non-2xx, and return the `OperationEnvelope` on success.
|