@discomedia/utils 1.0.36 → 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 +131 -10
- package/dist/index-frontend.cjs.map +1 -1
- package/dist/index-frontend.mjs +131 -10
- package/dist/index-frontend.mjs.map +1 -1
- package/dist/index.cjs +131 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +131 -10
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +6 -6
- package/dist/test.js +1165 -6002
- 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-frontend/alpaca-trading-api.d.ts +5 -0
- package/dist/types-frontend/alpaca-trading-api.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index-frontend.cjs
CHANGED
|
@@ -269,7 +269,7 @@ const safeJSON = (text) => {
|
|
|
269
269
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
270
270
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
271
271
|
|
|
272
|
-
const VERSION = '
|
|
272
|
+
const VERSION = '6.1.0'; // x-release-please-version
|
|
273
273
|
|
|
274
274
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
275
275
|
const isRunningInBrowser = () => {
|
|
@@ -5387,10 +5387,84 @@ class Moderations extends APIResource {
|
|
|
5387
5387
|
}
|
|
5388
5388
|
}
|
|
5389
5389
|
|
|
5390
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5391
|
+
class Calls extends APIResource {
|
|
5392
|
+
/**
|
|
5393
|
+
* Accept an incoming SIP call and configure the realtime session that will handle
|
|
5394
|
+
* it.
|
|
5395
|
+
*
|
|
5396
|
+
* @example
|
|
5397
|
+
* ```ts
|
|
5398
|
+
* await client.realtime.calls.accept('call_id', {
|
|
5399
|
+
* type: 'realtime',
|
|
5400
|
+
* });
|
|
5401
|
+
* ```
|
|
5402
|
+
*/
|
|
5403
|
+
accept(callID, body, options) {
|
|
5404
|
+
return this._client.post(path `/realtime/calls/${callID}/accept`, {
|
|
5405
|
+
body,
|
|
5406
|
+
...options,
|
|
5407
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
5408
|
+
});
|
|
5409
|
+
}
|
|
5410
|
+
/**
|
|
5411
|
+
* End an active Realtime API call, whether it was initiated over SIP or WebRTC.
|
|
5412
|
+
*
|
|
5413
|
+
* @example
|
|
5414
|
+
* ```ts
|
|
5415
|
+
* await client.realtime.calls.hangup('call_id');
|
|
5416
|
+
* ```
|
|
5417
|
+
*/
|
|
5418
|
+
hangup(callID, options) {
|
|
5419
|
+
return this._client.post(path `/realtime/calls/${callID}/hangup`, {
|
|
5420
|
+
...options,
|
|
5421
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
5422
|
+
});
|
|
5423
|
+
}
|
|
5424
|
+
/**
|
|
5425
|
+
* Transfer an active SIP call to a new destination using the SIP REFER verb.
|
|
5426
|
+
*
|
|
5427
|
+
* @example
|
|
5428
|
+
* ```ts
|
|
5429
|
+
* await client.realtime.calls.refer('call_id', {
|
|
5430
|
+
* target_uri: 'tel:+14155550123',
|
|
5431
|
+
* });
|
|
5432
|
+
* ```
|
|
5433
|
+
*/
|
|
5434
|
+
refer(callID, body, options) {
|
|
5435
|
+
return this._client.post(path `/realtime/calls/${callID}/refer`, {
|
|
5436
|
+
body,
|
|
5437
|
+
...options,
|
|
5438
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
5439
|
+
});
|
|
5440
|
+
}
|
|
5441
|
+
/**
|
|
5442
|
+
* Decline an incoming SIP call by returning a SIP status code to the caller.
|
|
5443
|
+
*
|
|
5444
|
+
* @example
|
|
5445
|
+
* ```ts
|
|
5446
|
+
* await client.realtime.calls.reject('call_id');
|
|
5447
|
+
* ```
|
|
5448
|
+
*/
|
|
5449
|
+
reject(callID, body = {}, options) {
|
|
5450
|
+
return this._client.post(path `/realtime/calls/${callID}/reject`, {
|
|
5451
|
+
body,
|
|
5452
|
+
...options,
|
|
5453
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
5454
|
+
});
|
|
5455
|
+
}
|
|
5456
|
+
}
|
|
5457
|
+
|
|
5390
5458
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5391
5459
|
class ClientSecrets extends APIResource {
|
|
5392
5460
|
/**
|
|
5393
5461
|
* Create a Realtime client secret with an associated session configuration.
|
|
5462
|
+
*
|
|
5463
|
+
* @example
|
|
5464
|
+
* ```ts
|
|
5465
|
+
* const clientSecret =
|
|
5466
|
+
* await client.realtime.clientSecrets.create();
|
|
5467
|
+
* ```
|
|
5394
5468
|
*/
|
|
5395
5469
|
create(body, options) {
|
|
5396
5470
|
return this._client.post('/realtime/client_secrets', { body, ...options });
|
|
@@ -5402,9 +5476,11 @@ class Realtime extends APIResource {
|
|
|
5402
5476
|
constructor() {
|
|
5403
5477
|
super(...arguments);
|
|
5404
5478
|
this.clientSecrets = new ClientSecrets(this._client);
|
|
5479
|
+
this.calls = new Calls(this._client);
|
|
5405
5480
|
}
|
|
5406
5481
|
}
|
|
5407
5482
|
Realtime.ClientSecrets = ClientSecrets;
|
|
5483
|
+
Realtime.Calls = Calls;
|
|
5408
5484
|
|
|
5409
5485
|
function maybeParseResponse(response, params) {
|
|
5410
5486
|
if (!params || !hasAutoParseableInput(params)) {
|
|
@@ -13088,7 +13164,7 @@ var config = {};
|
|
|
13088
13164
|
|
|
13089
13165
|
var main = {exports: {}};
|
|
13090
13166
|
|
|
13091
|
-
var version = "17.2.
|
|
13167
|
+
var version = "17.2.3";
|
|
13092
13168
|
var require$$4 = {
|
|
13093
13169
|
version: version};
|
|
13094
13170
|
|
|
@@ -13110,9 +13186,12 @@ function requireMain () {
|
|
|
13110
13186
|
'🔐 encrypt with Dotenvx: https://dotenvx.com',
|
|
13111
13187
|
'🔐 prevent committing .env to code: https://dotenvx.com/precommit',
|
|
13112
13188
|
'🔐 prevent building .env in docker: https://dotenvx.com/prebuild',
|
|
13113
|
-
'📡
|
|
13114
|
-
'
|
|
13115
|
-
'
|
|
13189
|
+
'📡 add observability to secrets: https://dotenvx.com/ops',
|
|
13190
|
+
'👥 sync secrets across teammates & machines: https://dotenvx.com/ops',
|
|
13191
|
+
'🗂️ backup and recover secrets: https://dotenvx.com/ops',
|
|
13192
|
+
'✅ audit secrets and track compliance: https://dotenvx.com/ops',
|
|
13193
|
+
'🔄 add secrets lifecycle management: https://dotenvx.com/ops',
|
|
13194
|
+
'🔑 add access controls to secrets: https://dotenvx.com/ops',
|
|
13116
13195
|
'🛠️ run anywhere with `dotenvx run -- yourcommand`',
|
|
13117
13196
|
'⚙️ specify custom .env file path with { path: \'/custom/path/.env\' }',
|
|
13118
13197
|
'⚙️ enable debug logging with { debug: true }',
|
|
@@ -15151,6 +15230,7 @@ class AlpacaTradingAPI {
|
|
|
15151
15230
|
reconnectTimeout = null;
|
|
15152
15231
|
messageHandlers = new Map();
|
|
15153
15232
|
debugLogging = false;
|
|
15233
|
+
manualDisconnect = false;
|
|
15154
15234
|
/**
|
|
15155
15235
|
* Constructor for AlpacaTradingAPI
|
|
15156
15236
|
* @param credentials - Alpaca credentials,
|
|
@@ -15240,6 +15320,8 @@ class AlpacaTradingAPI {
|
|
|
15240
15320
|
}
|
|
15241
15321
|
}
|
|
15242
15322
|
connectWebsocket() {
|
|
15323
|
+
// Reset manual disconnect flag to allow reconnection logic
|
|
15324
|
+
this.manualDisconnect = false;
|
|
15243
15325
|
if (this.connecting) {
|
|
15244
15326
|
this.log('Connection attempt skipped - already connecting');
|
|
15245
15327
|
return;
|
|
@@ -15290,13 +15372,52 @@ class AlpacaTradingAPI {
|
|
|
15290
15372
|
clearTimeout(this.reconnectTimeout);
|
|
15291
15373
|
this.reconnectTimeout = null;
|
|
15292
15374
|
}
|
|
15293
|
-
// Schedule reconnection
|
|
15294
|
-
this.
|
|
15295
|
-
this.
|
|
15296
|
-
|
|
15297
|
-
|
|
15375
|
+
// Schedule reconnection unless this was a manual disconnect
|
|
15376
|
+
if (!this.manualDisconnect) {
|
|
15377
|
+
this.reconnectTimeout = setTimeout(() => {
|
|
15378
|
+
this.log('Attempting to reconnect...');
|
|
15379
|
+
this.connectWebsocket();
|
|
15380
|
+
}, this.reconnectDelay);
|
|
15381
|
+
}
|
|
15298
15382
|
});
|
|
15299
15383
|
}
|
|
15384
|
+
/**
|
|
15385
|
+
* Cleanly disconnect from the WebSocket and stop auto-reconnects
|
|
15386
|
+
*/
|
|
15387
|
+
disconnect() {
|
|
15388
|
+
// Prevent auto-reconnect scheduling
|
|
15389
|
+
this.manualDisconnect = true;
|
|
15390
|
+
// Clear any scheduled reconnect
|
|
15391
|
+
if (this.reconnectTimeout) {
|
|
15392
|
+
clearTimeout(this.reconnectTimeout);
|
|
15393
|
+
this.reconnectTimeout = null;
|
|
15394
|
+
}
|
|
15395
|
+
if (this.ws) {
|
|
15396
|
+
this.log('Disconnecting WebSocket...');
|
|
15397
|
+
// Remove listeners first to avoid duplicate handlers after reconnects
|
|
15398
|
+
this.ws.removeAllListeners();
|
|
15399
|
+
try {
|
|
15400
|
+
// Attempt graceful close
|
|
15401
|
+
if (this.ws.readyState === WebSocket.OPEN || this.ws.readyState === WebSocket.CONNECTING) {
|
|
15402
|
+
this.ws.close(1000, 'Client disconnect');
|
|
15403
|
+
}
|
|
15404
|
+
else {
|
|
15405
|
+
this.ws.terminate();
|
|
15406
|
+
}
|
|
15407
|
+
}
|
|
15408
|
+
catch {
|
|
15409
|
+
// Fallback terminate on any error
|
|
15410
|
+
try {
|
|
15411
|
+
this.ws.terminate();
|
|
15412
|
+
}
|
|
15413
|
+
catch { /* no-op */ }
|
|
15414
|
+
}
|
|
15415
|
+
this.ws = null;
|
|
15416
|
+
}
|
|
15417
|
+
this.authenticated = false;
|
|
15418
|
+
this.connecting = false;
|
|
15419
|
+
this.log('WebSocket disconnected');
|
|
15420
|
+
}
|
|
15300
15421
|
async authenticate() {
|
|
15301
15422
|
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
|
15302
15423
|
throw new Error('WebSocket not ready for authentication');
|