@adaptic/utils 0.0.1010 → 0.0.1011
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.cjs +776 -370
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +776 -370
- package/dist/index.mjs.map +1 -1
- package/dist/test.js +45 -45
- package/dist/test.js.map +1 -1
- package/dist/types/__tests__/alpaca-order-idempotency.test.d.ts +2 -0
- package/dist/types/__tests__/alpaca-order-idempotency.test.d.ts.map +1 -0
- package/dist/types/__tests__/retry-classification.test.d.ts +2 -0
- package/dist/types/__tests__/retry-classification.test.d.ts.map +1 -0
- package/dist/types/alpaca/index.d.ts +4 -1
- package/dist/types/alpaca/index.d.ts.map +1 -1
- package/dist/types/alpaca/trading/orders.d.ts +106 -9
- package/dist/types/alpaca/trading/orders.d.ts.map +1 -1
- package/dist/types/index.d.ts +8 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils/retry.d.ts +65 -0
- package/dist/types/utils/retry.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/test.js
CHANGED
|
@@ -1537,6 +1537,51 @@ function createTimeoutSignal(ms) {
|
|
|
1537
1537
|
return AbortSignal.timeout(ms);
|
|
1538
1538
|
}
|
|
1539
1539
|
|
|
1540
|
+
/**
|
|
1541
|
+
* Structured error type hierarchy for all API integrations
|
|
1542
|
+
*
|
|
1543
|
+
* This module provides a comprehensive error handling system for external API integrations,
|
|
1544
|
+
* including Alpaca, Massive, and AlphaVantage services.
|
|
1545
|
+
*/
|
|
1546
|
+
/**
|
|
1547
|
+
* Base error class for all @adaptic/utils errors
|
|
1548
|
+
* Extends Error with additional context about service, error code, and retry capability
|
|
1549
|
+
*/
|
|
1550
|
+
class AdapticUtilsError extends Error {
|
|
1551
|
+
code;
|
|
1552
|
+
service;
|
|
1553
|
+
isRetryable;
|
|
1554
|
+
cause;
|
|
1555
|
+
name;
|
|
1556
|
+
constructor(message, code, service, isRetryable = false, cause) {
|
|
1557
|
+
super(message);
|
|
1558
|
+
this.code = code;
|
|
1559
|
+
this.service = service;
|
|
1560
|
+
this.isRetryable = isRetryable;
|
|
1561
|
+
this.cause = cause;
|
|
1562
|
+
this.name = this.constructor.name;
|
|
1563
|
+
// Maintains proper stack trace for where error was thrown (only available on V8)
|
|
1564
|
+
if (Error.captureStackTrace) {
|
|
1565
|
+
Error.captureStackTrace(this, this.constructor);
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
/**
|
|
1570
|
+
* Rate limit errors (429)
|
|
1571
|
+
* Used when API rate limits are exceeded
|
|
1572
|
+
* Always retryable, often with retry-after header information
|
|
1573
|
+
*/
|
|
1574
|
+
class RateLimitError extends AdapticUtilsError {
|
|
1575
|
+
service;
|
|
1576
|
+
retryAfterMs;
|
|
1577
|
+
constructor(message, service, retryAfterMs, cause) {
|
|
1578
|
+
super(message, "RATE_LIMIT", service, true, // Rate limit errors are always retryable
|
|
1579
|
+
cause);
|
|
1580
|
+
this.service = service;
|
|
1581
|
+
this.retryAfterMs = retryAfterMs;
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1540
1585
|
/**
|
|
1541
1586
|
* Node.js / undici / system error codes that represent transient network
|
|
1542
1587
|
* conditions. Present on `error.code` for net/http/dns/undici errors.
|
|
@@ -1704,51 +1749,6 @@ function isClientDeadlineExpiry(error) {
|
|
|
1704
1749
|
return false;
|
|
1705
1750
|
}
|
|
1706
1751
|
|
|
1707
|
-
/**
|
|
1708
|
-
* Structured error type hierarchy for all API integrations
|
|
1709
|
-
*
|
|
1710
|
-
* This module provides a comprehensive error handling system for external API integrations,
|
|
1711
|
-
* including Alpaca, Massive, and AlphaVantage services.
|
|
1712
|
-
*/
|
|
1713
|
-
/**
|
|
1714
|
-
* Base error class for all @adaptic/utils errors
|
|
1715
|
-
* Extends Error with additional context about service, error code, and retry capability
|
|
1716
|
-
*/
|
|
1717
|
-
class AdapticUtilsError extends Error {
|
|
1718
|
-
code;
|
|
1719
|
-
service;
|
|
1720
|
-
isRetryable;
|
|
1721
|
-
cause;
|
|
1722
|
-
name;
|
|
1723
|
-
constructor(message, code, service, isRetryable = false, cause) {
|
|
1724
|
-
super(message);
|
|
1725
|
-
this.code = code;
|
|
1726
|
-
this.service = service;
|
|
1727
|
-
this.isRetryable = isRetryable;
|
|
1728
|
-
this.cause = cause;
|
|
1729
|
-
this.name = this.constructor.name;
|
|
1730
|
-
// Maintains proper stack trace for where error was thrown (only available on V8)
|
|
1731
|
-
if (Error.captureStackTrace) {
|
|
1732
|
-
Error.captureStackTrace(this, this.constructor);
|
|
1733
|
-
}
|
|
1734
|
-
}
|
|
1735
|
-
}
|
|
1736
|
-
/**
|
|
1737
|
-
* Rate limit errors (429)
|
|
1738
|
-
* Used when API rate limits are exceeded
|
|
1739
|
-
* Always retryable, often with retry-after header information
|
|
1740
|
-
*/
|
|
1741
|
-
class RateLimitError extends AdapticUtilsError {
|
|
1742
|
-
service;
|
|
1743
|
-
retryAfterMs;
|
|
1744
|
-
constructor(message, service, retryAfterMs, cause) {
|
|
1745
|
-
super(message, "RATE_LIMIT", service, true, // Rate limit errors are always retryable
|
|
1746
|
-
cause);
|
|
1747
|
-
this.service = service;
|
|
1748
|
-
this.retryAfterMs = retryAfterMs;
|
|
1749
|
-
}
|
|
1750
|
-
}
|
|
1751
|
-
|
|
1752
1752
|
/**
|
|
1753
1753
|
* Token bucket rate limiter for external API integrations
|
|
1754
1754
|
*
|