@discomedia/utils 1.0.41 → 1.0.42
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-frontend.cjs +2 -15
- package/dist/index-frontend.cjs.map +1 -1
- package/dist/index-frontend.mjs +2 -15
- package/dist/index-frontend.mjs.map +1 -1
- package/dist/index.cjs +28 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +28 -47
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +6 -6
- package/dist/test.js +28 -47
- package/dist/test.js.map +1 -1
- package/dist/types/alpaca-market-data-api.d.ts.map +1 -1
- package/dist/types-frontend/alpaca-market-data-api.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -1502,8 +1502,8 @@ function pLimit(concurrency) {
|
|
|
1502
1502
|
},
|
|
1503
1503
|
},
|
|
1504
1504
|
map: {
|
|
1505
|
-
async value(
|
|
1506
|
-
const promises =
|
|
1505
|
+
async value(iterable, function_) {
|
|
1506
|
+
const promises = Array.from(iterable, (value, index) => this(function_, value, index));
|
|
1507
1507
|
return Promise.all(promises);
|
|
1508
1508
|
},
|
|
1509
1509
|
},
|
|
@@ -2449,7 +2449,7 @@ const safeJSON = (text) => {
|
|
|
2449
2449
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2450
2450
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
2451
2451
|
|
|
2452
|
-
const VERSION = '6.
|
|
2452
|
+
const VERSION = '6.5.0'; // x-release-please-version
|
|
2453
2453
|
|
|
2454
2454
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2455
2455
|
const isRunningInBrowser = () => {
|
|
@@ -6004,19 +6004,6 @@ class ChatKit extends APIResource {
|
|
|
6004
6004
|
this.sessions = new Sessions(this._client);
|
|
6005
6005
|
this.threads = new Threads$1(this._client);
|
|
6006
6006
|
}
|
|
6007
|
-
/**
|
|
6008
|
-
* Upload a ChatKit file
|
|
6009
|
-
*
|
|
6010
|
-
* @example
|
|
6011
|
-
* ```ts
|
|
6012
|
-
* const response = await client.beta.chatkit.uploadFile({
|
|
6013
|
-
* file: fs.createReadStream('path/to/file'),
|
|
6014
|
-
* });
|
|
6015
|
-
* ```
|
|
6016
|
-
*/
|
|
6017
|
-
uploadFile(body, options) {
|
|
6018
|
-
return this._client.post('/chatkit/files', maybeMultipartFormRequestOptions({ body, ...options, headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]) }, this._client));
|
|
6019
|
-
}
|
|
6020
6007
|
}
|
|
6021
6008
|
ChatKit.Sessions = Sessions;
|
|
6022
6009
|
ChatKit.Threads = Threads$1;
|
|
@@ -7338,7 +7325,7 @@ let Files$1 = class Files extends APIResource {
|
|
|
7338
7325
|
return this._client.getAPIList('/files', (CursorPage), { query, ...options });
|
|
7339
7326
|
}
|
|
7340
7327
|
/**
|
|
7341
|
-
* Delete a file.
|
|
7328
|
+
* Delete a file and remove it from all vector stores.
|
|
7342
7329
|
*/
|
|
7343
7330
|
delete(fileID, options) {
|
|
7344
7331
|
return this._client.delete(path `/files/${fileID}`, options);
|
|
@@ -16708,7 +16695,11 @@ function requireConfig () {
|
|
|
16708
16695
|
|
|
16709
16696
|
requireConfig();
|
|
16710
16697
|
|
|
16698
|
+
const DEBUG_LOGGING = process.env['DEBUG'] === 'true' || false;
|
|
16711
16699
|
const log = (message, options = { type: 'info' }) => {
|
|
16700
|
+
if (!DEBUG_LOGGING && options.type === 'debug') {
|
|
16701
|
+
return;
|
|
16702
|
+
}
|
|
16712
16703
|
log$1(message, { ...options, source: 'AlpacaMarketDataAPI' });
|
|
16713
16704
|
};
|
|
16714
16705
|
// Default settings for market data API
|
|
@@ -16798,7 +16789,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
|
|
|
16798
16789
|
this.optionWs = ws;
|
|
16799
16790
|
}
|
|
16800
16791
|
ws.on('open', () => {
|
|
16801
|
-
log(`${streamType} stream connected
|
|
16792
|
+
log(`${streamType} stream connected`);
|
|
16802
16793
|
const authMessage = {
|
|
16803
16794
|
action: 'auth',
|
|
16804
16795
|
key: process.env.ALPACA_API_KEY,
|
|
@@ -16811,7 +16802,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
|
|
|
16811
16802
|
const messages = JSON.parse(data.toString());
|
|
16812
16803
|
for (const message of messages) {
|
|
16813
16804
|
if (message.T === 'success' && message.msg === 'authenticated') {
|
|
16814
|
-
log(`${streamType} stream authenticated
|
|
16805
|
+
log(`${streamType} stream authenticated`);
|
|
16815
16806
|
this.sendSubscription(streamType);
|
|
16816
16807
|
}
|
|
16817
16808
|
else if (message.T === 'error') {
|
|
@@ -16961,9 +16952,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
|
|
|
16961
16952
|
symbols.forEach((symbol) => {
|
|
16962
16953
|
allBars[symbol] = [];
|
|
16963
16954
|
});
|
|
16964
|
-
log(`Starting historical bars fetch for ${symbolsStr.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})
|
|
16965
|
-
type: 'info',
|
|
16966
|
-
});
|
|
16955
|
+
log(`Starting historical bars fetch for ${symbolsStr.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})`);
|
|
16967
16956
|
while (hasMorePages) {
|
|
16968
16957
|
pageCount++;
|
|
16969
16958
|
const requestParams = {
|
|
@@ -17008,7 +16997,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
|
|
|
17008
16997
|
const dateRangeStr = earliestTimestamp && latestTimestamp
|
|
17009
16998
|
? `${new Date(earliestTimestamp).toLocaleDateString('en-US', { timeZone: 'America/New_York' })} to ${new Date(latestTimestamp).toLocaleDateString('en-US', { timeZone: 'America/New_York' })}`
|
|
17010
16999
|
: 'unknown range';
|
|
17011
|
-
log(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} bars (total: ${totalBarsCount.toLocaleString()}) for ${symbols.length} symbols, date range: ${dateRangeStr}${hasMorePages ? ', more pages available' : ', complete'}
|
|
17000
|
+
log(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} bars (total: ${totalBarsCount.toLocaleString()}) for ${symbols.length} symbols, date range: ${dateRangeStr}${hasMorePages ? ', more pages available' : ', complete'}`, { type: 'debug' });
|
|
17012
17001
|
// Prevent infinite loops
|
|
17013
17002
|
if (pageCount > 1000) {
|
|
17014
17003
|
log(`Stopping pagination after ${pageCount} pages to prevent infinite loop`, { type: 'warn' });
|
|
@@ -17019,7 +17008,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
|
|
|
17019
17008
|
const symbolsJoined = Object.entries(allBars)
|
|
17020
17009
|
.map(([symbol, bars]) => `${symbol}: ${bars.length}`)
|
|
17021
17010
|
.join(', ');
|
|
17022
|
-
log(`
|
|
17011
|
+
log(`Bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages for ${symbolsJoined.length} symbols'}`);
|
|
17023
17012
|
return {
|
|
17024
17013
|
bars: allBars,
|
|
17025
17014
|
next_page_token: null, // Always null since we fetch all pages
|
|
@@ -17300,9 +17289,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
|
|
|
17300
17289
|
symbols.forEach((symbol) => {
|
|
17301
17290
|
allBars[symbol] = [];
|
|
17302
17291
|
});
|
|
17303
|
-
log(`Starting historical options bars fetch for ${symbolsStr.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})
|
|
17304
|
-
type: 'info',
|
|
17305
|
-
});
|
|
17292
|
+
log(`Starting historical options bars fetch for ${symbolsStr.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})`);
|
|
17306
17293
|
while (hasMorePages) {
|
|
17307
17294
|
pageCount++;
|
|
17308
17295
|
const requestParams = {
|
|
@@ -17342,7 +17329,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
|
|
|
17342
17329
|
? `${earliestTimestamp.toLocaleDateString('en-US', { timeZone: 'America/New_York' })} to ${latestTimestamp.toLocaleDateString('en-US', { timeZone: 'America/New_York' })}`
|
|
17343
17330
|
: 'unknown range';
|
|
17344
17331
|
log(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} option bars (total: ${totalBarsCount.toLocaleString()}) for ${symbolsStr}, date range: ${dateRangeStr}${hasMorePages ? ', more pages available' : ', complete'}`, {
|
|
17345
|
-
type: '
|
|
17332
|
+
type: 'debug',
|
|
17346
17333
|
});
|
|
17347
17334
|
// Prevent infinite loops
|
|
17348
17335
|
if (pageCount > 1000) {
|
|
@@ -17354,9 +17341,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
|
|
|
17354
17341
|
const symbolCounts = Object.entries(allBars)
|
|
17355
17342
|
.map(([symbol, bars]) => `${symbol}: ${bars.length}`)
|
|
17356
17343
|
.join(', ');
|
|
17357
|
-
log(`
|
|
17358
|
-
type: 'info',
|
|
17359
|
-
});
|
|
17344
|
+
log(`Options bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages (${symbolCounts})`);
|
|
17360
17345
|
return {
|
|
17361
17346
|
bars: allBars,
|
|
17362
17347
|
next_page_token: undefined, // Always undefined since we fetch all pages
|
|
@@ -17382,9 +17367,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
|
|
|
17382
17367
|
symbols.forEach((symbol) => {
|
|
17383
17368
|
allTrades[symbol] = [];
|
|
17384
17369
|
});
|
|
17385
|
-
log(`Starting historical options trades fetch for ${symbolsStr.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})
|
|
17386
|
-
type: 'info',
|
|
17387
|
-
});
|
|
17370
|
+
log(`Starting historical options trades fetch for ${symbolsStr.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`);
|
|
17388
17371
|
while (hasMorePages) {
|
|
17389
17372
|
pageCount++;
|
|
17390
17373
|
const requestParams = {
|
|
@@ -17424,7 +17407,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
|
|
|
17424
17407
|
? `${earliestTimestamp.toLocaleDateString('en-US', { timeZone: 'America/New_York' })} to ${latestTimestamp.toLocaleDateString('en-US', { timeZone: 'America/New_York' })}`
|
|
17425
17408
|
: 'unknown range';
|
|
17426
17409
|
log(`Page ${pageCount}: Fetched ${pageTradesCount.toLocaleString()} option trades (total: ${totalTradesCount.toLocaleString()}) for ${symbolsStr.length} symbols, date range: ${dateRangeStr}${hasMorePages ? ', more pages available' : ', complete'}`, {
|
|
17427
|
-
type: '
|
|
17410
|
+
type: 'debug',
|
|
17428
17411
|
});
|
|
17429
17412
|
// Prevent infinite loops
|
|
17430
17413
|
if (pageCount > 1000) {
|
|
@@ -17436,9 +17419,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
|
|
|
17436
17419
|
const symbolCounts = Object.entries(allTrades)
|
|
17437
17420
|
.map(([symbol, trades]) => `${symbol}: ${trades.length}`)
|
|
17438
17421
|
.join(', ');
|
|
17439
|
-
log(`
|
|
17440
|
-
type: 'info',
|
|
17441
|
-
});
|
|
17422
|
+
log(`Options trades fetch complete: ${totalTradesCount.toLocaleString()} total trades across ${pageCount} pages (${symbolCounts})`);
|
|
17442
17423
|
return {
|
|
17443
17424
|
trades: allTrades,
|
|
17444
17425
|
next_page_token: undefined, // Always undefined since we fetch all pages
|
|
@@ -17646,7 +17627,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
|
|
|
17646
17627
|
symbols.forEach((symbol) => {
|
|
17647
17628
|
allBars[symbol] = [];
|
|
17648
17629
|
});
|
|
17649
|
-
log(`Starting crypto historical bars fetch for ${symbols.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})
|
|
17630
|
+
log(`Starting crypto historical bars fetch for ${symbols.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})`);
|
|
17650
17631
|
while (hasMorePages) {
|
|
17651
17632
|
pageCount++;
|
|
17652
17633
|
const requestParams = {
|
|
@@ -17670,14 +17651,14 @@ class AlpacaMarketDataAPI extends EventEmitter {
|
|
|
17670
17651
|
totalBarsCount += pageBarsCount;
|
|
17671
17652
|
pageToken = response.next_page_token || null;
|
|
17672
17653
|
hasMorePages = !!pageToken;
|
|
17673
|
-
log(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} crypto bars (total: ${totalBarsCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}
|
|
17654
|
+
log(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} crypto bars (total: ${totalBarsCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`, { type: 'debug' });
|
|
17674
17655
|
// Prevent infinite loops
|
|
17675
17656
|
if (pageCount > 1000) {
|
|
17676
17657
|
log(`Stopping crypto bars pagination after ${pageCount} pages to prevent infinite loop`, { type: 'warn' });
|
|
17677
17658
|
break;
|
|
17678
17659
|
}
|
|
17679
17660
|
}
|
|
17680
|
-
log(`Crypto historical bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages
|
|
17661
|
+
log(`Crypto historical bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages`);
|
|
17681
17662
|
return {
|
|
17682
17663
|
bars: allBars,
|
|
17683
17664
|
next_page_token: null, // Always null since we fetch all pages
|
|
@@ -17709,7 +17690,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
|
|
|
17709
17690
|
symbols.forEach((symbol) => {
|
|
17710
17691
|
allQuotes[symbol] = [];
|
|
17711
17692
|
});
|
|
17712
|
-
log(`Starting crypto historical quotes fetch for ${symbols.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})
|
|
17693
|
+
log(`Starting crypto historical quotes fetch for ${symbols.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`);
|
|
17713
17694
|
while (hasMorePages) {
|
|
17714
17695
|
pageCount++;
|
|
17715
17696
|
const requestParams = {
|
|
@@ -17733,14 +17714,14 @@ class AlpacaMarketDataAPI extends EventEmitter {
|
|
|
17733
17714
|
totalQuotesCount += pageQuotesCount;
|
|
17734
17715
|
pageToken = response.next_page_token || null;
|
|
17735
17716
|
hasMorePages = !!pageToken;
|
|
17736
|
-
log(`Page ${pageCount}: Fetched ${pageQuotesCount.toLocaleString()} crypto quotes (total: ${totalQuotesCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}
|
|
17717
|
+
log(`Page ${pageCount}: Fetched ${pageQuotesCount.toLocaleString()} crypto quotes (total: ${totalQuotesCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`, { type: 'debug' });
|
|
17737
17718
|
// Prevent infinite loops
|
|
17738
17719
|
if (pageCount > 1000) {
|
|
17739
17720
|
log(`Stopping crypto quotes pagination after ${pageCount} pages to prevent infinite loop`, { type: 'warn' });
|
|
17740
17721
|
break;
|
|
17741
17722
|
}
|
|
17742
17723
|
}
|
|
17743
|
-
log(`Crypto historical quotes fetch complete: ${totalQuotesCount.toLocaleString()} total quotes across ${pageCount} pages
|
|
17724
|
+
log(`Crypto historical quotes fetch complete: ${totalQuotesCount.toLocaleString()} total quotes across ${pageCount} pages`);
|
|
17744
17725
|
return {
|
|
17745
17726
|
quotes: allQuotes,
|
|
17746
17727
|
next_page_token: null, // Always null since we fetch all pages
|
|
@@ -17776,7 +17757,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
|
|
|
17776
17757
|
symbols.forEach((symbol) => {
|
|
17777
17758
|
allTrades[symbol] = [];
|
|
17778
17759
|
});
|
|
17779
|
-
log(`Starting crypto historical trades fetch for ${symbols.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})
|
|
17760
|
+
log(`Starting crypto historical trades fetch for ${symbols.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`);
|
|
17780
17761
|
while (hasMorePages) {
|
|
17781
17762
|
pageCount++;
|
|
17782
17763
|
const requestParams = {
|
|
@@ -17800,14 +17781,14 @@ class AlpacaMarketDataAPI extends EventEmitter {
|
|
|
17800
17781
|
totalTradesCount += pageTradesCount;
|
|
17801
17782
|
pageToken = response.next_page_token || null;
|
|
17802
17783
|
hasMorePages = !!pageToken;
|
|
17803
|
-
log(`Page ${pageCount}: Fetched ${pageTradesCount.toLocaleString()} crypto trades (total: ${totalTradesCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}
|
|
17784
|
+
log(`Page ${pageCount}: Fetched ${pageTradesCount.toLocaleString()} crypto trades (total: ${totalTradesCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`, { type: 'debug' });
|
|
17804
17785
|
// Prevent infinite loops
|
|
17805
17786
|
if (pageCount > 1000) {
|
|
17806
17787
|
log(`Stopping crypto trades pagination after ${pageCount} pages to prevent infinite loop`, { type: 'warn' });
|
|
17807
17788
|
break;
|
|
17808
17789
|
}
|
|
17809
17790
|
}
|
|
17810
|
-
log(`Crypto historical trades fetch complete: ${totalTradesCount.toLocaleString()} total trades across ${pageCount} pages
|
|
17791
|
+
log(`Crypto historical trades fetch complete: ${totalTradesCount.toLocaleString()} total trades across ${pageCount} pages`);
|
|
17811
17792
|
return {
|
|
17812
17793
|
trades: allTrades,
|
|
17813
17794
|
next_page_token: null, // Always null since we fetch all pages
|