@robosystems/client 2.8.0 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/artifacts/LedgerClient.d.ts +77 -18
  2. package/artifacts/LedgerClient.js +92 -25
  3. package/artifacts/LedgerClient.ts +161 -29
  4. package/artifacts/graphql/generated/graphql.d.ts +50 -5
  5. package/artifacts/graphql/generated/graphql.js +244 -2
  6. package/artifacts/graphql/generated/graphql.ts +303 -5
  7. package/artifacts/graphql/queries/ledger/accountRollups.js +12 -2
  8. package/artifacts/graphql/queries/ledger/accountRollups.ts +12 -2
  9. package/artifacts/graphql/queries/ledger/accountTree.js +2 -2
  10. package/artifacts/graphql/queries/ledger/accountTree.ts +2 -2
  11. package/artifacts/graphql/queries/ledger/accounts.js +8 -1
  12. package/artifacts/graphql/queries/ledger/accounts.ts +8 -1
  13. package/artifacts/graphql/queries/ledger/bankAccounts.d.ts +6 -0
  14. package/artifacts/graphql/queries/ledger/bankAccounts.js +35 -0
  15. package/artifacts/graphql/queries/ledger/bankAccounts.ts +33 -0
  16. package/artifacts/graphql/queries/ledger/closingBookStructures.js +2 -2
  17. package/artifacts/graphql/queries/ledger/closingBookStructures.ts +2 -2
  18. package/artifacts/graphql/queries/ledger/entities.js +1 -0
  19. package/artifacts/graphql/queries/ledger/entities.ts +1 -0
  20. package/artifacts/graphql/queries/ledger/entity.js +4 -2
  21. package/artifacts/graphql/queries/ledger/entity.ts +4 -2
  22. package/artifacts/graphql/queries/ledger/eventBlocks.js +2 -0
  23. package/artifacts/graphql/queries/ledger/eventBlocks.ts +2 -0
  24. package/artifacts/graphql/queries/ledger/fiscalCalendar.js +3 -2
  25. package/artifacts/graphql/queries/ledger/fiscalCalendar.ts +3 -2
  26. package/artifacts/graphql/queries/ledger/journalEntries.js +2 -0
  27. package/artifacts/graphql/queries/ledger/journalEntries.ts +2 -0
  28. package/artifacts/graphql/queries/ledger/periodCloseStatus.js +2 -2
  29. package/artifacts/graphql/queries/ledger/periodCloseStatus.ts +2 -2
  30. package/artifacts/graphql/queries/ledger/periodDrafts.js +2 -2
  31. package/artifacts/graphql/queries/ledger/periodDrafts.ts +2 -2
  32. package/artifacts/graphql/queries/ledger/reconciliations.js +2 -2
  33. package/artifacts/graphql/queries/ledger/reconciliations.ts +2 -2
  34. package/artifacts/graphql/queries/ledger/report.js +1 -0
  35. package/artifacts/graphql/queries/ledger/report.ts +1 -0
  36. package/artifacts/graphql/queries/ledger/reports.js +3 -2
  37. package/artifacts/graphql/queries/ledger/reports.ts +3 -2
  38. package/artifacts/graphql/queries/ledger/summary.js +3 -2
  39. package/artifacts/graphql/queries/ledger/summary.ts +3 -2
  40. package/artifacts/graphql/queries/ledger/transactions.js +2 -0
  41. package/artifacts/graphql/queries/ledger/transactions.ts +2 -0
  42. package/artifacts/graphql/queries/ledger/trialBalance.js +2 -2
  43. package/artifacts/graphql/queries/ledger/trialBalance.ts +2 -2
  44. package/index.ts +2 -2
  45. package/package.json +1 -1
  46. package/sdk/index.d.ts +2 -2
  47. package/sdk/index.js +4 -3
  48. package/sdk/index.ts +2 -2
  49. package/sdk/sdk.gen.d.ts +9 -1
  50. package/sdk/sdk.gen.js +20 -3
  51. package/sdk/sdk.gen.ts +18 -1
  52. package/sdk/types.gen.d.ts +206 -0
  53. package/sdk/types.gen.ts +214 -0
  54. package/sdk.gen.d.ts +9 -1
  55. package/sdk.gen.js +20 -3
  56. package/sdk.gen.ts +18 -1
  57. package/types.gen.d.ts +206 -0
  58. package/types.gen.ts +214 -0
@@ -1,6 +1,6 @@
1
- import type { AssociationResponse, AutoMapElementsOperation, BindTextBlockRequest, BindTextBlockResponse, BlockedSourceGraphResponse, BlockSourceGraphResult, ComputeMetricsRequest, ComputeMetricsResponse, CreateAgentRequest, CreateEventBlockRequest, CreateEventHandlerRequest, CreateInformationBlockRequest, CreateMappingAssociationOperation, CreateTaxonomyBlockRequest, CreateViewRequest, DeleteInformationBlockRequest, DeleteInformationBlockResponse, DeleteMappingAssociationOperation, DeleteResult, DeleteTaxonomyBlockRequest, DeleteTaxonomyBlockResponse, EntityTaxonomyResponse, EvaluateRulesRequest, EvaluateRulesResponse, EventBlockEnvelope, EventHandlerResponse, FinancialStatementAnalysisRequest, FinancialStatementAnalysisResponse, InformationBlockEnvelope, InitializeChartOfAccountsRequest, JournalEntryResponse, LedgerAgentResponse, LinkEntityTaxonomyRequest, LiveFinancialStatementRequest, LiveFinancialStatementResponse, OperationEnvelope, PreviewEventBlockResponse, PreviewReconciliationsRequest, PromoteObligationsRequest, PromoteObligationsResponse, PublishListMemberResponse, PublishListResponse, ReconcilingItemPlan, ReportResponse, ResolveReconcilingItemRequest, ResolveReconcilingItemResponse, RevokeReportShareResponse, ShareReportResponse, TaxonomyBlockEnvelope, UpdateAgentRequest, UpdateEntityRequest, UpdateEventBlockRequest, UpdateEventHandlerRequest, UpdateInformationBlockRequest, UpdateJournalEntryRequest, UpdateTaxonomyBlockRequest, ViewResponse } from '../types.gen';
1
+ import type { AssociationResponse, AutoMapElementsOperation, BindTextBlockRequest, BindTextBlockResponse, BlockedSourceGraphResponse, BlockSourceGraphResult, ComputeMetricsRequest, ComputeMetricsResponse, CreateAgentRequest, CreateEntityRequest, CreateEventBlockRequest, CreateEventHandlerRequest, CreateInformationBlockRequest, CreateMappingAssociationOperation, CreateTaxonomyBlockRequest, CreateViewRequest, DeleteInformationBlockRequest, DeleteInformationBlockResponse, DeleteMappingAssociationOperation, DeleteResult, DeleteTaxonomyBlockRequest, DeleteTaxonomyBlockResponse, EntityTaxonomyResponse, EvaluateRulesRequest, EvaluateRulesResponse, EventBlockEnvelope, EventHandlerResponse, FinancialStatementAnalysisRequest, FinancialStatementAnalysisResponse, InformationBlockEnvelope, InitializeChartOfAccountsRequest, JournalEntryResponse, LedgerAgentResponse, LinkBankAccountRequest, LinkBankAccountResponse, LinkEntityTaxonomyRequest, LiveFinancialStatementRequest, LiveFinancialStatementResponse, OperationEnvelope, PreviewEventBlockResponse, PreviewReconciliationsRequest, PromoteObligationsRequest, PromoteObligationsResponse, PublishListMemberResponse, PublishListResponse, ReconcilingItemPlan, ReportResponse, ResolveReconcilingItemRequest, ResolveReconcilingItemResponse, RevokeReportShareResponse, ShareReportResponse, TaxonomyBlockEnvelope, UpdateAgentRequest, UpdateEntityRequest, UpdateEventBlockRequest, UpdateEventHandlerRequest, UpdateInformationBlockRequest, UpdateJournalEntryRequest, UpdateTaxonomyBlockRequest, ViewResponse } from '../types.gen';
2
2
  import type { TokenProvider } from './graphql/client';
3
- import { type GetInformationBlockQuery, type GetLedgerAccountRollupsQuery, type GetLedgerAccountTreeQuery, type GetLedgerAgentQuery, type GetLedgerClosingBookStructuresQuery, type GetLedgerEntityQuery, type GetLedgerEventBlockQuery, type GetLedgerFiscalCalendarQuery, type GetLedgerMappedTrialBalanceQuery, type GetLedgerMappingCoverageQuery, type GetLedgerMappingQuery, type GetLedgerPeriodCloseStatusQuery, type GetLedgerPeriodDraftsQuery, type GetLedgerPublishListQuery, type GetLedgerReportingTaxonomyQuery, type GetLedgerReportPackageQuery, type GetLedgerReportQuery, type GetLedgerStatementQuery, type GetLedgerSummaryQuery, type GetLedgerTransactionQuery, type GetLedgerTrialBalanceQuery, type ListChartTemplatesQuery, type ListInformationBlocksQuery, type ListLedgerAccountsQuery, type ListLedgerAgentsQuery, type ListLedgerBlockedSourceGraphsQuery, type ListLedgerElementsQuery, type ListLedgerEntitiesQuery, type ListLedgerEventBlocksQuery, type ListLedgerJournalEntriesQuery, type ListLedgerMappingsQuery, type ListLedgerPublishListsQuery, type ListLedgerReconciliationsQuery, type ListLedgerReportsQuery, type ListLedgerStructuresQuery, type ListLedgerTaxonomiesQuery, type ListLedgerTransactionsQuery, type ListLedgerUnmappedElementsQuery, type MappingCandidatesQuery, type ReportDownloadFormat, type ReportLifecycle } from './graphql/generated/graphql';
3
+ import { ListLedgerBankAccountsQuery, type GetInformationBlockQuery, type GetLedgerAccountRollupsQuery, type GetLedgerAccountTreeQuery, type GetLedgerAgentQuery, type GetLedgerClosingBookStructuresQuery, type GetLedgerEntityQuery, type GetLedgerEventBlockQuery, type GetLedgerFiscalCalendarQuery, type GetLedgerMappedTrialBalanceQuery, type GetLedgerMappingCoverageQuery, type GetLedgerMappingQuery, type GetLedgerPeriodCloseStatusQuery, type GetLedgerPeriodDraftsQuery, type GetLedgerPublishListQuery, type GetLedgerReportingTaxonomyQuery, type GetLedgerReportPackageQuery, type GetLedgerReportQuery, type GetLedgerStatementQuery, type GetLedgerSummaryQuery, type GetLedgerTransactionQuery, type GetLedgerTrialBalanceQuery, type ListChartTemplatesQuery, type ListInformationBlocksQuery, type ListLedgerAccountsQuery, type ListLedgerAgentsQuery, type ListLedgerBlockedSourceGraphsQuery, type ListLedgerElementsQuery, type ListLedgerEntitiesQuery, type ListLedgerEventBlocksQuery, type ListLedgerJournalEntriesQuery, type ListLedgerMappingsQuery, type ListLedgerPublishListsQuery, type ListLedgerReconciliationsQuery, type ListLedgerReportsQuery, type ListLedgerStructuresQuery, type ListLedgerTaxonomiesQuery, type ListLedgerTransactionsQuery, type ListLedgerUnmappedElementsQuery, type MappingCandidatesQuery, type ReportDownloadFormat, type ReportLifecycle } from './graphql/generated/graphql';
4
4
  export { GraphQLError } from './graphql/client';
5
5
  export type { ReportLifecycle };
6
6
  export type LedgerEntity = NonNullable<GetLedgerEntityQuery['entity']>;
@@ -10,6 +10,8 @@ export type LedgerAccountList = NonNullable<ListLedgerAccountsQuery['accounts']>
10
10
  export type LedgerAccount = LedgerAccountList['accounts'][number];
11
11
  export type LedgerAccountTree = NonNullable<GetLedgerAccountTreeQuery['accountTree']>;
12
12
  export type LedgerAccountRollups = NonNullable<GetLedgerAccountRollupsQuery['accountRollups']>;
13
+ export type LedgerBankAccountList = NonNullable<ListLedgerBankAccountsQuery['bankAccounts']>;
14
+ export type LedgerBankAccount = LedgerBankAccountList['accounts'][number];
13
15
  export type LedgerTrialBalance = NonNullable<GetLedgerTrialBalanceQuery['trialBalance']>;
14
16
  export type LedgerMappedTrialBalance = NonNullable<GetLedgerMappedTrialBalanceQuery['mappedTrialBalance']>;
15
17
  export type LedgerTransactionList = NonNullable<ListLedgerTransactionsQuery['transactions']>;
@@ -167,6 +169,8 @@ export interface ScheduleCreated {
167
169
  }
168
170
  export type LedgerEntryType = 'standard' | 'adjusting' | 'closing' | 'reversing';
169
171
  export interface InitializeLedgerOptions {
172
+ /** The entity whose calendar is seeded. Omitted: the group parent. */
173
+ entityId?: string | null;
170
174
  closedThrough?: string | null;
171
175
  fiscalYearStartMonth?: number;
172
176
  earliestDataPeriod?: string | null;
@@ -176,6 +180,8 @@ export interface InitializeLedgerOptions {
176
180
  /** A shipped chart template key — the `key` of a `listChartTemplates()` row. */
177
181
  export type ChartTemplateKey = InitializeChartOfAccountsRequest['template'];
178
182
  export interface InitializeChartOfAccountsOptions {
183
+ /** The entity the chart belongs to. Omitted: the group parent. */
184
+ entityId?: string | null;
179
185
  /**
180
186
  * Legal form for the equity mapping: `corporation`, `llc` or `partnership`.
181
187
  * Defaults to the graph's primary entity, then to corporation.
@@ -197,7 +203,16 @@ export interface InitializeChartOfAccountsResult {
197
203
  /** Targets that did not resolve, or a framework this graph does not carry. Never fatal. */
198
204
  unresolved: string[];
199
205
  }
200
- export interface ClosePeriodOptions {
206
+ /**
207
+ * Which of the graph's entities a call is about. Omitted, it is the group
208
+ * parent: the entity the graph's own source connection books for. Every
209
+ * graph has one; a graph with subsidiaries has more, and each keeps its own
210
+ * books, chart and calendar.
211
+ */
212
+ export interface EntityScopeOptions {
213
+ entityId?: string | null;
214
+ }
215
+ export interface ClosePeriodOptions extends EntityScopeOptions {
201
216
  note?: string | null;
202
217
  allowStaleSync?: boolean;
203
218
  /**
@@ -362,11 +377,15 @@ export declare class LedgerClient {
362
377
  private gql;
363
378
  constructor(config: LedgerClientConfig);
364
379
  /**
365
- * Get the entity (company/organization) for this graph.
366
- * Returns null when the ledger has no entity yet.
380
+ * Get an entity of this graph: the group parent, or the one `entityId`
381
+ * names. Returns null when the ledger has no entity yet.
382
+ */
383
+ getEntity(graphId: string, options?: EntityScopeOptions): Promise<LedgerEntity | null>;
384
+ /**
385
+ * List the graph's entities, optionally filtered by source system. The
386
+ * group parent is the row with `isParent`; a subsidiary names its
387
+ * `parentEntityId` and may carry an `ownershipPct`.
367
388
  */
368
- getEntity(graphId: string): Promise<LedgerEntity | null>;
369
- /** List all entities for this graph, optionally filtered by source system. */
370
389
  listEntities(graphId: string, options?: {
371
390
  source?: string;
372
391
  }): Promise<LedgerEntitySummary[]>;
@@ -375,23 +394,52 @@ export declare class LedgerClient {
375
394
  * Returns the updated entity.
376
395
  */
377
396
  updateEntity(graphId: string, updates: UpdateEntityRequest): Promise<LedgerEntity>;
397
+ /**
398
+ * Create an entity in this graph. A graph's first entity becomes the group
399
+ * parent; every later one is a subsidiary of the parent unless
400
+ * `parent_entity_id` names another entity. The `ticker` prefixes the
401
+ * entity's account names and is unique in the graph (derived from the
402
+ * name's initials when omitted). Returns the entity in the shape
403
+ * `getEntity` returns.
404
+ */
405
+ createEntity(graphId: string, body: CreateEntityRequest): Promise<LedgerEntity>;
378
406
  /** Ledger rollup counts + QB sync metadata. */
379
- getSummary(graphId: string): Promise<LedgerSummary | null>;
407
+ getSummary(graphId: string, options?: EntityScopeOptions): Promise<LedgerSummary | null>;
380
408
  /** List CoA accounts with optional filters and pagination. */
381
409
  listAccounts(graphId: string, options?: {
382
410
  classification?: string;
383
411
  isActive?: boolean;
384
412
  limit?: number;
385
413
  offset?: number;
414
+ entityId?: string | null;
386
415
  }): Promise<LedgerAccountList | null>;
387
416
  /** Hierarchical Chart of Accounts (up to 4 levels deep). */
388
- getAccountTree(graphId: string): Promise<LedgerAccountTree | null>;
417
+ getAccountTree(graphId: string, options?: EntityScopeOptions): Promise<LedgerAccountTree | null>;
389
418
  /** Accounts rolled up to reporting concepts via a mapping structure. */
390
419
  getAccountRollups(graphId: string, options?: {
391
420
  mappingId?: string;
392
421
  startDate?: string;
393
422
  endDate?: string;
423
+ entityId?: string | null;
394
424
  }): Promise<LedgerAccountRollups | null>;
425
+ /**
426
+ * The group's bank and card accounts: every chart account a feed books to,
427
+ * or that a source system types as a bank or card account, with the entity
428
+ * whose chart it is in (`entityId`, the books its lines go into), what
429
+ * writes to it (`source`: a feed provider, `quickbooks`, or null for an
430
+ * account kept by hand) and the connection's status and last sync. Pass
431
+ * `entityId` for one entity's accounts; omit it for the whole group.
432
+ */
433
+ listBankAccounts(graphId: string, options?: EntityScopeOptions): Promise<LedgerBankAccountList | null>;
434
+ /**
435
+ * Point a bank feed's account at a chart account. `element_id` links an
436
+ * existing account (its chart's entity takes the feed); `entity_id` alone
437
+ * creates one in that entity's chart. This is how a feed account is bound
438
+ * to a subsidiary: lines still in the inbox move with it, posted entries
439
+ * stay where they were posted. An account another connection already
440
+ * feeds is refused.
441
+ */
442
+ linkBankAccount(graphId: string, body: LinkBankAccountRequest): Promise<LinkBankAccountResponse>;
395
443
  /** List transactions with optional type + date filters and pagination. */
396
444
  listTransactions(graphId: string, options?: {
397
445
  type?: string;
@@ -399,6 +447,7 @@ export declare class LedgerClient {
399
447
  endDate?: string;
400
448
  limit?: number;
401
449
  offset?: number;
450
+ entityId?: string | null;
402
451
  }): Promise<LedgerTransactionList | null>;
403
452
  /**
404
453
  * List journal entries with their line items, newest first.
@@ -422,6 +471,7 @@ export declare class LedgerClient {
422
471
  transactionId?: string;
423
472
  limit?: number;
424
473
  offset?: number;
474
+ entityId?: string | null;
425
475
  }): Promise<LedgerJournalEntryList | null>;
426
476
  /** Get transaction detail with entries + line items. */
427
477
  getTransaction(graphId: string, transactionId: string): Promise<LedgerTransaction | null>;
@@ -442,6 +492,7 @@ export declare class LedgerClient {
442
492
  isReconcilingItem?: boolean;
443
493
  limit?: number;
444
494
  offset?: number;
495
+ entityId?: string | null;
445
496
  }): Promise<LedgerEventBlock[]>;
446
497
  /** Get event block detail (carries the metadata blob with nested entries). */
447
498
  getEventBlock(graphId: string, eventId: string): Promise<LedgerEventBlockDetail | null>;
@@ -463,6 +514,7 @@ export declare class LedgerClient {
463
514
  getTrialBalance(graphId: string, options?: {
464
515
  startDate?: string;
465
516
  endDate?: string;
517
+ entityId?: string | null;
466
518
  }): Promise<LedgerTrialBalance | null>;
467
519
  /** Trial balance rolled up to GAAP reporting concepts via a mapping. */
468
520
  getMappedTrialBalance(graphId: string, mappingId: string, options?: {
@@ -673,9 +725,9 @@ export declare class LedgerClient {
673
725
  idempotencyKey?: string;
674
726
  }): Promise<ComputeMetricsResponse>;
675
727
  /** Close status for all schedules in a fiscal period. */
676
- getPeriodCloseStatus(graphId: string, periodStart: string, periodEnd: string): Promise<LedgerPeriodCloseStatus | null>;
728
+ getPeriodCloseStatus(graphId: string, periodStart: string, periodEnd: string, options?: EntityScopeOptions): Promise<LedgerPeriodCloseStatus | null>;
677
729
  /** All draft entries in a period, fully expanded for review pre-close. */
678
- listPeriodDrafts(graphId: string, period: string): Promise<LedgerPeriodDrafts | null>;
730
+ listPeriodDrafts(graphId: string, period: string, options?: EntityScopeOptions): Promise<LedgerPeriodDrafts | null>;
679
731
  /**
680
732
  * Idempotently create (or refresh) a draft closing entry from a
681
733
  * schedule for a period.
@@ -687,9 +739,12 @@ export declare class LedgerClient {
687
739
  */
688
740
  createClosingEntry(graphId: string, structureId: string, postingDate: string, periodStart: string, periodEnd: string, memo?: string): Promise<EventBlockEnvelope>;
689
741
  /** Grouped closing book structures for the close-screen sidebar. */
690
- getClosingBookStructures(graphId: string): Promise<LedgerClosingBookStructures | null>;
691
- /** Current fiscal calendar state — pointers, gap, closeable status. */
692
- getFiscalCalendar(graphId: string): Promise<LedgerFiscalCalendar | null>;
742
+ getClosingBookStructures(graphId: string, options?: EntityScopeOptions): Promise<LedgerClosingBookStructures | null>;
743
+ /**
744
+ * Current fiscal calendar state — pointers, gap, closeable status — for the
745
+ * group parent, or for the entity `entityId` names.
746
+ */
747
+ getFiscalCalendar(graphId: string, options?: EntityScopeOptions): Promise<LedgerFiscalCalendar | null>;
693
748
  /** One-time ledger initialization — seed fiscal calendar + periods. */
694
749
  initializeLedger(graphId: string, options?: InitializeLedgerOptions): Promise<InitializeLedgerResult>;
695
750
  /** Shipped chart-of-accounts templates for `initializeChartOfAccounts`. */
@@ -702,16 +757,19 @@ export declare class LedgerClient {
702
757
  */
703
758
  initializeChartOfAccounts(graphId: string, template: ChartTemplateKey, options?: InitializeChartOfAccountsOptions): Promise<InitializeChartOfAccountsResult>;
704
759
  /** Set the user-controlled close target (YYYY-MM). */
705
- setCloseTarget(graphId: string, period: string, note?: string | null): Promise<LedgerFiscalCalendar>;
706
- /** Close a fiscal period — the final commit action. */
760
+ setCloseTarget(graphId: string, period: string, note?: string | null, options?: EntityScopeOptions): Promise<LedgerFiscalCalendar>;
761
+ /**
762
+ * Close a fiscal period — the final commit action — on the group parent,
763
+ * or on the entity `entityId` names. Each entity closes on its own.
764
+ */
707
765
  closePeriod(graphId: string, period: string, options?: ClosePeriodOptions): Promise<ClosePeriodResult>;
708
766
  /** Reopen a closed fiscal period. Requires a reason for the audit log. */
709
- reopenPeriod(graphId: string, period: string, reason: string, note?: string | null): Promise<LedgerFiscalCalendar>;
767
+ reopenPeriod(graphId: string, period: string, reason: string, note?: string | null, options?: EntityScopeOptions): Promise<LedgerFiscalCalendar>;
710
768
  /**
711
769
  * Every reconciliation block's standing at a period end (YYYY-MM). A block
712
770
  * not yet compared for the period reads `not_started`.
713
771
  */
714
- listReconciliations(graphId: string, period: string): Promise<LedgerReconciliationList | null>;
772
+ listReconciliations(graphId: string, period: string, options?: EntityScopeOptions): Promise<LedgerReconciliationList | null>;
715
773
  /**
716
774
  * What changed on a reconciling item (a posted event whose source payload
717
775
  * changed afterwards) and what each treatment would do. Writes nothing.
@@ -879,6 +937,7 @@ export declare class LedgerClient {
879
937
  */
880
938
  listReports(graphId: string, options?: {
881
939
  lifecycle?: ReportLifecycle;
940
+ entityId?: string | null;
882
941
  }): Promise<ReportListItem[]>;
883
942
  /** Get a single report with its period list + available structures. */
884
943
  getReport(graphId: string, reportId: string): Promise<Report | null>;
@@ -18,13 +18,17 @@ class LedgerClient {
18
18
  }
19
19
  // ── Entity ──────────────────────────────────────────────────────────
20
20
  /**
21
- * Get the entity (company/organization) for this graph.
22
- * Returns null when the ledger has no entity yet.
21
+ * Get an entity of this graph: the group parent, or the one `entityId`
22
+ * names. Returns null when the ledger has no entity yet.
23
23
  */
24
- async getEntity(graphId) {
25
- return this.gqlQuery(graphId, graphql_1.GetLedgerEntityDocument, undefined, 'Get entity', (data) => data.entity);
24
+ async getEntity(graphId, options) {
25
+ return this.gqlQuery(graphId, graphql_1.GetLedgerEntityDocument, { entityId: options?.entityId ?? null }, 'Get entity', (data) => data.entity);
26
26
  }
27
- /** List all entities for this graph, optionally filtered by source system. */
27
+ /**
28
+ * List the graph's entities, optionally filtered by source system. The
29
+ * group parent is the row with `isParent`; a subsidiary names its
30
+ * `parentEntityId` and may carry an `ownershipPct`.
31
+ */
28
32
  async listEntities(graphId, options) {
29
33
  return this.gqlQuery(graphId, graphql_1.ListLedgerEntitiesDocument, { source: options?.source ?? null }, 'List entities', (data) => data.entities);
30
34
  }
@@ -44,10 +48,23 @@ class LedgerClient {
44
48
  const raw = this.requireResult('Update entity', envelope.result);
45
49
  return entityResponseToCamel(raw);
46
50
  }
51
+ /**
52
+ * Create an entity in this graph. A graph's first entity becomes the group
53
+ * parent; every later one is a subsidiary of the parent unless
54
+ * `parent_entity_id` names another entity. The `ticker` prefixes the
55
+ * entity's account names and is unique in the graph (derived from the
56
+ * name's initials when omitted). Returns the entity in the shape
57
+ * `getEntity` returns.
58
+ */
59
+ async createEntity(graphId, body) {
60
+ const envelope = await this.callOperation('Create entity', (o) => (0, sdk_gen_1.createEntity)({ ...o, path: { graph_id: graphId }, body }));
61
+ const raw = this.requireResult('Create entity', envelope.result);
62
+ return entityResponseToCamel(raw);
63
+ }
47
64
  // ── Summary ────────────────────────────────────────────────────────
48
65
  /** Ledger rollup counts + QB sync metadata. */
49
- async getSummary(graphId) {
50
- return this.gqlQuery(graphId, graphql_1.GetLedgerSummaryDocument, undefined, 'Get summary', (data) => data.summary);
66
+ async getSummary(graphId, options) {
67
+ return this.gqlQuery(graphId, graphql_1.GetLedgerSummaryDocument, { entityId: options?.entityId ?? null }, 'Get summary', (data) => data.summary);
51
68
  }
52
69
  // ── Accounts (Chart of Accounts) ───────────────────────────────────
53
70
  /** List CoA accounts with optional filters and pagination. */
@@ -57,11 +74,12 @@ class LedgerClient {
57
74
  isActive: options?.isActive ?? null,
58
75
  limit: options?.limit ?? 100,
59
76
  offset: options?.offset ?? 0,
77
+ entityId: options?.entityId ?? null,
60
78
  }, 'List accounts', (data) => data.accounts);
61
79
  }
62
80
  /** Hierarchical Chart of Accounts (up to 4 levels deep). */
63
- async getAccountTree(graphId) {
64
- return this.gqlQuery(graphId, graphql_1.GetLedgerAccountTreeDocument, undefined, 'Get account tree', (data) => data.accountTree);
81
+ async getAccountTree(graphId, options) {
82
+ return this.gqlQuery(graphId, graphql_1.GetLedgerAccountTreeDocument, { entityId: options?.entityId ?? null }, 'Get account tree', (data) => data.accountTree);
65
83
  }
66
84
  /** Accounts rolled up to reporting concepts via a mapping structure. */
67
85
  async getAccountRollups(graphId, options) {
@@ -69,8 +87,33 @@ class LedgerClient {
69
87
  mappingId: options?.mappingId ?? null,
70
88
  startDate: options?.startDate ?? null,
71
89
  endDate: options?.endDate ?? null,
90
+ entityId: options?.entityId ?? null,
72
91
  }, 'Get account rollups', (data) => data.accountRollups);
73
92
  }
93
+ // ── Bank accounts ─────────────────────────────────────────────────────
94
+ /**
95
+ * The group's bank and card accounts: every chart account a feed books to,
96
+ * or that a source system types as a bank or card account, with the entity
97
+ * whose chart it is in (`entityId`, the books its lines go into), what
98
+ * writes to it (`source`: a feed provider, `quickbooks`, or null for an
99
+ * account kept by hand) and the connection's status and last sync. Pass
100
+ * `entityId` for one entity's accounts; omit it for the whole group.
101
+ */
102
+ async listBankAccounts(graphId, options) {
103
+ return this.gqlQuery(graphId, graphql_1.ListLedgerBankAccountsDocument, { entityId: options?.entityId ?? null }, 'List bank accounts', (data) => data.bankAccounts);
104
+ }
105
+ /**
106
+ * Point a bank feed's account at a chart account. `element_id` links an
107
+ * existing account (its chart's entity takes the feed); `entity_id` alone
108
+ * creates one in that entity's chart. This is how a feed account is bound
109
+ * to a subsidiary: lines still in the inbox move with it, posted entries
110
+ * stay where they were posted. An account another connection already
111
+ * feeds is refused.
112
+ */
113
+ async linkBankAccount(graphId, body) {
114
+ const envelope = await this.callOperation('Link bank account', (o) => (0, sdk_gen_1.linkBankAccount)({ ...o, path: { graph_id: graphId }, body }));
115
+ return this.requireResult('Link bank account', envelope.result);
116
+ }
74
117
  // ── Transactions ────────────────────────────────────────────────────
75
118
  /** List transactions with optional type + date filters and pagination. */
76
119
  async listTransactions(graphId, options) {
@@ -80,6 +123,7 @@ class LedgerClient {
80
123
  endDate: options?.endDate ?? null,
81
124
  limit: options?.limit ?? 100,
82
125
  offset: options?.offset ?? 0,
126
+ entityId: options?.entityId ?? null,
83
127
  }, 'List transactions', (data) => data.transactions);
84
128
  }
85
129
  // ── Journal entries ─────────────────────────────────────────────────
@@ -106,6 +150,7 @@ class LedgerClient {
106
150
  transactionId: options?.transactionId ?? null,
107
151
  limit: options?.limit ?? 100,
108
152
  offset: options?.offset ?? 0,
153
+ entityId: options?.entityId ?? null,
109
154
  }, 'List journal entries', (data) => data.journalEntries);
110
155
  }
111
156
  /** Get transaction detail with entries + line items. */
@@ -130,6 +175,7 @@ class LedgerClient {
130
175
  isReconcilingItem: options?.isReconcilingItem ?? null,
131
176
  limit: options?.limit ?? 50,
132
177
  offset: options?.offset ?? 0,
178
+ entityId: options?.entityId ?? null,
133
179
  }, 'List event blocks', (data) => data.eventBlocks);
134
180
  }
135
181
  /** Get event block detail (carries the metadata blob with nested entries). */
@@ -161,6 +207,7 @@ class LedgerClient {
161
207
  return this.gqlQuery(graphId, graphql_1.GetLedgerTrialBalanceDocument, {
162
208
  startDate: options?.startDate ?? null,
163
209
  endDate: options?.endDate ?? null,
210
+ entityId: options?.entityId ?? null,
164
211
  }, 'Get trial balance', (data) => data.trialBalance);
165
212
  }
166
213
  /** Trial balance rolled up to GAAP reporting concepts via a mapping. */
@@ -534,12 +581,12 @@ class LedgerClient {
534
581
  }
535
582
  // ── Period close ────────────────────────────────────────────────────
536
583
  /** Close status for all schedules in a fiscal period. */
537
- async getPeriodCloseStatus(graphId, periodStart, periodEnd) {
538
- return this.gqlQuery(graphId, graphql_1.GetLedgerPeriodCloseStatusDocument, { periodStart, periodEnd }, 'Get period close status', (data) => data.periodCloseStatus);
584
+ async getPeriodCloseStatus(graphId, periodStart, periodEnd, options) {
585
+ return this.gqlQuery(graphId, graphql_1.GetLedgerPeriodCloseStatusDocument, { periodStart, periodEnd, entityId: options?.entityId ?? null }, 'Get period close status', (data) => data.periodCloseStatus);
539
586
  }
540
587
  /** All draft entries in a period, fully expanded for review pre-close. */
541
- async listPeriodDrafts(graphId, period) {
542
- return this.gqlQuery(graphId, graphql_1.GetLedgerPeriodDraftsDocument, { period }, 'List period drafts', (data) => data.periodDrafts);
588
+ async listPeriodDrafts(graphId, period, options) {
589
+ return this.gqlQuery(graphId, graphql_1.GetLedgerPeriodDraftsDocument, { period, entityId: options?.entityId ?? null }, 'List period drafts', (data) => data.periodDrafts);
543
590
  }
544
591
  /**
545
592
  * Idempotently create (or refresh) a draft closing entry from a
@@ -571,17 +618,21 @@ class LedgerClient {
571
618
  }
572
619
  // ── Closing book ───────────────────────────────────────────────────
573
620
  /** Grouped closing book structures for the close-screen sidebar. */
574
- async getClosingBookStructures(graphId) {
575
- return this.gqlQuery(graphId, graphql_1.GetLedgerClosingBookStructuresDocument, undefined, 'Get closing book structures', (data) => data.closingBookStructures);
621
+ async getClosingBookStructures(graphId, options) {
622
+ return this.gqlQuery(graphId, graphql_1.GetLedgerClosingBookStructuresDocument, { entityId: options?.entityId ?? null }, 'Get closing book structures', (data) => data.closingBookStructures);
576
623
  }
577
624
  // ── Fiscal Calendar ────────────────────────────────────────────────
578
- /** Current fiscal calendar state — pointers, gap, closeable status. */
579
- async getFiscalCalendar(graphId) {
580
- return this.gqlQuery(graphId, graphql_1.GetLedgerFiscalCalendarDocument, undefined, 'Get fiscal calendar', (data) => data.fiscalCalendar);
625
+ /**
626
+ * Current fiscal calendar state — pointers, gap, closeable status — for the
627
+ * group parent, or for the entity `entityId` names.
628
+ */
629
+ async getFiscalCalendar(graphId, options) {
630
+ return this.gqlQuery(graphId, graphql_1.GetLedgerFiscalCalendarDocument, { entityId: options?.entityId ?? null }, 'Get fiscal calendar', (data) => data.fiscalCalendar);
581
631
  }
582
632
  /** One-time ledger initialization — seed fiscal calendar + periods. */
583
633
  async initializeLedger(graphId, options) {
584
634
  const body = {
635
+ entity_id: options?.entityId ?? null,
585
636
  closed_through: options?.closedThrough ?? null,
586
637
  fiscal_year_start_month: options?.fiscalYearStartMonth,
587
638
  earliest_data_period: options?.earliestDataPeriod ?? null,
@@ -610,6 +661,7 @@ class LedgerClient {
610
661
  async initializeChartOfAccounts(graphId, template, options) {
611
662
  const body = {
612
663
  template,
664
+ entity_id: options?.entityId ?? null,
613
665
  entity_type: options?.entityType ?? null,
614
666
  name: options?.name ?? null,
615
667
  };
@@ -627,15 +679,23 @@ class LedgerClient {
627
679
  };
628
680
  }
629
681
  /** Set the user-controlled close target (YYYY-MM). */
630
- async setCloseTarget(graphId, period, note) {
631
- const body = { period, note: note ?? null };
682
+ async setCloseTarget(graphId, period, note, options) {
683
+ const body = {
684
+ period,
685
+ note: note ?? null,
686
+ entity_id: options?.entityId ?? null,
687
+ };
632
688
  const envelope = await this.callOperation('Set close target', (o) => (0, sdk_gen_1.setCloseTarget)({ ...o, path: { graph_id: graphId }, body }));
633
689
  return rawFiscalCalendarToCamel(envelope.result);
634
690
  }
635
- /** Close a fiscal period — the final commit action. */
691
+ /**
692
+ * Close a fiscal period — the final commit action — on the group parent,
693
+ * or on the entity `entityId` names. Each entity closes on its own.
694
+ */
636
695
  async closePeriod(graphId, period, options) {
637
696
  const body = {
638
697
  period,
698
+ entity_id: options?.entityId ?? null,
639
699
  note: options?.note ?? null,
640
700
  allow_stale_sync: options?.allowStaleSync,
641
701
  allow_stranded_obligations: options?.allowStrandedObligations,
@@ -657,11 +717,12 @@ class LedgerClient {
657
717
  };
658
718
  }
659
719
  /** Reopen a closed fiscal period. Requires a reason for the audit log. */
660
- async reopenPeriod(graphId, period, reason, note) {
720
+ async reopenPeriod(graphId, period, reason, note, options) {
661
721
  const body = {
662
722
  period,
663
723
  reason,
664
724
  note: note ?? null,
725
+ entity_id: options?.entityId ?? null,
665
726
  };
666
727
  const envelope = await this.callOperation('Reopen period', (o) => (0, sdk_gen_1.reopenPeriod)({ ...o, path: { graph_id: graphId }, body }));
667
728
  return rawFiscalCalendarToCamel(envelope.result);
@@ -671,8 +732,8 @@ class LedgerClient {
671
732
  * Every reconciliation block's standing at a period end (YYYY-MM). A block
672
733
  * not yet compared for the period reads `not_started`.
673
734
  */
674
- async listReconciliations(graphId, period) {
675
- return this.gqlQuery(graphId, graphql_1.ListLedgerReconciliationsDocument, { period }, 'List reconciliations', (data) => data.reconciliations);
735
+ async listReconciliations(graphId, period, options) {
736
+ return this.gqlQuery(graphId, graphql_1.ListLedgerReconciliationsDocument, { period, entityId: options?.entityId ?? null }, 'List reconciliations', (data) => data.reconciliations);
676
737
  }
677
738
  /**
678
739
  * What changed on a reconciling item (a posted event whose source payload
@@ -1016,7 +1077,10 @@ class LedgerClient {
1016
1077
  * `ARCHIVED` returns only those, `ALL` every report.
1017
1078
  */
1018
1079
  async listReports(graphId, options = {}) {
1019
- const list = await this.gqlQuery(graphId, graphql_1.ListLedgerReportsDocument, options.lifecycle ? { lifecycle: options.lifecycle } : undefined, 'List reports', (data) => data.reports);
1080
+ const list = await this.gqlQuery(graphId, graphql_1.ListLedgerReportsDocument, {
1081
+ ...(options.lifecycle ? { lifecycle: options.lifecycle } : {}),
1082
+ entityId: options.entityId ?? null,
1083
+ }, 'List reports', (data) => data.reports);
1020
1084
  return list?.reports ?? [];
1021
1085
  }
1022
1086
  /** Get a single report with its period list + available structures. */
@@ -1335,6 +1399,7 @@ function rawObligationDetailToCamel(raw) {
1335
1399
  function rawFiscalCalendarToCamel(raw) {
1336
1400
  return {
1337
1401
  graphId: raw.graph_id,
1402
+ entityId: raw.entity_id ?? null,
1338
1403
  fiscalYearStartMonth: raw.fiscal_year_start_month,
1339
1404
  closedThrough: raw.closed_through ?? null,
1340
1405
  closeTarget: raw.close_target ?? null,
@@ -1475,11 +1540,13 @@ function entityResponseToCamel(raw) {
1475
1540
  lei: raw.lei ?? null,
1476
1541
  industry: raw.industry ?? null,
1477
1542
  entityType: raw.entity_type ?? null,
1543
+ reportingStyleId: raw.reporting_style_id ?? null,
1478
1544
  phone: raw.phone ?? null,
1479
1545
  website: raw.website ?? null,
1480
1546
  status: raw.status ?? null,
1481
1547
  isParent: raw.is_parent ?? null,
1482
1548
  parentEntityId: raw.parent_entity_id ?? null,
1549
+ ownershipPct: raw.ownership_pct ?? null,
1483
1550
  source: raw.source ?? null,
1484
1551
  sourceId: raw.source_id ?? null,
1485
1552
  sourceGraphId: raw.source_graph_id ?? null,