@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.
Files changed (161) hide show
  1. package/{extensions → artifacts}/InvestorClient.js +0 -1
  2. package/{extensions → artifacts}/InvestorClient.ts +1 -1
  3. package/{extensions → artifacts}/LedgerClient.d.ts +168 -2
  4. package/{extensions → artifacts}/LedgerClient.js +301 -2
  5. package/{extensions → artifacts}/LedgerClient.ts +645 -2
  6. package/{extensions → artifacts}/config.d.ts +11 -11
  7. package/{extensions → artifacts}/config.js +11 -11
  8. package/{extensions → artifacts}/config.ts +16 -16
  9. package/{extensions → artifacts}/graphql/client.d.ts +1 -1
  10. package/{extensions → artifacts}/graphql/client.js +1 -2
  11. package/{extensions → artifacts}/graphql/client.ts +2 -2
  12. package/{extensions → artifacts}/hooks.js +6 -6
  13. package/{extensions → artifacts}/hooks.ts +7 -7
  14. package/{extensions → artifacts}/index.d.ts +21 -18
  15. package/{extensions → artifacts}/index.js +43 -53
  16. package/{extensions → artifacts}/index.ts +47 -60
  17. package/index.d.ts +2 -2
  18. package/index.js +2 -2
  19. package/index.ts +2 -2
  20. package/package.json +38 -8
  21. package/sdk/index.d.ts +2 -2
  22. package/sdk/index.js +27 -9
  23. package/sdk/index.ts +2 -2
  24. package/sdk/sdk.gen.d.ts +272 -274
  25. package/sdk/sdk.gen.js +468 -312
  26. package/sdk/sdk.gen.ts +464 -309
  27. package/sdk/types.gen.d.ts +2962 -440
  28. package/sdk/types.gen.ts +3058 -430
  29. package/sdk.gen.d.ts +272 -274
  30. package/sdk.gen.js +468 -312
  31. package/sdk.gen.ts +464 -309
  32. package/types.gen.d.ts +2962 -440
  33. package/types.gen.ts +3058 -430
  34. package/extensions/ReportClient.d.ts +0 -120
  35. package/extensions/ReportClient.js +0 -191
  36. package/extensions/ReportClient.ts +0 -433
  37. /package/{extensions → artifacts}/AgentClient.d.ts +0 -0
  38. /package/{extensions → artifacts}/AgentClient.js +0 -0
  39. /package/{extensions → artifacts}/AgentClient.ts +0 -0
  40. /package/{extensions → artifacts}/InvestorClient.d.ts +0 -0
  41. /package/{extensions → artifacts}/OperationClient.d.ts +0 -0
  42. /package/{extensions → artifacts}/OperationClient.js +0 -0
  43. /package/{extensions → artifacts}/OperationClient.ts +0 -0
  44. /package/{extensions → artifacts}/QueryClient.d.ts +0 -0
  45. /package/{extensions → artifacts}/QueryClient.js +0 -0
  46. /package/{extensions → artifacts}/QueryClient.ts +0 -0
  47. /package/{extensions → artifacts}/SSEClient.d.ts +0 -0
  48. /package/{extensions → artifacts}/SSEClient.js +0 -0
  49. /package/{extensions → artifacts}/SSEClient.ts +0 -0
  50. /package/{extensions → artifacts}/graphql/generated/graphql.d.ts +0 -0
  51. /package/{extensions → artifacts}/graphql/generated/graphql.js +0 -0
  52. /package/{extensions → artifacts}/graphql/generated/graphql.ts +0 -0
  53. /package/{extensions → artifacts}/graphql/queries/investor/holdings.d.ts +0 -0
  54. /package/{extensions → artifacts}/graphql/queries/investor/holdings.js +0 -0
  55. /package/{extensions → artifacts}/graphql/queries/investor/holdings.ts +0 -0
  56. /package/{extensions → artifacts}/graphql/queries/investor/portfolio.d.ts +0 -0
  57. /package/{extensions → artifacts}/graphql/queries/investor/portfolio.js +0 -0
  58. /package/{extensions → artifacts}/graphql/queries/investor/portfolio.ts +0 -0
  59. /package/{extensions → artifacts}/graphql/queries/investor/portfolios.d.ts +0 -0
  60. /package/{extensions → artifacts}/graphql/queries/investor/portfolios.js +0 -0
  61. /package/{extensions → artifacts}/graphql/queries/investor/portfolios.ts +0 -0
  62. /package/{extensions → artifacts}/graphql/queries/investor/position.d.ts +0 -0
  63. /package/{extensions → artifacts}/graphql/queries/investor/position.js +0 -0
  64. /package/{extensions → artifacts}/graphql/queries/investor/position.ts +0 -0
  65. /package/{extensions → artifacts}/graphql/queries/investor/positions.d.ts +0 -0
  66. /package/{extensions → artifacts}/graphql/queries/investor/positions.js +0 -0
  67. /package/{extensions → artifacts}/graphql/queries/investor/positions.ts +0 -0
  68. /package/{extensions → artifacts}/graphql/queries/investor/securities.d.ts +0 -0
  69. /package/{extensions → artifacts}/graphql/queries/investor/securities.js +0 -0
  70. /package/{extensions → artifacts}/graphql/queries/investor/securities.ts +0 -0
  71. /package/{extensions → artifacts}/graphql/queries/investor/security.d.ts +0 -0
  72. /package/{extensions → artifacts}/graphql/queries/investor/security.js +0 -0
  73. /package/{extensions → artifacts}/graphql/queries/investor/security.ts +0 -0
  74. /package/{extensions → artifacts}/graphql/queries/ledger/accountRollups.d.ts +0 -0
  75. /package/{extensions → artifacts}/graphql/queries/ledger/accountRollups.js +0 -0
  76. /package/{extensions → artifacts}/graphql/queries/ledger/accountRollups.ts +0 -0
  77. /package/{extensions → artifacts}/graphql/queries/ledger/accountTree.d.ts +0 -0
  78. /package/{extensions → artifacts}/graphql/queries/ledger/accountTree.js +0 -0
  79. /package/{extensions → artifacts}/graphql/queries/ledger/accountTree.ts +0 -0
  80. /package/{extensions → artifacts}/graphql/queries/ledger/accounts.d.ts +0 -0
  81. /package/{extensions → artifacts}/graphql/queries/ledger/accounts.js +0 -0
  82. /package/{extensions → artifacts}/graphql/queries/ledger/accounts.ts +0 -0
  83. /package/{extensions → artifacts}/graphql/queries/ledger/closingBookStructures.d.ts +0 -0
  84. /package/{extensions → artifacts}/graphql/queries/ledger/closingBookStructures.js +0 -0
  85. /package/{extensions → artifacts}/graphql/queries/ledger/closingBookStructures.ts +0 -0
  86. /package/{extensions → artifacts}/graphql/queries/ledger/elements.d.ts +0 -0
  87. /package/{extensions → artifacts}/graphql/queries/ledger/elements.js +0 -0
  88. /package/{extensions → artifacts}/graphql/queries/ledger/elements.ts +0 -0
  89. /package/{extensions → artifacts}/graphql/queries/ledger/entities.d.ts +0 -0
  90. /package/{extensions → artifacts}/graphql/queries/ledger/entities.js +0 -0
  91. /package/{extensions → artifacts}/graphql/queries/ledger/entities.ts +0 -0
  92. /package/{extensions → artifacts}/graphql/queries/ledger/entity.d.ts +0 -0
  93. /package/{extensions → artifacts}/graphql/queries/ledger/entity.js +0 -0
  94. /package/{extensions → artifacts}/graphql/queries/ledger/entity.ts +0 -0
  95. /package/{extensions → artifacts}/graphql/queries/ledger/fiscalCalendar.d.ts +0 -0
  96. /package/{extensions → artifacts}/graphql/queries/ledger/fiscalCalendar.js +0 -0
  97. /package/{extensions → artifacts}/graphql/queries/ledger/fiscalCalendar.ts +0 -0
  98. /package/{extensions → artifacts}/graphql/queries/ledger/mappedTrialBalance.d.ts +0 -0
  99. /package/{extensions → artifacts}/graphql/queries/ledger/mappedTrialBalance.js +0 -0
  100. /package/{extensions → artifacts}/graphql/queries/ledger/mappedTrialBalance.ts +0 -0
  101. /package/{extensions → artifacts}/graphql/queries/ledger/mapping.d.ts +0 -0
  102. /package/{extensions → artifacts}/graphql/queries/ledger/mapping.js +0 -0
  103. /package/{extensions → artifacts}/graphql/queries/ledger/mapping.ts +0 -0
  104. /package/{extensions → artifacts}/graphql/queries/ledger/mappingCoverage.d.ts +0 -0
  105. /package/{extensions → artifacts}/graphql/queries/ledger/mappingCoverage.js +0 -0
  106. /package/{extensions → artifacts}/graphql/queries/ledger/mappingCoverage.ts +0 -0
  107. /package/{extensions → artifacts}/graphql/queries/ledger/mappings.d.ts +0 -0
  108. /package/{extensions → artifacts}/graphql/queries/ledger/mappings.js +0 -0
  109. /package/{extensions → artifacts}/graphql/queries/ledger/mappings.ts +0 -0
  110. /package/{extensions → artifacts}/graphql/queries/ledger/periodCloseStatus.d.ts +0 -0
  111. /package/{extensions → artifacts}/graphql/queries/ledger/periodCloseStatus.js +0 -0
  112. /package/{extensions → artifacts}/graphql/queries/ledger/periodCloseStatus.ts +0 -0
  113. /package/{extensions → artifacts}/graphql/queries/ledger/periodDrafts.d.ts +0 -0
  114. /package/{extensions → artifacts}/graphql/queries/ledger/periodDrafts.js +0 -0
  115. /package/{extensions → artifacts}/graphql/queries/ledger/periodDrafts.ts +0 -0
  116. /package/{extensions → artifacts}/graphql/queries/ledger/publishList.d.ts +0 -0
  117. /package/{extensions → artifacts}/graphql/queries/ledger/publishList.js +0 -0
  118. /package/{extensions → artifacts}/graphql/queries/ledger/publishList.ts +0 -0
  119. /package/{extensions → artifacts}/graphql/queries/ledger/publishLists.d.ts +0 -0
  120. /package/{extensions → artifacts}/graphql/queries/ledger/publishLists.js +0 -0
  121. /package/{extensions → artifacts}/graphql/queries/ledger/publishLists.ts +0 -0
  122. /package/{extensions → artifacts}/graphql/queries/ledger/report.d.ts +0 -0
  123. /package/{extensions → artifacts}/graphql/queries/ledger/report.js +0 -0
  124. /package/{extensions → artifacts}/graphql/queries/ledger/report.ts +0 -0
  125. /package/{extensions → artifacts}/graphql/queries/ledger/reportingTaxonomy.d.ts +0 -0
  126. /package/{extensions → artifacts}/graphql/queries/ledger/reportingTaxonomy.js +0 -0
  127. /package/{extensions → artifacts}/graphql/queries/ledger/reportingTaxonomy.ts +0 -0
  128. /package/{extensions → artifacts}/graphql/queries/ledger/reports.d.ts +0 -0
  129. /package/{extensions → artifacts}/graphql/queries/ledger/reports.js +0 -0
  130. /package/{extensions → artifacts}/graphql/queries/ledger/reports.ts +0 -0
  131. /package/{extensions → artifacts}/graphql/queries/ledger/scheduleFacts.d.ts +0 -0
  132. /package/{extensions → artifacts}/graphql/queries/ledger/scheduleFacts.js +0 -0
  133. /package/{extensions → artifacts}/graphql/queries/ledger/scheduleFacts.ts +0 -0
  134. /package/{extensions → artifacts}/graphql/queries/ledger/schedules.d.ts +0 -0
  135. /package/{extensions → artifacts}/graphql/queries/ledger/schedules.js +0 -0
  136. /package/{extensions → artifacts}/graphql/queries/ledger/schedules.ts +0 -0
  137. /package/{extensions → artifacts}/graphql/queries/ledger/statement.d.ts +0 -0
  138. /package/{extensions → artifacts}/graphql/queries/ledger/statement.js +0 -0
  139. /package/{extensions → artifacts}/graphql/queries/ledger/statement.ts +0 -0
  140. /package/{extensions → artifacts}/graphql/queries/ledger/structures.d.ts +0 -0
  141. /package/{extensions → artifacts}/graphql/queries/ledger/structures.js +0 -0
  142. /package/{extensions → artifacts}/graphql/queries/ledger/structures.ts +0 -0
  143. /package/{extensions → artifacts}/graphql/queries/ledger/summary.d.ts +0 -0
  144. /package/{extensions → artifacts}/graphql/queries/ledger/summary.js +0 -0
  145. /package/{extensions → artifacts}/graphql/queries/ledger/summary.ts +0 -0
  146. /package/{extensions → artifacts}/graphql/queries/ledger/taxonomies.d.ts +0 -0
  147. /package/{extensions → artifacts}/graphql/queries/ledger/taxonomies.js +0 -0
  148. /package/{extensions → artifacts}/graphql/queries/ledger/taxonomies.ts +0 -0
  149. /package/{extensions → artifacts}/graphql/queries/ledger/transaction.d.ts +0 -0
  150. /package/{extensions → artifacts}/graphql/queries/ledger/transaction.js +0 -0
  151. /package/{extensions → artifacts}/graphql/queries/ledger/transaction.ts +0 -0
  152. /package/{extensions → artifacts}/graphql/queries/ledger/transactions.d.ts +0 -0
  153. /package/{extensions → artifacts}/graphql/queries/ledger/transactions.js +0 -0
  154. /package/{extensions → artifacts}/graphql/queries/ledger/transactions.ts +0 -0
  155. /package/{extensions → artifacts}/graphql/queries/ledger/trialBalance.d.ts +0 -0
  156. /package/{extensions → artifacts}/graphql/queries/ledger/trialBalance.js +0 -0
  157. /package/{extensions → artifacts}/graphql/queries/ledger/trialBalance.ts +0 -0
  158. /package/{extensions → artifacts}/graphql/queries/ledger/unmappedElements.d.ts +0 -0
  159. /package/{extensions → artifacts}/graphql/queries/ledger/unmappedElements.js +0 -0
  160. /package/{extensions → artifacts}/graphql/queries/ledger/unmappedElements.ts +0 -0
  161. /package/{extensions → artifacts}/hooks.d.ts +0 -0
@@ -25,37 +25,88 @@
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'
60
111
  import type { TokenProvider } from './graphql/client'
61
112
  import { GraphQLClientCache } from './graphql/client'
@@ -70,8 +121,11 @@ import {
70
121
  GetLedgerMappingDocument,
71
122
  GetLedgerPeriodCloseStatusDocument,
72
123
  GetLedgerPeriodDraftsDocument,
124
+ GetLedgerPublishListDocument,
125
+ GetLedgerReportDocument,
73
126
  GetLedgerReportingTaxonomyDocument,
74
127
  GetLedgerScheduleFactsDocument,
128
+ GetLedgerStatementDocument,
75
129
  GetLedgerSummaryDocument,
76
130
  GetLedgerTransactionDocument,
77
131
  GetLedgerTrialBalanceDocument,
@@ -79,6 +133,8 @@ import {
79
133
  ListLedgerElementsDocument,
80
134
  ListLedgerEntitiesDocument,
81
135
  ListLedgerMappingsDocument,
136
+ ListLedgerPublishListsDocument,
137
+ ListLedgerReportsDocument,
82
138
  ListLedgerSchedulesDocument,
83
139
  ListLedgerStructuresDocument,
84
140
  ListLedgerTaxonomiesDocument,
@@ -94,8 +150,11 @@ import {
94
150
  type GetLedgerMappingQuery,
95
151
  type GetLedgerPeriodCloseStatusQuery,
96
152
  type GetLedgerPeriodDraftsQuery,
153
+ type GetLedgerPublishListQuery,
97
154
  type GetLedgerReportingTaxonomyQuery,
155
+ type GetLedgerReportQuery,
98
156
  type GetLedgerScheduleFactsQuery,
157
+ type GetLedgerStatementQuery,
99
158
  type GetLedgerSummaryQuery,
100
159
  type GetLedgerTransactionQuery,
101
160
  type GetLedgerTrialBalanceQuery,
@@ -103,6 +162,8 @@ import {
103
162
  type ListLedgerElementsQuery,
104
163
  type ListLedgerEntitiesQuery,
105
164
  type ListLedgerMappingsQuery,
165
+ type ListLedgerPublishListsQuery,
166
+ type ListLedgerReportsQuery,
106
167
  type ListLedgerSchedulesQuery,
107
168
  type ListLedgerStructuresQuery,
108
169
  type ListLedgerTaxonomiesQuery,
@@ -174,6 +235,42 @@ export type LedgerClosingBookStructures = NonNullable<
174
235
  export type LedgerFiscalCalendar = NonNullable<GetLedgerFiscalCalendarQuery['fiscalCalendar']>
175
236
  export type LedgerFiscalPeriod = LedgerFiscalCalendar['periods'][number]
176
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
+
177
274
  // ── Write result shapes (envelope.result payloads) ─────────────────────
178
275
  //
179
276
  // Backend Pydantic models serialize these write results in snake_case.
@@ -342,6 +439,23 @@ export interface CreateScheduleOptions {
342
439
  }
343
440
  }
344
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
+
345
459
  // ── Client ──────────────────────────────────────────────────────────────
346
460
 
347
461
  interface LedgerClientConfig {
@@ -602,6 +716,43 @@ export class LedgerClient {
602
716
  return (envelope.result ?? {}) as Record<string, unknown>
603
717
  }
604
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
+
605
756
  /** List elements (CoA accounts, GAAP concepts, etc.) with filters. */
606
757
  async listElements(
607
758
  graphId: string,
@@ -644,6 +795,40 @@ export class LedgerClient {
644
795
  )
645
796
  }
646
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
+
647
832
  // ── Structures ──────────────────────────────────────────────────────
648
833
 
649
834
  /** List reporting structures (IS, BS, CF, schedules) with optional filters. */
@@ -676,6 +861,50 @@ export class LedgerClient {
676
861
  return envelope.result as unknown as LedgerMappingInfo
677
862
  }
678
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
+
679
908
  // ── Mappings ────────────────────────────────────────────────────────
680
909
 
681
910
  /** List active CoA→reporting mapping structures. */
@@ -755,6 +984,42 @@ export class LedgerClient {
755
984
  return { operationId: envelope.operationId, status: envelope.status }
756
985
  }
757
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
+
758
1023
  // ── Schedules ──────────────────────────────────────────────────────
759
1024
 
760
1025
  /** List all schedule structures with metadata. */
@@ -828,6 +1093,28 @@ export class LedgerClient {
828
1093
  }
829
1094
  }
830
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
+
831
1118
  /** Truncate a schedule — end it early at `newEndDate`. */
832
1119
  async truncateSchedule(
833
1120
  graphId: string,
@@ -1039,7 +1326,105 @@ export class LedgerClient {
1039
1326
  return rawFiscalCalendarToCamel(envelope.result as unknown as RawFiscalCalendar)
1040
1327
  }
1041
1328
 
1042
- // Reports, statements, and publish lists live on `ReportClient`.
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 ──────────────────────────────
1043
1428
 
1044
1429
  // ── Internal helpers ────────────────────────────────────────────────
1045
1430
 
@@ -1056,7 +1441,7 @@ export class LedgerClient {
1056
1441
  ): Promise<TResult> {
1057
1442
  try {
1058
1443
  const client = this.gql.get(graphId)
1059
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1444
+
1060
1445
  const raw = client.request as (doc: unknown, vars?: unknown) => Promise<any>
1061
1446
  // graphql-request's overloads don't cleanly resolve for generic
1062
1447
  // helpers wrapping codegen's `Exact<>` var types, so we bypass
@@ -1071,6 +1456,264 @@ export class LedgerClient {
1071
1456
  }
1072
1457
  }
1073
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
+
1074
1717
  /**
1075
1718
  * Await an SDK-generated `opXxx(...)` call, throw a readable error on
1076
1719
  * non-2xx, and return the `OperationEnvelope` on success.