@upbit-official/upbit-sdk 1.0.0 → 1.1.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/CHANGELOG.md +5 -0
- package/README.md +21 -0
- package/client.d.mts +10 -4
- package/client.d.mts.map +1 -1
- package/client.d.ts +10 -4
- package/client.d.ts.map +1 -1
- package/client.js +23 -5
- package/client.js.map +1 -1
- package/client.mjs +23 -5
- package/client.mjs.map +1 -1
- package/index.d.mts +3 -1
- package/index.d.mts.map +1 -1
- package/index.d.ts +3 -1
- package/index.d.ts.map +1 -1
- package/index.js +2 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -1
- package/index.mjs.map +1 -1
- package/internal/ws-parser.d.mts +40 -0
- package/internal/ws-parser.d.mts.map +1 -0
- package/internal/ws-parser.d.ts +40 -0
- package/internal/ws-parser.d.ts.map +1 -0
- package/internal/ws-parser.js +125 -0
- package/internal/ws-parser.js.map +1 -0
- package/internal/ws-parser.mjs +118 -0
- package/internal/ws-parser.mjs.map +1 -0
- package/internal/ws-simple-types.d.mts +8 -0
- package/internal/ws-simple-types.d.mts.map +1 -0
- package/internal/ws-simple-types.d.ts +8 -0
- package/internal/ws-simple-types.d.ts.map +1 -0
- package/internal/ws-simple-types.js +3 -0
- package/internal/ws-simple-types.js.map +1 -0
- package/internal/ws-simple-types.mjs +2 -0
- package/internal/ws-simple-types.mjs.map +1 -0
- package/internal/ws.d.mts +1 -0
- package/internal/ws.d.mts.map +1 -1
- package/internal/ws.d.ts +1 -0
- package/internal/ws.d.ts.map +1 -1
- package/internal/ws.js.map +1 -1
- package/internal/ws.mjs.map +1 -1
- package/lib/index.d.mts +4 -2
- package/lib/index.d.mts.map +1 -1
- package/lib/index.d.ts +4 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/jsonParseFloat.d.mts +5 -5
- package/lib/jsonParseFloat.d.mts.map +1 -1
- package/lib/jsonParseFloat.d.ts +5 -5
- package/lib/jsonParseFloat.d.ts.map +1 -1
- package/lib/jsonParseFloat.js +30 -12
- package/lib/jsonParseFloat.js.map +1 -1
- package/lib/jsonParseFloat.mjs +30 -12
- package/lib/jsonParseFloat.mjs.map +1 -1
- package/lib/ws.d.mts +102 -15
- package/lib/ws.d.mts.map +1 -1
- package/lib/ws.d.ts +102 -15
- package/lib/ws.d.ts.map +1 -1
- package/lib/ws.js +208 -34
- package/lib/ws.js.map +1 -1
- package/lib/ws.mjs +204 -33
- package/lib/ws.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/index.d.mts +3 -2
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +3 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +3 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +3 -2
- package/resources/index.mjs.map +1 -1
- package/resources/ws-info/index.d.mts +6 -0
- package/resources/ws-info/index.d.mts.map +1 -0
- package/resources/ws-info/index.d.ts +6 -0
- package/resources/ws-info/index.d.ts.map +1 -0
- package/resources/ws-info/index.js +6 -0
- package/resources/ws-info/index.js.map +1 -0
- package/resources/ws-info/index.mjs +2 -0
- package/resources/ws-info/index.mjs.map +1 -0
- package/resources/ws-info/internal-base.d.mts +63 -0
- package/resources/ws-info/internal-base.d.mts.map +1 -0
- package/resources/ws-info/internal-base.d.ts +63 -0
- package/resources/ws-info/internal-base.d.ts.map +1 -0
- package/resources/ws-info/internal-base.js +47 -0
- package/resources/ws-info/internal-base.js.map +1 -0
- package/resources/ws-info/internal-base.mjs +41 -0
- package/resources/ws-info/internal-base.mjs.map +1 -0
- package/resources/ws-info/ws-info.d.mts +1180 -0
- package/resources/ws-info/ws-info.d.mts.map +1 -0
- package/resources/ws-info/ws-info.d.ts +1180 -0
- package/resources/ws-info/ws-info.d.ts.map +1 -0
- package/resources/ws-info/ws-info.js +8 -0
- package/resources/ws-info/ws-info.js.map +1 -0
- package/resources/ws-info/ws-info.mjs +4 -0
- package/resources/ws-info/ws-info.mjs.map +1 -0
- package/resources/ws-info/ws.d.mts +91 -0
- package/resources/ws-info/ws.d.mts.map +1 -0
- package/resources/ws-info/ws.d.ts +91 -0
- package/resources/ws-info/ws.d.ts.map +1 -0
- package/resources/ws-info/ws.js +463 -0
- package/resources/ws-info/ws.js.map +1 -0
- package/resources/ws-info/ws.mjs +458 -0
- package/resources/ws-info/ws.mjs.map +1 -0
- package/resources/ws-info.d.mts +2 -0
- package/resources/ws-info.d.mts.map +1 -0
- package/resources/ws-info.d.ts +2 -0
- package/resources/ws-info.d.ts.map +1 -0
- package/resources/ws-info.js +5 -0
- package/resources/ws-info.js.map +1 -0
- package/resources/ws-info.mjs +2 -0
- package/resources/ws-info.mjs.map +1 -0
- package/resources/ws-private/index.d.mts +3 -1
- package/resources/ws-private/index.d.mts.map +1 -1
- package/resources/ws-private/index.d.ts +3 -1
- package/resources/ws-private/index.d.ts.map +1 -1
- package/resources/ws-private/index.js.map +1 -1
- package/resources/ws-private/index.mjs +1 -1
- package/resources/ws-private/index.mjs.map +1 -1
- package/resources/ws-private/internal-base.d.mts.map +1 -1
- package/resources/ws-private/internal-base.d.ts.map +1 -1
- package/resources/ws-private/internal-base.js.map +1 -1
- package/resources/ws-private/internal-base.mjs.map +1 -1
- package/resources/ws-private/ws-private.d.mts +301 -9
- package/resources/ws-private/ws-private.d.mts.map +1 -1
- package/resources/ws-private/ws-private.d.ts +301 -9
- package/resources/ws-private/ws-private.d.ts.map +1 -1
- package/resources/ws-private/ws-private.js.map +1 -1
- package/resources/ws-private/ws-private.mjs.map +1 -1
- package/resources/ws-private/ws.d.mts +2 -2
- package/resources/ws-private/ws.d.mts.map +1 -1
- package/resources/ws-private/ws.d.ts +2 -2
- package/resources/ws-private/ws.d.ts.map +1 -1
- package/resources/ws-private/ws.js +15 -20
- package/resources/ws-private/ws.js.map +1 -1
- package/resources/ws-private/ws.mjs +15 -20
- package/resources/ws-private/ws.mjs.map +1 -1
- package/resources/ws-public/index.d.mts +3 -1
- package/resources/ws-public/index.d.mts.map +1 -1
- package/resources/ws-public/index.d.ts +3 -1
- package/resources/ws-public/index.d.ts.map +1 -1
- package/resources/ws-public/index.js.map +1 -1
- package/resources/ws-public/index.mjs +1 -1
- package/resources/ws-public/index.mjs.map +1 -1
- package/resources/ws-public/internal-base.d.mts.map +1 -1
- package/resources/ws-public/internal-base.d.ts.map +1 -1
- package/resources/ws-public/internal-base.js.map +1 -1
- package/resources/ws-public/internal-base.mjs.map +1 -1
- package/resources/ws-public/ws-public.d.mts +355 -5
- package/resources/ws-public/ws-public.d.mts.map +1 -1
- package/resources/ws-public/ws-public.d.ts +355 -5
- package/resources/ws-public/ws-public.d.ts.map +1 -1
- package/resources/ws-public/ws.d.mts +2 -2
- package/resources/ws-public/ws.d.mts.map +1 -1
- package/resources/ws-public/ws.d.ts +2 -2
- package/resources/ws-public/ws.d.ts.map +1 -1
- package/resources/ws-public/ws.js +15 -20
- package/resources/ws-public/ws.js.map +1 -1
- package/resources/ws-public/ws.mjs +15 -20
- package/resources/ws-public/ws.mjs.map +1 -1
- package/src/client.ts +92 -5
- package/src/index.ts +24 -1
- package/src/internal/ws-parser.ts +164 -0
- package/src/internal/ws-simple-types.ts +34 -0
- package/src/internal/ws.ts +1 -0
- package/src/lib/index.ts +17 -2
- package/src/lib/jsonParseFloat.ts +37 -12
- package/src/lib/ws.ts +367 -55
- package/src/resources/index.ts +42 -2
- package/src/resources/ws-info/index.ts +44 -0
- package/src/resources/ws-info/internal-base.ts +96 -0
- package/src/resources/ws-info/ws-info.ts +1855 -0
- package/src/resources/ws-info/ws.ts +574 -0
- package/src/resources/ws-info.ts +1 -0
- package/src/resources/ws-private/index.ts +12 -1
- package/src/resources/ws-private/internal-base.ts +0 -1
- package/src/resources/ws-private/ws-private.ts +420 -18
- package/src/resources/ws-private/ws.ts +16 -23
- package/src/resources/ws-public/index.ts +16 -1
- package/src/resources/ws-public/internal-base.ts +0 -1
- package/src/resources/ws-public/ws-public.ts +459 -4
- package/src/resources/ws-public/ws.ts +16 -23
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
|
@@ -1,22 +1,372 @@
|
|
|
1
|
+
import type { WebSocketMessage } from '../../internal/ws-parser';
|
|
2
|
+
|
|
3
|
+
import type { WsListSubscriptionsResponse } from '../../lib/ws';
|
|
4
|
+
|
|
1
5
|
import { APIResource } from '../../core/resource';
|
|
2
6
|
|
|
7
|
+
import * as WsPrivateAPI from './ws-private';
|
|
8
|
+
|
|
3
9
|
export class WsPrivate extends APIResource {}
|
|
4
10
|
|
|
11
|
+
export interface Announcement {
|
|
12
|
+
/**
|
|
13
|
+
* Data type
|
|
14
|
+
*/
|
|
15
|
+
type: 'announcement';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Announcement body in Markdown. Included only when include_body is true and may
|
|
19
|
+
* be null for large bodies.
|
|
20
|
+
*/
|
|
21
|
+
body?: string | null;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Announcement category
|
|
25
|
+
*/
|
|
26
|
+
category?: AnnouncementCategory;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Announcement event type
|
|
30
|
+
*/
|
|
31
|
+
event_type?: AnnouncementEventType;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* First publication time (KST, ISO 8601)
|
|
35
|
+
*/
|
|
36
|
+
first_listed_at?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Latest publication time (KST, ISO 8601)
|
|
40
|
+
*/
|
|
41
|
+
listed_at?: string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Stream type (announcement supports realtime only)
|
|
45
|
+
*/
|
|
46
|
+
stream_type?: 'REALTIME';
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Timestamp (ms)
|
|
50
|
+
*/
|
|
51
|
+
timestamp?: number;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Announcement title
|
|
55
|
+
*/
|
|
56
|
+
title?: string;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Announcement detail page URL
|
|
60
|
+
*/
|
|
61
|
+
url?: string;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Announcement unique ID
|
|
65
|
+
*/
|
|
66
|
+
uuid?: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
5
69
|
/**
|
|
6
|
-
*
|
|
7
|
-
* required)
|
|
70
|
+
* Announcement category
|
|
8
71
|
*/
|
|
9
|
-
export type
|
|
10
|
-
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
72
|
+
export type AnnouncementCategory =
|
|
73
|
+
| 'notice'
|
|
74
|
+
| 'trade'
|
|
75
|
+
| 'wallet'
|
|
76
|
+
| 'maintenance'
|
|
77
|
+
| 'digital_asset'
|
|
78
|
+
| 'nft'
|
|
79
|
+
| 'service'
|
|
80
|
+
| 'event'
|
|
81
|
+
| 'note'
|
|
82
|
+
| 'trading'
|
|
83
|
+
| 'airdrop'
|
|
84
|
+
| 'feature'
|
|
85
|
+
| 'disclosure';
|
|
86
|
+
|
|
87
|
+
export type AnnouncementEventType = 'CREATED' | 'UPDATED';
|
|
88
|
+
|
|
89
|
+
export interface SimpleAnnouncement {
|
|
90
|
+
/**
|
|
91
|
+
* Data type
|
|
92
|
+
*/
|
|
93
|
+
ty: 'announcement';
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Announcement body in Markdown. Included only when include_body is true and may
|
|
97
|
+
* be null for large bodies.
|
|
98
|
+
*/
|
|
99
|
+
bd?: string | null;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Announcement category
|
|
103
|
+
*/
|
|
104
|
+
cat?:
|
|
105
|
+
| 'notice'
|
|
106
|
+
| 'trade'
|
|
107
|
+
| 'wallet'
|
|
108
|
+
| 'maintenance'
|
|
109
|
+
| 'digital_asset'
|
|
110
|
+
| 'nft'
|
|
111
|
+
| 'service'
|
|
112
|
+
| 'event'
|
|
113
|
+
| 'note'
|
|
114
|
+
| 'trading'
|
|
115
|
+
| 'airdrop'
|
|
116
|
+
| 'feature'
|
|
117
|
+
| 'disclosure';
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Announcement event type
|
|
121
|
+
*/
|
|
122
|
+
et?: 'CREATED' | 'UPDATED';
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* First publication time (KST, ISO 8601)
|
|
126
|
+
*/
|
|
127
|
+
flat?: string;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Latest publication time (KST, ISO 8601)
|
|
131
|
+
*/
|
|
132
|
+
lat?: string;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Stream type (announcement supports realtime only)
|
|
136
|
+
*/
|
|
137
|
+
st?: 'REALTIME';
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Timestamp (ms)
|
|
141
|
+
*/
|
|
142
|
+
tms?: number;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Announcement title
|
|
146
|
+
*/
|
|
147
|
+
tt?: string;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Announcement unique ID
|
|
151
|
+
*/
|
|
152
|
+
uid?: string;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Announcement detail page URL
|
|
156
|
+
*/
|
|
157
|
+
url?: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface SimpleMyAsset {
|
|
161
|
+
/**
|
|
162
|
+
* Data type
|
|
163
|
+
*/
|
|
164
|
+
ty: 'myAsset';
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* List of asset entries
|
|
168
|
+
*/
|
|
169
|
+
ast?: Array<SimpleMyAsset.Ast>;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Asset timestamp (ms)
|
|
173
|
+
*/
|
|
174
|
+
asttms?: number;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Asset unique ID
|
|
178
|
+
*/
|
|
179
|
+
astuid?: string;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Stream type (snapshot or realtime)
|
|
183
|
+
*/
|
|
184
|
+
st?: 'SNAPSHOT' | 'REALTIME';
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Timestamp (ms)
|
|
188
|
+
*/
|
|
189
|
+
tms?: number;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export namespace SimpleMyAsset {
|
|
193
|
+
/**
|
|
194
|
+
* Asset entry
|
|
195
|
+
*/
|
|
196
|
+
export interface Ast {
|
|
197
|
+
/**
|
|
198
|
+
* Available balance
|
|
199
|
+
*/
|
|
200
|
+
b?: string;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Currency code (uppercase)
|
|
204
|
+
*/
|
|
205
|
+
cu?: string;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Balance locked in open orders
|
|
209
|
+
*/
|
|
210
|
+
l?: string;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface SimpleMyOrder {
|
|
215
|
+
/**
|
|
216
|
+
* Data type
|
|
217
|
+
*/
|
|
218
|
+
ty: 'myOrder';
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* User-defined lookup value. Only provided for orders created after 2024-10-18.
|
|
222
|
+
*/
|
|
223
|
+
id?: string | null;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Ask/bid side
|
|
227
|
+
*/
|
|
228
|
+
ab?: 'ASK' | 'BID';
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Average execution price
|
|
232
|
+
*/
|
|
233
|
+
ap?: string;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Market code
|
|
237
|
+
*/
|
|
238
|
+
cd?: string;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Executed trade value
|
|
242
|
+
*/
|
|
243
|
+
ef?: string;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Executed quantity
|
|
247
|
+
*/
|
|
248
|
+
ev?: string;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Whether the executed order is a maker order. Null when state is not trade.
|
|
252
|
+
*/
|
|
253
|
+
im?: boolean | null;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Amount locked for this trade
|
|
257
|
+
*/
|
|
258
|
+
l?: string;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Order type
|
|
262
|
+
*/
|
|
263
|
+
ot?: 'limit' | 'price' | 'market' | 'best';
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Order timestamp (ms)
|
|
267
|
+
*/
|
|
268
|
+
otms?: number;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Order price. When state=trade, this is the execution price.
|
|
272
|
+
*/
|
|
273
|
+
p?: string;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Fee already paid
|
|
277
|
+
*/
|
|
278
|
+
pf?: string;
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Amount (buy) or quantity (sell) cancelled by self-match prevention
|
|
282
|
+
*/
|
|
283
|
+
pl?: string | null;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Order quantity cancelled by self-match prevention
|
|
287
|
+
*/
|
|
288
|
+
pv?: string | null;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Remaining fee
|
|
292
|
+
*/
|
|
293
|
+
rmf?: string;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Fee reserved for this order
|
|
297
|
+
*/
|
|
298
|
+
rsf?: string;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Remaining order quantity after execution
|
|
302
|
+
*/
|
|
303
|
+
rv?: string;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Order status
|
|
307
|
+
*/
|
|
308
|
+
s?: 'wait' | 'watch' | 'trade' | 'done' | 'cancel' | 'prevented';
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Self-match prevention type
|
|
312
|
+
*/
|
|
313
|
+
smpt?: 'reduce' | 'cancel_maker' | 'cancel_taker' | null;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Stream type (snapshot or realtime)
|
|
317
|
+
*/
|
|
318
|
+
st?: 'SNAPSHOT' | 'REALTIME';
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Number of executions for this order
|
|
322
|
+
*/
|
|
323
|
+
tc?: number;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Fee incurred on execution. Null when state is not trade.
|
|
327
|
+
*/
|
|
328
|
+
tf?: string | null;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* IOC/FOK/POST ONLY order condition
|
|
332
|
+
*/
|
|
333
|
+
tif?: 'ioc' | 'fok' | 'post_only' | null;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Timestamp (ms)
|
|
337
|
+
*/
|
|
338
|
+
tms?: number;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Trade timestamp (ms)
|
|
342
|
+
*/
|
|
343
|
+
ttms?: number | null;
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Trade unique ID
|
|
347
|
+
*/
|
|
348
|
+
tuid?: string | null;
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Order unique ID
|
|
352
|
+
*/
|
|
353
|
+
uid?: string;
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Order quantity. When state=trade, this is the executed quantity.
|
|
357
|
+
*/
|
|
358
|
+
v?: string;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export type SimplePrivateServerEvent = SimpleAnnouncement | SimpleMyOrder | SimpleMyAsset;
|
|
362
|
+
|
|
363
|
+
export type ConnectPrivateClientEvent = Array<
|
|
364
|
+
| ConnectPrivateClientEvent.WsTicketField
|
|
365
|
+
| ConnectPrivateClientEvent.WsAnnouncementTypeField
|
|
366
|
+
| ConnectPrivateClientEvent.WsMyOrderTypeField
|
|
367
|
+
| ConnectPrivateClientEvent.WsMyAssetTypeField
|
|
368
|
+
| ConnectPrivateClientEvent.WsFormatField
|
|
369
|
+
>;
|
|
20
370
|
|
|
21
371
|
export namespace ConnectPrivateClientEvent {
|
|
22
372
|
/**
|
|
@@ -29,6 +379,44 @@ export namespace ConnectPrivateClientEvent {
|
|
|
29
379
|
ticket: string;
|
|
30
380
|
}
|
|
31
381
|
|
|
382
|
+
/**
|
|
383
|
+
* Announcement subscription type field
|
|
384
|
+
*/
|
|
385
|
+
export interface WsAnnouncementTypeField {
|
|
386
|
+
type: 'announcement';
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Announcement categories to receive. Omit this field to receive announcements
|
|
390
|
+
* from all categories.
|
|
391
|
+
*/
|
|
392
|
+
categories?: Array<WsPrivateAPI.AnnouncementCategory>;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Whether to include the announcement body in stream messages
|
|
396
|
+
*/
|
|
397
|
+
include_body?: boolean;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Response format specifier field
|
|
402
|
+
*/
|
|
403
|
+
export interface WsFormatField {
|
|
404
|
+
/**
|
|
405
|
+
* Response format selector
|
|
406
|
+
*/
|
|
407
|
+
format?: 'DEFAULT' | 'SIMPLE' | 'JSON_LIST' | 'SIMPLE_LIST';
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Ticket field that identifies the requester
|
|
412
|
+
*/
|
|
413
|
+
export interface WsTicketField {
|
|
414
|
+
/**
|
|
415
|
+
* A value that uniquely identifies the requester (UUID recommended)
|
|
416
|
+
*/
|
|
417
|
+
ticket: string;
|
|
418
|
+
}
|
|
419
|
+
|
|
32
420
|
/**
|
|
33
421
|
* MyOrder subscription type field
|
|
34
422
|
*/
|
|
@@ -59,11 +447,10 @@ export namespace ConnectPrivateClientEvent {
|
|
|
59
447
|
}
|
|
60
448
|
}
|
|
61
449
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
export type ConnectPrivateServerEvent = ConnectPrivateServerEvent.MyOrder | ConnectPrivateServerEvent.MyAsset;
|
|
450
|
+
export type ConnectPrivateServerEvent =
|
|
451
|
+
| Announcement
|
|
452
|
+
| ConnectPrivateServerEvent.MyOrder
|
|
453
|
+
| ConnectPrivateServerEvent.MyAsset;
|
|
67
454
|
|
|
68
455
|
export namespace ConnectPrivateServerEvent {
|
|
69
456
|
/**
|
|
@@ -276,7 +663,22 @@ export namespace ConnectPrivateServerEvent {
|
|
|
276
663
|
|
|
277
664
|
export declare namespace WsPrivate {
|
|
278
665
|
export {
|
|
666
|
+
type Announcement as Announcement,
|
|
667
|
+
type AnnouncementCategory as AnnouncementCategory,
|
|
668
|
+
type AnnouncementEventType as AnnouncementEventType,
|
|
669
|
+
type SimpleAnnouncement as SimpleAnnouncement,
|
|
670
|
+
type SimpleMyAsset as SimpleMyAsset,
|
|
671
|
+
type SimpleMyOrder as SimpleMyOrder,
|
|
672
|
+
type SimplePrivateServerEvent as SimplePrivateServerEvent,
|
|
279
673
|
type ConnectPrivateClientEvent as ConnectPrivateClientEvent,
|
|
674
|
+
type ConnectPrivateServerMessage as ConnectPrivateServerMessage,
|
|
280
675
|
type ConnectPrivateServerEvent as ConnectPrivateServerEvent,
|
|
281
676
|
};
|
|
282
677
|
}
|
|
678
|
+
|
|
679
|
+
export type ConnectPrivateServerMessage =
|
|
680
|
+
| WebSocketMessage<ConnectPrivateServerEvent | SimplePrivateServerEvent>
|
|
681
|
+
| WsListSubscriptionsResponse
|
|
682
|
+
| Array<
|
|
683
|
+
WebSocketMessage<ConnectPrivateServerEvent | SimplePrivateServerEvent> | WsListSubscriptionsResponse
|
|
684
|
+
>;
|
|
@@ -3,10 +3,10 @@ import { WsPrivateEmitter, WsPrivateStreamMessage, WebSocketError, buildURL } fr
|
|
|
3
3
|
import { InternalEventEmitter } from '../../core/EventEmitter';
|
|
4
4
|
import { sleep } from '../../internal/utils/sleep';
|
|
5
5
|
import { isRecoverableClose, type ReconnectingEvent, type ReconnectingOverrides } from '../../internal/ws';
|
|
6
|
-
import * as WsPrivateAPI from './ws-private';
|
|
7
|
-
import { Upbit } from '../../client';
|
|
8
|
-
import { jsonParseFloat } from '../../lib/jsonParseFloat';
|
|
6
|
+
import type * as WsPrivateAPI from './ws-private';
|
|
7
|
+
import type { Upbit } from '../../client';
|
|
9
8
|
import { createJwtToken } from '../../lib/jwtAuth';
|
|
9
|
+
import { isRecord, parseWebSocketValue } from '../../internal/ws-parser';
|
|
10
10
|
|
|
11
11
|
export interface WsPrivateWSReconnectOptions {
|
|
12
12
|
/**
|
|
@@ -69,7 +69,7 @@ export class WsPrivateWS extends WsPrivateEmitter {
|
|
|
69
69
|
) {
|
|
70
70
|
super();
|
|
71
71
|
this._client = client;
|
|
72
|
-
this._parameters =
|
|
72
|
+
this._parameters = parameters;
|
|
73
73
|
const { reconnect, ...wsOptions } = options ?? {};
|
|
74
74
|
this._wsOptions = wsOptions;
|
|
75
75
|
this._reconnectOptions = reconnect ?? null;
|
|
@@ -147,7 +147,7 @@ export class WsPrivateWS extends WsPrivateEmitter {
|
|
|
147
147
|
push({ type: 'message', message: event });
|
|
148
148
|
};
|
|
149
149
|
|
|
150
|
-
//
|
|
150
|
+
// Connection and transport errors funnel through _onError → 'error' event
|
|
151
151
|
const onEmitterError = (err: WebSocketError) => {
|
|
152
152
|
push({ type: 'error', error: err });
|
|
153
153
|
};
|
|
@@ -272,27 +272,20 @@ export class WsPrivateWS extends WsPrivateEmitter {
|
|
|
272
272
|
|
|
273
273
|
const socket = new WS.WebSocket(this.url, {
|
|
274
274
|
...this._wsOptions,
|
|
275
|
-
headers:
|
|
276
|
-
...this._authHeaders(),
|
|
277
|
-
...this._wsOptions?.headers,
|
|
278
|
-
},
|
|
275
|
+
headers: this._client._buildWebSocketHandshakeHeaders(this._authHeaders(), this._wsOptions?.headers),
|
|
279
276
|
});
|
|
280
277
|
|
|
281
278
|
socket.on('message', (wsEvent) => {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
this._emit('event', event);
|
|
293
|
-
|
|
294
|
-
// @ts-ignore TS isn't smart enough to get the relationship right here
|
|
295
|
-
this._emit(event.type, event);
|
|
279
|
+
let event: unknown;
|
|
280
|
+
try {
|
|
281
|
+
event = parseWebSocketValue(wsEvent.toString());
|
|
282
|
+
} catch (error) {
|
|
283
|
+
this._onError(null, 'could not parse WebSocket message', new SyntaxError('Invalid WebSocket JSON'));
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
this._emit('event', event as WsPrivateAPI.ConnectPrivateServerEvent);
|
|
287
|
+
if (isRecord(event) && typeof event['type'] === 'string') {
|
|
288
|
+
this._emit(event['type'] as any, event as any);
|
|
296
289
|
}
|
|
297
290
|
});
|
|
298
291
|
|
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {
|
|
2
|
+
WsPublic,
|
|
3
|
+
type ConnectPublicClientEvent,
|
|
4
|
+
type ConnectPublicServerEvent,
|
|
5
|
+
type ListSubscriptionsResponse,
|
|
6
|
+
type ListSubscriptionsServerResponse,
|
|
7
|
+
type SimpleListSubscriptionsResponse,
|
|
8
|
+
} from './ws-public';
|
|
2
9
|
export { type WsPublicWSClientOptions, type WsPublicWSReconnectOptions } from './ws';
|
|
10
|
+
|
|
11
|
+
export type { SimplePublicServerEvent } from '../../internal/ws-simple-types';
|
|
12
|
+
export type {
|
|
13
|
+
SimpleTicker,
|
|
14
|
+
SimpleTrade,
|
|
15
|
+
SimpleOrderbook,
|
|
16
|
+
SimpleCandle,
|
|
17
|
+
} from '../../internal/ws-simple-types';
|
|
@@ -5,7 +5,6 @@ import { UpbitError } from '../../core/error';
|
|
|
5
5
|
import { stringifyQuery } from '../../internal/utils';
|
|
6
6
|
|
|
7
7
|
import type { ReconnectingEvent } from '../../internal/ws';
|
|
8
|
-
|
|
9
8
|
export type WsPublicStreamMessage =
|
|
10
9
|
| { type: 'connecting' | 'open' | 'closing' | 'close' }
|
|
11
10
|
| { type: 'reconnecting'; reconnect: ReconnectingEvent }
|