@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.
Files changed (190) hide show
  1. package/extensions/InvestorClient.d.ts +91 -0
  2. package/extensions/InvestorClient.js +223 -0
  3. package/extensions/InvestorClient.ts +501 -0
  4. package/extensions/LedgerClient.d.ts +213 -165
  5. package/extensions/LedgerClient.js +315 -393
  6. package/extensions/LedgerClient.ts +887 -564
  7. package/extensions/ReportClient.d.ts +77 -115
  8. package/extensions/ReportClient.js +124 -211
  9. package/extensions/ReportClient.ts +298 -358
  10. package/extensions/config.js +1 -1
  11. package/extensions/config.ts +1 -1
  12. package/extensions/graphql/client.d.ts +46 -0
  13. package/extensions/graphql/client.js +75 -0
  14. package/extensions/graphql/client.ts +82 -0
  15. package/extensions/graphql/generated/graphql.d.ts +1786 -0
  16. package/extensions/graphql/generated/graphql.js +2671 -0
  17. package/extensions/graphql/generated/graphql.ts +4491 -0
  18. package/extensions/graphql/queries/investor/holdings.d.ts +8 -0
  19. package/extensions/graphql/queries/investor/holdings.js +36 -0
  20. package/extensions/graphql/queries/investor/holdings.ts +34 -0
  21. package/extensions/graphql/queries/investor/portfolio.d.ts +4 -0
  22. package/extensions/graphql/queries/investor/portfolio.js +21 -0
  23. package/extensions/graphql/queries/investor/portfolio.ts +19 -0
  24. package/extensions/graphql/queries/investor/portfolios.d.ts +4 -0
  25. package/extensions/graphql/queries/investor/portfolios.js +29 -0
  26. package/extensions/graphql/queries/investor/portfolios.ts +27 -0
  27. package/extensions/graphql/queries/investor/position.d.ts +4 -0
  28. package/extensions/graphql/queries/investor/position.js +33 -0
  29. package/extensions/graphql/queries/investor/position.ts +31 -0
  30. package/extensions/graphql/queries/investor/positions.d.ts +8 -0
  31. package/extensions/graphql/queries/investor/positions.js +57 -0
  32. package/extensions/graphql/queries/investor/positions.ts +55 -0
  33. package/extensions/graphql/queries/investor/securities.d.ts +8 -0
  34. package/extensions/graphql/queries/investor/securities.js +50 -0
  35. package/extensions/graphql/queries/investor/securities.ts +48 -0
  36. package/extensions/graphql/queries/investor/security.d.ts +4 -0
  37. package/extensions/graphql/queries/investor/security.js +26 -0
  38. package/extensions/graphql/queries/investor/security.ts +24 -0
  39. package/extensions/graphql/queries/ledger/accountRollups.d.ts +7 -0
  40. package/extensions/graphql/queries/ledger/accountRollups.js +36 -0
  41. package/extensions/graphql/queries/ledger/accountRollups.ts +34 -0
  42. package/extensions/graphql/queries/ledger/accountTree.d.ts +11 -0
  43. package/extensions/graphql/queries/ledger/accountTree.js +61 -0
  44. package/extensions/graphql/queries/ledger/accountTree.ts +59 -0
  45. package/extensions/graphql/queries/ledger/accounts.d.ts +8 -0
  46. package/extensions/graphql/queries/ledger/accounts.js +45 -0
  47. package/extensions/graphql/queries/ledger/accounts.ts +43 -0
  48. package/extensions/graphql/queries/ledger/closingBookStructures.d.ts +6 -0
  49. package/extensions/graphql/queries/ledger/closingBookStructures.js +27 -0
  50. package/extensions/graphql/queries/ledger/closingBookStructures.ts +25 -0
  51. package/extensions/graphql/queries/ledger/elements.d.ts +6 -0
  52. package/extensions/graphql/queries/ledger/elements.js +56 -0
  53. package/extensions/graphql/queries/ledger/elements.ts +54 -0
  54. package/extensions/graphql/queries/ledger/entities.d.ts +7 -0
  55. package/extensions/graphql/queries/ledger/entities.js +31 -0
  56. package/extensions/graphql/queries/ledger/entities.ts +29 -0
  57. package/extensions/graphql/queries/ledger/entity.d.ts +14 -0
  58. package/extensions/graphql/queries/ledger/entity.js +55 -0
  59. package/extensions/graphql/queries/ledger/entity.ts +54 -0
  60. package/extensions/graphql/queries/ledger/fiscalCalendar.d.ts +8 -0
  61. package/extensions/graphql/queries/ledger/fiscalCalendar.js +35 -0
  62. package/extensions/graphql/queries/ledger/fiscalCalendar.ts +33 -0
  63. package/extensions/graphql/queries/ledger/mappedTrialBalance.d.ts +9 -0
  64. package/extensions/graphql/queries/ledger/mappedTrialBalance.js +29 -0
  65. package/extensions/graphql/queries/ledger/mappedTrialBalance.ts +27 -0
  66. package/extensions/graphql/queries/ledger/mapping.d.ts +5 -0
  67. package/extensions/graphql/queries/ledger/mapping.js +35 -0
  68. package/extensions/graphql/queries/ledger/mapping.ts +33 -0
  69. package/extensions/graphql/queries/ledger/mappingCoverage.d.ts +5 -0
  70. package/extensions/graphql/queries/ledger/mappingCoverage.js +22 -0
  71. package/extensions/graphql/queries/ledger/mappingCoverage.ts +20 -0
  72. package/extensions/graphql/queries/ledger/mappings.d.ts +6 -0
  73. package/extensions/graphql/queries/ledger/mappings.js +23 -0
  74. package/extensions/graphql/queries/ledger/mappings.ts +21 -0
  75. package/extensions/graphql/queries/ledger/periodCloseStatus.d.ts +6 -0
  76. package/extensions/graphql/queries/ledger/periodCloseStatus.js +29 -0
  77. package/extensions/graphql/queries/ledger/periodCloseStatus.ts +27 -0
  78. package/extensions/graphql/queries/ledger/periodDrafts.d.ts +8 -0
  79. package/extensions/graphql/queries/ledger/periodDrafts.js +45 -0
  80. package/extensions/graphql/queries/ledger/periodDrafts.ts +43 -0
  81. package/extensions/graphql/queries/ledger/publishList.d.ts +5 -0
  82. package/extensions/graphql/queries/ledger/publishList.js +29 -0
  83. package/extensions/graphql/queries/ledger/publishList.ts +27 -0
  84. package/extensions/graphql/queries/ledger/publishLists.d.ts +5 -0
  85. package/extensions/graphql/queries/ledger/publishLists.js +29 -0
  86. package/extensions/graphql/queries/ledger/publishLists.ts +27 -0
  87. package/extensions/graphql/queries/ledger/report.d.ts +5 -0
  88. package/extensions/graphql/queries/ledger/report.js +40 -0
  89. package/extensions/graphql/queries/ledger/report.ts +38 -0
  90. package/extensions/graphql/queries/ledger/reportingTaxonomy.d.ts +6 -0
  91. package/extensions/graphql/queries/ledger/reportingTaxonomy.js +27 -0
  92. package/extensions/graphql/queries/ledger/reportingTaxonomy.ts +25 -0
  93. package/extensions/graphql/queries/ledger/reports.d.ts +8 -0
  94. package/extensions/graphql/queries/ledger/reports.js +45 -0
  95. package/extensions/graphql/queries/ledger/reports.ts +43 -0
  96. package/extensions/graphql/queries/ledger/scheduleFacts.d.ts +7 -0
  97. package/extensions/graphql/queries/ledger/scheduleFacts.js +24 -0
  98. package/extensions/graphql/queries/ledger/scheduleFacts.ts +22 -0
  99. package/extensions/graphql/queries/ledger/schedules.d.ts +6 -0
  100. package/extensions/graphql/queries/ledger/schedules.js +24 -0
  101. package/extensions/graphql/queries/ledger/schedules.ts +22 -0
  102. package/extensions/graphql/queries/ledger/statement.d.ts +9 -0
  103. package/extensions/graphql/queries/ledger/statement.js +43 -0
  104. package/extensions/graphql/queries/ledger/statement.ts +41 -0
  105. package/extensions/graphql/queries/ledger/structures.d.ts +5 -0
  106. package/extensions/graphql/queries/ledger/structures.js +22 -0
  107. package/extensions/graphql/queries/ledger/structures.ts +20 -0
  108. package/extensions/graphql/queries/ledger/summary.d.ts +7 -0
  109. package/extensions/graphql/queries/ledger/summary.js +25 -0
  110. package/extensions/graphql/queries/ledger/summary.ts +23 -0
  111. package/extensions/graphql/queries/ledger/taxonomies.d.ts +5 -0
  112. package/extensions/graphql/queries/ledger/taxonomies.js +28 -0
  113. package/extensions/graphql/queries/ledger/taxonomies.ts +26 -0
  114. package/extensions/graphql/queries/ledger/transaction.d.ts +6 -0
  115. package/extensions/graphql/queries/ledger/transaction.js +49 -0
  116. package/extensions/graphql/queries/ledger/transaction.ts +47 -0
  117. package/extensions/graphql/queries/ledger/transactions.d.ts +7 -0
  118. package/extensions/graphql/queries/ledger/transactions.js +49 -0
  119. package/extensions/graphql/queries/ledger/transactions.ts +47 -0
  120. package/extensions/graphql/queries/ledger/trialBalance.d.ts +7 -0
  121. package/extensions/graphql/queries/ledger/trialBalance.js +28 -0
  122. package/extensions/graphql/queries/ledger/trialBalance.ts +26 -0
  123. package/extensions/graphql/queries/ledger/unmappedElements.d.ts +8 -0
  124. package/extensions/graphql/queries/ledger/unmappedElements.js +29 -0
  125. package/extensions/graphql/queries/ledger/unmappedElements.ts +27 -0
  126. package/extensions/hooks.d.ts +1 -1
  127. package/extensions/index.d.ts +5 -1
  128. package/extensions/index.js +13 -1
  129. package/extensions/index.ts +14 -0
  130. package/index.ts +2 -2
  131. package/package.json +14 -5
  132. package/sdk/index.d.ts +2 -2
  133. package/sdk/index.js +38 -65
  134. package/sdk/index.ts +2 -2
  135. package/sdk/sdk.gen.d.ts +101 -220
  136. package/sdk/sdk.gen.js +251 -445
  137. package/sdk/sdk.gen.ts +216 -409
  138. package/sdk/types.gen.d.ts +4586 -7045
  139. package/sdk/types.gen.ts +4702 -7334
  140. package/sdk.gen.d.ts +101 -220
  141. package/sdk.gen.js +251 -445
  142. package/sdk.gen.ts +216 -409
  143. package/types.gen.d.ts +4586 -7045
  144. package/types.gen.ts +4702 -7334
  145. package/extensions/AgentClient.test.ts +0 -403
  146. package/extensions/LedgerClient.test.ts +0 -1138
  147. package/extensions/OperationClient.test.ts +0 -365
  148. package/extensions/QueryClient.test.ts +0 -432
  149. package/extensions/ReportClient.test.ts +0 -828
  150. package/extensions/SSEClient.test.ts +0 -375
  151. package/extensions/config.test.ts +0 -199
  152. package/extensions/hooks.test.ts +0 -373
  153. package/extensions/index.test.ts +0 -420
  154. package/sdk-extensions/AgentClient.d.ts +0 -82
  155. package/sdk-extensions/AgentClient.js +0 -218
  156. package/sdk-extensions/AgentClient.test.ts +0 -403
  157. package/sdk-extensions/AgentClient.ts +0 -321
  158. package/sdk-extensions/LedgerClient.d.ts +0 -242
  159. package/sdk-extensions/LedgerClient.js +0 -496
  160. package/sdk-extensions/LedgerClient.test.ts +0 -1138
  161. package/sdk-extensions/LedgerClient.ts +0 -800
  162. package/sdk-extensions/OperationClient.d.ts +0 -65
  163. package/sdk-extensions/OperationClient.js +0 -251
  164. package/sdk-extensions/OperationClient.test.ts +0 -365
  165. package/sdk-extensions/OperationClient.ts +0 -324
  166. package/sdk-extensions/QueryClient.d.ts +0 -52
  167. package/sdk-extensions/QueryClient.js +0 -313
  168. package/sdk-extensions/QueryClient.test.ts +0 -432
  169. package/sdk-extensions/QueryClient.ts +0 -420
  170. package/sdk-extensions/README.md +0 -901
  171. package/sdk-extensions/ReportClient.d.ts +0 -151
  172. package/sdk-extensions/ReportClient.js +0 -278
  173. package/sdk-extensions/ReportClient.test.ts +0 -828
  174. package/sdk-extensions/ReportClient.ts +0 -486
  175. package/sdk-extensions/SSEClient.d.ts +0 -62
  176. package/sdk-extensions/SSEClient.js +0 -154
  177. package/sdk-extensions/SSEClient.test.ts +0 -375
  178. package/sdk-extensions/SSEClient.ts +0 -210
  179. package/sdk-extensions/config.d.ts +0 -57
  180. package/sdk-extensions/config.js +0 -152
  181. package/sdk-extensions/config.test.ts +0 -199
  182. package/sdk-extensions/config.ts +0 -175
  183. package/sdk-extensions/hooks.d.ts +0 -110
  184. package/sdk-extensions/hooks.js +0 -384
  185. package/sdk-extensions/hooks.test.ts +0 -373
  186. package/sdk-extensions/hooks.ts +0 -459
  187. package/sdk-extensions/index.d.ts +0 -63
  188. package/sdk-extensions/index.js +0 -164
  189. package/sdk-extensions/index.test.ts +0 -420
  190. package/sdk-extensions/index.ts +0 -203
@@ -81,7 +81,7 @@ function isValidJWT(token) {
81
81
  */
82
82
  function extractTokenFromSDKClient() {
83
83
  // Import dynamically to avoid circular dependency
84
- const { client } = require('../sdk/client.gen');
84
+ const { client } = require('../client.gen');
85
85
  const sdkConfig = getSDKExtensionsConfig();
86
86
  // Priority 1: Use explicitly configured token
87
87
  if (sdkConfig.token) {
@@ -94,7 +94,7 @@ export function isValidJWT(token: string | undefined): boolean {
94
94
  */
95
95
  export function extractTokenFromSDKClient(): string | undefined {
96
96
  // Import dynamically to avoid circular dependency
97
- const { client } = require('../sdk/client.gen')
97
+ const { client } = require('../client.gen')
98
98
 
99
99
  const sdkConfig = getSDKExtensionsConfig()
100
100
 
@@ -0,0 +1,46 @@
1
+ /**
2
+ * GraphQL client factory used internally by the facade clients.
3
+ *
4
+ * This is an implementation detail — consumers never interact with it
5
+ * directly. They call methods on LedgerClient / InvestorClient / etc.,
6
+ * which use this to execute GraphQL queries against
7
+ * `/extensions/{graph_id}/graphql`.
8
+ *
9
+ * **Graph scoping.** The GraphQL endpoint is mounted per-graph at
10
+ * `/extensions/{graph_id}/graphql`. Resolvers read the graph from the URL
11
+ * path parameter — never from GraphQL variables. Every facade method
12
+ * takes a `graphId` and resolves the correct per-graph client via
13
+ * `getGraphQLClient(graphId)`, which caches one `GraphQLClient` instance
14
+ * per graph to avoid rebuilding headers + URLs on every call.
15
+ *
16
+ * We pick graphql-request (tiny, no React, no caching) because the facade
17
+ * doesn't need the hook ergonomics that urql/Apollo provide. Type safety
18
+ * comes from GraphQL Code Generator, which produces typed DocumentNodes
19
+ * from the query files in sdk-extensions/graphql/queries/.
20
+ */
21
+ import { GraphQLClient } from 'graphql-request';
22
+ export interface GraphQLClientConfig {
23
+ baseUrl: string;
24
+ token?: string;
25
+ headers?: Record<string, string>;
26
+ credentials?: 'include' | 'same-origin' | 'omit';
27
+ }
28
+ /**
29
+ * Build a new GraphQL client for the given graph. Prefer
30
+ * `GraphQLClientCache.get(graphId)` in facade code — this is the raw
31
+ * factory and bypasses the cache.
32
+ */
33
+ export declare function createGraphQLClient(config: GraphQLClientConfig, graphId: string): GraphQLClient;
34
+ /**
35
+ * Per-graph cache of GraphQL clients. Facade clients own one instance of
36
+ * this and call `.get(graphId)` on every GraphQL method — cheap after the
37
+ * first call per graph.
38
+ */
39
+ export declare class GraphQLClientCache {
40
+ private config;
41
+ private clients;
42
+ constructor(config: GraphQLClientConfig);
43
+ get(graphId: string): GraphQLClient;
44
+ /** Drop all cached clients. Useful after a token rotation. */
45
+ clear(): void;
46
+ }
@@ -0,0 +1,75 @@
1
+ 'use client';
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.GraphQLClientCache = void 0;
5
+ exports.createGraphQLClient = createGraphQLClient;
6
+ /**
7
+ * GraphQL client factory used internally by the facade clients.
8
+ *
9
+ * This is an implementation detail — consumers never interact with it
10
+ * directly. They call methods on LedgerClient / InvestorClient / etc.,
11
+ * which use this to execute GraphQL queries against
12
+ * `/extensions/{graph_id}/graphql`.
13
+ *
14
+ * **Graph scoping.** The GraphQL endpoint is mounted per-graph at
15
+ * `/extensions/{graph_id}/graphql`. Resolvers read the graph from the URL
16
+ * path parameter — never from GraphQL variables. Every facade method
17
+ * takes a `graphId` and resolves the correct per-graph client via
18
+ * `getGraphQLClient(graphId)`, which caches one `GraphQLClient` instance
19
+ * per graph to avoid rebuilding headers + URLs on every call.
20
+ *
21
+ * We pick graphql-request (tiny, no React, no caching) because the facade
22
+ * doesn't need the hook ergonomics that urql/Apollo provide. Type safety
23
+ * comes from GraphQL Code Generator, which produces typed DocumentNodes
24
+ * from the query files in sdk-extensions/graphql/queries/.
25
+ */
26
+ const graphql_request_1 = require("graphql-request");
27
+ /**
28
+ * Build a new GraphQL client for the given graph. Prefer
29
+ * `GraphQLClientCache.get(graphId)` in facade code — this is the raw
30
+ * factory and bypasses the cache.
31
+ */
32
+ function createGraphQLClient(config, graphId) {
33
+ if (!graphId) {
34
+ throw new Error('createGraphQLClient requires a non-empty graphId');
35
+ }
36
+ const url = `${config.baseUrl.replace(/\/$/, '')}/extensions/${graphId}/graphql`;
37
+ const headers = {
38
+ ...(config.headers ?? {}),
39
+ };
40
+ if (config.token) {
41
+ // The backend accepts both Authorization: Bearer and X-API-Key. Match
42
+ // the existing facade convention of sending the token as X-API-Key,
43
+ // which is what the local dev workflow uses.
44
+ headers['X-API-Key'] = config.token;
45
+ }
46
+ return new graphql_request_1.GraphQLClient(url, {
47
+ headers,
48
+ credentials: config.credentials,
49
+ });
50
+ }
51
+ /**
52
+ * Per-graph cache of GraphQL clients. Facade clients own one instance of
53
+ * this and call `.get(graphId)` on every GraphQL method — cheap after the
54
+ * first call per graph.
55
+ */
56
+ class GraphQLClientCache {
57
+ constructor(config) {
58
+ this.config = config;
59
+ this.clients = new Map();
60
+ }
61
+ get(graphId) {
62
+ const existing = this.clients.get(graphId);
63
+ if (existing !== undefined) {
64
+ return existing;
65
+ }
66
+ const client = createGraphQLClient(this.config, graphId);
67
+ this.clients.set(graphId, client);
68
+ return client;
69
+ }
70
+ /** Drop all cached clients. Useful after a token rotation. */
71
+ clear() {
72
+ this.clients.clear();
73
+ }
74
+ }
75
+ exports.GraphQLClientCache = GraphQLClientCache;
@@ -0,0 +1,82 @@
1
+ 'use client'
2
+
3
+ /**
4
+ * GraphQL client factory used internally by the facade clients.
5
+ *
6
+ * This is an implementation detail — consumers never interact with it
7
+ * directly. They call methods on LedgerClient / InvestorClient / etc.,
8
+ * which use this to execute GraphQL queries against
9
+ * `/extensions/{graph_id}/graphql`.
10
+ *
11
+ * **Graph scoping.** The GraphQL endpoint is mounted per-graph at
12
+ * `/extensions/{graph_id}/graphql`. Resolvers read the graph from the URL
13
+ * path parameter — never from GraphQL variables. Every facade method
14
+ * takes a `graphId` and resolves the correct per-graph client via
15
+ * `getGraphQLClient(graphId)`, which caches one `GraphQLClient` instance
16
+ * per graph to avoid rebuilding headers + URLs on every call.
17
+ *
18
+ * We pick graphql-request (tiny, no React, no caching) because the facade
19
+ * doesn't need the hook ergonomics that urql/Apollo provide. Type safety
20
+ * comes from GraphQL Code Generator, which produces typed DocumentNodes
21
+ * from the query files in sdk-extensions/graphql/queries/.
22
+ */
23
+
24
+ import { GraphQLClient } from 'graphql-request'
25
+
26
+ export interface GraphQLClientConfig {
27
+ baseUrl: string
28
+ token?: string
29
+ headers?: Record<string, string>
30
+ credentials?: 'include' | 'same-origin' | 'omit'
31
+ }
32
+
33
+ /**
34
+ * Build a new GraphQL client for the given graph. Prefer
35
+ * `GraphQLClientCache.get(graphId)` in facade code — this is the raw
36
+ * factory and bypasses the cache.
37
+ */
38
+ export function createGraphQLClient(config: GraphQLClientConfig, graphId: string): GraphQLClient {
39
+ if (!graphId) {
40
+ throw new Error('createGraphQLClient requires a non-empty graphId')
41
+ }
42
+ const url = `${config.baseUrl.replace(/\/$/, '')}/extensions/${graphId}/graphql`
43
+ const headers: Record<string, string> = {
44
+ ...(config.headers ?? {}),
45
+ }
46
+ if (config.token) {
47
+ // The backend accepts both Authorization: Bearer and X-API-Key. Match
48
+ // the existing facade convention of sending the token as X-API-Key,
49
+ // which is what the local dev workflow uses.
50
+ headers['X-API-Key'] = config.token
51
+ }
52
+ return new GraphQLClient(url, {
53
+ headers,
54
+ credentials: config.credentials,
55
+ })
56
+ }
57
+
58
+ /**
59
+ * Per-graph cache of GraphQL clients. Facade clients own one instance of
60
+ * this and call `.get(graphId)` on every GraphQL method — cheap after the
61
+ * first call per graph.
62
+ */
63
+ export class GraphQLClientCache {
64
+ private clients = new Map<string, GraphQLClient>()
65
+
66
+ constructor(private config: GraphQLClientConfig) {}
67
+
68
+ get(graphId: string): GraphQLClient {
69
+ const existing = this.clients.get(graphId)
70
+ if (existing !== undefined) {
71
+ return existing
72
+ }
73
+ const client = createGraphQLClient(this.config, graphId)
74
+ this.clients.set(graphId, client)
75
+ return client
76
+ }
77
+
78
+ /** Drop all cached clients. Useful after a token rotation. */
79
+ clear(): void {
80
+ this.clients.clear()
81
+ }
82
+ }