@invezgo/sdk 1.3.1 → 2.0.1

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.
Files changed (56) hide show
  1. package/README.md +318 -313
  2. package/dist/cache.d.ts +27 -0
  3. package/dist/cache.d.ts.map +1 -0
  4. package/dist/client.d.ts +15 -18
  5. package/dist/client.d.ts.map +1 -1
  6. package/dist/errors.d.ts +71 -0
  7. package/dist/errors.d.ts.map +1 -0
  8. package/dist/generated/resources.d.ts +3291 -0
  9. package/dist/generated/resources.d.ts.map +1 -0
  10. package/dist/generated/types.d.ts +3449 -0
  11. package/dist/generated/types.d.ts.map +1 -0
  12. package/dist/http.d.ts +66 -0
  13. package/dist/http.d.ts.map +1 -0
  14. package/dist/index.d.ts +9 -15
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +755 -1005
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +775 -0
  19. package/dist/index.mjs.map +1 -0
  20. package/package.json +66 -60
  21. package/dist/endpoints/ai.d.ts +0 -98
  22. package/dist/endpoints/ai.d.ts.map +0 -1
  23. package/dist/endpoints/alerts.d.ts +0 -49
  24. package/dist/endpoints/alerts.d.ts.map +0 -1
  25. package/dist/endpoints/analysis.d.ts +0 -369
  26. package/dist/endpoints/analysis.d.ts.map +0 -1
  27. package/dist/endpoints/health.d.ts +0 -24
  28. package/dist/endpoints/health.d.ts.map +0 -1
  29. package/dist/endpoints/journals.d.ts +0 -49
  30. package/dist/endpoints/journals.d.ts.map +0 -1
  31. package/dist/endpoints/membership.d.ts +0 -35
  32. package/dist/endpoints/membership.d.ts.map +0 -1
  33. package/dist/endpoints/portfolios.d.ts +0 -14
  34. package/dist/endpoints/portfolios.d.ts.map +0 -1
  35. package/dist/endpoints/posts.d.ts +0 -42
  36. package/dist/endpoints/posts.d.ts.map +0 -1
  37. package/dist/endpoints/profile.d.ts +0 -34
  38. package/dist/endpoints/profile.d.ts.map +0 -1
  39. package/dist/endpoints/recommendation.d.ts +0 -10
  40. package/dist/endpoints/recommendation.d.ts.map +0 -1
  41. package/dist/endpoints/screener.d.ts +0 -45
  42. package/dist/endpoints/screener.d.ts.map +0 -1
  43. package/dist/endpoints/search.d.ts +0 -18
  44. package/dist/endpoints/search.d.ts.map +0 -1
  45. package/dist/endpoints/trades.d.ts +0 -31
  46. package/dist/endpoints/trades.d.ts.map +0 -1
  47. package/dist/endpoints/usage.d.ts +0 -11
  48. package/dist/endpoints/usage.d.ts.map +0 -1
  49. package/dist/endpoints/watchlists.d.ts +0 -64
  50. package/dist/endpoints/watchlists.d.ts.map +0 -1
  51. package/dist/index.esm.js +0 -1054
  52. package/dist/index.esm.js.map +0 -1
  53. package/dist/invezgo.d.ts +0 -40
  54. package/dist/invezgo.d.ts.map +0 -1
  55. package/dist/types.d.ts +0 -574
  56. package/dist/types.d.ts.map +0 -1
package/dist/index.esm.js DELETED
@@ -1,1054 +0,0 @@
1
- class InvezgoError extends Error {
2
- constructor(statusCode, message, error, response) {
3
- super(message);
4
- this.statusCode = statusCode;
5
- this.message = message;
6
- this.error = error;
7
- this.response = response;
8
- this.name = 'InvezgoError';
9
- Object.setPrototypeOf(this, InvezgoError.prototype);
10
- }
11
- }
12
- class HttpClient {
13
- constructor(config) {
14
- // Ensure baseURL doesn't have trailing slash since paths start with /
15
- const baseURL = config.baseURL || 'https://api.invezgo.com';
16
- this.baseURL = baseURL.endsWith('/') ? baseURL.slice(0, -1) : baseURL;
17
- this.apiKey = config.apiKey;
18
- this.timeout = config.timeout || 30000;
19
- if (!this.apiKey) {
20
- throw new Error('API Key is required');
21
- }
22
- }
23
- async request(method, path, options = {}) {
24
- const url = `${this.baseURL}${path}`;
25
- const controller = new AbortController();
26
- const timeoutId = setTimeout(() => controller.abort(), options.timeout || this.timeout);
27
- try {
28
- const headers = {
29
- 'Authorization': `Bearer ${this.apiKey}`,
30
- 'Content-Type': 'application/json',
31
- ...options.headers,
32
- };
33
- const response = await fetch(url, {
34
- method,
35
- headers,
36
- signal: controller.signal,
37
- });
38
- clearTimeout(timeoutId);
39
- // Handle 204 No Content
40
- if (response.status === 204) {
41
- return [];
42
- }
43
- const data = await response.json().catch(() => ({}));
44
- // Handle error responses
45
- if (!response.ok) {
46
- throw new InvezgoError(response.status, data?.message || response.statusText, data?.error, data);
47
- }
48
- return data;
49
- }
50
- catch (error) {
51
- clearTimeout(timeoutId);
52
- if (error.name === 'AbortError') {
53
- throw new InvezgoError(408, 'Request timeout', 'Timeout');
54
- }
55
- if (error instanceof InvezgoError) {
56
- throw error;
57
- }
58
- throw new InvezgoError(500, error.message || 'Unknown error occurred', 'InternalError', error);
59
- }
60
- }
61
- async get(path, params, options) {
62
- let url = path;
63
- if (params && Object.keys(params).length > 0) {
64
- const searchParams = new URLSearchParams();
65
- Object.entries(params).forEach(([key, value]) => {
66
- if (value !== undefined && value !== null) {
67
- if (Array.isArray(value)) {
68
- value.forEach(v => searchParams.append(key, String(v)));
69
- }
70
- else {
71
- searchParams.append(key, String(value));
72
- }
73
- }
74
- });
75
- url = `${path}?${searchParams.toString()}`;
76
- }
77
- return this.request('GET', url, options);
78
- }
79
- async post(path, body, options) {
80
- const requestOptions = {
81
- ...options,
82
- headers: {
83
- ...options?.headers,
84
- },
85
- };
86
- const controller = new AbortController();
87
- const timeoutId = setTimeout(() => controller.abort(), requestOptions.timeout || this.timeout);
88
- try {
89
- const url = `${this.baseURL}${path}`;
90
- const headers = {
91
- 'Authorization': `Bearer ${this.apiKey}`,
92
- 'Content-Type': 'application/json',
93
- ...requestOptions.headers,
94
- };
95
- const response = await fetch(url, {
96
- method: 'POST',
97
- headers,
98
- body: body ? JSON.stringify(body) : undefined,
99
- signal: controller.signal,
100
- });
101
- clearTimeout(timeoutId);
102
- if (response.status === 204) {
103
- return {};
104
- }
105
- const data = await response.json().catch(() => ({}));
106
- if (!response.ok) {
107
- throw new InvezgoError(response.status, data?.message || response.statusText, data?.error, data);
108
- }
109
- return data;
110
- }
111
- catch (error) {
112
- clearTimeout(timeoutId);
113
- if (error.name === 'AbortError') {
114
- throw new InvezgoError(408, 'Request timeout', 'Timeout');
115
- }
116
- if (error instanceof InvezgoError) {
117
- throw error;
118
- }
119
- throw new InvezgoError(500, error.message || 'Unknown error occurred', 'InternalError', error);
120
- }
121
- }
122
- async put(path, body, options) {
123
- const controller = new AbortController();
124
- const timeoutId = setTimeout(() => controller.abort(), options?.timeout || this.timeout);
125
- try {
126
- const url = `${this.baseURL}${path}`;
127
- const headers = {
128
- 'Authorization': `Bearer ${this.apiKey}`,
129
- 'Content-Type': 'application/json',
130
- ...options?.headers,
131
- };
132
- const response = await fetch(url, {
133
- method: 'PUT',
134
- headers,
135
- body: body ? JSON.stringify(body) : undefined,
136
- signal: controller.signal,
137
- });
138
- clearTimeout(timeoutId);
139
- if (response.status === 204) {
140
- return {};
141
- }
142
- const data = await response.json().catch(() => ({}));
143
- if (!response.ok) {
144
- throw new InvezgoError(response.status, data?.message || response.statusText, data?.error, data);
145
- }
146
- return data;
147
- }
148
- catch (error) {
149
- clearTimeout(timeoutId);
150
- if (error.name === 'AbortError') {
151
- throw new InvezgoError(408, 'Request timeout', 'Timeout');
152
- }
153
- if (error instanceof InvezgoError) {
154
- throw error;
155
- }
156
- throw new InvezgoError(500, error.message || 'Unknown error occurred', 'InternalError', error);
157
- }
158
- }
159
- async patch(path, body, options) {
160
- const controller = new AbortController();
161
- const timeoutId = setTimeout(() => controller.abort(), options?.timeout || this.timeout);
162
- try {
163
- const url = `${this.baseURL}${path}`;
164
- const headers = {
165
- 'Authorization': `Bearer ${this.apiKey}`,
166
- 'Content-Type': 'application/json',
167
- ...options?.headers,
168
- };
169
- const response = await fetch(url, {
170
- method: 'PATCH',
171
- headers,
172
- body: body ? JSON.stringify(body) : undefined,
173
- signal: controller.signal,
174
- });
175
- clearTimeout(timeoutId);
176
- if (response.status === 204) {
177
- return {};
178
- }
179
- const data = await response.json().catch(() => ({}));
180
- if (!response.ok) {
181
- throw new InvezgoError(response.status, data?.message || response.statusText, data?.error, data);
182
- }
183
- return data;
184
- }
185
- catch (error) {
186
- clearTimeout(timeoutId);
187
- if (error.name === 'AbortError') {
188
- throw new InvezgoError(408, 'Request timeout', 'Timeout');
189
- }
190
- if (error instanceof InvezgoError) {
191
- throw error;
192
- }
193
- throw new InvezgoError(500, error.message || 'Unknown error occurred', 'InternalError', error);
194
- }
195
- }
196
- async delete(path, params, options) {
197
- let url = path;
198
- if (params && Object.keys(params).length > 0) {
199
- const searchParams = new URLSearchParams();
200
- Object.entries(params).forEach(([key, value]) => {
201
- if (value !== undefined && value !== null) {
202
- if (Array.isArray(value)) {
203
- value.forEach(v => searchParams.append(key, String(v)));
204
- }
205
- else {
206
- searchParams.append(key, String(value));
207
- }
208
- }
209
- });
210
- url = `${path}?${searchParams.toString()}`;
211
- }
212
- return this.request('DELETE', url, options);
213
- }
214
- }
215
-
216
- class AlertsEndpoints {
217
- constructor(client) {
218
- this.client = client;
219
- }
220
- /**
221
- * Get list of alerts.
222
- */
223
- async list() {
224
- return this.client.get('/alerts');
225
- }
226
- /**
227
- * Create alert.
228
- */
229
- async add(dto) {
230
- return this.client.post('/alerts', dto);
231
- }
232
- /**
233
- * Update alert.
234
- */
235
- async update(id, dto) {
236
- return this.client.put(`/alerts/${id}`, dto);
237
- }
238
- /**
239
- * Delete alert.
240
- */
241
- async delete(id) {
242
- return this.client.delete(`/alerts/${id}`);
243
- }
244
- /**
245
- * Test alert formula.
246
- */
247
- async test(dto) {
248
- return this.client.post('/alerts/test', dto);
249
- }
250
- }
251
-
252
- class AnalysisEndpoints {
253
- constructor(client) {
254
- this.client = client;
255
- }
256
- /**
257
- * Get list of all stocks listed on BEI.
258
- */
259
- async getStockList() {
260
- return this.client.get('/analysis/list/stock');
261
- }
262
- /**
263
- * Get list of all brokers/securities on BEI.
264
- */
265
- async getBrokerList() {
266
- return this.client.get('/analysis/list/broker');
267
- }
268
- /**
269
- * Get list of all supported IDX indexes.
270
- */
271
- async getIndexList() {
272
- return this.client.get('/analysis/list/index');
273
- }
274
- /**
275
- * Get complete company information.
276
- */
277
- async getInformation(code) {
278
- return this.client.get(`/analysis/information/${code}`);
279
- }
280
- /**
281
- * Get top gainer and loser stocks for a specific date.
282
- */
283
- async getTopChange(date) {
284
- return this.client.get('/analysis/top/change', { date });
285
- }
286
- /**
287
- * Get top foreign accumulation and distribution.
288
- */
289
- async getTopForeign(date) {
290
- return this.client.get('/analysis/top/foreign', { date });
291
- }
292
- /**
293
- * Get top bandarmology accumulation and distribution.
294
- */
295
- async getTopAccumulation(date) {
296
- return this.client.get('/analysis/top/accumulation', { date });
297
- }
298
- /**
299
- * Get top retail accumulation and distribution.
300
- */
301
- async getTopRitel(date) {
302
- return this.client.get('/analysis/top/ritel', { date });
303
- }
304
- /**
305
- * Alias for getTopRitel.
306
- */
307
- async getTopRetail(date) {
308
- return this.getTopRitel(date);
309
- }
310
- /**
311
- * Get intraday chart data.
312
- */
313
- async getIntradayChart(code, market = 'RG') {
314
- return this.client.get(`/analysis/intraday/${code}`, { market });
315
- }
316
- /**
317
- * Get intraday stock summary data.
318
- */
319
- async getIntradayData(code, market = 'RG') {
320
- return this.client.get(`/analysis/intraday-data/${code}`, { market });
321
- }
322
- /**
323
- * Get intraday index summary data.
324
- */
325
- async getIntradayIndex(code, market = 'RG') {
326
- return this.client.get(`/analysis/intraday-index/${code}`, { market });
327
- }
328
- /**
329
- * Get order book data.
330
- */
331
- async getOrderBook(code, market = 'RG') {
332
- return this.client.get(`/analysis/order-book/${code}`, { market });
333
- }
334
- /**
335
- * Get complete stock chart data.
336
- */
337
- async getChart(code, params) {
338
- return this.client.get(`/analysis/chart/stock/${code}`, params);
339
- }
340
- /**
341
- * Get historical index chart data.
342
- */
343
- async getIndexChart(code, params) {
344
- return this.client.get(`/analysis/chart/index/${code}`, params);
345
- }
346
- /**
347
- * Get stock chart with technical indicator.
348
- */
349
- async getIndicatorChart(code, indicator, params) {
350
- return this.client.get(`/analysis/chart/stock/${indicator}/${code}`, params);
351
- }
352
- /**
353
- * Get shareholder detail above 5%.
354
- */
355
- async getShareholderDetail(code) {
356
- return this.client.get(`/analysis/shareholder-detail/${code}`);
357
- }
358
- /**
359
- * Get shareholder detail above 1% for a specific holder.
360
- */
361
- async getShareholderDetailOne(params) {
362
- return this.client.get('/analysis/shareholder-detail-one', params);
363
- }
364
- /**
365
- * Get number of shareholders.
366
- */
367
- async getShareholderNumber(code) {
368
- return this.client.get(`/analysis/shareholder/number/${code}`);
369
- }
370
- /**
371
- * Get shareholder relation graph.
372
- */
373
- async getShareholderRelation(params) {
374
- return this.client.get('/analysis/shareholder/relation', params);
375
- }
376
- /**
377
- * Get shareholder composition.
378
- */
379
- async getShareholder(code) {
380
- return this.client.get(`/analysis/shareholder/${code}`);
381
- }
382
- /**
383
- * Get KSEI shareholder data.
384
- */
385
- async getShareholderKSEI(code, range) {
386
- return this.client.get(`/analysis/shareholder/ksei/${code}`, {
387
- range: Math.min(range, 12),
388
- });
389
- }
390
- /**
391
- * Get broker summary for a stock.
392
- */
393
- async getBrokerSummaryStock(code, params) {
394
- return this.client.get(`/analysis/summary/stock/${code}`, params);
395
- }
396
- /**
397
- * Get broker summary for a broker.
398
- */
399
- async getBrokerSummaryBroker(code, params) {
400
- return this.client.get(`/analysis/summary/broker/${code}`, params);
401
- }
402
- /**
403
- * Get sector stalker data.
404
- */
405
- async getStalkerSector(params) {
406
- return this.client.get('/analysis/stalker/sector', params);
407
- }
408
- /**
409
- * Get sector rotation chart.
410
- */
411
- async getSectorRotation(params) {
412
- return this.client.get('/analysis/sector/rotation', params);
413
- }
414
- /**
415
- * Get broker stalker data for a stock.
416
- */
417
- async getBrokerStalker(broker, stock, params) {
418
- return this.client.get(`/analysis/stalker/broker/${broker}/${stock}`, params);
419
- }
420
- /**
421
- * Get broker stalker list.
422
- */
423
- async getBrokerStalkerList(code, params) {
424
- return this.client.get(`/analysis/stalker/list/${code}`, params);
425
- }
426
- /**
427
- * Get broker summary chart for a stock.
428
- */
429
- async getBrokerSummaryChartStock(code, params) {
430
- return this.client.get(`/analysis/summary-chart/stock/${code}`, params);
431
- }
432
- /**
433
- * Get broker summary chart for a broker.
434
- */
435
- async getBrokerSummaryChartBroker(code, params) {
436
- return this.client.get(`/analysis/summary-chart/broker/${code}`, params);
437
- }
438
- /**
439
- * Get inventory chart for a stock.
440
- */
441
- async getInventoryChartStock(code, params) {
442
- return this.client.get(`/analysis/inventory-chart/stock/${code}`, params);
443
- }
444
- /**
445
- * Get inventory chart for a broker.
446
- */
447
- async getInventoryChartBroker(code, params) {
448
- return this.client.get(`/analysis/inventory-chart/broker/${code}`, params);
449
- }
450
- /**
451
- * Get momentum chart.
452
- */
453
- async getMomentumChart(code, params) {
454
- return this.client.get(`/analysis/momentum-chart/${code}`, params);
455
- }
456
- /**
457
- * Get intraday inventory chart.
458
- */
459
- async getIntradayInventoryChart(code, params) {
460
- return this.client.get(`/analysis/intraday-inventory-chart/${code}`, params);
461
- }
462
- /**
463
- * Get distribution or crossing chart.
464
- */
465
- async getSankeyChart(code, params) {
466
- return this.client.get(`/analysis/sankey-chart/${code}`, params);
467
- }
468
- /**
469
- * Get price table.
470
- */
471
- async getPriceTable(code, date) {
472
- return this.client.get(`/analysis/price-table/${code}`, { date });
473
- }
474
- /**
475
- * Get time table.
476
- */
477
- async getTimeTable(code, params) {
478
- return this.client.get(`/analysis/time-table/${code}`, params);
479
- }
480
- /**
481
- * Get price diary.
482
- */
483
- async getPriceDiary(code) {
484
- return this.client.get(`/analysis/price-diary/${code}`);
485
- }
486
- /**
487
- * Get price seasonality.
488
- */
489
- async getPriceSeasonality(code, range) {
490
- return this.client.get(`/analysis/price-seasonality/${code}`, {
491
- range: Math.min(range, 60),
492
- });
493
- }
494
- /**
495
- * Get shareholders above 5%.
496
- */
497
- async getShareholderAbove(params) {
498
- return this.client.get('/analysis/shareholder-above', params);
499
- }
500
- /**
501
- * Get shareholder above 5% chart.
502
- */
503
- async getShareholderAboveChart(code, params) {
504
- return this.client.get(`/analysis/shareholder-above-chart/${code}`, params);
505
- }
506
- /**
507
- * Get shareholders above 1%.
508
- */
509
- async getShareholderOne(params) {
510
- return this.client.get('/analysis/shareholder-one', params);
511
- }
512
- /**
513
- * Get shareholder above 1% chart.
514
- */
515
- async getShareholderOneChart(code, params) {
516
- return this.client.get(`/analysis/shareholder-one-chart/${code}`, params);
517
- }
518
- /**
519
- * Get insider trading data.
520
- */
521
- async getInsiderTrading(params) {
522
- return this.client.get('/analysis/shareholder-insider', params);
523
- }
524
- /**
525
- * Get insider chart.
526
- */
527
- async getInsiderChart(code, params) {
528
- return this.client.get(`/analysis/insider-chart/${code}`, params);
529
- }
530
- /**
531
- * Get financial statement.
532
- */
533
- async getFinancialStatement(code, params) {
534
- return this.client.get(`/analysis/financial-statement/${code}`, { ...params, limit: Math.min(params.limit, 20) });
535
- }
536
- /**
537
- * Get financial statement chart.
538
- */
539
- async getFinancialStatementChart(code, params) {
540
- return this.client.get(`/analysis/financial-statement-chart/${code}`, { ...params, limit: Math.min(params.limit, 20) });
541
- }
542
- /**
543
- * Get key statistics.
544
- */
545
- async getKeyStat(code, params) {
546
- return this.client.get(`/analysis/keystat/${code}`, {
547
- ...params,
548
- limit: Math.min(params.limit, 20),
549
- });
550
- }
551
- /**
552
- * Get key statistics chart.
553
- */
554
- async getKeyStatChart(code, params) {
555
- return this.client.get(`/analysis/keystat-chart/${code}`, {
556
- ...params,
557
- limit: Math.min(params.limit, 20),
558
- });
559
- }
560
- /**
561
- * Get corporate action calendar.
562
- */
563
- async getCalendar(params) {
564
- return this.client.get('/analysis/calendar', params);
565
- }
566
- /**
567
- * Alias for getCalendar.
568
- */
569
- async getCorporateActionCalendar(params) {
570
- return this.getCalendar(params);
571
- }
572
- /**
573
- * Get multi-timeframe chart data for stocks or indexes.
574
- */
575
- async getMultiTimeChart(code, params) {
576
- return this.client.get(`/analysis/chart/multi-time/${code}`, params);
577
- }
578
- /**
579
- * Get high concentration stock ownership data for all issuers.
580
- */
581
- async getShareholderHigh() {
582
- return this.client.get('/analysis/shareholder/high');
583
- }
584
- /**
585
- * Get complete shareholder data with all investor classifications for a specific period.
586
- */
587
- async getShareholderClassification(code, range) {
588
- return this.client.get(`/analysis/shareholder/classification/${code}`, { range: Math.min(range, 36) });
589
- }
590
- /**
591
- * Get latest shareholder data with investor classifications in table format.
592
- */
593
- async getShareholderClassifyTable(code) {
594
- return this.client.get(`/analysis/shareholder/classify-table/${code}`);
595
- }
596
- /**
597
- * Get order queue (order tracking) for a stock at a specific price, side, page, and limit.
598
- */
599
- async getOrderQueue(code, params) {
600
- return this.client.get(`/analysis/queue/${code}`, params);
601
- }
602
- }
603
-
604
- class WatchlistsEndpoints {
605
- constructor(client) {
606
- this.client = client;
607
- }
608
- /**
609
- * Get list of watchlists.
610
- */
611
- async list(group = 'null') {
612
- return this.client.get('/watchlists', { group });
613
- }
614
- /**
615
- * Add stock to watchlist.
616
- */
617
- async add(dto) {
618
- return this.client.post('/watchlists', dto);
619
- }
620
- /**
621
- * Delete watchlist entries.
622
- *
623
- * The current OpenAPI spec does not describe delete filters,
624
- * but the SDK keeps optional query params for batch deletion support.
625
- */
626
- async delete(params) {
627
- return this.client.delete('/watchlists', params);
628
- }
629
- /**
630
- * Get list of watchlist groups.
631
- */
632
- async listGroups() {
633
- return this.client.get('/watchlists/group');
634
- }
635
- /**
636
- * Add new watchlist group.
637
- */
638
- async addGroup(dto) {
639
- return this.client.post('/watchlists/group', dto);
640
- }
641
- /**
642
- * Update watchlist group.
643
- */
644
- async updateGroup(id, dto) {
645
- return this.client.put(`/watchlists/group/${id}`, dto);
646
- }
647
- /**
648
- * Delete watchlist group.
649
- */
650
- async deleteGroup(id) {
651
- return this.client.delete(`/watchlists/group/${id}`);
652
- }
653
- /**
654
- * Update watchlist.
655
- */
656
- async update(id, dto) {
657
- return this.client.put(`/watchlists/${id}`, dto);
658
- }
659
- /**
660
- * Update watchlist note.
661
- */
662
- async updateNote(id, dto) {
663
- return this.client.patch(`/watchlists/${id}`, dto);
664
- }
665
- }
666
-
667
- class JournalsEndpoints {
668
- constructor(client) {
669
- this.client = client;
670
- }
671
- /**
672
- * Extract journal transactions from uploaded file.
673
- */
674
- async extractFromFile(file) {
675
- const formData = new FormData();
676
- formData.append('file', file);
677
- const url = `${this.client.baseURL}/journals/file`;
678
- const response = await fetch(url, {
679
- method: 'POST',
680
- headers: {
681
- Authorization: `Bearer ${this.client.apiKey}`,
682
- },
683
- body: formData,
684
- });
685
- if (!response.ok) {
686
- const data = (await response.json().catch(() => ({})));
687
- throw new InvezgoError(response.status, data.message || 'Failed to extract journal from file', data.error, data);
688
- }
689
- return response.json().catch(() => ({}));
690
- }
691
- /**
692
- * Add new journal transaction.
693
- */
694
- async add(dto) {
695
- return this.client.post('/journals', dto);
696
- }
697
- /**
698
- * List journal transactions.
699
- */
700
- async list() {
701
- return this.client.get('/journals');
702
- }
703
- /**
704
- * Delete journal entries.
705
- *
706
- * The current OpenAPI spec does not describe delete filters,
707
- * but the SDK keeps optional query params for batch deletion support.
708
- */
709
- async delete(params) {
710
- return this.client.delete('/journals', params);
711
- }
712
- /**
713
- * Get journal transactions summary.
714
- */
715
- async getSummary() {
716
- return this.client.get('/journals/summary');
717
- }
718
- /**
719
- * Update journal transaction note.
720
- */
721
- async updateNote(id, dto) {
722
- return this.client.patch(`/journals/${id}`, dto);
723
- }
724
- }
725
-
726
- class PortfoliosEndpoints {
727
- constructor(client) {
728
- this.client = client;
729
- }
730
- /**
731
- * Get list of portfolios
732
- */
733
- async list() {
734
- return this.client.get('/portfolios');
735
- }
736
- /**
737
- * Get portfolio summary
738
- */
739
- async getSummary() {
740
- return this.client.get('/portfolios/summary');
741
- }
742
- }
743
-
744
- class SearchEndpoints {
745
- constructor(client) {
746
- this.client = client;
747
- }
748
- /**
749
- * Search for stocks or users
750
- */
751
- async search(query) {
752
- return this.client.get('/search', { query });
753
- }
754
- /**
755
- * Search for stocks
756
- */
757
- async searchStock(query, cursor) {
758
- return this.client.get('/search/stock', { query, cursor });
759
- }
760
- /**
761
- * Search for users
762
- */
763
- async searchUser(query, cursor) {
764
- return this.client.get('/search/user', { query, cursor });
765
- }
766
- }
767
-
768
- class ProfileEndpoints {
769
- constructor(client) {
770
- this.client = client;
771
- }
772
- /**
773
- * Get user profile details
774
- */
775
- async getUserDetails(username) {
776
- return this.client.get(`/profile/detail/${username}`);
777
- }
778
- /**
779
- * Get user posts
780
- */
781
- async getUserPosts(username, page, limit) {
782
- return this.client.get(`/profile/posts/${username}`, { page, limit });
783
- }
784
- /**
785
- * Get user posts by category
786
- */
787
- async getCategoryPosts(username, category, page, limit) {
788
- return this.client.get(`/profile/posts/${username}/${category}`, { page, limit });
789
- }
790
- /**
791
- * Get user watchlist
792
- */
793
- async getUserWatchlist(username) {
794
- return this.client.get(`/profile/watchlist/${username}`);
795
- }
796
- /**
797
- * Get user followers
798
- */
799
- async getFollowers(username) {
800
- return this.client.get(`/profile/follow/${username}`);
801
- }
802
- /**
803
- * Get users being followed
804
- */
805
- async getFollowing(username) {
806
- return this.client.get(`/profile/following/${username}`);
807
- }
808
- /**
809
- * Get user memberships
810
- */
811
- async getMemberships(username) {
812
- return this.client.get(`/profile/membership/${username}`);
813
- }
814
- }
815
-
816
- class MembershipEndpoints {
817
- constructor(client) {
818
- this.client = client;
819
- }
820
- /**
821
- * Get list of memberships.
822
- */
823
- async list() {
824
- return this.client.get('/membership');
825
- }
826
- /**
827
- * Add new membership.
828
- */
829
- async add(dto) {
830
- return this.client.post('/membership', dto);
831
- }
832
- /**
833
- * Get membership scopes.
834
- */
835
- async getScope() {
836
- return this.client.get('/membership/scope');
837
- }
838
- /**
839
- * Get membership transactions.
840
- */
841
- async getTransactions() {
842
- return this.client.get('/membership/list');
843
- }
844
- /**
845
- * Update membership.
846
- */
847
- async update(id, dto) {
848
- return this.client.put(`/membership/${id}`, dto);
849
- }
850
- /**
851
- * Delete membership.
852
- */
853
- async delete(id) {
854
- return this.client.delete(`/membership/${id}`);
855
- }
856
- }
857
-
858
- class PostsEndpoints {
859
- constructor(client) {
860
- this.client = client;
861
- }
862
- /**
863
- * Get all posts
864
- */
865
- async getAll() {
866
- return this.client.get('/posts');
867
- }
868
- /**
869
- * Get posts by category
870
- */
871
- async getByCategory(category) {
872
- return this.client.get(`/posts/category/${category}`);
873
- }
874
- /**
875
- * Get posts for a stock
876
- */
877
- async getStockPosts(code) {
878
- return this.client.get(`/posts/space/${code}`);
879
- }
880
- /**
881
- * Get stock posts by category
882
- */
883
- async getStockCategoryPosts(code, category) {
884
- return this.client.get(`/posts/space/category/${code}/${category}`);
885
- }
886
- /**
887
- * Get post details
888
- */
889
- async getPostById(id) {
890
- return this.client.get(`/posts/detail/${id}`);
891
- }
892
- /**
893
- * Get post comments
894
- */
895
- async getComments(id) {
896
- return this.client.get(`/posts/comment/${id}`);
897
- }
898
- /**
899
- * Get liked posts
900
- */
901
- async getLiked() {
902
- return this.client.get('/posts/like');
903
- }
904
- /**
905
- * Get favorite posts
906
- */
907
- async getFavorites() {
908
- return this.client.get('/posts/favorite');
909
- }
910
- /**
911
- * Get post voters
912
- */
913
- async getVoters(id) {
914
- return this.client.get(`/posts/vote/${id}`);
915
- }
916
- }
917
-
918
- class RecommendationEndpoints {
919
- constructor(client) {
920
- this.client = client;
921
- }
922
- /**
923
- * Get user recommendations.
924
- */
925
- async getUserRecommendations() {
926
- return this.client.get('/recommendation/user');
927
- }
928
- }
929
-
930
- class TradesEndpoints {
931
- constructor(client) {
932
- this.client = client;
933
- }
934
- /**
935
- * Get list of realized trades
936
- */
937
- async list() {
938
- return this.client.get('/trades');
939
- }
940
- /**
941
- * Delete trades
942
- */
943
- async delete(params) {
944
- return this.client.delete('/trades', params);
945
- }
946
- /**
947
- * Get trades summary
948
- */
949
- async getSummary() {
950
- return this.client.get('/trades/summary');
951
- }
952
- /**
953
- * Get trades summary chart
954
- */
955
- async getSummaryChart() {
956
- return this.client.get('/trades/summary-chart');
957
- }
958
- /**
959
- * Update trade note
960
- */
961
- async updateNote(id, dto) {
962
- return this.client.patch(`/trades/${id}`, dto);
963
- }
964
- }
965
-
966
- class ScreenerEndpoints {
967
- constructor(client) {
968
- this.client = client;
969
- }
970
- /**
971
- * Get list of preset screeners.
972
- */
973
- async list() {
974
- return this.client.get('/screener');
975
- }
976
- /**
977
- * Save preset screener.
978
- */
979
- async save(dto) {
980
- return this.client.post('/screener', dto);
981
- }
982
- /**
983
- * Update preset screener.
984
- */
985
- async update(id, dto) {
986
- return this.client.put(`/screener/${id}`, dto);
987
- }
988
- /**
989
- * Delete preset screener.
990
- */
991
- async delete(id) {
992
- return this.client.delete(`/screener/${id}`);
993
- }
994
- /**
995
- * Run screener.
996
- */
997
- async screen(dto) {
998
- return this.client.post('/screener/screen', dto);
999
- }
1000
- }
1001
-
1002
- class UsageEndpoints {
1003
- constructor(client) {
1004
- this.client = client;
1005
- }
1006
- /**
1007
- * Get API usage statistics for the configured API key.
1008
- */
1009
- async getApiUsage() {
1010
- return this.client.get('/usage/api');
1011
- }
1012
- }
1013
-
1014
- class Invezgo {
1015
- constructor(config) {
1016
- this.client = new HttpClient(config);
1017
- this.alerts = new AlertsEndpoints(this.client);
1018
- this.analysis = new AnalysisEndpoints(this.client);
1019
- this.watchlists = new WatchlistsEndpoints(this.client);
1020
- this.journals = new JournalsEndpoints(this.client);
1021
- this.portfolios = new PortfoliosEndpoints(this.client);
1022
- this.search = new SearchEndpoints(this.client);
1023
- this.profile = new ProfileEndpoints(this.client);
1024
- this.membership = new MembershipEndpoints(this.client);
1025
- this.posts = new PostsEndpoints(this.client);
1026
- this.recommendation = new RecommendationEndpoints(this.client);
1027
- this.trades = new TradesEndpoints(this.client);
1028
- this.screener = new ScreenerEndpoints(this.client);
1029
- this.usage = new UsageEndpoints(this.client);
1030
- }
1031
- /**
1032
- * Update API key.
1033
- */
1034
- setApiKey(apiKey) {
1035
- this.client.apiKey = apiKey;
1036
- }
1037
- /**
1038
- * Check whether an API key is currently configured.
1039
- */
1040
- hasApiKey() {
1041
- return !!this.client.apiKey;
1042
- }
1043
- }
1044
-
1045
- /**
1046
- * Invezgo SDK for JavaScript and TypeScript.
1047
- *
1048
- * Official SDK for accessing Invezgo API.
1049
- *
1050
- * @packageDocumentation
1051
- */
1052
-
1053
- export { AlertsEndpoints, Invezgo, InvezgoError, JournalsEndpoints, MembershipEndpoints, RecommendationEndpoints, ScreenerEndpoints, TradesEndpoints, UsageEndpoints, WatchlistsEndpoints, Invezgo as default };
1054
- //# sourceMappingURL=index.esm.js.map