reportify-sdk 0.2.8 → 0.2.9
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.mts +628 -145
- package/dist/index.d.ts +628 -145
- package/dist/index.js +950 -260
- package/dist/index.mjs +945 -259
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -45,11 +45,17 @@ var StockModule = class {
|
|
|
45
45
|
* Get list of major shareholders
|
|
46
46
|
*
|
|
47
47
|
* @param symbol - Stock symbol
|
|
48
|
+
* @param options.type - Type of shareholders ('shareholders' or 'outstanding_shareholders')
|
|
49
|
+
* @param options.limit - Number of results to return (default: 10)
|
|
48
50
|
*/
|
|
49
|
-
async shareholders(symbol) {
|
|
51
|
+
async shareholders(symbol, options = {}) {
|
|
50
52
|
const response = await this.client.post(
|
|
51
53
|
"/v1/stock/company-shareholders",
|
|
52
|
-
{
|
|
54
|
+
{
|
|
55
|
+
symbol,
|
|
56
|
+
type: options.type || "shareholders",
|
|
57
|
+
limit: options.limit || 10
|
|
58
|
+
}
|
|
53
59
|
);
|
|
54
60
|
return Array.isArray(response) ? response : response.shareholders || [];
|
|
55
61
|
}
|
|
@@ -60,17 +66,28 @@ var StockModule = class {
|
|
|
60
66
|
* Get income statement data
|
|
61
67
|
*
|
|
62
68
|
* @param symbol - Stock symbol
|
|
63
|
-
* @param options.period - "annual" or "quarterly"
|
|
64
|
-
* @param options.limit - Number of periods to return
|
|
69
|
+
* @param options.period - "annual", "quarterly", or "cumulative quarterly"
|
|
70
|
+
* @param options.limit - Number of periods to return (default: 8)
|
|
71
|
+
* @param options.startDate - Start date (YYYY-MM-DD)
|
|
72
|
+
* @param options.endDate - End date (YYYY-MM-DD)
|
|
73
|
+
* @param options.calendar - "calendar" or "fiscal" (default: "fiscal")
|
|
74
|
+
* @param options.fiscalYear - Specific fiscal year (e.g., "2023")
|
|
75
|
+
* @param options.fiscalQuarter - Specific fiscal quarter (Q1, Q2, Q3, Q4, FY, H1)
|
|
65
76
|
*/
|
|
66
77
|
async incomeStatement(symbol, options = {}) {
|
|
78
|
+
const body = {
|
|
79
|
+
symbol,
|
|
80
|
+
period: options.period || "annual",
|
|
81
|
+
limit: options.limit || 8,
|
|
82
|
+
calendar: options.calendar || "fiscal"
|
|
83
|
+
};
|
|
84
|
+
if (options.startDate) body.start_date = options.startDate;
|
|
85
|
+
if (options.endDate) body.end_date = options.endDate;
|
|
86
|
+
if (options.fiscalYear) body.fiscal_year = options.fiscalYear;
|
|
87
|
+
if (options.fiscalQuarter) body.fiscal_quarter = options.fiscalQuarter;
|
|
67
88
|
const response = await this.client.post(
|
|
68
89
|
"/v1/stock/company-income-statement",
|
|
69
|
-
|
|
70
|
-
symbol,
|
|
71
|
-
period: options.period || "annual",
|
|
72
|
-
limit: options.limit || 10
|
|
73
|
-
}
|
|
90
|
+
body
|
|
74
91
|
);
|
|
75
92
|
return this.normalizeArrayResponse(response);
|
|
76
93
|
}
|
|
@@ -79,16 +96,27 @@ var StockModule = class {
|
|
|
79
96
|
*
|
|
80
97
|
* @param symbol - Stock symbol
|
|
81
98
|
* @param options.period - "annual" or "quarterly"
|
|
82
|
-
* @param options.limit - Number of periods to return
|
|
99
|
+
* @param options.limit - Number of periods to return (default: 8)
|
|
100
|
+
* @param options.startDate - Start date (YYYY-MM-DD)
|
|
101
|
+
* @param options.endDate - End date (YYYY-MM-DD)
|
|
102
|
+
* @param options.calendar - "calendar" or "fiscal" (default: "fiscal")
|
|
103
|
+
* @param options.fiscalYear - Specific fiscal year (e.g., "2023")
|
|
104
|
+
* @param options.fiscalQuarter - Specific fiscal quarter (Q1, Q2, Q3, Q4, FY)
|
|
83
105
|
*/
|
|
84
106
|
async balanceSheet(symbol, options = {}) {
|
|
107
|
+
const body = {
|
|
108
|
+
symbol,
|
|
109
|
+
period: options.period || "annual",
|
|
110
|
+
limit: options.limit || 8,
|
|
111
|
+
calendar: options.calendar || "fiscal"
|
|
112
|
+
};
|
|
113
|
+
if (options.startDate) body.start_date = options.startDate;
|
|
114
|
+
if (options.endDate) body.end_date = options.endDate;
|
|
115
|
+
if (options.fiscalYear) body.fiscal_year = options.fiscalYear;
|
|
116
|
+
if (options.fiscalQuarter) body.fiscal_quarter = options.fiscalQuarter;
|
|
85
117
|
const response = await this.client.post(
|
|
86
118
|
"/v1/stock/company-balance-sheet",
|
|
87
|
-
|
|
88
|
-
symbol,
|
|
89
|
-
period: options.period || "annual",
|
|
90
|
-
limit: options.limit || 10
|
|
91
|
-
}
|
|
119
|
+
body
|
|
92
120
|
);
|
|
93
121
|
return this.normalizeArrayResponse(response);
|
|
94
122
|
}
|
|
@@ -96,33 +124,51 @@ var StockModule = class {
|
|
|
96
124
|
* Get cash flow statement data
|
|
97
125
|
*
|
|
98
126
|
* @param symbol - Stock symbol
|
|
99
|
-
* @param options.period - "annual" or "quarterly"
|
|
100
|
-
* @param options.limit - Number of periods to return
|
|
127
|
+
* @param options.period - "annual", "quarterly", or "cumulative quarterly"
|
|
128
|
+
* @param options.limit - Number of periods to return (default: 8)
|
|
129
|
+
* @param options.startDate - Start date (YYYY-MM-DD)
|
|
130
|
+
* @param options.endDate - End date (YYYY-MM-DD)
|
|
131
|
+
* @param options.calendar - "calendar" or "fiscal" (default: "fiscal")
|
|
132
|
+
* @param options.fiscalYear - Specific fiscal year (e.g., "2023")
|
|
133
|
+
* @param options.fiscalQuarter - Specific fiscal quarter (Q1, Q2, Q3, Q4, FY, H1)
|
|
101
134
|
*/
|
|
102
135
|
async cashflowStatement(symbol, options = {}) {
|
|
136
|
+
const body = {
|
|
137
|
+
symbol,
|
|
138
|
+
period: options.period || "annual",
|
|
139
|
+
limit: options.limit || 8,
|
|
140
|
+
calendar: options.calendar || "fiscal"
|
|
141
|
+
};
|
|
142
|
+
if (options.startDate) body.start_date = options.startDate;
|
|
143
|
+
if (options.endDate) body.end_date = options.endDate;
|
|
144
|
+
if (options.fiscalYear) body.fiscal_year = options.fiscalYear;
|
|
145
|
+
if (options.fiscalQuarter) body.fiscal_quarter = options.fiscalQuarter;
|
|
103
146
|
const response = await this.client.post(
|
|
104
147
|
"/v1/stock/company-cashflow-statement",
|
|
105
|
-
|
|
106
|
-
symbol,
|
|
107
|
-
period: options.period || "annual",
|
|
108
|
-
limit: options.limit || 10
|
|
109
|
-
}
|
|
148
|
+
body
|
|
110
149
|
);
|
|
111
150
|
return this.normalizeArrayResponse(response);
|
|
112
151
|
}
|
|
113
152
|
/**
|
|
114
|
-
* Get revenue breakdown
|
|
153
|
+
* Get revenue breakdown
|
|
115
154
|
*
|
|
116
155
|
* @param symbol - Stock symbol
|
|
117
|
-
* @param options.
|
|
156
|
+
* @param options.period - Report cycle (e.g., "FY", "Q2")
|
|
157
|
+
* @param options.limit - Number of records to return (default: 6)
|
|
158
|
+
* @param options.startDate - Start date (YYYY-MM-DD)
|
|
159
|
+
* @param options.endDate - End date (YYYY-MM-DD)
|
|
160
|
+
* @param options.fiscalYear - Specific fiscal year (e.g., "2023")
|
|
118
161
|
*/
|
|
119
162
|
async revenueBreakdown(symbol, options = {}) {
|
|
163
|
+
const body = { symbol };
|
|
164
|
+
if (options.period) body.period = options.period;
|
|
165
|
+
if (options.limit !== void 0) body.limit = options.limit;
|
|
166
|
+
if (options.startDate) body.start_date = options.startDate;
|
|
167
|
+
if (options.endDate) body.end_date = options.endDate;
|
|
168
|
+
if (options.fiscalYear) body.fiscal_year = options.fiscalYear;
|
|
120
169
|
const response = await this.client.post(
|
|
121
170
|
"/v1/stock/company-revenue-breakdown",
|
|
122
|
-
|
|
123
|
-
symbol,
|
|
124
|
-
breakdown_type: options.breakdownType || "segment"
|
|
125
|
-
}
|
|
171
|
+
body
|
|
126
172
|
);
|
|
127
173
|
return this.normalizeArrayResponse(response);
|
|
128
174
|
}
|
|
@@ -136,65 +182,43 @@ var StockModule = class {
|
|
|
136
182
|
* @param options - Query options
|
|
137
183
|
*/
|
|
138
184
|
async prices(symbol, options = {}) {
|
|
185
|
+
const body = { symbol };
|
|
186
|
+
if (options.startDate) body.start_date = options.startDate;
|
|
187
|
+
if (options.endDate) body.end_date = options.endDate;
|
|
139
188
|
const response = await this.client.post(
|
|
140
189
|
"/v1/stock/company-prices",
|
|
141
|
-
|
|
142
|
-
symbol,
|
|
143
|
-
start_date: options.startDate,
|
|
144
|
-
end_date: options.endDate,
|
|
145
|
-
limit: options.limit || 100
|
|
146
|
-
}
|
|
190
|
+
body
|
|
147
191
|
);
|
|
148
192
|
return this.normalizeArrayResponse(response);
|
|
149
193
|
}
|
|
150
194
|
/**
|
|
151
|
-
* Get
|
|
195
|
+
* Get real-time stock quote
|
|
152
196
|
*
|
|
153
197
|
* @param symbol - Stock symbol
|
|
154
|
-
* @param options - Query options
|
|
155
|
-
*/
|
|
156
|
-
async kline(symbol, options = {}) {
|
|
157
|
-
const response = await this.client.post(
|
|
158
|
-
"/v1/stock/kline",
|
|
159
|
-
{
|
|
160
|
-
symbol,
|
|
161
|
-
interval: options.interval || "1d",
|
|
162
|
-
adjust: options.adjust || "forward",
|
|
163
|
-
start_date: options.startDate,
|
|
164
|
-
end_date: options.endDate,
|
|
165
|
-
limit: options.limit || 100
|
|
166
|
-
}
|
|
167
|
-
);
|
|
168
|
-
return this.normalizeArrayResponse(response);
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Get real-time stock quotes
|
|
172
|
-
*
|
|
173
|
-
* @param symbols - Single symbol or array of symbols
|
|
174
198
|
*/
|
|
175
|
-
async quote(
|
|
176
|
-
const symbolList = Array.isArray(symbols) ? symbols : [symbols];
|
|
199
|
+
async quote(symbol) {
|
|
177
200
|
const response = await this.client.post(
|
|
178
201
|
"/v1/stock/quote-realtime",
|
|
179
|
-
{
|
|
202
|
+
{ symbol }
|
|
180
203
|
);
|
|
181
|
-
|
|
204
|
+
if ("data" in response) {
|
|
205
|
+
return response.data;
|
|
206
|
+
}
|
|
207
|
+
return response;
|
|
182
208
|
}
|
|
183
209
|
/**
|
|
184
210
|
* Get stock index prices
|
|
185
211
|
*
|
|
186
|
-
* @param symbol - Index symbol
|
|
212
|
+
* @param symbol - Index symbol (e.g., HSI, SPX, DJI)
|
|
187
213
|
* @param options - Query options
|
|
188
214
|
*/
|
|
189
215
|
async indexPrices(symbol, options = {}) {
|
|
216
|
+
const body = { symbol };
|
|
217
|
+
if (options.startDate) body.start_date = options.startDate;
|
|
218
|
+
if (options.endDate) body.end_date = options.endDate;
|
|
190
219
|
const response = await this.client.post(
|
|
191
220
|
"/v1/stock/index-prices",
|
|
192
|
-
|
|
193
|
-
symbol,
|
|
194
|
-
start_date: options.startDate,
|
|
195
|
-
end_date: options.endDate,
|
|
196
|
-
limit: options.limit || 100
|
|
197
|
-
}
|
|
221
|
+
body
|
|
198
222
|
);
|
|
199
223
|
return this.normalizeArrayResponse(response);
|
|
200
224
|
}
|
|
@@ -205,39 +229,54 @@ var StockModule = class {
|
|
|
205
229
|
* Screen stocks based on various criteria
|
|
206
230
|
*/
|
|
207
231
|
async screener(options = {}) {
|
|
232
|
+
const body = {
|
|
233
|
+
limit: options.limit || 100
|
|
234
|
+
};
|
|
235
|
+
if (options.marketCapMoreThan !== void 0) body.market_cap_more_than = options.marketCapMoreThan;
|
|
236
|
+
if (options.marketCapLowerThan !== void 0) body.market_cap_lower_than = options.marketCapLowerThan;
|
|
237
|
+
if (options.priceMoreThan !== void 0) body.price_more_than = options.priceMoreThan;
|
|
238
|
+
if (options.priceLowerThan !== void 0) body.price_lower_than = options.priceLowerThan;
|
|
239
|
+
if (options.changePercentageMoreThan !== void 0) body.change_percentage_more_than = options.changePercentageMoreThan;
|
|
240
|
+
if (options.changePercentageLowerThan !== void 0) body.change_percentage_lower_than = options.changePercentageLowerThan;
|
|
241
|
+
if (options.volumeMoreThan !== void 0) body.volume_more_than = options.volumeMoreThan;
|
|
242
|
+
if (options.volumeLowerThan !== void 0) body.volume_lower_than = options.volumeLowerThan;
|
|
243
|
+
if (options.country) body.country = options.country;
|
|
244
|
+
if (options.exchange) body.exchange = options.exchange;
|
|
245
|
+
if (options.dividendYieldMoreThan !== void 0) body.dividend_yield_more_than = options.dividendYieldMoreThan;
|
|
246
|
+
if (options.dividendYieldLowerThan !== void 0) body.dividend_yield_lower_than = options.dividendYieldLowerThan;
|
|
247
|
+
if (options.peTtmMoreThan !== void 0) body.pe_ttm_more_than = options.peTtmMoreThan;
|
|
248
|
+
if (options.peTtmLowerThan !== void 0) body.pe_ttm_lower_than = options.peTtmLowerThan;
|
|
208
249
|
const response = await this.client.post(
|
|
209
250
|
"/v1/stock/screener",
|
|
210
|
-
|
|
211
|
-
market: options.market,
|
|
212
|
-
sector: options.sector,
|
|
213
|
-
min_market_cap: options.minMarketCap,
|
|
214
|
-
max_market_cap: options.maxMarketCap,
|
|
215
|
-
min_pe: options.minPe,
|
|
216
|
-
max_pe: options.maxPe,
|
|
217
|
-
limit: options.limit || 50
|
|
218
|
-
}
|
|
251
|
+
body
|
|
219
252
|
);
|
|
220
253
|
return this.normalizeArrayResponse(response);
|
|
221
254
|
}
|
|
222
255
|
/**
|
|
223
256
|
* Get earnings announcement calendar
|
|
257
|
+
*
|
|
258
|
+
* @param options.market - Required: Stock market (cn, hk, us)
|
|
259
|
+
* @param options.startDate - Required: Start date (YYYY-MM-DD)
|
|
260
|
+
* @param options.endDate - Required: End date (YYYY-MM-DD)
|
|
261
|
+
* @param options.symbol - Optional: Stock symbol
|
|
224
262
|
*/
|
|
225
|
-
async earningsCalendar(options
|
|
263
|
+
async earningsCalendar(options) {
|
|
264
|
+
const body = {
|
|
265
|
+
market: options.market,
|
|
266
|
+
start_date: options.startDate,
|
|
267
|
+
end_date: options.endDate
|
|
268
|
+
};
|
|
269
|
+
if (options.symbol) body.symbol = options.symbol;
|
|
226
270
|
const response = await this.client.post(
|
|
227
271
|
"/v1/stock/earnings-calendar",
|
|
228
|
-
|
|
229
|
-
market: options.market || "us",
|
|
230
|
-
start_date: options.startDate,
|
|
231
|
-
end_date: options.endDate,
|
|
232
|
-
symbol: options.symbol
|
|
233
|
-
}
|
|
272
|
+
body
|
|
234
273
|
);
|
|
235
274
|
return this.normalizeArrayResponse(response);
|
|
236
275
|
}
|
|
237
276
|
/**
|
|
238
277
|
* Get Hong Kong IPO calendar
|
|
239
278
|
*/
|
|
240
|
-
async ipoCalendarHK(status
|
|
279
|
+
async ipoCalendarHK(status) {
|
|
241
280
|
const response = await this.client.post(
|
|
242
281
|
"/v1/stock/ipo-calendar-hk",
|
|
243
282
|
{ status }
|
|
@@ -327,184 +366,247 @@ var StockModule = class {
|
|
|
327
366
|
}
|
|
328
367
|
};
|
|
329
368
|
|
|
330
|
-
// src/
|
|
331
|
-
var
|
|
369
|
+
// src/docs.ts
|
|
370
|
+
var DocsModule = class {
|
|
332
371
|
constructor(client) {
|
|
333
372
|
this.client = client;
|
|
334
373
|
}
|
|
335
374
|
/**
|
|
336
|
-
* Get
|
|
337
|
-
*
|
|
338
|
-
* Returns recent content related to companies the user is following.
|
|
375
|
+
* Get document content and metadata
|
|
339
376
|
*
|
|
340
|
-
* @param
|
|
377
|
+
* @param docId - Document ID
|
|
341
378
|
*/
|
|
342
|
-
async
|
|
343
|
-
|
|
344
|
-
"/v1/tools/timeline/companies",
|
|
345
|
-
{ num: options.num || 10 }
|
|
346
|
-
);
|
|
347
|
-
return response.docs || [];
|
|
379
|
+
async get(docId) {
|
|
380
|
+
return this.client.get(`/v1/docs/${docId}`);
|
|
348
381
|
}
|
|
349
382
|
/**
|
|
350
|
-
* Get
|
|
351
|
-
*
|
|
352
|
-
* Returns recent content related to custom topics the user is following.
|
|
383
|
+
* Get document summary
|
|
353
384
|
*
|
|
354
|
-
* @param
|
|
385
|
+
* @param docId - Document ID
|
|
355
386
|
*/
|
|
356
|
-
async
|
|
357
|
-
|
|
358
|
-
"/v1/tools/timeline/topics",
|
|
359
|
-
{ num: options.num || 10 }
|
|
360
|
-
);
|
|
361
|
-
return response.docs || [];
|
|
387
|
+
async summary(docId) {
|
|
388
|
+
return this.client.get(`/v1/docs/${docId}/summary`);
|
|
362
389
|
}
|
|
363
390
|
/**
|
|
364
|
-
* Get
|
|
365
|
-
*
|
|
366
|
-
* Returns recent content from research institutions, banks, etc.
|
|
391
|
+
* Get raw document content
|
|
367
392
|
*
|
|
368
|
-
* @param
|
|
393
|
+
* @param docId - Document ID
|
|
369
394
|
*/
|
|
370
|
-
async
|
|
371
|
-
|
|
372
|
-
"/v1/tools/timeline/institutes",
|
|
373
|
-
{ num: options.num || 10 }
|
|
374
|
-
);
|
|
375
|
-
return response.docs || [];
|
|
395
|
+
async rawContent(docId) {
|
|
396
|
+
return this.client.get(`/v1/docs/${docId}/raw-content`);
|
|
376
397
|
}
|
|
377
398
|
/**
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
* Returns recent content from public media accounts.
|
|
399
|
+
* List documents with filters
|
|
381
400
|
*
|
|
382
|
-
* @param options
|
|
401
|
+
* @param options - Filter options
|
|
383
402
|
*/
|
|
384
|
-
async
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
403
|
+
async list(options = {}) {
|
|
404
|
+
const body = {
|
|
405
|
+
page_num: options.pageNum || 1,
|
|
406
|
+
page_size: options.pageSize || 10
|
|
407
|
+
};
|
|
408
|
+
if (options.symbols) body.symbols = options.symbols;
|
|
409
|
+
if (options.categories) body.categories = options.categories;
|
|
410
|
+
if (options.markets) body.markets = options.markets;
|
|
411
|
+
if (options.institutions) body.institutions = options.institutions;
|
|
412
|
+
if (options.tags) body.tags = options.tags;
|
|
413
|
+
if (options.startDate) body.start_date = options.startDate;
|
|
414
|
+
if (options.endDate) body.end_date = options.endDate;
|
|
415
|
+
if (options.minScore !== void 0) body.min_score = options.minScore;
|
|
416
|
+
if (options.extendedFilters) body.extended_filters = options.extendedFilters;
|
|
417
|
+
if (options.folderIds) body.folder_ids = options.folderIds;
|
|
418
|
+
const response = await this.client.post("/v1/docs", body);
|
|
419
|
+
return {
|
|
420
|
+
items: response.docs || [],
|
|
421
|
+
total: response.total_count || 0,
|
|
422
|
+
page: response.page_num || 1,
|
|
423
|
+
pageSize: response.page_size || 10
|
|
424
|
+
};
|
|
390
425
|
}
|
|
391
426
|
/**
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
* Returns recent content from social media accounts.
|
|
427
|
+
* Query documents by symbols
|
|
395
428
|
*
|
|
396
|
-
* @param
|
|
429
|
+
* @param symbols - Required: Stock symbols
|
|
430
|
+
* @param options - Filter options
|
|
397
431
|
*/
|
|
398
|
-
async
|
|
399
|
-
const
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
432
|
+
async queryBySymbols(symbols, options = {}) {
|
|
433
|
+
const body = {
|
|
434
|
+
symbols,
|
|
435
|
+
page_num: options.pageNum || 1,
|
|
436
|
+
page_size: options.pageSize || 10
|
|
437
|
+
};
|
|
438
|
+
if (options.categories) body.categories = options.categories;
|
|
439
|
+
if (options.markets) body.markets = options.markets;
|
|
440
|
+
if (options.startDate) body.start_date = options.startDate;
|
|
441
|
+
if (options.endDate) body.end_date = options.endDate;
|
|
442
|
+
const response = await this.client.post("/v1/docs/symbols", body);
|
|
443
|
+
return {
|
|
444
|
+
items: response.docs || [],
|
|
445
|
+
total: response.total_count || 0,
|
|
446
|
+
page: response.page_num || 1,
|
|
447
|
+
pageSize: response.page_size || 10
|
|
448
|
+
};
|
|
411
449
|
}
|
|
412
450
|
/**
|
|
413
|
-
*
|
|
451
|
+
* Query documents by tags
|
|
414
452
|
*
|
|
415
|
-
*
|
|
453
|
+
* @param tags - Required: Document tags
|
|
454
|
+
* @param options - Filter options
|
|
455
|
+
*/
|
|
456
|
+
async queryByTags(tags, options = {}) {
|
|
457
|
+
const body = {
|
|
458
|
+
tags,
|
|
459
|
+
page_num: options.pageNum || 1,
|
|
460
|
+
page_size: options.pageSize || 10
|
|
461
|
+
};
|
|
462
|
+
if (options.categories) body.categories = options.categories;
|
|
463
|
+
if (options.markets) body.markets = options.markets;
|
|
464
|
+
if (options.startDate) body.start_date = options.startDate;
|
|
465
|
+
if (options.endDate) body.end_date = options.endDate;
|
|
466
|
+
const response = await this.client.post("/v1/docs/tags", body);
|
|
467
|
+
return {
|
|
468
|
+
items: response.docs || [],
|
|
469
|
+
total: response.total_count || 0,
|
|
470
|
+
page: response.page_num || 1,
|
|
471
|
+
pageSize: response.page_size || 10
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Search document chunks semantically
|
|
416
476
|
*
|
|
417
477
|
* @param query - Search query string
|
|
418
478
|
* @param options - Search options
|
|
419
|
-
*
|
|
420
|
-
* @example
|
|
421
|
-
* ```typescript
|
|
422
|
-
* const results = await client.kb.search('quarterly revenue', { num: 5 });
|
|
423
|
-
* results.forEach(chunk => console.log(chunk.content));
|
|
424
|
-
* ```
|
|
425
479
|
*/
|
|
426
|
-
async
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
);
|
|
480
|
+
async searchChunks(query, options = {}) {
|
|
481
|
+
const body = {
|
|
482
|
+
query,
|
|
483
|
+
num: options.num || 10
|
|
484
|
+
};
|
|
485
|
+
if (options.symbols) body.symbols = options.symbols;
|
|
486
|
+
if (options.categories) body.categories = options.categories;
|
|
487
|
+
if (options.folderIds) body.folder_ids = options.folderIds;
|
|
488
|
+
if (options.docIds) body.doc_ids = options.docIds;
|
|
489
|
+
if (options.markets) body.markets = options.markets;
|
|
490
|
+
if (options.institutions) body.institutions = options.institutions;
|
|
491
|
+
if (options.tags) body.tags = options.tags;
|
|
492
|
+
if (options.startDate) body.start_date = options.startDate;
|
|
493
|
+
if (options.endDate) body.end_date = options.endDate;
|
|
494
|
+
if (options.minScore !== void 0) body.min_score = options.minScore;
|
|
495
|
+
if (options.extendedFilters) body.extended_filters = options.extendedFilters;
|
|
496
|
+
if (options.includeDocExtraDetails !== void 0) body.include_doc_extra_details = options.includeDocExtraDetails;
|
|
497
|
+
if (options.refineQuestion !== void 0) body.refine_question = options.refineQuestion;
|
|
498
|
+
if (options.dateRange) body.date_range = options.dateRange;
|
|
499
|
+
const response = await this.client.post("/v1/search/chunks", body);
|
|
438
500
|
return response.chunks || [];
|
|
439
501
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
//
|
|
443
|
-
var DocsModule = class {
|
|
444
|
-
constructor(client) {
|
|
445
|
-
this.client = client;
|
|
446
|
-
}
|
|
502
|
+
// ===========================================================================
|
|
503
|
+
// Folder Management
|
|
504
|
+
// ===========================================================================
|
|
447
505
|
/**
|
|
448
|
-
*
|
|
506
|
+
* Create a new document folder
|
|
449
507
|
*
|
|
450
|
-
* @param
|
|
508
|
+
* @param name - Folder name
|
|
509
|
+
* @returns Folder ID
|
|
451
510
|
*/
|
|
452
|
-
async
|
|
453
|
-
|
|
511
|
+
async createFolder(name) {
|
|
512
|
+
const response = await this.client.post("/v1/docs/folder/create", { name });
|
|
513
|
+
return { folderId: response.folder_id };
|
|
454
514
|
}
|
|
455
515
|
/**
|
|
456
|
-
*
|
|
516
|
+
* Delete a document folder and all files within it
|
|
457
517
|
*
|
|
458
|
-
* @param
|
|
518
|
+
* @param folderId - Folder ID to delete
|
|
519
|
+
* @returns Deleted folder ID and document IDs
|
|
459
520
|
*/
|
|
460
|
-
async
|
|
461
|
-
|
|
521
|
+
async deleteFolder(folderId) {
|
|
522
|
+
const response = await this.client.delete(
|
|
523
|
+
"/v1/docs/folder/delete",
|
|
524
|
+
{ folder_id: folderId }
|
|
525
|
+
);
|
|
526
|
+
return { folderId: response.folder_id, docIds: response.doc_ids };
|
|
462
527
|
}
|
|
528
|
+
// ===========================================================================
|
|
529
|
+
// Document Upload
|
|
530
|
+
// ===========================================================================
|
|
463
531
|
/**
|
|
464
|
-
*
|
|
532
|
+
* Upload documents by URL
|
|
465
533
|
*
|
|
466
|
-
* @param
|
|
534
|
+
* @param docs - Array of document upload requests
|
|
535
|
+
* @param options.folderId - Optional folder ID
|
|
536
|
+
* @param options.pdfParsingMode - PDF parsing mode (1: by page, 3: by logic)
|
|
467
537
|
*/
|
|
468
|
-
async
|
|
469
|
-
|
|
538
|
+
async uploadDocs(docs, options = {}) {
|
|
539
|
+
const body = {
|
|
540
|
+
docs: docs.map((doc) => ({
|
|
541
|
+
url: doc.url,
|
|
542
|
+
name: doc.name,
|
|
543
|
+
metadatas: doc.metadatas,
|
|
544
|
+
published_at: doc.publishedAt,
|
|
545
|
+
tags: doc.tags
|
|
546
|
+
}))
|
|
547
|
+
};
|
|
548
|
+
if (options.folderId) body.folder_id = options.folderId;
|
|
549
|
+
if (options.pdfParsingMode !== void 0) body.pdf_parsing_mode = options.pdfParsingMode;
|
|
550
|
+
const response = await this.client.post("/v1/docs/upload", body);
|
|
551
|
+
return {
|
|
552
|
+
docs: response.docs.map((doc) => ({
|
|
553
|
+
id: doc.id,
|
|
554
|
+
title: doc.title,
|
|
555
|
+
originalUrl: doc.original_url
|
|
556
|
+
}))
|
|
557
|
+
};
|
|
470
558
|
}
|
|
471
559
|
/**
|
|
472
|
-
*
|
|
560
|
+
* Upload documents by URL asynchronously
|
|
473
561
|
*
|
|
474
|
-
* @param
|
|
562
|
+
* @param docs - Array of document upload requests
|
|
563
|
+
* @param options.folderId - Optional folder ID
|
|
564
|
+
* @param options.pdfParsingMode - PDF parsing mode (1: by page, 3: by logic)
|
|
475
565
|
*/
|
|
476
|
-
async
|
|
477
|
-
const
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
566
|
+
async uploadDocsAsync(docs, options = {}) {
|
|
567
|
+
const body = {
|
|
568
|
+
docs: docs.map((doc) => ({
|
|
569
|
+
url: doc.url,
|
|
570
|
+
name: doc.name,
|
|
571
|
+
metadatas: doc.metadatas,
|
|
572
|
+
published_at: doc.publishedAt,
|
|
573
|
+
tags: doc.tags
|
|
574
|
+
}))
|
|
575
|
+
};
|
|
576
|
+
if (options.folderId) body.folder_id = options.folderId;
|
|
577
|
+
if (options.pdfParsingMode !== void 0) body.pdf_parsing_mode = options.pdfParsingMode;
|
|
578
|
+
const response = await this.client.post("/v1/docs/upload/async", body);
|
|
485
579
|
return {
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
580
|
+
docs: response.docs.map((doc) => ({
|
|
581
|
+
id: doc.id,
|
|
582
|
+
title: doc.title,
|
|
583
|
+
originalUrl: doc.original_url
|
|
584
|
+
}))
|
|
490
585
|
};
|
|
491
586
|
}
|
|
492
587
|
/**
|
|
493
|
-
*
|
|
588
|
+
* Get upload status of a document
|
|
494
589
|
*
|
|
495
|
-
* @param
|
|
496
|
-
* @
|
|
590
|
+
* @param docId - Document ID
|
|
591
|
+
* @returns Upload status (pending, processing, completed)
|
|
497
592
|
*/
|
|
498
|
-
async
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
593
|
+
async getUploadStatus(docId) {
|
|
594
|
+
return this.client.get(
|
|
595
|
+
`/v1/docs/${docId}/upload/status`
|
|
596
|
+
);
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Delete documents
|
|
600
|
+
*
|
|
601
|
+
* @param docIds - Array of document IDs to delete
|
|
602
|
+
* @returns Deleted document IDs
|
|
603
|
+
*/
|
|
604
|
+
async deleteDocs(docIds) {
|
|
605
|
+
const response = await this.client.delete(
|
|
606
|
+
"/v1/docs/delete",
|
|
607
|
+
{ doc_ids: docIds }
|
|
608
|
+
);
|
|
609
|
+
return { docIds: response.doc_ids };
|
|
508
610
|
}
|
|
509
611
|
};
|
|
510
612
|
|
|
@@ -813,18 +915,474 @@ var ConceptsModule = class {
|
|
|
813
915
|
}
|
|
814
916
|
};
|
|
815
917
|
|
|
816
|
-
// src/
|
|
817
|
-
var
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
super(message);
|
|
821
|
-
this.name = "ReportifyError";
|
|
822
|
-
this.statusCode = statusCode;
|
|
918
|
+
// src/channels.ts
|
|
919
|
+
var ChannelsModule = class {
|
|
920
|
+
constructor(client) {
|
|
921
|
+
this.client = client;
|
|
823
922
|
}
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
923
|
+
/**
|
|
924
|
+
* Search for channels by query string
|
|
925
|
+
*
|
|
926
|
+
* @param query - Search query string
|
|
927
|
+
* @param options - Pagination options
|
|
928
|
+
*/
|
|
929
|
+
async search(query, options = {}) {
|
|
930
|
+
const response = await this.client.post("/v1/channels/search", {
|
|
931
|
+
query,
|
|
932
|
+
page_num: options.pageNum || 1,
|
|
933
|
+
page_size: options.pageSize || 10
|
|
934
|
+
});
|
|
935
|
+
return {
|
|
936
|
+
items: response.channels.map((ch) => ({
|
|
937
|
+
id: ch.id,
|
|
938
|
+
name: ch.name,
|
|
939
|
+
description: ch.description,
|
|
940
|
+
avatarUrl: ch.avatar_url,
|
|
941
|
+
following: ch.following
|
|
942
|
+
})),
|
|
943
|
+
total: response.total_count || 0,
|
|
944
|
+
page: response.page_num || 1,
|
|
945
|
+
pageSize: response.page_size || 10
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
/**
|
|
949
|
+
* Get list of channels user is following
|
|
950
|
+
*
|
|
951
|
+
* @param options - Pagination options
|
|
952
|
+
*/
|
|
953
|
+
async getFollowings(options = {}) {
|
|
954
|
+
const response = await this.client.get("/v1/channels/followings", {
|
|
955
|
+
page_num: options.pageNum || 1,
|
|
956
|
+
page_size: options.pageSize || 10
|
|
957
|
+
});
|
|
958
|
+
return {
|
|
959
|
+
items: response.channels.map((ch) => ({
|
|
960
|
+
id: ch.id,
|
|
961
|
+
name: ch.name,
|
|
962
|
+
description: ch.description,
|
|
963
|
+
avatarUrl: ch.avatar_url,
|
|
964
|
+
following: ch.following
|
|
965
|
+
})),
|
|
966
|
+
total: response.total_count || 0,
|
|
967
|
+
page: response.page_num || 1,
|
|
968
|
+
pageSize: response.page_size || 10
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* Follow a channel
|
|
973
|
+
*
|
|
974
|
+
* @param channelId - Channel ID to follow
|
|
975
|
+
*/
|
|
976
|
+
async follow(channelId) {
|
|
977
|
+
const response = await this.client.post(`/v1/channels/${channelId}/follow`);
|
|
978
|
+
return {
|
|
979
|
+
id: response.id,
|
|
980
|
+
name: response.name,
|
|
981
|
+
description: response.description,
|
|
982
|
+
avatarUrl: response.avatar_url,
|
|
983
|
+
following: response.following
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Unfollow a channel
|
|
988
|
+
*
|
|
989
|
+
* @param channelId - Channel ID to unfollow
|
|
990
|
+
*/
|
|
991
|
+
async unfollow(channelId) {
|
|
992
|
+
return this.client.delete(
|
|
993
|
+
`/v1/channels/${channelId}/unfollow`
|
|
994
|
+
);
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Get documents from followed channels
|
|
998
|
+
*
|
|
999
|
+
* @param options - Query options
|
|
1000
|
+
*/
|
|
1001
|
+
async getDocs(options = {}) {
|
|
1002
|
+
const params = {
|
|
1003
|
+
page_num: options.pageNum || 1,
|
|
1004
|
+
page_size: options.pageSize || 10
|
|
1005
|
+
};
|
|
1006
|
+
if (options.channelIds) params.channel_ids = options.channelIds;
|
|
1007
|
+
const response = await this.client.get("/v1/channels/followings/docs", params);
|
|
1008
|
+
return {
|
|
1009
|
+
items: response.docs || [],
|
|
1010
|
+
total: response.total_count || 0,
|
|
1011
|
+
page: response.page_num || 1,
|
|
1012
|
+
pageSize: response.page_size || 10
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
|
|
1017
|
+
// src/chat.ts
|
|
1018
|
+
var ChatModule = class {
|
|
1019
|
+
constructor(client) {
|
|
1020
|
+
this.client = client;
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* Chat completion based on document content
|
|
1024
|
+
*
|
|
1025
|
+
* @param query - User query
|
|
1026
|
+
* @param options - Chat options
|
|
1027
|
+
*/
|
|
1028
|
+
async completion(query, options = {}) {
|
|
1029
|
+
const body = {
|
|
1030
|
+
query,
|
|
1031
|
+
mode: options.mode || "concise",
|
|
1032
|
+
session_id: options.sessionId || "",
|
|
1033
|
+
stream: options.stream ?? true
|
|
1034
|
+
};
|
|
1035
|
+
if (options.folderIds) body.folder_ids = options.folderIds;
|
|
1036
|
+
if (options.docIds) body.doc_ids = options.docIds;
|
|
1037
|
+
if (options.categories) body.categories = options.categories;
|
|
1038
|
+
if (options.markets) body.markets = options.markets;
|
|
1039
|
+
if (options.institutions) body.institutions = options.institutions;
|
|
1040
|
+
if (options.symbols) body.symbols = options.symbols;
|
|
1041
|
+
if (options.tags) body.tags = options.tags;
|
|
1042
|
+
if (options.startDate) body.start_date = options.startDate;
|
|
1043
|
+
if (options.endDate) body.end_date = options.endDate;
|
|
1044
|
+
if (options.minScore !== void 0) body.min_score = options.minScore;
|
|
1045
|
+
if (options.extendedFilters) body.extended_filters = options.extendedFilters;
|
|
1046
|
+
const response = await this.client.post("/v1/chat/completion", body);
|
|
1047
|
+
return {
|
|
1048
|
+
type: response.type,
|
|
1049
|
+
messageId: response.message_id,
|
|
1050
|
+
message: response.message,
|
|
1051
|
+
extra: response.extra
|
|
1052
|
+
};
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
// src/agent.ts
|
|
1057
|
+
var AgentModule = class {
|
|
1058
|
+
constructor(client) {
|
|
1059
|
+
this.client = client;
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Create a new agent conversation
|
|
1063
|
+
*
|
|
1064
|
+
* @param agentId - Agent ID
|
|
1065
|
+
* @param title - Optional conversation title
|
|
1066
|
+
*/
|
|
1067
|
+
async createConversation(agentId, title) {
|
|
1068
|
+
const body = { agent_id: agentId };
|
|
1069
|
+
if (title) body.title = title;
|
|
1070
|
+
const response = await this.client.post("/v1/agent/conversations", body);
|
|
1071
|
+
return {
|
|
1072
|
+
id: response.id,
|
|
1073
|
+
userId: response.user_id,
|
|
1074
|
+
agentId: response.agent_id,
|
|
1075
|
+
type: response.type,
|
|
1076
|
+
title: response.title,
|
|
1077
|
+
status: response.status,
|
|
1078
|
+
createdAt: response.created_at,
|
|
1079
|
+
updatedAt: response.updated_at
|
|
1080
|
+
};
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Chat with agent in a conversation
|
|
1084
|
+
*
|
|
1085
|
+
* @param conversationId - Conversation ID
|
|
1086
|
+
* @param message - User message
|
|
1087
|
+
* @param options - Chat options
|
|
1088
|
+
*/
|
|
1089
|
+
async chat(conversationId, message, options = {}) {
|
|
1090
|
+
const body = {
|
|
1091
|
+
message,
|
|
1092
|
+
stream: options.stream ?? true
|
|
1093
|
+
};
|
|
1094
|
+
if (options.documents) {
|
|
1095
|
+
body.documents = options.documents.map((doc) => ({
|
|
1096
|
+
doc_id: doc.docId,
|
|
1097
|
+
doc_title: doc.docTitle,
|
|
1098
|
+
file_type: doc.fileType
|
|
1099
|
+
}));
|
|
1100
|
+
}
|
|
1101
|
+
return this.client.post(`/v1/agent/conversations/${conversationId}/chat`, body);
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Get conversation details
|
|
1105
|
+
*
|
|
1106
|
+
* @param conversationId - Conversation ID
|
|
1107
|
+
*/
|
|
1108
|
+
async getConversation(conversationId) {
|
|
1109
|
+
const response = await this.client.get(`/v1/agent/conversations/${conversationId}`);
|
|
1110
|
+
return {
|
|
1111
|
+
id: response.id,
|
|
1112
|
+
userId: response.user_id,
|
|
1113
|
+
agentId: response.agent_id,
|
|
1114
|
+
type: response.type,
|
|
1115
|
+
title: response.title,
|
|
1116
|
+
status: response.status,
|
|
1117
|
+
createdAt: response.created_at,
|
|
1118
|
+
updatedAt: response.updated_at
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* List messages in a conversation
|
|
1123
|
+
*
|
|
1124
|
+
* @param conversationId - Conversation ID
|
|
1125
|
+
* @param options - Query options
|
|
1126
|
+
*/
|
|
1127
|
+
async listMessages(conversationId, options = {}) {
|
|
1128
|
+
const params = {
|
|
1129
|
+
limit: options.limit || 10
|
|
1130
|
+
};
|
|
1131
|
+
if (options.beforeMessageId) params.before_message_id = options.beforeMessageId;
|
|
1132
|
+
const response = await this.client.get(`/v1/agent/conversations/${conversationId}/messages`, params);
|
|
1133
|
+
return {
|
|
1134
|
+
messages: response.messages.map((msg) => ({
|
|
1135
|
+
id: msg.id,
|
|
1136
|
+
userId: msg.user_id,
|
|
1137
|
+
conversationId: msg.conversation_id,
|
|
1138
|
+
turnId: msg.turn_id,
|
|
1139
|
+
role: msg.role,
|
|
1140
|
+
replyToMessageId: msg.reply_to_message_id,
|
|
1141
|
+
content: msg.content,
|
|
1142
|
+
status: msg.status,
|
|
1143
|
+
errorInfo: msg.error_info,
|
|
1144
|
+
assistantMessageId: msg.assistant_message_id,
|
|
1145
|
+
createdAt: msg.created_at,
|
|
1146
|
+
updatedAt: msg.updated_at,
|
|
1147
|
+
assistantEvents: msg.assistant_events
|
|
1148
|
+
}))
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
/**
|
|
1152
|
+
* Get assistant message events (streaming or non-streaming)
|
|
1153
|
+
*
|
|
1154
|
+
* @param conversationId - Conversation ID
|
|
1155
|
+
* @param assistantMessageId - Assistant message ID from chat response header
|
|
1156
|
+
* @param options - Query options
|
|
1157
|
+
*/
|
|
1158
|
+
async getAssistantMessageEvents(conversationId, assistantMessageId, options = {}) {
|
|
1159
|
+
const params = {
|
|
1160
|
+
stream: options.stream ?? true,
|
|
1161
|
+
timeout: options.timeout || 1800,
|
|
1162
|
+
from_offset: options.fromOffset || 0
|
|
1163
|
+
};
|
|
1164
|
+
return this.client.get(
|
|
1165
|
+
`/v1/agent/conversations/${conversationId}/messages/${assistantMessageId}`,
|
|
1166
|
+
params
|
|
1167
|
+
);
|
|
1168
|
+
}
|
|
1169
|
+
/**
|
|
1170
|
+
* Cancel agent execution
|
|
1171
|
+
*
|
|
1172
|
+
* @param conversationId - Conversation ID
|
|
1173
|
+
* @param assistantMessageId - Assistant message ID
|
|
1174
|
+
*/
|
|
1175
|
+
async cancelExecution(conversationId, assistantMessageId) {
|
|
1176
|
+
const response = await this.client.post(`/v1/agent/conversations/${conversationId}/messages/${assistantMessageId}/cancel`);
|
|
1177
|
+
return {
|
|
1178
|
+
responseId: response.response_id,
|
|
1179
|
+
status: response.status
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
/**
|
|
1183
|
+
* Get agent generated file
|
|
1184
|
+
*
|
|
1185
|
+
* @param fileId - Agent generated file ID
|
|
1186
|
+
* @returns File content as ArrayBuffer
|
|
1187
|
+
*
|
|
1188
|
+
* @example
|
|
1189
|
+
* ```typescript
|
|
1190
|
+
* const fileContent = await client.agent.getFile('file_abc123');
|
|
1191
|
+
* // Save to file in Node.js
|
|
1192
|
+
* fs.writeFileSync('output.xlsx', Buffer.from(fileContent));
|
|
1193
|
+
* ```
|
|
1194
|
+
*/
|
|
1195
|
+
async getFile(fileId) {
|
|
1196
|
+
return this.client.getBytes(`/v1/agent/files/${fileId}`);
|
|
1197
|
+
}
|
|
1198
|
+
};
|
|
1199
|
+
|
|
1200
|
+
// src/kb.ts
|
|
1201
|
+
var KBModule = class {
|
|
1202
|
+
constructor(client) {
|
|
1203
|
+
this.client = client;
|
|
1204
|
+
}
|
|
1205
|
+
/**
|
|
1206
|
+
* Search user's knowledge base
|
|
1207
|
+
*
|
|
1208
|
+
* @deprecated This method uses an internal API not documented in the public OpenAPI spec.
|
|
1209
|
+
* Consider using client.docs.searchChunks() instead.
|
|
1210
|
+
*
|
|
1211
|
+
* Performs semantic search across documents the user has uploaded
|
|
1212
|
+
* to their personal knowledge base.
|
|
1213
|
+
*
|
|
1214
|
+
* @param query - Search query string
|
|
1215
|
+
* @param options - Search options
|
|
1216
|
+
*
|
|
1217
|
+
* @example
|
|
1218
|
+
* ```typescript
|
|
1219
|
+
* const results = await client.kb.search('quarterly revenue', { num: 5 });
|
|
1220
|
+
* results.forEach(chunk => console.log(chunk.content));
|
|
1221
|
+
* ```
|
|
1222
|
+
*/
|
|
1223
|
+
async search(query, options = {}) {
|
|
1224
|
+
console.warn(
|
|
1225
|
+
"kb.search() uses an internal API not documented in the public OpenAPI spec. Consider using docs.searchChunks() instead."
|
|
1226
|
+
);
|
|
1227
|
+
const body = {
|
|
1228
|
+
query,
|
|
1229
|
+
num: options.num || 10
|
|
1230
|
+
};
|
|
1231
|
+
if (options.folderIds) body.folder_ids = options.folderIds;
|
|
1232
|
+
if (options.docIds) body.doc_ids = options.docIds;
|
|
1233
|
+
if (options.startDate) body.start_date = options.startDate;
|
|
1234
|
+
if (options.endDate) body.end_date = options.endDate;
|
|
1235
|
+
const response = await this.client.post(
|
|
1236
|
+
"/v1/tools/kb/search",
|
|
1237
|
+
body
|
|
1238
|
+
);
|
|
1239
|
+
return response.chunks || [];
|
|
1240
|
+
}
|
|
1241
|
+
};
|
|
1242
|
+
|
|
1243
|
+
// src/timeline.ts
|
|
1244
|
+
function emitDeprecationWarning(methodName) {
|
|
1245
|
+
console.warn(
|
|
1246
|
+
`timeline.${methodName}() uses an internal API not documented in the public OpenAPI spec. This endpoint may change without notice.`
|
|
1247
|
+
);
|
|
1248
|
+
}
|
|
1249
|
+
var TimelineModule = class {
|
|
1250
|
+
constructor(client) {
|
|
1251
|
+
this.client = client;
|
|
1252
|
+
}
|
|
1253
|
+
/**
|
|
1254
|
+
* Get timeline for followed companies
|
|
1255
|
+
*
|
|
1256
|
+
* @deprecated This method uses an internal API not documented in the public OpenAPI spec.
|
|
1257
|
+
*
|
|
1258
|
+
* Returns recent content related to companies the user is following.
|
|
1259
|
+
*
|
|
1260
|
+
* @param options.num - Number of items to return (default: 10, max: 100)
|
|
1261
|
+
*/
|
|
1262
|
+
async companies(options = {}) {
|
|
1263
|
+
emitDeprecationWarning("companies");
|
|
1264
|
+
const response = await this.client.post(
|
|
1265
|
+
"/v1/tools/timeline/companies",
|
|
1266
|
+
{ num: options.num || 10 }
|
|
1267
|
+
);
|
|
1268
|
+
return response.docs || [];
|
|
1269
|
+
}
|
|
1270
|
+
/**
|
|
1271
|
+
* Get timeline for followed topics
|
|
1272
|
+
*
|
|
1273
|
+
* @deprecated This method uses an internal API not documented in the public OpenAPI spec.
|
|
1274
|
+
*
|
|
1275
|
+
* Returns recent content related to custom topics the user is following.
|
|
1276
|
+
*
|
|
1277
|
+
* @param options.num - Number of items to return
|
|
1278
|
+
*/
|
|
1279
|
+
async topics(options = {}) {
|
|
1280
|
+
emitDeprecationWarning("topics");
|
|
1281
|
+
const response = await this.client.post(
|
|
1282
|
+
"/v1/tools/timeline/topics",
|
|
1283
|
+
{ num: options.num || 10 }
|
|
1284
|
+
);
|
|
1285
|
+
return response.docs || [];
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* Get timeline for followed professional institutes
|
|
1289
|
+
*
|
|
1290
|
+
* @deprecated This method uses an internal API not documented in the public OpenAPI spec.
|
|
1291
|
+
*
|
|
1292
|
+
* Returns recent content from research institutions, banks, etc.
|
|
1293
|
+
*
|
|
1294
|
+
* @param options.num - Number of items to return
|
|
1295
|
+
*/
|
|
1296
|
+
async institutes(options = {}) {
|
|
1297
|
+
emitDeprecationWarning("institutes");
|
|
1298
|
+
const response = await this.client.post(
|
|
1299
|
+
"/v1/tools/timeline/institutes",
|
|
1300
|
+
{ num: options.num || 10 }
|
|
1301
|
+
);
|
|
1302
|
+
return response.docs || [];
|
|
1303
|
+
}
|
|
1304
|
+
/**
|
|
1305
|
+
* Get timeline for followed public media
|
|
1306
|
+
*
|
|
1307
|
+
* @deprecated This method uses an internal API not documented in the public OpenAPI spec.
|
|
1308
|
+
*
|
|
1309
|
+
* Returns recent content from public media accounts.
|
|
1310
|
+
*
|
|
1311
|
+
* @param options.num - Number of items to return
|
|
1312
|
+
*/
|
|
1313
|
+
async publicMedia(options = {}) {
|
|
1314
|
+
emitDeprecationWarning("publicMedia");
|
|
1315
|
+
const response = await this.client.post(
|
|
1316
|
+
"/v1/tools/timeline/public-media",
|
|
1317
|
+
{ num: options.num || 10 }
|
|
1318
|
+
);
|
|
1319
|
+
return response.docs || [];
|
|
1320
|
+
}
|
|
1321
|
+
/**
|
|
1322
|
+
* Get timeline for followed social media
|
|
1323
|
+
*
|
|
1324
|
+
* @deprecated This method uses an internal API not documented in the public OpenAPI spec.
|
|
1325
|
+
*
|
|
1326
|
+
* Returns recent content from social media accounts.
|
|
1327
|
+
*
|
|
1328
|
+
* @param options.num - Number of items to return
|
|
1329
|
+
*/
|
|
1330
|
+
async socialMedia(options = {}) {
|
|
1331
|
+
emitDeprecationWarning("socialMedia");
|
|
1332
|
+
const response = await this.client.post(
|
|
1333
|
+
"/v1/tools/timeline/social-media",
|
|
1334
|
+
{ num: options.num || 10 }
|
|
1335
|
+
);
|
|
1336
|
+
return response.docs || [];
|
|
1337
|
+
}
|
|
1338
|
+
};
|
|
1339
|
+
|
|
1340
|
+
// src/user.ts
|
|
1341
|
+
var UserModule = class {
|
|
1342
|
+
constructor(client) {
|
|
1343
|
+
this.client = client;
|
|
1344
|
+
}
|
|
1345
|
+
/**
|
|
1346
|
+
* Get all companies followed by the user
|
|
1347
|
+
*
|
|
1348
|
+
* Returns a list of companies that the user is following,
|
|
1349
|
+
* including company details like symbol, name, logo, and follow timestamp.
|
|
1350
|
+
*
|
|
1351
|
+
* @example
|
|
1352
|
+
* ```typescript
|
|
1353
|
+
* const companies = await client.user.followedCompanies();
|
|
1354
|
+
* companies.forEach(company => {
|
|
1355
|
+
* console.log(`${company.symbol}: ${company.name}`);
|
|
1356
|
+
* });
|
|
1357
|
+
* ```
|
|
1358
|
+
*/
|
|
1359
|
+
async followedCompanies() {
|
|
1360
|
+
const response = await this.client.get("/v1/tools/user/followed-companies");
|
|
1361
|
+
return (response.companies || []).map((company) => ({
|
|
1362
|
+
symbol: company.symbol,
|
|
1363
|
+
ticker: company.ticker,
|
|
1364
|
+
market: company.market,
|
|
1365
|
+
name: company.name,
|
|
1366
|
+
chineseName: company.chinese_name,
|
|
1367
|
+
englishName: company.english_name,
|
|
1368
|
+
logo: company.logo,
|
|
1369
|
+
followedAt: company.followed_at
|
|
1370
|
+
}));
|
|
1371
|
+
}
|
|
1372
|
+
};
|
|
1373
|
+
|
|
1374
|
+
// src/types.ts
|
|
1375
|
+
var ReportifyError = class extends Error {
|
|
1376
|
+
statusCode;
|
|
1377
|
+
constructor(message, statusCode) {
|
|
1378
|
+
super(message);
|
|
1379
|
+
this.name = "ReportifyError";
|
|
1380
|
+
this.statusCode = statusCode;
|
|
1381
|
+
}
|
|
1382
|
+
};
|
|
1383
|
+
var AuthenticationError = class extends ReportifyError {
|
|
1384
|
+
constructor(message = "Invalid or missing API key") {
|
|
1385
|
+
super(message, 401);
|
|
828
1386
|
this.name = "AuthenticationError";
|
|
829
1387
|
}
|
|
830
1388
|
};
|
|
@@ -856,11 +1414,15 @@ var Reportify = class {
|
|
|
856
1414
|
timeout;
|
|
857
1415
|
// Sub-modules
|
|
858
1416
|
stock;
|
|
859
|
-
timeline;
|
|
860
|
-
kb;
|
|
861
1417
|
docs;
|
|
862
1418
|
quant;
|
|
863
1419
|
concepts;
|
|
1420
|
+
channels;
|
|
1421
|
+
chat;
|
|
1422
|
+
agent;
|
|
1423
|
+
kb;
|
|
1424
|
+
timeline;
|
|
1425
|
+
user;
|
|
864
1426
|
constructor(config) {
|
|
865
1427
|
if (!config.apiKey) {
|
|
866
1428
|
throw new AuthenticationError("API key is required");
|
|
@@ -869,11 +1431,15 @@ var Reportify = class {
|
|
|
869
1431
|
this.baseUrl = (config.baseUrl || DEFAULT_BASE_URL).replace(/\/$/, "");
|
|
870
1432
|
this.timeout = config.timeout || DEFAULT_TIMEOUT;
|
|
871
1433
|
this.stock = new StockModule(this);
|
|
872
|
-
this.timeline = new TimelineModule(this);
|
|
873
|
-
this.kb = new KBModule(this);
|
|
874
1434
|
this.docs = new DocsModule(this);
|
|
875
1435
|
this.quant = new QuantModule(this);
|
|
876
1436
|
this.concepts = new ConceptsModule(this);
|
|
1437
|
+
this.channels = new ChannelsModule(this);
|
|
1438
|
+
this.chat = new ChatModule(this);
|
|
1439
|
+
this.agent = new AgentModule(this);
|
|
1440
|
+
this.kb = new KBModule(this);
|
|
1441
|
+
this.timeline = new TimelineModule(this);
|
|
1442
|
+
this.user = new UserModule(this);
|
|
877
1443
|
}
|
|
878
1444
|
/**
|
|
879
1445
|
* Make an HTTP request to the API
|
|
@@ -940,6 +1506,38 @@ var Reportify = class {
|
|
|
940
1506
|
async post(path, body) {
|
|
941
1507
|
return this.request("POST", path, { body });
|
|
942
1508
|
}
|
|
1509
|
+
/**
|
|
1510
|
+
* Make a DELETE request
|
|
1511
|
+
*/
|
|
1512
|
+
async delete(path, body) {
|
|
1513
|
+
return this.request("DELETE", path, { body });
|
|
1514
|
+
}
|
|
1515
|
+
/**
|
|
1516
|
+
* Make a GET request and return raw bytes (for file downloads)
|
|
1517
|
+
*/
|
|
1518
|
+
async getBytes(path) {
|
|
1519
|
+
const url = `${this.baseUrl}${path}`;
|
|
1520
|
+
const response = await fetch(url, {
|
|
1521
|
+
method: "GET",
|
|
1522
|
+
headers: {
|
|
1523
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
1524
|
+
"Content-Type": "application/json",
|
|
1525
|
+
"User-Agent": "reportify-sdk-typescript/0.2.9"
|
|
1526
|
+
}
|
|
1527
|
+
});
|
|
1528
|
+
if (!response.ok) {
|
|
1529
|
+
if (response.status === 401) {
|
|
1530
|
+
throw new AuthenticationError("Invalid API key");
|
|
1531
|
+
} else if (response.status === 404) {
|
|
1532
|
+
throw new NotFoundError(`Resource not found: ${path}`);
|
|
1533
|
+
} else if (response.status === 429) {
|
|
1534
|
+
throw new RateLimitError("Rate limit exceeded");
|
|
1535
|
+
} else {
|
|
1536
|
+
throw new APIError(`API error: ${response.status}`);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
return response.arrayBuffer();
|
|
1540
|
+
}
|
|
943
1541
|
// ===========================================================================
|
|
944
1542
|
// Search Methods
|
|
945
1543
|
// ===========================================================================
|
|
@@ -957,72 +1555,159 @@ var Reportify = class {
|
|
|
957
1555
|
* ```
|
|
958
1556
|
*/
|
|
959
1557
|
async search(query, options = {}) {
|
|
960
|
-
const
|
|
1558
|
+
const body = {
|
|
961
1559
|
query,
|
|
962
|
-
num: options.num || 10
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
1560
|
+
num: options.num || 10
|
|
1561
|
+
};
|
|
1562
|
+
if (options.categories) body.categories = options.categories;
|
|
1563
|
+
if (options.symbols) body.symbols = options.symbols;
|
|
1564
|
+
if (options.industries) body.industries = options.industries;
|
|
1565
|
+
if (options.channelIds) body.channel_ids = options.channelIds;
|
|
1566
|
+
if (options.startDatetime) body.start_datetime = options.startDatetime;
|
|
1567
|
+
if (options.endDatetime) body.end_datetime = options.endDatetime;
|
|
1568
|
+
const response = await this.post("/v2/search", body);
|
|
968
1569
|
return response.docs || [];
|
|
969
1570
|
}
|
|
970
1571
|
/**
|
|
971
1572
|
* Search news articles
|
|
972
1573
|
*/
|
|
973
1574
|
async searchNews(query, options = {}) {
|
|
974
|
-
const
|
|
1575
|
+
const body = {
|
|
975
1576
|
query,
|
|
976
|
-
num: options.num || 10
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1577
|
+
num: options.num || 10
|
|
1578
|
+
};
|
|
1579
|
+
if (options.symbols) body.symbols = options.symbols;
|
|
1580
|
+
if (options.channelIds) body.channel_ids = options.channelIds;
|
|
1581
|
+
if (options.startDatetime) body.start_datetime = options.startDatetime;
|
|
1582
|
+
if (options.endDatetime) body.end_datetime = options.endDatetime;
|
|
1583
|
+
const response = await this.post("/v2/search/news", body);
|
|
981
1584
|
return response.docs || [];
|
|
982
1585
|
}
|
|
983
1586
|
/**
|
|
984
1587
|
* Search research reports
|
|
985
1588
|
*/
|
|
986
1589
|
async searchReports(query, options = {}) {
|
|
987
|
-
const
|
|
1590
|
+
const body = {
|
|
988
1591
|
query,
|
|
989
|
-
num: options.num || 10
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
1592
|
+
num: options.num || 10
|
|
1593
|
+
};
|
|
1594
|
+
if (options.symbols) body.symbols = options.symbols;
|
|
1595
|
+
if (options.industries) body.industries = options.industries;
|
|
1596
|
+
if (options.channelIds) body.channel_ids = options.channelIds;
|
|
1597
|
+
if (options.startDatetime) body.start_datetime = options.startDatetime;
|
|
1598
|
+
if (options.endDatetime) body.end_datetime = options.endDatetime;
|
|
1599
|
+
const response = await this.post("/v2/search/reports", body);
|
|
994
1600
|
return response.docs || [];
|
|
995
1601
|
}
|
|
996
1602
|
/**
|
|
997
1603
|
* Search company filings
|
|
1604
|
+
* @param query - Search query string
|
|
1605
|
+
* @param symbols - Required: Stock symbols to filter by
|
|
1606
|
+
* @param options - Search options
|
|
998
1607
|
*/
|
|
999
|
-
async searchFilings(query, options = {}) {
|
|
1000
|
-
const
|
|
1608
|
+
async searchFilings(query, symbols, options = {}) {
|
|
1609
|
+
const body = {
|
|
1001
1610
|
query,
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1611
|
+
symbols,
|
|
1612
|
+
num: options.num || 10
|
|
1613
|
+
};
|
|
1614
|
+
if (options.startDatetime) body.start_datetime = options.startDatetime;
|
|
1615
|
+
if (options.endDatetime) body.end_datetime = options.endDatetime;
|
|
1616
|
+
const response = await this.post("/v2/search/filings", body);
|
|
1007
1617
|
return response.docs || [];
|
|
1008
1618
|
}
|
|
1009
1619
|
/**
|
|
1010
|
-
* Search earnings call transcripts
|
|
1620
|
+
* Search earnings pack documents (Financial reports, Earnings call transcripts, etc.)
|
|
1621
|
+
* @param query - Search query string
|
|
1622
|
+
* @param symbols - Required: Stock symbols to filter by
|
|
1623
|
+
* @param options - Search options
|
|
1011
1624
|
*/
|
|
1012
|
-
async
|
|
1013
|
-
const
|
|
1625
|
+
async searchEarningsPack(query, symbols, options = {}) {
|
|
1626
|
+
const body = {
|
|
1014
1627
|
query,
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1628
|
+
symbols,
|
|
1629
|
+
num: options.num || 10
|
|
1630
|
+
};
|
|
1631
|
+
if (options.startDatetime) body.start_datetime = options.startDatetime;
|
|
1632
|
+
if (options.endDatetime) body.end_datetime = options.endDatetime;
|
|
1633
|
+
const response = await this.post("/v2/search/earnings-pack", body);
|
|
1634
|
+
return response.docs || [];
|
|
1635
|
+
}
|
|
1636
|
+
/**
|
|
1637
|
+
* Search conference call transcripts
|
|
1638
|
+
* @param query - Search query string
|
|
1639
|
+
* @param symbols - Required: Stock symbols to filter by
|
|
1640
|
+
* @param options - Search options
|
|
1641
|
+
*/
|
|
1642
|
+
async searchConferenceCalls(query, symbols, options = {}) {
|
|
1643
|
+
const body = {
|
|
1644
|
+
query,
|
|
1645
|
+
symbols,
|
|
1646
|
+
num: options.num || 10
|
|
1647
|
+
};
|
|
1648
|
+
if (options.startDatetime) body.start_datetime = options.startDatetime;
|
|
1649
|
+
if (options.endDatetime) body.end_datetime = options.endDatetime;
|
|
1650
|
+
const response = await this.post("/v2/search/conference-calls", body);
|
|
1651
|
+
return response.docs || [];
|
|
1652
|
+
}
|
|
1653
|
+
/**
|
|
1654
|
+
* Search minutes transcripts (Conference calls, IR meetings)
|
|
1655
|
+
* @param query - Search query string
|
|
1656
|
+
* @param options - Search options
|
|
1657
|
+
*/
|
|
1658
|
+
async searchMinutes(query, options = {}) {
|
|
1659
|
+
const body = {
|
|
1660
|
+
query,
|
|
1661
|
+
num: options.num || 10
|
|
1662
|
+
};
|
|
1663
|
+
if (options.symbols) body.symbols = options.symbols;
|
|
1664
|
+
if (options.startDatetime) body.start_datetime = options.startDatetime;
|
|
1665
|
+
if (options.endDatetime) body.end_datetime = options.endDatetime;
|
|
1666
|
+
const response = await this.post("/v2/search/minutes", body);
|
|
1020
1667
|
return response.docs || [];
|
|
1021
1668
|
}
|
|
1669
|
+
/**
|
|
1670
|
+
* Search social media content
|
|
1671
|
+
*/
|
|
1672
|
+
async searchSocials(query, options = {}) {
|
|
1673
|
+
const body = {
|
|
1674
|
+
query,
|
|
1675
|
+
num: options.num || 10
|
|
1676
|
+
};
|
|
1677
|
+
if (options.symbols) body.symbols = options.symbols;
|
|
1678
|
+
if (options.channelIds) body.channel_ids = options.channelIds;
|
|
1679
|
+
if (options.startDatetime) body.start_datetime = options.startDatetime;
|
|
1680
|
+
if (options.endDatetime) body.end_datetime = options.endDatetime;
|
|
1681
|
+
const response = await this.post("/v2/search/socials", body);
|
|
1682
|
+
return response.docs || [];
|
|
1683
|
+
}
|
|
1684
|
+
/**
|
|
1685
|
+
* Search webpage content
|
|
1686
|
+
*/
|
|
1687
|
+
async searchWebpages(query, options = {}) {
|
|
1688
|
+
const body = {
|
|
1689
|
+
query,
|
|
1690
|
+
num: options.num || 10
|
|
1691
|
+
};
|
|
1692
|
+
if (options.startDatetime) body.start_datetime = options.startDatetime;
|
|
1693
|
+
if (options.endDatetime) body.end_datetime = options.endDatetime;
|
|
1694
|
+
const response = await this.post("/v2/search/webpages", body);
|
|
1695
|
+
return response.docs || [];
|
|
1696
|
+
}
|
|
1697
|
+
/**
|
|
1698
|
+
* @deprecated Use searchConferenceCalls instead
|
|
1699
|
+
* Search earnings call transcripts
|
|
1700
|
+
*/
|
|
1701
|
+
async searchTranscripts(query, symbols, options = {}) {
|
|
1702
|
+
return this.searchConferenceCalls(query, symbols, options);
|
|
1703
|
+
}
|
|
1022
1704
|
};
|
|
1023
1705
|
export {
|
|
1024
1706
|
APIError,
|
|
1707
|
+
AgentModule,
|
|
1025
1708
|
AuthenticationError,
|
|
1709
|
+
ChannelsModule,
|
|
1710
|
+
ChatModule,
|
|
1026
1711
|
ConceptsModule,
|
|
1027
1712
|
DocsModule,
|
|
1028
1713
|
KBModule,
|
|
@@ -1032,5 +1717,6 @@ export {
|
|
|
1032
1717
|
Reportify,
|
|
1033
1718
|
ReportifyError,
|
|
1034
1719
|
StockModule,
|
|
1035
|
-
TimelineModule
|
|
1720
|
+
TimelineModule,
|
|
1721
|
+
UserModule
|
|
1036
1722
|
};
|