@discomedia/utils 1.0.65 → 1.0.66
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 +188 -11
- package/dist/index-frontend.cjs.map +1 -1
- package/dist/index-frontend.mjs +188 -11
- package/dist/index-frontend.mjs.map +1 -1
- package/dist/index.cjs +234 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +234 -63
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +6 -6
- package/dist/test.js +236 -65
- package/dist/test.js.map +1 -1
- package/dist/types/alpaca-market-data-api.d.ts +10 -0
- package/dist/types/alpaca-market-data-api.d.ts.map +1 -1
- package/dist/types-frontend/alpaca-market-data-api.d.ts +10 -0
- package/dist/types-frontend/alpaca-market-data-api.d.ts.map +1 -1
- package/package.json +6 -6
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.66",
|
|
7
7
|
"author": "Disco Media",
|
|
8
8
|
"description": "Utility functions used in Disco Media apps",
|
|
9
9
|
"always-build-npm": true,
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"test": "npm run build && node dist/test.js"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"dotenv": "^17.
|
|
36
|
-
"openai": "^6.
|
|
35
|
+
"dotenv": "^17.4.1",
|
|
36
|
+
"openai": "^6.34.0",
|
|
37
37
|
"p-limit": "^7.3.0",
|
|
38
38
|
"tslib": "^2.8.1",
|
|
39
|
-
"ws": "^8.
|
|
39
|
+
"ws": "^8.20.0",
|
|
40
40
|
"zod": "^4.3.6"
|
|
41
41
|
},
|
|
42
42
|
"license": "ISC",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
48
48
|
"@types/ws": "^8.18.1",
|
|
49
49
|
"lightweight-charts": "^5.1.0",
|
|
50
|
-
"rollup": "^4.
|
|
51
|
-
"typescript": "^
|
|
50
|
+
"rollup": "^4.60.1",
|
|
51
|
+
"typescript": "^6.0.2"
|
|
52
52
|
}
|
|
53
53
|
}
|
package/dist/test.js
CHANGED
|
@@ -2,7 +2,7 @@ import require$$0$3, { EventEmitter } from 'events';
|
|
|
2
2
|
import require$$1 from 'https';
|
|
3
3
|
import require$$2 from 'http';
|
|
4
4
|
import require$$3$1 from 'net';
|
|
5
|
-
import require$$4
|
|
5
|
+
import require$$4 from 'tls';
|
|
6
6
|
import require$$3 from 'crypto';
|
|
7
7
|
import require$$0$2 from 'stream';
|
|
8
8
|
import require$$7 from 'url';
|
|
@@ -1563,6 +1563,37 @@ class InvalidWebhookSignatureError extends Error {
|
|
|
1563
1563
|
super(message);
|
|
1564
1564
|
}
|
|
1565
1565
|
}
|
|
1566
|
+
/**
|
|
1567
|
+
* Error thrown by the API server during OAuth token exchange.
|
|
1568
|
+
* Can have status codes 400, 401, or 403.
|
|
1569
|
+
* Other status codes from OAuth endpoints are raised as normal APIError types.
|
|
1570
|
+
*/
|
|
1571
|
+
class OAuthError extends APIError {
|
|
1572
|
+
constructor(status, error, headers) {
|
|
1573
|
+
let finalMessage = 'OAuth2 authentication error';
|
|
1574
|
+
let error_code = undefined;
|
|
1575
|
+
if (error && typeof error === 'object') {
|
|
1576
|
+
const errorData = error;
|
|
1577
|
+
error_code = errorData['error'];
|
|
1578
|
+
const description = errorData['error_description'];
|
|
1579
|
+
if (description && typeof description === 'string') {
|
|
1580
|
+
finalMessage = description;
|
|
1581
|
+
}
|
|
1582
|
+
else if (error_code) {
|
|
1583
|
+
finalMessage = error_code;
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
super(status, error, finalMessage, headers);
|
|
1587
|
+
this.error_code = error_code;
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
class SubjectTokenProviderError extends OpenAIError {
|
|
1591
|
+
constructor(message, provider, cause) {
|
|
1592
|
+
super(message);
|
|
1593
|
+
this.provider = provider;
|
|
1594
|
+
this.cause = cause;
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1566
1597
|
|
|
1567
1598
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
1568
1599
|
// https://url.spec.whatwg.org/#url-scheme-string
|
|
@@ -1615,7 +1646,7 @@ const safeJSON = (text) => {
|
|
|
1615
1646
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
1616
1647
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
1617
1648
|
|
|
1618
|
-
const VERSION = '6.
|
|
1649
|
+
const VERSION = '6.34.0'; // x-release-please-version
|
|
1619
1650
|
|
|
1620
1651
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
1621
1652
|
const isRunningInBrowser = () => {
|
|
@@ -2996,6 +3027,91 @@ class ConversationCursorPage extends AbstractPage {
|
|
|
2996
3027
|
}
|
|
2997
3028
|
}
|
|
2998
3029
|
|
|
3030
|
+
const SUBJECT_TOKEN_TYPES = {
|
|
3031
|
+
jwt: 'urn:ietf:params:oauth:token-type:jwt',
|
|
3032
|
+
id: 'urn:ietf:params:oauth:token-type:id_token',
|
|
3033
|
+
};
|
|
3034
|
+
const TOKEN_EXCHANGE_GRANT_TYPE = 'urn:ietf:params:oauth:grant-type:token-exchange';
|
|
3035
|
+
class WorkloadIdentityAuth {
|
|
3036
|
+
constructor(config, fetch) {
|
|
3037
|
+
this.cachedToken = null;
|
|
3038
|
+
this.refreshPromise = null;
|
|
3039
|
+
this.tokenExchangeUrl = 'https://auth.openai.com/oauth/token';
|
|
3040
|
+
this.config = config;
|
|
3041
|
+
this.fetch = fetch ?? getDefaultFetch();
|
|
3042
|
+
}
|
|
3043
|
+
async getToken() {
|
|
3044
|
+
if (!this.cachedToken || this.isTokenExpired(this.cachedToken)) {
|
|
3045
|
+
if (this.refreshPromise) {
|
|
3046
|
+
return await this.refreshPromise;
|
|
3047
|
+
}
|
|
3048
|
+
this.refreshPromise = this.refreshToken();
|
|
3049
|
+
try {
|
|
3050
|
+
const token = await this.refreshPromise;
|
|
3051
|
+
return token;
|
|
3052
|
+
}
|
|
3053
|
+
finally {
|
|
3054
|
+
this.refreshPromise = null;
|
|
3055
|
+
}
|
|
3056
|
+
}
|
|
3057
|
+
if (this.needsRefresh(this.cachedToken) && !this.refreshPromise) {
|
|
3058
|
+
this.refreshPromise = this.refreshToken().finally(() => {
|
|
3059
|
+
this.refreshPromise = null;
|
|
3060
|
+
});
|
|
3061
|
+
}
|
|
3062
|
+
return this.cachedToken.token;
|
|
3063
|
+
}
|
|
3064
|
+
async refreshToken() {
|
|
3065
|
+
const subjectToken = await this.config.provider.getToken();
|
|
3066
|
+
const response = await this.fetch(this.tokenExchangeUrl, {
|
|
3067
|
+
method: 'POST',
|
|
3068
|
+
headers: {
|
|
3069
|
+
'Content-Type': 'application/json',
|
|
3070
|
+
},
|
|
3071
|
+
body: JSON.stringify({
|
|
3072
|
+
grant_type: TOKEN_EXCHANGE_GRANT_TYPE,
|
|
3073
|
+
client_id: this.config.clientId,
|
|
3074
|
+
subject_token: subjectToken,
|
|
3075
|
+
subject_token_type: SUBJECT_TOKEN_TYPES[this.config.provider.tokenType],
|
|
3076
|
+
identity_provider_id: this.config.identityProviderId,
|
|
3077
|
+
service_account_id: this.config.serviceAccountId,
|
|
3078
|
+
}),
|
|
3079
|
+
});
|
|
3080
|
+
if (!response.ok) {
|
|
3081
|
+
const errorText = await response.text();
|
|
3082
|
+
let body = undefined;
|
|
3083
|
+
try {
|
|
3084
|
+
body = JSON.parse(errorText);
|
|
3085
|
+
}
|
|
3086
|
+
catch { }
|
|
3087
|
+
if (response.status === 400 || response.status === 401 || response.status === 403) {
|
|
3088
|
+
throw new OAuthError(response.status, body, response.headers);
|
|
3089
|
+
}
|
|
3090
|
+
throw APIError.generate(response.status, body, `Token exchange failed with status ${response.status}`, response.headers);
|
|
3091
|
+
}
|
|
3092
|
+
const tokenResponse = (await response.json());
|
|
3093
|
+
const expiresIn = tokenResponse.expires_in || 3600;
|
|
3094
|
+
const expiresAt = Date.now() + expiresIn * 1000;
|
|
3095
|
+
this.cachedToken = {
|
|
3096
|
+
token: tokenResponse.access_token,
|
|
3097
|
+
expiresAt,
|
|
3098
|
+
};
|
|
3099
|
+
return tokenResponse.access_token;
|
|
3100
|
+
}
|
|
3101
|
+
isTokenExpired(cachedToken) {
|
|
3102
|
+
return Date.now() >= cachedToken.expiresAt;
|
|
3103
|
+
}
|
|
3104
|
+
needsRefresh(cachedToken) {
|
|
3105
|
+
const bufferSeconds = this.config.refreshBufferSeconds ?? 1200;
|
|
3106
|
+
const bufferMs = bufferSeconds * 1000;
|
|
3107
|
+
return Date.now() >= cachedToken.expiresAt - bufferMs;
|
|
3108
|
+
}
|
|
3109
|
+
invalidateToken() {
|
|
3110
|
+
this.cachedToken = null;
|
|
3111
|
+
this.refreshPromise = null;
|
|
3112
|
+
}
|
|
3113
|
+
}
|
|
3114
|
+
|
|
2999
3115
|
const checkFileSupport = () => {
|
|
3000
3116
|
if (typeof File === 'undefined') {
|
|
3001
3117
|
const { process } = globalThis;
|
|
@@ -8301,6 +8417,7 @@ _Webhooks_instances = new WeakSet(), _Webhooks_validateSecret = function _Webhoo
|
|
|
8301
8417
|
|
|
8302
8418
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
8303
8419
|
var _OpenAI_instances, _a$1, _OpenAI_encoder, _OpenAI_baseURLOverridden;
|
|
8420
|
+
const WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER = 'workload-identity-auth';
|
|
8304
8421
|
/**
|
|
8305
8422
|
* API Client for interfacing with the OpenAI API.
|
|
8306
8423
|
*/
|
|
@@ -8321,7 +8438,7 @@ class OpenAI {
|
|
|
8321
8438
|
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
8322
8439
|
* @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
|
|
8323
8440
|
*/
|
|
8324
|
-
constructor({ baseURL = readEnv('OPENAI_BASE_URL'), apiKey = readEnv('OPENAI_API_KEY'), organization = readEnv('OPENAI_ORG_ID') ?? null, project = readEnv('OPENAI_PROJECT_ID') ?? null, webhookSecret = readEnv('OPENAI_WEBHOOK_SECRET') ?? null, ...opts } = {}) {
|
|
8441
|
+
constructor({ baseURL = readEnv('OPENAI_BASE_URL'), apiKey = readEnv('OPENAI_API_KEY'), organization = readEnv('OPENAI_ORG_ID') ?? null, project = readEnv('OPENAI_PROJECT_ID') ?? null, webhookSecret = readEnv('OPENAI_WEBHOOK_SECRET') ?? null, workloadIdentity, ...opts } = {}) {
|
|
8325
8442
|
_OpenAI_instances.add(this);
|
|
8326
8443
|
_OpenAI_encoder.set(this, void 0);
|
|
8327
8444
|
/**
|
|
@@ -8376,14 +8493,21 @@ class OpenAI {
|
|
|
8376
8493
|
this.containers = new Containers(this);
|
|
8377
8494
|
this.skills = new Skills(this);
|
|
8378
8495
|
this.videos = new Videos(this);
|
|
8379
|
-
if (
|
|
8380
|
-
|
|
8496
|
+
if (workloadIdentity) {
|
|
8497
|
+
if (apiKey && apiKey !== WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER) {
|
|
8498
|
+
throw new OpenAIError('The `apiKey` and `workloadIdentity` arguments are mutually exclusive; only one can be passed at a time.');
|
|
8499
|
+
}
|
|
8500
|
+
apiKey = WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER;
|
|
8501
|
+
}
|
|
8502
|
+
else if (apiKey === undefined) {
|
|
8503
|
+
throw new OpenAIError('Missing credentials. Please pass an `apiKey`, `workloadIdentity`, or set the `OPENAI_API_KEY` environment variable.');
|
|
8381
8504
|
}
|
|
8382
8505
|
const options = {
|
|
8383
8506
|
apiKey,
|
|
8384
8507
|
organization,
|
|
8385
8508
|
project,
|
|
8386
8509
|
webhookSecret,
|
|
8510
|
+
workloadIdentity,
|
|
8387
8511
|
...opts,
|
|
8388
8512
|
baseURL: baseURL || `https://api.openai.com/v1`,
|
|
8389
8513
|
};
|
|
@@ -8405,6 +8529,9 @@ class OpenAI {
|
|
|
8405
8529
|
this.fetch = options.fetch ?? getDefaultFetch();
|
|
8406
8530
|
__classPrivateFieldSet(this, _OpenAI_encoder, FallbackEncoder);
|
|
8407
8531
|
this._options = options;
|
|
8532
|
+
if (workloadIdentity) {
|
|
8533
|
+
this._workloadIdentityAuth = new WorkloadIdentityAuth(workloadIdentity, this.fetch);
|
|
8534
|
+
}
|
|
8408
8535
|
this.apiKey = typeof apiKey === 'string' ? apiKey : 'Missing Key';
|
|
8409
8536
|
this.organization = organization;
|
|
8410
8537
|
this.project = project;
|
|
@@ -8424,6 +8551,7 @@ class OpenAI {
|
|
|
8424
8551
|
fetch: this.fetch,
|
|
8425
8552
|
fetchOptions: this.fetchOptions,
|
|
8426
8553
|
apiKey: this.apiKey,
|
|
8554
|
+
workloadIdentity: this._options.workloadIdentity,
|
|
8427
8555
|
organization: this.organization,
|
|
8428
8556
|
project: this.project,
|
|
8429
8557
|
webhookSecret: this.webhookSecret,
|
|
@@ -8550,7 +8678,7 @@ class OpenAI {
|
|
|
8550
8678
|
throw new APIUserAbortError();
|
|
8551
8679
|
}
|
|
8552
8680
|
const controller = new AbortController();
|
|
8553
|
-
const response = await this.
|
|
8681
|
+
const response = await this.fetchWithAuth(url, req, timeout, controller).catch(castToError);
|
|
8554
8682
|
const headersTime = Date.now();
|
|
8555
8683
|
if (response instanceof globalThis.Error) {
|
|
8556
8684
|
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
@@ -8580,6 +8708,9 @@ class OpenAI {
|
|
|
8580
8708
|
durationMs: headersTime - startTime,
|
|
8581
8709
|
message: response.message,
|
|
8582
8710
|
}));
|
|
8711
|
+
if (response instanceof OAuthError || response instanceof SubjectTokenProviderError) {
|
|
8712
|
+
throw response;
|
|
8713
|
+
}
|
|
8583
8714
|
if (isTimeout) {
|
|
8584
8715
|
throw new APIConnectionTimeoutError();
|
|
8585
8716
|
}
|
|
@@ -8591,6 +8722,20 @@ class OpenAI {
|
|
|
8591
8722
|
.join('');
|
|
8592
8723
|
const responseInfo = `[${requestLogID}${retryLogStr}${specialHeaders}] ${req.method} ${url} ${response.ok ? 'succeeded' : 'failed'} with status ${response.status} in ${headersTime - startTime}ms`;
|
|
8593
8724
|
if (!response.ok) {
|
|
8725
|
+
if (response.status === 401 &&
|
|
8726
|
+
this._workloadIdentityAuth &&
|
|
8727
|
+
!options.__metadata?.['hasStreamingBody'] &&
|
|
8728
|
+
!options.__metadata?.['workloadIdentityTokenRefreshed']) {
|
|
8729
|
+
await CancelReadableStream(response.body);
|
|
8730
|
+
this._workloadIdentityAuth.invalidateToken();
|
|
8731
|
+
return this.makeRequest({
|
|
8732
|
+
...options,
|
|
8733
|
+
__metadata: {
|
|
8734
|
+
...options.__metadata,
|
|
8735
|
+
workloadIdentityTokenRefreshed: true,
|
|
8736
|
+
},
|
|
8737
|
+
}, retriesRemaining, retryOfRequestLogID ?? requestLogID);
|
|
8738
|
+
}
|
|
8594
8739
|
const shouldRetry = await this.shouldRetry(response);
|
|
8595
8740
|
if (retriesRemaining && shouldRetry) {
|
|
8596
8741
|
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
@@ -8641,6 +8786,18 @@ class OpenAI {
|
|
|
8641
8786
|
const request = this.makeRequest(options, null, undefined);
|
|
8642
8787
|
return new PagePromise(this, request, Page);
|
|
8643
8788
|
}
|
|
8789
|
+
async fetchWithAuth(url, init, timeout, controller) {
|
|
8790
|
+
if (this._workloadIdentityAuth) {
|
|
8791
|
+
const headers = init.headers;
|
|
8792
|
+
const authHeader = headers.get('Authorization');
|
|
8793
|
+
if (!authHeader || authHeader === `Bearer ${WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER}`) {
|
|
8794
|
+
const token = await this._workloadIdentityAuth.getToken();
|
|
8795
|
+
headers.set('Authorization', `Bearer ${token}`);
|
|
8796
|
+
}
|
|
8797
|
+
}
|
|
8798
|
+
const response = await this.fetchWithTimeout(url, init, timeout, controller);
|
|
8799
|
+
return response;
|
|
8800
|
+
}
|
|
8644
8801
|
async fetchWithTimeout(url, init, ms, controller) {
|
|
8645
8802
|
const { signal, method, ...options } = init || {};
|
|
8646
8803
|
const abort = this._makeAbort(controller);
|
|
@@ -8737,7 +8894,13 @@ class OpenAI {
|
|
|
8737
8894
|
if ('timeout' in options)
|
|
8738
8895
|
validatePositiveInteger('timeout', options.timeout);
|
|
8739
8896
|
options.timeout = options.timeout ?? this.timeout;
|
|
8740
|
-
const { bodyHeaders, body } = this.buildBody({ options });
|
|
8897
|
+
const { bodyHeaders, body, isStreamingBody } = this.buildBody({ options });
|
|
8898
|
+
if (isStreamingBody) {
|
|
8899
|
+
inputOptions.__metadata = {
|
|
8900
|
+
...inputOptions.__metadata,
|
|
8901
|
+
hasStreamingBody: true,
|
|
8902
|
+
};
|
|
8903
|
+
}
|
|
8741
8904
|
const reqHeaders = await this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
|
|
8742
8905
|
const req = {
|
|
8743
8906
|
method,
|
|
@@ -8784,9 +8947,18 @@ class OpenAI {
|
|
|
8784
8947
|
}
|
|
8785
8948
|
buildBody({ options: { body, headers: rawHeaders } }) {
|
|
8786
8949
|
if (!body) {
|
|
8787
|
-
return { bodyHeaders: undefined, body: undefined };
|
|
8950
|
+
return { bodyHeaders: undefined, body: undefined, isStreamingBody: false };
|
|
8788
8951
|
}
|
|
8789
8952
|
const headers = buildHeaders([rawHeaders]);
|
|
8953
|
+
const isReadableStream = typeof globalThis.ReadableStream !== 'undefined' &&
|
|
8954
|
+
body instanceof globalThis.ReadableStream;
|
|
8955
|
+
const isRetryableBody = !isReadableStream &&
|
|
8956
|
+
(typeof body === 'string' ||
|
|
8957
|
+
body instanceof ArrayBuffer ||
|
|
8958
|
+
ArrayBuffer.isView(body) ||
|
|
8959
|
+
(typeof globalThis.Blob !== 'undefined' && body instanceof globalThis.Blob) ||
|
|
8960
|
+
body instanceof URLSearchParams ||
|
|
8961
|
+
body instanceof FormData);
|
|
8790
8962
|
if (
|
|
8791
8963
|
// Pass raw type verbatim
|
|
8792
8964
|
ArrayBuffer.isView(body) ||
|
|
@@ -8802,23 +8974,28 @@ class OpenAI {
|
|
|
8802
8974
|
// `URLSearchParams` -> `application/x-www-form-urlencoded`
|
|
8803
8975
|
body instanceof URLSearchParams ||
|
|
8804
8976
|
// Send chunked stream (each chunk has own `length`)
|
|
8805
|
-
|
|
8806
|
-
return { bodyHeaders: undefined, body: body };
|
|
8977
|
+
isReadableStream) {
|
|
8978
|
+
return { bodyHeaders: undefined, body: body, isStreamingBody: !isRetryableBody };
|
|
8807
8979
|
}
|
|
8808
8980
|
else if (typeof body === 'object' &&
|
|
8809
8981
|
(Symbol.asyncIterator in body ||
|
|
8810
8982
|
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) {
|
|
8811
|
-
return {
|
|
8983
|
+
return {
|
|
8984
|
+
bodyHeaders: undefined,
|
|
8985
|
+
body: ReadableStreamFrom(body),
|
|
8986
|
+
isStreamingBody: true,
|
|
8987
|
+
};
|
|
8812
8988
|
}
|
|
8813
8989
|
else if (typeof body === 'object' &&
|
|
8814
8990
|
headers.values.get('content-type') === 'application/x-www-form-urlencoded') {
|
|
8815
8991
|
return {
|
|
8816
8992
|
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
8817
8993
|
body: this.stringifyQuery(body),
|
|
8994
|
+
isStreamingBody: false,
|
|
8818
8995
|
};
|
|
8819
8996
|
}
|
|
8820
8997
|
else {
|
|
8821
|
-
return __classPrivateFieldGet(this, _OpenAI_encoder, "f").call(this, { body, headers });
|
|
8998
|
+
return { ...__classPrivateFieldGet(this, _OpenAI_encoder, "f").call(this, { body, headers }), isStreamingBody: false };
|
|
8822
8999
|
}
|
|
8823
9000
|
}
|
|
8824
9001
|
}
|
|
@@ -9825,7 +10002,7 @@ class Doc {
|
|
|
9825
10002
|
}
|
|
9826
10003
|
}
|
|
9827
10004
|
|
|
9828
|
-
const version
|
|
10005
|
+
const version = {
|
|
9829
10006
|
major: 4,
|
|
9830
10007
|
minor: 3,
|
|
9831
10008
|
patch: 6,
|
|
@@ -9836,7 +10013,7 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
|
9836
10013
|
inst ?? (inst = {});
|
|
9837
10014
|
inst._zod.def = def; // set _def property
|
|
9838
10015
|
inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
|
|
9839
|
-
inst._zod.version = version
|
|
10016
|
+
inst._zod.version = version;
|
|
9840
10017
|
const checks = [...(inst._zod.def.checks ?? [])];
|
|
9841
10018
|
// if inst is itself a checks.$ZodCheck, run it as a check
|
|
9842
10019
|
if (inst._zod.traits.has("$ZodCheck")) {
|
|
@@ -16767,6 +16944,9 @@ function requirePermessageDeflate () {
|
|
|
16767
16944
|
* acknowledge disabling of client context takeover
|
|
16768
16945
|
* @param {Number} [options.concurrencyLimit=10] The number of concurrent
|
|
16769
16946
|
* calls to zlib
|
|
16947
|
+
* @param {Boolean} [options.isServer=false] Create the instance in either
|
|
16948
|
+
* server or client mode
|
|
16949
|
+
* @param {Number} [options.maxPayload=0] The maximum allowed message length
|
|
16770
16950
|
* @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
|
|
16771
16951
|
* use of a custom server window size
|
|
16772
16952
|
* @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
|
|
@@ -16777,16 +16957,13 @@ function requirePermessageDeflate () {
|
|
|
16777
16957
|
* deflate
|
|
16778
16958
|
* @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
|
|
16779
16959
|
* inflate
|
|
16780
|
-
* @param {Boolean} [isServer=false] Create the instance in either server or
|
|
16781
|
-
* client mode
|
|
16782
|
-
* @param {Number} [maxPayload=0] The maximum allowed message length
|
|
16783
16960
|
*/
|
|
16784
|
-
constructor(options
|
|
16785
|
-
this._maxPayload = maxPayload | 0;
|
|
16961
|
+
constructor(options) {
|
|
16786
16962
|
this._options = options || {};
|
|
16787
16963
|
this._threshold =
|
|
16788
16964
|
this._options.threshold !== undefined ? this._options.threshold : 1024;
|
|
16789
|
-
this.
|
|
16965
|
+
this._maxPayload = this._options.maxPayload | 0;
|
|
16966
|
+
this._isServer = !!this._options.isServer;
|
|
16790
16967
|
this._deflate = null;
|
|
16791
16968
|
this._inflate = null;
|
|
16792
16969
|
|
|
@@ -19268,7 +19445,7 @@ function requireWebsocket () {
|
|
|
19268
19445
|
const https = require$$1;
|
|
19269
19446
|
const http = require$$2;
|
|
19270
19447
|
const net = require$$3$1;
|
|
19271
|
-
const tls = require$$4
|
|
19448
|
+
const tls = require$$4;
|
|
19272
19449
|
const { randomBytes, createHash } = require$$3;
|
|
19273
19450
|
const { Duplex, Readable } = require$$0$2;
|
|
19274
19451
|
const { URL } = require$$7;
|
|
@@ -19955,7 +20132,7 @@ function requireWebsocket () {
|
|
|
19955
20132
|
} else {
|
|
19956
20133
|
try {
|
|
19957
20134
|
parsedUrl = new URL(address);
|
|
19958
|
-
} catch
|
|
20135
|
+
} catch {
|
|
19959
20136
|
throw new SyntaxError(`Invalid URL: ${address}`);
|
|
19960
20137
|
}
|
|
19961
20138
|
}
|
|
@@ -20017,11 +20194,11 @@ function requireWebsocket () {
|
|
|
20017
20194
|
opts.timeout = opts.handshakeTimeout;
|
|
20018
20195
|
|
|
20019
20196
|
if (opts.perMessageDeflate) {
|
|
20020
|
-
perMessageDeflate = new PerMessageDeflate(
|
|
20021
|
-
opts.perMessageDeflate
|
|
20022
|
-
false,
|
|
20023
|
-
opts.maxPayload
|
|
20024
|
-
);
|
|
20197
|
+
perMessageDeflate = new PerMessageDeflate({
|
|
20198
|
+
...opts.perMessageDeflate,
|
|
20199
|
+
isServer: false,
|
|
20200
|
+
maxPayload: opts.maxPayload
|
|
20201
|
+
});
|
|
20025
20202
|
opts.headers['Sec-WebSocket-Extensions'] = format({
|
|
20026
20203
|
[PerMessageDeflate.extensionName]: perMessageDeflate.offer()
|
|
20027
20204
|
});
|
|
@@ -20828,13 +21005,14 @@ function requireStream () {
|
|
|
20828
21005
|
|
|
20829
21006
|
requireStream();
|
|
20830
21007
|
|
|
21008
|
+
requireExtension();
|
|
21009
|
+
|
|
21010
|
+
requirePermessageDeflate();
|
|
21011
|
+
|
|
20831
21012
|
requireReceiver();
|
|
20832
21013
|
|
|
20833
21014
|
requireSender();
|
|
20834
21015
|
|
|
20835
|
-
var websocketExports = requireWebsocket();
|
|
20836
|
-
var WebSocket = /*@__PURE__*/getDefaultExportFromCjs(websocketExports);
|
|
20837
|
-
|
|
20838
21016
|
var subprotocol;
|
|
20839
21017
|
var hasRequiredSubprotocol;
|
|
20840
21018
|
|
|
@@ -20905,6 +21083,11 @@ function requireSubprotocol () {
|
|
|
20905
21083
|
return subprotocol;
|
|
20906
21084
|
}
|
|
20907
21085
|
|
|
21086
|
+
requireSubprotocol();
|
|
21087
|
+
|
|
21088
|
+
var websocketExports = requireWebsocket();
|
|
21089
|
+
var WebSocket = /*@__PURE__*/getDefaultExportFromCjs(websocketExports);
|
|
21090
|
+
|
|
20908
21091
|
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex$", "caughtErrors": "none" }] */
|
|
20909
21092
|
|
|
20910
21093
|
var websocketServer;
|
|
@@ -21205,11 +21388,11 @@ function requireWebsocketServer () {
|
|
|
21205
21388
|
this.options.perMessageDeflate &&
|
|
21206
21389
|
secWebSocketExtensions !== undefined
|
|
21207
21390
|
) {
|
|
21208
|
-
const perMessageDeflate = new PerMessageDeflate(
|
|
21209
|
-
this.options.perMessageDeflate,
|
|
21210
|
-
true,
|
|
21211
|
-
this.options.maxPayload
|
|
21212
|
-
);
|
|
21391
|
+
const perMessageDeflate = new PerMessageDeflate({
|
|
21392
|
+
...this.options.perMessageDeflate,
|
|
21393
|
+
isServer: true,
|
|
21394
|
+
maxPayload: this.options.maxPayload
|
|
21395
|
+
});
|
|
21213
21396
|
|
|
21214
21397
|
try {
|
|
21215
21398
|
const offers = extension.parse(secWebSocketExtensions);
|
|
@@ -21473,10 +21656,6 @@ var config = {};
|
|
|
21473
21656
|
|
|
21474
21657
|
var main = {exports: {}};
|
|
21475
21658
|
|
|
21476
|
-
var version = "17.3.1";
|
|
21477
|
-
var require$$4 = {
|
|
21478
|
-
version: version};
|
|
21479
|
-
|
|
21480
21659
|
var hasRequiredMain;
|
|
21481
21660
|
|
|
21482
21661
|
function requireMain () {
|
|
@@ -21486,25 +21665,17 @@ function requireMain () {
|
|
|
21486
21665
|
const path = require$$1$1;
|
|
21487
21666
|
const os = require$$2$1;
|
|
21488
21667
|
const crypto = require$$3;
|
|
21489
|
-
const packageJson = require$$4;
|
|
21490
|
-
|
|
21491
|
-
const version = packageJson.version;
|
|
21492
21668
|
|
|
21493
21669
|
// Array of tips to display randomly
|
|
21494
21670
|
const TIPS = [
|
|
21495
|
-
'
|
|
21496
|
-
'
|
|
21497
|
-
'
|
|
21498
|
-
'
|
|
21499
|
-
'
|
|
21500
|
-
'
|
|
21501
|
-
'
|
|
21502
|
-
'
|
|
21503
|
-
'⚙️ enable debug logging with { debug: true }',
|
|
21504
|
-
'⚙️ override existing env vars with { override: true }',
|
|
21505
|
-
'⚙️ suppress all logs with { quiet: true }',
|
|
21506
|
-
'⚙️ write to custom object with { processEnv: myObject }',
|
|
21507
|
-
'⚙️ load multiple .env files with { path: [\'.env.local\', \'.env\'] }'
|
|
21671
|
+
'◈ encrypted .env [www.dotenvx.com]',
|
|
21672
|
+
'◈ secrets for agents [www.dotenvx.com]',
|
|
21673
|
+
'⌁ auth for agents [www.vestauth.com]',
|
|
21674
|
+
'⌘ custom filepath { path: \'/custom/path/.env\' }',
|
|
21675
|
+
'⌘ enable debugging { debug: true }',
|
|
21676
|
+
'⌘ override existing { override: true }',
|
|
21677
|
+
'⌘ suppress logs { quiet: true }',
|
|
21678
|
+
'⌘ multiple files { path: [\'.env.local\', \'.env\'] }'
|
|
21508
21679
|
];
|
|
21509
21680
|
|
|
21510
21681
|
// Get a random tip from the tips array
|
|
@@ -21612,15 +21783,15 @@ function requireMain () {
|
|
|
21612
21783
|
}
|
|
21613
21784
|
|
|
21614
21785
|
function _warn (message) {
|
|
21615
|
-
console.error(
|
|
21786
|
+
console.error(`⚠ ${message}`);
|
|
21616
21787
|
}
|
|
21617
21788
|
|
|
21618
21789
|
function _debug (message) {
|
|
21619
|
-
console.log(
|
|
21790
|
+
console.log(`┆ ${message}`);
|
|
21620
21791
|
}
|
|
21621
21792
|
|
|
21622
21793
|
function _log (message) {
|
|
21623
|
-
console.log(
|
|
21794
|
+
console.log(`◇ ${message}`);
|
|
21624
21795
|
}
|
|
21625
21796
|
|
|
21626
21797
|
function _dotenvKey (options) {
|
|
@@ -21714,7 +21885,7 @@ function requireMain () {
|
|
|
21714
21885
|
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || (options && options.quiet));
|
|
21715
21886
|
|
|
21716
21887
|
if (debug || !quiet) {
|
|
21717
|
-
_log('
|
|
21888
|
+
_log('loading env from encrypted .env.vault');
|
|
21718
21889
|
}
|
|
21719
21890
|
|
|
21720
21891
|
const parsed = DotenvModule._parseVault(options);
|
|
@@ -21743,7 +21914,7 @@ function requireMain () {
|
|
|
21743
21914
|
encoding = options.encoding;
|
|
21744
21915
|
} else {
|
|
21745
21916
|
if (debug) {
|
|
21746
|
-
_debug('
|
|
21917
|
+
_debug('no encoding is specified (UTF-8 is used by default)');
|
|
21747
21918
|
}
|
|
21748
21919
|
}
|
|
21749
21920
|
|
|
@@ -21771,7 +21942,7 @@ function requireMain () {
|
|
|
21771
21942
|
DotenvModule.populate(parsedAll, parsed, options);
|
|
21772
21943
|
} catch (e) {
|
|
21773
21944
|
if (debug) {
|
|
21774
|
-
_debug(`
|
|
21945
|
+
_debug(`failed to load ${path} ${e.message}`);
|
|
21775
21946
|
}
|
|
21776
21947
|
lastError = e;
|
|
21777
21948
|
}
|
|
@@ -21792,13 +21963,13 @@ function requireMain () {
|
|
|
21792
21963
|
shortPaths.push(relative);
|
|
21793
21964
|
} catch (e) {
|
|
21794
21965
|
if (debug) {
|
|
21795
|
-
_debug(`
|
|
21966
|
+
_debug(`failed to load ${filePath} ${e.message}`);
|
|
21796
21967
|
}
|
|
21797
21968
|
lastError = e;
|
|
21798
21969
|
}
|
|
21799
21970
|
}
|
|
21800
21971
|
|
|
21801
|
-
_log(`
|
|
21972
|
+
_log(`injected env (${keysCount}) from ${shortPaths.join(',')} ${dim(`// tip: ${_getRandomTip()}`)}`);
|
|
21802
21973
|
}
|
|
21803
21974
|
|
|
21804
21975
|
if (lastError) {
|
|
@@ -21819,7 +21990,7 @@ function requireMain () {
|
|
|
21819
21990
|
|
|
21820
21991
|
// dotenvKey exists but .env.vault file does not exist
|
|
21821
21992
|
if (!vaultPath) {
|
|
21822
|
-
_warn(`
|
|
21993
|
+
_warn(`you set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}`);
|
|
21823
21994
|
|
|
21824
21995
|
return DotenvModule.configDotenv(options)
|
|
21825
21996
|
}
|
|
@@ -22349,7 +22520,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
|
|
|
22349
22520
|
pageCount++;
|
|
22350
22521
|
const requestParams = {
|
|
22351
22522
|
...params,
|
|
22352
|
-
adjustment: DEFAULT_ADJUSTMENT,
|
|
22523
|
+
adjustment: params.adjustment ?? DEFAULT_ADJUSTMENT,
|
|
22353
22524
|
feed: DEFAULT_FEED,
|
|
22354
22525
|
...(pageToken && { page_token: pageToken }),
|
|
22355
22526
|
};
|