@discomedia/utils 1.0.41 → 1.0.43

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.7.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;
@@ -7306,20 +7293,19 @@ let Files$1 = class Files extends APIResource {
7306
7293
  * up to 512 MB, and the size of all files uploaded by one organization can be up
7307
7294
  * to 1 TB.
7308
7295
  *
7309
- * The Assistants API supports files up to 2 million tokens and of specific file
7310
- * types. See the
7311
- * [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) for
7312
- * details.
7313
- *
7314
- * The Fine-tuning API only supports `.jsonl` files. The input also has certain
7315
- * required formats for fine-tuning
7316
- * [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or
7317
- * [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
7318
- * models.
7319
- *
7320
- * The Batch API only supports `.jsonl` files up to 200 MB in size. The input also
7321
- * has a specific required
7322
- * [format](https://platform.openai.com/docs/api-reference/batch/request-input).
7296
+ * - The Assistants API supports files up to 2 million tokens and of specific file
7297
+ * types. See the
7298
+ * [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools)
7299
+ * for details.
7300
+ * - The Fine-tuning API only supports `.jsonl` files. The input also has certain
7301
+ * required formats for fine-tuning
7302
+ * [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input)
7303
+ * or
7304
+ * [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
7305
+ * models.
7306
+ * - The Batch API only supports `.jsonl` files up to 200 MB in size. The input
7307
+ * also has a specific required
7308
+ * [format](https://platform.openai.com/docs/api-reference/batch/request-input).
7323
7309
  *
7324
7310
  * Please [contact us](https://help.openai.com/) if you need to increase these
7325
7311
  * storage limits.
@@ -7340,7 +7326,7 @@ let Files$1 = class Files extends APIResource {
7340
7326
  return this._client.getAPIList('/files', (CursorPage), { query, ...options });
7341
7327
  }
7342
7328
  /**
7343
- * Delete a file.
7329
+ * Delete a file and remove it from all vector stores.
7344
7330
  */
7345
7331
  delete(fileID, options) {
7346
7332
  return this._client.delete(path `/files/${fileID}`, options);
@@ -8222,11 +8208,27 @@ class InputItems extends APIResource {
8222
8208
  }
8223
8209
  }
8224
8210
 
8211
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
8212
+ class InputTokens extends APIResource {
8213
+ /**
8214
+ * Get input token counts
8215
+ *
8216
+ * @example
8217
+ * ```ts
8218
+ * const response = await client.responses.inputTokens.count();
8219
+ * ```
8220
+ */
8221
+ count(body = {}, options) {
8222
+ return this._client.post('/responses/input_tokens', { body, ...options });
8223
+ }
8224
+ }
8225
+
8225
8226
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
8226
8227
  class Responses extends APIResource {
8227
8228
  constructor() {
8228
8229
  super(...arguments);
8229
8230
  this.inputItems = new InputItems(this._client);
8231
+ this.inputTokens = new InputTokens(this._client);
8230
8232
  }
8231
8233
  create(body, options) {
8232
8234
  return this._client.post('/responses', { body, ...options, stream: body.stream ?? false })._thenUnwrap((rsp) => {
@@ -8292,6 +8294,7 @@ class Responses extends APIResource {
8292
8294
  }
8293
8295
  }
8294
8296
  Responses.InputItems = InputItems;
8297
+ Responses.InputTokens = InputTokens;
8295
8298
 
8296
8299
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
8297
8300
  class Parts extends APIResource {
@@ -16710,7 +16713,11 @@ function requireConfig () {
16710
16713
 
16711
16714
  requireConfig();
16712
16715
 
16716
+ const DEBUG_LOGGING = process.env['DEBUG'] === 'true' || false;
16713
16717
  const log = (message, options = { type: 'info' }) => {
16718
+ if (!DEBUG_LOGGING && options.type === 'debug') {
16719
+ return;
16720
+ }
16714
16721
  log$1(message, { ...options, source: 'AlpacaMarketDataAPI' });
16715
16722
  };
16716
16723
  // Default settings for market data API
@@ -16800,7 +16807,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
16800
16807
  this.optionWs = ws;
16801
16808
  }
16802
16809
  ws.on('open', () => {
16803
- log(`${streamType} stream connected`, { type: 'info' });
16810
+ log(`${streamType} stream connected`);
16804
16811
  const authMessage = {
16805
16812
  action: 'auth',
16806
16813
  key: process.env.ALPACA_API_KEY,
@@ -16813,7 +16820,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
16813
16820
  const messages = JSON.parse(data.toString());
16814
16821
  for (const message of messages) {
16815
16822
  if (message.T === 'success' && message.msg === 'authenticated') {
16816
- log(`${streamType} stream authenticated`, { type: 'info' });
16823
+ log(`${streamType} stream authenticated`);
16817
16824
  this.sendSubscription(streamType);
16818
16825
  }
16819
16826
  else if (message.T === 'error') {
@@ -16963,9 +16970,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
16963
16970
  symbols.forEach((symbol) => {
16964
16971
  allBars[symbol] = [];
16965
16972
  });
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
- });
16973
+ log(`Starting historical bars fetch for ${symbolsStr.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})`);
16969
16974
  while (hasMorePages) {
16970
16975
  pageCount++;
16971
16976
  const requestParams = {
@@ -17010,7 +17015,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17010
17015
  const dateRangeStr = earliestTimestamp && latestTimestamp
17011
17016
  ? `${new Date(earliestTimestamp).toLocaleDateString('en-US', { timeZone: 'America/New_York' })} to ${new Date(latestTimestamp).toLocaleDateString('en-US', { timeZone: 'America/New_York' })}`
17012
17017
  : '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'}`);
17018
+ 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
17019
  // Prevent infinite loops
17015
17020
  if (pageCount > 1000) {
17016
17021
  log(`Stopping pagination after ${pageCount} pages to prevent infinite loop`, { type: 'warn' });
@@ -17021,7 +17026,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17021
17026
  const symbolsJoined = Object.entries(allBars)
17022
17027
  .map(([symbol, bars]) => `${symbol}: ${bars.length}`)
17023
17028
  .join(', ');
17024
- log(`Historical bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages for ${symbolsJoined.length} symbols'}`);
17029
+ log(`Bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages for ${symbolsJoined.length} symbols'}`);
17025
17030
  return {
17026
17031
  bars: allBars,
17027
17032
  next_page_token: null, // Always null since we fetch all pages
@@ -17302,9 +17307,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17302
17307
  symbols.forEach((symbol) => {
17303
17308
  allBars[symbol] = [];
17304
17309
  });
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
- });
17310
+ log(`Starting historical options bars fetch for ${symbolsStr.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})`);
17308
17311
  while (hasMorePages) {
17309
17312
  pageCount++;
17310
17313
  const requestParams = {
@@ -17344,7 +17347,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17344
17347
  ? `${earliestTimestamp.toLocaleDateString('en-US', { timeZone: 'America/New_York' })} to ${latestTimestamp.toLocaleDateString('en-US', { timeZone: 'America/New_York' })}`
17345
17348
  : 'unknown range';
17346
17349
  log(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} option bars (total: ${totalBarsCount.toLocaleString()}) for ${symbolsStr}, date range: ${dateRangeStr}${hasMorePages ? ', more pages available' : ', complete'}`, {
17347
- type: 'info',
17350
+ type: 'debug',
17348
17351
  });
17349
17352
  // Prevent infinite loops
17350
17353
  if (pageCount > 1000) {
@@ -17356,9 +17359,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17356
17359
  const symbolCounts = Object.entries(allBars)
17357
17360
  .map(([symbol, bars]) => `${symbol}: ${bars.length}`)
17358
17361
  .join(', ');
17359
- log(`Historical options bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages (${symbolCounts})`, {
17360
- type: 'info',
17361
- });
17362
+ log(`Options bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages (${symbolCounts})`);
17362
17363
  return {
17363
17364
  bars: allBars,
17364
17365
  next_page_token: undefined, // Always undefined since we fetch all pages
@@ -17384,9 +17385,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17384
17385
  symbols.forEach((symbol) => {
17385
17386
  allTrades[symbol] = [];
17386
17387
  });
17387
- log(`Starting historical options trades fetch for ${symbolsStr.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`, {
17388
- type: 'info',
17389
- });
17388
+ log(`Starting historical options trades fetch for ${symbolsStr.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`);
17390
17389
  while (hasMorePages) {
17391
17390
  pageCount++;
17392
17391
  const requestParams = {
@@ -17426,7 +17425,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17426
17425
  ? `${earliestTimestamp.toLocaleDateString('en-US', { timeZone: 'America/New_York' })} to ${latestTimestamp.toLocaleDateString('en-US', { timeZone: 'America/New_York' })}`
17427
17426
  : 'unknown range';
17428
17427
  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',
17428
+ type: 'debug',
17430
17429
  });
17431
17430
  // Prevent infinite loops
17432
17431
  if (pageCount > 1000) {
@@ -17438,9 +17437,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17438
17437
  const symbolCounts = Object.entries(allTrades)
17439
17438
  .map(([symbol, trades]) => `${symbol}: ${trades.length}`)
17440
17439
  .join(', ');
17441
- log(`Historical options trades fetch complete: ${totalTradesCount.toLocaleString()} total trades across ${pageCount} pages (${symbolCounts})`, {
17442
- type: 'info',
17443
- });
17440
+ log(`Options trades fetch complete: ${totalTradesCount.toLocaleString()} total trades across ${pageCount} pages (${symbolCounts})`);
17444
17441
  return {
17445
17442
  trades: allTrades,
17446
17443
  next_page_token: undefined, // Always undefined since we fetch all pages
@@ -17648,7 +17645,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17648
17645
  symbols.forEach((symbol) => {
17649
17646
  allBars[symbol] = [];
17650
17647
  });
17651
- log(`Starting crypto historical bars fetch for ${symbols.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})`, { type: 'info' });
17648
+ log(`Starting crypto historical bars fetch for ${symbols.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})`);
17652
17649
  while (hasMorePages) {
17653
17650
  pageCount++;
17654
17651
  const requestParams = {
@@ -17672,14 +17669,14 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17672
17669
  totalBarsCount += pageBarsCount;
17673
17670
  pageToken = response.next_page_token || null;
17674
17671
  hasMorePages = !!pageToken;
17675
- log(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} crypto bars (total: ${totalBarsCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`);
17672
+ log(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} crypto bars (total: ${totalBarsCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`, { type: 'debug' });
17676
17673
  // Prevent infinite loops
17677
17674
  if (pageCount > 1000) {
17678
17675
  log(`Stopping crypto bars pagination after ${pageCount} pages to prevent infinite loop`, { type: 'warn' });
17679
17676
  break;
17680
17677
  }
17681
17678
  }
17682
- log(`Crypto historical bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages`, { type: 'info' });
17679
+ log(`Crypto historical bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages`);
17683
17680
  return {
17684
17681
  bars: allBars,
17685
17682
  next_page_token: null, // Always null since we fetch all pages
@@ -17711,7 +17708,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17711
17708
  symbols.forEach((symbol) => {
17712
17709
  allQuotes[symbol] = [];
17713
17710
  });
17714
- log(`Starting crypto historical quotes fetch for ${symbols.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`, { type: 'info' });
17711
+ log(`Starting crypto historical quotes fetch for ${symbols.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`);
17715
17712
  while (hasMorePages) {
17716
17713
  pageCount++;
17717
17714
  const requestParams = {
@@ -17735,14 +17732,14 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17735
17732
  totalQuotesCount += pageQuotesCount;
17736
17733
  pageToken = response.next_page_token || null;
17737
17734
  hasMorePages = !!pageToken;
17738
- log(`Page ${pageCount}: Fetched ${pageQuotesCount.toLocaleString()} crypto quotes (total: ${totalQuotesCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`);
17735
+ log(`Page ${pageCount}: Fetched ${pageQuotesCount.toLocaleString()} crypto quotes (total: ${totalQuotesCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`, { type: 'debug' });
17739
17736
  // Prevent infinite loops
17740
17737
  if (pageCount > 1000) {
17741
17738
  log(`Stopping crypto quotes pagination after ${pageCount} pages to prevent infinite loop`, { type: 'warn' });
17742
17739
  break;
17743
17740
  }
17744
17741
  }
17745
- log(`Crypto historical quotes fetch complete: ${totalQuotesCount.toLocaleString()} total quotes across ${pageCount} pages`, { type: 'info' });
17742
+ log(`Crypto historical quotes fetch complete: ${totalQuotesCount.toLocaleString()} total quotes across ${pageCount} pages`);
17746
17743
  return {
17747
17744
  quotes: allQuotes,
17748
17745
  next_page_token: null, // Always null since we fetch all pages
@@ -17778,7 +17775,7 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17778
17775
  symbols.forEach((symbol) => {
17779
17776
  allTrades[symbol] = [];
17780
17777
  });
17781
- log(`Starting crypto historical trades fetch for ${symbols.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`, { type: 'info' });
17778
+ log(`Starting crypto historical trades fetch for ${symbols.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`);
17782
17779
  while (hasMorePages) {
17783
17780
  pageCount++;
17784
17781
  const requestParams = {
@@ -17802,14 +17799,14 @@ class AlpacaMarketDataAPI extends require$$0$3.EventEmitter {
17802
17799
  totalTradesCount += pageTradesCount;
17803
17800
  pageToken = response.next_page_token || null;
17804
17801
  hasMorePages = !!pageToken;
17805
- log(`Page ${pageCount}: Fetched ${pageTradesCount.toLocaleString()} crypto trades (total: ${totalTradesCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`);
17802
+ log(`Page ${pageCount}: Fetched ${pageTradesCount.toLocaleString()} crypto trades (total: ${totalTradesCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`, { type: 'debug' });
17806
17803
  // Prevent infinite loops
17807
17804
  if (pageCount > 1000) {
17808
17805
  log(`Stopping crypto trades pagination after ${pageCount} pages to prevent infinite loop`, { type: 'warn' });
17809
17806
  break;
17810
17807
  }
17811
17808
  }
17812
- log(`Crypto historical trades fetch complete: ${totalTradesCount.toLocaleString()} total trades across ${pageCount} pages`, { type: 'info' });
17809
+ log(`Crypto historical trades fetch complete: ${totalTradesCount.toLocaleString()} total trades across ${pageCount} pages`);
17813
17810
  return {
17814
17811
  trades: allTrades,
17815
17812
  next_page_token: null, // Always null since we fetch all pages