@discomedia/utils 1.0.6 → 1.0.8

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.
Files changed (80) hide show
  1. package/README.md +95 -3
  2. package/dist/index-frontend.cjs +16027 -0
  3. package/dist/index-frontend.cjs.map +1 -0
  4. package/dist/index-frontend.mjs +16023 -0
  5. package/dist/index-frontend.mjs.map +1 -0
  6. package/dist/index.cjs +558 -10
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.mjs +558 -10
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/package.json +7 -1
  11. package/dist/test.js +6426 -582
  12. package/dist/test.js.map +1 -1
  13. package/dist/types/alpaca-market-data-api.d.ts +1 -0
  14. package/dist/types/alpaca-market-data-api.d.ts.map +1 -1
  15. package/dist/types/alpaca-trading-api.d.ts.map +1 -1
  16. package/dist/types/index-frontend.d.ts +15 -0
  17. package/dist/types/index-frontend.d.ts.map +1 -0
  18. package/dist/types/index.d.ts +1 -0
  19. package/dist/types/index.d.ts.map +1 -1
  20. package/dist/types/old-test.d.ts +2 -0
  21. package/dist/types/old-test.d.ts.map +1 -0
  22. package/dist/types-frontend/alpaca-market-data-api.d.ts +372 -0
  23. package/dist/types-frontend/alpaca-market-data-api.d.ts.map +1 -0
  24. package/dist/types-frontend/alpaca-trading-api.d.ts +315 -0
  25. package/dist/types-frontend/alpaca-trading-api.d.ts.map +1 -0
  26. package/dist/types-frontend/format-tools.d.ts +46 -0
  27. package/dist/types-frontend/format-tools.d.ts.map +1 -0
  28. package/dist/types-frontend/index-frontend.d.ts +15 -0
  29. package/dist/types-frontend/index-frontend.d.ts.map +1 -0
  30. package/dist/types-frontend/index.d.ts +126 -0
  31. package/dist/types-frontend/index.d.ts.map +1 -0
  32. package/dist/types-frontend/json-tools.d.ts +33 -0
  33. package/dist/types-frontend/json-tools.d.ts.map +1 -0
  34. package/dist/types-frontend/llm-config.d.ts +36 -0
  35. package/dist/types-frontend/llm-config.d.ts.map +1 -0
  36. package/dist/types-frontend/llm-deepseek.d.ts +12 -0
  37. package/dist/types-frontend/llm-deepseek.d.ts.map +1 -0
  38. package/dist/types-frontend/llm-images.d.ts +49 -0
  39. package/dist/types-frontend/llm-images.d.ts.map +1 -0
  40. package/dist/types-frontend/llm-openai.d.ts +64 -0
  41. package/dist/types-frontend/llm-openai.d.ts.map +1 -0
  42. package/dist/types-frontend/llm-utils.d.ts +16 -0
  43. package/dist/types-frontend/llm-utils.d.ts.map +1 -0
  44. package/dist/types-frontend/logging.d.ts +12 -0
  45. package/dist/types-frontend/logging.d.ts.map +1 -0
  46. package/dist/types-frontend/market-hours.d.ts +24 -0
  47. package/dist/types-frontend/market-hours.d.ts.map +1 -0
  48. package/dist/types-frontend/market-time.d.ts +254 -0
  49. package/dist/types-frontend/market-time.d.ts.map +1 -0
  50. package/dist/types-frontend/misc-utils.d.ts +49 -0
  51. package/dist/types-frontend/misc-utils.d.ts.map +1 -0
  52. package/dist/types-frontend/old-test.d.ts +2 -0
  53. package/dist/types-frontend/old-test.d.ts.map +1 -0
  54. package/dist/types-frontend/polygon-indices.d.ts +85 -0
  55. package/dist/types-frontend/polygon-indices.d.ts.map +1 -0
  56. package/dist/types-frontend/polygon.d.ts +126 -0
  57. package/dist/types-frontend/polygon.d.ts.map +1 -0
  58. package/dist/types-frontend/technical-analysis.d.ts +90 -0
  59. package/dist/types-frontend/technical-analysis.d.ts.map +1 -0
  60. package/dist/types-frontend/test.d.ts +2 -0
  61. package/dist/types-frontend/test.d.ts.map +1 -0
  62. package/dist/types-frontend/testing/market-time-refactor-test.d.ts +1 -0
  63. package/dist/types-frontend/testing/market-time-refactor-test.d.ts.map +1 -0
  64. package/dist/types-frontend/types/alpaca-types.d.ts +962 -0
  65. package/dist/types-frontend/types/alpaca-types.d.ts.map +1 -0
  66. package/dist/types-frontend/types/index.d.ts +7 -0
  67. package/dist/types-frontend/types/index.d.ts.map +1 -0
  68. package/dist/types-frontend/types/llm-types.d.ts +82 -0
  69. package/dist/types-frontend/types/llm-types.d.ts.map +1 -0
  70. package/dist/types-frontend/types/logging-types.d.ts +10 -0
  71. package/dist/types-frontend/types/logging-types.d.ts.map +1 -0
  72. package/dist/types-frontend/types/market-time-types.d.ts +59 -0
  73. package/dist/types-frontend/types/market-time-types.d.ts.map +1 -0
  74. package/dist/types-frontend/types/polygon-indices-types.d.ts +190 -0
  75. package/dist/types-frontend/types/polygon-indices-types.d.ts.map +1 -0
  76. package/dist/types-frontend/types/polygon-types.d.ts +204 -0
  77. package/dist/types-frontend/types/polygon-types.d.ts.map +1 -0
  78. package/dist/types-frontend/types/ta-types.d.ts +89 -0
  79. package/dist/types-frontend/types/ta-types.d.ts.map +1 -0
  80. package/package.json +7 -1
package/dist/index.cjs CHANGED
@@ -3,15 +3,18 @@
3
3
  var dateFns = require('date-fns');
4
4
  var dateFnsTz = require('date-fns-tz');
5
5
  var require$$0$3 = require('events');
6
- var require$$1$1 = require('https');
6
+ var require$$1 = require('https');
7
7
  var require$$2 = require('http');
8
- var require$$3 = require('net');
9
- var require$$4 = require('tls');
10
- var require$$1 = require('crypto');
8
+ var require$$3$1 = require('net');
9
+ var require$$4$1 = require('tls');
10
+ var require$$3 = require('crypto');
11
11
  var require$$0$2 = require('stream');
12
12
  var require$$7 = require('url');
13
13
  var require$$0 = require('zlib');
14
14
  var require$$0$1 = require('buffer');
15
+ var require$$0$4 = require('fs');
16
+ var require$$1$1 = require('path');
17
+ var require$$2$1 = require('os');
15
18
 
16
19
  /**
17
20
  * Logs a message to the console.
@@ -803,6 +806,34 @@ function getTradingStartAndEndDates(options = {}) {
803
806
  }
804
807
  return { startDate, endDate: endMarketClose };
805
808
  }
809
+ // Export the old MARKET_TIMES constant for backward compatibility
810
+ const MARKET_TIMES = {
811
+ TIMEZONE: MARKET_CONFIG.TIMEZONE,
812
+ PRE: {
813
+ START: { HOUR: 4, MINUTE: 0, MINUTES: 240 },
814
+ END: { HOUR: 9, MINUTE: 30, MINUTES: 570 }
815
+ },
816
+ EARLY_MORNING: {
817
+ START: { HOUR: 9, MINUTE: 30, MINUTES: 570 },
818
+ END: { HOUR: 10, MINUTE: 0, MINUTES: 600 }
819
+ },
820
+ EARLY_CLOSE_BEFORE_HOLIDAY: {
821
+ START: { HOUR: 9, MINUTE: 30, MINUTES: 570 },
822
+ END: { HOUR: 13, MINUTE: 0, MINUTES: 780 }
823
+ },
824
+ EARLY_EXTENDED_BEFORE_HOLIDAY: {
825
+ START: { HOUR: 13, MINUTE: 0, MINUTES: 780 },
826
+ END: { HOUR: 17, MINUTE: 0, MINUTES: 1020 }
827
+ },
828
+ REGULAR: {
829
+ START: { HOUR: 9, MINUTE: 30, MINUTES: 570 },
830
+ END: { HOUR: 16, MINUTE: 0, MINUTES: 960 }
831
+ },
832
+ EXTENDED: {
833
+ START: { HOUR: 4, MINUTE: 0, MINUTES: 240 },
834
+ END: { HOUR: 20, MINUTE: 0, MINUTES: 1200 }
835
+ },
836
+ };
806
837
 
807
838
  // format-tools.ts
808
839
  /**
@@ -11880,7 +11911,7 @@ function requireSender () {
11880
11911
  hasRequiredSender = 1;
11881
11912
 
11882
11913
  const { Duplex } = require$$0$2;
11883
- const { randomFillSync } = require$$1;
11914
+ const { randomFillSync } = require$$3;
11884
11915
 
11885
11916
  const PerMessageDeflate = requirePermessageDeflate();
11886
11917
  const { EMPTY_BUFFER, kWebSocket, NOOP } = requireConstants();
@@ -13001,11 +13032,11 @@ function requireWebsocket () {
13001
13032
  hasRequiredWebsocket = 1;
13002
13033
 
13003
13034
  const EventEmitter = require$$0$3;
13004
- const https = require$$1$1;
13035
+ const https = require$$1;
13005
13036
  const http = require$$2;
13006
- const net = require$$3;
13007
- const tls = require$$4;
13008
- const { randomBytes, createHash } = require$$1;
13037
+ const net = require$$3$1;
13038
+ const tls = require$$4$1;
13039
+ const { randomBytes, createHash } = require$$3;
13009
13040
  const { Duplex, Readable } = require$$0$2;
13010
13041
  const { URL } = require$$7;
13011
13042
 
@@ -14648,7 +14679,7 @@ function requireWebsocketServer () {
14648
14679
  const EventEmitter = require$$0$3;
14649
14680
  const http = require$$2;
14650
14681
  const { Duplex } = require$$0$2;
14651
- const { createHash } = require$$1;
14682
+ const { createHash } = require$$3;
14652
14683
 
14653
14684
  const extension = requireExtension();
14654
14685
  const PerMessageDeflate = requirePermessageDeflate();
@@ -15196,6 +15227,522 @@ function requireWebsocketServer () {
15196
15227
 
15197
15228
  requireWebsocketServer();
15198
15229
 
15230
+ var config = {};
15231
+
15232
+ var main = {exports: {}};
15233
+
15234
+ var version = "17.1.0";
15235
+ var require$$4 = {
15236
+ version: version};
15237
+
15238
+ var hasRequiredMain;
15239
+
15240
+ function requireMain () {
15241
+ if (hasRequiredMain) return main.exports;
15242
+ hasRequiredMain = 1;
15243
+ const fs = require$$0$4;
15244
+ const path = require$$1$1;
15245
+ const os = require$$2$1;
15246
+ const crypto = require$$3;
15247
+ const packageJson = require$$4;
15248
+
15249
+ const version = packageJson.version;
15250
+
15251
+ // Array of tips to display randomly
15252
+ const TIPS = [
15253
+ '🔐 encrypt with dotenvx: https://dotenvx.com',
15254
+ '🔐 prevent committing .env to code: https://dotenvx.com/precommit',
15255
+ '🔐 prevent building .env in docker: https://dotenvx.com/prebuild',
15256
+ '🛠️ run anywhere with `dotenvx run -- yourcommand`',
15257
+ '⚙️ specify custom .env file path with { path: \'/custom/path/.env\' }',
15258
+ '⚙️ enable debug logging with { debug: true }',
15259
+ '⚙️ override existing env vars with { override: true }',
15260
+ '⚙️ suppress all logs with { quiet: true }',
15261
+ '⚙️ write to custom object with { processEnv: myObject }',
15262
+ '⚙️ load multiple .env files with { path: [\'.env.local\', \'.env\'] }'
15263
+ ];
15264
+
15265
+ // Get a random tip from the tips array
15266
+ function _getRandomTip () {
15267
+ return TIPS[Math.floor(Math.random() * TIPS.length)]
15268
+ }
15269
+
15270
+ function supportsAnsi () {
15271
+ return process.stdout.isTTY // && process.env.TERM !== 'dumb'
15272
+ }
15273
+
15274
+ function dim (text) {
15275
+ return supportsAnsi() ? `\x1b[2m${text}\x1b[0m` : text
15276
+ }
15277
+
15278
+ const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
15279
+
15280
+ // Parse src into an Object
15281
+ function parse (src) {
15282
+ const obj = {};
15283
+
15284
+ // Convert buffer to string
15285
+ let lines = src.toString();
15286
+
15287
+ // Convert line breaks to same format
15288
+ lines = lines.replace(/\r\n?/mg, '\n');
15289
+
15290
+ let match;
15291
+ while ((match = LINE.exec(lines)) != null) {
15292
+ const key = match[1];
15293
+
15294
+ // Default undefined or null to empty string
15295
+ let value = (match[2] || '');
15296
+
15297
+ // Remove whitespace
15298
+ value = value.trim();
15299
+
15300
+ // Check if double quoted
15301
+ const maybeQuote = value[0];
15302
+
15303
+ // Remove surrounding quotes
15304
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2');
15305
+
15306
+ // Expand newlines if double quoted
15307
+ if (maybeQuote === '"') {
15308
+ value = value.replace(/\\n/g, '\n');
15309
+ value = value.replace(/\\r/g, '\r');
15310
+ }
15311
+
15312
+ // Add to object
15313
+ obj[key] = value;
15314
+ }
15315
+
15316
+ return obj
15317
+ }
15318
+
15319
+ function _parseVault (options) {
15320
+ options = options || {};
15321
+
15322
+ const vaultPath = _vaultPath(options);
15323
+ options.path = vaultPath; // parse .env.vault
15324
+ const result = DotenvModule.configDotenv(options);
15325
+ if (!result.parsed) {
15326
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
15327
+ err.code = 'MISSING_DATA';
15328
+ throw err
15329
+ }
15330
+
15331
+ // handle scenario for comma separated keys - for use with key rotation
15332
+ // example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod"
15333
+ const keys = _dotenvKey(options).split(',');
15334
+ const length = keys.length;
15335
+
15336
+ let decrypted;
15337
+ for (let i = 0; i < length; i++) {
15338
+ try {
15339
+ // Get full key
15340
+ const key = keys[i].trim();
15341
+
15342
+ // Get instructions for decrypt
15343
+ const attrs = _instructions(result, key);
15344
+
15345
+ // Decrypt
15346
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
15347
+
15348
+ break
15349
+ } catch (error) {
15350
+ // last key
15351
+ if (i + 1 >= length) {
15352
+ throw error
15353
+ }
15354
+ // try next key
15355
+ }
15356
+ }
15357
+
15358
+ // Parse decrypted .env string
15359
+ return DotenvModule.parse(decrypted)
15360
+ }
15361
+
15362
+ function _warn (message) {
15363
+ console.error(`[dotenv@${version}][WARN] ${message}`);
15364
+ }
15365
+
15366
+ function _debug (message) {
15367
+ console.log(`[dotenv@${version}][DEBUG] ${message}`);
15368
+ }
15369
+
15370
+ function _log (message) {
15371
+ console.log(`[dotenv@${version}] ${message}`);
15372
+ }
15373
+
15374
+ function _dotenvKey (options) {
15375
+ // prioritize developer directly setting options.DOTENV_KEY
15376
+ if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
15377
+ return options.DOTENV_KEY
15378
+ }
15379
+
15380
+ // secondary infra already contains a DOTENV_KEY environment variable
15381
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
15382
+ return process.env.DOTENV_KEY
15383
+ }
15384
+
15385
+ // fallback to empty string
15386
+ return ''
15387
+ }
15388
+
15389
+ function _instructions (result, dotenvKey) {
15390
+ // Parse DOTENV_KEY. Format is a URI
15391
+ let uri;
15392
+ try {
15393
+ uri = new URL(dotenvKey);
15394
+ } catch (error) {
15395
+ if (error.code === 'ERR_INVALID_URL') {
15396
+ const err = new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development');
15397
+ err.code = 'INVALID_DOTENV_KEY';
15398
+ throw err
15399
+ }
15400
+
15401
+ throw error
15402
+ }
15403
+
15404
+ // Get decrypt key
15405
+ const key = uri.password;
15406
+ if (!key) {
15407
+ const err = new Error('INVALID_DOTENV_KEY: Missing key part');
15408
+ err.code = 'INVALID_DOTENV_KEY';
15409
+ throw err
15410
+ }
15411
+
15412
+ // Get environment
15413
+ const environment = uri.searchParams.get('environment');
15414
+ if (!environment) {
15415
+ const err = new Error('INVALID_DOTENV_KEY: Missing environment part');
15416
+ err.code = 'INVALID_DOTENV_KEY';
15417
+ throw err
15418
+ }
15419
+
15420
+ // Get ciphertext payload
15421
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
15422
+ const ciphertext = result.parsed[environmentKey]; // DOTENV_VAULT_PRODUCTION
15423
+ if (!ciphertext) {
15424
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
15425
+ err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT';
15426
+ throw err
15427
+ }
15428
+
15429
+ return { ciphertext, key }
15430
+ }
15431
+
15432
+ function _vaultPath (options) {
15433
+ let possibleVaultPath = null;
15434
+
15435
+ if (options && options.path && options.path.length > 0) {
15436
+ if (Array.isArray(options.path)) {
15437
+ for (const filepath of options.path) {
15438
+ if (fs.existsSync(filepath)) {
15439
+ possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`;
15440
+ }
15441
+ }
15442
+ } else {
15443
+ possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`;
15444
+ }
15445
+ } else {
15446
+ possibleVaultPath = path.resolve(process.cwd(), '.env.vault');
15447
+ }
15448
+
15449
+ if (fs.existsSync(possibleVaultPath)) {
15450
+ return possibleVaultPath
15451
+ }
15452
+
15453
+ return null
15454
+ }
15455
+
15456
+ function _resolveHome (envPath) {
15457
+ return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
15458
+ }
15459
+
15460
+ function _configVault (options) {
15461
+ const debug = Boolean(options && options.debug);
15462
+ const quiet = Boolean(options && options.quiet);
15463
+
15464
+ if (debug || !quiet) {
15465
+ _log('Loading env from encrypted .env.vault');
15466
+ }
15467
+
15468
+ const parsed = DotenvModule._parseVault(options);
15469
+
15470
+ let processEnv = process.env;
15471
+ if (options && options.processEnv != null) {
15472
+ processEnv = options.processEnv;
15473
+ }
15474
+
15475
+ DotenvModule.populate(processEnv, parsed, options);
15476
+
15477
+ return { parsed }
15478
+ }
15479
+
15480
+ function configDotenv (options) {
15481
+ const dotenvPath = path.resolve(process.cwd(), '.env');
15482
+ let encoding = 'utf8';
15483
+ const debug = Boolean(options && options.debug);
15484
+ const quiet = Boolean(options && options.quiet);
15485
+
15486
+ if (options && options.encoding) {
15487
+ encoding = options.encoding;
15488
+ } else {
15489
+ if (debug) {
15490
+ _debug('No encoding is specified. UTF-8 is used by default');
15491
+ }
15492
+ }
15493
+
15494
+ let optionPaths = [dotenvPath]; // default, look for .env
15495
+ if (options && options.path) {
15496
+ if (!Array.isArray(options.path)) {
15497
+ optionPaths = [_resolveHome(options.path)];
15498
+ } else {
15499
+ optionPaths = []; // reset default
15500
+ for (const filepath of options.path) {
15501
+ optionPaths.push(_resolveHome(filepath));
15502
+ }
15503
+ }
15504
+ }
15505
+
15506
+ // Build the parsed data in a temporary object (because we need to return it). Once we have the final
15507
+ // parsed data, we will combine it with process.env (or options.processEnv if provided).
15508
+ let lastError;
15509
+ const parsedAll = {};
15510
+ for (const path of optionPaths) {
15511
+ try {
15512
+ // Specifying an encoding returns a string instead of a buffer
15513
+ const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }));
15514
+
15515
+ DotenvModule.populate(parsedAll, parsed, options);
15516
+ } catch (e) {
15517
+ if (debug) {
15518
+ _debug(`Failed to load ${path} ${e.message}`);
15519
+ }
15520
+ lastError = e;
15521
+ }
15522
+ }
15523
+
15524
+ let processEnv = process.env;
15525
+ if (options && options.processEnv != null) {
15526
+ processEnv = options.processEnv;
15527
+ }
15528
+
15529
+ const populated = DotenvModule.populate(processEnv, parsedAll, options);
15530
+
15531
+ if (debug || !quiet) {
15532
+ const keysCount = Object.keys(populated).length;
15533
+ const shortPaths = [];
15534
+ for (const filePath of optionPaths) {
15535
+ try {
15536
+ const relative = path.relative(process.cwd(), filePath);
15537
+ shortPaths.push(relative);
15538
+ } catch (e) {
15539
+ if (debug) {
15540
+ _debug(`Failed to load ${filePath} ${e.message}`);
15541
+ }
15542
+ lastError = e;
15543
+ }
15544
+ }
15545
+
15546
+ _log(`injecting env (${keysCount}) from ${shortPaths.join(',')} ${dim(`(tip: ${_getRandomTip()})`)}`);
15547
+ }
15548
+
15549
+ if (lastError) {
15550
+ return { parsed: parsedAll, error: lastError }
15551
+ } else {
15552
+ return { parsed: parsedAll }
15553
+ }
15554
+ }
15555
+
15556
+ // Populates process.env from .env file
15557
+ function config (options) {
15558
+ // fallback to original dotenv if DOTENV_KEY is not set
15559
+ if (_dotenvKey(options).length === 0) {
15560
+ return DotenvModule.configDotenv(options)
15561
+ }
15562
+
15563
+ const vaultPath = _vaultPath(options);
15564
+
15565
+ // dotenvKey exists but .env.vault file does not exist
15566
+ if (!vaultPath) {
15567
+ _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
15568
+
15569
+ return DotenvModule.configDotenv(options)
15570
+ }
15571
+
15572
+ return DotenvModule._configVault(options)
15573
+ }
15574
+
15575
+ function decrypt (encrypted, keyStr) {
15576
+ const key = Buffer.from(keyStr.slice(-64), 'hex');
15577
+ let ciphertext = Buffer.from(encrypted, 'base64');
15578
+
15579
+ const nonce = ciphertext.subarray(0, 12);
15580
+ const authTag = ciphertext.subarray(-16);
15581
+ ciphertext = ciphertext.subarray(12, -16);
15582
+
15583
+ try {
15584
+ const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce);
15585
+ aesgcm.setAuthTag(authTag);
15586
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`
15587
+ } catch (error) {
15588
+ const isRange = error instanceof RangeError;
15589
+ const invalidKeyLength = error.message === 'Invalid key length';
15590
+ const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data';
15591
+
15592
+ if (isRange || invalidKeyLength) {
15593
+ const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)');
15594
+ err.code = 'INVALID_DOTENV_KEY';
15595
+ throw err
15596
+ } else if (decryptionFailed) {
15597
+ const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY');
15598
+ err.code = 'DECRYPTION_FAILED';
15599
+ throw err
15600
+ } else {
15601
+ throw error
15602
+ }
15603
+ }
15604
+ }
15605
+
15606
+ // Populate process.env with parsed values
15607
+ function populate (processEnv, parsed, options = {}) {
15608
+ const debug = Boolean(options && options.debug);
15609
+ const override = Boolean(options && options.override);
15610
+ const populated = {};
15611
+
15612
+ if (typeof parsed !== 'object') {
15613
+ const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate');
15614
+ err.code = 'OBJECT_REQUIRED';
15615
+ throw err
15616
+ }
15617
+
15618
+ // Set process.env
15619
+ for (const key of Object.keys(parsed)) {
15620
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
15621
+ if (override === true) {
15622
+ processEnv[key] = parsed[key];
15623
+ populated[key] = parsed[key];
15624
+ }
15625
+
15626
+ if (debug) {
15627
+ if (override === true) {
15628
+ _debug(`"${key}" is already defined and WAS overwritten`);
15629
+ } else {
15630
+ _debug(`"${key}" is already defined and was NOT overwritten`);
15631
+ }
15632
+ }
15633
+ } else {
15634
+ processEnv[key] = parsed[key];
15635
+ populated[key] = parsed[key];
15636
+ }
15637
+ }
15638
+
15639
+ return populated
15640
+ }
15641
+
15642
+ const DotenvModule = {
15643
+ configDotenv,
15644
+ _configVault,
15645
+ _parseVault,
15646
+ config,
15647
+ decrypt,
15648
+ parse,
15649
+ populate
15650
+ };
15651
+
15652
+ main.exports.configDotenv = DotenvModule.configDotenv;
15653
+ main.exports._configVault = DotenvModule._configVault;
15654
+ main.exports._parseVault = DotenvModule._parseVault;
15655
+ main.exports.config = DotenvModule.config;
15656
+ main.exports.decrypt = DotenvModule.decrypt;
15657
+ main.exports.parse = DotenvModule.parse;
15658
+ main.exports.populate = DotenvModule.populate;
15659
+
15660
+ main.exports = DotenvModule;
15661
+ return main.exports;
15662
+ }
15663
+
15664
+ var envOptions;
15665
+ var hasRequiredEnvOptions;
15666
+
15667
+ function requireEnvOptions () {
15668
+ if (hasRequiredEnvOptions) return envOptions;
15669
+ hasRequiredEnvOptions = 1;
15670
+ // ../config.js accepts options via environment variables
15671
+ const options = {};
15672
+
15673
+ if (process.env.DOTENV_CONFIG_ENCODING != null) {
15674
+ options.encoding = process.env.DOTENV_CONFIG_ENCODING;
15675
+ }
15676
+
15677
+ if (process.env.DOTENV_CONFIG_PATH != null) {
15678
+ options.path = process.env.DOTENV_CONFIG_PATH;
15679
+ }
15680
+
15681
+ if (process.env.DOTENV_CONFIG_QUIET != null) {
15682
+ options.quiet = process.env.DOTENV_CONFIG_QUIET;
15683
+ }
15684
+
15685
+ if (process.env.DOTENV_CONFIG_DEBUG != null) {
15686
+ options.debug = process.env.DOTENV_CONFIG_DEBUG;
15687
+ }
15688
+
15689
+ if (process.env.DOTENV_CONFIG_OVERRIDE != null) {
15690
+ options.override = process.env.DOTENV_CONFIG_OVERRIDE;
15691
+ }
15692
+
15693
+ if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {
15694
+ options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY;
15695
+ }
15696
+
15697
+ envOptions = options;
15698
+ return envOptions;
15699
+ }
15700
+
15701
+ var cliOptions;
15702
+ var hasRequiredCliOptions;
15703
+
15704
+ function requireCliOptions () {
15705
+ if (hasRequiredCliOptions) return cliOptions;
15706
+ hasRequiredCliOptions = 1;
15707
+ const re = /^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/;
15708
+
15709
+ cliOptions = function optionMatcher (args) {
15710
+ const options = args.reduce(function (acc, cur) {
15711
+ const matches = cur.match(re);
15712
+ if (matches) {
15713
+ acc[matches[1]] = matches[2];
15714
+ }
15715
+ return acc
15716
+ }, {});
15717
+
15718
+ if (!('quiet' in options)) {
15719
+ options.quiet = 'true';
15720
+ }
15721
+
15722
+ return options
15723
+ };
15724
+ return cliOptions;
15725
+ }
15726
+
15727
+ var hasRequiredConfig;
15728
+
15729
+ function requireConfig () {
15730
+ if (hasRequiredConfig) return config;
15731
+ hasRequiredConfig = 1;
15732
+ (function () {
15733
+ requireMain().config(
15734
+ Object.assign(
15735
+ {},
15736
+ requireEnvOptions(),
15737
+ requireCliOptions()(process.argv)
15738
+ )
15739
+ );
15740
+ })();
15741
+ return config;
15742
+ }
15743
+
15744
+ requireConfig();
15745
+
15199
15746
  const log = (message, options = { type: 'info' }) => {
15200
15747
  log$1(message, { ...options, source: 'AlpacaMarketDataAPI' });
15201
15748
  };
@@ -17481,6 +18028,7 @@ const disco = {
17481
18028
  getNYTimeZone: getNYTimeZone,
17482
18029
  getTradingDate: getTradingDate,
17483
18030
  getTradingStartAndEndDates: getTradingStartAndEndDates,
18031
+ MARKET_TIMES: MARKET_TIMES,
17484
18032
  },
17485
18033
  utils: {
17486
18034
  logIfDebug: logIfDebug,