@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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.0.41",
6
+ "version": "1.0.42",
7
7
  "author": "Disco Media",
8
8
  "description": "Utility functions used in Disco Media apps",
9
9
  "always-build-npm": true,
@@ -33,20 +33,20 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "dotenv": "^17.2.3",
36
- "openai": "^6.2.0",
37
- "p-limit": "^7.1.1",
36
+ "openai": "^6.5.0",
37
+ "p-limit": "^7.2.0",
38
38
  "tslib": "^2.8.1",
39
39
  "ws": "^8.18.3"
40
40
  },
41
41
  "license": "ISC",
42
42
  "devDependencies": {
43
- "@rollup/plugin-commonjs": "^28.0.6",
43
+ "@rollup/plugin-commonjs": "^28.0.8",
44
44
  "@rollup/plugin-json": "^6.1.0",
45
- "@rollup/plugin-node-resolve": "^16.0.2",
45
+ "@rollup/plugin-node-resolve": "^16.0.3",
46
46
  "@rollup/plugin-typescript": "^12.1.4",
47
47
  "@types/ws": "^8.18.1",
48
48
  "lightweight-charts": "^5.0.9",
49
- "rollup": "^4.52.4",
49
+ "rollup": "^4.52.5",
50
50
  "typescript": "^5.9.3"
51
51
  }
52
52
  }
package/dist/test.js CHANGED
@@ -532,8 +532,8 @@ function pLimit(concurrency) {
532
532
  },
533
533
  },
534
534
  map: {
535
- async value(array, function_) {
536
- const promises = array.map((value, index) => this(function_, value, index));
535
+ async value(iterable, function_) {
536
+ const promises = Array.from(iterable, (value, index) => this(function_, value, index));
537
537
  return Promise.all(promises);
538
538
  },
539
539
  },
@@ -799,7 +799,7 @@ const safeJSON = (text) => {
799
799
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
800
800
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
801
801
 
802
- const VERSION = '6.2.0'; // x-release-please-version
802
+ const VERSION = '6.5.0'; // x-release-please-version
803
803
 
804
804
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
805
805
  const isRunningInBrowser = () => {
@@ -4354,19 +4354,6 @@ class ChatKit extends APIResource {
4354
4354
  this.sessions = new Sessions(this._client);
4355
4355
  this.threads = new Threads$1(this._client);
4356
4356
  }
4357
- /**
4358
- * Upload a ChatKit file
4359
- *
4360
- * @example
4361
- * ```ts
4362
- * const response = await client.beta.chatkit.uploadFile({
4363
- * file: fs.createReadStream('path/to/file'),
4364
- * });
4365
- * ```
4366
- */
4367
- uploadFile(body, options) {
4368
- return this._client.post('/chatkit/files', maybeMultipartFormRequestOptions({ body, ...options, headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]) }, this._client));
4369
- }
4370
4357
  }
4371
4358
  ChatKit.Sessions = Sessions;
4372
4359
  ChatKit.Threads = Threads$1;
@@ -5688,7 +5675,7 @@ let Files$1 = class Files extends APIResource {
5688
5675
  return this._client.getAPIList('/files', (CursorPage), { query, ...options });
5689
5676
  }
5690
5677
  /**
5691
- * Delete a file.
5678
+ * Delete a file and remove it from all vector stores.
5692
5679
  */
5693
5680
  delete(fileID, options) {
5694
5681
  return this._client.delete(path `/files/${fileID}`, options);
@@ -13225,7 +13212,11 @@ function requireConfig () {
13225
13212
 
13226
13213
  requireConfig();
13227
13214
 
13215
+ const DEBUG_LOGGING = process.env['DEBUG'] === 'true' || false;
13228
13216
  const log = (message, options = { type: 'info' }) => {
13217
+ if (!DEBUG_LOGGING && options.type === 'debug') {
13218
+ return;
13219
+ }
13229
13220
  log$1(message, { ...options, source: 'AlpacaMarketDataAPI' });
13230
13221
  };
13231
13222
  // Default settings for market data API
@@ -13315,7 +13306,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
13315
13306
  this.optionWs = ws;
13316
13307
  }
13317
13308
  ws.on('open', () => {
13318
- log(`${streamType} stream connected`, { type: 'info' });
13309
+ log(`${streamType} stream connected`);
13319
13310
  const authMessage = {
13320
13311
  action: 'auth',
13321
13312
  key: process.env.ALPACA_API_KEY,
@@ -13328,7 +13319,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
13328
13319
  const messages = JSON.parse(data.toString());
13329
13320
  for (const message of messages) {
13330
13321
  if (message.T === 'success' && message.msg === 'authenticated') {
13331
- log(`${streamType} stream authenticated`, { type: 'info' });
13322
+ log(`${streamType} stream authenticated`);
13332
13323
  this.sendSubscription(streamType);
13333
13324
  }
13334
13325
  else if (message.T === 'error') {
@@ -13478,9 +13469,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
13478
13469
  symbols.forEach((symbol) => {
13479
13470
  allBars[symbol] = [];
13480
13471
  });
13481
- log(`Starting historical bars fetch for ${symbolsStr.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})`, {
13482
- type: 'info',
13483
- });
13472
+ log(`Starting historical bars fetch for ${symbolsStr.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})`);
13484
13473
  while (hasMorePages) {
13485
13474
  pageCount++;
13486
13475
  const requestParams = {
@@ -13525,7 +13514,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
13525
13514
  const dateRangeStr = earliestTimestamp && latestTimestamp
13526
13515
  ? `${new Date(earliestTimestamp).toLocaleDateString('en-US', { timeZone: 'America/New_York' })} to ${new Date(latestTimestamp).toLocaleDateString('en-US', { timeZone: 'America/New_York' })}`
13527
13516
  : 'unknown range';
13528
- log(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} bars (total: ${totalBarsCount.toLocaleString()}) for ${symbols.length} symbols, date range: ${dateRangeStr}${hasMorePages ? ', more pages available' : ', complete'}`);
13517
+ log(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} bars (total: ${totalBarsCount.toLocaleString()}) for ${symbols.length} symbols, date range: ${dateRangeStr}${hasMorePages ? ', more pages available' : ', complete'}`, { type: 'debug' });
13529
13518
  // Prevent infinite loops
13530
13519
  if (pageCount > 1000) {
13531
13520
  log(`Stopping pagination after ${pageCount} pages to prevent infinite loop`, { type: 'warn' });
@@ -13536,7 +13525,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
13536
13525
  const symbolsJoined = Object.entries(allBars)
13537
13526
  .map(([symbol, bars]) => `${symbol}: ${bars.length}`)
13538
13527
  .join(', ');
13539
- log(`Historical bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages for ${symbolsJoined.length} symbols'}`);
13528
+ log(`Bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages for ${symbolsJoined.length} symbols'}`);
13540
13529
  return {
13541
13530
  bars: allBars,
13542
13531
  next_page_token: null, // Always null since we fetch all pages
@@ -13817,9 +13806,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
13817
13806
  symbols.forEach((symbol) => {
13818
13807
  allBars[symbol] = [];
13819
13808
  });
13820
- log(`Starting historical options bars fetch for ${symbolsStr.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})`, {
13821
- type: 'info',
13822
- });
13809
+ log(`Starting historical options bars fetch for ${symbolsStr.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})`);
13823
13810
  while (hasMorePages) {
13824
13811
  pageCount++;
13825
13812
  const requestParams = {
@@ -13859,7 +13846,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
13859
13846
  ? `${earliestTimestamp.toLocaleDateString('en-US', { timeZone: 'America/New_York' })} to ${latestTimestamp.toLocaleDateString('en-US', { timeZone: 'America/New_York' })}`
13860
13847
  : 'unknown range';
13861
13848
  log(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} option bars (total: ${totalBarsCount.toLocaleString()}) for ${symbolsStr}, date range: ${dateRangeStr}${hasMorePages ? ', more pages available' : ', complete'}`, {
13862
- type: 'info',
13849
+ type: 'debug',
13863
13850
  });
13864
13851
  // Prevent infinite loops
13865
13852
  if (pageCount > 1000) {
@@ -13871,9 +13858,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
13871
13858
  const symbolCounts = Object.entries(allBars)
13872
13859
  .map(([symbol, bars]) => `${symbol}: ${bars.length}`)
13873
13860
  .join(', ');
13874
- log(`Historical options bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages (${symbolCounts})`, {
13875
- type: 'info',
13876
- });
13861
+ log(`Options bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages (${symbolCounts})`);
13877
13862
  return {
13878
13863
  bars: allBars,
13879
13864
  next_page_token: undefined, // Always undefined since we fetch all pages
@@ -13899,9 +13884,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
13899
13884
  symbols.forEach((symbol) => {
13900
13885
  allTrades[symbol] = [];
13901
13886
  });
13902
- log(`Starting historical options trades fetch for ${symbolsStr.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`, {
13903
- type: 'info',
13904
- });
13887
+ log(`Starting historical options trades fetch for ${symbolsStr.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`);
13905
13888
  while (hasMorePages) {
13906
13889
  pageCount++;
13907
13890
  const requestParams = {
@@ -13941,7 +13924,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
13941
13924
  ? `${earliestTimestamp.toLocaleDateString('en-US', { timeZone: 'America/New_York' })} to ${latestTimestamp.toLocaleDateString('en-US', { timeZone: 'America/New_York' })}`
13942
13925
  : 'unknown range';
13943
13926
  log(`Page ${pageCount}: Fetched ${pageTradesCount.toLocaleString()} option trades (total: ${totalTradesCount.toLocaleString()}) for ${symbolsStr.length} symbols, date range: ${dateRangeStr}${hasMorePages ? ', more pages available' : ', complete'}`, {
13944
- type: 'info',
13927
+ type: 'debug',
13945
13928
  });
13946
13929
  // Prevent infinite loops
13947
13930
  if (pageCount > 1000) {
@@ -13953,9 +13936,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
13953
13936
  const symbolCounts = Object.entries(allTrades)
13954
13937
  .map(([symbol, trades]) => `${symbol}: ${trades.length}`)
13955
13938
  .join(', ');
13956
- log(`Historical options trades fetch complete: ${totalTradesCount.toLocaleString()} total trades across ${pageCount} pages (${symbolCounts})`, {
13957
- type: 'info',
13958
- });
13939
+ log(`Options trades fetch complete: ${totalTradesCount.toLocaleString()} total trades across ${pageCount} pages (${symbolCounts})`);
13959
13940
  return {
13960
13941
  trades: allTrades,
13961
13942
  next_page_token: undefined, // Always undefined since we fetch all pages
@@ -14163,7 +14144,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
14163
14144
  symbols.forEach((symbol) => {
14164
14145
  allBars[symbol] = [];
14165
14146
  });
14166
- log(`Starting crypto historical bars fetch for ${symbols.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})`, { type: 'info' });
14147
+ log(`Starting crypto historical bars fetch for ${symbols.length} symbols (${params.timeframe}, ${params.start || 'no start'} to ${params.end || 'no end'})`);
14167
14148
  while (hasMorePages) {
14168
14149
  pageCount++;
14169
14150
  const requestParams = {
@@ -14187,14 +14168,14 @@ class AlpacaMarketDataAPI extends EventEmitter {
14187
14168
  totalBarsCount += pageBarsCount;
14188
14169
  pageToken = response.next_page_token || null;
14189
14170
  hasMorePages = !!pageToken;
14190
- log(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} crypto bars (total: ${totalBarsCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`);
14171
+ log(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} crypto bars (total: ${totalBarsCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`, { type: 'debug' });
14191
14172
  // Prevent infinite loops
14192
14173
  if (pageCount > 1000) {
14193
14174
  log(`Stopping crypto bars pagination after ${pageCount} pages to prevent infinite loop`, { type: 'warn' });
14194
14175
  break;
14195
14176
  }
14196
14177
  }
14197
- log(`Crypto historical bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages`, { type: 'info' });
14178
+ log(`Crypto historical bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages`);
14198
14179
  return {
14199
14180
  bars: allBars,
14200
14181
  next_page_token: null, // Always null since we fetch all pages
@@ -14226,7 +14207,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
14226
14207
  symbols.forEach((symbol) => {
14227
14208
  allQuotes[symbol] = [];
14228
14209
  });
14229
- log(`Starting crypto historical quotes fetch for ${symbols.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`, { type: 'info' });
14210
+ log(`Starting crypto historical quotes fetch for ${symbols.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`);
14230
14211
  while (hasMorePages) {
14231
14212
  pageCount++;
14232
14213
  const requestParams = {
@@ -14250,14 +14231,14 @@ class AlpacaMarketDataAPI extends EventEmitter {
14250
14231
  totalQuotesCount += pageQuotesCount;
14251
14232
  pageToken = response.next_page_token || null;
14252
14233
  hasMorePages = !!pageToken;
14253
- log(`Page ${pageCount}: Fetched ${pageQuotesCount.toLocaleString()} crypto quotes (total: ${totalQuotesCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`);
14234
+ log(`Page ${pageCount}: Fetched ${pageQuotesCount.toLocaleString()} crypto quotes (total: ${totalQuotesCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`, { type: 'debug' });
14254
14235
  // Prevent infinite loops
14255
14236
  if (pageCount > 1000) {
14256
14237
  log(`Stopping crypto quotes pagination after ${pageCount} pages to prevent infinite loop`, { type: 'warn' });
14257
14238
  break;
14258
14239
  }
14259
14240
  }
14260
- log(`Crypto historical quotes fetch complete: ${totalQuotesCount.toLocaleString()} total quotes across ${pageCount} pages`, { type: 'info' });
14241
+ log(`Crypto historical quotes fetch complete: ${totalQuotesCount.toLocaleString()} total quotes across ${pageCount} pages`);
14261
14242
  return {
14262
14243
  quotes: allQuotes,
14263
14244
  next_page_token: null, // Always null since we fetch all pages
@@ -14293,7 +14274,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
14293
14274
  symbols.forEach((symbol) => {
14294
14275
  allTrades[symbol] = [];
14295
14276
  });
14296
- log(`Starting crypto historical trades fetch for ${symbols.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`, { type: 'info' });
14277
+ log(`Starting crypto historical trades fetch for ${symbols.length} symbols (${params.start || 'no start'} to ${params.end || 'no end'})`);
14297
14278
  while (hasMorePages) {
14298
14279
  pageCount++;
14299
14280
  const requestParams = {
@@ -14317,14 +14298,14 @@ class AlpacaMarketDataAPI extends EventEmitter {
14317
14298
  totalTradesCount += pageTradesCount;
14318
14299
  pageToken = response.next_page_token || null;
14319
14300
  hasMorePages = !!pageToken;
14320
- log(`Page ${pageCount}: Fetched ${pageTradesCount.toLocaleString()} crypto trades (total: ${totalTradesCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`);
14301
+ log(`Page ${pageCount}: Fetched ${pageTradesCount.toLocaleString()} crypto trades (total: ${totalTradesCount.toLocaleString()}) for ${symbols.length} symbols${hasMorePages ? ', more pages available' : ', complete'}`, { type: 'debug' });
14321
14302
  // Prevent infinite loops
14322
14303
  if (pageCount > 1000) {
14323
14304
  log(`Stopping crypto trades pagination after ${pageCount} pages to prevent infinite loop`, { type: 'warn' });
14324
14305
  break;
14325
14306
  }
14326
14307
  }
14327
- log(`Crypto historical trades fetch complete: ${totalTradesCount.toLocaleString()} total trades across ${pageCount} pages`, { type: 'info' });
14308
+ log(`Crypto historical trades fetch complete: ${totalTradesCount.toLocaleString()} total trades across ${pageCount} pages`);
14328
14309
  return {
14329
14310
  trades: allTrades,
14330
14311
  next_page_token: null, // Always null since we fetch all pages