@robosystems/client 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{extensions → artifacts}/InvestorClient.js +0 -1
- package/{extensions → artifacts}/InvestorClient.ts +1 -1
- package/{extensions → artifacts}/LedgerClient.d.ts +168 -2
- package/{extensions → artifacts}/LedgerClient.js +301 -2
- package/{extensions → artifacts}/LedgerClient.ts +645 -2
- package/{extensions → artifacts}/config.d.ts +11 -11
- package/{extensions → artifacts}/config.js +11 -11
- package/{extensions → artifacts}/config.ts +16 -16
- package/{extensions → artifacts}/graphql/client.d.ts +1 -1
- package/{extensions → artifacts}/graphql/client.js +1 -2
- package/{extensions → artifacts}/graphql/client.ts +2 -2
- package/{extensions → artifacts}/hooks.js +6 -6
- package/{extensions → artifacts}/hooks.ts +7 -7
- package/{extensions → artifacts}/index.d.ts +21 -18
- package/{extensions → artifacts}/index.js +43 -53
- package/{extensions → artifacts}/index.ts +47 -60
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/index.ts +2 -2
- package/package.json +38 -8
- package/sdk/index.d.ts +2 -2
- package/sdk/index.js +27 -9
- package/sdk/index.ts +2 -2
- package/sdk/sdk.gen.d.ts +272 -274
- package/sdk/sdk.gen.js +468 -312
- package/sdk/sdk.gen.ts +464 -309
- package/sdk/types.gen.d.ts +2962 -440
- package/sdk/types.gen.ts +3058 -430
- package/sdk.gen.d.ts +272 -274
- package/sdk.gen.js +468 -312
- package/sdk.gen.ts +464 -309
- package/types.gen.d.ts +2962 -440
- package/types.gen.ts +3058 -430
- package/extensions/ReportClient.d.ts +0 -120
- package/extensions/ReportClient.js +0 -191
- package/extensions/ReportClient.ts +0 -433
- /package/{extensions → artifacts}/AgentClient.d.ts +0 -0
- /package/{extensions → artifacts}/AgentClient.js +0 -0
- /package/{extensions → artifacts}/AgentClient.ts +0 -0
- /package/{extensions → artifacts}/InvestorClient.d.ts +0 -0
- /package/{extensions → artifacts}/OperationClient.d.ts +0 -0
- /package/{extensions → artifacts}/OperationClient.js +0 -0
- /package/{extensions → artifacts}/OperationClient.ts +0 -0
- /package/{extensions → artifacts}/QueryClient.d.ts +0 -0
- /package/{extensions → artifacts}/QueryClient.js +0 -0
- /package/{extensions → artifacts}/QueryClient.ts +0 -0
- /package/{extensions → artifacts}/SSEClient.d.ts +0 -0
- /package/{extensions → artifacts}/SSEClient.js +0 -0
- /package/{extensions → artifacts}/SSEClient.ts +0 -0
- /package/{extensions → artifacts}/graphql/generated/graphql.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/generated/graphql.js +0 -0
- /package/{extensions → artifacts}/graphql/generated/graphql.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/holdings.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/holdings.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/holdings.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/portfolio.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/portfolio.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/portfolio.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/portfolios.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/portfolios.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/portfolios.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/position.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/position.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/position.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/positions.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/positions.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/positions.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/securities.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/securities.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/securities.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/security.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/security.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/investor/security.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/accountRollups.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/accountRollups.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/accountRollups.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/accountTree.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/accountTree.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/accountTree.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/accounts.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/accounts.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/accounts.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/closingBookStructures.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/closingBookStructures.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/closingBookStructures.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/elements.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/elements.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/elements.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/entities.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/entities.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/entities.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/entity.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/entity.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/entity.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/fiscalCalendar.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/fiscalCalendar.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/fiscalCalendar.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mappedTrialBalance.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mappedTrialBalance.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mappedTrialBalance.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mapping.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mapping.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mapping.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mappingCoverage.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mappingCoverage.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mappingCoverage.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mappings.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mappings.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/mappings.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/periodCloseStatus.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/periodCloseStatus.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/periodCloseStatus.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/periodDrafts.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/periodDrafts.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/periodDrafts.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/publishList.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/publishList.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/publishList.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/publishLists.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/publishLists.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/publishLists.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/report.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/report.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/report.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/reportingTaxonomy.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/reportingTaxonomy.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/reportingTaxonomy.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/reports.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/reports.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/reports.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/scheduleFacts.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/scheduleFacts.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/scheduleFacts.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/schedules.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/schedules.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/schedules.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/statement.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/statement.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/statement.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/structures.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/structures.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/structures.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/summary.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/summary.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/summary.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/taxonomies.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/taxonomies.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/taxonomies.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/transaction.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/transaction.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/transaction.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/transactions.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/transactions.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/transactions.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/trialBalance.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/trialBalance.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/trialBalance.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/unmappedElements.d.ts +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/unmappedElements.js +0 -0
- /package/{extensions → artifacts}/graphql/queries/ledger/unmappedElements.ts +0 -0
- /package/{extensions → artifacts}/hooks.d.ts +0 -0
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import type { OperationEnvelope } from '../types.gen';
|
|
2
|
-
import type { TokenProvider } from './graphql/client';
|
|
3
|
-
import { type GetLedgerPublishListQuery, type GetLedgerReportQuery, type GetLedgerStatementQuery, type ListLedgerPublishListsQuery, type ListLedgerReportsQuery } from './graphql/generated/graphql';
|
|
4
|
-
export type Report = NonNullable<GetLedgerReportQuery['report']>;
|
|
5
|
-
export type ReportListItem = NonNullable<ListLedgerReportsQuery['reports']>['reports'][number];
|
|
6
|
-
export type StatementData = NonNullable<GetLedgerStatementQuery['statement']>;
|
|
7
|
-
export type StatementPeriod = StatementData['periods'][number];
|
|
8
|
-
export type StatementRow = StatementData['rows'][number];
|
|
9
|
-
export type PublishList = NonNullable<ListLedgerPublishListsQuery['publishLists']>['publishLists'][number];
|
|
10
|
-
export type PublishListDetail = NonNullable<GetLedgerPublishListQuery['publishList']>;
|
|
11
|
-
export type PublishListMember = PublishListDetail['members'][number];
|
|
12
|
-
export interface PeriodSpecInput {
|
|
13
|
-
start: string;
|
|
14
|
-
end: string;
|
|
15
|
-
label: string;
|
|
16
|
-
}
|
|
17
|
-
export interface CreateReportOptions {
|
|
18
|
-
name: string;
|
|
19
|
-
mappingId: string;
|
|
20
|
-
periodStart: string;
|
|
21
|
-
periodEnd: string;
|
|
22
|
-
taxonomyId?: string;
|
|
23
|
-
periodType?: string;
|
|
24
|
-
comparative?: boolean;
|
|
25
|
-
/** When set, overrides periodStart/periodEnd/comparative with N explicit periods. */
|
|
26
|
-
periods?: PeriodSpecInput[];
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Envelope around a report operation. `status === "completed"` means the
|
|
30
|
-
* backend produced the report synchronously — `result` contains the
|
|
31
|
-
* freshly-created report shape (same fields as `ReportListItem`), so
|
|
32
|
-
* consumers can read `result?.id` immediately. For pending/failed
|
|
33
|
-
* dispatches, `result` is null and consumers should subscribe to
|
|
34
|
-
* `/v1/operations/{operationId}/stream` for progress.
|
|
35
|
-
*
|
|
36
|
-
* The loose `{ id; name; ... }` shape here intentionally mirrors the
|
|
37
|
-
* GraphQL `report` field without pulling in every nullable child relation
|
|
38
|
-
* — `create_report` and `regenerate_report` return a freshly-generated
|
|
39
|
-
* row, not a fully-resolved GraphQL projection.
|
|
40
|
-
*/
|
|
41
|
-
export interface ReportOperationAck {
|
|
42
|
-
operationId: string;
|
|
43
|
-
status: OperationEnvelope['status'];
|
|
44
|
-
/**
|
|
45
|
-
* Synchronous command result. Populated for `status === "completed"`
|
|
46
|
-
* dispatches where the backend produced the report inline.
|
|
47
|
-
*/
|
|
48
|
-
result: Record<string, unknown> | null;
|
|
49
|
-
}
|
|
50
|
-
interface ReportClientConfig {
|
|
51
|
-
baseUrl: string;
|
|
52
|
-
credentials?: 'include' | 'same-origin' | 'omit';
|
|
53
|
-
headers?: Record<string, string>;
|
|
54
|
-
/** Static credential — use `tokenProvider` instead if the JWT rotates. */
|
|
55
|
-
token?: string;
|
|
56
|
-
/**
|
|
57
|
-
* Dynamic credential callback. When set, invoked on every GraphQL
|
|
58
|
-
* request so refreshes flow through automatically.
|
|
59
|
-
*/
|
|
60
|
-
tokenProvider?: TokenProvider;
|
|
61
|
-
}
|
|
62
|
-
export declare class ReportClient {
|
|
63
|
-
private config;
|
|
64
|
-
private gql;
|
|
65
|
-
constructor(config: ReportClientConfig);
|
|
66
|
-
/**
|
|
67
|
-
* Kick off report creation (async). Use the returned `operationId` to
|
|
68
|
-
* subscribe to progress via SSE, then call `get()` once finished.
|
|
69
|
-
*/
|
|
70
|
-
create(graphId: string, options: CreateReportOptions): Promise<ReportOperationAck>;
|
|
71
|
-
/** List all reports for a graph (includes received shared reports). */
|
|
72
|
-
list(graphId: string): Promise<ReportListItem[]>;
|
|
73
|
-
/** Get a single report with its period list + available structures. */
|
|
74
|
-
get(graphId: string, reportId: string): Promise<Report | null>;
|
|
75
|
-
/**
|
|
76
|
-
* Render a financial statement — facts viewed through a structure.
|
|
77
|
-
*
|
|
78
|
-
* @param structureType - income_statement, balance_sheet, cash_flow_statement
|
|
79
|
-
*/
|
|
80
|
-
statement(graphId: string, reportId: string, structureType: string): Promise<StatementData | null>;
|
|
81
|
-
/**
|
|
82
|
-
* Regenerate an existing report (async). Returns an operation id;
|
|
83
|
-
* subscribe via SSE for progress.
|
|
84
|
-
*/
|
|
85
|
-
regenerate(graphId: string, reportId: string, periodStart?: string, periodEnd?: string): Promise<ReportOperationAck>;
|
|
86
|
-
/** Delete a report and its generated facts. */
|
|
87
|
-
delete(graphId: string, reportId: string): Promise<void>;
|
|
88
|
-
/**
|
|
89
|
-
* Share a published report to every member of a publish list (async).
|
|
90
|
-
* Each target graph receives a snapshot copy of the report's facts.
|
|
91
|
-
*/
|
|
92
|
-
share(graphId: string, reportId: string, publishListId: string): Promise<ReportOperationAck>;
|
|
93
|
-
/** Check if a report was received via sharing (vs locally created). */
|
|
94
|
-
isSharedReport(report: Report): boolean;
|
|
95
|
-
/** List publish lists with pagination. */
|
|
96
|
-
listPublishLists(graphId: string, options?: {
|
|
97
|
-
limit?: number;
|
|
98
|
-
offset?: number;
|
|
99
|
-
}): Promise<PublishList[]>;
|
|
100
|
-
/** Create a new publish list. */
|
|
101
|
-
createPublishList(graphId: string, name: string, description?: string): Promise<Record<string, unknown>>;
|
|
102
|
-
/** Get a single publish list with its full member list. */
|
|
103
|
-
getPublishList(graphId: string, listId: string): Promise<PublishListDetail | null>;
|
|
104
|
-
/** Update a publish list's name or description. */
|
|
105
|
-
updatePublishList(graphId: string, listId: string, updates: {
|
|
106
|
-
name?: string;
|
|
107
|
-
description?: string | null;
|
|
108
|
-
}): Promise<Record<string, unknown>>;
|
|
109
|
-
/** Delete a publish list. */
|
|
110
|
-
deletePublishList(graphId: string, listId: string): Promise<void>;
|
|
111
|
-
/** Add target graphs as members of a publish list. */
|
|
112
|
-
addMembers(graphId: string, listId: string, targetGraphIds: string[]): Promise<Record<string, unknown>>;
|
|
113
|
-
/** Remove a single member from a publish list. */
|
|
114
|
-
removeMember(graphId: string, listId: string, memberId: string): Promise<{
|
|
115
|
-
deleted: boolean;
|
|
116
|
-
}>;
|
|
117
|
-
private gqlQuery;
|
|
118
|
-
private callOperation;
|
|
119
|
-
}
|
|
120
|
-
export {};
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ReportClient = void 0;
|
|
5
|
-
const graphql_request_1 = require("graphql-request");
|
|
6
|
-
const sdk_gen_1 = require("../sdk.gen");
|
|
7
|
-
const client_1 = require("./graphql/client");
|
|
8
|
-
const graphql_1 = require("./graphql/generated/graphql");
|
|
9
|
-
class ReportClient {
|
|
10
|
-
constructor(config) {
|
|
11
|
-
this.config = config;
|
|
12
|
-
this.gql = new client_1.GraphQLClientCache(config);
|
|
13
|
-
}
|
|
14
|
-
// ── Reports ─────────────────────────────────────────────────────────
|
|
15
|
-
/**
|
|
16
|
-
* Kick off report creation (async). Use the returned `operationId` to
|
|
17
|
-
* subscribe to progress via SSE, then call `get()` once finished.
|
|
18
|
-
*/
|
|
19
|
-
async create(graphId, options) {
|
|
20
|
-
const body = {
|
|
21
|
-
name: options.name,
|
|
22
|
-
mapping_id: options.mappingId,
|
|
23
|
-
period_start: options.periodStart,
|
|
24
|
-
period_end: options.periodEnd,
|
|
25
|
-
taxonomy_id: options.taxonomyId ?? 'tax_usgaap_reporting',
|
|
26
|
-
period_type: options.periodType ?? 'quarterly',
|
|
27
|
-
comparative: options.comparative ?? true,
|
|
28
|
-
};
|
|
29
|
-
if (options.periods && options.periods.length > 0) {
|
|
30
|
-
body.periods = options.periods;
|
|
31
|
-
}
|
|
32
|
-
const envelope = await this.callOperation('Create report', (0, sdk_gen_1.opCreateReport)({ path: { graph_id: graphId }, body }));
|
|
33
|
-
return {
|
|
34
|
-
operationId: envelope.operationId,
|
|
35
|
-
status: envelope.status,
|
|
36
|
-
result: envelope.result ?? null,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
/** List all reports for a graph (includes received shared reports). */
|
|
40
|
-
async list(graphId) {
|
|
41
|
-
const list = await this.gqlQuery(graphId, graphql_1.ListLedgerReportsDocument, undefined, 'List reports', (data) => data.reports);
|
|
42
|
-
return list?.reports ?? [];
|
|
43
|
-
}
|
|
44
|
-
/** Get a single report with its period list + available structures. */
|
|
45
|
-
async get(graphId, reportId) {
|
|
46
|
-
return this.gqlQuery(graphId, graphql_1.GetLedgerReportDocument, { reportId }, 'Get report', (data) => data.report);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Render a financial statement — facts viewed through a structure.
|
|
50
|
-
*
|
|
51
|
-
* @param structureType - income_statement, balance_sheet, cash_flow_statement
|
|
52
|
-
*/
|
|
53
|
-
async statement(graphId, reportId, structureType) {
|
|
54
|
-
return this.gqlQuery(graphId, graphql_1.GetLedgerStatementDocument, { reportId, structureType }, 'Get statement', (data) => data.statement);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Regenerate an existing report (async). Returns an operation id;
|
|
58
|
-
* subscribe via SSE for progress.
|
|
59
|
-
*/
|
|
60
|
-
async regenerate(graphId, reportId, periodStart, periodEnd) {
|
|
61
|
-
const envelope = await this.callOperation('Regenerate report', (0, sdk_gen_1.opRegenerateReport)({
|
|
62
|
-
path: { graph_id: graphId },
|
|
63
|
-
body: {
|
|
64
|
-
report_id: reportId,
|
|
65
|
-
period_start: periodStart,
|
|
66
|
-
period_end: periodEnd,
|
|
67
|
-
},
|
|
68
|
-
}));
|
|
69
|
-
return {
|
|
70
|
-
operationId: envelope.operationId,
|
|
71
|
-
status: envelope.status,
|
|
72
|
-
result: envelope.result ?? null,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
/** Delete a report and its generated facts. */
|
|
76
|
-
async delete(graphId, reportId) {
|
|
77
|
-
await this.callOperation('Delete report', (0, sdk_gen_1.opDeleteReport)({
|
|
78
|
-
path: { graph_id: graphId },
|
|
79
|
-
body: { report_id: reportId },
|
|
80
|
-
}));
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Share a published report to every member of a publish list (async).
|
|
84
|
-
* Each target graph receives a snapshot copy of the report's facts.
|
|
85
|
-
*/
|
|
86
|
-
async share(graphId, reportId, publishListId) {
|
|
87
|
-
const envelope = await this.callOperation('Share report', (0, sdk_gen_1.opShareReport)({
|
|
88
|
-
path: { graph_id: graphId },
|
|
89
|
-
body: {
|
|
90
|
-
report_id: reportId,
|
|
91
|
-
publish_list_id: publishListId,
|
|
92
|
-
},
|
|
93
|
-
}));
|
|
94
|
-
return {
|
|
95
|
-
operationId: envelope.operationId,
|
|
96
|
-
status: envelope.status,
|
|
97
|
-
result: envelope.result ?? null,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
/** Check if a report was received via sharing (vs locally created). */
|
|
101
|
-
isSharedReport(report) {
|
|
102
|
-
return report.sourceGraphId !== null;
|
|
103
|
-
}
|
|
104
|
-
// ── Publish Lists ────────────────────────────────────────────────────
|
|
105
|
-
/** List publish lists with pagination. */
|
|
106
|
-
async listPublishLists(graphId, options) {
|
|
107
|
-
const list = await this.gqlQuery(graphId, graphql_1.ListLedgerPublishListsDocument, {
|
|
108
|
-
limit: options?.limit ?? 100,
|
|
109
|
-
offset: options?.offset ?? 0,
|
|
110
|
-
}, 'List publish lists', (data) => data.publishLists);
|
|
111
|
-
return list?.publishLists ?? [];
|
|
112
|
-
}
|
|
113
|
-
/** Create a new publish list. */
|
|
114
|
-
async createPublishList(graphId, name, description) {
|
|
115
|
-
const body = {
|
|
116
|
-
name,
|
|
117
|
-
description: description ?? null,
|
|
118
|
-
};
|
|
119
|
-
const envelope = await this.callOperation('Create publish list', (0, sdk_gen_1.opCreatePublishList)({ path: { graph_id: graphId }, body }));
|
|
120
|
-
return (envelope.result ?? {});
|
|
121
|
-
}
|
|
122
|
-
/** Get a single publish list with its full member list. */
|
|
123
|
-
async getPublishList(graphId, listId) {
|
|
124
|
-
return this.gqlQuery(graphId, graphql_1.GetLedgerPublishListDocument, { listId }, 'Get publish list', (data) => data.publishList);
|
|
125
|
-
}
|
|
126
|
-
/** Update a publish list's name or description. */
|
|
127
|
-
async updatePublishList(graphId, listId, updates) {
|
|
128
|
-
const envelope = await this.callOperation('Update publish list', (0, sdk_gen_1.opUpdatePublishList)({
|
|
129
|
-
path: { graph_id: graphId },
|
|
130
|
-
body: {
|
|
131
|
-
list_id: listId,
|
|
132
|
-
name: updates.name,
|
|
133
|
-
description: updates.description ?? null,
|
|
134
|
-
},
|
|
135
|
-
}));
|
|
136
|
-
return (envelope.result ?? {});
|
|
137
|
-
}
|
|
138
|
-
/** Delete a publish list. */
|
|
139
|
-
async deletePublishList(graphId, listId) {
|
|
140
|
-
await this.callOperation('Delete publish list', (0, sdk_gen_1.opDeletePublishList)({
|
|
141
|
-
path: { graph_id: graphId },
|
|
142
|
-
body: { list_id: listId },
|
|
143
|
-
}));
|
|
144
|
-
}
|
|
145
|
-
/** Add target graphs as members of a publish list. */
|
|
146
|
-
async addMembers(graphId, listId, targetGraphIds) {
|
|
147
|
-
const envelope = await this.callOperation('Add publish list members', (0, sdk_gen_1.opAddPublishListMembers)({
|
|
148
|
-
path: { graph_id: graphId },
|
|
149
|
-
body: {
|
|
150
|
-
list_id: listId,
|
|
151
|
-
target_graph_ids: targetGraphIds,
|
|
152
|
-
},
|
|
153
|
-
}));
|
|
154
|
-
return (envelope.result ?? {});
|
|
155
|
-
}
|
|
156
|
-
/** Remove a single member from a publish list. */
|
|
157
|
-
async removeMember(graphId, listId, memberId) {
|
|
158
|
-
const envelope = await this.callOperation('Remove publish list member', (0, sdk_gen_1.opRemovePublishListMember)({
|
|
159
|
-
path: { graph_id: graphId },
|
|
160
|
-
body: { list_id: listId, member_id: memberId },
|
|
161
|
-
}));
|
|
162
|
-
return (envelope.result ?? { deleted: true });
|
|
163
|
-
}
|
|
164
|
-
// ── Internal helpers ────────────────────────────────────────────────
|
|
165
|
-
async gqlQuery(graphId, document, variables, label, pick) {
|
|
166
|
-
try {
|
|
167
|
-
const client = this.gql.get(graphId);
|
|
168
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
169
|
-
const raw = client.request;
|
|
170
|
-
const data = (await raw.call(client, document, variables));
|
|
171
|
-
return pick(data);
|
|
172
|
-
}
|
|
173
|
-
catch (err) {
|
|
174
|
-
if (err instanceof graphql_request_1.ClientError) {
|
|
175
|
-
throw new Error(`${label} failed: ${JSON.stringify(err.response.errors ?? err.message)}`);
|
|
176
|
-
}
|
|
177
|
-
throw err;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
async callOperation(label, call) {
|
|
181
|
-
const response = await call;
|
|
182
|
-
if (response.error !== undefined) {
|
|
183
|
-
throw new Error(`${label} failed: ${JSON.stringify(response.error)}`);
|
|
184
|
-
}
|
|
185
|
-
if (response.data === undefined) {
|
|
186
|
-
throw new Error(`${label} failed: empty response`);
|
|
187
|
-
}
|
|
188
|
-
return response.data;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
exports.ReportClient = ReportClient;
|