@robosystems/client 2.5.2 → 2.6.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 (41) hide show
  1. package/artifacts/InvestorClient.d.ts +7 -1
  2. package/artifacts/InvestorClient.js +24 -14
  3. package/artifacts/InvestorClient.ts +46 -27
  4. package/artifacts/LedgerClient.d.ts +23 -17
  5. package/artifacts/LedgerClient.js +116 -123
  6. package/artifacts/LedgerClient.ts +180 -242
  7. package/artifacts/OperationClient.js +24 -1
  8. package/artifacts/OperationClient.ts +24 -1
  9. package/artifacts/OperatorClient.d.ts +10 -0
  10. package/artifacts/OperatorClient.js +72 -17
  11. package/artifacts/OperatorClient.ts +79 -21
  12. package/artifacts/QueryClient.d.ts +2 -1
  13. package/artifacts/QueryClient.js +17 -58
  14. package/artifacts/QueryClient.ts +21 -68
  15. package/artifacts/SSEClient.d.ts +1 -0
  16. package/artifacts/SSEClient.js +56 -7
  17. package/artifacts/SSEClient.ts +57 -7
  18. package/artifacts/config.js +18 -4
  19. package/artifacts/config.ts +18 -4
  20. package/artifacts/graphql/client.d.ts +10 -0
  21. package/artifacts/graphql/client.js +29 -21
  22. package/artifacts/graphql/client.ts +34 -23
  23. package/artifacts/index.d.ts +2 -2
  24. package/artifacts/index.js +6 -6
  25. package/artifacts/index.ts +8 -8
  26. package/artifacts/rest.d.ts +22 -0
  27. package/artifacts/rest.js +27 -0
  28. package/artifacts/rest.ts +54 -0
  29. package/artifacts/retry.js +8 -3
  30. package/artifacts/retry.ts +8 -3
  31. package/package.json +9 -1
  32. package/sdk/sdk.gen.d.ts +2 -2
  33. package/sdk/sdk.gen.js +2 -2
  34. package/sdk/sdk.gen.ts +2 -2
  35. package/sdk/types.gen.d.ts +21 -13
  36. package/sdk/types.gen.ts +21 -13
  37. package/sdk.gen.d.ts +2 -2
  38. package/sdk.gen.js +2 -2
  39. package/sdk.gen.ts +2 -2
  40. package/types.gen.d.ts +21 -13
  41. package/types.gen.ts +21 -13
@@ -13,13 +13,16 @@
13
13
  * Code Generator). The graph is in the URL, not in the query.
14
14
  * - **Writes** go through named command operations at
15
15
  * `/extensions/roboledger/{graph_id}/operations/{operation_name}`
16
- * (via the OpenAPI-generated command functions in `../sdk/sdk.gen`).
16
+ * (via the OpenAPI-generated command functions in `../sdk/sdk.gen`,
17
+ * called with this facade's own `baseUrl`, credential and headers).
17
18
  * Each command returns an `OperationEnvelope`; the facade unwraps
18
- * `envelope.result` and returns a friendly camelCase type.
19
+ * `envelope.result`.
19
20
  *
20
21
  * Consumers don't need to know which transport a method uses — the
21
- * facade signature stays stable. The only trick is that write method
22
- * results are cast from the envelope's untyped `result` field.
22
+ * facade signature stays stable. Most write results are the generated
23
+ * (snake_case) response types the typed envelopes carry; a few are
24
+ * mapped to the camelCase read shapes, and ops whose envelope `result`
25
+ * is untyped are cast to a local raw type before mapping.
23
26
  */
24
27
 
25
28
  import type { TypedDocumentNode } from '@graphql-typed-document-node/core'
@@ -249,6 +252,7 @@ import {
249
252
  type ReportDownloadFormat,
250
253
  type ReportLifecycle,
251
254
  } from './graphql/generated/graphql'
255
+ import { restCallOptions, withIdempotencyKey, type RestCallOptions } from './rest'
252
256
 
253
257
  // Re-export the structured GraphQL error type so consumers importing
254
258
  // from the `@robosystems/client/ledger` subpath can `instanceof` it.
@@ -741,7 +745,7 @@ interface LedgerClientConfig {
741
745
  token?: string
742
746
  /**
743
747
  * Dynamic credential callback. When set, invoked on every GraphQL
744
- * request so refreshes flow through automatically.
748
+ * request and REST write so refreshes flow through automatically.
745
749
  */
746
750
  tokenProvider?: TokenProvider
747
751
  /** GraphQL request timeout in milliseconds (default 60s). */
@@ -805,12 +809,8 @@ export class LedgerClient {
805
809
  * Returns the updated entity.
806
810
  */
807
811
  async updateEntity(graphId: string, updates: UpdateEntityRequest): Promise<LedgerEntity> {
808
- const envelope = await this.callOperation(
809
- 'Update entity',
810
- updateEntity({
811
- path: { graph_id: graphId },
812
- body: updates,
813
- })
812
+ const envelope = await this.callOperation('Update entity', (o) =>
813
+ updateEntity({ ...o, path: { graph_id: graphId }, body: updates })
814
814
  )
815
815
  // The REST envelope carries LedgerEntityResponse (snake_case); LedgerEntity
816
816
  // is the GraphQL camelCase shape that getEntity returns. The old
@@ -1145,9 +1145,8 @@ export class LedgerClient {
1145
1145
  graphId: string,
1146
1146
  body: LinkEntityTaxonomyRequest
1147
1147
  ): Promise<EntityTaxonomyResponse> {
1148
- const envelope = await this.callOperation(
1149
- 'Link entity taxonomy',
1150
- linkEntityTaxonomy({ path: { graph_id: graphId }, body })
1148
+ const envelope = await this.callOperation('Link entity taxonomy', (o) =>
1149
+ linkEntityTaxonomy({ ...o, path: { graph_id: graphId }, body })
1151
1150
  )
1152
1151
  return this.requireResult('Link entity taxonomy', envelope.result)
1153
1152
  }
@@ -1161,10 +1160,12 @@ export class LedgerClient {
1161
1160
  body: CreateTaxonomyBlockRequest,
1162
1161
  idempotencyKey?: string
1163
1162
  ): Promise<TaxonomyBlockEnvelope> {
1164
- const headers = idempotencyKey ? { 'Idempotency-Key': idempotencyKey } : undefined
1165
- const envelope = await this.callOperation(
1166
- 'Create taxonomy block',
1167
- createTaxonomyBlock({ path: { graph_id: graphId }, body, headers })
1163
+ const envelope = await this.callOperation('Create taxonomy block', (o) =>
1164
+ createTaxonomyBlock({
1165
+ ...withIdempotencyKey(o, idempotencyKey),
1166
+ path: { graph_id: graphId },
1167
+ body,
1168
+ })
1168
1169
  )
1169
1170
  return this.requireResult('Create taxonomy block', envelope.result)
1170
1171
  }
@@ -1174,9 +1175,8 @@ export class LedgerClient {
1174
1175
  graphId: string,
1175
1176
  body: UpdateTaxonomyBlockRequest
1176
1177
  ): Promise<TaxonomyBlockEnvelope> {
1177
- const envelope = await this.callOperation(
1178
- 'Update taxonomy block',
1179
- updateTaxonomyBlock({ path: { graph_id: graphId }, body })
1178
+ const envelope = await this.callOperation('Update taxonomy block', (o) =>
1179
+ updateTaxonomyBlock({ ...o, path: { graph_id: graphId }, body })
1180
1180
  )
1181
1181
  return this.requireResult('Update taxonomy block', envelope.result)
1182
1182
  }
@@ -1186,9 +1186,8 @@ export class LedgerClient {
1186
1186
  graphId: string,
1187
1187
  body: DeleteTaxonomyBlockRequest
1188
1188
  ): Promise<DeleteTaxonomyBlockResponse> {
1189
- const envelope = await this.callOperation(
1190
- 'Delete taxonomy block',
1191
- deleteTaxonomyBlock({ path: { graph_id: graphId }, body })
1189
+ const envelope = await this.callOperation('Delete taxonomy block', (o) =>
1190
+ deleteTaxonomyBlock({ ...o, path: { graph_id: graphId }, body })
1192
1191
  )
1193
1192
  return (envelope.result ?? { deleted: true }) as DeleteTaxonomyBlockResponse
1194
1193
  }
@@ -1204,10 +1203,8 @@ export class LedgerClient {
1204
1203
  body: BindTextBlockRequest,
1205
1204
  idempotencyKey?: string
1206
1205
  ): Promise<BindTextBlockResponse> {
1207
- const headers = idempotencyKey ? { 'Idempotency-Key': idempotencyKey } : undefined
1208
- const envelope = await this.callOperation(
1209
- 'Bind text block',
1210
- bindTextBlock({ path: { graph_id: graphId }, body, headers })
1206
+ const envelope = await this.callOperation('Bind text block', (o) =>
1207
+ bindTextBlock({ ...withIdempotencyKey(o, idempotencyKey), path: { graph_id: graphId }, body })
1211
1208
  )
1212
1209
  return this.requireResult('Bind text block', envelope.result)
1213
1210
  }
@@ -1341,9 +1338,8 @@ export class LedgerClient {
1341
1338
  graphId: string,
1342
1339
  body: CreateMappingAssociationOperation
1343
1340
  ): Promise<AssociationResponse> {
1344
- const envelope = await this.callOperation(
1345
- 'Create mapping association',
1346
- createMappingAssociation({ path: { graph_id: graphId }, body })
1341
+ const envelope = await this.callOperation('Create mapping association', (o) =>
1342
+ createMappingAssociation({ ...o, path: { graph_id: graphId }, body })
1347
1343
  )
1348
1344
  return this.requireResult('Create mapping association', envelope.result)
1349
1345
  }
@@ -1353,9 +1349,8 @@ export class LedgerClient {
1353
1349
  graphId: string,
1354
1350
  body: DeleteMappingAssociationOperation
1355
1351
  ): Promise<DeleteResult> {
1356
- const envelope = await this.callOperation(
1357
- 'Delete mapping association',
1358
- deleteMappingAssociation({ path: { graph_id: graphId }, body })
1352
+ const envelope = await this.callOperation('Delete mapping association', (o) =>
1353
+ deleteMappingAssociation({ ...o, path: { graph_id: graphId }, body })
1359
1354
  )
1360
1355
  return (envelope.result ?? { deleted: true }) as DeleteResult
1361
1356
  }
@@ -1369,9 +1364,8 @@ export class LedgerClient {
1369
1364
  graphId: string,
1370
1365
  body: AutoMapElementsOperation
1371
1366
  ): Promise<{ operationId: string; status: OperationEnvelope['status'] }> {
1372
- const envelope = await this.callOperation(
1373
- 'Auto-map elements',
1374
- autoMapElements({ path: { graph_id: graphId }, body })
1367
+ const envelope = await this.callOperation('Auto-map elements', (o) =>
1368
+ autoMapElements({ ...o, path: { graph_id: graphId }, body })
1375
1369
  )
1376
1370
  return { operationId: envelope.operationId, status: envelope.status }
1377
1371
  }
@@ -1476,7 +1470,6 @@ export class LedgerClient {
1476
1470
 
1477
1471
  // ── Schedules ──────────────────────────────────────────────────────
1478
1472
 
1479
- /** Create a new schedule with pre-generated monthly facts. */
1480
1473
  /**
1481
1474
  * Create an Information Block of any registered block_type.
1482
1475
  *
@@ -1492,14 +1485,11 @@ export class LedgerClient {
1492
1485
  body: CreateInformationBlockRequest,
1493
1486
  options?: { idempotencyKey?: string }
1494
1487
  ): Promise<InformationBlockEnvelope> {
1495
- const envelope = await this.callOperation(
1496
- 'Create information block',
1488
+ const envelope = await this.callOperation('Create information block', (o) =>
1497
1489
  createInformationBlock({
1490
+ ...withIdempotencyKey(o, options?.idempotencyKey),
1498
1491
  path: { graph_id: graphId },
1499
1492
  body,
1500
- headers: options?.idempotencyKey
1501
- ? { 'Idempotency-Key': options.idempotencyKey }
1502
- : undefined,
1503
1493
  })
1504
1494
  )
1505
1495
  return this.requireResult('Create information block', envelope.result)
@@ -1513,9 +1503,8 @@ export class LedgerClient {
1513
1503
  graphId: string,
1514
1504
  body: UpdateInformationBlockRequest
1515
1505
  ): Promise<InformationBlockEnvelope> {
1516
- const envelope = await this.callOperation(
1517
- 'Update information block',
1518
- updateInformationBlock({ path: { graph_id: graphId }, body })
1506
+ const envelope = await this.callOperation('Update information block', (o) =>
1507
+ updateInformationBlock({ ...o, path: { graph_id: graphId }, body })
1519
1508
  )
1520
1509
  return this.requireResult('Update information block', envelope.result)
1521
1510
  }
@@ -1529,13 +1518,13 @@ export class LedgerClient {
1529
1518
  graphId: string,
1530
1519
  body: DeleteInformationBlockRequest
1531
1520
  ): Promise<DeleteInformationBlockResponse> {
1532
- const envelope = await this.callOperation(
1533
- 'Delete information block',
1534
- deleteInformationBlock({ path: { graph_id: graphId }, body })
1521
+ const envelope = await this.callOperation('Delete information block', (o) =>
1522
+ deleteInformationBlock({ ...o, path: { graph_id: graphId }, body })
1535
1523
  )
1536
1524
  return (envelope.result ?? { deleted: true }) as DeleteInformationBlockResponse
1537
1525
  }
1538
1526
 
1527
+ /** Create a new schedule with pre-generated monthly facts. */
1539
1528
  async createSchedule(
1540
1529
  graphId: string,
1541
1530
  options: CreateScheduleOptions
@@ -1567,9 +1556,8 @@ export class LedgerClient {
1567
1556
  : undefined,
1568
1557
  },
1569
1558
  }
1570
- const envelope = await this.callOperation(
1571
- 'Create schedule',
1572
- createInformationBlock({ path: { graph_id: graphId }, body })
1559
+ const envelope = await this.callOperation('Create schedule', (o) =>
1560
+ createInformationBlock({ ...o, path: { graph_id: graphId }, body })
1573
1561
  )
1574
1562
  // `create-information-block` returns an InformationBlockEnvelope, not the
1575
1563
  // ScheduleCreatedResponse shape this used to decode — there is no
@@ -1587,7 +1575,10 @@ export class LedgerClient {
1587
1575
  }
1588
1576
  }
1589
1577
 
1590
- /** Update mutable fields on a schedule (name, entry_template, metadata). */
1578
+ /**
1579
+ * Rename a schedule. For other block fields use `updateInformationBlock`
1580
+ * with a `schedule` payload.
1581
+ */
1591
1582
  async updateSchedule(
1592
1583
  graphId: string,
1593
1584
  structureId: string,
@@ -1597,9 +1588,8 @@ export class LedgerClient {
1597
1588
  block_type: 'schedule',
1598
1589
  payload: { structure_id: structureId, ...options },
1599
1590
  }
1600
- const envelope = await this.callOperation(
1601
- 'Update schedule',
1602
- updateInformationBlock({ path: { graph_id: graphId }, body })
1591
+ const envelope = await this.callOperation('Update schedule', (o) =>
1592
+ updateInformationBlock({ ...o, path: { graph_id: graphId }, body })
1603
1593
  )
1604
1594
  return this.requireResult('Update schedule', envelope.result)
1605
1595
  }
@@ -1613,9 +1603,8 @@ export class LedgerClient {
1613
1603
  block_type: 'schedule',
1614
1604
  payload: { structure_id: structureId },
1615
1605
  }
1616
- const envelope = await this.callOperation(
1617
- 'Delete schedule',
1618
- deleteInformationBlock({ path: { graph_id: graphId }, body })
1606
+ const envelope = await this.callOperation('Delete schedule', (o) =>
1607
+ deleteInformationBlock({ ...o, path: { graph_id: graphId }, body })
1619
1608
  )
1620
1609
  return (envelope.result ?? { deleted: true }) as DeleteInformationBlockResponse
1621
1610
  }
@@ -1631,7 +1620,8 @@ export class LedgerClient {
1631
1620
  * a rebuild re-scopes the schedule to today's close state. Use this to
1632
1621
  * pick up a fixed generator without orphaning obligations.
1633
1622
  *
1634
- * Returns the same shape as `createSchedule`.
1623
+ * Returns the {@link ScheduleCreated} rebuild summary (periods, facts,
1624
+ * rule results) — richer than `createSchedule`'s {@link ScheduleBlockCreated}.
1635
1625
  */
1636
1626
  async rebuildSchedule(
1637
1627
  graphId: string,
@@ -1639,14 +1629,11 @@ export class LedgerClient {
1639
1629
  options?: { idempotencyKey?: string }
1640
1630
  ): Promise<ScheduleCreated> {
1641
1631
  const body: RebuildScheduleRequest = { structure_id: structureId }
1642
- const envelope = await this.callOperation(
1643
- 'Rebuild schedule',
1632
+ const envelope = await this.callOperation('Rebuild schedule', (o) =>
1644
1633
  rebuildSchedule({
1634
+ ...withIdempotencyKey(o, options?.idempotencyKey),
1645
1635
  path: { graph_id: graphId },
1646
1636
  body,
1647
- headers: options?.idempotencyKey
1648
- ? { 'Idempotency-Key': options.idempotencyKey }
1649
- : undefined,
1650
1637
  })
1651
1638
  )
1652
1639
  const raw = envelope.result as unknown as RawScheduleCreatedResult
@@ -1697,18 +1684,16 @@ export class LedgerClient {
1697
1684
  reason: options.reason ?? 'asset_disposed_event',
1698
1685
  },
1699
1686
  }
1700
- const envelope = await this.callOperation(
1701
- 'Dispose schedule',
1702
- createEventBlock({ path: { graph_id: graphId }, body })
1687
+ const envelope = await this.callOperation('Dispose schedule', (o) =>
1688
+ createEventBlock({ ...o, path: { graph_id: graphId }, body })
1703
1689
  )
1704
1690
  return this.requireResult('Dispose schedule', envelope.result)
1705
1691
  }
1706
1692
 
1707
1693
  /** Evaluate taxonomy rules against facts in a structure. */
1708
1694
  async evaluateRules(graphId: string, body: EvaluateRulesRequest): Promise<EvaluateRulesResponse> {
1709
- const envelope = await this.callOperation(
1710
- 'Evaluate rules',
1711
- evaluateRules({ path: { graph_id: graphId }, body })
1695
+ const envelope = await this.callOperation('Evaluate rules', (o) =>
1696
+ evaluateRules({ ...o, path: { graph_id: graphId }, body })
1712
1697
  )
1713
1698
  return this.requireResult('Evaluate rules', envelope.result)
1714
1699
  }
@@ -1726,14 +1711,11 @@ export class LedgerClient {
1726
1711
  body: ComputeMetricsRequest,
1727
1712
  options?: { idempotencyKey?: string }
1728
1713
  ): Promise<ComputeMetricsResponse> {
1729
- const envelope = await this.callOperation(
1730
- 'Compute metrics',
1714
+ const envelope = await this.callOperation('Compute metrics', (o) =>
1731
1715
  computeMetrics({
1716
+ ...withIdempotencyKey(o, options?.idempotencyKey),
1732
1717
  path: { graph_id: graphId },
1733
1718
  body,
1734
- headers: options?.idempotencyKey
1735
- ? { 'Idempotency-Key': options.idempotencyKey }
1736
- : undefined,
1737
1719
  })
1738
1720
  )
1739
1721
  return this.requireResult('Compute metrics', envelope.result)
@@ -1799,9 +1781,8 @@ export class LedgerClient {
1799
1781
  memo: memo ?? null,
1800
1782
  },
1801
1783
  }
1802
- const envelope = await this.callOperation(
1803
- 'Create closing entry',
1804
- createEventBlock({ path: { graph_id: graphId }, body })
1784
+ const envelope = await this.callOperation('Create closing entry', (o) =>
1785
+ createEventBlock({ ...o, path: { graph_id: graphId }, body })
1805
1786
  )
1806
1787
  return this.requireResult('Create closing entry', envelope.result)
1807
1788
  }
@@ -1844,9 +1825,8 @@ export class LedgerClient {
1844
1825
  auto_seed_schedules: options?.autoSeedSchedules,
1845
1826
  note: options?.note ?? null,
1846
1827
  }
1847
- const envelope = await this.callOperation(
1848
- 'Initialize ledger',
1849
- initializeLedger({ path: { graph_id: graphId }, body })
1828
+ const envelope = await this.callOperation('Initialize ledger', (o) =>
1829
+ initializeLedger({ ...o, path: { graph_id: graphId }, body })
1850
1830
  )
1851
1831
  const raw = envelope.result as unknown as RawInitializeLedgerResult
1852
1832
  return {
@@ -1885,9 +1865,8 @@ export class LedgerClient {
1885
1865
  entity_type: options?.entityType ?? null,
1886
1866
  name: options?.name ?? null,
1887
1867
  }
1888
- const envelope = await this.callOperation(
1889
- 'Initialize chart of accounts',
1890
- initializeChartOfAccounts({ path: { graph_id: graphId }, body })
1868
+ const envelope = await this.callOperation('Initialize chart of accounts', (o) =>
1869
+ initializeChartOfAccounts({ ...o, path: { graph_id: graphId }, body })
1891
1870
  )
1892
1871
  const raw = envelope.result as unknown as InitializeChartOfAccountsResponse
1893
1872
  return {
@@ -1909,9 +1888,8 @@ export class LedgerClient {
1909
1888
  note?: string | null
1910
1889
  ): Promise<LedgerFiscalCalendar> {
1911
1890
  const body: SetCloseTargetOperation = { period, note: note ?? null }
1912
- const envelope = await this.callOperation(
1913
- 'Set close target',
1914
- setCloseTarget({ path: { graph_id: graphId }, body })
1891
+ const envelope = await this.callOperation('Set close target', (o) =>
1892
+ setCloseTarget({ ...o, path: { graph_id: graphId }, body })
1915
1893
  )
1916
1894
  return rawFiscalCalendarToCamel(envelope.result as unknown as RawFiscalCalendar)
1917
1895
  }
@@ -1931,9 +1909,8 @@ export class LedgerClient {
1931
1909
  allow_reconciling_items: options?.allowReconcilingItems,
1932
1910
  allow_unposted_source_events: options?.allowUnpostedSourceEvents,
1933
1911
  }
1934
- const envelope = await this.callOperation(
1935
- 'Close period',
1936
- closePeriod({ path: { graph_id: graphId }, body })
1912
+ const envelope = await this.callOperation('Close period', (o) =>
1913
+ closePeriod({ ...o, path: { graph_id: graphId }, body })
1937
1914
  )
1938
1915
  const raw = envelope.result as unknown as RawClosePeriodResult
1939
1916
  return {
@@ -1960,9 +1937,8 @@ export class LedgerClient {
1960
1937
  reason,
1961
1938
  note: note ?? null,
1962
1939
  }
1963
- const envelope = await this.callOperation(
1964
- 'Reopen period',
1965
- reopenPeriod({ path: { graph_id: graphId }, body })
1940
+ const envelope = await this.callOperation('Reopen period', (o) =>
1941
+ reopenPeriod({ ...o, path: { graph_id: graphId }, body })
1966
1942
  )
1967
1943
  return rawFiscalCalendarToCamel(envelope.result as unknown as RawFiscalCalendar)
1968
1944
  }
@@ -1992,9 +1968,8 @@ export class LedgerClient {
1992
1968
  * List the items with `listEventBlocks(graphId, { isReconcilingItem: true })`.
1993
1969
  */
1994
1970
  async previewReconcilingItem(graphId: string, eventId: string): Promise<ReconcilingItemPlan> {
1995
- const envelope = await this.callOperation(
1996
- 'Preview reconciling item',
1997
- previewReconcilingItem({ path: { graph_id: graphId }, body: { event_id: eventId } })
1971
+ const envelope = await this.callOperation('Preview reconciling item', (o) =>
1972
+ previewReconcilingItem({ ...o, path: { graph_id: graphId }, body: { event_id: eventId } })
1998
1973
  )
1999
1974
  return this.requireResult('Preview reconciling item', envelope.result)
2000
1975
  }
@@ -2009,9 +1984,8 @@ export class LedgerClient {
2009
1984
  graphId: string,
2010
1985
  body: ResolveReconcilingItemRequest
2011
1986
  ): Promise<ResolveReconcilingItemResponse> {
2012
- const envelope = await this.callOperation(
2013
- 'Resolve reconciling item',
2014
- resolveReconcilingItem({ path: { graph_id: graphId }, body })
1987
+ const envelope = await this.callOperation('Resolve reconciling item', (o) =>
1988
+ resolveReconcilingItem({ ...o, path: { graph_id: graphId }, body })
2015
1989
  )
2016
1990
  return this.requireResult('Resolve reconciling item', envelope.result)
2017
1991
  }
@@ -2025,9 +1999,8 @@ export class LedgerClient {
2025
1999
  graphId: string,
2026
2000
  body: PromoteObligationsRequest = {}
2027
2001
  ): Promise<PromoteObligationsResponse> {
2028
- const envelope = await this.callOperation(
2029
- 'Promote obligations',
2030
- promoteObligations({ path: { graph_id: graphId }, body })
2002
+ const envelope = await this.callOperation('Promote obligations', (o) =>
2003
+ promoteObligations({ ...o, path: { graph_id: graphId }, body })
2031
2004
  )
2032
2005
  return this.requireResult('Promote obligations', envelope.result)
2033
2006
  }
@@ -2043,9 +2016,8 @@ export class LedgerClient {
2043
2016
  method: options?.method,
2044
2017
  include_tied: options?.includeTied,
2045
2018
  }
2046
- const envelope = await this.callOperation(
2047
- 'Preview reconciliations',
2048
- previewReconciliations({ path: { graph_id: graphId }, body })
2019
+ const envelope = await this.callOperation('Preview reconciliations', (o) =>
2020
+ previewReconciliations({ ...o, path: { graph_id: graphId }, body })
2049
2021
  )
2050
2022
  return reconciliationPreviewToCamel(envelope.result as unknown as ReconciliationPreviewResponse)
2051
2023
  }
@@ -2056,9 +2028,8 @@ export class LedgerClient {
2056
2028
  */
2057
2029
  async refreshReconciliations(graphId: string, period: string): Promise<LedgerReconciliationList> {
2058
2030
  const body: RefreshReconciliationsRequest = { period }
2059
- const envelope = await this.callOperation(
2060
- 'Refresh reconciliations',
2061
- refreshReconciliations({ path: { graph_id: graphId }, body })
2031
+ const envelope = await this.callOperation('Refresh reconciliations', (o) =>
2032
+ refreshReconciliations({ ...o, path: { graph_id: graphId }, body })
2062
2033
  )
2063
2034
  return reconciliationListToCamel(envelope.result as unknown as ReconciliationListResponse)
2064
2035
  }
@@ -2078,9 +2049,8 @@ export class LedgerClient {
2078
2049
  document_id: input.documentId ?? null,
2079
2050
  note: input.note ?? null,
2080
2051
  }
2081
- const envelope = await this.callOperation(
2082
- 'Record statement balance',
2083
- recordStatementBalance({ path: { graph_id: graphId }, body })
2052
+ const envelope = await this.callOperation('Record statement balance', (o) =>
2053
+ recordStatementBalance({ ...o, path: { graph_id: graphId }, body })
2084
2054
  )
2085
2055
  return reconciliationSummaryToCamel(envelope.result as unknown as ReconciliationSummary)
2086
2056
  }
@@ -2098,9 +2068,8 @@ export class LedgerClient {
2098
2068
  review_required: changes.reviewRequired,
2099
2069
  separate_reviewer: changes.separateReviewer,
2100
2070
  }
2101
- const envelope = await this.callOperation(
2102
- 'Set reconciliation policy',
2103
- setReconciliationPolicy({ path: { graph_id: graphId }, body })
2071
+ const envelope = await this.callOperation('Set reconciliation policy', (o) =>
2072
+ setReconciliationPolicy({ ...o, path: { graph_id: graphId }, body })
2104
2073
  )
2105
2074
  const raw = envelope.result as unknown as ReconciliationPolicyResponse
2106
2075
  return {
@@ -2127,9 +2096,8 @@ export class LedgerClient {
2127
2096
  period,
2128
2097
  note: note ?? null,
2129
2098
  }
2130
- const envelope = await this.callOperation(
2131
- 'Sign off reconciliation',
2132
- signOffReconciliation({ path: { graph_id: graphId }, body })
2099
+ const envelope = await this.callOperation('Sign off reconciliation', (o) =>
2100
+ signOffReconciliation({ ...o, path: { graph_id: graphId }, body })
2133
2101
  )
2134
2102
  return reconciliationSummaryToCamel(envelope.result as unknown as ReconciliationSummary)
2135
2103
  }
@@ -2175,12 +2143,12 @@ export class LedgerClient {
2175
2143
  transaction_id: options.transactionId ?? null,
2176
2144
  },
2177
2145
  }
2178
- const headers = options.idempotencyKey
2179
- ? { 'Idempotency-Key': options.idempotencyKey }
2180
- : undefined
2181
- const envelope = await this.callOperation(
2182
- 'Create journal entry',
2183
- createEventBlock({ path: { graph_id: graphId }, body, headers })
2146
+ const envelope = await this.callOperation('Create journal entry', (o) =>
2147
+ createEventBlock({
2148
+ ...withIdempotencyKey(o, options.idempotencyKey),
2149
+ path: { graph_id: graphId },
2150
+ body,
2151
+ })
2184
2152
  )
2185
2153
  return this.requireResult('Create journal entry', envelope.result)
2186
2154
  }
@@ -2190,9 +2158,8 @@ export class LedgerClient {
2190
2158
  graphId: string,
2191
2159
  body: UpdateJournalEntryRequest
2192
2160
  ): Promise<JournalEntryResponse> {
2193
- const envelope = await this.callOperation(
2194
- 'Update journal entry',
2195
- updateJournalEntry({ path: { graph_id: graphId }, body })
2161
+ const envelope = await this.callOperation('Update journal entry', (o) =>
2162
+ updateJournalEntry({ ...o, path: { graph_id: graphId }, body })
2196
2163
  )
2197
2164
  return this.requireResult('Update journal entry', envelope.result)
2198
2165
  }
@@ -2200,9 +2167,8 @@ export class LedgerClient {
2200
2167
  /** Hard-delete a draft journal entry. Posted entries must be reversed. */
2201
2168
  async deleteJournalEntry(graphId: string, entryId: string): Promise<DeleteResult> {
2202
2169
  const body: DeleteJournalEntryRequest = { entry_id: entryId }
2203
- const envelope = await this.callOperation(
2204
- 'Delete journal entry',
2205
- deleteJournalEntry({ path: { graph_id: graphId }, body })
2170
+ const envelope = await this.callOperation('Delete journal entry', (o) =>
2171
+ deleteJournalEntry({ ...o, path: { graph_id: graphId }, body })
2206
2172
  )
2207
2173
  return (envelope.result ?? { deleted: true }) as DeleteResult
2208
2174
  }
@@ -2239,15 +2205,40 @@ export class LedgerClient {
2239
2205
  reason: options?.reason ?? null,
2240
2206
  },
2241
2207
  }
2242
- const envelope = await this.callOperation(
2243
- 'Reverse journal entry',
2244
- createEventBlock({ path: { graph_id: graphId }, body })
2208
+ const envelope = await this.callOperation('Reverse journal entry', (o) =>
2209
+ createEventBlock({ ...o, path: { graph_id: graphId }, body })
2245
2210
  )
2246
2211
  return this.requireResult('Reverse journal entry', envelope.result)
2247
2212
  }
2248
2213
 
2249
2214
  // ── Event blocks (generic preview + status transitions) ──────────────
2250
2215
 
2216
+ /**
2217
+ * Create an event block directly. Use for support-class events
2218
+ * (`event_class: 'support'`) with categories `approval`, `control`,
2219
+ * `reconciliation`, or `inquiry`, which the specialized helpers don't
2220
+ * cover. Economic events should generally go through
2221
+ * `createJournalEntry`, `createClosingEntry`, etc., but this works for
2222
+ * those too.
2223
+ *
2224
+ * Supply `idempotencyKey` to make the call safe to retry — replays
2225
+ * within 24 hours return the same envelope.
2226
+ */
2227
+ async createEventBlock(
2228
+ graphId: string,
2229
+ body: CreateEventBlockRequest,
2230
+ idempotencyKey?: string
2231
+ ): Promise<EventBlockEnvelope> {
2232
+ const envelope = await this.callOperation('Create event block', (o) =>
2233
+ createEventBlock({
2234
+ ...withIdempotencyKey(o, idempotencyKey),
2235
+ path: { graph_id: graphId },
2236
+ body,
2237
+ })
2238
+ )
2239
+ return this.requireResult('Create event block', envelope.result)
2240
+ }
2241
+
2251
2242
  /**
2252
2243
  * Dry-run an event block — resolve the handler, evaluate metadata, and
2253
2244
  * return the planned GL rows without writing anything. Companion to
@@ -2260,9 +2251,8 @@ export class LedgerClient {
2260
2251
  graphId: string,
2261
2252
  body: CreateEventBlockRequest
2262
2253
  ): Promise<PreviewEventBlockResponse> {
2263
- const envelope = await this.callOperation(
2264
- 'Preview event block',
2265
- previewEventBlock({ path: { graph_id: graphId }, body })
2254
+ const envelope = await this.callOperation('Preview event block', (o) =>
2255
+ previewEventBlock({ ...o, path: { graph_id: graphId }, body })
2266
2256
  )
2267
2257
  return this.requireResult('Preview event block', envelope.result)
2268
2258
  }
@@ -2277,9 +2267,8 @@ export class LedgerClient {
2277
2267
  graphId: string,
2278
2268
  body: UpdateEventBlockRequest
2279
2269
  ): Promise<EventBlockEnvelope> {
2280
- const envelope = await this.callOperation(
2281
- 'Update event block',
2282
- updateEventBlock({ path: { graph_id: graphId }, body })
2270
+ const envelope = await this.callOperation('Update event block', (o) =>
2271
+ updateEventBlock({ ...o, path: { graph_id: graphId }, body })
2283
2272
  )
2284
2273
  return this.requireResult('Update event block', envelope.result)
2285
2274
  }
@@ -2297,10 +2286,8 @@ export class LedgerClient {
2297
2286
  body: CreateAgentRequest,
2298
2287
  idempotencyKey?: string
2299
2288
  ): Promise<LedgerAgentResponse> {
2300
- const headers = idempotencyKey ? { 'Idempotency-Key': idempotencyKey } : undefined
2301
- const envelope = await this.callOperation(
2302
- 'Create agent',
2303
- createAgent({ path: { graph_id: graphId }, body, headers })
2289
+ const envelope = await this.callOperation('Create agent', (o) =>
2290
+ createAgent({ ...withIdempotencyKey(o, idempotencyKey), path: { graph_id: graphId }, body })
2304
2291
  )
2305
2292
  return this.requireResult('Create agent', envelope.result)
2306
2293
  }
@@ -2310,9 +2297,8 @@ export class LedgerClient {
2310
2297
  * metadata object; all other fields replace.
2311
2298
  */
2312
2299
  async updateAgent(graphId: string, body: UpdateAgentRequest): Promise<LedgerAgentResponse> {
2313
- const envelope = await this.callOperation(
2314
- 'Update agent',
2315
- updateAgent({ path: { graph_id: graphId }, body })
2300
+ const envelope = await this.callOperation('Update agent', (o) =>
2301
+ updateAgent({ ...o, path: { graph_id: graphId }, body })
2316
2302
  )
2317
2303
  return this.requireResult('Update agent', envelope.result)
2318
2304
  }
@@ -2329,9 +2315,8 @@ export class LedgerClient {
2329
2315
  graphId: string,
2330
2316
  body: CreateEventHandlerRequest
2331
2317
  ): Promise<EventHandlerResponse> {
2332
- const envelope = await this.callOperation(
2333
- 'Create event handler',
2334
- createEventHandler({ path: { graph_id: graphId }, body })
2318
+ const envelope = await this.callOperation('Create event handler', (o) =>
2319
+ createEventHandler({ ...o, path: { graph_id: graphId }, body })
2335
2320
  )
2336
2321
  return this.requireResult('Create event handler', envelope.result)
2337
2322
  }
@@ -2344,9 +2329,8 @@ export class LedgerClient {
2344
2329
  graphId: string,
2345
2330
  body: UpdateEventHandlerRequest
2346
2331
  ): Promise<EventHandlerResponse> {
2347
- const envelope = await this.callOperation(
2348
- 'Update event handler',
2349
- updateEventHandler({ path: { graph_id: graphId }, body })
2332
+ const envelope = await this.callOperation('Update event handler', (o) =>
2333
+ updateEventHandler({ ...o, path: { graph_id: graphId }, body })
2350
2334
  )
2351
2335
  return this.requireResult('Update event handler', envelope.result)
2352
2336
  }
@@ -2363,9 +2347,8 @@ export class LedgerClient {
2363
2347
  graphId: string,
2364
2348
  body: LiveFinancialStatementRequest
2365
2349
  ): Promise<LiveFinancialStatementResponse> {
2366
- const envelope = await this.callOperation(
2367
- 'Live financial statement',
2368
- liveFinancialStatement({ path: { graph_id: graphId }, body })
2350
+ const envelope = await this.callOperation('Live financial statement', (o) =>
2351
+ liveFinancialStatement({ ...o, path: { graph_id: graphId }, body })
2369
2352
  )
2370
2353
  return this.requireResult('Live financial statement', envelope.result)
2371
2354
  }
@@ -2380,9 +2363,8 @@ export class LedgerClient {
2380
2363
  graphId: string,
2381
2364
  body: FinancialStatementAnalysisRequest
2382
2365
  ): Promise<FinancialStatementAnalysisResponse> {
2383
- const envelope = await this.callOperation(
2384
- 'Financial statement analysis',
2385
- financialStatementAnalysis({ path: { graph_id: graphId }, body })
2366
+ const envelope = await this.callOperation('Financial statement analysis', (o) =>
2367
+ financialStatementAnalysis({ ...o, path: { graph_id: graphId }, body })
2386
2368
  )
2387
2369
  return this.requireResult('Financial statement analysis', envelope.result)
2388
2370
  }
@@ -2397,9 +2379,8 @@ export class LedgerClient {
2397
2379
  * tenant graphs (after materialization) and the SEC shared repository.
2398
2380
  */
2399
2381
  async buildFactGrid(graphId: string, body: CreateViewRequest): Promise<ViewResponse> {
2400
- const envelope = await this.callOperation(
2401
- 'Build fact grid',
2402
- buildFactGrid({ path: { graph_id: graphId }, body })
2382
+ const envelope = await this.callOperation('Build fact grid', (o) =>
2383
+ buildFactGrid({ ...o, path: { graph_id: graphId }, body })
2403
2384
  )
2404
2385
  return this.requireResult('Build fact grid', envelope.result)
2405
2386
  }
@@ -2456,9 +2437,8 @@ export class LedgerClient {
2456
2437
  if (options.periods && options.periods.length > 0) {
2457
2438
  body.periods = options.periods
2458
2439
  }
2459
- const envelope = await this.callOperation(
2460
- 'Create report',
2461
- createReport({ path: { graph_id: graphId }, body })
2440
+ const envelope = await this.callOperation('Create report', (o) =>
2441
+ createReport({ ...o, path: { graph_id: graphId }, body })
2462
2442
  )
2463
2443
  return this.requireResult('Create report', envelope.result)
2464
2444
  }
@@ -2540,9 +2520,9 @@ export class LedgerClient {
2540
2520
  periodStart?: string,
2541
2521
  periodEnd?: string
2542
2522
  ): Promise<ReportResponse> {
2543
- const envelope = await this.callOperation(
2544
- 'Regenerate report',
2523
+ const envelope = await this.callOperation('Regenerate report', (o) =>
2545
2524
  regenerateReport({
2525
+ ...o,
2546
2526
  path: { graph_id: graphId },
2547
2527
  body: {
2548
2528
  report_id: reportId,
@@ -2556,12 +2536,8 @@ export class LedgerClient {
2556
2536
 
2557
2537
  /** Delete a report and its generated facts. */
2558
2538
  async deleteReport(graphId: string, reportId: string): Promise<DeleteResult> {
2559
- const envelope = await this.callOperation(
2560
- 'Delete report',
2561
- deleteReport({
2562
- path: { graph_id: graphId },
2563
- body: { report_id: reportId },
2564
- })
2539
+ const envelope = await this.callOperation('Delete report', (o) =>
2540
+ deleteReport({ ...o, path: { graph_id: graphId }, body: { report_id: reportId } })
2565
2541
  )
2566
2542
  return (envelope.result ?? { deleted: true }) as DeleteResult
2567
2543
  }
@@ -2630,9 +2606,9 @@ export class LedgerClient {
2630
2606
  reportId: string,
2631
2607
  publishListId: string
2632
2608
  ): Promise<ShareReportResponse> {
2633
- const envelope = await this.callOperation(
2634
- 'Share report',
2609
+ const envelope = await this.callOperation('Share report', (o) =>
2635
2610
  shareReport({
2611
+ ...o,
2636
2612
  path: { graph_id: graphId },
2637
2613
  body: {
2638
2614
  report_id: reportId,
@@ -2651,9 +2627,8 @@ export class LedgerClient {
2651
2627
  */
2652
2628
  async fileReport(graphId: string, reportId: string): Promise<ReportResponse> {
2653
2629
  const body: FileReportRequest = { report_id: reportId }
2654
- const envelope = await this.callOperation(
2655
- 'File report',
2656
- fileReport({ path: { graph_id: graphId }, body })
2630
+ const envelope = await this.callOperation('File report', (o) =>
2631
+ fileReport({ ...o, path: { graph_id: graphId }, body })
2657
2632
  )
2658
2633
  return this.requireResult('File report', envelope.result)
2659
2634
  }
@@ -2674,9 +2649,8 @@ export class LedgerClient {
2674
2649
  report_id: reportId,
2675
2650
  target_status: targetStatus,
2676
2651
  }
2677
- const envelope = await this.callOperation(
2678
- 'Transition filing status',
2679
- transitionFilingStatus({ path: { graph_id: graphId }, body })
2652
+ const envelope = await this.callOperation('Transition filing status', (o) =>
2653
+ transitionFilingStatus({ ...o, path: { graph_id: graphId }, body })
2680
2654
  )
2681
2655
  return this.requireResult('Transition filing status', envelope.result)
2682
2656
  }
@@ -2704,9 +2678,9 @@ export class LedgerClient {
2704
2678
  reportId: string,
2705
2679
  targetGraphId: string
2706
2680
  ): Promise<RevokeReportShareResponse> {
2707
- const envelope = await this.callOperation(
2708
- 'Revoke report share',
2681
+ const envelope = await this.callOperation('Revoke report share', (o) =>
2709
2682
  revokeReportShare({
2683
+ ...o,
2710
2684
  path: { graph_id: graphId },
2711
2685
  body: {
2712
2686
  report_id: reportId,
@@ -2757,9 +2731,9 @@ export class LedgerClient {
2757
2731
  sourceGraphId: string,
2758
2732
  options?: { reason?: string; purge?: boolean }
2759
2733
  ): Promise<BlockSourceGraphResult> {
2760
- const envelope = await this.callOperation(
2761
- 'Block source graph',
2734
+ const envelope = await this.callOperation('Block source graph', (o) =>
2762
2735
  blockSourceGraph({
2736
+ ...o,
2763
2737
  path: { graph_id: graphId },
2764
2738
  body: {
2765
2739
  source_graph_id: sourceGraphId,
@@ -2781,9 +2755,9 @@ export class LedgerClient {
2781
2755
  graphId: string,
2782
2756
  sourceGraphId: string
2783
2757
  ): Promise<BlockedSourceGraphResponse> {
2784
- const envelope = await this.callOperation(
2785
- 'Unblock source graph',
2758
+ const envelope = await this.callOperation('Unblock source graph', (o) =>
2786
2759
  unblockSourceGraph({
2760
+ ...o,
2787
2761
  path: { graph_id: graphId },
2788
2762
  body: {
2789
2763
  source_graph_id: sourceGraphId,
@@ -2823,9 +2797,8 @@ export class LedgerClient {
2823
2797
  name,
2824
2798
  description: description ?? null,
2825
2799
  }
2826
- const envelope = await this.callOperation(
2827
- 'Create publish list',
2828
- createPublishList({ path: { graph_id: graphId }, body })
2800
+ const envelope = await this.callOperation('Create publish list', (o) =>
2801
+ createPublishList({ ...o, path: { graph_id: graphId }, body })
2829
2802
  )
2830
2803
  return this.requireResult('Create publish list', envelope.result)
2831
2804
  }
@@ -2847,28 +2820,21 @@ export class LedgerClient {
2847
2820
  listId: string,
2848
2821
  updates: { name?: string; description?: string | null }
2849
2822
  ): Promise<PublishListResponse> {
2850
- const envelope = await this.callOperation(
2851
- 'Update publish list',
2852
- updatePublishList({
2853
- path: { graph_id: graphId },
2854
- body: {
2855
- list_id: listId,
2856
- name: updates.name,
2857
- description: updates.description ?? null,
2858
- } as UpdatePublishListOperation,
2859
- })
2823
+ // The server applies only the fields present, so an omitted key must
2824
+ // stay off the wire; an explicit `description: null` still clears it.
2825
+ const body: UpdatePublishListOperation = { list_id: listId }
2826
+ if (updates.name !== undefined) body.name = updates.name
2827
+ if (updates.description !== undefined) body.description = updates.description
2828
+ const envelope = await this.callOperation('Update publish list', (o) =>
2829
+ updatePublishList({ ...o, path: { graph_id: graphId }, body })
2860
2830
  )
2861
2831
  return this.requireResult('Update publish list', envelope.result)
2862
2832
  }
2863
2833
 
2864
2834
  /** Delete a publish list. */
2865
2835
  async deletePublishList(graphId: string, listId: string): Promise<DeleteResult> {
2866
- const envelope = await this.callOperation(
2867
- 'Delete publish list',
2868
- deletePublishList({
2869
- path: { graph_id: graphId },
2870
- body: { list_id: listId },
2871
- })
2836
+ const envelope = await this.callOperation('Delete publish list', (o) =>
2837
+ deletePublishList({ ...o, path: { graph_id: graphId }, body: { list_id: listId } })
2872
2838
  )
2873
2839
  return (envelope.result ?? { deleted: true }) as DeleteResult
2874
2840
  }
@@ -2879,9 +2845,9 @@ export class LedgerClient {
2879
2845
  listId: string,
2880
2846
  targetGraphIds: string[]
2881
2847
  ): Promise<PublishListMemberResponse[]> {
2882
- const envelope = await this.callOperation(
2883
- 'Add publish list members',
2848
+ const envelope = await this.callOperation('Add publish list members', (o) =>
2884
2849
  addPublishListMembers({
2850
+ ...o,
2885
2851
  path: { graph_id: graphId },
2886
2852
  body: {
2887
2853
  list_id: listId,
@@ -2898,9 +2864,9 @@ export class LedgerClient {
2898
2864
  listId: string,
2899
2865
  memberId: string
2900
2866
  ): Promise<DeleteResult> {
2901
- const envelope = await this.callOperation(
2902
- 'Remove publish list member',
2867
+ const envelope = await this.callOperation('Remove publish list member', (o) =>
2903
2868
  removePublishListMember({
2869
+ ...o,
2904
2870
  path: { graph_id: graphId },
2905
2871
  body: { list_id: listId, member_id: memberId },
2906
2872
  })
@@ -2911,8 +2877,9 @@ export class LedgerClient {
2911
2877
  // ── Internal helpers ────────────────────────────────────────────────
2912
2878
 
2913
2879
  /**
2914
- * Await an SDK-generated command call, throw a readable error on
2915
- * non-2xx, and return the parsed envelope on success.
2880
+ * Run an SDK-generated command call with this facade's per-call
2881
+ * transport options (`baseUrl`, credential, headers), throw a readable
2882
+ * error on non-2xx, and return the parsed envelope on success.
2916
2883
  *
2917
2884
  * Generic over the SDK call's response shape so typed ops (e.g.
2918
2885
  * `createEventBlock`, which returns
@@ -2922,9 +2889,9 @@ export class LedgerClient {
2922
2889
  */
2923
2890
  private async callOperation<T>(
2924
2891
  label: string,
2925
- call: Promise<{ data?: T; error?: unknown }>
2892
+ call: (options: RestCallOptions) => Promise<{ data?: T; error?: unknown }>
2926
2893
  ): Promise<T> {
2927
- const response = await call
2894
+ const response = await call(await restCallOptions(this.config))
2928
2895
  if (response.error !== undefined) {
2929
2896
  throw new Error(`${label} failed: ${JSON.stringify(response.error)}`)
2930
2897
  }
@@ -2945,35 +2912,6 @@ export class LedgerClient {
2945
2912
  }
2946
2913
  return result
2947
2914
  }
2948
-
2949
- /**
2950
- * Resolve the current bearer token / API key for non-GraphQL REST
2951
- * calls. Mirrors the GraphQL client's behaviour — dynamic
2952
- * ``tokenProvider`` is consulted first (so JWT rotation flows
2953
- * naturally), then the static ``token`` config. Returns ``null``
2954
- * when no credential is configured (cookie-based / anonymous flows).
2955
- * A ``tokenProvider`` that **throws** fails the call fast instead of
2956
- * silently proceeding unauthenticated — matching the Python client,
2957
- * which raises when its configured credential cannot be resolved.
2958
- */
2959
- private async resolveToken(): Promise<string | null> {
2960
- if (this.config.tokenProvider) {
2961
- let token: string | null | undefined
2962
- try {
2963
- token = await this.config.tokenProvider()
2964
- } catch (err) {
2965
- const detail = err instanceof Error ? err.message : String(err)
2966
- throw new Error(
2967
- `RoboSystems SDK: tokenProvider threw while resolving the request credential (${detail}). ` +
2968
- 'Fix the tokenProvider passed in the client config (or via setSDKClientConfig) so it ' +
2969
- 'returns the current token, or null to send an unauthenticated (cookie-based) request.',
2970
- { cause: err }
2971
- )
2972
- }
2973
- return token ?? null
2974
- }
2975
- return this.config.token ?? null
2976
- }
2977
2915
  }
2978
2916
 
2979
2917
  // ── Module-private conversion helpers ─────────────────────────────────