@rivascva/dt-idl 1.0.7
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/.eslintrc.json +35 -0
- package/.githooks/pre-commit-config.yaml +8 -0
- package/.githooks/pre-push-config.yaml +6 -0
- package/.github/workflows/publish.yaml +40 -0
- package/.prettierrc.json +5 -0
- package/.vscode/settings.json +10 -0
- package/Makefile +4 -0
- package/dist/index.cjs.js +464 -0
- package/dist/index.d.ts +690 -0
- package/dist/index.esm.js +461 -0
- package/package.json +39 -0
- package/rollup.config.ts +29 -0
- package/services/dt-market-service.yaml +474 -0
- package/services/dt-trade-service.yaml +388 -0
- package/ts/clients/clients.ts +10 -0
- package/ts/clients/index.ts +1 -0
- package/ts/index.ts +2 -0
- package/ts/services/dt-market-service.ts +366 -0
- package/ts/services/dt-trade-service.ts +309 -0
- package/ts/types/index.ts +1 -0
- package/ts/types/types.ts +11 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
openapi: 3.0.0
|
|
2
|
+
|
|
3
|
+
info:
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
title: Dream Trade Trade Service
|
|
6
|
+
description: Make trades on the stock market.
|
|
7
|
+
|
|
8
|
+
servers:
|
|
9
|
+
- url: http://localhost:8081/v1
|
|
10
|
+
|
|
11
|
+
paths:
|
|
12
|
+
/users:
|
|
13
|
+
get:
|
|
14
|
+
description: Gets all users
|
|
15
|
+
operationId: getUsers
|
|
16
|
+
tags:
|
|
17
|
+
- Users
|
|
18
|
+
responses:
|
|
19
|
+
200:
|
|
20
|
+
description: Success
|
|
21
|
+
content:
|
|
22
|
+
application/json:
|
|
23
|
+
schema:
|
|
24
|
+
type: array
|
|
25
|
+
items:
|
|
26
|
+
$ref: "#/components/schemas/User"
|
|
27
|
+
404:
|
|
28
|
+
$ref: "#/components/responses/NotFound"
|
|
29
|
+
500:
|
|
30
|
+
$ref: "#/components/responses/InternalServerError"
|
|
31
|
+
post:
|
|
32
|
+
description: Adds a new user
|
|
33
|
+
operationId: addUser
|
|
34
|
+
tags:
|
|
35
|
+
- Users
|
|
36
|
+
requestBody:
|
|
37
|
+
description: The request body to add a user
|
|
38
|
+
required: true
|
|
39
|
+
content:
|
|
40
|
+
application/json:
|
|
41
|
+
schema:
|
|
42
|
+
$ref: "#/components/schemas/UserPayload"
|
|
43
|
+
responses:
|
|
44
|
+
201:
|
|
45
|
+
description: Added
|
|
46
|
+
content:
|
|
47
|
+
application/json:
|
|
48
|
+
schema:
|
|
49
|
+
$ref: "#/components/schemas/User"
|
|
50
|
+
400:
|
|
51
|
+
$ref: "#/components/responses/BadRequest"
|
|
52
|
+
500:
|
|
53
|
+
$ref: "#/components/responses/InternalServerError"
|
|
54
|
+
|
|
55
|
+
/users/{userId}:
|
|
56
|
+
get:
|
|
57
|
+
description: Gets a user
|
|
58
|
+
operationId: getUser
|
|
59
|
+
tags:
|
|
60
|
+
- Users
|
|
61
|
+
parameters:
|
|
62
|
+
- in: path
|
|
63
|
+
name: userId
|
|
64
|
+
description: The user id
|
|
65
|
+
required: true
|
|
66
|
+
schema:
|
|
67
|
+
type: string
|
|
68
|
+
example: 123456
|
|
69
|
+
responses:
|
|
70
|
+
200:
|
|
71
|
+
description: Success
|
|
72
|
+
content:
|
|
73
|
+
application/json:
|
|
74
|
+
schema:
|
|
75
|
+
type: object
|
|
76
|
+
$ref: "#/components/schemas/User"
|
|
77
|
+
404:
|
|
78
|
+
$ref: "#/components/responses/NotFound"
|
|
79
|
+
500:
|
|
80
|
+
$ref: "#/components/responses/InternalServerError"
|
|
81
|
+
put:
|
|
82
|
+
description: Updates an existing user
|
|
83
|
+
operationId: updateUser
|
|
84
|
+
tags:
|
|
85
|
+
- Users
|
|
86
|
+
parameters:
|
|
87
|
+
- in: path
|
|
88
|
+
name: userId
|
|
89
|
+
description: The user id
|
|
90
|
+
required: true
|
|
91
|
+
schema:
|
|
92
|
+
type: string
|
|
93
|
+
example: 123456
|
|
94
|
+
requestBody:
|
|
95
|
+
description: The request body to updated a user
|
|
96
|
+
required: true
|
|
97
|
+
content:
|
|
98
|
+
application/json:
|
|
99
|
+
schema:
|
|
100
|
+
$ref: "#/components/schemas/UserPayload"
|
|
101
|
+
responses:
|
|
102
|
+
200:
|
|
103
|
+
description: Success
|
|
104
|
+
content:
|
|
105
|
+
application/json:
|
|
106
|
+
schema:
|
|
107
|
+
$ref: "#/components/schemas/User"
|
|
108
|
+
400:
|
|
109
|
+
$ref: "#/components/responses/BadRequest"
|
|
110
|
+
404:
|
|
111
|
+
$ref: "#/components/responses/NotFound"
|
|
112
|
+
500:
|
|
113
|
+
$ref: "#/components/responses/InternalServerError"
|
|
114
|
+
|
|
115
|
+
/users/{userId}/portfolios:
|
|
116
|
+
get:
|
|
117
|
+
description: Gets all portfolios of a user
|
|
118
|
+
operationId: getUserPortfolios
|
|
119
|
+
tags:
|
|
120
|
+
- Users
|
|
121
|
+
parameters:
|
|
122
|
+
- in: path
|
|
123
|
+
name: userId
|
|
124
|
+
description: The user id
|
|
125
|
+
required: true
|
|
126
|
+
schema:
|
|
127
|
+
type: string
|
|
128
|
+
example: 123456
|
|
129
|
+
responses:
|
|
130
|
+
200:
|
|
131
|
+
description: Success
|
|
132
|
+
content:
|
|
133
|
+
application/json:
|
|
134
|
+
schema:
|
|
135
|
+
type: array
|
|
136
|
+
items:
|
|
137
|
+
$ref: "#/components/schemas/Portfolio"
|
|
138
|
+
404:
|
|
139
|
+
$ref: "#/components/responses/NotFound"
|
|
140
|
+
500:
|
|
141
|
+
$ref: "#/components/responses/InternalServerError"
|
|
142
|
+
|
|
143
|
+
/orders:
|
|
144
|
+
post:
|
|
145
|
+
description: Add a new order
|
|
146
|
+
operationId: addOrder
|
|
147
|
+
tags:
|
|
148
|
+
- Orders
|
|
149
|
+
requestBody:
|
|
150
|
+
description: The request body to add an order
|
|
151
|
+
required: true
|
|
152
|
+
content:
|
|
153
|
+
application/json:
|
|
154
|
+
schema:
|
|
155
|
+
$ref: "#/components/schemas/OrderPayload"
|
|
156
|
+
responses:
|
|
157
|
+
201:
|
|
158
|
+
description: Added
|
|
159
|
+
content:
|
|
160
|
+
application/json:
|
|
161
|
+
schema:
|
|
162
|
+
$ref: "#/components/schemas/Order"
|
|
163
|
+
400:
|
|
164
|
+
$ref: "#/components/responses/BadRequest"
|
|
165
|
+
404:
|
|
166
|
+
$ref: "#/components/responses/NotFound"
|
|
167
|
+
500:
|
|
168
|
+
$ref: "#/components/responses/InternalServerError"
|
|
169
|
+
|
|
170
|
+
components:
|
|
171
|
+
schemas:
|
|
172
|
+
UserPayload:
|
|
173
|
+
description: A user payload
|
|
174
|
+
properties:
|
|
175
|
+
email:
|
|
176
|
+
type: string
|
|
177
|
+
example: sam.smith@example.com
|
|
178
|
+
name:
|
|
179
|
+
type: string
|
|
180
|
+
example: Sam Smith
|
|
181
|
+
required:
|
|
182
|
+
- email
|
|
183
|
+
- name
|
|
184
|
+
|
|
185
|
+
User:
|
|
186
|
+
description: A user
|
|
187
|
+
allOf:
|
|
188
|
+
- $ref: "#/components/schemas/UserPayload"
|
|
189
|
+
- type: object
|
|
190
|
+
properties:
|
|
191
|
+
id:
|
|
192
|
+
type: string
|
|
193
|
+
example: 123456
|
|
194
|
+
dateCreated:
|
|
195
|
+
type: integer
|
|
196
|
+
format: int64
|
|
197
|
+
example: 1713398544000
|
|
198
|
+
dateUpdated:
|
|
199
|
+
type: integer
|
|
200
|
+
format: int64
|
|
201
|
+
example: 1713398544000
|
|
202
|
+
required:
|
|
203
|
+
- id
|
|
204
|
+
- dateCreated
|
|
205
|
+
- dateUpdated
|
|
206
|
+
|
|
207
|
+
Portfolio:
|
|
208
|
+
description: A trading portfolio
|
|
209
|
+
properties:
|
|
210
|
+
id:
|
|
211
|
+
type: string
|
|
212
|
+
example: 123456
|
|
213
|
+
userId:
|
|
214
|
+
type: string
|
|
215
|
+
example: 123456
|
|
216
|
+
type:
|
|
217
|
+
$ref: "#/components/schemas/PortfolioType"
|
|
218
|
+
example: PERSONAL
|
|
219
|
+
cash:
|
|
220
|
+
type: number
|
|
221
|
+
format: double
|
|
222
|
+
example: 10500.25
|
|
223
|
+
holdings:
|
|
224
|
+
type: array
|
|
225
|
+
items:
|
|
226
|
+
$ref: "#/components/schemas/Holding"
|
|
227
|
+
dateCreated:
|
|
228
|
+
type: integer
|
|
229
|
+
format: int64
|
|
230
|
+
example: 1713398544000
|
|
231
|
+
dateUpdated:
|
|
232
|
+
type: integer
|
|
233
|
+
format: int64
|
|
234
|
+
example: 1713398544000
|
|
235
|
+
required:
|
|
236
|
+
- id
|
|
237
|
+
- userId
|
|
238
|
+
- type
|
|
239
|
+
- cash
|
|
240
|
+
- holdings
|
|
241
|
+
- dateCreated
|
|
242
|
+
- dateUpdated
|
|
243
|
+
|
|
244
|
+
Holding:
|
|
245
|
+
description: An active stock holding
|
|
246
|
+
properties:
|
|
247
|
+
id:
|
|
248
|
+
type: string
|
|
249
|
+
example: 123456
|
|
250
|
+
symbol:
|
|
251
|
+
type: string
|
|
252
|
+
example: AAPL
|
|
253
|
+
averagePrice:
|
|
254
|
+
type: number
|
|
255
|
+
format: double
|
|
256
|
+
example: 182.25
|
|
257
|
+
quantity:
|
|
258
|
+
type: integer
|
|
259
|
+
format: int64
|
|
260
|
+
example: 10
|
|
261
|
+
dateCreated:
|
|
262
|
+
type: integer
|
|
263
|
+
format: int64
|
|
264
|
+
example: 1713398544000
|
|
265
|
+
dateUpdated:
|
|
266
|
+
type: integer
|
|
267
|
+
format: int64
|
|
268
|
+
example: 1713398544000
|
|
269
|
+
required:
|
|
270
|
+
- id
|
|
271
|
+
- symbol
|
|
272
|
+
- averagePrice
|
|
273
|
+
- quantity
|
|
274
|
+
- dateCreated
|
|
275
|
+
- dateUpdated
|
|
276
|
+
|
|
277
|
+
OrderPayload:
|
|
278
|
+
description: A trade order payload
|
|
279
|
+
properties:
|
|
280
|
+
portfolioId:
|
|
281
|
+
type: string
|
|
282
|
+
example: 123456
|
|
283
|
+
type:
|
|
284
|
+
$ref: "#/components/schemas/OrderType"
|
|
285
|
+
example: BUY
|
|
286
|
+
symbol:
|
|
287
|
+
type: string
|
|
288
|
+
example: AAPL
|
|
289
|
+
targetPrice:
|
|
290
|
+
type: number
|
|
291
|
+
format: double
|
|
292
|
+
example: 182.25
|
|
293
|
+
quantity:
|
|
294
|
+
type: integer
|
|
295
|
+
format: int64
|
|
296
|
+
example: 10
|
|
297
|
+
required:
|
|
298
|
+
- portfolioId
|
|
299
|
+
- type
|
|
300
|
+
- symbol
|
|
301
|
+
- targetPrice
|
|
302
|
+
- quantity
|
|
303
|
+
|
|
304
|
+
Order:
|
|
305
|
+
description: A trade order
|
|
306
|
+
allOf:
|
|
307
|
+
- $ref: "#/components/schemas/OrderPayload"
|
|
308
|
+
- type: object
|
|
309
|
+
properties:
|
|
310
|
+
id:
|
|
311
|
+
type: string
|
|
312
|
+
example: 123456
|
|
313
|
+
actualPrice:
|
|
314
|
+
type: number
|
|
315
|
+
format: double
|
|
316
|
+
example: 182.25
|
|
317
|
+
dateCreated:
|
|
318
|
+
type: integer
|
|
319
|
+
format: int64
|
|
320
|
+
example: 1713398544000
|
|
321
|
+
required:
|
|
322
|
+
- id
|
|
323
|
+
- actualPrice
|
|
324
|
+
- dateCreated
|
|
325
|
+
|
|
326
|
+
Error:
|
|
327
|
+
description: A generic error
|
|
328
|
+
properties:
|
|
329
|
+
status:
|
|
330
|
+
type: integer
|
|
331
|
+
format: int64
|
|
332
|
+
example: 500
|
|
333
|
+
code:
|
|
334
|
+
$ref: "#/components/schemas/ErrorCode"
|
|
335
|
+
example: ERROR
|
|
336
|
+
message:
|
|
337
|
+
type: string
|
|
338
|
+
example: Error
|
|
339
|
+
required:
|
|
340
|
+
- status
|
|
341
|
+
- code
|
|
342
|
+
- message
|
|
343
|
+
|
|
344
|
+
ErrorCode:
|
|
345
|
+
type: string
|
|
346
|
+
enum:
|
|
347
|
+
- ERROR
|
|
348
|
+
- NOT_ENOUGH_CASH
|
|
349
|
+
- NOT_ENOUGH_SHARES
|
|
350
|
+
- REQS_NOT_MET
|
|
351
|
+
|
|
352
|
+
PortfolioType:
|
|
353
|
+
type: string
|
|
354
|
+
enum:
|
|
355
|
+
- PERSONAL
|
|
356
|
+
- COMPETITIVE
|
|
357
|
+
|
|
358
|
+
OrderType:
|
|
359
|
+
type: string
|
|
360
|
+
enum:
|
|
361
|
+
- BUY_MARKET
|
|
362
|
+
- BUY_LIMIT
|
|
363
|
+
- BUY_STOP
|
|
364
|
+
- SELL_MARKET
|
|
365
|
+
- SELL_LIMIT
|
|
366
|
+
- SELL_STOP
|
|
367
|
+
|
|
368
|
+
responses:
|
|
369
|
+
NotFound:
|
|
370
|
+
description: The resource was not found
|
|
371
|
+
content:
|
|
372
|
+
application/json:
|
|
373
|
+
schema:
|
|
374
|
+
$ref: "#/components/schemas/Error"
|
|
375
|
+
|
|
376
|
+
BadRequest:
|
|
377
|
+
description: Invalid request payload
|
|
378
|
+
content:
|
|
379
|
+
application/json:
|
|
380
|
+
schema:
|
|
381
|
+
$ref: "#/components/schemas/Error"
|
|
382
|
+
|
|
383
|
+
InternalServerError:
|
|
384
|
+
description: There was an internal server error
|
|
385
|
+
content:
|
|
386
|
+
application/json:
|
|
387
|
+
schema:
|
|
388
|
+
$ref: "#/components/schemas/Error"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import createClient, { ClientOptions } from 'openapi-fetch';
|
|
2
|
+
|
|
3
|
+
import { paths as MarketServicePaths } from '@ts/services/dt-market-service';
|
|
4
|
+
import { paths as TradeServicePaths } from '@ts/services/dt-trade-service';
|
|
5
|
+
|
|
6
|
+
export const createMarketServiceClient = (options: ClientOptions) =>
|
|
7
|
+
createClient<MarketServicePaths>(options);
|
|
8
|
+
|
|
9
|
+
export const createTradeServiceClient = (options: ClientOptions) =>
|
|
10
|
+
createClient<TradeServicePaths>(options);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './clients';
|
package/ts/index.ts
ADDED