@robosystems/client 0.3.8 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/LedgerClient.d.ts +42 -49
- package/artifacts/LedgerClient.js +86 -116
- package/artifacts/LedgerClient.ts +155 -238
- package/artifacts/graphql/generated/graphql.d.ts +334 -68
- package/artifacts/graphql/generated/graphql.js +276 -117
- package/artifacts/graphql/generated/graphql.ts +654 -217
- package/artifacts/graphql/queries/ledger/informationBlock.d.ts +15 -0
- package/artifacts/graphql/queries/ledger/informationBlock.js +125 -0
- package/artifacts/graphql/queries/ledger/informationBlock.ts +124 -0
- package/index.ts +2 -2
- package/package.json +1 -1
- package/sdk/index.d.ts +2 -2
- package/sdk/index.js +11 -18
- package/sdk/index.ts +2 -2
- package/sdk/sdk.gen.d.ts +49 -105
- package/sdk/sdk.gen.js +82 -201
- package/sdk/sdk.gen.ts +65 -184
- package/sdk/types.gen.d.ts +2329 -2593
- package/sdk/types.gen.ts +852 -1155
- package/sdk.gen.d.ts +49 -105
- package/sdk.gen.js +82 -201
- package/sdk.gen.ts +65 -184
- package/types.gen.d.ts +2329 -2593
- package/types.gen.ts +852 -1155
- package/artifacts/graphql/queries/ledger/scheduleFacts.d.ts +0 -7
- package/artifacts/graphql/queries/ledger/scheduleFacts.js +0 -24
- package/artifacts/graphql/queries/ledger/scheduleFacts.ts +0 -22
- package/artifacts/graphql/queries/ledger/schedules.d.ts +0 -6
- package/artifacts/graphql/queries/ledger/schedules.js +0 -24
- package/artifacts/graphql/queries/ledger/schedules.ts +0 -22
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { AutoMapElementsOperation,
|
|
1
|
+
import type { AutoMapElementsOperation, CreateMappingAssociationOperation, CreateTaxonomyBlockRequest, CreateViewRequest, DeleteMappingAssociationOperation, DeleteTaxonomyBlockRequest, DisposeScheduleRequest, EvaluateRulesRequest, LinkEntityTaxonomyRequest, OperationEnvelope, UpdateEntityRequest, UpdateJournalEntryRequest, UpdateTaxonomyBlockRequest } from '../types.gen';
|
|
2
2
|
import type { TokenProvider } from './graphql/client';
|
|
3
|
-
import { 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
|
|
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']>;
|
|
5
5
|
export type LedgerEntitySummary = ListLedgerEntitiesQuery['entities'][number];
|
|
6
6
|
export type LedgerSummary = NonNullable<GetLedgerSummaryQuery['summary']>;
|
|
@@ -25,10 +25,11 @@ export type LedgerMappingList = NonNullable<ListLedgerMappingsQuery['mappings']>
|
|
|
25
25
|
export type LedgerMappingInfo = LedgerMappingList['structures'][number];
|
|
26
26
|
export type LedgerMapping = NonNullable<GetLedgerMappingQuery['mapping']>;
|
|
27
27
|
export type LedgerMappingCoverage = NonNullable<GetLedgerMappingCoverageQuery['mappingCoverage']>;
|
|
28
|
-
export type
|
|
29
|
-
export type
|
|
30
|
-
export type
|
|
31
|
-
export type
|
|
28
|
+
export type InformationBlock = NonNullable<GetInformationBlockQuery['informationBlock']>;
|
|
29
|
+
export type InformationBlockList = ListInformationBlocksQuery['informationBlocks'];
|
|
30
|
+
export type InformationBlockElement = InformationBlock['elements'][number];
|
|
31
|
+
export type InformationBlockConnection = InformationBlock['connections'][number];
|
|
32
|
+
export type InformationBlockFact = InformationBlock['facts'][number];
|
|
32
33
|
export type LedgerPeriodCloseStatus = NonNullable<GetLedgerPeriodCloseStatusQuery['periodCloseStatus']>;
|
|
33
34
|
export type LedgerPeriodCloseItem = LedgerPeriodCloseStatus['schedules'][number];
|
|
34
35
|
export type LedgerPeriodDrafts = NonNullable<GetLedgerPeriodDraftsQuery['periodDrafts']>;
|
|
@@ -267,17 +268,22 @@ export declare class LedgerClient {
|
|
|
267
268
|
listTaxonomies(graphId: string, options?: {
|
|
268
269
|
taxonomyType?: string;
|
|
269
270
|
}): Promise<LedgerTaxonomy[]>;
|
|
270
|
-
/** Create a new taxonomy (used for CoA + mapping taxonomies). */
|
|
271
|
-
createTaxonomy(graphId: string, body: CreateTaxonomyRequest): Promise<Record<string, unknown>>;
|
|
272
|
-
/** Update mutable fields on a taxonomy. `taxonomy_type` is immutable. */
|
|
273
|
-
updateTaxonomy(graphId: string, body: UpdateTaxonomyRequest): Promise<Record<string, unknown>>;
|
|
274
|
-
/** Soft-delete a taxonomy (`is_active=false`). */
|
|
275
|
-
deleteTaxonomy(graphId: string, taxonomyId: string): Promise<Record<string, unknown>>;
|
|
276
271
|
/**
|
|
277
272
|
* Link the graph's entity to a taxonomy (ENTITY_HAS_TAXONOMY edge).
|
|
278
273
|
* Idempotent — returns existing linkage if already present.
|
|
279
274
|
*/
|
|
280
275
|
linkEntityTaxonomy(graphId: string, body: LinkEntityTaxonomyRequest): Promise<Record<string, unknown>>;
|
|
276
|
+
/**
|
|
277
|
+
* Create a taxonomy block atomically (taxonomy + structures + elements +
|
|
278
|
+
* associations + rules in one envelope).
|
|
279
|
+
*/
|
|
280
|
+
createTaxonomyBlock(graphId: string, body: CreateTaxonomyBlockRequest, idempotencyKey?: string): Promise<Record<string, unknown>>;
|
|
281
|
+
/** Update a taxonomy block — add/update/remove elements, structures, associations, or rules. */
|
|
282
|
+
updateTaxonomyBlock(graphId: string, body: UpdateTaxonomyBlockRequest): Promise<Record<string, unknown>>;
|
|
283
|
+
/** Delete a taxonomy block. Cascades through elements, structures, and associations. */
|
|
284
|
+
deleteTaxonomyBlock(graphId: string, body: DeleteTaxonomyBlockRequest): Promise<{
|
|
285
|
+
deleted: boolean;
|
|
286
|
+
}>;
|
|
281
287
|
/** List elements (CoA accounts, GAAP concepts, etc.) with filters. */
|
|
282
288
|
listElements(graphId: string, options?: {
|
|
283
289
|
taxonomyId?: string;
|
|
@@ -291,32 +297,11 @@ export declare class LedgerClient {
|
|
|
291
297
|
listUnmappedElements(graphId: string, options?: {
|
|
292
298
|
mappingId?: string;
|
|
293
299
|
}): Promise<LedgerUnmappedElement[]>;
|
|
294
|
-
/** Create a new element within a taxonomy (native CoA account, etc.). */
|
|
295
|
-
createElement(graphId: string, body: CreateElementRequest): Promise<Record<string, unknown>>;
|
|
296
|
-
/** Update mutable fields on an element. `taxonomy_id` and `source` are immutable. */
|
|
297
|
-
updateElement(graphId: string, body: UpdateElementRequest): Promise<Record<string, unknown>>;
|
|
298
|
-
/** Soft-delete an element (`is_active=false`). */
|
|
299
|
-
deleteElement(graphId: string, elementId: string): Promise<Record<string, unknown>>;
|
|
300
300
|
/** List reporting structures (IS, BS, CF, schedules) with optional filters. */
|
|
301
301
|
listStructures(graphId: string, options?: {
|
|
302
302
|
taxonomyId?: string;
|
|
303
303
|
structureType?: string;
|
|
304
304
|
}): Promise<LedgerStructure[]>;
|
|
305
|
-
/**
|
|
306
|
-
* Create a new structure. Most common use is a CoA→reporting mapping
|
|
307
|
-
* structure; also used for custom statement + schedule structures.
|
|
308
|
-
*/
|
|
309
|
-
createStructure(graphId: string, body: CreateStructureRequest): Promise<LedgerMappingInfo>;
|
|
310
|
-
/** Convenience wrapper — create a CoA→GAAP mapping structure. */
|
|
311
|
-
createMappingStructure(graphId: string, options?: {
|
|
312
|
-
name?: string;
|
|
313
|
-
description?: string | null;
|
|
314
|
-
taxonomyId?: string;
|
|
315
|
-
}): Promise<LedgerMappingInfo>;
|
|
316
|
-
/** Update mutable fields on a structure. `structure_type` is immutable. */
|
|
317
|
-
updateStructure(graphId: string, body: UpdateStructureRequest): Promise<Record<string, unknown>>;
|
|
318
|
-
/** Soft-delete a structure (`is_active=false`). */
|
|
319
|
-
deleteStructure(graphId: string, structureId: string): Promise<Record<string, unknown>>;
|
|
320
305
|
/** List active CoA→reporting mapping structures. */
|
|
321
306
|
listMappings(graphId: string): Promise<LedgerMappingInfo[]>;
|
|
322
307
|
/** Get a mapping structure with all its associations. */
|
|
@@ -338,31 +323,39 @@ export declare class LedgerClient {
|
|
|
338
323
|
operationId: string;
|
|
339
324
|
status: OperationEnvelope['status'];
|
|
340
325
|
}>;
|
|
341
|
-
/**
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
326
|
+
/**
|
|
327
|
+
* Fetch an Information Block envelope by id — the generic
|
|
328
|
+
* cross-block-type read. Returns `null` when the block doesn't exist
|
|
329
|
+
* (or its type isn't registered). See `information-block.md`.
|
|
330
|
+
*/
|
|
331
|
+
getInformationBlock(graphId: string, id: string): Promise<InformationBlock | null>;
|
|
332
|
+
/**
|
|
333
|
+
* List Information Block envelopes with optional block_type + category
|
|
334
|
+
* filters. Replaces the old `listSchedules` method — callers use
|
|
335
|
+
* `{blockType: 'schedule'}` to get the same set of blocks.
|
|
336
|
+
*/
|
|
337
|
+
listInformationBlocks(graphId: string, options?: {
|
|
338
|
+
blockType?: string;
|
|
339
|
+
category?: string;
|
|
340
|
+
limit?: number;
|
|
341
|
+
offset?: number;
|
|
342
|
+
}): Promise<InformationBlockList>;
|
|
356
343
|
/** Create a new schedule with pre-generated monthly facts. */
|
|
357
344
|
createSchedule(graphId: string, options: CreateScheduleOptions): Promise<ScheduleCreated>;
|
|
358
345
|
/** Update mutable fields on a schedule (name, entry_template, metadata). */
|
|
359
|
-
updateSchedule(graphId: string,
|
|
346
|
+
updateSchedule(graphId: string, structureId: string, options: {
|
|
347
|
+
name?: string;
|
|
348
|
+
}): Promise<Record<string, unknown>>;
|
|
360
349
|
/** Permanently delete a schedule (cascades through facts + associations). */
|
|
361
350
|
deleteSchedule(graphId: string, structureId: string): Promise<{
|
|
362
351
|
deleted: boolean;
|
|
363
352
|
}>;
|
|
364
353
|
/** Truncate a schedule — end it early at `newEndDate`. */
|
|
365
354
|
truncateSchedule(graphId: string, structureId: string, options: TruncateScheduleOptions): Promise<TruncateScheduleResult>;
|
|
355
|
+
/** Dispose of a schedule asset — post a disposal entry and delete forward facts. */
|
|
356
|
+
disposeSchedule(graphId: string, body: DisposeScheduleRequest): Promise<Record<string, unknown>>;
|
|
357
|
+
/** Evaluate taxonomy rules against facts in a structure. */
|
|
358
|
+
evaluateRules(graphId: string, body: EvaluateRulesRequest): Promise<Record<string, unknown>>;
|
|
366
359
|
/** Close status for all schedules in a fiscal period. */
|
|
367
360
|
getPeriodCloseStatus(graphId: string, periodStart: string, periodEnd: string): Promise<LedgerPeriodCloseStatus | null>;
|
|
368
361
|
/** All draft entries in a period, fully expanded for review pre-close. */
|
|
@@ -132,22 +132,6 @@ class LedgerClient {
|
|
|
132
132
|
const list = await this.gqlQuery(graphId, graphql_1.ListLedgerTaxonomiesDocument, { taxonomyType: options?.taxonomyType ?? null }, 'List taxonomies', (data) => data.taxonomies);
|
|
133
133
|
return list?.taxonomies ?? [];
|
|
134
134
|
}
|
|
135
|
-
/** Create a new taxonomy (used for CoA + mapping taxonomies). */
|
|
136
|
-
async createTaxonomy(graphId, body) {
|
|
137
|
-
const envelope = await this.callOperation('Create taxonomy', (0, sdk_gen_1.opCreateTaxonomy)({ path: { graph_id: graphId }, body }));
|
|
138
|
-
return (envelope.result ?? {});
|
|
139
|
-
}
|
|
140
|
-
/** Update mutable fields on a taxonomy. `taxonomy_type` is immutable. */
|
|
141
|
-
async updateTaxonomy(graphId, body) {
|
|
142
|
-
const envelope = await this.callOperation('Update taxonomy', (0, sdk_gen_1.opUpdateTaxonomy)({ path: { graph_id: graphId }, body }));
|
|
143
|
-
return (envelope.result ?? {});
|
|
144
|
-
}
|
|
145
|
-
/** Soft-delete a taxonomy (`is_active=false`). */
|
|
146
|
-
async deleteTaxonomy(graphId, taxonomyId) {
|
|
147
|
-
const body = { taxonomy_id: taxonomyId };
|
|
148
|
-
const envelope = await this.callOperation('Delete taxonomy', (0, sdk_gen_1.opDeleteTaxonomy)({ path: { graph_id: graphId }, body }));
|
|
149
|
-
return (envelope.result ?? {});
|
|
150
|
-
}
|
|
151
135
|
/**
|
|
152
136
|
* Link the graph's entity to a taxonomy (ENTITY_HAS_TAXONOMY edge).
|
|
153
137
|
* Idempotent — returns existing linkage if already present.
|
|
@@ -156,6 +140,25 @@ class LedgerClient {
|
|
|
156
140
|
const envelope = await this.callOperation('Link entity taxonomy', (0, sdk_gen_1.opLinkEntityTaxonomy)({ path: { graph_id: graphId }, body }));
|
|
157
141
|
return (envelope.result ?? {});
|
|
158
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Create a taxonomy block atomically (taxonomy + structures + elements +
|
|
145
|
+
* associations + rules in one envelope).
|
|
146
|
+
*/
|
|
147
|
+
async createTaxonomyBlock(graphId, body, idempotencyKey) {
|
|
148
|
+
const headers = idempotencyKey ? { 'Idempotency-Key': idempotencyKey } : undefined;
|
|
149
|
+
const envelope = await this.callOperation('Create taxonomy block', (0, sdk_gen_1.opCreateTaxonomyBlock)({ path: { graph_id: graphId }, body, headers }));
|
|
150
|
+
return (envelope.result ?? {});
|
|
151
|
+
}
|
|
152
|
+
/** Update a taxonomy block — add/update/remove elements, structures, associations, or rules. */
|
|
153
|
+
async updateTaxonomyBlock(graphId, body) {
|
|
154
|
+
const envelope = await this.callOperation('Update taxonomy block', (0, sdk_gen_1.opUpdateTaxonomyBlock)({ path: { graph_id: graphId }, body }));
|
|
155
|
+
return (envelope.result ?? {});
|
|
156
|
+
}
|
|
157
|
+
/** Delete a taxonomy block. Cascades through elements, structures, and associations. */
|
|
158
|
+
async deleteTaxonomyBlock(graphId, body) {
|
|
159
|
+
const envelope = await this.callOperation('Delete taxonomy block', (0, sdk_gen_1.opDeleteTaxonomyBlock)({ path: { graph_id: graphId }, body }));
|
|
160
|
+
return (envelope.result ?? { deleted: true });
|
|
161
|
+
}
|
|
159
162
|
/** List elements (CoA accounts, GAAP concepts, etc.) with filters. */
|
|
160
163
|
async listElements(graphId, options) {
|
|
161
164
|
return this.gqlQuery(graphId, graphql_1.ListLedgerElementsDocument, {
|
|
@@ -171,22 +174,6 @@ class LedgerClient {
|
|
|
171
174
|
async listUnmappedElements(graphId, options) {
|
|
172
175
|
return this.gqlQuery(graphId, graphql_1.ListLedgerUnmappedElementsDocument, { mappingId: options?.mappingId ?? null }, 'List unmapped elements', (data) => data.unmappedElements);
|
|
173
176
|
}
|
|
174
|
-
/** Create a new element within a taxonomy (native CoA account, etc.). */
|
|
175
|
-
async createElement(graphId, body) {
|
|
176
|
-
const envelope = await this.callOperation('Create element', (0, sdk_gen_1.opCreateElement)({ path: { graph_id: graphId }, body }));
|
|
177
|
-
return (envelope.result ?? {});
|
|
178
|
-
}
|
|
179
|
-
/** Update mutable fields on an element. `taxonomy_id` and `source` are immutable. */
|
|
180
|
-
async updateElement(graphId, body) {
|
|
181
|
-
const envelope = await this.callOperation('Update element', (0, sdk_gen_1.opUpdateElement)({ path: { graph_id: graphId }, body }));
|
|
182
|
-
return (envelope.result ?? {});
|
|
183
|
-
}
|
|
184
|
-
/** Soft-delete an element (`is_active=false`). */
|
|
185
|
-
async deleteElement(graphId, elementId) {
|
|
186
|
-
const body = { element_id: elementId };
|
|
187
|
-
const envelope = await this.callOperation('Delete element', (0, sdk_gen_1.opDeleteElement)({ path: { graph_id: graphId }, body }));
|
|
188
|
-
return (envelope.result ?? {});
|
|
189
|
-
}
|
|
190
177
|
// ── Structures ──────────────────────────────────────────────────────
|
|
191
178
|
/** List reporting structures (IS, BS, CF, schedules) with optional filters. */
|
|
192
179
|
async listStructures(graphId, options) {
|
|
@@ -196,36 +183,6 @@ class LedgerClient {
|
|
|
196
183
|
}, 'List structures', (data) => data.structures);
|
|
197
184
|
return list?.structures ?? [];
|
|
198
185
|
}
|
|
199
|
-
/**
|
|
200
|
-
* Create a new structure. Most common use is a CoA→reporting mapping
|
|
201
|
-
* structure; also used for custom statement + schedule structures.
|
|
202
|
-
*/
|
|
203
|
-
async createStructure(graphId, body) {
|
|
204
|
-
const envelope = await this.callOperation('Create structure', (0, sdk_gen_1.opCreateStructure)({ path: { graph_id: graphId }, body }));
|
|
205
|
-
return envelope.result;
|
|
206
|
-
}
|
|
207
|
-
/** Convenience wrapper — create a CoA→GAAP mapping structure. */
|
|
208
|
-
async createMappingStructure(graphId, options) {
|
|
209
|
-
const body = {
|
|
210
|
-
name: options?.name ?? 'CoA to Reporting',
|
|
211
|
-
structure_type: 'coa_mapping',
|
|
212
|
-
taxonomy_id: options?.taxonomyId ?? 'tax_usgaap_reporting',
|
|
213
|
-
description: options?.description ?? 'Map Chart of Accounts to US GAAP reporting concepts',
|
|
214
|
-
};
|
|
215
|
-
const envelope = await this.callOperation('Create mapping structure', (0, sdk_gen_1.opCreateStructure)({ path: { graph_id: graphId }, body }));
|
|
216
|
-
return envelope.result;
|
|
217
|
-
}
|
|
218
|
-
/** Update mutable fields on a structure. `structure_type` is immutable. */
|
|
219
|
-
async updateStructure(graphId, body) {
|
|
220
|
-
const envelope = await this.callOperation('Update structure', (0, sdk_gen_1.opUpdateStructure)({ path: { graph_id: graphId }, body }));
|
|
221
|
-
return (envelope.result ?? {});
|
|
222
|
-
}
|
|
223
|
-
/** Soft-delete a structure (`is_active=false`). */
|
|
224
|
-
async deleteStructure(graphId, structureId) {
|
|
225
|
-
const body = { structure_id: structureId };
|
|
226
|
-
const envelope = await this.callOperation('Delete structure', (0, sdk_gen_1.opDeleteStructure)({ path: { graph_id: graphId }, body }));
|
|
227
|
-
return (envelope.result ?? {});
|
|
228
|
-
}
|
|
229
186
|
// ── Mappings ────────────────────────────────────────────────────────
|
|
230
187
|
/** List active CoA→reporting mapping structures. */
|
|
231
188
|
async listMappings(graphId) {
|
|
@@ -259,64 +216,60 @@ class LedgerClient {
|
|
|
259
216
|
const envelope = await this.callOperation('Auto-map elements', (0, sdk_gen_1.opAutoMapElements)({ path: { graph_id: graphId }, body }));
|
|
260
217
|
return { operationId: envelope.operationId, status: envelope.status };
|
|
261
218
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
return (envelope.result ?? {});
|
|
219
|
+
// ── Information Blocks ─────────────────────────────────────────────
|
|
220
|
+
/**
|
|
221
|
+
* Fetch an Information Block envelope by id — the generic
|
|
222
|
+
* cross-block-type read. Returns `null` when the block doesn't exist
|
|
223
|
+
* (or its type isn't registered). See `information-block.md`.
|
|
224
|
+
*/
|
|
225
|
+
async getInformationBlock(graphId, id) {
|
|
226
|
+
const block = await this.gqlQuery(graphId, graphql_1.GetInformationBlockDocument, { id }, 'Get information block', (data) => data.informationBlock ?? null);
|
|
227
|
+
return block ?? null;
|
|
272
228
|
}
|
|
273
|
-
/**
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
229
|
+
/**
|
|
230
|
+
* List Information Block envelopes with optional block_type + category
|
|
231
|
+
* filters. Replaces the old `listSchedules` method — callers use
|
|
232
|
+
* `{blockType: 'schedule'}` to get the same set of blocks.
|
|
233
|
+
*/
|
|
234
|
+
async listInformationBlocks(graphId, options) {
|
|
235
|
+
const blocks = await this.gqlQuery(graphId, graphql_1.ListInformationBlocksDocument, {
|
|
236
|
+
blockType: options?.blockType ?? null,
|
|
237
|
+
category: options?.category ?? null,
|
|
238
|
+
limit: options?.limit ?? null,
|
|
239
|
+
offset: options?.offset ?? null,
|
|
240
|
+
}, 'List information blocks', (data) => data.informationBlocks);
|
|
241
|
+
return blocks ?? [];
|
|
278
242
|
}
|
|
279
243
|
// ── Schedules ──────────────────────────────────────────────────────
|
|
280
|
-
/** List all schedule structures with metadata. */
|
|
281
|
-
async listSchedules(graphId) {
|
|
282
|
-
const list = await this.gqlQuery(graphId, graphql_1.ListLedgerSchedulesDocument, undefined, 'List schedules', (data) => data.schedules);
|
|
283
|
-
return list?.schedules ?? [];
|
|
284
|
-
}
|
|
285
|
-
/** Schedule facts optionally filtered by period window. */
|
|
286
|
-
async getScheduleFacts(graphId, structureId, options) {
|
|
287
|
-
const facts = await this.gqlQuery(graphId, graphql_1.GetLedgerScheduleFactsDocument, {
|
|
288
|
-
structureId,
|
|
289
|
-
periodStart: options?.periodStart ?? null,
|
|
290
|
-
periodEnd: options?.periodEnd ?? null,
|
|
291
|
-
}, 'Get schedule facts', (data) => data.scheduleFacts);
|
|
292
|
-
return facts?.facts ?? [];
|
|
293
|
-
}
|
|
294
244
|
/** Create a new schedule with pre-generated monthly facts. */
|
|
295
245
|
async createSchedule(graphId, options) {
|
|
296
246
|
const body = {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
247
|
+
block_type: 'schedule',
|
|
248
|
+
payload: {
|
|
249
|
+
name: options.name,
|
|
250
|
+
element_ids: options.elementIds,
|
|
251
|
+
period_start: options.periodStart,
|
|
252
|
+
period_end: options.periodEnd,
|
|
253
|
+
monthly_amount: options.monthlyAmount,
|
|
254
|
+
entry_template: {
|
|
255
|
+
debit_element_id: options.entryTemplate.debitElementId,
|
|
256
|
+
credit_element_id: options.entryTemplate.creditElementId,
|
|
257
|
+
entry_type: options.entryTemplate.entryType,
|
|
258
|
+
memo_template: options.entryTemplate.memoTemplate,
|
|
259
|
+
},
|
|
260
|
+
taxonomy_id: options.taxonomyId,
|
|
261
|
+
schedule_metadata: options.scheduleMetadata
|
|
262
|
+
? {
|
|
263
|
+
method: options.scheduleMetadata.method,
|
|
264
|
+
original_amount: options.scheduleMetadata.originalAmount,
|
|
265
|
+
residual_value: options.scheduleMetadata.residualValue,
|
|
266
|
+
useful_life_months: options.scheduleMetadata.usefulLifeMonths,
|
|
267
|
+
asset_element_id: options.scheduleMetadata.assetElementId,
|
|
268
|
+
}
|
|
269
|
+
: undefined,
|
|
307
270
|
},
|
|
308
|
-
taxonomy_id: options.taxonomyId,
|
|
309
|
-
schedule_metadata: options.scheduleMetadata
|
|
310
|
-
? {
|
|
311
|
-
method: options.scheduleMetadata.method,
|
|
312
|
-
original_amount: options.scheduleMetadata.originalAmount,
|
|
313
|
-
residual_value: options.scheduleMetadata.residualValue,
|
|
314
|
-
useful_life_months: options.scheduleMetadata.usefulLifeMonths,
|
|
315
|
-
asset_element_id: options.scheduleMetadata.assetElementId,
|
|
316
|
-
}
|
|
317
|
-
: undefined,
|
|
318
271
|
};
|
|
319
|
-
const envelope = await this.callOperation('Create schedule', (0, sdk_gen_1.
|
|
272
|
+
const envelope = await this.callOperation('Create schedule', (0, sdk_gen_1.opCreateInformationBlock)({ path: { graph_id: graphId }, body }));
|
|
320
273
|
const raw = envelope.result;
|
|
321
274
|
return {
|
|
322
275
|
structureId: raw.structure_id,
|
|
@@ -327,14 +280,21 @@ class LedgerClient {
|
|
|
327
280
|
};
|
|
328
281
|
}
|
|
329
282
|
/** Update mutable fields on a schedule (name, entry_template, metadata). */
|
|
330
|
-
async updateSchedule(graphId,
|
|
331
|
-
const
|
|
283
|
+
async updateSchedule(graphId, structureId, options) {
|
|
284
|
+
const body = {
|
|
285
|
+
block_type: 'schedule',
|
|
286
|
+
payload: { structure_id: structureId, ...options },
|
|
287
|
+
};
|
|
288
|
+
const envelope = await this.callOperation('Update schedule', (0, sdk_gen_1.opUpdateInformationBlock)({ path: { graph_id: graphId }, body }));
|
|
332
289
|
return (envelope.result ?? {});
|
|
333
290
|
}
|
|
334
291
|
/** Permanently delete a schedule (cascades through facts + associations). */
|
|
335
292
|
async deleteSchedule(graphId, structureId) {
|
|
336
|
-
const body = {
|
|
337
|
-
|
|
293
|
+
const body = {
|
|
294
|
+
block_type: 'schedule',
|
|
295
|
+
payload: { structure_id: structureId },
|
|
296
|
+
};
|
|
297
|
+
const envelope = await this.callOperation('Delete schedule', (0, sdk_gen_1.opDeleteInformationBlock)({ path: { graph_id: graphId }, body }));
|
|
338
298
|
return (envelope.result ?? { deleted: true });
|
|
339
299
|
}
|
|
340
300
|
/** Truncate a schedule — end it early at `newEndDate`. */
|
|
@@ -353,6 +313,16 @@ class LedgerClient {
|
|
|
353
313
|
reason: raw.reason,
|
|
354
314
|
};
|
|
355
315
|
}
|
|
316
|
+
/** Dispose of a schedule asset — post a disposal entry and delete forward facts. */
|
|
317
|
+
async disposeSchedule(graphId, body) {
|
|
318
|
+
const envelope = await this.callOperation('Dispose schedule', (0, sdk_gen_1.opDisposeSchedule)({ path: { graph_id: graphId }, body }));
|
|
319
|
+
return (envelope.result ?? {});
|
|
320
|
+
}
|
|
321
|
+
/** Evaluate taxonomy rules against facts in a structure. */
|
|
322
|
+
async evaluateRules(graphId, body) {
|
|
323
|
+
const envelope = await this.callOperation('Evaluate rules', (0, sdk_gen_1.opEvaluateRules)({ path: { graph_id: graphId }, body }));
|
|
324
|
+
return (envelope.result ?? {});
|
|
325
|
+
}
|
|
356
326
|
// ── Period close ────────────────────────────────────────────────────
|
|
357
327
|
/** Close status for all schedules in a fiscal period. */
|
|
358
328
|
async getPeriodCloseStatus(graphId, periodStart, periodEnd) {
|