@robosystems/client 0.3.13 → 0.3.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/artifacts/InvestorClient.d.ts +35 -20
  2. package/artifacts/InvestorClient.js +78 -71
  3. package/artifacts/InvestorClient.ts +164 -141
  4. package/artifacts/LedgerClient.d.ts +22 -1
  5. package/artifacts/LedgerClient.js +40 -0
  6. package/artifacts/LedgerClient.ts +67 -0
  7. package/artifacts/graphql/generated/graphql.d.ts +401 -6
  8. package/artifacts/graphql/generated/graphql.js +633 -4
  9. package/artifacts/graphql/generated/graphql.ts +1058 -41
  10. package/artifacts/graphql/queries/investor/portfolio_block.d.ts +10 -0
  11. package/artifacts/graphql/queries/investor/portfolio_block.js +60 -0
  12. package/artifacts/graphql/queries/investor/portfolio_block.ts +58 -0
  13. package/artifacts/graphql/queries/ledger/informationBlock.js +110 -0
  14. package/artifacts/graphql/queries/ledger/informationBlock.ts +110 -0
  15. package/artifacts/graphql/queries/ledger/reportPackage.d.ts +11 -0
  16. package/artifacts/graphql/queries/ledger/reportPackage.js +151 -0
  17. package/artifacts/graphql/queries/ledger/reportPackage.ts +149 -0
  18. package/index.ts +2 -2
  19. package/package.json +1 -1
  20. package/sdk/index.d.ts +2 -2
  21. package/sdk/index.js +8 -9
  22. package/sdk/index.ts +2 -2
  23. package/sdk/sdk.gen.d.ts +26 -34
  24. package/sdk/sdk.gen.js +51 -68
  25. package/sdk/sdk.gen.ts +47 -64
  26. package/sdk/types.gen.d.ts +409 -365
  27. package/sdk/types.gen.ts +411 -367
  28. package/sdk.gen.d.ts +26 -34
  29. package/sdk.gen.js +51 -68
  30. package/sdk.gen.ts +47 -64
  31. package/types.gen.d.ts +409 -365
  32. package/types.gen.ts +411 -367
  33. package/artifacts/graphql/queries/investor/portfolio.d.ts +0 -4
  34. package/artifacts/graphql/queries/investor/portfolio.js +0 -21
  35. package/artifacts/graphql/queries/investor/portfolio.ts +0 -19
@@ -1,9 +1,12 @@
1
- import type { CreatePortfolioRequest, CreatePositionRequest, CreateSecurityRequest, UpdatePortfolioOperation, UpdatePositionOperation, UpdateSecurityOperation } from '../types.gen';
1
+ import type { CreatePortfolioBlockRequest, CreateSecurityRequest, PortfolioBlockPortfolioPatch, PortfolioBlockPositions, UpdateSecurityOperation } from '../types.gen';
2
2
  import type { TokenProvider } from './graphql/client';
3
- import { type GetInvestorHoldingsQuery, type GetInvestorPortfolioQuery, type GetInvestorPositionQuery, type GetInvestorSecurityQuery, type ListInvestorPortfoliosQuery, type ListInvestorPositionsQuery, type ListInvestorSecuritiesQuery } from './graphql/generated/graphql';
3
+ import { type GetInvestorHoldingsQuery, type GetInvestorPortfolioBlockQuery, type GetInvestorPositionQuery, type GetInvestorSecurityQuery, type ListInvestorPortfoliosQuery, type ListInvestorPositionsQuery, type ListInvestorSecuritiesQuery } from './graphql/generated/graphql';
4
4
  export type InvestorPortfolioList = NonNullable<ListInvestorPortfoliosQuery['portfolios']>;
5
5
  export type InvestorPortfolioSummary = InvestorPortfolioList['portfolios'][number];
6
- export type InvestorPortfolio = NonNullable<GetInvestorPortfolioQuery['portfolio']>;
6
+ export type InvestorPortfolioBlock = NonNullable<GetInvestorPortfolioBlockQuery['portfolioBlock']>;
7
+ export type InvestorPositionBlock = InvestorPortfolioBlock['positions'][number];
8
+ export type InvestorSecurityLite = InvestorPositionBlock['security'];
9
+ export type InvestorEntityLite = InvestorPortfolioBlock['owner'];
7
10
  export type InvestorSecurityList = NonNullable<ListInvestorSecuritiesQuery['securities']>;
8
11
  export type InvestorSecuritySummary = InvestorSecurityList['securities'][number];
9
12
  export type InvestorSecurity = NonNullable<GetInvestorSecurityQuery['security']>;
@@ -34,17 +37,37 @@ export declare class InvestorClient {
34
37
  limit?: number;
35
38
  offset?: number;
36
39
  }): Promise<InvestorPortfolioList | null>;
37
- /** Get a single portfolio by id. Returns null if it doesn't exist. */
38
- getPortfolio(graphId: string, portfolioId: string): Promise<InvestorPortfolio | null>;
39
- /** Create a new portfolio. Returns the created portfolio. */
40
- createPortfolio(graphId: string, body: CreatePortfolioRequest): Promise<InvestorPortfolio>;
41
- /** Update a portfolio's metadata. Only provided fields are applied. */
42
- updatePortfolio(graphId: string, portfolioId: string, updates: Omit<UpdatePortfolioOperation, 'portfolio_id'>): Promise<InvestorPortfolio>;
43
40
  /**
44
- * Delete a portfolio. Fails with 409 if the portfolio still has active
45
- * positions dispose those first.
41
+ * Get the Portfolio Block molecule envelope with portfolio,
42
+ * positions, securities, and entity references in a single read.
43
+ * Returns null if the portfolio doesn't exist.
46
44
  */
47
- deletePortfolio(graphId: string, portfolioId: string): Promise<{
45
+ getPortfolioBlock(graphId: string, portfolioId: string): Promise<InvestorPortfolioBlock | null>;
46
+ /**
47
+ * Create a portfolio (with optional initial positions) atomically.
48
+ * Each position references an existing security; this op never mints
49
+ * securities — use `createSecurity` first.
50
+ */
51
+ createPortfolioBlock(graphId: string, body: CreatePortfolioBlockRequest): Promise<InvestorPortfolioBlock>;
52
+ /**
53
+ * Patch portfolio fields and apply position deltas (`add`, `update`,
54
+ * `dispose`) atomically. All deltas roll back together on failure.
55
+ * Pass only the fields/deltas you want changed — anything omitted
56
+ * is left untouched.
57
+ */
58
+ updatePortfolioBlock(graphId: string, portfolioId: string, updates: {
59
+ portfolio?: PortfolioBlockPortfolioPatch;
60
+ positions?: PortfolioBlockPositions;
61
+ }): Promise<InvestorPortfolioBlock>;
62
+ /**
63
+ * Cascade-delete the portfolio plus all of its positions. When the
64
+ * portfolio still has active positions, the request must include
65
+ * `confirmActivePositions: true` — safety belt to prevent accidental
66
+ * cascade. Disposed-only portfolios delete without the flag.
67
+ */
68
+ deletePortfolioBlock(graphId: string, portfolioId: string, options?: {
69
+ confirmActivePositions?: boolean;
70
+ }): Promise<{
48
71
  deleted: boolean;
49
72
  }>;
50
73
  /** List securities with pagination and filters. */
@@ -78,14 +101,6 @@ export declare class InvestorClient {
78
101
  }): Promise<InvestorPositionList | null>;
79
102
  /** Get a single position by id. Returns null if it doesn't exist. */
80
103
  getPosition(graphId: string, positionId: string): Promise<InvestorPosition | null>;
81
- /** Create a new position. */
82
- createPosition(graphId: string, body: CreatePositionRequest): Promise<InvestorPosition>;
83
- /** Update a position. Only provided fields are applied. */
84
- updatePosition(graphId: string, positionId: string, updates: Omit<UpdatePositionOperation, 'position_id'>): Promise<InvestorPosition>;
85
- /** Delete (dispose) a position. */
86
- deletePosition(graphId: string, positionId: string): Promise<{
87
- deleted: boolean;
88
- }>;
89
104
  /**
90
105
  * Get portfolio holdings grouped by entity. Returns the full list of
91
106
  * securities held and aggregate cost-basis / current-value for each
@@ -11,7 +11,7 @@ class InvestorClient {
11
11
  this.config = config;
12
12
  this.gql = new client_1.GraphQLClientCache(config);
13
13
  }
14
- // ── Portfolios ──────────────────────────────────────────────────────
14
+ // ── Portfolios (reads) ──────────────────────────────────────────────
15
15
  /** List portfolios with pagination. */
16
16
  async listPortfolios(graphId, options) {
17
17
  return this.gqlQuery(graphId, graphql_1.ListInvestorPortfoliosDocument, {
@@ -19,35 +19,50 @@ class InvestorClient {
19
19
  offset: options?.offset ?? 0,
20
20
  }, 'List portfolios', (data) => data.portfolios);
21
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);
22
+ /**
23
+ * Get the Portfolio Block — molecule envelope with portfolio,
24
+ * positions, securities, and entity references in a single read.
25
+ * Returns null if the portfolio doesn't exist.
26
+ */
27
+ async getPortfolioBlock(graphId, portfolioId) {
28
+ return this.gqlQuery(graphId, graphql_1.GetInvestorPortfolioBlockDocument, { portfolioId }, 'Get portfolio block', (data) => data.portfolioBlock);
25
29
  }
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
+ // ── Portfolio Block (writes) ────────────────────────────────────────
31
+ /**
32
+ * Create a portfolio (with optional initial positions) atomically.
33
+ * Each position references an existing security; this op never mints
34
+ * securities — use `createSecurity` first.
35
+ */
36
+ async createPortfolioBlock(graphId, body) {
37
+ const envelope = await this.callOperation('Create portfolio block', (0, sdk_gen_1.opCreatePortfolioBlock)({ path: { graph_id: graphId }, body }));
38
+ return rawToPortfolioBlock(envelope.result);
30
39
  }
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);
40
+ /**
41
+ * Patch portfolio fields and apply position deltas (`add`, `update`,
42
+ * `dispose`) atomically. All deltas roll back together on failure.
43
+ * Pass only the fields/deltas you want changed — anything omitted
44
+ * is left untouched.
45
+ */
46
+ async updatePortfolioBlock(graphId, portfolioId, updates) {
47
+ const body = {
48
+ portfolio_id: portfolioId,
49
+ ...updates,
50
+ };
51
+ const envelope = await this.callOperation('Update portfolio block', (0, sdk_gen_1.opUpdatePortfolioBlock)({ path: { graph_id: graphId }, body }));
52
+ return rawToPortfolioBlock(envelope.result);
41
53
  }
42
54
  /**
43
- * Delete a portfolio. Fails with 409 if the portfolio still has active
44
- * positions dispose those first.
55
+ * Cascade-delete the portfolio plus all of its positions. When the
56
+ * portfolio still has active positions, the request must include
57
+ * `confirmActivePositions: true` — safety belt to prevent accidental
58
+ * cascade. Disposed-only portfolios delete without the flag.
45
59
  */
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
- }));
60
+ async deletePortfolioBlock(graphId, portfolioId, options) {
61
+ const body = {
62
+ portfolio_id: portfolioId,
63
+ confirm_active_positions: options?.confirmActivePositions ?? false,
64
+ };
65
+ const envelope = await this.callOperation('Delete portfolio block', (0, sdk_gen_1.opDeletePortfolioBlock)({ path: { graph_id: graphId }, body }));
51
66
  return (envelope.result ?? { deleted: true });
52
67
  }
53
68
  // ── Securities ──────────────────────────────────────────────────────
@@ -92,7 +107,7 @@ class InvestorClient {
92
107
  }));
93
108
  return (envelope.result ?? { deleted: true });
94
109
  }
95
- // ── Positions ───────────────────────────────────────────────────────
110
+ // ── Positions (reads only — writes folded into Portfolio Block) ─────
96
111
  /** List positions with pagination and filters. */
97
112
  async listPositions(graphId, options) {
98
113
  return this.gqlQuery(graphId, graphql_1.ListInvestorPositionsDocument, {
@@ -107,30 +122,6 @@ class InvestorClient {
107
122
  async getPosition(graphId, positionId) {
108
123
  return this.gqlQuery(graphId, graphql_1.GetInvestorPositionDocument, { positionId }, 'Get position', (data) => data.position);
109
124
  }
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
125
  // ── Holdings (aggregation) ─────────────────────────────────────────
135
126
  /**
136
127
  * Get portfolio holdings grouped by entity. Returns the full list of
@@ -167,18 +158,6 @@ class InvestorClient {
167
158
  }
168
159
  }
169
160
  exports.InvestorClient = InvestorClient;
170
- function rawToInvestorPortfolio(raw) {
171
- return {
172
- id: raw.id,
173
- name: raw.name,
174
- description: raw.description,
175
- strategy: raw.strategy,
176
- inceptionDate: raw.inception_date,
177
- baseCurrency: raw.base_currency,
178
- createdAt: raw.created_at,
179
- updatedAt: raw.updated_at,
180
- };
181
- }
182
161
  function rawToInvestorSecurity(raw) {
183
162
  return {
184
163
  id: raw.id,
@@ -196,26 +175,54 @@ function rawToInvestorSecurity(raw) {
196
175
  updatedAt: raw.updated_at,
197
176
  };
198
177
  }
199
- function rawToInvestorPosition(raw) {
178
+ function rawToEntityLite(raw) {
179
+ if (raw === null)
180
+ return null;
181
+ return {
182
+ id: raw.id,
183
+ name: raw.name,
184
+ sourceGraphId: raw.source_graph_id,
185
+ };
186
+ }
187
+ function rawToSecurityLite(raw) {
188
+ return {
189
+ id: raw.id,
190
+ name: raw.name,
191
+ securityType: raw.security_type,
192
+ securitySubtype: raw.security_subtype,
193
+ isActive: raw.is_active,
194
+ issuer: rawToEntityLite(raw.issuer),
195
+ sourceGraphId: raw.source_graph_id,
196
+ };
197
+ }
198
+ function rawToPositionBlock(raw) {
200
199
  return {
201
200
  id: raw.id,
202
- portfolioId: raw.portfolio_id,
203
- securityId: raw.security_id,
204
- securityName: raw.security_name,
205
- entityName: raw.entity_name,
206
201
  quantity: raw.quantity,
207
202
  quantityType: raw.quantity_type,
208
- costBasis: raw.cost_basis,
209
203
  costBasisDollars: raw.cost_basis_dollars,
210
- currency: raw.currency,
211
- currentValue: raw.current_value,
212
204
  currentValueDollars: raw.current_value_dollars,
213
205
  valuationDate: raw.valuation_date,
214
206
  valuationSource: raw.valuation_source,
215
207
  acquisitionDate: raw.acquisition_date,
216
- dispositionDate: raw.disposition_date,
217
208
  status: raw.status,
218
209
  notes: raw.notes,
210
+ security: rawToSecurityLite(raw.security),
211
+ };
212
+ }
213
+ function rawToPortfolioBlock(raw) {
214
+ return {
215
+ id: raw.id,
216
+ name: raw.name,
217
+ description: raw.description,
218
+ strategy: raw.strategy,
219
+ inceptionDate: raw.inception_date,
220
+ baseCurrency: raw.base_currency,
221
+ owner: rawToEntityLite(raw.owner),
222
+ positions: raw.positions.map(rawToPositionBlock),
223
+ totalCostBasisDollars: raw.total_cost_basis_dollars,
224
+ totalCurrentValueDollars: raw.total_current_value_dollars,
225
+ activePositionCount: raw.active_position_count,
219
226
  createdAt: raw.created_at,
220
227
  updatedAt: raw.updated_at,
221
228
  };