@rivascva/dt-idl 1.1.70 → 1.1.72
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/index.d.ts +26 -45
- package/go/utils/context.go +22 -0
- package/package.json +1 -1
- package/services/dt-trade-service.yaml +22 -32
- package/ts/services/dt-trade-service.ts +26 -45
package/dist/index.d.ts
CHANGED
|
@@ -692,7 +692,8 @@ interface paths$2 {
|
|
|
692
692
|
path?: never;
|
|
693
693
|
cookie?: never;
|
|
694
694
|
};
|
|
695
|
-
|
|
695
|
+
/** @description Gets all portfolios */
|
|
696
|
+
get: operations$2["getPortfolios"];
|
|
696
697
|
put?: never;
|
|
697
698
|
/** @description Adds a new portfolio */
|
|
698
699
|
post: operations$2["addPortfolio"];
|
|
@@ -719,23 +720,6 @@ interface paths$2 {
|
|
|
719
720
|
patch?: never;
|
|
720
721
|
trace?: never;
|
|
721
722
|
};
|
|
722
|
-
"/portfolios/by-user/{userId}": {
|
|
723
|
-
parameters: {
|
|
724
|
-
query?: never;
|
|
725
|
-
header?: never;
|
|
726
|
-
path?: never;
|
|
727
|
-
cookie?: never;
|
|
728
|
-
};
|
|
729
|
-
/** @description Gets the portfolios for the given user */
|
|
730
|
-
get: operations$2["getPortfoliosByUser"];
|
|
731
|
-
put?: never;
|
|
732
|
-
post?: never;
|
|
733
|
-
delete?: never;
|
|
734
|
-
options?: never;
|
|
735
|
-
head?: never;
|
|
736
|
-
patch?: never;
|
|
737
|
-
trace?: never;
|
|
738
|
-
};
|
|
739
723
|
"/orders": {
|
|
740
724
|
parameters: {
|
|
741
725
|
query?: never;
|
|
@@ -775,8 +759,6 @@ interface components$2 {
|
|
|
775
759
|
schemas: {
|
|
776
760
|
/** @description Payload to add a new portfolio */
|
|
777
761
|
AddPortfolioPayload: {
|
|
778
|
-
/** @example 123456 */
|
|
779
|
-
userId: string;
|
|
780
762
|
/** @example PERSONAL */
|
|
781
763
|
type: components$2["schemas"]["PortfolioType"];
|
|
782
764
|
/**
|
|
@@ -791,6 +773,8 @@ interface components$2 {
|
|
|
791
773
|
Portfolio: components$2["schemas"]["AddPortfolioPayload"] & {
|
|
792
774
|
/** @example 123456 */
|
|
793
775
|
id: string;
|
|
776
|
+
/** @example 123456 */
|
|
777
|
+
userId: string;
|
|
794
778
|
holdings: components$2["schemas"]["Holding"][];
|
|
795
779
|
orders: components$2["schemas"]["Order"][];
|
|
796
780
|
/**
|
|
@@ -936,53 +920,44 @@ interface components$2 {
|
|
|
936
920
|
pathItems: never;
|
|
937
921
|
}
|
|
938
922
|
interface operations$2 {
|
|
939
|
-
|
|
923
|
+
getPortfolios: {
|
|
940
924
|
parameters: {
|
|
941
925
|
query?: never;
|
|
942
926
|
header?: never;
|
|
943
927
|
path?: never;
|
|
944
928
|
cookie?: never;
|
|
945
929
|
};
|
|
946
|
-
|
|
947
|
-
requestBody: {
|
|
948
|
-
content: {
|
|
949
|
-
"application/json": components$2["schemas"]["AddPortfolioPayload"];
|
|
950
|
-
};
|
|
951
|
-
};
|
|
930
|
+
requestBody?: never;
|
|
952
931
|
responses: {
|
|
953
|
-
/** @description
|
|
954
|
-
|
|
932
|
+
/** @description Success */
|
|
933
|
+
200: {
|
|
955
934
|
headers: {
|
|
956
935
|
[name: string]: unknown;
|
|
957
936
|
};
|
|
958
937
|
content: {
|
|
959
|
-
"application/json": components$2["schemas"]["Portfolio"];
|
|
938
|
+
"application/json": components$2["schemas"]["Portfolio"][];
|
|
960
939
|
};
|
|
961
940
|
};
|
|
962
|
-
400: components$2["responses"]["BadRequest"];
|
|
963
941
|
404: components$2["responses"]["NotFound"];
|
|
964
942
|
500: components$2["responses"]["InternalServerError"];
|
|
965
943
|
};
|
|
966
944
|
};
|
|
967
|
-
|
|
945
|
+
addPortfolio: {
|
|
968
946
|
parameters: {
|
|
969
947
|
query?: never;
|
|
970
948
|
header?: never;
|
|
971
|
-
path
|
|
972
|
-
/** @description The portfolio id */
|
|
973
|
-
portfolioId: string;
|
|
974
|
-
};
|
|
949
|
+
path?: never;
|
|
975
950
|
cookie?: never;
|
|
976
951
|
};
|
|
977
|
-
/** @description The request body to
|
|
952
|
+
/** @description The request body to add a portfolio */
|
|
978
953
|
requestBody: {
|
|
979
954
|
content: {
|
|
980
|
-
"application/json": components$2["schemas"]["
|
|
955
|
+
"application/json": components$2["schemas"]["AddPortfolioPayload"];
|
|
981
956
|
};
|
|
982
957
|
};
|
|
983
958
|
responses: {
|
|
984
|
-
/** @description
|
|
985
|
-
|
|
959
|
+
/** @description Added */
|
|
960
|
+
201: {
|
|
986
961
|
headers: {
|
|
987
962
|
[name: string]: unknown;
|
|
988
963
|
};
|
|
@@ -995,17 +970,22 @@ interface operations$2 {
|
|
|
995
970
|
500: components$2["responses"]["InternalServerError"];
|
|
996
971
|
};
|
|
997
972
|
};
|
|
998
|
-
|
|
973
|
+
updatePortfolio: {
|
|
999
974
|
parameters: {
|
|
1000
975
|
query?: never;
|
|
1001
976
|
header?: never;
|
|
1002
977
|
path: {
|
|
1003
|
-
/** @description The
|
|
1004
|
-
|
|
978
|
+
/** @description The portfolio id */
|
|
979
|
+
portfolioId: string;
|
|
1005
980
|
};
|
|
1006
981
|
cookie?: never;
|
|
1007
982
|
};
|
|
1008
|
-
|
|
983
|
+
/** @description The request body to update a portfolio */
|
|
984
|
+
requestBody: {
|
|
985
|
+
content: {
|
|
986
|
+
"application/json": components$2["schemas"]["UpdatePortfolioPayload"];
|
|
987
|
+
};
|
|
988
|
+
};
|
|
1009
989
|
responses: {
|
|
1010
990
|
/** @description Success */
|
|
1011
991
|
200: {
|
|
@@ -1013,9 +993,10 @@ interface operations$2 {
|
|
|
1013
993
|
[name: string]: unknown;
|
|
1014
994
|
};
|
|
1015
995
|
content: {
|
|
1016
|
-
"application/json": components$2["schemas"]["Portfolio"]
|
|
996
|
+
"application/json": components$2["schemas"]["Portfolio"];
|
|
1017
997
|
};
|
|
1018
998
|
};
|
|
999
|
+
400: components$2["responses"]["BadRequest"];
|
|
1019
1000
|
404: components$2["responses"]["NotFound"];
|
|
1020
1001
|
500: components$2["responses"]["InternalServerError"];
|
|
1021
1002
|
};
|
package/go/utils/context.go
CHANGED
|
@@ -2,6 +2,8 @@ package utils
|
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"context"
|
|
5
|
+
"errors"
|
|
6
|
+
"fmt"
|
|
5
7
|
|
|
6
8
|
"github.com/RivasCVA/dt-idl/go/models"
|
|
7
9
|
"github.com/golang-jwt/jwt/v5"
|
|
@@ -15,3 +17,23 @@ func GetTokenFromContext(ctx context.Context) *jwt.Token {
|
|
|
15
17
|
}
|
|
16
18
|
return token
|
|
17
19
|
}
|
|
20
|
+
|
|
21
|
+
// GetUserIdFromContext retrieves the user id from the JTW token in the given context.
|
|
22
|
+
func GetUserIdFromContext(ctx context.Context) (string, error) {
|
|
23
|
+
// get the token from the context
|
|
24
|
+
token := GetTokenFromContext(ctx)
|
|
25
|
+
if token == nil {
|
|
26
|
+
return "", errors.New("token not found in the context")
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// get the subject (userId) from the token
|
|
30
|
+
userId, err := token.Claims.GetSubject()
|
|
31
|
+
if err != nil {
|
|
32
|
+
return "", fmt.Errorf("failed to get the subject from the token: %w", err)
|
|
33
|
+
}
|
|
34
|
+
if userId == "" {
|
|
35
|
+
return "", errors.New("user id not found in the token subject")
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return userId, nil
|
|
39
|
+
}
|
package/package.json
CHANGED
|
@@ -10,6 +10,24 @@ servers:
|
|
|
10
10
|
|
|
11
11
|
paths:
|
|
12
12
|
/portfolios:
|
|
13
|
+
get:
|
|
14
|
+
description: Gets all portfolios
|
|
15
|
+
operationId: getPortfolios
|
|
16
|
+
tags:
|
|
17
|
+
- Portfolios
|
|
18
|
+
responses:
|
|
19
|
+
200:
|
|
20
|
+
description: Success
|
|
21
|
+
content:
|
|
22
|
+
application/json:
|
|
23
|
+
schema:
|
|
24
|
+
type: array
|
|
25
|
+
items:
|
|
26
|
+
$ref: '#/components/schemas/Portfolio'
|
|
27
|
+
404:
|
|
28
|
+
$ref: '#/components/responses/NotFound'
|
|
29
|
+
500:
|
|
30
|
+
$ref: '#/components/responses/InternalServerError'
|
|
13
31
|
post:
|
|
14
32
|
description: Adds a new portfolio
|
|
15
33
|
operationId: addPortfolio
|
|
@@ -71,34 +89,6 @@ paths:
|
|
|
71
89
|
500:
|
|
72
90
|
$ref: '#/components/responses/InternalServerError'
|
|
73
91
|
|
|
74
|
-
/portfolios/by-user/{userId}:
|
|
75
|
-
get:
|
|
76
|
-
description: Gets the portfolios for the given user
|
|
77
|
-
operationId: getPortfoliosByUser
|
|
78
|
-
tags:
|
|
79
|
-
- Portfolios
|
|
80
|
-
parameters:
|
|
81
|
-
- in: path
|
|
82
|
-
name: userId
|
|
83
|
-
description: The user id
|
|
84
|
-
required: true
|
|
85
|
-
schema:
|
|
86
|
-
type: string
|
|
87
|
-
example: 123456
|
|
88
|
-
responses:
|
|
89
|
-
200:
|
|
90
|
-
description: Success
|
|
91
|
-
content:
|
|
92
|
-
application/json:
|
|
93
|
-
schema:
|
|
94
|
-
type: array
|
|
95
|
-
items:
|
|
96
|
-
$ref: '#/components/schemas/Portfolio'
|
|
97
|
-
404:
|
|
98
|
-
$ref: '#/components/responses/NotFound'
|
|
99
|
-
500:
|
|
100
|
-
$ref: '#/components/responses/InternalServerError'
|
|
101
|
-
|
|
102
92
|
/orders:
|
|
103
93
|
post:
|
|
104
94
|
description: Adds a new order
|
|
@@ -155,9 +145,6 @@ components:
|
|
|
155
145
|
AddPortfolioPayload:
|
|
156
146
|
description: Payload to add a new portfolio
|
|
157
147
|
properties:
|
|
158
|
-
userId:
|
|
159
|
-
type: string
|
|
160
|
-
example: 123456
|
|
161
148
|
type:
|
|
162
149
|
$ref: '#/components/schemas/PortfolioType'
|
|
163
150
|
example: PERSONAL
|
|
@@ -166,7 +153,6 @@ components:
|
|
|
166
153
|
format: double
|
|
167
154
|
example: 10500.25
|
|
168
155
|
required:
|
|
169
|
-
- userId
|
|
170
156
|
- type
|
|
171
157
|
- cash
|
|
172
158
|
|
|
@@ -184,6 +170,9 @@ components:
|
|
|
184
170
|
id:
|
|
185
171
|
type: string
|
|
186
172
|
example: 123456
|
|
173
|
+
userId:
|
|
174
|
+
type: string
|
|
175
|
+
example: 123456
|
|
187
176
|
holdings:
|
|
188
177
|
type: array
|
|
189
178
|
items:
|
|
@@ -202,6 +191,7 @@ components:
|
|
|
202
191
|
example: 1713398544000
|
|
203
192
|
required:
|
|
204
193
|
- id
|
|
194
|
+
- userId
|
|
205
195
|
- holdings
|
|
206
196
|
- orders
|
|
207
197
|
- dateCreated
|
|
@@ -11,7 +11,8 @@ export interface paths {
|
|
|
11
11
|
path?: never;
|
|
12
12
|
cookie?: never;
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
/** @description Gets all portfolios */
|
|
15
|
+
get: operations["getPortfolios"];
|
|
15
16
|
put?: never;
|
|
16
17
|
/** @description Adds a new portfolio */
|
|
17
18
|
post: operations["addPortfolio"];
|
|
@@ -38,23 +39,6 @@ export interface paths {
|
|
|
38
39
|
patch?: never;
|
|
39
40
|
trace?: never;
|
|
40
41
|
};
|
|
41
|
-
"/portfolios/by-user/{userId}": {
|
|
42
|
-
parameters: {
|
|
43
|
-
query?: never;
|
|
44
|
-
header?: never;
|
|
45
|
-
path?: never;
|
|
46
|
-
cookie?: never;
|
|
47
|
-
};
|
|
48
|
-
/** @description Gets the portfolios for the given user */
|
|
49
|
-
get: operations["getPortfoliosByUser"];
|
|
50
|
-
put?: never;
|
|
51
|
-
post?: never;
|
|
52
|
-
delete?: never;
|
|
53
|
-
options?: never;
|
|
54
|
-
head?: never;
|
|
55
|
-
patch?: never;
|
|
56
|
-
trace?: never;
|
|
57
|
-
};
|
|
58
42
|
"/orders": {
|
|
59
43
|
parameters: {
|
|
60
44
|
query?: never;
|
|
@@ -95,8 +79,6 @@ export interface components {
|
|
|
95
79
|
schemas: {
|
|
96
80
|
/** @description Payload to add a new portfolio */
|
|
97
81
|
AddPortfolioPayload: {
|
|
98
|
-
/** @example 123456 */
|
|
99
|
-
userId: string;
|
|
100
82
|
/** @example PERSONAL */
|
|
101
83
|
type: components["schemas"]["PortfolioType"];
|
|
102
84
|
/**
|
|
@@ -111,6 +93,8 @@ export interface components {
|
|
|
111
93
|
Portfolio: components["schemas"]["AddPortfolioPayload"] & {
|
|
112
94
|
/** @example 123456 */
|
|
113
95
|
id: string;
|
|
96
|
+
/** @example 123456 */
|
|
97
|
+
userId: string;
|
|
114
98
|
holdings: components["schemas"]["Holding"][];
|
|
115
99
|
orders: components["schemas"]["Order"][];
|
|
116
100
|
/**
|
|
@@ -257,53 +241,44 @@ export interface components {
|
|
|
257
241
|
}
|
|
258
242
|
export type $defs = Record<string, never>;
|
|
259
243
|
export interface operations {
|
|
260
|
-
|
|
244
|
+
getPortfolios: {
|
|
261
245
|
parameters: {
|
|
262
246
|
query?: never;
|
|
263
247
|
header?: never;
|
|
264
248
|
path?: never;
|
|
265
249
|
cookie?: never;
|
|
266
250
|
};
|
|
267
|
-
|
|
268
|
-
requestBody: {
|
|
269
|
-
content: {
|
|
270
|
-
"application/json": components["schemas"]["AddPortfolioPayload"];
|
|
271
|
-
};
|
|
272
|
-
};
|
|
251
|
+
requestBody?: never;
|
|
273
252
|
responses: {
|
|
274
|
-
/** @description
|
|
275
|
-
|
|
253
|
+
/** @description Success */
|
|
254
|
+
200: {
|
|
276
255
|
headers: {
|
|
277
256
|
[name: string]: unknown;
|
|
278
257
|
};
|
|
279
258
|
content: {
|
|
280
|
-
"application/json": components["schemas"]["Portfolio"];
|
|
259
|
+
"application/json": components["schemas"]["Portfolio"][];
|
|
281
260
|
};
|
|
282
261
|
};
|
|
283
|
-
400: components["responses"]["BadRequest"];
|
|
284
262
|
404: components["responses"]["NotFound"];
|
|
285
263
|
500: components["responses"]["InternalServerError"];
|
|
286
264
|
};
|
|
287
265
|
};
|
|
288
|
-
|
|
266
|
+
addPortfolio: {
|
|
289
267
|
parameters: {
|
|
290
268
|
query?: never;
|
|
291
269
|
header?: never;
|
|
292
|
-
path
|
|
293
|
-
/** @description The portfolio id */
|
|
294
|
-
portfolioId: string;
|
|
295
|
-
};
|
|
270
|
+
path?: never;
|
|
296
271
|
cookie?: never;
|
|
297
272
|
};
|
|
298
|
-
/** @description The request body to
|
|
273
|
+
/** @description The request body to add a portfolio */
|
|
299
274
|
requestBody: {
|
|
300
275
|
content: {
|
|
301
|
-
"application/json": components["schemas"]["
|
|
276
|
+
"application/json": components["schemas"]["AddPortfolioPayload"];
|
|
302
277
|
};
|
|
303
278
|
};
|
|
304
279
|
responses: {
|
|
305
|
-
/** @description
|
|
306
|
-
|
|
280
|
+
/** @description Added */
|
|
281
|
+
201: {
|
|
307
282
|
headers: {
|
|
308
283
|
[name: string]: unknown;
|
|
309
284
|
};
|
|
@@ -316,17 +291,22 @@ export interface operations {
|
|
|
316
291
|
500: components["responses"]["InternalServerError"];
|
|
317
292
|
};
|
|
318
293
|
};
|
|
319
|
-
|
|
294
|
+
updatePortfolio: {
|
|
320
295
|
parameters: {
|
|
321
296
|
query?: never;
|
|
322
297
|
header?: never;
|
|
323
298
|
path: {
|
|
324
|
-
/** @description The
|
|
325
|
-
|
|
299
|
+
/** @description The portfolio id */
|
|
300
|
+
portfolioId: string;
|
|
326
301
|
};
|
|
327
302
|
cookie?: never;
|
|
328
303
|
};
|
|
329
|
-
|
|
304
|
+
/** @description The request body to update a portfolio */
|
|
305
|
+
requestBody: {
|
|
306
|
+
content: {
|
|
307
|
+
"application/json": components["schemas"]["UpdatePortfolioPayload"];
|
|
308
|
+
};
|
|
309
|
+
};
|
|
330
310
|
responses: {
|
|
331
311
|
/** @description Success */
|
|
332
312
|
200: {
|
|
@@ -334,9 +314,10 @@ export interface operations {
|
|
|
334
314
|
[name: string]: unknown;
|
|
335
315
|
};
|
|
336
316
|
content: {
|
|
337
|
-
"application/json": components["schemas"]["Portfolio"]
|
|
317
|
+
"application/json": components["schemas"]["Portfolio"];
|
|
338
318
|
};
|
|
339
319
|
};
|
|
320
|
+
400: components["responses"]["BadRequest"];
|
|
340
321
|
404: components["responses"]["NotFound"];
|
|
341
322
|
500: components["responses"]["InternalServerError"];
|
|
342
323
|
};
|