@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/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.15",
|
|
7
7
|
"author": "Disco Media",
|
|
8
8
|
"description": "Utility functions used in Disco Media apps",
|
|
9
9
|
"always-build-npm": true,
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"date-fns": "^4.1.0",
|
|
36
36
|
"date-fns-tz": "^3.2.0",
|
|
37
|
-
"dotenv": "^17.
|
|
37
|
+
"dotenv": "^17.2.0",
|
|
38
38
|
"ms": "^2.1.3",
|
|
39
|
-
"openai": "^5.
|
|
39
|
+
"openai": "^5.9.0",
|
|
40
40
|
"p-limit": "^6.2.0",
|
|
41
41
|
"ws": "^8.18.3"
|
|
42
42
|
},
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@types/ms": "^2.1.0",
|
|
51
51
|
"@types/ws": "^8.18.1",
|
|
52
52
|
"lightweight-charts": "^5.0.8",
|
|
53
|
-
"rollup": "^4.
|
|
53
|
+
"rollup": "^4.45.0",
|
|
54
54
|
"typescript": "^5.8.3"
|
|
55
55
|
}
|
|
56
56
|
}
|
package/dist/test.js
CHANGED
|
@@ -7,7 +7,7 @@ var config = {};
|
|
|
7
7
|
|
|
8
8
|
var main = {exports: {}};
|
|
9
9
|
|
|
10
|
-
var version = "17.
|
|
10
|
+
var version = "17.2.0";
|
|
11
11
|
var require$$4 = {
|
|
12
12
|
version: version};
|
|
13
13
|
|
|
@@ -43,6 +43,13 @@ function requireMain () {
|
|
|
43
43
|
return TIPS[Math.floor(Math.random() * TIPS.length)]
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
function parseBoolean (value) {
|
|
47
|
+
if (typeof value === 'string') {
|
|
48
|
+
return !['false', '0', 'no', 'off', ''].includes(value.toLowerCase())
|
|
49
|
+
}
|
|
50
|
+
return Boolean(value)
|
|
51
|
+
}
|
|
52
|
+
|
|
46
53
|
function supportsAnsi () {
|
|
47
54
|
return process.stdout.isTTY // && process.env.TERM !== 'dumb'
|
|
48
55
|
}
|
|
@@ -234,8 +241,8 @@ function requireMain () {
|
|
|
234
241
|
}
|
|
235
242
|
|
|
236
243
|
function _configVault (options) {
|
|
237
|
-
const debug =
|
|
238
|
-
const quiet =
|
|
244
|
+
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || (options && options.debug));
|
|
245
|
+
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || (options && options.quiet));
|
|
239
246
|
|
|
240
247
|
if (debug || !quiet) {
|
|
241
248
|
_log('Loading env from encrypted .env.vault');
|
|
@@ -256,8 +263,12 @@ function requireMain () {
|
|
|
256
263
|
function configDotenv (options) {
|
|
257
264
|
const dotenvPath = path.resolve(process.cwd(), '.env');
|
|
258
265
|
let encoding = 'utf8';
|
|
259
|
-
|
|
260
|
-
|
|
266
|
+
let processEnv = process.env;
|
|
267
|
+
if (options && options.processEnv != null) {
|
|
268
|
+
processEnv = options.processEnv;
|
|
269
|
+
}
|
|
270
|
+
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || (options && options.debug));
|
|
271
|
+
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || (options && options.quiet));
|
|
261
272
|
|
|
262
273
|
if (options && options.encoding) {
|
|
263
274
|
encoding = options.encoding;
|
|
@@ -297,13 +308,12 @@ function requireMain () {
|
|
|
297
308
|
}
|
|
298
309
|
}
|
|
299
310
|
|
|
300
|
-
let processEnv = process.env;
|
|
301
|
-
if (options && options.processEnv != null) {
|
|
302
|
-
processEnv = options.processEnv;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
311
|
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
|
306
312
|
|
|
313
|
+
// handle user settings DOTENV_CONFIG_ options inside .env file(s)
|
|
314
|
+
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
|
315
|
+
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
|
316
|
+
|
|
307
317
|
if (debug || !quiet) {
|
|
308
318
|
const keysCount = Object.keys(populated).length;
|
|
309
319
|
const shortPaths = [];
|
|
@@ -750,7 +760,7 @@ const safeJSON = (text) => {
|
|
|
750
760
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
751
761
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
752
762
|
|
|
753
|
-
const VERSION = '5.
|
|
763
|
+
const VERSION = '5.9.0'; // x-release-please-version
|
|
754
764
|
|
|
755
765
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
756
766
|
const isRunningInBrowser = () => {
|
|
@@ -6823,7 +6833,7 @@ class OpenAI {
|
|
|
6823
6833
|
* Create a new client instance re-using the same options given to the current client with optional overriding.
|
|
6824
6834
|
*/
|
|
6825
6835
|
withOptions(options) {
|
|
6826
|
-
|
|
6836
|
+
const client = new this.constructor({
|
|
6827
6837
|
...this._options,
|
|
6828
6838
|
baseURL: this.baseURL,
|
|
6829
6839
|
maxRetries: this.maxRetries,
|
|
@@ -6838,6 +6848,7 @@ class OpenAI {
|
|
|
6838
6848
|
webhookSecret: this.webhookSecret,
|
|
6839
6849
|
...options,
|
|
6840
6850
|
});
|
|
6851
|
+
return client;
|
|
6841
6852
|
}
|
|
6842
6853
|
defaultQuery() {
|
|
6843
6854
|
return this._options.defaultQuery;
|
|
@@ -6845,7 +6856,7 @@ class OpenAI {
|
|
|
6845
6856
|
validateHeaders({ values, nulls }) {
|
|
6846
6857
|
return;
|
|
6847
6858
|
}
|
|
6848
|
-
authHeaders(opts) {
|
|
6859
|
+
async authHeaders(opts) {
|
|
6849
6860
|
return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
|
|
6850
6861
|
}
|
|
6851
6862
|
stringifyQuery(query) {
|
|
@@ -6915,7 +6926,9 @@ class OpenAI {
|
|
|
6915
6926
|
retriesRemaining = maxRetries;
|
|
6916
6927
|
}
|
|
6917
6928
|
await this.prepareOptions(options);
|
|
6918
|
-
const { req, url, timeout } = this.buildRequest(options, {
|
|
6929
|
+
const { req, url, timeout } = await this.buildRequest(options, {
|
|
6930
|
+
retryCount: maxRetries - retriesRemaining,
|
|
6931
|
+
});
|
|
6919
6932
|
await this.prepareRequest(req, { url, options });
|
|
6920
6933
|
/** Not an API request ID, just for correlating local log entries. */
|
|
6921
6934
|
const requestLogID = 'log_' + ((Math.random() * (1 << 24)) | 0).toString(16).padStart(6, '0');
|
|
@@ -6973,7 +6986,7 @@ class OpenAI {
|
|
|
6973
6986
|
.join('');
|
|
6974
6987
|
const responseInfo = `[${requestLogID}${retryLogStr}${specialHeaders}] ${req.method} ${url} ${response.ok ? 'succeeded' : 'failed'} with status ${response.status} in ${headersTime - startTime}ms`;
|
|
6975
6988
|
if (!response.ok) {
|
|
6976
|
-
const shouldRetry = this.shouldRetry(response);
|
|
6989
|
+
const shouldRetry = await this.shouldRetry(response);
|
|
6977
6990
|
if (retriesRemaining && shouldRetry) {
|
|
6978
6991
|
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
6979
6992
|
// We don't need the body of this response.
|
|
@@ -7047,7 +7060,7 @@ class OpenAI {
|
|
|
7047
7060
|
clearTimeout(timeout);
|
|
7048
7061
|
}
|
|
7049
7062
|
}
|
|
7050
|
-
shouldRetry(response) {
|
|
7063
|
+
async shouldRetry(response) {
|
|
7051
7064
|
// Note this is not a standard header.
|
|
7052
7065
|
const shouldRetryHeader = response.headers.get('x-should-retry');
|
|
7053
7066
|
// If the server explicitly says whether or not to retry, obey.
|
|
@@ -7109,7 +7122,7 @@ class OpenAI {
|
|
|
7109
7122
|
const jitter = 1 - Math.random() * 0.25;
|
|
7110
7123
|
return sleepSeconds * jitter * 1000;
|
|
7111
7124
|
}
|
|
7112
|
-
buildRequest(inputOptions, { retryCount = 0 } = {}) {
|
|
7125
|
+
async buildRequest(inputOptions, { retryCount = 0 } = {}) {
|
|
7113
7126
|
const options = { ...inputOptions };
|
|
7114
7127
|
const { method, path, query, defaultBaseURL } = options;
|
|
7115
7128
|
const url = this.buildURL(path, query, defaultBaseURL);
|
|
@@ -7117,7 +7130,7 @@ class OpenAI {
|
|
|
7117
7130
|
validatePositiveInteger('timeout', options.timeout);
|
|
7118
7131
|
options.timeout = options.timeout ?? this.timeout;
|
|
7119
7132
|
const { bodyHeaders, body } = this.buildBody({ options });
|
|
7120
|
-
const reqHeaders = this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
|
|
7133
|
+
const reqHeaders = await this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
|
|
7121
7134
|
const req = {
|
|
7122
7135
|
method,
|
|
7123
7136
|
headers: reqHeaders,
|
|
@@ -7130,7 +7143,7 @@ class OpenAI {
|
|
|
7130
7143
|
};
|
|
7131
7144
|
return { req, url, timeout: options.timeout };
|
|
7132
7145
|
}
|
|
7133
|
-
buildHeaders({ options, method, bodyHeaders, retryCount, }) {
|
|
7146
|
+
async buildHeaders({ options, method, bodyHeaders, retryCount, }) {
|
|
7134
7147
|
let idempotencyHeaders = {};
|
|
7135
7148
|
if (this.idempotencyHeader && method !== 'get') {
|
|
7136
7149
|
if (!options.idempotencyKey)
|
|
@@ -7148,7 +7161,7 @@ class OpenAI {
|
|
|
7148
7161
|
'OpenAI-Organization': this.organization,
|
|
7149
7162
|
'OpenAI-Project': this.project,
|
|
7150
7163
|
},
|
|
7151
|
-
this.authHeaders(options),
|
|
7164
|
+
await this.authHeaders(options),
|
|
7152
7165
|
this._options.defaultHeaders,
|
|
7153
7166
|
bodyHeaders,
|
|
7154
7167
|
options.headers,
|