@discomedia/utils 1.0.13 → 1.0.15
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-frontend.cjs +33 -22
- package/dist/index-frontend.cjs.map +1 -1
- package/dist/index-frontend.mjs +33 -22
- package/dist/index-frontend.mjs.map +1 -1
- package/dist/index.cjs +34 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +34 -23
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +4 -4
- package/dist/test.js +33 -20
- package/dist/test.js.map +1 -1
- package/dist/types/market-time.d.ts +0 -1
- package/dist/types/market-time.d.ts.map +1 -1
- package/dist/types-frontend/market-time.d.ts +0 -1
- package/dist/types-frontend/market-time.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -311,12 +311,10 @@ class TimeFormatter {
|
|
|
311
311
|
*/
|
|
312
312
|
class MarketTimeCalculator {
|
|
313
313
|
calendar;
|
|
314
|
-
formatter;
|
|
315
314
|
timezone;
|
|
316
315
|
constructor(timezone = MARKET_CONFIG.TIMEZONE) {
|
|
317
316
|
this.timezone = timezone;
|
|
318
317
|
this.calendar = new MarketCalendar(timezone);
|
|
319
|
-
this.formatter = new TimeFormatter(timezone);
|
|
320
318
|
}
|
|
321
319
|
/**
|
|
322
320
|
* Get market open/close times for a date
|
|
@@ -806,7 +804,7 @@ function getTradingStartAndEndDates(options = {}) {
|
|
|
806
804
|
}
|
|
807
805
|
return { startDate, endDate: endMarketClose };
|
|
808
806
|
}
|
|
809
|
-
// Export the
|
|
807
|
+
// Export the MARKET_TIMES constant for backward compatibility
|
|
810
808
|
const MARKET_TIMES = {
|
|
811
809
|
TIMEZONE: MARKET_CONFIG.TIMEZONE,
|
|
812
810
|
PRE: {
|
|
@@ -2262,7 +2260,7 @@ const safeJSON = (text) => {
|
|
|
2262
2260
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2263
2261
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
2264
2262
|
|
|
2265
|
-
const VERSION = '5.
|
|
2263
|
+
const VERSION = '5.9.0'; // x-release-please-version
|
|
2266
2264
|
|
|
2267
2265
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2268
2266
|
const isRunningInBrowser = () => {
|
|
@@ -8335,7 +8333,7 @@ class OpenAI {
|
|
|
8335
8333
|
* Create a new client instance re-using the same options given to the current client with optional overriding.
|
|
8336
8334
|
*/
|
|
8337
8335
|
withOptions(options) {
|
|
8338
|
-
|
|
8336
|
+
const client = new this.constructor({
|
|
8339
8337
|
...this._options,
|
|
8340
8338
|
baseURL: this.baseURL,
|
|
8341
8339
|
maxRetries: this.maxRetries,
|
|
@@ -8350,6 +8348,7 @@ class OpenAI {
|
|
|
8350
8348
|
webhookSecret: this.webhookSecret,
|
|
8351
8349
|
...options,
|
|
8352
8350
|
});
|
|
8351
|
+
return client;
|
|
8353
8352
|
}
|
|
8354
8353
|
defaultQuery() {
|
|
8355
8354
|
return this._options.defaultQuery;
|
|
@@ -8357,7 +8356,7 @@ class OpenAI {
|
|
|
8357
8356
|
validateHeaders({ values, nulls }) {
|
|
8358
8357
|
return;
|
|
8359
8358
|
}
|
|
8360
|
-
authHeaders(opts) {
|
|
8359
|
+
async authHeaders(opts) {
|
|
8361
8360
|
return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
|
|
8362
8361
|
}
|
|
8363
8362
|
stringifyQuery(query) {
|
|
@@ -8427,7 +8426,9 @@ class OpenAI {
|
|
|
8427
8426
|
retriesRemaining = maxRetries;
|
|
8428
8427
|
}
|
|
8429
8428
|
await this.prepareOptions(options);
|
|
8430
|
-
const { req, url, timeout } = this.buildRequest(options, {
|
|
8429
|
+
const { req, url, timeout } = await this.buildRequest(options, {
|
|
8430
|
+
retryCount: maxRetries - retriesRemaining,
|
|
8431
|
+
});
|
|
8431
8432
|
await this.prepareRequest(req, { url, options });
|
|
8432
8433
|
/** Not an API request ID, just for correlating local log entries. */
|
|
8433
8434
|
const requestLogID = 'log_' + ((Math.random() * (1 << 24)) | 0).toString(16).padStart(6, '0');
|
|
@@ -8485,7 +8486,7 @@ class OpenAI {
|
|
|
8485
8486
|
.join('');
|
|
8486
8487
|
const responseInfo = `[${requestLogID}${retryLogStr}${specialHeaders}] ${req.method} ${url} ${response.ok ? 'succeeded' : 'failed'} with status ${response.status} in ${headersTime - startTime}ms`;
|
|
8487
8488
|
if (!response.ok) {
|
|
8488
|
-
const shouldRetry = this.shouldRetry(response);
|
|
8489
|
+
const shouldRetry = await this.shouldRetry(response);
|
|
8489
8490
|
if (retriesRemaining && shouldRetry) {
|
|
8490
8491
|
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
8491
8492
|
// We don't need the body of this response.
|
|
@@ -8559,7 +8560,7 @@ class OpenAI {
|
|
|
8559
8560
|
clearTimeout(timeout);
|
|
8560
8561
|
}
|
|
8561
8562
|
}
|
|
8562
|
-
shouldRetry(response) {
|
|
8563
|
+
async shouldRetry(response) {
|
|
8563
8564
|
// Note this is not a standard header.
|
|
8564
8565
|
const shouldRetryHeader = response.headers.get('x-should-retry');
|
|
8565
8566
|
// If the server explicitly says whether or not to retry, obey.
|
|
@@ -8621,7 +8622,7 @@ class OpenAI {
|
|
|
8621
8622
|
const jitter = 1 - Math.random() * 0.25;
|
|
8622
8623
|
return sleepSeconds * jitter * 1000;
|
|
8623
8624
|
}
|
|
8624
|
-
buildRequest(inputOptions, { retryCount = 0 } = {}) {
|
|
8625
|
+
async buildRequest(inputOptions, { retryCount = 0 } = {}) {
|
|
8625
8626
|
const options = { ...inputOptions };
|
|
8626
8627
|
const { method, path, query, defaultBaseURL } = options;
|
|
8627
8628
|
const url = this.buildURL(path, query, defaultBaseURL);
|
|
@@ -8629,7 +8630,7 @@ class OpenAI {
|
|
|
8629
8630
|
validatePositiveInteger('timeout', options.timeout);
|
|
8630
8631
|
options.timeout = options.timeout ?? this.timeout;
|
|
8631
8632
|
const { bodyHeaders, body } = this.buildBody({ options });
|
|
8632
|
-
const reqHeaders = this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
|
|
8633
|
+
const reqHeaders = await this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
|
|
8633
8634
|
const req = {
|
|
8634
8635
|
method,
|
|
8635
8636
|
headers: reqHeaders,
|
|
@@ -8642,7 +8643,7 @@ class OpenAI {
|
|
|
8642
8643
|
};
|
|
8643
8644
|
return { req, url, timeout: options.timeout };
|
|
8644
8645
|
}
|
|
8645
|
-
buildHeaders({ options, method, bodyHeaders, retryCount, }) {
|
|
8646
|
+
async buildHeaders({ options, method, bodyHeaders, retryCount, }) {
|
|
8646
8647
|
let idempotencyHeaders = {};
|
|
8647
8648
|
if (this.idempotencyHeader && method !== 'get') {
|
|
8648
8649
|
if (!options.idempotencyKey)
|
|
@@ -8660,7 +8661,7 @@ class OpenAI {
|
|
|
8660
8661
|
'OpenAI-Organization': this.organization,
|
|
8661
8662
|
'OpenAI-Project': this.project,
|
|
8662
8663
|
},
|
|
8663
|
-
this.authHeaders(options),
|
|
8664
|
+
await this.authHeaders(options),
|
|
8664
8665
|
this._options.defaultHeaders,
|
|
8665
8666
|
bodyHeaders,
|
|
8666
8667
|
options.headers,
|
|
@@ -15400,7 +15401,7 @@ var config = {};
|
|
|
15400
15401
|
|
|
15401
15402
|
var main = {exports: {}};
|
|
15402
15403
|
|
|
15403
|
-
var version = "17.
|
|
15404
|
+
var version = "17.2.0";
|
|
15404
15405
|
var require$$4 = {
|
|
15405
15406
|
version: version};
|
|
15406
15407
|
|
|
@@ -15436,6 +15437,13 @@ function requireMain () {
|
|
|
15436
15437
|
return TIPS[Math.floor(Math.random() * TIPS.length)]
|
|
15437
15438
|
}
|
|
15438
15439
|
|
|
15440
|
+
function parseBoolean (value) {
|
|
15441
|
+
if (typeof value === 'string') {
|
|
15442
|
+
return !['false', '0', 'no', 'off', ''].includes(value.toLowerCase())
|
|
15443
|
+
}
|
|
15444
|
+
return Boolean(value)
|
|
15445
|
+
}
|
|
15446
|
+
|
|
15439
15447
|
function supportsAnsi () {
|
|
15440
15448
|
return process.stdout.isTTY // && process.env.TERM !== 'dumb'
|
|
15441
15449
|
}
|
|
@@ -15627,8 +15635,8 @@ function requireMain () {
|
|
|
15627
15635
|
}
|
|
15628
15636
|
|
|
15629
15637
|
function _configVault (options) {
|
|
15630
|
-
const debug =
|
|
15631
|
-
const quiet =
|
|
15638
|
+
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || (options && options.debug));
|
|
15639
|
+
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || (options && options.quiet));
|
|
15632
15640
|
|
|
15633
15641
|
if (debug || !quiet) {
|
|
15634
15642
|
_log('Loading env from encrypted .env.vault');
|
|
@@ -15649,8 +15657,12 @@ function requireMain () {
|
|
|
15649
15657
|
function configDotenv (options) {
|
|
15650
15658
|
const dotenvPath = path.resolve(process.cwd(), '.env');
|
|
15651
15659
|
let encoding = 'utf8';
|
|
15652
|
-
|
|
15653
|
-
|
|
15660
|
+
let processEnv = process.env;
|
|
15661
|
+
if (options && options.processEnv != null) {
|
|
15662
|
+
processEnv = options.processEnv;
|
|
15663
|
+
}
|
|
15664
|
+
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || (options && options.debug));
|
|
15665
|
+
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || (options && options.quiet));
|
|
15654
15666
|
|
|
15655
15667
|
if (options && options.encoding) {
|
|
15656
15668
|
encoding = options.encoding;
|
|
@@ -15690,13 +15702,12 @@ function requireMain () {
|
|
|
15690
15702
|
}
|
|
15691
15703
|
}
|
|
15692
15704
|
|
|
15693
|
-
let processEnv = process.env;
|
|
15694
|
-
if (options && options.processEnv != null) {
|
|
15695
|
-
processEnv = options.processEnv;
|
|
15696
|
-
}
|
|
15697
|
-
|
|
15698
15705
|
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
|
15699
15706
|
|
|
15707
|
+
// handle user settings DOTENV_CONFIG_ options inside .env file(s)
|
|
15708
|
+
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
|
15709
|
+
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
|
15710
|
+
|
|
15700
15711
|
if (debug || !quiet) {
|
|
15701
15712
|
const keysCount = Object.keys(populated).length;
|
|
15702
15713
|
const shortPaths = [];
|