@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.cjs CHANGED
@@ -1504,8 +1504,8 @@ function pLimit(concurrency) {
1504
1504
  },
1505
1505
  },
1506
1506
  map: {
1507
- async value(array, function_) {
1508
- const promises = array.map((value, index) => this(function_, value, index));
1507
+ async value(iterable, function_) {
1508
+ const promises = Array.from(iterable, (value, index) => this(function_, value, index));
1509
1509
  return Promise.all(promises);
1510
1510
  },
1511
1511
  },
@@ -2451,7 +2451,7 @@ const safeJSON = (text) => {
2451
2451
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2452
2452
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
2453
2453
 
2454
- const VERSION = '6.2.0'; // x-release-please-version
2454
+ const VERSION = '6.5.0'; // x-release-please-version
2455
2455
 
2456
2456
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2457
2457
  const isRunningInBrowser = () => {
@@ -6006,19 +6006,6 @@ class ChatKit extends APIResource {
6006
6006
  this.sessions = new Sessions(this._client);
6007
6007
  this.threads = new Threads$1(this._client);
6008
6008
  }
6009
- /**
6010
- * Upload a ChatKit file
6011
- *
6012
- * @example
6013
- * ```ts
6014
- * const response = await client.beta.chatkit.uploadFile({
6015
- * file: fs.createReadStream('path/to/file'),
6016
- * });
6017
- * ```
6018
- */
6019
- uploadFile(body, options) {
6020
- return this._client.post('/chatkit/files', maybeMultipartFormRequestOptions({ body, ...options, headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]) }, this._client));
6021
- }
6022
6009
  }
6023
6010
  ChatKit.Sessions = Sessions;
6024
6011
  ChatKit.Threads = Threads$1;
@@ -7340,7 +7327,7 @@ let Files$1 = class Files extends APIResource {
7340
7327
  return this._client.getAPIList('/files', (CursorPage), { query, ...options });
7341
7328
  }
7342
7329
  /**
7343
- * Delete a file.
7330
+ * Delete a file and remove it from all vector stores.
7344
7331
  */
7345
7332
  delete(fileID, options) {
7346
7333
  return this._client.delete(path `/files/${fileID}`, options);
@@ -16710,7 +16697,11 @@ function requireConfig () {
16710
16697
 
16711
16698
  requireConfig();
16712
16699
 
16700
+ const DEBUG_LOGGING = process.env['DEBUG'] === 'true' || false;
16713
16701
  const log = (message, options = { type: 'info' }) => {
16702
+ if (!DEBUG_LOGGING && options.type === 'debug') {
16703
+ return;
16704
+ }
16714
16705
  log$1(message, { ...options, source: 'AlpacaMarketDataAPI' });
16715
16706
  };
16716
16707
  // Default settings for market data API
@@ -16800,7 +16791,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
16800
16791
  this.optionWs = ws;
16801
16792
  }
16802
16793
  ws.on('open', () => {
16803
- log(`${streamType} stream connected`, { type: 'info' });
16794
+ log(`${streamType} stream connected`);
16804
16795
  const authMessage = {
16805
16796
  action: 'auth',
16806
16797
  key: process.env.ALPACA_API_KEY,
@@ -16813,7 +16804,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
16813
16804
  const messages = JSON.parse(data.toString());
16814
16805
  for (const message of messages) {
16815
16806
  if (message.T === 'success' && message.msg === 'authenticated') {
16816
- log(`${streamType} stream authenticated`, { type: 'info' });
16807
+ log(`${streamType} stream authenticated`);
16817
16808
  this.sendSubscription(streamType);
16818
16809
  }
16819
16810
  else if (message.T === 'error') {
@@ -16963,9 +16954,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
16963
16954
  symbols.forEach((symbol) => {
16964
16955
  allBars[symbol] = [];
16965
16956
  });
16966
- log(`Starting historical bars fetch for ${symbolsStr.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})`, {
16967
- type: 'info',
16968
- });
16957
+ log(`Starting historical bars fetch for ${symbolsStr.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})`);
16969
16958
  while (hasMorePages) {
16970
16959
  pageCount++;
16971
16960
  const requestParams = {
@@ -17010,7 +16999,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17010
16999
  const dateRangeStr = earliestTimestamp && latestTimestamp
17011
17000
  ? `${new Date(earliestTimestamp).toLocaleDateString('en-US', { timeZone: 'America/New_York' })} to ${new Date(latestTimestamp).toLocaleDateString('en-US', { timeZone: 'America/New_York' })}`
17012
17001
  : 'unknown range';
17013
- log(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} bars (total: ${totalBarsCount.toLocaleString()}) for ${symbols.length} symbols, date range: ${dateRangeStr}${hasMorePages ? ', more pages available' : ', complete'}`);
17002
+ log(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} bars (total: ${totalBarsCount.toLocaleString()}) for ${symbols.length} symbols, date range: ${dateRangeStr}${hasMorePages ? ', more pages available' : ', complete'}`, { type: 'debug' });
17014
17003
  // Prevent infinite loops
17015
17004
  if (pageCount > 1000) {
17016
17005
  log(`Stopping pagination after ${pageCount} pages to prevent infinite loop`, { type: 'warn' });
@@ -17021,7 +17010,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17021
17010
  const symbolsJoined = Object.entries(allBars)
17022
17011
  .map(([symbol, bars]) => `${symbol}: ${bars.length}`)
17023
17012
  .join(', ');
17024
- log(`Historical bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages for ${symbolsJoined.length} symbols'}`);
17013
+ log(`Bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages for ${symbolsJoined.length} symbols'}`);
17025
17014
  return {
17026
17015
  bars: allBars,
17027
17016
  next_page_token: null, // Always null since we fetch all pages
@@ -17302,9 +17291,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17302
17291
  symbols.forEach((symbol) => {
17303
17292
  allBars[symbol] = [];
17304
17293
  });
17305
- log(`Starting historical options bars fetch for ${symbolsStr.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})`, {
17306
- type: 'info',
17307
- });
17294
+ log(`Starting historical options bars fetch for ${symbolsStr.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})`);
17308
17295
  while (hasMorePages) {
17309
17296
  pageCount++;
17310
17297
  const requestParams = {
@@ -17344,7 +17331,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17344
17331
  ? `${earliestTimestamp.toLocaleDateString('en-US', { timeZone: 'America/New_York' })} to ${latestTimestamp.toLocaleDateString('en-US', { timeZone: 'America/New_York' })}`
17345
17332
  : 'unknown range';
17346
17333
  log(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} option bars (total: ${totalBarsCount.toLocaleString()}) for ${symbolsStr}, date range: ${dateRangeStr}${hasMorePages ? ', more pages available' : ', complete'}`, {
17347
- type: 'info',
17334
+ type: 'debug',
17348
17335
  });
17349
17336
  // Prevent infinite loops
17350
17337
  if (pageCount > 1000) {
@@ -17356,9 +17343,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17356
17343
  const symbolCounts = Object.entries(allBars)
17357
17344
  .map(([symbol, bars]) => `${symbol}: ${bars.length}`)
17358
17345
  .join(', ');
17359
- log(`Historical options bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages (${symbolCounts})`, {
17360
- type: 'info',
17361
- });
17346
+ log(`Options bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages (${symbolCounts})`);
17362
17347
  return {
17363
17348
  bars: allBars,
17364
17349
  next_page_token: undefined, // Always undefined since we fetch all pages
@@ -17384,9 +17369,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17384
17369
  symbols.forEach((symbol) => {
17385
17370
  allTrades[symbol] = [];
17386
17371
  });
17387
- log(`Starting historical options trades fetch for ${symbolsStr.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`, {
17388
- type: 'info',
17389
- });
17372
+ log(`Starting historical options trades fetch for ${symbolsStr.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`);
17390
17373
  while (hasMorePages) {
17391
17374
  pageCount++;
17392
17375
  const requestParams = {
@@ -17426,7 +17409,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17426
17409
  ? `${earliestTimestamp.toLocaleDateString('en-US', { timeZone: 'America/New_York' })} to ${latestTimestamp.toLocaleDateString('en-US', { timeZone: 'America/New_York' })}`
17427
17410
  : 'unknown range';
17428
17411
  log(`Page ${pageCount}: Fetched ${pageTradesCount.toLocaleString()} option trades (total: ${totalTradesCount.toLocaleString()}) for ${symbolsStr.length} symbols, date range: ${dateRangeStr}${hasMorePages ? ', more pages available' : ', complete'}`, {
17429
- type: 'info',
17412
+ type: 'debug',
17430
17413
  });
17431
17414
  // Prevent infinite loops
17432
17415
  if (pageCount > 1000) {
@@ -17438,9 +17421,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17438
17421
  const symbolCounts = Object.entries(allTrades)
17439
17422
  .map(([symbol, trades]) => `${symbol}: ${trades.length}`)
17440
17423
  .join(', ');
17441
- log(`Historical options trades fetch complete: ${totalTradesCount.toLocaleString()} total trades across ${pageCount} pages (${symbolCounts})`, {
17442
- type: 'info',
17443
- });
17424
+ log(`Options trades fetch complete: ${totalTradesCount.toLocaleString()} total trades across ${pageCount} pages (${symbolCounts})`);
17444
17425
  return {
17445
17426
  trades: allTrades,
17446
17427
  next_page_token: undefined, // Always undefined since we fetch all pages
@@ -17648,7 +17629,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17648
17629
  symbols.forEach((symbol) => {
17649
17630
  allBars[symbol] = [];
17650
17631
  });
17651
- log(`Starting crypto historical bars fetch for ${symbols.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})`, { type: 'info' });
17632
+ log(`Starting crypto historical bars fetch for ${symbols.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})`);
17652
17633
  while (hasMorePages) {
17653
17634
  pageCount++;
17654
17635
  const requestParams = {
@@ -17672,14 +17653,14 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17672
17653
  totalBarsCount += pageBarsCount;
17673
17654
  pageToken = response.next_page_token || null;
17674
17655
  hasMorePages = !!pageToken;
17675
- log(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} crypto bars (total: ${totalBarsCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`);
17656
+ log(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} crypto bars (total: ${totalBarsCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`, { type: 'debug' });
17676
17657
  // Prevent infinite loops
17677
17658
  if (pageCount > 1000) {
17678
17659
  log(`Stopping crypto bars pagination after ${pageCount} pages to prevent infinite loop`, { type: 'warn' });
17679
17660
  break;
17680
17661
  }
17681
17662
  }
17682
- log(`Crypto historical bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages`, { type: 'info' });
17663
+ log(`Crypto historical bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages`);
17683
17664
  return {
17684
17665
  bars: allBars,
17685
17666
  next_page_token: null, // Always null since we fetch all pages
@@ -17711,7 +17692,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17711
17692
  symbols.forEach((symbol) => {
17712
17693
  allQuotes[symbol] = [];
17713
17694
  });
17714
- log(`Starting crypto historical quotes fetch for ${symbols.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`, { type: 'info' });
17695
+ log(`Starting crypto historical quotes fetch for ${symbols.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`);
17715
17696
  while (hasMorePages) {
17716
17697
  pageCount++;
17717
17698
  const requestParams = {
@@ -17735,14 +17716,14 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17735
17716
  totalQuotesCount += pageQuotesCount;
17736
17717
  pageToken = response.next_page_token || null;
17737
17718
  hasMorePages = !!pageToken;
17738
- log(`Page ${pageCount}: Fetched ${pageQuotesCount.toLocaleString()} crypto quotes (total: ${totalQuotesCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`);
17719
+ log(`Page ${pageCount}: Fetched ${pageQuotesCount.toLocaleString()} crypto quotes (total: ${totalQuotesCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`, { type: 'debug' });
17739
17720
  // Prevent infinite loops
17740
17721
  if (pageCount > 1000) {
17741
17722
  log(`Stopping crypto quotes pagination after ${pageCount} pages to prevent infinite loop`, { type: 'warn' });
17742
17723
  break;
17743
17724
  }
17744
17725
  }
17745
- log(`Crypto historical quotes fetch complete: ${totalQuotesCount.toLocaleString()} total quotes across ${pageCount} pages`, { type: 'info' });
17726
+ log(`Crypto historical quotes fetch complete: ${totalQuotesCount.toLocaleString()} total quotes across ${pageCount} pages`);
17746
17727
  return {
17747
17728
  quotes: allQuotes,
17748
17729
  next_page_token: null, // Always null since we fetch all pages
@@ -17778,7 +17759,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17778
17759
  symbols.forEach((symbol) => {
17779
17760
  allTrades[symbol] = [];
17780
17761
  });
17781
- log(`Starting crypto historical trades fetch for ${symbols.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`, { type: 'info' });
17762
+ log(`Starting crypto historical trades fetch for ${symbols.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`);
17782
17763
  while (hasMorePages) {
17783
17764
  pageCount++;
17784
17765
  const requestParams = {
@@ -17802,14 +17783,14 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17802
17783
  totalTradesCount += pageTradesCount;
17803
17784
  pageToken = response.next_page_token || null;
17804
17785
  hasMorePages = !!pageToken;
17805
- log(`Page ${pageCount}: Fetched ${pageTradesCount.toLocaleString()} crypto trades (total: ${totalTradesCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`);
17786
+ log(`Page ${pageCount}: Fetched ${pageTradesCount.toLocaleString()} crypto trades (total: ${totalTradesCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`, { type: 'debug' });
17806
17787
  // Prevent infinite loops
17807
17788
  if (pageCount > 1000) {
17808
17789
  log(`Stopping crypto trades pagination after ${pageCount} pages to prevent infinite loop`, { type: 'warn' });
17809
17790
  break;
17810
17791
  }
17811
17792
  }
17812
- log(`Crypto historical trades fetch complete: ${totalTradesCount.toLocaleString()} total trades across ${pageCount} pages`, { type: 'info' });
17793
+ log(`Crypto historical trades fetch complete: ${totalTradesCount.toLocaleString()} total trades across ${pageCount} pages`);
17813
17794
  return {
17814
17795
  trades: allTrades,
17815
17796
  next_page_token: null, // Always null since we fetch all pages