@robosystems/client 0.2.48 → 0.3.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.
- package/extensions/InvestorClient.d.ts +91 -0
- package/extensions/InvestorClient.js +223 -0
- package/extensions/InvestorClient.ts +501 -0
- package/extensions/LedgerClient.d.ts +213 -165
- package/extensions/LedgerClient.js +315 -393
- package/extensions/LedgerClient.ts +887 -564
- package/extensions/ReportClient.d.ts +77 -115
- package/extensions/ReportClient.js +124 -211
- package/extensions/ReportClient.ts +298 -358
- package/extensions/config.js +1 -1
- package/extensions/config.ts +1 -1
- package/extensions/graphql/client.d.ts +46 -0
- package/extensions/graphql/client.js +75 -0
- package/extensions/graphql/client.ts +82 -0
- package/extensions/graphql/generated/graphql.d.ts +1786 -0
- package/extensions/graphql/generated/graphql.js +2671 -0
- package/extensions/graphql/generated/graphql.ts +4491 -0
- package/extensions/graphql/queries/investor/holdings.d.ts +8 -0
- package/extensions/graphql/queries/investor/holdings.js +36 -0
- package/extensions/graphql/queries/investor/holdings.ts +34 -0
- package/extensions/graphql/queries/investor/portfolio.d.ts +4 -0
- package/extensions/graphql/queries/investor/portfolio.js +21 -0
- package/extensions/graphql/queries/investor/portfolio.ts +19 -0
- package/extensions/graphql/queries/investor/portfolios.d.ts +4 -0
- package/extensions/graphql/queries/investor/portfolios.js +29 -0
- package/extensions/graphql/queries/investor/portfolios.ts +27 -0
- package/extensions/graphql/queries/investor/position.d.ts +4 -0
- package/extensions/graphql/queries/investor/position.js +33 -0
- package/extensions/graphql/queries/investor/position.ts +31 -0
- package/extensions/graphql/queries/investor/positions.d.ts +8 -0
- package/extensions/graphql/queries/investor/positions.js +57 -0
- package/extensions/graphql/queries/investor/positions.ts +55 -0
- package/extensions/graphql/queries/investor/securities.d.ts +8 -0
- package/extensions/graphql/queries/investor/securities.js +50 -0
- package/extensions/graphql/queries/investor/securities.ts +48 -0
- package/extensions/graphql/queries/investor/security.d.ts +4 -0
- package/extensions/graphql/queries/investor/security.js +26 -0
- package/extensions/graphql/queries/investor/security.ts +24 -0
- package/extensions/graphql/queries/ledger/accountRollups.d.ts +7 -0
- package/extensions/graphql/queries/ledger/accountRollups.js +36 -0
- package/extensions/graphql/queries/ledger/accountRollups.ts +34 -0
- package/extensions/graphql/queries/ledger/accountTree.d.ts +11 -0
- package/extensions/graphql/queries/ledger/accountTree.js +61 -0
- package/extensions/graphql/queries/ledger/accountTree.ts +59 -0
- package/extensions/graphql/queries/ledger/accounts.d.ts +8 -0
- package/extensions/graphql/queries/ledger/accounts.js +45 -0
- package/extensions/graphql/queries/ledger/accounts.ts +43 -0
- package/extensions/graphql/queries/ledger/closingBookStructures.d.ts +6 -0
- package/extensions/graphql/queries/ledger/closingBookStructures.js +27 -0
- package/extensions/graphql/queries/ledger/closingBookStructures.ts +25 -0
- package/extensions/graphql/queries/ledger/elements.d.ts +6 -0
- package/extensions/graphql/queries/ledger/elements.js +56 -0
- package/extensions/graphql/queries/ledger/elements.ts +54 -0
- package/extensions/graphql/queries/ledger/entities.d.ts +7 -0
- package/extensions/graphql/queries/ledger/entities.js +31 -0
- package/extensions/graphql/queries/ledger/entities.ts +29 -0
- package/extensions/graphql/queries/ledger/entity.d.ts +14 -0
- package/extensions/graphql/queries/ledger/entity.js +55 -0
- package/extensions/graphql/queries/ledger/entity.ts +54 -0
- package/extensions/graphql/queries/ledger/fiscalCalendar.d.ts +8 -0
- package/extensions/graphql/queries/ledger/fiscalCalendar.js +35 -0
- package/extensions/graphql/queries/ledger/fiscalCalendar.ts +33 -0
- package/extensions/graphql/queries/ledger/mappedTrialBalance.d.ts +9 -0
- package/extensions/graphql/queries/ledger/mappedTrialBalance.js +29 -0
- package/extensions/graphql/queries/ledger/mappedTrialBalance.ts +27 -0
- package/extensions/graphql/queries/ledger/mapping.d.ts +5 -0
- package/extensions/graphql/queries/ledger/mapping.js +35 -0
- package/extensions/graphql/queries/ledger/mapping.ts +33 -0
- package/extensions/graphql/queries/ledger/mappingCoverage.d.ts +5 -0
- package/extensions/graphql/queries/ledger/mappingCoverage.js +22 -0
- package/extensions/graphql/queries/ledger/mappingCoverage.ts +20 -0
- package/extensions/graphql/queries/ledger/mappings.d.ts +6 -0
- package/extensions/graphql/queries/ledger/mappings.js +23 -0
- package/extensions/graphql/queries/ledger/mappings.ts +21 -0
- package/extensions/graphql/queries/ledger/periodCloseStatus.d.ts +6 -0
- package/extensions/graphql/queries/ledger/periodCloseStatus.js +29 -0
- package/extensions/graphql/queries/ledger/periodCloseStatus.ts +27 -0
- package/extensions/graphql/queries/ledger/periodDrafts.d.ts +8 -0
- package/extensions/graphql/queries/ledger/periodDrafts.js +45 -0
- package/extensions/graphql/queries/ledger/periodDrafts.ts +43 -0
- package/extensions/graphql/queries/ledger/publishList.d.ts +5 -0
- package/extensions/graphql/queries/ledger/publishList.js +29 -0
- package/extensions/graphql/queries/ledger/publishList.ts +27 -0
- package/extensions/graphql/queries/ledger/publishLists.d.ts +5 -0
- package/extensions/graphql/queries/ledger/publishLists.js +29 -0
- package/extensions/graphql/queries/ledger/publishLists.ts +27 -0
- package/extensions/graphql/queries/ledger/report.d.ts +5 -0
- package/extensions/graphql/queries/ledger/report.js +40 -0
- package/extensions/graphql/queries/ledger/report.ts +38 -0
- package/extensions/graphql/queries/ledger/reportingTaxonomy.d.ts +6 -0
- package/extensions/graphql/queries/ledger/reportingTaxonomy.js +27 -0
- package/extensions/graphql/queries/ledger/reportingTaxonomy.ts +25 -0
- package/extensions/graphql/queries/ledger/reports.d.ts +8 -0
- package/extensions/graphql/queries/ledger/reports.js +45 -0
- package/extensions/graphql/queries/ledger/reports.ts +43 -0
- package/extensions/graphql/queries/ledger/scheduleFacts.d.ts +7 -0
- package/extensions/graphql/queries/ledger/scheduleFacts.js +24 -0
- package/extensions/graphql/queries/ledger/scheduleFacts.ts +22 -0
- package/extensions/graphql/queries/ledger/schedules.d.ts +6 -0
- package/extensions/graphql/queries/ledger/schedules.js +24 -0
- package/extensions/graphql/queries/ledger/schedules.ts +22 -0
- package/extensions/graphql/queries/ledger/statement.d.ts +9 -0
- package/extensions/graphql/queries/ledger/statement.js +43 -0
- package/extensions/graphql/queries/ledger/statement.ts +41 -0
- package/extensions/graphql/queries/ledger/structures.d.ts +5 -0
- package/extensions/graphql/queries/ledger/structures.js +22 -0
- package/extensions/graphql/queries/ledger/structures.ts +20 -0
- package/extensions/graphql/queries/ledger/summary.d.ts +7 -0
- package/extensions/graphql/queries/ledger/summary.js +25 -0
- package/extensions/graphql/queries/ledger/summary.ts +23 -0
- package/extensions/graphql/queries/ledger/taxonomies.d.ts +5 -0
- package/extensions/graphql/queries/ledger/taxonomies.js +28 -0
- package/extensions/graphql/queries/ledger/taxonomies.ts +26 -0
- package/extensions/graphql/queries/ledger/transaction.d.ts +6 -0
- package/extensions/graphql/queries/ledger/transaction.js +49 -0
- package/extensions/graphql/queries/ledger/transaction.ts +47 -0
- package/extensions/graphql/queries/ledger/transactions.d.ts +7 -0
- package/extensions/graphql/queries/ledger/transactions.js +49 -0
- package/extensions/graphql/queries/ledger/transactions.ts +47 -0
- package/extensions/graphql/queries/ledger/trialBalance.d.ts +7 -0
- package/extensions/graphql/queries/ledger/trialBalance.js +28 -0
- package/extensions/graphql/queries/ledger/trialBalance.ts +26 -0
- package/extensions/graphql/queries/ledger/unmappedElements.d.ts +8 -0
- package/extensions/graphql/queries/ledger/unmappedElements.js +29 -0
- package/extensions/graphql/queries/ledger/unmappedElements.ts +27 -0
- package/extensions/hooks.d.ts +1 -1
- package/extensions/index.d.ts +5 -1
- package/extensions/index.js +13 -1
- package/extensions/index.ts +14 -0
- package/index.ts +2 -2
- package/package.json +14 -5
- package/sdk/index.d.ts +2 -2
- package/sdk/index.js +38 -65
- package/sdk/index.ts +2 -2
- package/sdk/sdk.gen.d.ts +101 -220
- package/sdk/sdk.gen.js +251 -445
- package/sdk/sdk.gen.ts +216 -409
- package/sdk/types.gen.d.ts +4586 -7045
- package/sdk/types.gen.ts +4702 -7334
- package/sdk.gen.d.ts +101 -220
- package/sdk.gen.js +251 -445
- package/sdk.gen.ts +216 -409
- package/types.gen.d.ts +4586 -7045
- package/types.gen.ts +4702 -7334
- package/extensions/AgentClient.test.ts +0 -403
- package/extensions/LedgerClient.test.ts +0 -1138
- package/extensions/OperationClient.test.ts +0 -365
- package/extensions/QueryClient.test.ts +0 -432
- package/extensions/ReportClient.test.ts +0 -828
- package/extensions/SSEClient.test.ts +0 -375
- package/extensions/config.test.ts +0 -199
- package/extensions/hooks.test.ts +0 -373
- package/extensions/index.test.ts +0 -420
- package/sdk-extensions/AgentClient.d.ts +0 -82
- package/sdk-extensions/AgentClient.js +0 -218
- package/sdk-extensions/AgentClient.test.ts +0 -403
- package/sdk-extensions/AgentClient.ts +0 -321
- package/sdk-extensions/LedgerClient.d.ts +0 -242
- package/sdk-extensions/LedgerClient.js +0 -496
- package/sdk-extensions/LedgerClient.test.ts +0 -1138
- package/sdk-extensions/LedgerClient.ts +0 -800
- package/sdk-extensions/OperationClient.d.ts +0 -65
- package/sdk-extensions/OperationClient.js +0 -251
- package/sdk-extensions/OperationClient.test.ts +0 -365
- package/sdk-extensions/OperationClient.ts +0 -324
- package/sdk-extensions/QueryClient.d.ts +0 -52
- package/sdk-extensions/QueryClient.js +0 -313
- package/sdk-extensions/QueryClient.test.ts +0 -432
- package/sdk-extensions/QueryClient.ts +0 -420
- package/sdk-extensions/README.md +0 -901
- package/sdk-extensions/ReportClient.d.ts +0 -151
- package/sdk-extensions/ReportClient.js +0 -278
- package/sdk-extensions/ReportClient.test.ts +0 -828
- package/sdk-extensions/ReportClient.ts +0 -486
- package/sdk-extensions/SSEClient.d.ts +0 -62
- package/sdk-extensions/SSEClient.js +0 -154
- package/sdk-extensions/SSEClient.test.ts +0 -375
- package/sdk-extensions/SSEClient.ts +0 -210
- package/sdk-extensions/config.d.ts +0 -57
- package/sdk-extensions/config.js +0 -152
- package/sdk-extensions/config.test.ts +0 -199
- package/sdk-extensions/config.ts +0 -175
- package/sdk-extensions/hooks.d.ts +0 -110
- package/sdk-extensions/hooks.js +0 -384
- package/sdk-extensions/hooks.test.ts +0 -373
- package/sdk-extensions/hooks.ts +0 -459
- package/sdk-extensions/index.d.ts +0 -63
- package/sdk-extensions/index.js +0 -164
- package/sdk-extensions/index.test.ts +0 -420
- package/sdk-extensions/index.ts +0 -203
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { CreatePortfolioRequest, CreatePositionRequest, CreateSecurityRequest, UpdatePortfolioOperation, UpdatePositionOperation, UpdateSecurityOperation } from '../types.gen';
|
|
2
|
+
import { type GetInvestorHoldingsQuery, type GetInvestorPortfolioQuery, type GetInvestorPositionQuery, type GetInvestorSecurityQuery, type ListInvestorPortfoliosQuery, type ListInvestorPositionsQuery, type ListInvestorSecuritiesQuery } from './graphql/generated/graphql';
|
|
3
|
+
export type InvestorPortfolioList = NonNullable<ListInvestorPortfoliosQuery['portfolios']>;
|
|
4
|
+
export type InvestorPortfolioSummary = InvestorPortfolioList['portfolios'][number];
|
|
5
|
+
export type InvestorPortfolio = NonNullable<GetInvestorPortfolioQuery['portfolio']>;
|
|
6
|
+
export type InvestorSecurityList = NonNullable<ListInvestorSecuritiesQuery['securities']>;
|
|
7
|
+
export type InvestorSecuritySummary = InvestorSecurityList['securities'][number];
|
|
8
|
+
export type InvestorSecurity = NonNullable<GetInvestorSecurityQuery['security']>;
|
|
9
|
+
export type InvestorPositionList = NonNullable<ListInvestorPositionsQuery['positions']>;
|
|
10
|
+
export type InvestorPositionSummary = InvestorPositionList['positions'][number];
|
|
11
|
+
export type InvestorPosition = NonNullable<GetInvestorPositionQuery['position']>;
|
|
12
|
+
export type InvestorHoldings = NonNullable<GetInvestorHoldingsQuery['holdings']>;
|
|
13
|
+
export type InvestorEntityHolding = InvestorHoldings['holdings'][number];
|
|
14
|
+
export type InvestorHeldSecurity = InvestorEntityHolding['securities'][number];
|
|
15
|
+
interface InvestorClientConfig {
|
|
16
|
+
baseUrl: string;
|
|
17
|
+
credentials?: 'include' | 'same-origin' | 'omit';
|
|
18
|
+
headers?: Record<string, string>;
|
|
19
|
+
token?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class InvestorClient {
|
|
22
|
+
private config;
|
|
23
|
+
private gql;
|
|
24
|
+
constructor(config: InvestorClientConfig);
|
|
25
|
+
/** List portfolios with pagination. */
|
|
26
|
+
listPortfolios(graphId: string, options?: {
|
|
27
|
+
limit?: number;
|
|
28
|
+
offset?: number;
|
|
29
|
+
}): Promise<InvestorPortfolioList | null>;
|
|
30
|
+
/** Get a single portfolio by id. Returns null if it doesn't exist. */
|
|
31
|
+
getPortfolio(graphId: string, portfolioId: string): Promise<InvestorPortfolio | null>;
|
|
32
|
+
/** Create a new portfolio. Returns the created portfolio. */
|
|
33
|
+
createPortfolio(graphId: string, body: CreatePortfolioRequest): Promise<InvestorPortfolio>;
|
|
34
|
+
/** Update a portfolio's metadata. Only provided fields are applied. */
|
|
35
|
+
updatePortfolio(graphId: string, portfolioId: string, updates: Omit<UpdatePortfolioOperation, 'portfolio_id'>): Promise<InvestorPortfolio>;
|
|
36
|
+
/**
|
|
37
|
+
* Delete a portfolio. Fails with 409 if the portfolio still has active
|
|
38
|
+
* positions — dispose those first.
|
|
39
|
+
*/
|
|
40
|
+
deletePortfolio(graphId: string, portfolioId: string): Promise<{
|
|
41
|
+
deleted: boolean;
|
|
42
|
+
}>;
|
|
43
|
+
/** List securities with pagination and filters. */
|
|
44
|
+
listSecurities(graphId: string, options?: {
|
|
45
|
+
entityId?: string;
|
|
46
|
+
securityType?: string;
|
|
47
|
+
isActive?: boolean;
|
|
48
|
+
limit?: number;
|
|
49
|
+
offset?: number;
|
|
50
|
+
}): Promise<InvestorSecurityList | null>;
|
|
51
|
+
/** Get a single security by id. Returns null if it doesn't exist. */
|
|
52
|
+
getSecurity(graphId: string, securityId: string): Promise<InvestorSecurity | null>;
|
|
53
|
+
/**
|
|
54
|
+
* Create a new security. Passing `source_graph_id` auto-links to the
|
|
55
|
+
* matching entity in the target graph.
|
|
56
|
+
*/
|
|
57
|
+
createSecurity(graphId: string, body: CreateSecurityRequest): Promise<InvestorSecurity>;
|
|
58
|
+
/** Update a security's metadata. Only provided fields are applied. */
|
|
59
|
+
updateSecurity(graphId: string, securityId: string, updates: Omit<UpdateSecurityOperation, 'security_id'>): Promise<InvestorSecurity>;
|
|
60
|
+
/** Soft-delete a security (sets is_active=false). */
|
|
61
|
+
deleteSecurity(graphId: string, securityId: string): Promise<{
|
|
62
|
+
deleted: boolean;
|
|
63
|
+
}>;
|
|
64
|
+
/** List positions with pagination and filters. */
|
|
65
|
+
listPositions(graphId: string, options?: {
|
|
66
|
+
portfolioId?: string;
|
|
67
|
+
securityId?: string;
|
|
68
|
+
status?: string;
|
|
69
|
+
limit?: number;
|
|
70
|
+
offset?: number;
|
|
71
|
+
}): Promise<InvestorPositionList | null>;
|
|
72
|
+
/** Get a single position by id. Returns null if it doesn't exist. */
|
|
73
|
+
getPosition(graphId: string, positionId: string): Promise<InvestorPosition | null>;
|
|
74
|
+
/** Create a new position. */
|
|
75
|
+
createPosition(graphId: string, body: CreatePositionRequest): Promise<InvestorPosition>;
|
|
76
|
+
/** Update a position. Only provided fields are applied. */
|
|
77
|
+
updatePosition(graphId: string, positionId: string, updates: Omit<UpdatePositionOperation, 'position_id'>): Promise<InvestorPosition>;
|
|
78
|
+
/** Delete (dispose) a position. */
|
|
79
|
+
deletePosition(graphId: string, positionId: string): Promise<{
|
|
80
|
+
deleted: boolean;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* Get portfolio holdings grouped by entity. Returns the full list of
|
|
84
|
+
* securities held and aggregate cost-basis / current-value for each
|
|
85
|
+
* entity in the portfolio.
|
|
86
|
+
*/
|
|
87
|
+
getHoldings(graphId: string, portfolioId: string): Promise<InvestorHoldings | null>;
|
|
88
|
+
private gqlQuery;
|
|
89
|
+
private callOperation;
|
|
90
|
+
}
|
|
91
|
+
export {};
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.InvestorClient = 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 InvestorClient {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.config = config;
|
|
12
|
+
this.gql = new client_1.GraphQLClientCache(config);
|
|
13
|
+
}
|
|
14
|
+
// ── Portfolios ──────────────────────────────────────────────────────
|
|
15
|
+
/** List portfolios with pagination. */
|
|
16
|
+
async listPortfolios(graphId, options) {
|
|
17
|
+
return this.gqlQuery(graphId, graphql_1.ListInvestorPortfoliosDocument, {
|
|
18
|
+
limit: options?.limit ?? 100,
|
|
19
|
+
offset: options?.offset ?? 0,
|
|
20
|
+
}, 'List portfolios', (data) => data.portfolios);
|
|
21
|
+
}
|
|
22
|
+
/** Get a single portfolio by id. Returns null if it doesn't exist. */
|
|
23
|
+
async getPortfolio(graphId, portfolioId) {
|
|
24
|
+
return this.gqlQuery(graphId, graphql_1.GetInvestorPortfolioDocument, { portfolioId }, 'Get portfolio', (data) => data.portfolio);
|
|
25
|
+
}
|
|
26
|
+
/** Create a new portfolio. Returns the created portfolio. */
|
|
27
|
+
async createPortfolio(graphId, body) {
|
|
28
|
+
const envelope = await this.callOperation('Create portfolio', (0, sdk_gen_1.opCreatePortfolio)({ path: { graph_id: graphId }, body }));
|
|
29
|
+
return rawToInvestorPortfolio(envelope.result);
|
|
30
|
+
}
|
|
31
|
+
/** Update a portfolio's metadata. Only provided fields are applied. */
|
|
32
|
+
async updatePortfolio(graphId, portfolioId, updates) {
|
|
33
|
+
const envelope = await this.callOperation('Update portfolio', (0, sdk_gen_1.opUpdatePortfolio)({
|
|
34
|
+
path: { graph_id: graphId },
|
|
35
|
+
body: {
|
|
36
|
+
...updates,
|
|
37
|
+
portfolio_id: portfolioId,
|
|
38
|
+
},
|
|
39
|
+
}));
|
|
40
|
+
return rawToInvestorPortfolio(envelope.result);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Delete a portfolio. Fails with 409 if the portfolio still has active
|
|
44
|
+
* positions — dispose those first.
|
|
45
|
+
*/
|
|
46
|
+
async deletePortfolio(graphId, portfolioId) {
|
|
47
|
+
const envelope = await this.callOperation('Delete portfolio', (0, sdk_gen_1.opDeletePortfolio)({
|
|
48
|
+
path: { graph_id: graphId },
|
|
49
|
+
body: { portfolio_id: portfolioId },
|
|
50
|
+
}));
|
|
51
|
+
return (envelope.result ?? { deleted: true });
|
|
52
|
+
}
|
|
53
|
+
// ── Securities ──────────────────────────────────────────────────────
|
|
54
|
+
/** List securities with pagination and filters. */
|
|
55
|
+
async listSecurities(graphId, options) {
|
|
56
|
+
return this.gqlQuery(graphId, graphql_1.ListInvestorSecuritiesDocument, {
|
|
57
|
+
entityId: options?.entityId ?? null,
|
|
58
|
+
securityType: options?.securityType ?? null,
|
|
59
|
+
isActive: options?.isActive ?? null,
|
|
60
|
+
limit: options?.limit ?? 100,
|
|
61
|
+
offset: options?.offset ?? 0,
|
|
62
|
+
}, 'List securities', (data) => data.securities);
|
|
63
|
+
}
|
|
64
|
+
/** Get a single security by id. Returns null if it doesn't exist. */
|
|
65
|
+
async getSecurity(graphId, securityId) {
|
|
66
|
+
return this.gqlQuery(graphId, graphql_1.GetInvestorSecurityDocument, { securityId }, 'Get security', (data) => data.security);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Create a new security. Passing `source_graph_id` auto-links to the
|
|
70
|
+
* matching entity in the target graph.
|
|
71
|
+
*/
|
|
72
|
+
async createSecurity(graphId, body) {
|
|
73
|
+
const envelope = await this.callOperation('Create security', (0, sdk_gen_1.opCreateSecurity)({ path: { graph_id: graphId }, body }));
|
|
74
|
+
return rawToInvestorSecurity(envelope.result);
|
|
75
|
+
}
|
|
76
|
+
/** Update a security's metadata. Only provided fields are applied. */
|
|
77
|
+
async updateSecurity(graphId, securityId, updates) {
|
|
78
|
+
const envelope = await this.callOperation('Update security', (0, sdk_gen_1.opUpdateSecurity)({
|
|
79
|
+
path: { graph_id: graphId },
|
|
80
|
+
body: {
|
|
81
|
+
...updates,
|
|
82
|
+
security_id: securityId,
|
|
83
|
+
},
|
|
84
|
+
}));
|
|
85
|
+
return rawToInvestorSecurity(envelope.result);
|
|
86
|
+
}
|
|
87
|
+
/** Soft-delete a security (sets is_active=false). */
|
|
88
|
+
async deleteSecurity(graphId, securityId) {
|
|
89
|
+
const envelope = await this.callOperation('Delete security', (0, sdk_gen_1.opDeleteSecurity)({
|
|
90
|
+
path: { graph_id: graphId },
|
|
91
|
+
body: { security_id: securityId },
|
|
92
|
+
}));
|
|
93
|
+
return (envelope.result ?? { deleted: true });
|
|
94
|
+
}
|
|
95
|
+
// ── Positions ───────────────────────────────────────────────────────
|
|
96
|
+
/** List positions with pagination and filters. */
|
|
97
|
+
async listPositions(graphId, options) {
|
|
98
|
+
return this.gqlQuery(graphId, graphql_1.ListInvestorPositionsDocument, {
|
|
99
|
+
portfolioId: options?.portfolioId ?? null,
|
|
100
|
+
securityId: options?.securityId ?? null,
|
|
101
|
+
status: options?.status ?? null,
|
|
102
|
+
limit: options?.limit ?? 100,
|
|
103
|
+
offset: options?.offset ?? 0,
|
|
104
|
+
}, 'List positions', (data) => data.positions);
|
|
105
|
+
}
|
|
106
|
+
/** Get a single position by id. Returns null if it doesn't exist. */
|
|
107
|
+
async getPosition(graphId, positionId) {
|
|
108
|
+
return this.gqlQuery(graphId, graphql_1.GetInvestorPositionDocument, { positionId }, 'Get position', (data) => data.position);
|
|
109
|
+
}
|
|
110
|
+
/** Create a new position. */
|
|
111
|
+
async createPosition(graphId, body) {
|
|
112
|
+
const envelope = await this.callOperation('Create position', (0, sdk_gen_1.opCreatePosition)({ path: { graph_id: graphId }, body }));
|
|
113
|
+
return rawToInvestorPosition(envelope.result);
|
|
114
|
+
}
|
|
115
|
+
/** Update a position. Only provided fields are applied. */
|
|
116
|
+
async updatePosition(graphId, positionId, updates) {
|
|
117
|
+
const envelope = await this.callOperation('Update position', (0, sdk_gen_1.opUpdatePosition)({
|
|
118
|
+
path: { graph_id: graphId },
|
|
119
|
+
body: {
|
|
120
|
+
...updates,
|
|
121
|
+
position_id: positionId,
|
|
122
|
+
},
|
|
123
|
+
}));
|
|
124
|
+
return rawToInvestorPosition(envelope.result);
|
|
125
|
+
}
|
|
126
|
+
/** Delete (dispose) a position. */
|
|
127
|
+
async deletePosition(graphId, positionId) {
|
|
128
|
+
const envelope = await this.callOperation('Delete position', (0, sdk_gen_1.opDeletePosition)({
|
|
129
|
+
path: { graph_id: graphId },
|
|
130
|
+
body: { position_id: positionId },
|
|
131
|
+
}));
|
|
132
|
+
return (envelope.result ?? { deleted: true });
|
|
133
|
+
}
|
|
134
|
+
// ── Holdings (aggregation) ─────────────────────────────────────────
|
|
135
|
+
/**
|
|
136
|
+
* Get portfolio holdings grouped by entity. Returns the full list of
|
|
137
|
+
* securities held and aggregate cost-basis / current-value for each
|
|
138
|
+
* entity in the portfolio.
|
|
139
|
+
*/
|
|
140
|
+
async getHoldings(graphId, portfolioId) {
|
|
141
|
+
return this.gqlQuery(graphId, graphql_1.GetInvestorHoldingsDocument, { portfolioId }, 'Get holdings', (data) => data.holdings);
|
|
142
|
+
}
|
|
143
|
+
// ── Internal helpers ────────────────────────────────────────────────
|
|
144
|
+
async gqlQuery(graphId, document, variables, label, pick) {
|
|
145
|
+
try {
|
|
146
|
+
const client = this.gql.get(graphId);
|
|
147
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
148
|
+
const raw = client.request;
|
|
149
|
+
const data = (await raw.call(client, document, variables));
|
|
150
|
+
return pick(data);
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
if (err instanceof graphql_request_1.ClientError) {
|
|
154
|
+
throw new Error(`${label} failed: ${JSON.stringify(err.response.errors ?? err.message)}`);
|
|
155
|
+
}
|
|
156
|
+
throw err;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
async callOperation(label, call) {
|
|
160
|
+
const response = await call;
|
|
161
|
+
if (response.error !== undefined) {
|
|
162
|
+
throw new Error(`${label} failed: ${JSON.stringify(response.error)}`);
|
|
163
|
+
}
|
|
164
|
+
if (response.data === undefined) {
|
|
165
|
+
throw new Error(`${label} failed: empty response`);
|
|
166
|
+
}
|
|
167
|
+
return response.data;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
exports.InvestorClient = InvestorClient;
|
|
171
|
+
function rawToInvestorPortfolio(raw) {
|
|
172
|
+
return {
|
|
173
|
+
id: raw.id,
|
|
174
|
+
name: raw.name,
|
|
175
|
+
description: raw.description,
|
|
176
|
+
strategy: raw.strategy,
|
|
177
|
+
inceptionDate: raw.inception_date,
|
|
178
|
+
baseCurrency: raw.base_currency,
|
|
179
|
+
createdAt: raw.created_at,
|
|
180
|
+
updatedAt: raw.updated_at,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function rawToInvestorSecurity(raw) {
|
|
184
|
+
return {
|
|
185
|
+
id: raw.id,
|
|
186
|
+
entityId: raw.entity_id,
|
|
187
|
+
entityName: raw.entity_name,
|
|
188
|
+
sourceGraphId: raw.source_graph_id,
|
|
189
|
+
name: raw.name,
|
|
190
|
+
securityType: raw.security_type,
|
|
191
|
+
securitySubtype: raw.security_subtype,
|
|
192
|
+
terms: raw.terms,
|
|
193
|
+
isActive: raw.is_active,
|
|
194
|
+
authorizedShares: raw.authorized_shares,
|
|
195
|
+
outstandingShares: raw.outstanding_shares,
|
|
196
|
+
createdAt: raw.created_at,
|
|
197
|
+
updatedAt: raw.updated_at,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function rawToInvestorPosition(raw) {
|
|
201
|
+
return {
|
|
202
|
+
id: raw.id,
|
|
203
|
+
portfolioId: raw.portfolio_id,
|
|
204
|
+
securityId: raw.security_id,
|
|
205
|
+
securityName: raw.security_name,
|
|
206
|
+
entityName: raw.entity_name,
|
|
207
|
+
quantity: raw.quantity,
|
|
208
|
+
quantityType: raw.quantity_type,
|
|
209
|
+
costBasis: raw.cost_basis,
|
|
210
|
+
costBasisDollars: raw.cost_basis_dollars,
|
|
211
|
+
currency: raw.currency,
|
|
212
|
+
currentValue: raw.current_value,
|
|
213
|
+
currentValueDollars: raw.current_value_dollars,
|
|
214
|
+
valuationDate: raw.valuation_date,
|
|
215
|
+
valuationSource: raw.valuation_source,
|
|
216
|
+
acquisitionDate: raw.acquisition_date,
|
|
217
|
+
dispositionDate: raw.disposition_date,
|
|
218
|
+
status: raw.status,
|
|
219
|
+
notes: raw.notes,
|
|
220
|
+
createdAt: raw.created_at,
|
|
221
|
+
updatedAt: raw.updated_at,
|
|
222
|
+
};
|
|
223
|
+
}
|