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