@discomedia/utils 1.0.35 → 1.0.37
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 +135 -14
- package/dist/index-frontend.cjs.map +1 -1
- package/dist/index-frontend.mjs +135 -14
- package/dist/index-frontend.mjs.map +1 -1
- package/dist/index.cjs +152 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +152 -14
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +6 -6
- package/dist/test.js +1172 -5992
- package/dist/test.js.map +1 -1
- package/dist/types/alpaca-trading-api.d.ts +5 -0
- package/dist/types/alpaca-trading-api.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/market-time.d.ts +14 -0
- package/dist/types/market-time.d.ts.map +1 -1
- package/dist/types-frontend/alpaca-trading-api.d.ts +5 -0
- package/dist/types-frontend/alpaca-trading-api.d.ts.map +1 -1
- package/dist/types-frontend/index.d.ts +1 -0
- package/dist/types-frontend/index.d.ts.map +1 -1
- package/dist/types-frontend/market-time.d.ts +14 -0
- package/dist/types-frontend/market-time.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -772,6 +772,22 @@ function getNYTimeZone(date) {
|
|
|
772
772
|
const offset = getNYOffset(date || new Date());
|
|
773
773
|
return offset === -4 ? '-04:00' : '-05:00';
|
|
774
774
|
}
|
|
775
|
+
/**
|
|
776
|
+
* Converts any date to the market time zone (America/New_York, Eastern Time).
|
|
777
|
+
* Returns a new Date object representing the same moment in time but adjusted to NY/Eastern timezone.
|
|
778
|
+
* Automatically handles daylight saving time transitions (EST/EDT).
|
|
779
|
+
*
|
|
780
|
+
* @param date - Date object to convert to market time zone
|
|
781
|
+
* @returns Date object in NY/Eastern time zone
|
|
782
|
+
* @example
|
|
783
|
+
* ```typescript
|
|
784
|
+
* const utcDate = new Date('2024-01-15T15:30:00Z'); // 3:30 PM UTC
|
|
785
|
+
* const nyDate = convertDateToMarketTimeZone(utcDate); // 10:30 AM EST (winter) or 11:30 AM EDT (summer)
|
|
786
|
+
* ```
|
|
787
|
+
*/
|
|
788
|
+
function convertDateToMarketTimeZone(date) {
|
|
789
|
+
return toNYTime(date);
|
|
790
|
+
}
|
|
775
791
|
/**
|
|
776
792
|
* Returns the current market status for a given date.
|
|
777
793
|
* @param options - { date?: Date }
|
|
@@ -2393,7 +2409,7 @@ const safeJSON = (text) => {
|
|
|
2393
2409
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2394
2410
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
2395
2411
|
|
|
2396
|
-
const VERSION = '
|
|
2412
|
+
const VERSION = '6.1.0'; // x-release-please-version
|
|
2397
2413
|
|
|
2398
2414
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2399
2415
|
const isRunningInBrowser = () => {
|
|
@@ -6900,23 +6916,23 @@ class Conversations extends APIResource {
|
|
|
6900
6916
|
/**
|
|
6901
6917
|
* Create a conversation.
|
|
6902
6918
|
*/
|
|
6903
|
-
create(body, options) {
|
|
6919
|
+
create(body = {}, options) {
|
|
6904
6920
|
return this._client.post('/conversations', { body, ...options });
|
|
6905
6921
|
}
|
|
6906
6922
|
/**
|
|
6907
|
-
* Get a conversation
|
|
6923
|
+
* Get a conversation
|
|
6908
6924
|
*/
|
|
6909
6925
|
retrieve(conversationID, options) {
|
|
6910
6926
|
return this._client.get(path `/conversations/${conversationID}`, options);
|
|
6911
6927
|
}
|
|
6912
6928
|
/**
|
|
6913
|
-
* Update a conversation
|
|
6929
|
+
* Update a conversation
|
|
6914
6930
|
*/
|
|
6915
6931
|
update(conversationID, body, options) {
|
|
6916
6932
|
return this._client.post(path `/conversations/${conversationID}`, { body, ...options });
|
|
6917
6933
|
}
|
|
6918
6934
|
/**
|
|
6919
|
-
* Delete a conversation
|
|
6935
|
+
* Delete a conversation. Items in the conversation will not be deleted.
|
|
6920
6936
|
*/
|
|
6921
6937
|
delete(conversationID, options) {
|
|
6922
6938
|
return this._client.delete(path `/conversations/${conversationID}`, options);
|
|
@@ -7511,10 +7527,84 @@ class Moderations extends APIResource {
|
|
|
7511
7527
|
}
|
|
7512
7528
|
}
|
|
7513
7529
|
|
|
7530
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
7531
|
+
class Calls extends APIResource {
|
|
7532
|
+
/**
|
|
7533
|
+
* Accept an incoming SIP call and configure the realtime session that will handle
|
|
7534
|
+
* it.
|
|
7535
|
+
*
|
|
7536
|
+
* @example
|
|
7537
|
+
* ```ts
|
|
7538
|
+
* await client.realtime.calls.accept('call_id', {
|
|
7539
|
+
* type: 'realtime',
|
|
7540
|
+
* });
|
|
7541
|
+
* ```
|
|
7542
|
+
*/
|
|
7543
|
+
accept(callID, body, options) {
|
|
7544
|
+
return this._client.post(path `/realtime/calls/${callID}/accept`, {
|
|
7545
|
+
body,
|
|
7546
|
+
...options,
|
|
7547
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
7548
|
+
});
|
|
7549
|
+
}
|
|
7550
|
+
/**
|
|
7551
|
+
* End an active Realtime API call, whether it was initiated over SIP or WebRTC.
|
|
7552
|
+
*
|
|
7553
|
+
* @example
|
|
7554
|
+
* ```ts
|
|
7555
|
+
* await client.realtime.calls.hangup('call_id');
|
|
7556
|
+
* ```
|
|
7557
|
+
*/
|
|
7558
|
+
hangup(callID, options) {
|
|
7559
|
+
return this._client.post(path `/realtime/calls/${callID}/hangup`, {
|
|
7560
|
+
...options,
|
|
7561
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
7562
|
+
});
|
|
7563
|
+
}
|
|
7564
|
+
/**
|
|
7565
|
+
* Transfer an active SIP call to a new destination using the SIP REFER verb.
|
|
7566
|
+
*
|
|
7567
|
+
* @example
|
|
7568
|
+
* ```ts
|
|
7569
|
+
* await client.realtime.calls.refer('call_id', {
|
|
7570
|
+
* target_uri: 'tel:+14155550123',
|
|
7571
|
+
* });
|
|
7572
|
+
* ```
|
|
7573
|
+
*/
|
|
7574
|
+
refer(callID, body, options) {
|
|
7575
|
+
return this._client.post(path `/realtime/calls/${callID}/refer`, {
|
|
7576
|
+
body,
|
|
7577
|
+
...options,
|
|
7578
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
7579
|
+
});
|
|
7580
|
+
}
|
|
7581
|
+
/**
|
|
7582
|
+
* Decline an incoming SIP call by returning a SIP status code to the caller.
|
|
7583
|
+
*
|
|
7584
|
+
* @example
|
|
7585
|
+
* ```ts
|
|
7586
|
+
* await client.realtime.calls.reject('call_id');
|
|
7587
|
+
* ```
|
|
7588
|
+
*/
|
|
7589
|
+
reject(callID, body = {}, options) {
|
|
7590
|
+
return this._client.post(path `/realtime/calls/${callID}/reject`, {
|
|
7591
|
+
body,
|
|
7592
|
+
...options,
|
|
7593
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
7594
|
+
});
|
|
7595
|
+
}
|
|
7596
|
+
}
|
|
7597
|
+
|
|
7514
7598
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
7515
7599
|
class ClientSecrets extends APIResource {
|
|
7516
7600
|
/**
|
|
7517
7601
|
* Create a Realtime client secret with an associated session configuration.
|
|
7602
|
+
*
|
|
7603
|
+
* @example
|
|
7604
|
+
* ```ts
|
|
7605
|
+
* const clientSecret =
|
|
7606
|
+
* await client.realtime.clientSecrets.create();
|
|
7607
|
+
* ```
|
|
7518
7608
|
*/
|
|
7519
7609
|
create(body, options) {
|
|
7520
7610
|
return this._client.post('/realtime/client_secrets', { body, ...options });
|
|
@@ -7526,9 +7616,11 @@ class Realtime extends APIResource {
|
|
|
7526
7616
|
constructor() {
|
|
7527
7617
|
super(...arguments);
|
|
7528
7618
|
this.clientSecrets = new ClientSecrets(this._client);
|
|
7619
|
+
this.calls = new Calls(this._client);
|
|
7529
7620
|
}
|
|
7530
7621
|
}
|
|
7531
7622
|
Realtime.ClientSecrets = ClientSecrets;
|
|
7623
|
+
Realtime.Calls = Calls;
|
|
7532
7624
|
|
|
7533
7625
|
function maybeParseResponse(response, params) {
|
|
7534
7626
|
if (!params || !hasAutoParseableInput(params)) {
|
|
@@ -15843,7 +15935,7 @@ var config = {};
|
|
|
15843
15935
|
|
|
15844
15936
|
var main = {exports: {}};
|
|
15845
15937
|
|
|
15846
|
-
var version = "17.2.
|
|
15938
|
+
var version = "17.2.3";
|
|
15847
15939
|
var require$$4 = {
|
|
15848
15940
|
version: version};
|
|
15849
15941
|
|
|
@@ -15865,9 +15957,12 @@ function requireMain () {
|
|
|
15865
15957
|
'🔐 encrypt with Dotenvx: https://dotenvx.com',
|
|
15866
15958
|
'🔐 prevent committing .env to code: https://dotenvx.com/precommit',
|
|
15867
15959
|
'🔐 prevent building .env in docker: https://dotenvx.com/prebuild',
|
|
15868
|
-
'📡
|
|
15869
|
-
'
|
|
15870
|
-
'
|
|
15960
|
+
'📡 add observability to secrets: https://dotenvx.com/ops',
|
|
15961
|
+
'👥 sync secrets across teammates & machines: https://dotenvx.com/ops',
|
|
15962
|
+
'🗂️ backup and recover secrets: https://dotenvx.com/ops',
|
|
15963
|
+
'✅ audit secrets and track compliance: https://dotenvx.com/ops',
|
|
15964
|
+
'🔄 add secrets lifecycle management: https://dotenvx.com/ops',
|
|
15965
|
+
'🔑 add access controls to secrets: https://dotenvx.com/ops',
|
|
15871
15966
|
'🛠️ run anywhere with `dotenvx run -- yourcommand`',
|
|
15872
15967
|
'⚙️ specify custom .env file path with { path: \'/custom/path/.env\' }',
|
|
15873
15968
|
'⚙️ enable debug logging with { debug: true }',
|
|
@@ -17567,6 +17662,7 @@ class AlpacaTradingAPI {
|
|
|
17567
17662
|
reconnectTimeout = null;
|
|
17568
17663
|
messageHandlers = new Map();
|
|
17569
17664
|
debugLogging = false;
|
|
17665
|
+
manualDisconnect = false;
|
|
17570
17666
|
/**
|
|
17571
17667
|
* Constructor for AlpacaTradingAPI
|
|
17572
17668
|
* @param credentials - Alpaca credentials,
|
|
@@ -17656,6 +17752,8 @@ class AlpacaTradingAPI {
|
|
|
17656
17752
|
}
|
|
17657
17753
|
}
|
|
17658
17754
|
connectWebsocket() {
|
|
17755
|
+
// Reset manual disconnect flag to allow reconnection logic
|
|
17756
|
+
this.manualDisconnect = false;
|
|
17659
17757
|
if (this.connecting) {
|
|
17660
17758
|
this.log('Connection attempt skipped - already connecting');
|
|
17661
17759
|
return;
|
|
@@ -17706,13 +17804,52 @@ class AlpacaTradingAPI {
|
|
|
17706
17804
|
clearTimeout(this.reconnectTimeout);
|
|
17707
17805
|
this.reconnectTimeout = null;
|
|
17708
17806
|
}
|
|
17709
|
-
// Schedule reconnection
|
|
17710
|
-
this.
|
|
17711
|
-
this.
|
|
17712
|
-
|
|
17713
|
-
|
|
17807
|
+
// Schedule reconnection unless this was a manual disconnect
|
|
17808
|
+
if (!this.manualDisconnect) {
|
|
17809
|
+
this.reconnectTimeout = setTimeout(() => {
|
|
17810
|
+
this.log('Attempting to reconnect...');
|
|
17811
|
+
this.connectWebsocket();
|
|
17812
|
+
}, this.reconnectDelay);
|
|
17813
|
+
}
|
|
17714
17814
|
});
|
|
17715
17815
|
}
|
|
17816
|
+
/**
|
|
17817
|
+
* Cleanly disconnect from the WebSocket and stop auto-reconnects
|
|
17818
|
+
*/
|
|
17819
|
+
disconnect() {
|
|
17820
|
+
// Prevent auto-reconnect scheduling
|
|
17821
|
+
this.manualDisconnect = true;
|
|
17822
|
+
// Clear any scheduled reconnect
|
|
17823
|
+
if (this.reconnectTimeout) {
|
|
17824
|
+
clearTimeout(this.reconnectTimeout);
|
|
17825
|
+
this.reconnectTimeout = null;
|
|
17826
|
+
}
|
|
17827
|
+
if (this.ws) {
|
|
17828
|
+
this.log('Disconnecting WebSocket...');
|
|
17829
|
+
// Remove listeners first to avoid duplicate handlers after reconnects
|
|
17830
|
+
this.ws.removeAllListeners();
|
|
17831
|
+
try {
|
|
17832
|
+
// Attempt graceful close
|
|
17833
|
+
if (this.ws.readyState === WebSocket.OPEN || this.ws.readyState === WebSocket.CONNECTING) {
|
|
17834
|
+
this.ws.close(1000, 'Client disconnect');
|
|
17835
|
+
}
|
|
17836
|
+
else {
|
|
17837
|
+
this.ws.terminate();
|
|
17838
|
+
}
|
|
17839
|
+
}
|
|
17840
|
+
catch {
|
|
17841
|
+
// Fallback terminate on any error
|
|
17842
|
+
try {
|
|
17843
|
+
this.ws.terminate();
|
|
17844
|
+
}
|
|
17845
|
+
catch { /* no-op */ }
|
|
17846
|
+
}
|
|
17847
|
+
this.ws = null;
|
|
17848
|
+
}
|
|
17849
|
+
this.authenticated = false;
|
|
17850
|
+
this.connecting = false;
|
|
17851
|
+
this.log('WebSocket disconnected');
|
|
17852
|
+
}
|
|
17716
17853
|
async authenticate() {
|
|
17717
17854
|
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
|
17718
17855
|
throw new Error('WebSocket not ready for authentication');
|
|
@@ -18979,6 +19116,7 @@ const disco = {
|
|
|
18979
19116
|
calculateFibonacciLevels: calculateFibonacciLevels,
|
|
18980
19117
|
},
|
|
18981
19118
|
time: {
|
|
19119
|
+
convertDateToMarketTimeZone: convertDateToMarketTimeZone,
|
|
18982
19120
|
getStartAndEndDates: getStartAndEndDates,
|
|
18983
19121
|
getMarketOpenClose: getMarketOpenClose,
|
|
18984
19122
|
getLastFullTradingDate: getLastFullTradingDate,
|