@robosystems/client 0.3.9 → 0.3.11

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.
@@ -1,4 +1,4 @@
1
- import type { AutoMapElementsOperation, BulkAssociationItem, CreateElementRequest, CreateMappingAssociationOperation, CreateStructureRequest, CreateTaxonomyRequest, CreateViewRequest, DeleteMappingAssociationOperation, LinkEntityTaxonomyRequest, OperationEnvelope, UpdateAssociationRequest, UpdateElementRequest, UpdateEntityRequest, UpdateJournalEntryRequest, UpdateStructureRequest, UpdateTaxonomyRequest } from '../types.gen';
1
+ import type { AutoMapElementsOperation, CreateAgentRequest, CreateEventBlockRequest, CreateEventHandlerRequest, CreateMappingAssociationOperation, CreateTaxonomyBlockRequest, CreateViewRequest, DeleteMappingAssociationOperation, DeleteTaxonomyBlockRequest, EvaluateRulesRequest, FinancialStatementAnalysisRequest, LinkEntityTaxonomyRequest, LiveFinancialStatementRequest, OperationEnvelope, UpdateAgentRequest, UpdateEntityRequest, UpdateEventBlockRequest, UpdateEventHandlerRequest, UpdateJournalEntryRequest, UpdateTaxonomyBlockRequest } from '../types.gen';
2
2
  import type { TokenProvider } from './graphql/client';
3
3
  import { type GetInformationBlockQuery, type GetLedgerAccountRollupsQuery, type GetLedgerAccountTreeQuery, type GetLedgerClosingBookStructuresQuery, type GetLedgerEntityQuery, type GetLedgerFiscalCalendarQuery, type GetLedgerMappedTrialBalanceQuery, type GetLedgerMappingCoverageQuery, type GetLedgerMappingQuery, type GetLedgerPeriodCloseStatusQuery, type GetLedgerPeriodDraftsQuery, type GetLedgerPublishListQuery, type GetLedgerReportingTaxonomyQuery, type GetLedgerReportQuery, type GetLedgerStatementQuery, type GetLedgerSummaryQuery, type GetLedgerTransactionQuery, type GetLedgerTrialBalanceQuery, type ListInformationBlocksQuery, type ListLedgerAccountsQuery, type ListLedgerElementsQuery, type ListLedgerEntitiesQuery, type ListLedgerMappingsQuery, type ListLedgerPublishListsQuery, type ListLedgerReportsQuery, type ListLedgerStructuresQuery, type ListLedgerTaxonomiesQuery, type ListLedgerTransactionsQuery, type ListLedgerUnmappedElementsQuery } from './graphql/generated/graphql';
4
4
  export type LedgerEntity = NonNullable<GetLedgerEntityQuery['entity']>;
@@ -77,18 +77,6 @@ export interface ClosePeriodResult {
77
77
  targetAutoAdvanced: boolean;
78
78
  fiscalCalendar: LedgerFiscalCalendar;
79
79
  }
80
- export type ClosingEntryOutcome = 'created' | 'unchanged' | 'regenerated' | 'removed' | 'skipped';
81
- export interface ClosingEntry {
82
- outcome: ClosingEntryOutcome;
83
- entryId: string | null;
84
- status: string | null;
85
- postingDate: string | null;
86
- memo: string | null;
87
- debitElementId: string | null;
88
- creditElementId: string | null;
89
- amount: number | null;
90
- reason: string | null;
91
- }
92
80
  export interface ScheduleCreated {
93
81
  structureId: string;
94
82
  name: string;
@@ -96,12 +84,6 @@ export interface ScheduleCreated {
96
84
  totalPeriods: number;
97
85
  totalFacts: number;
98
86
  }
99
- export interface TruncateScheduleResult {
100
- structureId: string;
101
- newEndDate: string;
102
- factsDeleted: number;
103
- reason: string;
104
- }
105
87
  export type LedgerEntryType = 'standard' | 'adjusting' | 'closing' | 'reversing';
106
88
  export interface InitializeLedgerOptions {
107
89
  closedThrough?: string | null;
@@ -114,22 +96,6 @@ export interface ClosePeriodOptions {
114
96
  note?: string | null;
115
97
  allowStaleSync?: boolean;
116
98
  }
117
- export interface ManualClosingLineItem {
118
- elementId: string;
119
- debitAmount?: number;
120
- creditAmount?: number;
121
- description?: string | null;
122
- }
123
- export interface CreateManualClosingEntryOptions {
124
- postingDate: string;
125
- memo: string;
126
- lineItems: ManualClosingLineItem[];
127
- entryType?: LedgerEntryType;
128
- }
129
- export interface TruncateScheduleOptions {
130
- newEndDate: string;
131
- reason: string;
132
- }
133
99
  export interface CreateScheduleOptions {
134
100
  name: string;
135
101
  elementIds: string[];
@@ -228,30 +194,6 @@ export declare class LedgerClient {
228
194
  }): Promise<LedgerTransactionList | null>;
229
195
  /** Get transaction detail with entries + line items. */
230
196
  getTransaction(graphId: string, transactionId: string): Promise<LedgerTransaction | null>;
231
- /**
232
- * Create a standalone business-event Transaction without entries.
233
- *
234
- * Returns a `transaction_id` that can be passed to `createJournalEntry`
235
- * to attach entries to this event. Use when a single event (invoice,
236
- * payment, deposit) produces multiple entries over its lifecycle.
237
- *
238
- * `amount` is in minor currency units (cents).
239
- * `type` is free-form: invoice, payment, bill, expense, deposit, etc.
240
- */
241
- createTransaction(graphId: string, options: {
242
- type: string;
243
- date: string;
244
- amount: number;
245
- currency?: string;
246
- description?: string;
247
- merchantName?: string;
248
- referenceNumber?: string;
249
- number?: string;
250
- category?: string;
251
- dueDate?: string;
252
- status?: 'pending' | 'posted';
253
- idempotencyKey?: string;
254
- }): Promise<Record<string, unknown>>;
255
197
  /** Trial balance by raw CoA account. */
256
198
  getTrialBalance(graphId: string, options?: {
257
199
  startDate?: string;
@@ -268,17 +210,22 @@ export declare class LedgerClient {
268
210
  listTaxonomies(graphId: string, options?: {
269
211
  taxonomyType?: string;
270
212
  }): Promise<LedgerTaxonomy[]>;
271
- /** Create a new taxonomy (used for CoA + mapping taxonomies). */
272
- createTaxonomy(graphId: string, body: CreateTaxonomyRequest): Promise<Record<string, unknown>>;
273
- /** Update mutable fields on a taxonomy. `taxonomy_type` is immutable. */
274
- updateTaxonomy(graphId: string, body: UpdateTaxonomyRequest): Promise<Record<string, unknown>>;
275
- /** Soft-delete a taxonomy (`is_active=false`). */
276
- deleteTaxonomy(graphId: string, taxonomyId: string): Promise<Record<string, unknown>>;
277
213
  /**
278
214
  * Link the graph's entity to a taxonomy (ENTITY_HAS_TAXONOMY edge).
279
215
  * Idempotent — returns existing linkage if already present.
280
216
  */
281
217
  linkEntityTaxonomy(graphId: string, body: LinkEntityTaxonomyRequest): Promise<Record<string, unknown>>;
218
+ /**
219
+ * Create a taxonomy block atomically (taxonomy + structures + elements +
220
+ * associations + rules in one envelope).
221
+ */
222
+ createTaxonomyBlock(graphId: string, body: CreateTaxonomyBlockRequest, idempotencyKey?: string): Promise<Record<string, unknown>>;
223
+ /** Update a taxonomy block — add/update/remove elements, structures, associations, or rules. */
224
+ updateTaxonomyBlock(graphId: string, body: UpdateTaxonomyBlockRequest): Promise<Record<string, unknown>>;
225
+ /** Delete a taxonomy block. Cascades through elements, structures, and associations. */
226
+ deleteTaxonomyBlock(graphId: string, body: DeleteTaxonomyBlockRequest): Promise<{
227
+ deleted: boolean;
228
+ }>;
282
229
  /** List elements (CoA accounts, GAAP concepts, etc.) with filters. */
283
230
  listElements(graphId: string, options?: {
284
231
  taxonomyId?: string;
@@ -292,32 +239,11 @@ export declare class LedgerClient {
292
239
  listUnmappedElements(graphId: string, options?: {
293
240
  mappingId?: string;
294
241
  }): Promise<LedgerUnmappedElement[]>;
295
- /** Create a new element within a taxonomy (native CoA account, etc.). */
296
- createElement(graphId: string, body: CreateElementRequest): Promise<Record<string, unknown>>;
297
- /** Update mutable fields on an element. `taxonomy_id` and `source` are immutable. */
298
- updateElement(graphId: string, body: UpdateElementRequest): Promise<Record<string, unknown>>;
299
- /** Soft-delete an element (`is_active=false`). */
300
- deleteElement(graphId: string, elementId: string): Promise<Record<string, unknown>>;
301
242
  /** List reporting structures (IS, BS, CF, schedules) with optional filters. */
302
243
  listStructures(graphId: string, options?: {
303
244
  taxonomyId?: string;
304
245
  structureType?: string;
305
246
  }): Promise<LedgerStructure[]>;
306
- /**
307
- * Create a new structure. Most common use is a CoA→reporting mapping
308
- * structure; also used for custom statement + schedule structures.
309
- */
310
- createStructure(graphId: string, body: CreateStructureRequest): Promise<LedgerMappingInfo>;
311
- /** Convenience wrapper — create a CoA→GAAP mapping structure. */
312
- createMappingStructure(graphId: string, options?: {
313
- name?: string;
314
- description?: string | null;
315
- taxonomyId?: string;
316
- }): Promise<LedgerMappingInfo>;
317
- /** Update mutable fields on a structure. `structure_type` is immutable. */
318
- updateStructure(graphId: string, body: UpdateStructureRequest): Promise<Record<string, unknown>>;
319
- /** Soft-delete a structure (`is_active=false`). */
320
- deleteStructure(graphId: string, structureId: string): Promise<Record<string, unknown>>;
321
247
  /** List active CoA→reporting mapping structures. */
322
248
  listMappings(graphId: string): Promise<LedgerMappingInfo[]>;
323
249
  /** Get a mapping structure with all its associations. */
@@ -339,14 +265,6 @@ export declare class LedgerClient {
339
265
  operationId: string;
340
266
  status: OperationEnvelope['status'];
341
267
  }>;
342
- /** Bulk create associations within a single structure, atomically. */
343
- createAssociations(graphId: string, structureId: string, associations: BulkAssociationItem[]): Promise<Record<string, unknown>>;
344
- /** Update mutable fields on an association (order, weight, confidence). */
345
- updateAssociation(graphId: string, body: UpdateAssociationRequest): Promise<Record<string, unknown>>;
346
- /** Hard-delete an association (any type: presentation, calculation, mapping). */
347
- deleteAssociation(graphId: string, associationId: string): Promise<{
348
- deleted: boolean;
349
- }>;
350
268
  /**
351
269
  * Fetch an Information Block envelope by id — the generic
352
270
  * cross-block-type read. Returns `null` when the block doesn't exist
@@ -374,22 +292,38 @@ export declare class LedgerClient {
374
292
  deleteSchedule(graphId: string, structureId: string): Promise<{
375
293
  deleted: boolean;
376
294
  }>;
377
- /** Truncate a schedule — end it early at `newEndDate`. */
378
- truncateSchedule(graphId: string, structureId: string, options: TruncateScheduleOptions): Promise<TruncateScheduleResult>;
295
+ /**
296
+ * Dispose of a schedule asset — atomically truncates forward facts,
297
+ * deletes the SumEquals rule, and posts a balanced disposal entry.
298
+ *
299
+ * Routes through `create-event-block` with `event_type='asset_disposed'`.
300
+ * `occurred_at` is required and represents the disposal date.
301
+ */
302
+ disposeSchedule(graphId: string, options: {
303
+ scheduleId: string;
304
+ occurredAt: string;
305
+ proceeds?: number;
306
+ proceedsElementId?: string | null;
307
+ gainLossElementId?: string | null;
308
+ memo?: string | null;
309
+ reason?: string;
310
+ }): Promise<Record<string, unknown>>;
311
+ /** Evaluate taxonomy rules against facts in a structure. */
312
+ evaluateRules(graphId: string, body: EvaluateRulesRequest): Promise<Record<string, unknown>>;
379
313
  /** Close status for all schedules in a fiscal period. */
380
314
  getPeriodCloseStatus(graphId: string, periodStart: string, periodEnd: string): Promise<LedgerPeriodCloseStatus | null>;
381
315
  /** All draft entries in a period, fully expanded for review pre-close. */
382
316
  listPeriodDrafts(graphId: string, period: string): Promise<LedgerPeriodDrafts | null>;
383
317
  /**
384
318
  * Idempotently create (or refresh) a draft closing entry from a
385
- * schedule for a period. See `ClosingEntryOutcome` for semantics.
386
- */
387
- createClosingEntry(graphId: string, structureId: string, postingDate: string, periodStart: string, periodEnd: string, memo?: string): Promise<ClosingEntry>;
388
- /**
389
- * Create a manual balanced closing entry (not tied to a schedule).
390
- * Used for disposals, adjustments, and one-off closing events.
319
+ * schedule for a period.
320
+ *
321
+ * Routes through `create-event-block` with
322
+ * `event_type='schedule_entry_due'`. Returns the EventBlockEnvelope —
323
+ * the underlying handler is idempotent and dispatches to one of
324
+ * created / unchanged / regenerated / removed / skipped internally.
391
325
  */
392
- createManualClosingEntry(graphId: string, options: CreateManualClosingEntryOptions): Promise<ClosingEntry>;
326
+ createClosingEntry(graphId: string, structureId: string, postingDate: string, periodStart: string, periodEnd: string, memo?: string): Promise<Record<string, unknown>>;
393
327
  /** Grouped closing book structures for the close-screen sidebar. */
394
328
  getClosingBookStructures(graphId: string): Promise<LedgerClosingBookStructures | null>;
395
329
  /** Current fiscal calendar state — pointers, gap, closeable status. */
@@ -405,12 +339,17 @@ export declare class LedgerClient {
405
339
  /**
406
340
  * Create a journal entry with balanced line items (DR=CR enforced).
407
341
  *
408
- * Defaults to `status='draft'`. Pass `status='posted'` for historical
409
- * data import where entries represent already-happened business events.
342
+ * Routes through `create-event-block` with
343
+ * `event_type='journal_entry_recorded'` the Python handler forwards
344
+ * to the internal journal-entry command. Defaults to `status='draft'`;
345
+ * pass `status='posted'` for historical data imports.
410
346
  *
411
347
  * Supply `idempotencyKey` to make the call safe to retry — replays
412
348
  * within 24 hours return the same envelope. Reusing the key with a
413
349
  * different body returns HTTP 409.
350
+ *
351
+ * Returns the EventBlockEnvelope (event row fields); query the ledger
352
+ * separately if you need the resulting entry_id.
414
353
  */
415
354
  createJournalEntry(graphId: string, options: CreateJournalEntryOptions): Promise<Record<string, unknown>>;
416
355
  /** Update a draft journal entry. Posted entries are immutable. */
@@ -422,11 +361,69 @@ export declare class LedgerClient {
422
361
  /**
423
362
  * Reverse a posted journal entry — creates an offsetting entry and marks
424
363
  * the original as reversed.
364
+ *
365
+ * Routes through `create-event-block` with
366
+ * `event_type='journal_entry_reversed'`.
425
367
  */
426
368
  reverseJournalEntry(graphId: string, entryId: string, options?: {
427
369
  postingDate?: string | null;
428
370
  memo?: string | null;
371
+ reason?: string | null;
429
372
  }): Promise<Record<string, unknown>>;
373
+ /**
374
+ * Dry-run an event block — resolve the handler, evaluate metadata, and
375
+ * return the planned GL rows without writing anything. Companion to
376
+ * `createJournalEntry` / `reverseJournalEntry` / `createClosingEntry` /
377
+ * `disposeSchedule`: pass the same body you'd send to those methods
378
+ * (the underlying `CreateEventBlockRequest`) and inspect what the
379
+ * handler would do.
380
+ */
381
+ previewEventBlock(graphId: string, body: CreateEventBlockRequest): Promise<Record<string, unknown>>;
382
+ /**
383
+ * Apply a status transition and/or field corrections to an existing
384
+ * event block. Use for posting drafts (`classified` → `committed` →
385
+ * `fulfilled`), voiding, superseding (correction chains), or patching
386
+ * `description` / `effective_at` / `metadata`.
387
+ */
388
+ updateEventBlock(graphId: string, body: UpdateEventBlockRequest): Promise<Record<string, unknown>>;
389
+ /**
390
+ * Create an agent — REA counterparty (customer, vendor, employee, etc.)
391
+ * referenced by event blocks via `agent_id`. `(source, external_id)` is
392
+ * unique when `external_id` is provided, so external-source ingestion is
393
+ * idempotent at the DB level.
394
+ */
395
+ createAgent(graphId: string, body: CreateAgentRequest, idempotencyKey?: string): Promise<Record<string, unknown>>;
396
+ /**
397
+ * Update an agent. `metadata_patch` is a partial merge into the existing
398
+ * metadata object; all other fields replace.
399
+ */
400
+ updateAgent(graphId: string, body: UpdateAgentRequest): Promise<Record<string, unknown>>;
401
+ /**
402
+ * Register a tenant-configurable event handler — DSL row in the
403
+ * `event_handlers` table that drives `create-event-block` for event
404
+ * types not covered by a Python handler. Match selectors plus a
405
+ * `transaction_template` describing the GL rows to produce.
406
+ */
407
+ createEventHandler(graphId: string, body: CreateEventHandlerRequest): Promise<Record<string, unknown>>;
408
+ /**
409
+ * Update a registered event handler. Pass `approve: true` to flip an
410
+ * AI-suggested handler from unapproved to active.
411
+ */
412
+ updateEventHandler(graphId: string, body: UpdateEventHandlerRequest): Promise<Record<string, unknown>>;
413
+ /**
414
+ * Live financial statement — pulls facts directly from the graph for
415
+ * an explicit period window (or fiscal year) and returns the statement
416
+ * shape without a persisted Report row. Useful for ad-hoc previews and
417
+ * dashboards.
418
+ */
419
+ liveFinancialStatement(graphId: string, body: LiveFinancialStatementRequest): Promise<Record<string, unknown>>;
420
+ /**
421
+ * Run a financial statement analysis against an existing report.
422
+ * On shared-repo graphs (e.g. SEC), `ticker` is required; on tenant
423
+ * graphs it's ignored. Either pass an explicit `report_id` or let the
424
+ * server auto-resolve via `fiscal_year` + `period_type`.
425
+ */
426
+ financialStatementAnalysis(graphId: string, body: FinancialStatementAnalysisRequest): Promise<Record<string, unknown>>;
430
427
  /**
431
428
  * Build a multi-dimensional fact grid against the graph schema.
432
429
  *