@discomedia/utils 1.0.55 → 1.0.56
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 +8 -33
- package/dist/index-frontend.cjs.map +1 -1
- package/dist/index-frontend.mjs +8 -33
- package/dist/index-frontend.mjs.map +1 -1
- package/dist/index.cjs +53 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +53 -50
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +4 -4
- package/dist/test.js +840 -104
- package/dist/test.js.map +1 -1
- package/dist/types/alpaca-trading-api.d.ts +3 -1
- package/dist/types/alpaca-trading-api.d.ts.map +1 -1
- package/dist/types-frontend/alpaca-trading-api.d.ts +3 -1
- package/dist/types-frontend/alpaca-trading-api.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1491,8 +1491,18 @@ class Queue {
|
|
|
1491
1491
|
}
|
|
1492
1492
|
|
|
1493
1493
|
function pLimit(concurrency) {
|
|
1494
|
+
let rejectOnClear = false;
|
|
1495
|
+
|
|
1496
|
+
if (typeof concurrency === 'object') {
|
|
1497
|
+
({concurrency, rejectOnClear = false} = concurrency);
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1494
1500
|
validateConcurrency(concurrency);
|
|
1495
1501
|
|
|
1502
|
+
if (typeof rejectOnClear !== 'boolean') {
|
|
1503
|
+
throw new TypeError('Expected `rejectOnClear` to be a boolean');
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1496
1506
|
const queue = new Queue();
|
|
1497
1507
|
let activeCount = 0;
|
|
1498
1508
|
|
|
@@ -1500,7 +1510,7 @@ function pLimit(concurrency) {
|
|
|
1500
1510
|
// Process the next queued function if we're under the concurrency limit
|
|
1501
1511
|
if (activeCount < concurrency && queue.size > 0) {
|
|
1502
1512
|
activeCount++;
|
|
1503
|
-
queue.dequeue()();
|
|
1513
|
+
queue.dequeue().run();
|
|
1504
1514
|
}
|
|
1505
1515
|
};
|
|
1506
1516
|
|
|
@@ -1527,11 +1537,14 @@ function pLimit(concurrency) {
|
|
|
1527
1537
|
next();
|
|
1528
1538
|
};
|
|
1529
1539
|
|
|
1530
|
-
const enqueue = (function_, resolve, arguments_) => {
|
|
1540
|
+
const enqueue = (function_, resolve, reject, arguments_) => {
|
|
1541
|
+
const queueItem = {reject};
|
|
1542
|
+
|
|
1531
1543
|
// Queue the internal resolve function instead of the run function
|
|
1532
1544
|
// to preserve the asynchronous execution context.
|
|
1533
1545
|
new Promise(internalResolve => { // eslint-disable-line promise/param-names
|
|
1534
|
-
|
|
1546
|
+
queueItem.run = internalResolve;
|
|
1547
|
+
queue.enqueue(queueItem);
|
|
1535
1548
|
}).then(run.bind(undefined, function_, resolve, arguments_)); // eslint-disable-line promise/prefer-await-to-then
|
|
1536
1549
|
|
|
1537
1550
|
// Start processing immediately if we haven't reached the concurrency limit
|
|
@@ -1540,8 +1553,8 @@ function pLimit(concurrency) {
|
|
|
1540
1553
|
}
|
|
1541
1554
|
};
|
|
1542
1555
|
|
|
1543
|
-
const generator = (function_, ...arguments_) => new Promise(resolve => {
|
|
1544
|
-
enqueue(function_, resolve, arguments_);
|
|
1556
|
+
const generator = (function_, ...arguments_) => new Promise((resolve, reject) => {
|
|
1557
|
+
enqueue(function_, resolve, reject, arguments_);
|
|
1545
1558
|
});
|
|
1546
1559
|
|
|
1547
1560
|
Object.defineProperties(generator, {
|
|
@@ -1553,7 +1566,16 @@ function pLimit(concurrency) {
|
|
|
1553
1566
|
},
|
|
1554
1567
|
clearQueue: {
|
|
1555
1568
|
value() {
|
|
1556
|
-
|
|
1569
|
+
if (!rejectOnClear) {
|
|
1570
|
+
queue.clear();
|
|
1571
|
+
return;
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
const abortError = AbortSignal.abort().reason;
|
|
1575
|
+
|
|
1576
|
+
while (queue.size > 0) {
|
|
1577
|
+
queue.dequeue().reject(abortError);
|
|
1578
|
+
}
|
|
1557
1579
|
},
|
|
1558
1580
|
},
|
|
1559
1581
|
concurrency: {
|
|
@@ -2519,7 +2541,7 @@ const safeJSON = (text) => {
|
|
|
2519
2541
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2520
2542
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
2521
2543
|
|
|
2522
|
-
const VERSION = '6.
|
|
2544
|
+
const VERSION = '6.17.0'; // x-release-please-version
|
|
2523
2545
|
|
|
2524
2546
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2525
2547
|
const isRunningInBrowser = () => {
|
|
@@ -5812,12 +5834,7 @@ class Assistants extends APIResource {
|
|
|
5812
5834
|
/**
|
|
5813
5835
|
* Create an assistant with a model and instructions.
|
|
5814
5836
|
*
|
|
5815
|
-
* @
|
|
5816
|
-
* ```ts
|
|
5817
|
-
* const assistant = await client.beta.assistants.create({
|
|
5818
|
-
* model: 'gpt-4o',
|
|
5819
|
-
* });
|
|
5820
|
-
* ```
|
|
5837
|
+
* @deprecated
|
|
5821
5838
|
*/
|
|
5822
5839
|
create(body, options) {
|
|
5823
5840
|
return this._client.post('/assistants', {
|
|
@@ -5829,12 +5846,7 @@ class Assistants extends APIResource {
|
|
|
5829
5846
|
/**
|
|
5830
5847
|
* Retrieves an assistant.
|
|
5831
5848
|
*
|
|
5832
|
-
* @
|
|
5833
|
-
* ```ts
|
|
5834
|
-
* const assistant = await client.beta.assistants.retrieve(
|
|
5835
|
-
* 'assistant_id',
|
|
5836
|
-
* );
|
|
5837
|
-
* ```
|
|
5849
|
+
* @deprecated
|
|
5838
5850
|
*/
|
|
5839
5851
|
retrieve(assistantID, options) {
|
|
5840
5852
|
return this._client.get(path `/assistants/${assistantID}`, {
|
|
@@ -5845,12 +5857,7 @@ class Assistants extends APIResource {
|
|
|
5845
5857
|
/**
|
|
5846
5858
|
* Modifies an assistant.
|
|
5847
5859
|
*
|
|
5848
|
-
* @
|
|
5849
|
-
* ```ts
|
|
5850
|
-
* const assistant = await client.beta.assistants.update(
|
|
5851
|
-
* 'assistant_id',
|
|
5852
|
-
* );
|
|
5853
|
-
* ```
|
|
5860
|
+
* @deprecated
|
|
5854
5861
|
*/
|
|
5855
5862
|
update(assistantID, body, options) {
|
|
5856
5863
|
return this._client.post(path `/assistants/${assistantID}`, {
|
|
@@ -5862,13 +5869,7 @@ class Assistants extends APIResource {
|
|
|
5862
5869
|
/**
|
|
5863
5870
|
* Returns a list of assistants.
|
|
5864
5871
|
*
|
|
5865
|
-
* @
|
|
5866
|
-
* ```ts
|
|
5867
|
-
* // Automatically fetches more pages as needed.
|
|
5868
|
-
* for await (const assistant of client.beta.assistants.list()) {
|
|
5869
|
-
* // ...
|
|
5870
|
-
* }
|
|
5871
|
-
* ```
|
|
5872
|
+
* @deprecated
|
|
5872
5873
|
*/
|
|
5873
5874
|
list(query = {}, options) {
|
|
5874
5875
|
return this._client.getAPIList('/assistants', (CursorPage), {
|
|
@@ -5880,11 +5881,7 @@ class Assistants extends APIResource {
|
|
|
5880
5881
|
/**
|
|
5881
5882
|
* Delete an assistant.
|
|
5882
5883
|
*
|
|
5883
|
-
* @
|
|
5884
|
-
* ```ts
|
|
5885
|
-
* const assistantDeleted =
|
|
5886
|
-
* await client.beta.assistants.delete('assistant_id');
|
|
5887
|
-
* ```
|
|
5884
|
+
* @deprecated
|
|
5888
5885
|
*/
|
|
5889
5886
|
delete(assistantID, options) {
|
|
5890
5887
|
return this._client.delete(path `/assistants/${assistantID}`, {
|
|
@@ -7358,8 +7355,8 @@ Evals.Runs = Runs;
|
|
|
7358
7355
|
let Files$1 = class Files extends APIResource {
|
|
7359
7356
|
/**
|
|
7360
7357
|
* Upload a file that can be used across various endpoints. Individual files can be
|
|
7361
|
-
* up to 512 MB, and
|
|
7362
|
-
*
|
|
7358
|
+
* up to 512 MB, and each project can store up to 2.5 TB of files in total. There
|
|
7359
|
+
* is no organization-wide storage limit.
|
|
7363
7360
|
*
|
|
7364
7361
|
* - The Assistants API supports files up to 2 million tokens and of specific file
|
|
7365
7362
|
* types. See the
|
|
@@ -18536,22 +18533,28 @@ class AlpacaTradingAPI {
|
|
|
18536
18533
|
* @param side (string) - the side of the order
|
|
18537
18534
|
* @param trailPercent100 (number) - the trail percent of the order (scale 100, i.e. 0.5 = 0.5%)
|
|
18538
18535
|
* @param position_intent (string) - the position intent of the order
|
|
18536
|
+
* @param client_order_id (string) - optional client order id
|
|
18537
|
+
* @returns The created trailing stop order
|
|
18539
18538
|
*/
|
|
18540
|
-
async createTrailingStop(symbol, qty, side, trailPercent100, position_intent) {
|
|
18539
|
+
async createTrailingStop(symbol, qty, side, trailPercent100, position_intent, client_order_id) {
|
|
18541
18540
|
this.log(`Creating trailing stop ${side.toUpperCase()} ${qty} shares for ${symbol} with trail percent ${trailPercent100}%`, {
|
|
18542
18541
|
symbol,
|
|
18543
18542
|
});
|
|
18543
|
+
const body = {
|
|
18544
|
+
symbol,
|
|
18545
|
+
qty: Math.abs(qty),
|
|
18546
|
+
side,
|
|
18547
|
+
position_intent,
|
|
18548
|
+
order_class: 'simple',
|
|
18549
|
+
type: 'trailing_stop',
|
|
18550
|
+
trail_percent: trailPercent100, // Already in decimal form (e.g., 4 for 4%)
|
|
18551
|
+
time_in_force: 'gtc',
|
|
18552
|
+
};
|
|
18553
|
+
if (client_order_id !== undefined) {
|
|
18554
|
+
body.client_order_id = client_order_id;
|
|
18555
|
+
}
|
|
18544
18556
|
try {
|
|
18545
|
-
await this.makeRequest(`/orders`, 'POST',
|
|
18546
|
-
symbol,
|
|
18547
|
-
qty: Math.abs(qty),
|
|
18548
|
-
side,
|
|
18549
|
-
position_intent,
|
|
18550
|
-
order_class: 'simple',
|
|
18551
|
-
type: 'trailing_stop',
|
|
18552
|
-
trail_percent: trailPercent100, // Already in decimal form (e.g., 4 for 4%)
|
|
18553
|
-
time_in_force: 'gtc',
|
|
18554
|
-
});
|
|
18557
|
+
return await this.makeRequest(`/orders`, 'POST', body);
|
|
18555
18558
|
}
|
|
18556
18559
|
catch (error) {
|
|
18557
18560
|
this.log(`Error creating trailing stop: ${error}`, {
|