@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
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for Meshtrade API clients using functional options pattern.
|
|
4
|
+
*
|
|
5
|
+
* Supports flexible authentication modes with optional group context:
|
|
6
|
+
*
|
|
7
|
+
* 1. **No Authentication** (public APIs):
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const client = new ServiceNode(
|
|
10
|
+
* WithServerUrl("http://localhost:10000")
|
|
11
|
+
* );
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* 2. **API Key Authentication** (backend services):
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const client = new ServiceNode(
|
|
17
|
+
* WithAPIKey("your-api-key"),
|
|
18
|
+
* WithGroup("groups/01ARZ3NDEKTSV4YWVF8F5BH32"),
|
|
19
|
+
* WithServerUrl("https://api.example.com")
|
|
20
|
+
* );
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* 3. **JWT Token Authentication** (Next.js backend with user session):
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const client = new ServiceNode(
|
|
26
|
+
* WithJWTAccessToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."),
|
|
27
|
+
* WithServerUrl("https://api.example.com")
|
|
28
|
+
* );
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* 4. **JWT with Group Context** (user session with specific group):
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const client = new ServiceNode(
|
|
34
|
+
* WithJWTAccessToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."),
|
|
35
|
+
* WithGroup("groups/01ARZ3NDEKTSV4YWVF8F5BH32"),
|
|
36
|
+
* WithServerUrl("https://api.example.com")
|
|
37
|
+
* );
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.ClientConfig = void 0;
|
|
42
|
+
exports.WithAPIKey = WithAPIKey;
|
|
43
|
+
exports.WithJWTAccessToken = WithJWTAccessToken;
|
|
44
|
+
exports.WithGroup = WithGroup;
|
|
45
|
+
exports.WithServerUrl = WithServerUrl;
|
|
46
|
+
exports.buildConfigFromOptions = buildConfigFromOptions;
|
|
47
|
+
/**
|
|
48
|
+
* Internal configuration class used to build client configuration.
|
|
49
|
+
*/
|
|
50
|
+
class ClientConfig {
|
|
51
|
+
constructor() {
|
|
52
|
+
/** API server URL (default: production) */
|
|
53
|
+
this.apiServerURL = "http://localhost:10000";
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Validates the configuration.
|
|
57
|
+
* @throws {Error} If both API key and JWT token are provided (mutually exclusive)
|
|
58
|
+
*/
|
|
59
|
+
validate() {
|
|
60
|
+
if (this.apiKey && this.jwtToken) {
|
|
61
|
+
throw new Error("API key and JWT token authentication are mutually exclusive. " +
|
|
62
|
+
"Please use WithAPIKey() OR WithJWTAccessToken(), not both.");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.ClientConfig = ClientConfig;
|
|
67
|
+
/**
|
|
68
|
+
* Configures the client with an API key for service-to-service authentication.
|
|
69
|
+
*
|
|
70
|
+
* **Mutually Exclusive**: Cannot be used with WithJWTAccessToken().
|
|
71
|
+
* **Optional**: Can be combined with WithGroup() for group-specific operations.
|
|
72
|
+
*
|
|
73
|
+
* @param apiKey - The API key for authentication
|
|
74
|
+
* @returns A client option function
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const client = new ServiceNode(
|
|
79
|
+
* WithAPIKey("your-api-key"),
|
|
80
|
+
* WithGroup("groups/01ARZ3NDEKTSV4YWVF8F5BH32")
|
|
81
|
+
* );
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
function WithAPIKey(apiKey) {
|
|
85
|
+
return (config) => {
|
|
86
|
+
if (!apiKey || apiKey.trim() === "") {
|
|
87
|
+
throw new Error("API key cannot be empty");
|
|
88
|
+
}
|
|
89
|
+
if (config.jwtToken) {
|
|
90
|
+
throw new Error("Cannot use both WithAPIKey() and WithJWTAccessToken(). " +
|
|
91
|
+
"Please choose one authentication method.");
|
|
92
|
+
}
|
|
93
|
+
config.apiKey = apiKey;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Configures the client with a JWT access token for user session authentication.
|
|
98
|
+
*
|
|
99
|
+
* **Mutually Exclusive**: Cannot be used with WithAPIKey().
|
|
100
|
+
* **Optional**: Can be combined with WithGroup() for group-specific operations.
|
|
101
|
+
*
|
|
102
|
+
* The JWT is injected as a cookie header (Cookie: AccessToken=<jwt>)
|
|
103
|
+
* so the server can extract it from the request.
|
|
104
|
+
*
|
|
105
|
+
* @param token - The JWT access token from the user's session
|
|
106
|
+
* @returns A client option function
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const client = new ServiceNode(
|
|
111
|
+
* WithJWTAccessToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."),
|
|
112
|
+
* WithGroup("groups/01ARZ3NDEKTSV4YWVF8F5BH32")
|
|
113
|
+
* );
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
function WithJWTAccessToken(token) {
|
|
117
|
+
return (config) => {
|
|
118
|
+
if (!token || token.trim() === "") {
|
|
119
|
+
throw new Error("JWT token cannot be empty");
|
|
120
|
+
}
|
|
121
|
+
if (config.apiKey) {
|
|
122
|
+
throw new Error("Cannot use both WithJWTAccessToken() and WithAPIKey(). " +
|
|
123
|
+
"Please choose one authentication method.");
|
|
124
|
+
}
|
|
125
|
+
config.jwtToken = token;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Configures the client with a group context for operations.
|
|
130
|
+
*
|
|
131
|
+
* **Optional**: Can be used with WithAPIKey() or WithJWTAccessToken().
|
|
132
|
+
* When used alone without authentication, adds group header to requests.
|
|
133
|
+
*
|
|
134
|
+
* @param group - The group resource name in format "groups/{ulid}"
|
|
135
|
+
* @returns A client option function
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* // With API Key
|
|
140
|
+
* const client = new ServiceNode(
|
|
141
|
+
* WithAPIKey("your-api-key"),
|
|
142
|
+
* WithGroup("groups/01ARZ3NDEKTSV4YWVF8F5BH32")
|
|
143
|
+
* );
|
|
144
|
+
*
|
|
145
|
+
* // With JWT
|
|
146
|
+
* const client = new ServiceNode(
|
|
147
|
+
* WithJWTAccessToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."),
|
|
148
|
+
* WithGroup("groups/01ARZ3NDEKTSV4YWVF8F5BH32")
|
|
149
|
+
* );
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
function WithGroup(group) {
|
|
153
|
+
return (config) => {
|
|
154
|
+
if (!group || group.trim() === "") {
|
|
155
|
+
throw new Error("Group cannot be empty");
|
|
156
|
+
}
|
|
157
|
+
config.group = group;
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Configures the client with a custom server URL.
|
|
162
|
+
*
|
|
163
|
+
* **Optional**: If not provided, defaults to localhost:10000.
|
|
164
|
+
*
|
|
165
|
+
* @param url - The API server URL
|
|
166
|
+
* @returns A client option function
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* const client = new ServiceNode(
|
|
171
|
+
* WithServerUrl("http://localhost:10000"),
|
|
172
|
+
* WithAPIKey("your-api-key"),
|
|
173
|
+
* WithGroup("groups/01ARZ3NDEKTSV4YWVF8F5BH32")
|
|
174
|
+
* );
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
function WithServerUrl(url) {
|
|
178
|
+
return (config) => {
|
|
179
|
+
if (!url || url.trim() === "") {
|
|
180
|
+
throw new Error("Server URL cannot be empty");
|
|
181
|
+
}
|
|
182
|
+
config.apiServerURL = url;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Builds client configuration from an array of option functions.
|
|
187
|
+
*
|
|
188
|
+
* @param opts - Variable number of option functions
|
|
189
|
+
* @returns A validated ClientConfig instance
|
|
190
|
+
* @throws {Error} If configuration is invalid (e.g., both API key and JWT provided)
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```typescript
|
|
194
|
+
* const config = buildConfigFromOptions(
|
|
195
|
+
* WithAPIKey("your-api-key"),
|
|
196
|
+
* WithGroup("groups/01ARZ3NDEKTSV4YWVF8F5BH32"),
|
|
197
|
+
* WithServerUrl("https://api.example.com")
|
|
198
|
+
* );
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
function buildConfigFromOptions(...opts) {
|
|
202
|
+
const config = new ClientConfig();
|
|
203
|
+
// Apply each option
|
|
204
|
+
for (const opt of opts) {
|
|
205
|
+
opt(config);
|
|
206
|
+
}
|
|
207
|
+
// Validate the final configuration
|
|
208
|
+
config.validate();
|
|
209
|
+
return config;
|
|
210
|
+
}
|
|
@@ -34,12 +34,20 @@ export type APIUser = Message<"meshtrade.iam.api_user.v1.APIUser"> & {
|
|
|
34
34
|
* @generated from field: string owner = 2;
|
|
35
35
|
*/
|
|
36
36
|
owner: string;
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* Ownership hiearchy of groups that have access to this resource in the format groups/{group_id}.
|
|
40
|
+
* System set on creation.
|
|
41
|
+
*
|
|
42
|
+
* @generated from field: repeated string owners = 3;
|
|
43
|
+
*/
|
|
44
|
+
owners: string[];
|
|
37
45
|
/**
|
|
38
46
|
*
|
|
39
47
|
* A non-unique, user-provided name for the API user, used for display purposes.
|
|
40
48
|
* Required on creation.
|
|
41
49
|
*
|
|
42
|
-
* @generated from field: string display_name =
|
|
50
|
+
* @generated from field: string display_name = 4;
|
|
43
51
|
*/
|
|
44
52
|
displayName: string;
|
|
45
53
|
/**
|
|
@@ -47,7 +55,7 @@ export type APIUser = Message<"meshtrade.iam.api_user.v1.APIUser"> & {
|
|
|
47
55
|
* The current state of the API user (active or inactive).
|
|
48
56
|
* System set on creation to default value of inactive.
|
|
49
57
|
*
|
|
50
|
-
* @generated from field: meshtrade.iam.api_user.v1.APIUserState state =
|
|
58
|
+
* @generated from field: meshtrade.iam.api_user.v1.APIUserState state = 5;
|
|
51
59
|
*/
|
|
52
60
|
state: APIUserState;
|
|
53
61
|
/**
|
|
@@ -56,7 +64,7 @@ export type APIUser = Message<"meshtrade.iam.api_user.v1.APIUser"> & {
|
|
|
56
64
|
* prepended by the name of the group in which they have been assigned that role.
|
|
57
65
|
* e.g. groups/{ULIDv2}/roles/{role}, where role is a value of the meshtrade.iam.role.v1.Role enum.
|
|
58
66
|
*
|
|
59
|
-
* @generated from field: repeated string roles =
|
|
67
|
+
* @generated from field: repeated string roles = 6;
|
|
60
68
|
*/
|
|
61
69
|
roles: string[];
|
|
62
70
|
/**
|
|
@@ -65,7 +73,7 @@ export type APIUser = Message<"meshtrade.iam.api_user.v1.APIUser"> & {
|
|
|
65
73
|
* This field is only populated on the entity the first time it is returned after creation - it is NOT stored.
|
|
66
74
|
* Populated once by system on creation.
|
|
67
75
|
*
|
|
68
|
-
* @generated from field: string api_key =
|
|
76
|
+
* @generated from field: string api_key = 7;
|
|
69
77
|
*/
|
|
70
78
|
apiKey: string;
|
|
71
79
|
};
|
|
@@ -9,7 +9,7 @@ const validate_pb_1 = require("../../../../buf/validate/validate_pb");
|
|
|
9
9
|
/**
|
|
10
10
|
* Describes the file meshtrade/iam/api_user/v1/api_user.proto.
|
|
11
11
|
*/
|
|
12
|
-
exports.file_meshtrade_iam_api_user_v1_api_user = (0, codegenv2_1.fileDesc)("
|
|
12
|
+
exports.file_meshtrade_iam_api_user_v1_api_user = (0, codegenv2_1.fileDesc)("CihtZXNodHJhZGUvaWFtL2FwaV91c2VyL3YxL2FwaV91c2VyLnByb3RvEhltZXNodHJhZGUuaWFtLmFwaV91c2VyLnYxIsAGCgdBUElVc2VyErwBCgRuYW1lGAEgASgJQq0BukipAboBpQEKFG5hbWUuZm9ybWF0Lm9wdGlvbmFsEjZuYW1lIG11c3QgYmUgZW1wdHkgb3IgaW4gdGhlIGZvcm1hdCBhcGlfdXNlcnMve1VMSUR2Mn0aVXNpemUodGhpcykgPT0gMCB8fCB0aGlzLm1hdGNoZXMoJ15hcGlfdXNlcnMvWzAxMjM0NTY3ODlBQkNERUZHSEpLTU5QUVJTVFZXWFlaXXsyNn0kJykSSwoFb3duZXIYAiABKAlCPLpIOcgBAXI0Mi9eZ3JvdXBzL1swMTIzNDU2Nzg5QUJDREVGR0hKS01OUFFSU1RWV1hZWl17MjZ9JJgBIRJOCgZvd25lcnMYAyADKAlCPrpIO5IBOCI2cjQyL15ncm91cHMvWzAxMjM0NTY3ODlBQkNERUZHSEpLTU5QUVJTVFZXWFlaXXsyNn0kmAEhEqcBCgxkaXNwbGF5X25hbWUYBCABKAlCkAG6SIwBugF/ChVkaXNwbGF5X25hbWUucmVxdWlyZWQSQWRpc3BsYXkgbmFtZSBpcyByZXF1aXJlZCBhbmQgbXVzdCBiZSBiZXR3ZWVuIDEgYW5kIDI1NSBjaGFyYWN0ZXJzGiNzaXplKHRoaXMpID4gMCAmJiBzaXplKHRoaXMpIDw9IDI1NcgBAXIFEAEY/wEStwEKBXN0YXRlGAUgASgOMicubWVzaHRyYWRlLmlhbS5hcGlfdXNlci52MS5BUElVc2VyU3RhdGVCf7pIfLoBdAoLc3RhdGUudmFsaWQSL3N0YXRlIG11c3QgYmUgYSB2YWxpZCBBUElVc2VyU3RhdGUgaWYgc3BlY2lmaWVkGjRpbnQodGhpcykgPT0gMCB8fCAoaW50KHRoaXMpID49IDEgJiYgaW50KHRoaXMpIDw9IDIpggECEAESZAoFcm9sZXMYBiADKAlCVbpIUpIBTyJNcksQLxgwMkVeZ3JvdXBzL1swMTIzNDU2Nzg5QUJDREVGR0hKS01OUFFSU1RWV1hZWl17MjZ9L3JvbGVzL1sxLTldWzAtOV17Niw3fSQSDwoHYXBpX2tleRgHIAEoCSpmCgxBUElVc2VyU3RhdGUSHgoaQVBJX1VTRVJfU1RBVEVfVU5TUEVDSUZJRUQQABIZChVBUElfVVNFUl9TVEFURV9BQ1RJVkUQARIbChdBUElfVVNFUl9TVEFURV9JTkFDVElWRRACKqYBCg1BUElVc2VyQWN0aW9uEh8KG0FQSV9VU0VSX0FDVElPTl9VTlNQRUNJRklFRBAAEhwKGEFQSV9VU0VSX0FDVElPTl9BQ1RJVkFURRABEh4KGkFQSV9VU0VSX0FDVElPTl9ERUFDVElWQVRFEAISGgoWQVBJX1VTRVJfQUNUSU9OX0NSRUFURRADEhoKFkFQSV9VU0VSX0FDVElPTl9VUERBVEUQBEJuCiBjby5tZXNodHJhZGUuYXBpLmlhbS5hcGlfdXNlci52MUIRQXBpVXNlck91dGVyQ2xhc3NaN2dpdGh1Yi5jb20vbWVzaHRyYWRlL2FwaS9nby9pYW0vYXBpX3VzZXIvdjE7YXBpX3VzZXJfdjFiBnByb3RvMw", [validate_pb_1.file_buf_validate_validate]);
|
|
13
13
|
/**
|
|
14
14
|
* Describes the message meshtrade.iam.api_user.v1.APIUser.
|
|
15
15
|
* Use `create(APIUserSchema)` to create a new message.
|
|
@@ -1,59 +1,84 @@
|
|
|
1
|
-
import { Interceptor } from "@connectrpc/connect";
|
|
2
1
|
import { ActivateAPIUserRequest, AssignRolesToAPIUserRequest, CreateAPIUserRequest, DeactivateAPIUserRequest, GetAPIUserByKeyHashRequest, GetAPIUserRequest, ListAPIUsersRequest, ListAPIUsersResponse, RevokeRolesFromAPIUserRequest, SearchAPIUsersRequest, SearchAPIUsersResponse } from "./service_pb";
|
|
3
2
|
import { APIUser } from "./api_user_pb";
|
|
4
|
-
import {
|
|
3
|
+
import { ClientOption } from "../../../config";
|
|
5
4
|
/**
|
|
6
5
|
* Node.js client for interacting with the meshtrade.iam.api_user.v1 apiuser 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 APIUserServiceNode(
|
|
12
|
+
* const client = new APIUserServiceNode(
|
|
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 APIUserServiceNode(
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* const client = new APIUserServiceNode(
|
|
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 APIUserServiceNode(
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
28
|
+
* const client = new APIUserServiceNode(
|
|
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 APIUserServiceNode(
|
|
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 APIUserServiceNode {
|
|
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 APIUserServiceNode.
|
|
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 {APIUserServiceNode} 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): APIUserServiceNode;
|