@discomedia/utils 1.0.12 → 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/dist/types/types/llm-types.d.ts +1 -2
- package/dist/types/types/llm-types.d.ts.map +1 -1
- package/dist/types-frontend/types/llm-types.d.ts +1 -2
- package/dist/types-frontend/types/llm-types.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index-frontend.mjs
CHANGED
|
@@ -249,7 +249,7 @@ const safeJSON = (text) => {
|
|
|
249
249
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
250
250
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
251
251
|
|
|
252
|
-
const VERSION = '5.
|
|
252
|
+
const VERSION = '5.9.0'; // x-release-please-version
|
|
253
253
|
|
|
254
254
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
255
255
|
const isRunningInBrowser = () => {
|
|
@@ -6322,7 +6322,7 @@ class OpenAI {
|
|
|
6322
6322
|
* Create a new client instance re-using the same options given to the current client with optional overriding.
|
|
6323
6323
|
*/
|
|
6324
6324
|
withOptions(options) {
|
|
6325
|
-
|
|
6325
|
+
const client = new this.constructor({
|
|
6326
6326
|
...this._options,
|
|
6327
6327
|
baseURL: this.baseURL,
|
|
6328
6328
|
maxRetries: this.maxRetries,
|
|
@@ -6337,6 +6337,7 @@ class OpenAI {
|
|
|
6337
6337
|
webhookSecret: this.webhookSecret,
|
|
6338
6338
|
...options,
|
|
6339
6339
|
});
|
|
6340
|
+
return client;
|
|
6340
6341
|
}
|
|
6341
6342
|
defaultQuery() {
|
|
6342
6343
|
return this._options.defaultQuery;
|
|
@@ -6344,7 +6345,7 @@ class OpenAI {
|
|
|
6344
6345
|
validateHeaders({ values, nulls }) {
|
|
6345
6346
|
return;
|
|
6346
6347
|
}
|
|
6347
|
-
authHeaders(opts) {
|
|
6348
|
+
async authHeaders(opts) {
|
|
6348
6349
|
return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
|
|
6349
6350
|
}
|
|
6350
6351
|
stringifyQuery(query) {
|
|
@@ -6414,7 +6415,9 @@ class OpenAI {
|
|
|
6414
6415
|
retriesRemaining = maxRetries;
|
|
6415
6416
|
}
|
|
6416
6417
|
await this.prepareOptions(options);
|
|
6417
|
-
const { req, url, timeout } = this.buildRequest(options, {
|
|
6418
|
+
const { req, url, timeout } = await this.buildRequest(options, {
|
|
6419
|
+
retryCount: maxRetries - retriesRemaining,
|
|
6420
|
+
});
|
|
6418
6421
|
await this.prepareRequest(req, { url, options });
|
|
6419
6422
|
/** Not an API request ID, just for correlating local log entries. */
|
|
6420
6423
|
const requestLogID = 'log_' + ((Math.random() * (1 << 24)) | 0).toString(16).padStart(6, '0');
|
|
@@ -6472,7 +6475,7 @@ class OpenAI {
|
|
|
6472
6475
|
.join('');
|
|
6473
6476
|
const responseInfo = `[${requestLogID}${retryLogStr}${specialHeaders}] ${req.method} ${url} ${response.ok ? 'succeeded' : 'failed'} with status ${response.status} in ${headersTime - startTime}ms`;
|
|
6474
6477
|
if (!response.ok) {
|
|
6475
|
-
const shouldRetry = this.shouldRetry(response);
|
|
6478
|
+
const shouldRetry = await this.shouldRetry(response);
|
|
6476
6479
|
if (retriesRemaining && shouldRetry) {
|
|
6477
6480
|
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
6478
6481
|
// We don't need the body of this response.
|
|
@@ -6546,7 +6549,7 @@ class OpenAI {
|
|
|
6546
6549
|
clearTimeout(timeout);
|
|
6547
6550
|
}
|
|
6548
6551
|
}
|
|
6549
|
-
shouldRetry(response) {
|
|
6552
|
+
async shouldRetry(response) {
|
|
6550
6553
|
// Note this is not a standard header.
|
|
6551
6554
|
const shouldRetryHeader = response.headers.get('x-should-retry');
|
|
6552
6555
|
// If the server explicitly says whether or not to retry, obey.
|
|
@@ -6608,7 +6611,7 @@ class OpenAI {
|
|
|
6608
6611
|
const jitter = 1 - Math.random() * 0.25;
|
|
6609
6612
|
return sleepSeconds * jitter * 1000;
|
|
6610
6613
|
}
|
|
6611
|
-
buildRequest(inputOptions, { retryCount = 0 } = {}) {
|
|
6614
|
+
async buildRequest(inputOptions, { retryCount = 0 } = {}) {
|
|
6612
6615
|
const options = { ...inputOptions };
|
|
6613
6616
|
const { method, path, query, defaultBaseURL } = options;
|
|
6614
6617
|
const url = this.buildURL(path, query, defaultBaseURL);
|
|
@@ -6616,7 +6619,7 @@ class OpenAI {
|
|
|
6616
6619
|
validatePositiveInteger('timeout', options.timeout);
|
|
6617
6620
|
options.timeout = options.timeout ?? this.timeout;
|
|
6618
6621
|
const { bodyHeaders, body } = this.buildBody({ options });
|
|
6619
|
-
const reqHeaders = this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
|
|
6622
|
+
const reqHeaders = await this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
|
|
6620
6623
|
const req = {
|
|
6621
6624
|
method,
|
|
6622
6625
|
headers: reqHeaders,
|
|
@@ -6629,7 +6632,7 @@ class OpenAI {
|
|
|
6629
6632
|
};
|
|
6630
6633
|
return { req, url, timeout: options.timeout };
|
|
6631
6634
|
}
|
|
6632
|
-
buildHeaders({ options, method, bodyHeaders, retryCount, }) {
|
|
6635
|
+
async buildHeaders({ options, method, bodyHeaders, retryCount, }) {
|
|
6633
6636
|
let idempotencyHeaders = {};
|
|
6634
6637
|
if (this.idempotencyHeader && method !== 'get') {
|
|
6635
6638
|
if (!options.idempotencyKey)
|
|
@@ -6647,7 +6650,7 @@ class OpenAI {
|
|
|
6647
6650
|
'OpenAI-Organization': this.organization,
|
|
6648
6651
|
'OpenAI-Project': this.project,
|
|
6649
6652
|
},
|
|
6650
|
-
this.authHeaders(options),
|
|
6653
|
+
await this.authHeaders(options),
|
|
6651
6654
|
this._options.defaultHeaders,
|
|
6652
6655
|
bodyHeaders,
|
|
6653
6656
|
options.headers,
|
|
@@ -12872,7 +12875,7 @@ var config = {};
|
|
|
12872
12875
|
|
|
12873
12876
|
var main = {exports: {}};
|
|
12874
12877
|
|
|
12875
|
-
var version = "17.
|
|
12878
|
+
var version = "17.2.0";
|
|
12876
12879
|
var require$$4 = {
|
|
12877
12880
|
version: version};
|
|
12878
12881
|
|
|
@@ -12908,6 +12911,13 @@ function requireMain () {
|
|
|
12908
12911
|
return TIPS[Math.floor(Math.random() * TIPS.length)]
|
|
12909
12912
|
}
|
|
12910
12913
|
|
|
12914
|
+
function parseBoolean (value) {
|
|
12915
|
+
if (typeof value === 'string') {
|
|
12916
|
+
return !['false', '0', 'no', 'off', ''].includes(value.toLowerCase())
|
|
12917
|
+
}
|
|
12918
|
+
return Boolean(value)
|
|
12919
|
+
}
|
|
12920
|
+
|
|
12911
12921
|
function supportsAnsi () {
|
|
12912
12922
|
return process.stdout.isTTY // && process.env.TERM !== 'dumb'
|
|
12913
12923
|
}
|
|
@@ -13099,8 +13109,8 @@ function requireMain () {
|
|
|
13099
13109
|
}
|
|
13100
13110
|
|
|
13101
13111
|
function _configVault (options) {
|
|
13102
|
-
const debug =
|
|
13103
|
-
const quiet =
|
|
13112
|
+
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || (options && options.debug));
|
|
13113
|
+
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || (options && options.quiet));
|
|
13104
13114
|
|
|
13105
13115
|
if (debug || !quiet) {
|
|
13106
13116
|
_log('Loading env from encrypted .env.vault');
|
|
@@ -13121,8 +13131,12 @@ function requireMain () {
|
|
|
13121
13131
|
function configDotenv (options) {
|
|
13122
13132
|
const dotenvPath = path.resolve(process.cwd(), '.env');
|
|
13123
13133
|
let encoding = 'utf8';
|
|
13124
|
-
|
|
13125
|
-
|
|
13134
|
+
let processEnv = process.env;
|
|
13135
|
+
if (options && options.processEnv != null) {
|
|
13136
|
+
processEnv = options.processEnv;
|
|
13137
|
+
}
|
|
13138
|
+
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || (options && options.debug));
|
|
13139
|
+
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || (options && options.quiet));
|
|
13126
13140
|
|
|
13127
13141
|
if (options && options.encoding) {
|
|
13128
13142
|
encoding = options.encoding;
|
|
@@ -13162,13 +13176,12 @@ function requireMain () {
|
|
|
13162
13176
|
}
|
|
13163
13177
|
}
|
|
13164
13178
|
|
|
13165
|
-
let processEnv = process.env;
|
|
13166
|
-
if (options && options.processEnv != null) {
|
|
13167
|
-
processEnv = options.processEnv;
|
|
13168
|
-
}
|
|
13169
|
-
|
|
13170
13179
|
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
|
13171
13180
|
|
|
13181
|
+
// handle user settings DOTENV_CONFIG_ options inside .env file(s)
|
|
13182
|
+
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
|
13183
|
+
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
|
13184
|
+
|
|
13172
13185
|
if (debug || !quiet) {
|
|
13173
13186
|
const keysCount = Object.keys(populated).length;
|
|
13174
13187
|
const shortPaths = [];
|