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