@meshtrade/api-node 1.30.2 → 1.32.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/dist/meshtrade/compliance/client/v1/client_pb.d.ts +17 -9
- package/dist/meshtrade/compliance/client/v1/client_pb.js +1 -1
- package/dist/meshtrade/compliance/client/v1/service_node_meshts.d.ts +46 -21
- package/dist/meshtrade/compliance/client/v1/service_node_meshts.js +98 -56
- package/dist/meshtrade/config/index.d.ts +160 -0
- package/dist/meshtrade/config/index.js +210 -0
- package/dist/meshtrade/iam/api_user/v1/api_user_pb.d.ts +12 -4
- package/dist/meshtrade/iam/api_user/v1/api_user_pb.js +1 -1
- package/dist/meshtrade/iam/api_user/v1/service_node_meshts.d.ts +46 -21
- package/dist/meshtrade/iam/api_user/v1/service_node_meshts.js +149 -65
- package/dist/meshtrade/iam/group/v1/group_pb.d.ts +8 -0
- package/dist/meshtrade/iam/group/v1/group_pb.js +1 -1
- package/dist/meshtrade/iam/group/v1/service_node_meshts.d.ts +46 -21
- package/dist/meshtrade/iam/group/v1/service_node_meshts.js +114 -58
- package/dist/meshtrade/iam/user/v1/service_node_meshts.d.ts +46 -21
- package/dist/meshtrade/iam/user/v1/service_node_meshts.js +141 -64
- package/dist/meshtrade/iam/user/v1/user_pb.d.ts +10 -2
- package/dist/meshtrade/iam/user/v1/user_pb.js +1 -1
- package/dist/meshtrade/{common/connectInterceptors.d.ts → interceptors/index.d.ts} +6 -64
- package/dist/meshtrade/{common/connectInterceptors.js → interceptors/index.js} +20 -90
- package/dist/meshtrade/ledger/transaction/v1/service_node_meshts.d.ts +46 -21
- package/dist/meshtrade/ledger/transaction/v1/service_node_meshts.js +90 -55
- package/dist/meshtrade/market_data/price/v1/service_node_meshts.d.ts +46 -21
- package/dist/meshtrade/market_data/price/v1/service_node_meshts.js +82 -54
- package/dist/meshtrade/reporting/account_report/v1/service_node_meshts.d.ts +46 -21
- package/dist/meshtrade/reporting/account_report/v1/service_node_meshts.js +90 -55
- package/dist/meshtrade/studio/instrument/v1/instrument_pb.d.ts +8 -0
- package/dist/meshtrade/studio/instrument/v1/instrument_pb.js +1 -1
- package/dist/meshtrade/trading/limit_order/v1/limit_order_pb.d.ts +16 -8
- package/dist/meshtrade/trading/limit_order/v1/limit_order_pb.js +1 -1
- package/dist/meshtrade/trading/limit_order/v1/service_node_meshts.d.ts +46 -21
- package/dist/meshtrade/trading/limit_order/v1/service_node_meshts.js +133 -63
- package/dist/meshtrade/trading/limit_order/v1/service_pb.js +1 -1
- package/dist/meshtrade/trading/market_order/v1/service_node_meshts.d.ts +46 -21
- package/dist/meshtrade/trading/market_order/v1/service_node_meshts.js +82 -54
- package/dist/meshtrade/wallet/account/v1/account_pb.d.ts +8 -0
- package/dist/meshtrade/wallet/account/v1/account_pb.js +1 -1
- package/dist/meshtrade/wallet/account/v1/service_node_meshts.d.ts +46 -21
- package/dist/meshtrade/wallet/account/v1/service_node_meshts.js +149 -65
- package/package.json +19 -2
- package/dist/meshtrade/common/config.d.ts +0 -50
- package/dist/meshtrade/common/config.js +0 -34
- package/dist/meshtrade/common/validation.d.ts +0 -62
- package/dist/meshtrade/common/validation.js +0 -77
|
@@ -1,59 +1,84 @@
|
|
|
1
|
-
import { Interceptor } from "@connectrpc/connect";
|
|
2
1
|
import { GetAccountReportRequest, GetExcelAccountReportRequest, GetExcelAccountReportResponse } from "./service_pb";
|
|
3
2
|
import { AccountReport } from "./account_report_pb";
|
|
4
|
-
import {
|
|
3
|
+
import { ClientOption } from "../../../config";
|
|
5
4
|
/**
|
|
6
5
|
* Node.js client for interacting with the meshtrade.reporting.account_report.v1 account report v1 API resource service.
|
|
7
6
|
* Uses Connect-ES with gRPC transport for Node.js gRPC communication.
|
|
8
7
|
*
|
|
9
|
-
* Supports
|
|
8
|
+
* Supports flexible authentication modes using functional options pattern:
|
|
10
9
|
*
|
|
11
10
|
* 1. **No Authentication** (public APIs):
|
|
12
11
|
* ```typescript
|
|
13
|
-
* const client = new AccountReportServiceNode(
|
|
12
|
+
* const client = new AccountReportServiceNode(
|
|
13
|
+
* WithServerUrl("http://localhost:10000")
|
|
14
|
+
* );
|
|
14
15
|
* ```
|
|
15
16
|
*
|
|
16
17
|
* 2. **API Key Authentication** (backend services):
|
|
17
18
|
* ```typescript
|
|
18
|
-
* const client = new AccountReportServiceNode(
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* const client = new AccountReportServiceNode(
|
|
20
|
+
* WithAPIKey("your-api-key"),
|
|
21
|
+
* WithGroup("groups/01ARZ3NDEKTSV4YWVF8F5BH32"),
|
|
22
|
+
* WithServerUrl("https://api.example.com")
|
|
23
|
+
* );
|
|
23
24
|
* ```
|
|
24
25
|
*
|
|
25
26
|
* 3. **JWT Token Authentication** (Next.js backend with user session):
|
|
26
27
|
* ```typescript
|
|
27
|
-
* const client = new AccountReportServiceNode(
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
28
|
+
* const client = new AccountReportServiceNode(
|
|
29
|
+
* WithJWTAccessToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."),
|
|
30
|
+
* WithServerUrl("https://api.example.com")
|
|
31
|
+
* );
|
|
31
32
|
* ```
|
|
33
|
+
*
|
|
34
|
+
* 4. **JWT with Group Context** (user session with specific group):
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const client = new AccountReportServiceNode(
|
|
37
|
+
* WithJWTAccessToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."),
|
|
38
|
+
* WithGroup("groups/01ARZ3NDEKTSV4YWVF8F5BH32"),
|
|
39
|
+
* WithServerUrl("https://api.example.com")
|
|
40
|
+
* );
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* Available options:
|
|
44
|
+
* - `WithAPIKey(key)` - API key authentication (mutually exclusive with JWT)
|
|
45
|
+
* - `WithJWTAccessToken(token)` - JWT authentication (mutually exclusive with API key)
|
|
46
|
+
* - `WithGroup(group)` - Group context (optional, works with both auth modes)
|
|
47
|
+
* - `WithServerUrl(url)` - Custom server URL (optional, defaults to production)
|
|
32
48
|
*/
|
|
33
49
|
export declare class AccountReportServiceNode {
|
|
34
50
|
private _client;
|
|
35
51
|
private readonly _config;
|
|
36
52
|
private readonly _interceptors;
|
|
53
|
+
private readonly _validator;
|
|
37
54
|
/**
|
|
38
55
|
* Constructs an instance of AccountReportServiceNode.
|
|
39
|
-
*
|
|
40
|
-
*
|
|
56
|
+
*
|
|
57
|
+
* Uses functional options pattern for flexible configuration:
|
|
58
|
+
* - `WithAPIKey(key)` - API key authentication
|
|
59
|
+
* - `WithJWTAccessToken(token)` - JWT authentication
|
|
60
|
+
* - `WithGroup(group)` - Group context (optional)
|
|
61
|
+
* - `WithServerUrl(url)` - Custom server URL (optional)
|
|
62
|
+
*
|
|
63
|
+
* @param {...ClientOption} opts - Variable number of configuration options
|
|
41
64
|
*/
|
|
42
|
-
constructor(
|
|
65
|
+
constructor(...opts: ClientOption[]);
|
|
43
66
|
/**
|
|
44
67
|
* Returns a new client instance configured to send the specified group
|
|
45
68
|
* resource name in the request headers for subsequent API calls.
|
|
46
69
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
70
|
+
* This method creates a new client with the same authentication configuration
|
|
71
|
+
* but with the group context updated to the specified value.
|
|
72
|
+
*
|
|
73
|
+
* **Compatibility**: Works with all authentication modes:
|
|
74
|
+
* - **API key auth**: Creates new client with API key + new group
|
|
75
|
+
* - **JWT auth**: Creates new client with JWT + new group
|
|
76
|
+
* - **No auth**: Creates new client with standalone group interceptor
|
|
51
77
|
*
|
|
52
78
|
* @param {string} group - The operating group context to inject into the request
|
|
53
79
|
* in the format `groups/{ulid}` where {ulid} is a 26-character ULID.
|
|
54
80
|
* Example: 'groups/01ARZ3NDEKTSV4YWVF8F5BH32'
|
|
55
81
|
* @returns {AccountReportServiceNode} A new, configured instance of the client.
|
|
56
|
-
* @throws {Error} If used with JWT authentication or no authentication
|
|
57
82
|
* @throws {Error} If the group format is invalid
|
|
58
83
|
*/
|
|
59
84
|
withGroup(group: string): AccountReportServiceNode;
|
|
@@ -7,62 +7,82 @@ exports.AccountReportServiceNode = void 0;
|
|
|
7
7
|
const connect_1 = require("@connectrpc/connect");
|
|
8
8
|
const connect_node_1 = require("@connectrpc/connect-node");
|
|
9
9
|
const service_pb_1 = require("./service_pb");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
10
|
+
const service_pb_2 = require("./service_pb");
|
|
11
|
+
const config_1 = require("../../../config");
|
|
12
|
+
const protovalidate_1 = require("@bufbuild/protovalidate");
|
|
13
|
+
const interceptors_1 = require("../../../interceptors");
|
|
13
14
|
/**
|
|
14
15
|
* Node.js client for interacting with the meshtrade.reporting.account_report.v1 account report v1 API resource service.
|
|
15
16
|
* Uses Connect-ES with gRPC transport for Node.js gRPC communication.
|
|
16
17
|
*
|
|
17
|
-
* Supports
|
|
18
|
+
* Supports flexible authentication modes using functional options pattern:
|
|
18
19
|
*
|
|
19
20
|
* 1. **No Authentication** (public APIs):
|
|
20
21
|
* ```typescript
|
|
21
|
-
* const client = new AccountReportServiceNode(
|
|
22
|
+
* const client = new AccountReportServiceNode(
|
|
23
|
+
* WithServerUrl("http://localhost:10000")
|
|
24
|
+
* );
|
|
22
25
|
* ```
|
|
23
26
|
*
|
|
24
27
|
* 2. **API Key Authentication** (backend services):
|
|
25
28
|
* ```typescript
|
|
26
|
-
* const client = new AccountReportServiceNode(
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
29
|
+
* const client = new AccountReportServiceNode(
|
|
30
|
+
* WithAPIKey("your-api-key"),
|
|
31
|
+
* WithGroup("groups/01ARZ3NDEKTSV4YWVF8F5BH32"),
|
|
32
|
+
* WithServerUrl("https://api.example.com")
|
|
33
|
+
* );
|
|
31
34
|
* ```
|
|
32
35
|
*
|
|
33
36
|
* 3. **JWT Token Authentication** (Next.js backend with user session):
|
|
34
37
|
* ```typescript
|
|
35
|
-
* const client = new AccountReportServiceNode(
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
38
|
+
* const client = new AccountReportServiceNode(
|
|
39
|
+
* WithJWTAccessToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."),
|
|
40
|
+
* WithServerUrl("https://api.example.com")
|
|
41
|
+
* );
|
|
39
42
|
* ```
|
|
43
|
+
*
|
|
44
|
+
* 4. **JWT with Group Context** (user session with specific group):
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const client = new AccountReportServiceNode(
|
|
47
|
+
* WithJWTAccessToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."),
|
|
48
|
+
* WithGroup("groups/01ARZ3NDEKTSV4YWVF8F5BH32"),
|
|
49
|
+
* WithServerUrl("https://api.example.com")
|
|
50
|
+
* );
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* Available options:
|
|
54
|
+
* - `WithAPIKey(key)` - API key authentication (mutually exclusive with JWT)
|
|
55
|
+
* - `WithJWTAccessToken(token)` - JWT authentication (mutually exclusive with API key)
|
|
56
|
+
* - `WithGroup(group)` - Group context (optional, works with both auth modes)
|
|
57
|
+
* - `WithServerUrl(url)` - Custom server URL (optional, defaults to production)
|
|
40
58
|
*/
|
|
41
59
|
class AccountReportServiceNode {
|
|
42
60
|
/**
|
|
43
61
|
* Constructs an instance of AccountReportServiceNode.
|
|
44
|
-
*
|
|
45
|
-
*
|
|
62
|
+
*
|
|
63
|
+
* Uses functional options pattern for flexible configuration:
|
|
64
|
+
* - `WithAPIKey(key)` - API key authentication
|
|
65
|
+
* - `WithJWTAccessToken(token)` - JWT authentication
|
|
66
|
+
* - `WithGroup(group)` - Group context (optional)
|
|
67
|
+
* - `WithServerUrl(url)` - Custom server URL (optional)
|
|
68
|
+
*
|
|
69
|
+
* @param {...ClientOption} opts - Variable number of configuration options
|
|
46
70
|
*/
|
|
47
|
-
constructor(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
71
|
+
constructor(...opts) {
|
|
72
|
+
// Build configuration from options
|
|
73
|
+
this._config = (0, config_1.buildConfigFromOptions)(...opts);
|
|
74
|
+
// Initialize validator for request validation
|
|
75
|
+
this._validator = (0, protovalidate_1.createValidator)();
|
|
76
|
+
this._interceptors = [];
|
|
77
|
+
this._interceptors.push((0, interceptors_1.createLoggingInterceptor)());
|
|
78
|
+
if (this._config.apiKey) {
|
|
79
|
+
this._interceptors.push((0, interceptors_1.createApiKeyInterceptor)(this._config.apiKey));
|
|
80
|
+
}
|
|
81
|
+
if (this._config.jwtToken) {
|
|
82
|
+
this._interceptors.push((0, interceptors_1.createJwtInterceptor)(this._config.jwtToken));
|
|
53
83
|
}
|
|
54
|
-
|
|
55
|
-
this._interceptors
|
|
56
|
-
// Add authentication interceptor based on configuration
|
|
57
|
-
if (this._config.apiKey && this._config.group) {
|
|
58
|
-
// API Key authentication mode
|
|
59
|
-
this._interceptors.push((0, connectInterceptors_1.createApiKeyInterceptor)(this._config.apiKey, this._config.group));
|
|
60
|
-
}
|
|
61
|
-
else if (this._config.jwtToken) {
|
|
62
|
-
// JWT authentication mode
|
|
63
|
-
this._interceptors.push((0, connectInterceptors_1.createJwtInterceptor)(this._config.jwtToken));
|
|
64
|
-
}
|
|
65
|
-
// If neither is configured, no authentication (public API mode)
|
|
84
|
+
if (this._config.group) {
|
|
85
|
+
this._interceptors.push((0, interceptors_1.createGroupInterceptor)(this._config.group));
|
|
66
86
|
}
|
|
67
87
|
// Create the gRPC transport for Node.js with interceptors
|
|
68
88
|
// Note: gRPC transport uses HTTP/2 by default
|
|
@@ -77,35 +97,36 @@ class AccountReportServiceNode {
|
|
|
77
97
|
* Returns a new client instance configured to send the specified group
|
|
78
98
|
* resource name in the request headers for subsequent API calls.
|
|
79
99
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
100
|
+
* This method creates a new client with the same authentication configuration
|
|
101
|
+
* but with the group context updated to the specified value.
|
|
102
|
+
*
|
|
103
|
+
* **Compatibility**: Works with all authentication modes:
|
|
104
|
+
* - **API key auth**: Creates new client with API key + new group
|
|
105
|
+
* - **JWT auth**: Creates new client with JWT + new group
|
|
106
|
+
* - **No auth**: Creates new client with standalone group interceptor
|
|
84
107
|
*
|
|
85
108
|
* @param {string} group - The operating group context to inject into the request
|
|
86
109
|
* in the format `groups/{ulid}` where {ulid} is a 26-character ULID.
|
|
87
110
|
* Example: 'groups/01ARZ3NDEKTSV4YWVF8F5BH32'
|
|
88
111
|
* @returns {AccountReportServiceNode} A new, configured instance of the client.
|
|
89
|
-
* @throws {Error} If used with JWT authentication or no authentication
|
|
90
112
|
* @throws {Error} If the group format is invalid
|
|
91
113
|
*/
|
|
92
114
|
withGroup(group) {
|
|
93
|
-
//
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
115
|
+
// Build new options array with existing auth and updated group
|
|
116
|
+
const newOpts = [];
|
|
117
|
+
// Add server URL
|
|
118
|
+
newOpts.push((0, config_1.WithServerUrl)(this._config.apiServerURL));
|
|
119
|
+
// Add authentication (preserve existing mode)
|
|
120
|
+
if (this._config.apiKey) {
|
|
121
|
+
newOpts.push((0, config_1.WithAPIKey)(this._config.apiKey));
|
|
97
122
|
}
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
"Please configure API key authentication to use group context.");
|
|
123
|
+
else if (this._config.jwtToken) {
|
|
124
|
+
newOpts.push((0, config_1.WithJWTAccessToken)(this._config.jwtToken));
|
|
101
125
|
}
|
|
102
|
-
//
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
];
|
|
107
|
-
// Return a new client instance with updated group context
|
|
108
|
-
return new AccountReportServiceNode(this._config, newInterceptors);
|
|
126
|
+
// Add the new group
|
|
127
|
+
newOpts.push((0, config_1.WithGroup)(group));
|
|
128
|
+
// Return a new client instance with updated configuration
|
|
129
|
+
return new AccountReportServiceNode(...newOpts);
|
|
109
130
|
}
|
|
110
131
|
/**
|
|
111
132
|
* Retrieves an account report.
|
|
@@ -114,7 +135,14 @@ class AccountReportServiceNode {
|
|
|
114
135
|
*/
|
|
115
136
|
getAccountReport(request) {
|
|
116
137
|
// Validate request
|
|
117
|
-
(
|
|
138
|
+
const result = this._validator.validate(service_pb_2.GetAccountReportRequestSchema, request);
|
|
139
|
+
if (result.kind === "invalid") {
|
|
140
|
+
const violations = result.violations.map(v => `${v.field.toString()}: ${v.message}`).join("; ");
|
|
141
|
+
throw new Error(`Validation failed: ${violations}`);
|
|
142
|
+
}
|
|
143
|
+
else if (result.kind === "error") {
|
|
144
|
+
throw result.error;
|
|
145
|
+
}
|
|
118
146
|
return this._client.getAccountReport(request);
|
|
119
147
|
}
|
|
120
148
|
/**
|
|
@@ -124,7 +152,14 @@ class AccountReportServiceNode {
|
|
|
124
152
|
*/
|
|
125
153
|
getExcelAccountReport(request) {
|
|
126
154
|
// Validate request
|
|
127
|
-
(
|
|
155
|
+
const result = this._validator.validate(service_pb_2.GetExcelAccountReportRequestSchema, request);
|
|
156
|
+
if (result.kind === "invalid") {
|
|
157
|
+
const violations = result.violations.map(v => `${v.field.toString()}: ${v.message}`).join("; ");
|
|
158
|
+
throw new Error(`Validation failed: ${violations}`);
|
|
159
|
+
}
|
|
160
|
+
else if (result.kind === "error") {
|
|
161
|
+
throw result.error;
|
|
162
|
+
}
|
|
128
163
|
return this._client.getExcelAccountReport(request);
|
|
129
164
|
}
|
|
130
165
|
}
|
|
@@ -30,6 +30,14 @@ export type Instrument = Message<"meshtrade.studio.instrument.v1.Instrument"> &
|
|
|
30
30
|
* @generated from field: string owner = 2;
|
|
31
31
|
*/
|
|
32
32
|
owner: string;
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* Ownership hiearchy of groups that have access to this resource in the format groups/{group_id}.
|
|
36
|
+
* System set on creation.
|
|
37
|
+
*
|
|
38
|
+
* @generated from field: repeated string owners = 3;
|
|
39
|
+
*/
|
|
40
|
+
owners: string[];
|
|
33
41
|
/**
|
|
34
42
|
*
|
|
35
43
|
* Human-readable name for organizational identification and display.
|
|
@@ -10,7 +10,7 @@ const token_pb_1 = require("../../../type/v1/token_pb");
|
|
|
10
10
|
/**
|
|
11
11
|
* Describes the file meshtrade/studio/instrument/v1/instrument.proto.
|
|
12
12
|
*/
|
|
13
|
-
exports.file_meshtrade_studio_instrument_v1_instrument = (0, codegenv2_1.fileDesc)("
|
|
13
|
+
exports.file_meshtrade_studio_instrument_v1_instrument = (0, codegenv2_1.fileDesc)("Ci9tZXNodHJhZGUvc3R1ZGlvL2luc3RydW1lbnQvdjEvaW5zdHJ1bWVudC5wcm90bxIebWVzaHRyYWRlLnN0dWRpby5pbnN0cnVtZW50LnYxIqoDCgpJbnN0cnVtZW50ErYBCgRuYW1lGAEgASgJQqcBukijAboBnwEKFG5hbWUuZm9ybWF0Lm9wdGlvbmFsEjNuYW1lIG11c3QgYmUgZW1wdHkgb3IgaW4gdGhlIGZvcm1hdCBncm91cHMve1VMSUR2Mn0aUnNpemUodGhpcykgPT0gMCB8fCB0aGlzLm1hdGNoZXMoJ15ncm91cHMvWzAxMjM0NTY3ODlBQkNERUZHSEpLTU5QUVJTVFZXWFlaXXsyNn0kJykSSAoFb3duZXIYAiABKAlCObpINnI0Mi9eZ3JvdXBzL1swMTIzNDU2Nzg5QUJDREVGR0hKS01OUFFSU1RWV1hZWl17MjZ9JJgBIRJOCgZvd25lcnMYAyADKAlCPrpIO5IBOCI2cjQyL15ncm91cHMvWzAxMjM0NTY3ODlBQkNERUZHSEpLTU5QUVJTVFZXWFlaXXsyNn0kmAEhEiAKDGRpc3BsYXlfbmFtZRgEIAEoCUIKukgHcgUQARj/ARInCgV0b2tlbhgFIAEoCzIYLm1lc2h0cmFkZS50eXBlLnYxLlRva2VuQmcKJWNvLm1lc2h0cmFkZS5hcGkuc3R1ZGlvLmluc3RydW1lbnQudjFaPmdpdGh1Yi5jb20vbWVzaHRyYWRlL2FwaS9nby9zdHVkaW8vaW5zdHJ1bWVudC92MTtpbnN0cnVtZW50X3YxYgZwcm90bzM", [validate_pb_1.file_buf_validate_validate, token_pb_1.file_meshtrade_type_v1_token]);
|
|
14
14
|
/**
|
|
15
15
|
* Describes the message meshtrade.studio.instrument.v1.Instrument.
|
|
16
16
|
* Use `create(InstrumentSchema)` to create a new message.
|
|
@@ -35,13 +35,21 @@ export type LimitOrder = Message<"meshtrade.trading.limit_order.v1.LimitOrder">
|
|
|
35
35
|
* @generated from field: string owner = 2;
|
|
36
36
|
*/
|
|
37
37
|
owner: string;
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* Ownership hiearchy of groups that have access to this resource in the format groups/{group_id}.
|
|
41
|
+
* System set on creation.
|
|
42
|
+
*
|
|
43
|
+
* @generated from field: repeated string owners = 3;
|
|
44
|
+
*/
|
|
45
|
+
owners: string[];
|
|
38
46
|
/**
|
|
39
47
|
*
|
|
40
48
|
* The account associated with this limit order.
|
|
41
49
|
* Format: accounts/{ULIDv2}.
|
|
42
50
|
* This field is required on creation.
|
|
43
51
|
*
|
|
44
|
-
* @generated from field: string account =
|
|
52
|
+
* @generated from field: string account = 5;
|
|
45
53
|
*/
|
|
46
54
|
account: string;
|
|
47
55
|
/**
|
|
@@ -53,7 +61,7 @@ export type LimitOrder = Message<"meshtrade.trading.limit_order.v1.LimitOrder">
|
|
|
53
61
|
* this owner. The Mesh system enforces this constraint to ensure reliable
|
|
54
62
|
* lookups via GetLimitOrderByExternalReference.
|
|
55
63
|
*
|
|
56
|
-
* @generated from field: string external_reference =
|
|
64
|
+
* @generated from field: string external_reference = 6;
|
|
57
65
|
*/
|
|
58
66
|
externalReference: string;
|
|
59
67
|
/**
|
|
@@ -61,7 +69,7 @@ export type LimitOrder = Message<"meshtrade.trading.limit_order.v1.LimitOrder">
|
|
|
61
69
|
* Order side indicating buy or sell.
|
|
62
70
|
* This field is required on creation.
|
|
63
71
|
*
|
|
64
|
-
* @generated from field: meshtrade.trading.limit_order.v1.LimitOrderSide side =
|
|
72
|
+
* @generated from field: meshtrade.trading.limit_order.v1.LimitOrderSide side = 7;
|
|
65
73
|
*/
|
|
66
74
|
side: LimitOrderSide;
|
|
67
75
|
/**
|
|
@@ -69,7 +77,7 @@ export type LimitOrder = Message<"meshtrade.trading.limit_order.v1.LimitOrder">
|
|
|
69
77
|
* Limit price for the order.
|
|
70
78
|
* This field is required on creation.
|
|
71
79
|
*
|
|
72
|
-
* @generated from field: meshtrade.type.v1.Amount limit_price =
|
|
80
|
+
* @generated from field: meshtrade.type.v1.Amount limit_price = 8;
|
|
73
81
|
*/
|
|
74
82
|
limitPrice?: Amount;
|
|
75
83
|
/**
|
|
@@ -77,7 +85,7 @@ export type LimitOrder = Message<"meshtrade.trading.limit_order.v1.LimitOrder">
|
|
|
77
85
|
* Order quantity.
|
|
78
86
|
* This field is required on creation.
|
|
79
87
|
*
|
|
80
|
-
* @generated from field: meshtrade.type.v1.Amount quantity =
|
|
88
|
+
* @generated from field: meshtrade.type.v1.Amount quantity = 9;
|
|
81
89
|
*/
|
|
82
90
|
quantity?: Amount;
|
|
83
91
|
/**
|
|
@@ -89,7 +97,7 @@ export type LimitOrder = Message<"meshtrade.trading.limit_order.v1.LimitOrder">
|
|
|
89
97
|
*
|
|
90
98
|
* Only populated when live_ledger_data=true in request.
|
|
91
99
|
*
|
|
92
|
-
* @generated from field: meshtrade.type.v1.Amount fill_price =
|
|
100
|
+
* @generated from field: meshtrade.type.v1.Amount fill_price = 10;
|
|
93
101
|
*/
|
|
94
102
|
fillPrice?: Amount;
|
|
95
103
|
/**
|
|
@@ -101,7 +109,7 @@ export type LimitOrder = Message<"meshtrade.trading.limit_order.v1.LimitOrder">
|
|
|
101
109
|
*
|
|
102
110
|
* Only populated when live_ledger_data=true in request.
|
|
103
111
|
*
|
|
104
|
-
* @generated from field: meshtrade.type.v1.Amount filled_quantity =
|
|
112
|
+
* @generated from field: meshtrade.type.v1.Amount filled_quantity = 11;
|
|
105
113
|
*/
|
|
106
114
|
filledQuantity?: Amount;
|
|
107
115
|
/**
|
|
@@ -109,7 +117,7 @@ export type LimitOrder = Message<"meshtrade.trading.limit_order.v1.LimitOrder">
|
|
|
109
117
|
* Order status from live ledger data.
|
|
110
118
|
* Only populated when live_ledger_data=true in request.
|
|
111
119
|
*
|
|
112
|
-
* @generated from field: meshtrade.trading.limit_order.v1.LimitOrderStatus status =
|
|
120
|
+
* @generated from field: meshtrade.trading.limit_order.v1.LimitOrderStatus status = 12;
|
|
113
121
|
*/
|
|
114
122
|
status: LimitOrderStatus;
|
|
115
123
|
};
|
|
@@ -10,7 +10,7 @@ const amount_pb_1 = require("../../../type/v1/amount_pb");
|
|
|
10
10
|
/**
|
|
11
11
|
* Describes the file meshtrade/trading/limit_order/v1/limit_order.proto.
|
|
12
12
|
*/
|
|
13
|
-
exports.file_meshtrade_trading_limit_order_v1_limit_order = (0, codegenv2_1.fileDesc)("
|
|
13
|
+
exports.file_meshtrade_trading_limit_order_v1_limit_order = (0, codegenv2_1.fileDesc)("CjJtZXNodHJhZGUvdHJhZGluZy9saW1pdF9vcmRlci92MS9saW1pdF9vcmRlci5wcm90bxIgbWVzaHRyYWRlLnRyYWRpbmcubGltaXRfb3JkZXIudjEi2QYKCkxpbWl0T3JkZXISwgEKBG5hbWUYASABKAlCswG6SK8BugGrAQoUbmFtZS5mb3JtYXQub3B0aW9uYWwSOW5hbWUgbXVzdCBiZSBlbXB0eSBvciBpbiB0aGUgZm9ybWF0IGxpbWl0X29yZGVycy97VUxJRHYyfRpYc2l6ZSh0aGlzKSA9PSAwIHx8IHRoaXMubWF0Y2hlcygnXmxpbWl0X29yZGVycy9bMDEyMzQ1Njc4OUFCQ0RFRkdISktNTlBRUlNUVldYWVpdezI2fSQnKRJLCgVvd25lchgCIAEoCUI8ukg5yAEBcjQyL15ncm91cHMvWzAxMjM0NTY3ODlBQkNERUZHSEpLTU5QUVJTVFZXWFlaXXsyNn0kmAEhEk4KBm93bmVycxgDIAMoCUI+ukg7kgE4IjZyNDIvXmdyb3Vwcy9bMDEyMzQ1Njc4OUFCQ0RFRkdISktNTlBRUlNUVldYWVpdezI2fSSYASESTwoHYWNjb3VudBgFIAEoCUI+ukg7yAEBcjYyMV5hY2NvdW50cy9bMDEyMzQ1Njc4OUFCQ0RFRkdISktNTlBRUlNUVldYWVpdezI2fSSYASMSJAoSZXh0ZXJuYWxfcmVmZXJlbmNlGAYgASgJQgi6SAVyAxjIARJKCgRzaWRlGAcgASgOMjAubWVzaHRyYWRlLnRyYWRpbmcubGltaXRfb3JkZXIudjEuTGltaXRPcmRlclNpZGVCCrpIB4IBBBABIAASNgoLbGltaXRfcHJpY2UYCCABKAsyGS5tZXNodHJhZGUudHlwZS52MS5BbW91bnRCBrpIA8gBARIzCghxdWFudGl0eRgJIAEoCzIZLm1lc2h0cmFkZS50eXBlLnYxLkFtb3VudEIGukgDyAEBEi0KCmZpbGxfcHJpY2UYCiABKAsyGS5tZXNodHJhZGUudHlwZS52MS5BbW91bnQSMgoPZmlsbGVkX3F1YW50aXR5GAsgASgLMhkubWVzaHRyYWRlLnR5cGUudjEuQW1vdW50EkIKBnN0YXR1cxgMIAEoDjIyLm1lc2h0cmFkZS50cmFkaW5nLmxpbWl0X29yZGVyLnYxLkxpbWl0T3JkZXJTdGF0dXNKBAgEEAVSDGRpc3BsYXlfbmFtZSpnCg5MaW1pdE9yZGVyU2lkZRIgChxMSU1JVF9PUkRFUl9TSURFX1VOU1BFQ0lGSUVEEAASGAoUTElNSVRfT1JERVJfU0lERV9CVVkQARIZChVMSU1JVF9PUkRFUl9TSURFX1NFTEwQAirNAgoQTGltaXRPcmRlclN0YXR1cxIiCh5MSU1JVF9PUkRFUl9TVEFUVVNfVU5TUEVDSUZJRUQQABItCilMSU1JVF9PUkRFUl9TVEFUVVNfU1VCTUlTU0lPTl9JTl9QUk9HUkVTUxABEigKJExJTUlUX09SREVSX1NUQVRVU19TVUJNSVNTSU9OX0ZBSUxFRBACEhsKF0xJTUlUX09SREVSX1NUQVRVU19PUEVOEAMSKwonTElNSVRfT1JERVJfU1RBVFVTX0NPTVBMRVRFX0lOX1BST0dSRVNTEAQSHwobTElNSVRfT1JERVJfU1RBVFVTX0NPTVBMRVRFEAUSLworTElNSVRfT1JERVJfU1RBVFVTX0NBTkNFTExBVElPTl9JTl9QUk9HUkVTUxAGEiAKHExJTUlUX09SREVSX1NUQVRVU19DQU5DRUxMRUQQB0JsCidjby5tZXNodHJhZGUuYXBpLnRyYWRpbmcubGltaXRfb3JkZXIudjFaQWdpdGh1Yi5jb20vbWVzaHRyYWRlL2FwaS9nby90cmFkaW5nL2xpbWl0X29yZGVyL3YxO2xpbWl0X29yZGVyX3YxYgZwcm90bzM", [validate_pb_1.file_buf_validate_validate, amount_pb_1.file_meshtrade_type_v1_amount]);
|
|
14
14
|
/**
|
|
15
15
|
* Describes the message meshtrade.trading.limit_order.v1.LimitOrder.
|
|
16
16
|
* Use `create(LimitOrderSchema)` to create a new message.
|
|
@@ -1,59 +1,84 @@
|
|
|
1
|
-
import { Interceptor } from "@connectrpc/connect";
|
|
2
1
|
import { CancelLimitOrderRequest, CreateLimitOrderRequest, GetLimitOrderByExternalReferenceRequest, GetLimitOrderRequest, ListLimitOrdersRequest, ListLimitOrdersResponse, MonitorLimitOrderRequest, SearchLimitOrdersRequest, SearchLimitOrdersResponse } from "./service_pb";
|
|
3
2
|
import { LimitOrder } from "./limit_order_pb";
|
|
4
|
-
import {
|
|
3
|
+
import { ClientOption } from "../../../config";
|
|
5
4
|
/**
|
|
6
5
|
* Node.js client for interacting with the meshtrade.trading.limit_order.v1 limit order v1 API resource service.
|
|
7
6
|
* Uses Connect-ES with gRPC transport for Node.js gRPC communication.
|
|
8
7
|
*
|
|
9
|
-
* Supports
|
|
8
|
+
* Supports flexible authentication modes using functional options pattern:
|
|
10
9
|
*
|
|
11
10
|
* 1. **No Authentication** (public APIs):
|
|
12
11
|
* ```typescript
|
|
13
|
-
* const client = new LimitOrderServiceNode(
|
|
12
|
+
* const client = new LimitOrderServiceNode(
|
|
13
|
+
* WithServerUrl("http://localhost:10000")
|
|
14
|
+
* );
|
|
14
15
|
* ```
|
|
15
16
|
*
|
|
16
17
|
* 2. **API Key Authentication** (backend services):
|
|
17
18
|
* ```typescript
|
|
18
|
-
* const client = new LimitOrderServiceNode(
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* const client = new LimitOrderServiceNode(
|
|
20
|
+
* WithAPIKey("your-api-key"),
|
|
21
|
+
* WithGroup("groups/01ARZ3NDEKTSV4YWVF8F5BH32"),
|
|
22
|
+
* WithServerUrl("https://api.example.com")
|
|
23
|
+
* );
|
|
23
24
|
* ```
|
|
24
25
|
*
|
|
25
26
|
* 3. **JWT Token Authentication** (Next.js backend with user session):
|
|
26
27
|
* ```typescript
|
|
27
|
-
* const client = new LimitOrderServiceNode(
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
28
|
+
* const client = new LimitOrderServiceNode(
|
|
29
|
+
* WithJWTAccessToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."),
|
|
30
|
+
* WithServerUrl("https://api.example.com")
|
|
31
|
+
* );
|
|
31
32
|
* ```
|
|
33
|
+
*
|
|
34
|
+
* 4. **JWT with Group Context** (user session with specific group):
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const client = new LimitOrderServiceNode(
|
|
37
|
+
* WithJWTAccessToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."),
|
|
38
|
+
* WithGroup("groups/01ARZ3NDEKTSV4YWVF8F5BH32"),
|
|
39
|
+
* WithServerUrl("https://api.example.com")
|
|
40
|
+
* );
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* Available options:
|
|
44
|
+
* - `WithAPIKey(key)` - API key authentication (mutually exclusive with JWT)
|
|
45
|
+
* - `WithJWTAccessToken(token)` - JWT authentication (mutually exclusive with API key)
|
|
46
|
+
* - `WithGroup(group)` - Group context (optional, works with both auth modes)
|
|
47
|
+
* - `WithServerUrl(url)` - Custom server URL (optional, defaults to production)
|
|
32
48
|
*/
|
|
33
49
|
export declare class LimitOrderServiceNode {
|
|
34
50
|
private _client;
|
|
35
51
|
private readonly _config;
|
|
36
52
|
private readonly _interceptors;
|
|
53
|
+
private readonly _validator;
|
|
37
54
|
/**
|
|
38
55
|
* Constructs an instance of LimitOrderServiceNode.
|
|
39
|
-
*
|
|
40
|
-
*
|
|
56
|
+
*
|
|
57
|
+
* Uses functional options pattern for flexible configuration:
|
|
58
|
+
* - `WithAPIKey(key)` - API key authentication
|
|
59
|
+
* - `WithJWTAccessToken(token)` - JWT authentication
|
|
60
|
+
* - `WithGroup(group)` - Group context (optional)
|
|
61
|
+
* - `WithServerUrl(url)` - Custom server URL (optional)
|
|
62
|
+
*
|
|
63
|
+
* @param {...ClientOption} opts - Variable number of configuration options
|
|
41
64
|
*/
|
|
42
|
-
constructor(
|
|
65
|
+
constructor(...opts: ClientOption[]);
|
|
43
66
|
/**
|
|
44
67
|
* Returns a new client instance configured to send the specified group
|
|
45
68
|
* resource name in the request headers for subsequent API calls.
|
|
46
69
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
70
|
+
* This method creates a new client with the same authentication configuration
|
|
71
|
+
* but with the group context updated to the specified value.
|
|
72
|
+
*
|
|
73
|
+
* **Compatibility**: Works with all authentication modes:
|
|
74
|
+
* - **API key auth**: Creates new client with API key + new group
|
|
75
|
+
* - **JWT auth**: Creates new client with JWT + new group
|
|
76
|
+
* - **No auth**: Creates new client with standalone group interceptor
|
|
51
77
|
*
|
|
52
78
|
* @param {string} group - The operating group context to inject into the request
|
|
53
79
|
* in the format `groups/{ulid}` where {ulid} is a 26-character ULID.
|
|
54
80
|
* Example: 'groups/01ARZ3NDEKTSV4YWVF8F5BH32'
|
|
55
81
|
* @returns {LimitOrderServiceNode} A new, configured instance of the client.
|
|
56
|
-
* @throws {Error} If used with JWT authentication or no authentication
|
|
57
82
|
* @throws {Error} If the group format is invalid
|
|
58
83
|
*/
|
|
59
84
|
withGroup(group: string): LimitOrderServiceNode;
|