triqai 0.3.0 → 0.4.1
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/CHANGELOG.md +26 -0
- package/README.md +63 -2
- package/dist/index.cjs +750 -144
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +87 -26
- package/dist/index.d.ts +87 -26
- package/dist/index.js +750 -145
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1493,6 +1493,41 @@ interface TriqaiConfig {
|
|
|
1493
1493
|
onRequest?: (request: RequestInfo) => void;
|
|
1494
1494
|
/** Called after every HTTP response. Useful for logging/debugging. */
|
|
1495
1495
|
onResponse?: (response: ResponseInfo) => void;
|
|
1496
|
+
/**
|
|
1497
|
+
* Client-side pacing: calls on this client wait their turn within the API's
|
|
1498
|
+
* rate and concurrency limits instead of being refused with 429. On by
|
|
1499
|
+
* default in Node.js and Bun; off by default elsewhere, such as Cloudflare
|
|
1500
|
+
* Workers, Deno and browsers. Pass `true` or an object to turn it on, or
|
|
1501
|
+
* `false` to send every request immediately.
|
|
1502
|
+
*/
|
|
1503
|
+
pacing?: boolean | PacingOptions;
|
|
1504
|
+
}
|
|
1505
|
+
/** Options accepted by every request method. */
|
|
1506
|
+
interface RequestOptions {
|
|
1507
|
+
/**
|
|
1508
|
+
* Cancels the call, including while it waits its turn or between retries.
|
|
1509
|
+
* The call then rejects with the signal's reason, as `fetch` does.
|
|
1510
|
+
*/
|
|
1511
|
+
signal?: AbortSignal;
|
|
1512
|
+
}
|
|
1513
|
+
interface PacingOptions {
|
|
1514
|
+
/**
|
|
1515
|
+
* Most enrichment requests this client keeps in flight. The API's
|
|
1516
|
+
* concurrency limit applies when it is lower. Until the API has reported
|
|
1517
|
+
* its limit, at most 5 are in flight unless you set this.
|
|
1518
|
+
*/
|
|
1519
|
+
maxConcurrency?: number;
|
|
1520
|
+
/**
|
|
1521
|
+
* Most requests per second this client sends, retries included. The API's
|
|
1522
|
+
* rate limit applies when it is lower.
|
|
1523
|
+
*/
|
|
1524
|
+
requestsPerSecond?: number;
|
|
1525
|
+
/**
|
|
1526
|
+
* Longest time in milliseconds a call waits for its turn before its first
|
|
1527
|
+
* attempt. It then rejects with `PacingTimeoutError` without being sent.
|
|
1528
|
+
* Defaults to `maxRetryTime`.
|
|
1529
|
+
*/
|
|
1530
|
+
maxWait?: number;
|
|
1496
1531
|
}
|
|
1497
1532
|
interface RequestInfo {
|
|
1498
1533
|
method: string;
|
|
@@ -1516,7 +1551,7 @@ interface RateLimitInfo {
|
|
|
1516
1551
|
concurrencyRemaining?: number;
|
|
1517
1552
|
retryAfter?: number;
|
|
1518
1553
|
}
|
|
1519
|
-
interface EnrichOptions {
|
|
1554
|
+
interface EnrichOptions extends RequestOptions {
|
|
1520
1555
|
/**
|
|
1521
1556
|
* @deprecated Has no effect. The API never supported a cache bypass: the
|
|
1522
1557
|
* public contract defines no `force` parameter and no endpoint reads one.
|
|
@@ -1570,17 +1605,24 @@ declare class HttpClient {
|
|
|
1570
1605
|
private readonly defaultHeaders;
|
|
1571
1606
|
private readonly onRequest?;
|
|
1572
1607
|
private readonly onResponse?;
|
|
1608
|
+
private readonly pacer?;
|
|
1573
1609
|
constructor(apiKey: string, config?: TriqaiConfig);
|
|
1574
|
-
get<T>(path: string, query?: Record<string, unknown
|
|
1575
|
-
post<T>(path: string, body?: unknown): Promise<HttpResponse<T>>;
|
|
1576
|
-
delete<T>(path: string, body?: unknown): Promise<HttpResponse<T>>;
|
|
1610
|
+
get<T>(path: string, query?: Record<string, unknown>, options?: RequestOptions): Promise<HttpResponse<T>>;
|
|
1611
|
+
post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HttpResponse<T>>;
|
|
1612
|
+
delete<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HttpResponse<T>>;
|
|
1577
1613
|
private request;
|
|
1578
1614
|
/**
|
|
1579
1615
|
* Variant that injects custom headers (used by resources for Idempotency-Key etc.).
|
|
1580
1616
|
*/
|
|
1581
|
-
postWithHeaders<T>(path: string, body: unknown, headers: Record<string, string>, query?: Record<string, unknown
|
|
1617
|
+
postWithHeaders<T>(path: string, body: unknown, headers: Record<string, string>, query?: Record<string, unknown>, options?: RequestOptions): Promise<HttpResponse<T>>;
|
|
1582
1618
|
private buildUrl;
|
|
1583
1619
|
private calculateDelay;
|
|
1620
|
+
/**
|
|
1621
|
+
* The wait after a 429. Without Retry-After, the limit's reset time is used
|
|
1622
|
+
* when it is near, measured against the response's Date header so the
|
|
1623
|
+
* client's clock does not matter; otherwise the normal backoff.
|
|
1624
|
+
*/
|
|
1625
|
+
private rateLimitDelay;
|
|
1584
1626
|
private canRetry;
|
|
1585
1627
|
private mapError;
|
|
1586
1628
|
}
|
|
@@ -1589,9 +1631,9 @@ declare class Banks {
|
|
|
1589
1631
|
private readonly http;
|
|
1590
1632
|
constructor(http: HttpClient);
|
|
1591
1633
|
/** Exact, case-insensitive name lookup with an optional country of origin. Costs zero credits. */
|
|
1592
|
-
search(params: BankSearchParams): Promise<BankSearchResponse["data"]>;
|
|
1634
|
+
search(params: BankSearchParams, options?: RequestOptions): Promise<BankSearchResponse["data"]>;
|
|
1593
1635
|
/** Retrieve stored bank details by UUID. */
|
|
1594
|
-
get(id: string): Promise<BankData>;
|
|
1636
|
+
get(id: string, options?: RequestOptions): Promise<BankData>;
|
|
1595
1637
|
}
|
|
1596
1638
|
|
|
1597
1639
|
declare class Categories {
|
|
@@ -1603,6 +1645,7 @@ declare class Categories {
|
|
|
1603
1645
|
* Returns the full category tree used for transaction classification,
|
|
1604
1646
|
* including MCC, SIC, and NAICS codes.
|
|
1605
1647
|
*
|
|
1648
|
+
* @param options - Optional `signal` to cancel the call.
|
|
1606
1649
|
* @returns Array of category info objects and the total count.
|
|
1607
1650
|
*
|
|
1608
1651
|
* @example
|
|
@@ -1611,7 +1654,7 @@ declare class Categories {
|
|
|
1611
1654
|
* console.log(`${total} categories available`);
|
|
1612
1655
|
* ```
|
|
1613
1656
|
*/
|
|
1614
|
-
list(): Promise<{
|
|
1657
|
+
list(options?: RequestOptions): Promise<{
|
|
1615
1658
|
categories: CategoryInfo[];
|
|
1616
1659
|
total: number;
|
|
1617
1660
|
categoryVersion: string;
|
|
@@ -1625,6 +1668,7 @@ declare class Intermediaries {
|
|
|
1625
1668
|
* Get an intermediary (payment processor / platform) by ID.
|
|
1626
1669
|
*
|
|
1627
1670
|
* @param id - Intermediary UUID.
|
|
1671
|
+
* @param options - Optional `signal` to cancel the call.
|
|
1628
1672
|
* @returns The intermediary data (name, icon, description, website, domain, etc.).
|
|
1629
1673
|
*
|
|
1630
1674
|
* @example
|
|
@@ -1633,7 +1677,7 @@ declare class Intermediaries {
|
|
|
1633
1677
|
* console.log(intermediary.name); // "PayPal", "Square", etc.
|
|
1634
1678
|
* ```
|
|
1635
1679
|
*/
|
|
1636
|
-
get(id: string): Promise<IntermediaryData>;
|
|
1680
|
+
get(id: string, options?: RequestOptions): Promise<IntermediaryData>;
|
|
1637
1681
|
}
|
|
1638
1682
|
|
|
1639
1683
|
/**
|
|
@@ -1701,7 +1745,7 @@ declare class IssueReports {
|
|
|
1701
1745
|
* console.log(report.id, report.status);
|
|
1702
1746
|
* ```
|
|
1703
1747
|
*/
|
|
1704
|
-
create(params: CreateIssueReportParams): Promise<IssueReport>;
|
|
1748
|
+
create(params: CreateIssueReportParams, options?: RequestOptions): Promise<IssueReport>;
|
|
1705
1749
|
/**
|
|
1706
1750
|
* List issue reports with pagination.
|
|
1707
1751
|
*
|
|
@@ -1716,14 +1760,15 @@ declare class IssueReports {
|
|
|
1716
1760
|
* }
|
|
1717
1761
|
* ```
|
|
1718
1762
|
*/
|
|
1719
|
-
list(params?: ListIssueReportsParams): Promise<Page<IssueReport>>;
|
|
1763
|
+
list(params?: ListIssueReportsParams, options?: RequestOptions): Promise<Page<IssueReport>>;
|
|
1720
1764
|
/**
|
|
1721
1765
|
* Get a single issue report by ID.
|
|
1722
1766
|
*
|
|
1723
1767
|
* @param id - Issue report UUID.
|
|
1768
|
+
* @param options - Optional `signal` to cancel the call.
|
|
1724
1769
|
* @returns The issue report details.
|
|
1725
1770
|
*/
|
|
1726
|
-
get(id: string): Promise<IssueReport>;
|
|
1771
|
+
get(id: string, options?: RequestOptions): Promise<IssueReport>;
|
|
1727
1772
|
}
|
|
1728
1773
|
|
|
1729
1774
|
declare class Locations {
|
|
@@ -1733,6 +1778,7 @@ declare class Locations {
|
|
|
1733
1778
|
* Get a location by ID.
|
|
1734
1779
|
*
|
|
1735
1780
|
* @param id - Location UUID.
|
|
1781
|
+
* @param options - Optional `signal` to cancel the call.
|
|
1736
1782
|
* @returns The location data (name, formatted address, coordinates, phone, rating, etc.).
|
|
1737
1783
|
*
|
|
1738
1784
|
* @example
|
|
@@ -1741,7 +1787,7 @@ declare class Locations {
|
|
|
1741
1787
|
* console.log(location.formatted, location.structured.city);
|
|
1742
1788
|
* ```
|
|
1743
1789
|
*/
|
|
1744
|
-
get(id: string): Promise<LocationData>;
|
|
1790
|
+
get(id: string, options?: RequestOptions): Promise<LocationData>;
|
|
1745
1791
|
}
|
|
1746
1792
|
|
|
1747
1793
|
declare class Merchants {
|
|
@@ -1751,6 +1797,7 @@ declare class Merchants {
|
|
|
1751
1797
|
* Get a merchant by ID.
|
|
1752
1798
|
*
|
|
1753
1799
|
* @param id - Merchant UUID.
|
|
1800
|
+
* @param options - Optional `signal` to cancel the call.
|
|
1754
1801
|
* @returns The merchant data (name, icon, website, domain, aliases, etc.).
|
|
1755
1802
|
*
|
|
1756
1803
|
* @example
|
|
@@ -1759,7 +1806,7 @@ declare class Merchants {
|
|
|
1759
1806
|
* console.log(merchant.name, merchant.website);
|
|
1760
1807
|
* ```
|
|
1761
1808
|
*/
|
|
1762
|
-
get(id: string): Promise<MerchantData>;
|
|
1809
|
+
get(id: string, options?: RequestOptions): Promise<MerchantData>;
|
|
1763
1810
|
}
|
|
1764
1811
|
|
|
1765
1812
|
declare class Transactions {
|
|
@@ -1769,7 +1816,7 @@ declare class Transactions {
|
|
|
1769
1816
|
* Enrich a transaction with merchant, category, location, and entity data.
|
|
1770
1817
|
*
|
|
1771
1818
|
* @param request - The transaction to enrich (title, country, type, and optional options).
|
|
1772
|
-
* @param options - Optional
|
|
1819
|
+
* @param options - Optional idempotency key and `signal` to cancel the call.
|
|
1773
1820
|
* @returns The enriched transaction data.
|
|
1774
1821
|
*
|
|
1775
1822
|
* @example
|
|
@@ -1800,7 +1847,7 @@ declare class Transactions {
|
|
|
1800
1847
|
* }
|
|
1801
1848
|
* ```
|
|
1802
1849
|
*/
|
|
1803
|
-
list(params?: ListTransactionsParams): Promise<Page<EnrichedTransaction>>;
|
|
1850
|
+
list(params?: ListTransactionsParams, options?: RequestOptions): Promise<Page<EnrichedTransaction>>;
|
|
1804
1851
|
/**
|
|
1805
1852
|
* Count your organization's transactions.
|
|
1806
1853
|
*
|
|
@@ -1812,21 +1859,23 @@ declare class Transactions {
|
|
|
1812
1859
|
* const { count } = await triqai.transactions.count({ afterDate: "2026-01-01T00:00:00Z" });
|
|
1813
1860
|
* ```
|
|
1814
1861
|
*/
|
|
1815
|
-
count(params?: CountTransactionsParams): Promise<TransactionCountResponse["data"]>;
|
|
1862
|
+
count(params?: CountTransactionsParams, options?: RequestOptions): Promise<TransactionCountResponse["data"]>;
|
|
1816
1863
|
/**
|
|
1817
1864
|
* Get a single transaction by ID.
|
|
1818
1865
|
*
|
|
1819
1866
|
* @param id - Transaction UUID.
|
|
1867
|
+
* @param options - Optional `signal` to cancel the call.
|
|
1820
1868
|
* @returns The enriched transaction record.
|
|
1821
1869
|
*/
|
|
1822
|
-
get(id: string): Promise<EnrichedTransaction>;
|
|
1870
|
+
get(id: string, options?: RequestOptions): Promise<EnrichedTransaction>;
|
|
1823
1871
|
/**
|
|
1824
1872
|
* Delete a transaction by ID.
|
|
1825
1873
|
*
|
|
1826
1874
|
* @param id - Transaction UUID.
|
|
1875
|
+
* @param options - Optional `signal` to cancel the call.
|
|
1827
1876
|
* @returns Confirmation with the deleted transaction ID.
|
|
1828
1877
|
*/
|
|
1829
|
-
delete(id: string): Promise<{
|
|
1878
|
+
delete(id: string, options?: RequestOptions): Promise<{
|
|
1830
1879
|
deleted: true;
|
|
1831
1880
|
transactionId: string;
|
|
1832
1881
|
}>;
|
|
@@ -1849,7 +1898,7 @@ declare class Transactions {
|
|
|
1849
1898
|
* });
|
|
1850
1899
|
* ```
|
|
1851
1900
|
*/
|
|
1852
|
-
batchDelete(request: BatchDeleteTransactionsParams): Promise<BatchDeleteResponse["data"]>;
|
|
1901
|
+
batchDelete(request: BatchDeleteTransactionsParams, options?: RequestOptions): Promise<BatchDeleteResponse["data"]>;
|
|
1853
1902
|
}
|
|
1854
1903
|
|
|
1855
1904
|
/**
|
|
@@ -1903,7 +1952,7 @@ declare class Triqai {
|
|
|
1903
1952
|
* console.log(health.data.version); // "1.1.9"
|
|
1904
1953
|
* ```
|
|
1905
1954
|
*/
|
|
1906
|
-
health(): Promise<HealthResponse>;
|
|
1955
|
+
health(options?: RequestOptions): Promise<HealthResponse>;
|
|
1907
1956
|
/**
|
|
1908
1957
|
* Get API version and endpoint directory.
|
|
1909
1958
|
*
|
|
@@ -1916,33 +1965,36 @@ declare class Triqai {
|
|
|
1916
1965
|
* console.log(info.data.endpoints);
|
|
1917
1966
|
* ```
|
|
1918
1967
|
*/
|
|
1919
|
-
apiInfo(): Promise<ApiInfoResponse>;
|
|
1968
|
+
apiInfo(options?: RequestOptions): Promise<ApiInfoResponse>;
|
|
1920
1969
|
/**
|
|
1921
1970
|
* Make a raw GET request to any API path.
|
|
1922
1971
|
* Useful for accessing endpoints not yet covered by a resource class.
|
|
1923
1972
|
*
|
|
1924
1973
|
* @param path - API path (e.g. "/v1/some-endpoint").
|
|
1925
1974
|
* @param query - Optional query parameters.
|
|
1975
|
+
* @param options - Optional `signal` to cancel the call.
|
|
1926
1976
|
* @returns The full HTTP response including headers and rate limit info.
|
|
1927
1977
|
*/
|
|
1928
|
-
rawGet<T = unknown>(path: string, query?: Record<string, unknown
|
|
1978
|
+
rawGet<T = unknown>(path: string, query?: Record<string, unknown>, options?: RequestOptions): Promise<HttpResponse<T>>;
|
|
1929
1979
|
/**
|
|
1930
1980
|
* Make a raw POST request to any API path.
|
|
1931
1981
|
* Useful for accessing endpoints not yet covered by a resource class.
|
|
1932
1982
|
*
|
|
1933
1983
|
* @param path - API path (e.g. "/v1/some-endpoint").
|
|
1934
1984
|
* @param body - Request body.
|
|
1985
|
+
* @param options - Optional `signal` to cancel the call.
|
|
1935
1986
|
* @returns The full HTTP response including headers and rate limit info.
|
|
1936
1987
|
*/
|
|
1937
|
-
rawPost<T = unknown>(path: string, body?: unknown): Promise<HttpResponse<T>>;
|
|
1988
|
+
rawPost<T = unknown>(path: string, body?: unknown, options?: RequestOptions): Promise<HttpResponse<T>>;
|
|
1938
1989
|
/**
|
|
1939
1990
|
* Make a raw DELETE request to any API path.
|
|
1940
1991
|
* Useful for accessing endpoints not yet covered by a resource class.
|
|
1941
1992
|
*
|
|
1942
1993
|
* @param path - API path (e.g. "/v1/some-resource/uuid").
|
|
1994
|
+
* @param options - Optional `signal` to cancel the call.
|
|
1943
1995
|
* @returns The full HTTP response including headers and rate limit info.
|
|
1944
1996
|
*/
|
|
1945
|
-
rawDelete<T = unknown>(path: string): Promise<HttpResponse<T>>;
|
|
1997
|
+
rawDelete<T = unknown>(path: string, options?: RequestOptions): Promise<HttpResponse<T>>;
|
|
1946
1998
|
}
|
|
1947
1999
|
|
|
1948
2000
|
interface RawErrorObject {
|
|
@@ -2032,7 +2084,16 @@ declare class ConnectionError extends TriqaiError {
|
|
|
2032
2084
|
constructor(message: string);
|
|
2033
2085
|
}
|
|
2034
2086
|
declare class TimeoutError extends TriqaiError {
|
|
2087
|
+
constructor(message: string, opts?: {
|
|
2088
|
+
code?: string;
|
|
2089
|
+
});
|
|
2090
|
+
}
|
|
2091
|
+
/**
|
|
2092
|
+
* The call waited longer than `pacing.maxWait` for its turn and was never
|
|
2093
|
+
* sent, so nothing was charged. Safe to call again.
|
|
2094
|
+
*/
|
|
2095
|
+
declare class PacingTimeoutError extends TimeoutError {
|
|
2035
2096
|
constructor(message: string);
|
|
2036
2097
|
}
|
|
2037
2098
|
|
|
2038
|
-
export { type ApiInfoResponse, AuthenticationError, AuthorizationError, type BankData, type BankResponse, type BankSearchParams, type BankSearchResponse, type BatchDeleteRequest, type BatchDeleteResponse, type BatchDeleteTransactionsParams, type Category, type CategoryCode, type CategoryInfo, type CategoryListResponse, type CategoryStructure, ClientDisconnectedError, type ClientDisconnectedErrorResponse, type ConfidenceWithReasons, ConnectionError, type Coordinates, type CountTransactionsParams, type CreateIssueReportParams, type DeleteTransactionResponse, DuplicateRequestError, type DuplicateRequestErrorResponse, type EnrichMeta, type EnrichOptions, type EnrichRequest, type EnrichRequestOptions, type EnrichSuccessResponse, type EnrichedTransaction, type EnrichmentData, type EnrichmentErrorCode, type EnrichmentFieldPath, type EnrichmentFilterOptions, type EntityResult, type ErrorObject, type ErrorResponse, GatewayTimeoutError, GoneError, type HealthResponse, type HttpResponse, InsufficientCreditsError, type IntermediaryData, type IntermediaryRecord, type IntermediaryResponse, InternalServerError, type IssueReport, type IssueReportListResponse, type IssueReportResponse, type IssueReportStatus, type ListIssueReportsParams, type ListTransactionsParams, type LocationData, type LocationRating, type LocationResponse, type MerchantData, type MerchantResponse, NotFoundError, Page, type PageInfo, type PaginationMeta, type PersonData, type PrefilledIntermediary, type PrefilledLocation, type PrefilledMerchant, RateLimitError, type RateLimitInfo, type RawErrorObject, type RawResponseMeta, type ReportIssueRequest, type RequestInfo, type ResponseInfo, type ResponseMeta, ServiceUnavailableError, type StructuredAddress, TimeoutError, type TransactionCountResponse, type TransactionData, type TransactionDetailResponse, type TransactionListResponse, type TransactionPagination, type TransactionRecord, type TransactionType, Triqai, type TriqaiConfig, TriqaiError, ValidationError, Triqai as default };
|
|
2099
|
+
export { type ApiInfoResponse, AuthenticationError, AuthorizationError, type BankData, type BankResponse, type BankSearchParams, type BankSearchResponse, type BatchDeleteRequest, type BatchDeleteResponse, type BatchDeleteTransactionsParams, type Category, type CategoryCode, type CategoryInfo, type CategoryListResponse, type CategoryStructure, ClientDisconnectedError, type ClientDisconnectedErrorResponse, type ConfidenceWithReasons, ConnectionError, type Coordinates, type CountTransactionsParams, type CreateIssueReportParams, type DeleteTransactionResponse, DuplicateRequestError, type DuplicateRequestErrorResponse, type EnrichMeta, type EnrichOptions, type EnrichRequest, type EnrichRequestOptions, type EnrichSuccessResponse, type EnrichedTransaction, type EnrichmentData, type EnrichmentErrorCode, type EnrichmentFieldPath, type EnrichmentFilterOptions, type EntityResult, type ErrorObject, type ErrorResponse, GatewayTimeoutError, GoneError, type HealthResponse, type HttpResponse, InsufficientCreditsError, type IntermediaryData, type IntermediaryRecord, type IntermediaryResponse, InternalServerError, type IssueReport, type IssueReportListResponse, type IssueReportResponse, type IssueReportStatus, type ListIssueReportsParams, type ListTransactionsParams, type LocationData, type LocationRating, type LocationResponse, type MerchantData, type MerchantResponse, NotFoundError, type PacingOptions, PacingTimeoutError, Page, type PageInfo, type PaginationMeta, type PersonData, type PrefilledIntermediary, type PrefilledLocation, type PrefilledMerchant, RateLimitError, type RateLimitInfo, type RawErrorObject, type RawResponseMeta, type ReportIssueRequest, type RequestInfo, type RequestOptions, type ResponseInfo, type ResponseMeta, ServiceUnavailableError, type StructuredAddress, TimeoutError, type TransactionCountResponse, type TransactionData, type TransactionDetailResponse, type TransactionListResponse, type TransactionPagination, type TransactionRecord, type TransactionType, Triqai, type TriqaiConfig, TriqaiError, ValidationError, Triqai as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1493,6 +1493,41 @@ interface TriqaiConfig {
|
|
|
1493
1493
|
onRequest?: (request: RequestInfo) => void;
|
|
1494
1494
|
/** Called after every HTTP response. Useful for logging/debugging. */
|
|
1495
1495
|
onResponse?: (response: ResponseInfo) => void;
|
|
1496
|
+
/**
|
|
1497
|
+
* Client-side pacing: calls on this client wait their turn within the API's
|
|
1498
|
+
* rate and concurrency limits instead of being refused with 429. On by
|
|
1499
|
+
* default in Node.js and Bun; off by default elsewhere, such as Cloudflare
|
|
1500
|
+
* Workers, Deno and browsers. Pass `true` or an object to turn it on, or
|
|
1501
|
+
* `false` to send every request immediately.
|
|
1502
|
+
*/
|
|
1503
|
+
pacing?: boolean | PacingOptions;
|
|
1504
|
+
}
|
|
1505
|
+
/** Options accepted by every request method. */
|
|
1506
|
+
interface RequestOptions {
|
|
1507
|
+
/**
|
|
1508
|
+
* Cancels the call, including while it waits its turn or between retries.
|
|
1509
|
+
* The call then rejects with the signal's reason, as `fetch` does.
|
|
1510
|
+
*/
|
|
1511
|
+
signal?: AbortSignal;
|
|
1512
|
+
}
|
|
1513
|
+
interface PacingOptions {
|
|
1514
|
+
/**
|
|
1515
|
+
* Most enrichment requests this client keeps in flight. The API's
|
|
1516
|
+
* concurrency limit applies when it is lower. Until the API has reported
|
|
1517
|
+
* its limit, at most 5 are in flight unless you set this.
|
|
1518
|
+
*/
|
|
1519
|
+
maxConcurrency?: number;
|
|
1520
|
+
/**
|
|
1521
|
+
* Most requests per second this client sends, retries included. The API's
|
|
1522
|
+
* rate limit applies when it is lower.
|
|
1523
|
+
*/
|
|
1524
|
+
requestsPerSecond?: number;
|
|
1525
|
+
/**
|
|
1526
|
+
* Longest time in milliseconds a call waits for its turn before its first
|
|
1527
|
+
* attempt. It then rejects with `PacingTimeoutError` without being sent.
|
|
1528
|
+
* Defaults to `maxRetryTime`.
|
|
1529
|
+
*/
|
|
1530
|
+
maxWait?: number;
|
|
1496
1531
|
}
|
|
1497
1532
|
interface RequestInfo {
|
|
1498
1533
|
method: string;
|
|
@@ -1516,7 +1551,7 @@ interface RateLimitInfo {
|
|
|
1516
1551
|
concurrencyRemaining?: number;
|
|
1517
1552
|
retryAfter?: number;
|
|
1518
1553
|
}
|
|
1519
|
-
interface EnrichOptions {
|
|
1554
|
+
interface EnrichOptions extends RequestOptions {
|
|
1520
1555
|
/**
|
|
1521
1556
|
* @deprecated Has no effect. The API never supported a cache bypass: the
|
|
1522
1557
|
* public contract defines no `force` parameter and no endpoint reads one.
|
|
@@ -1570,17 +1605,24 @@ declare class HttpClient {
|
|
|
1570
1605
|
private readonly defaultHeaders;
|
|
1571
1606
|
private readonly onRequest?;
|
|
1572
1607
|
private readonly onResponse?;
|
|
1608
|
+
private readonly pacer?;
|
|
1573
1609
|
constructor(apiKey: string, config?: TriqaiConfig);
|
|
1574
|
-
get<T>(path: string, query?: Record<string, unknown
|
|
1575
|
-
post<T>(path: string, body?: unknown): Promise<HttpResponse<T>>;
|
|
1576
|
-
delete<T>(path: string, body?: unknown): Promise<HttpResponse<T>>;
|
|
1610
|
+
get<T>(path: string, query?: Record<string, unknown>, options?: RequestOptions): Promise<HttpResponse<T>>;
|
|
1611
|
+
post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HttpResponse<T>>;
|
|
1612
|
+
delete<T>(path: string, body?: unknown, options?: RequestOptions): Promise<HttpResponse<T>>;
|
|
1577
1613
|
private request;
|
|
1578
1614
|
/**
|
|
1579
1615
|
* Variant that injects custom headers (used by resources for Idempotency-Key etc.).
|
|
1580
1616
|
*/
|
|
1581
|
-
postWithHeaders<T>(path: string, body: unknown, headers: Record<string, string>, query?: Record<string, unknown
|
|
1617
|
+
postWithHeaders<T>(path: string, body: unknown, headers: Record<string, string>, query?: Record<string, unknown>, options?: RequestOptions): Promise<HttpResponse<T>>;
|
|
1582
1618
|
private buildUrl;
|
|
1583
1619
|
private calculateDelay;
|
|
1620
|
+
/**
|
|
1621
|
+
* The wait after a 429. Without Retry-After, the limit's reset time is used
|
|
1622
|
+
* when it is near, measured against the response's Date header so the
|
|
1623
|
+
* client's clock does not matter; otherwise the normal backoff.
|
|
1624
|
+
*/
|
|
1625
|
+
private rateLimitDelay;
|
|
1584
1626
|
private canRetry;
|
|
1585
1627
|
private mapError;
|
|
1586
1628
|
}
|
|
@@ -1589,9 +1631,9 @@ declare class Banks {
|
|
|
1589
1631
|
private readonly http;
|
|
1590
1632
|
constructor(http: HttpClient);
|
|
1591
1633
|
/** Exact, case-insensitive name lookup with an optional country of origin. Costs zero credits. */
|
|
1592
|
-
search(params: BankSearchParams): Promise<BankSearchResponse["data"]>;
|
|
1634
|
+
search(params: BankSearchParams, options?: RequestOptions): Promise<BankSearchResponse["data"]>;
|
|
1593
1635
|
/** Retrieve stored bank details by UUID. */
|
|
1594
|
-
get(id: string): Promise<BankData>;
|
|
1636
|
+
get(id: string, options?: RequestOptions): Promise<BankData>;
|
|
1595
1637
|
}
|
|
1596
1638
|
|
|
1597
1639
|
declare class Categories {
|
|
@@ -1603,6 +1645,7 @@ declare class Categories {
|
|
|
1603
1645
|
* Returns the full category tree used for transaction classification,
|
|
1604
1646
|
* including MCC, SIC, and NAICS codes.
|
|
1605
1647
|
*
|
|
1648
|
+
* @param options - Optional `signal` to cancel the call.
|
|
1606
1649
|
* @returns Array of category info objects and the total count.
|
|
1607
1650
|
*
|
|
1608
1651
|
* @example
|
|
@@ -1611,7 +1654,7 @@ declare class Categories {
|
|
|
1611
1654
|
* console.log(`${total} categories available`);
|
|
1612
1655
|
* ```
|
|
1613
1656
|
*/
|
|
1614
|
-
list(): Promise<{
|
|
1657
|
+
list(options?: RequestOptions): Promise<{
|
|
1615
1658
|
categories: CategoryInfo[];
|
|
1616
1659
|
total: number;
|
|
1617
1660
|
categoryVersion: string;
|
|
@@ -1625,6 +1668,7 @@ declare class Intermediaries {
|
|
|
1625
1668
|
* Get an intermediary (payment processor / platform) by ID.
|
|
1626
1669
|
*
|
|
1627
1670
|
* @param id - Intermediary UUID.
|
|
1671
|
+
* @param options - Optional `signal` to cancel the call.
|
|
1628
1672
|
* @returns The intermediary data (name, icon, description, website, domain, etc.).
|
|
1629
1673
|
*
|
|
1630
1674
|
* @example
|
|
@@ -1633,7 +1677,7 @@ declare class Intermediaries {
|
|
|
1633
1677
|
* console.log(intermediary.name); // "PayPal", "Square", etc.
|
|
1634
1678
|
* ```
|
|
1635
1679
|
*/
|
|
1636
|
-
get(id: string): Promise<IntermediaryData>;
|
|
1680
|
+
get(id: string, options?: RequestOptions): Promise<IntermediaryData>;
|
|
1637
1681
|
}
|
|
1638
1682
|
|
|
1639
1683
|
/**
|
|
@@ -1701,7 +1745,7 @@ declare class IssueReports {
|
|
|
1701
1745
|
* console.log(report.id, report.status);
|
|
1702
1746
|
* ```
|
|
1703
1747
|
*/
|
|
1704
|
-
create(params: CreateIssueReportParams): Promise<IssueReport>;
|
|
1748
|
+
create(params: CreateIssueReportParams, options?: RequestOptions): Promise<IssueReport>;
|
|
1705
1749
|
/**
|
|
1706
1750
|
* List issue reports with pagination.
|
|
1707
1751
|
*
|
|
@@ -1716,14 +1760,15 @@ declare class IssueReports {
|
|
|
1716
1760
|
* }
|
|
1717
1761
|
* ```
|
|
1718
1762
|
*/
|
|
1719
|
-
list(params?: ListIssueReportsParams): Promise<Page<IssueReport>>;
|
|
1763
|
+
list(params?: ListIssueReportsParams, options?: RequestOptions): Promise<Page<IssueReport>>;
|
|
1720
1764
|
/**
|
|
1721
1765
|
* Get a single issue report by ID.
|
|
1722
1766
|
*
|
|
1723
1767
|
* @param id - Issue report UUID.
|
|
1768
|
+
* @param options - Optional `signal` to cancel the call.
|
|
1724
1769
|
* @returns The issue report details.
|
|
1725
1770
|
*/
|
|
1726
|
-
get(id: string): Promise<IssueReport>;
|
|
1771
|
+
get(id: string, options?: RequestOptions): Promise<IssueReport>;
|
|
1727
1772
|
}
|
|
1728
1773
|
|
|
1729
1774
|
declare class Locations {
|
|
@@ -1733,6 +1778,7 @@ declare class Locations {
|
|
|
1733
1778
|
* Get a location by ID.
|
|
1734
1779
|
*
|
|
1735
1780
|
* @param id - Location UUID.
|
|
1781
|
+
* @param options - Optional `signal` to cancel the call.
|
|
1736
1782
|
* @returns The location data (name, formatted address, coordinates, phone, rating, etc.).
|
|
1737
1783
|
*
|
|
1738
1784
|
* @example
|
|
@@ -1741,7 +1787,7 @@ declare class Locations {
|
|
|
1741
1787
|
* console.log(location.formatted, location.structured.city);
|
|
1742
1788
|
* ```
|
|
1743
1789
|
*/
|
|
1744
|
-
get(id: string): Promise<LocationData>;
|
|
1790
|
+
get(id: string, options?: RequestOptions): Promise<LocationData>;
|
|
1745
1791
|
}
|
|
1746
1792
|
|
|
1747
1793
|
declare class Merchants {
|
|
@@ -1751,6 +1797,7 @@ declare class Merchants {
|
|
|
1751
1797
|
* Get a merchant by ID.
|
|
1752
1798
|
*
|
|
1753
1799
|
* @param id - Merchant UUID.
|
|
1800
|
+
* @param options - Optional `signal` to cancel the call.
|
|
1754
1801
|
* @returns The merchant data (name, icon, website, domain, aliases, etc.).
|
|
1755
1802
|
*
|
|
1756
1803
|
* @example
|
|
@@ -1759,7 +1806,7 @@ declare class Merchants {
|
|
|
1759
1806
|
* console.log(merchant.name, merchant.website);
|
|
1760
1807
|
* ```
|
|
1761
1808
|
*/
|
|
1762
|
-
get(id: string): Promise<MerchantData>;
|
|
1809
|
+
get(id: string, options?: RequestOptions): Promise<MerchantData>;
|
|
1763
1810
|
}
|
|
1764
1811
|
|
|
1765
1812
|
declare class Transactions {
|
|
@@ -1769,7 +1816,7 @@ declare class Transactions {
|
|
|
1769
1816
|
* Enrich a transaction with merchant, category, location, and entity data.
|
|
1770
1817
|
*
|
|
1771
1818
|
* @param request - The transaction to enrich (title, country, type, and optional options).
|
|
1772
|
-
* @param options - Optional
|
|
1819
|
+
* @param options - Optional idempotency key and `signal` to cancel the call.
|
|
1773
1820
|
* @returns The enriched transaction data.
|
|
1774
1821
|
*
|
|
1775
1822
|
* @example
|
|
@@ -1800,7 +1847,7 @@ declare class Transactions {
|
|
|
1800
1847
|
* }
|
|
1801
1848
|
* ```
|
|
1802
1849
|
*/
|
|
1803
|
-
list(params?: ListTransactionsParams): Promise<Page<EnrichedTransaction>>;
|
|
1850
|
+
list(params?: ListTransactionsParams, options?: RequestOptions): Promise<Page<EnrichedTransaction>>;
|
|
1804
1851
|
/**
|
|
1805
1852
|
* Count your organization's transactions.
|
|
1806
1853
|
*
|
|
@@ -1812,21 +1859,23 @@ declare class Transactions {
|
|
|
1812
1859
|
* const { count } = await triqai.transactions.count({ afterDate: "2026-01-01T00:00:00Z" });
|
|
1813
1860
|
* ```
|
|
1814
1861
|
*/
|
|
1815
|
-
count(params?: CountTransactionsParams): Promise<TransactionCountResponse["data"]>;
|
|
1862
|
+
count(params?: CountTransactionsParams, options?: RequestOptions): Promise<TransactionCountResponse["data"]>;
|
|
1816
1863
|
/**
|
|
1817
1864
|
* Get a single transaction by ID.
|
|
1818
1865
|
*
|
|
1819
1866
|
* @param id - Transaction UUID.
|
|
1867
|
+
* @param options - Optional `signal` to cancel the call.
|
|
1820
1868
|
* @returns The enriched transaction record.
|
|
1821
1869
|
*/
|
|
1822
|
-
get(id: string): Promise<EnrichedTransaction>;
|
|
1870
|
+
get(id: string, options?: RequestOptions): Promise<EnrichedTransaction>;
|
|
1823
1871
|
/**
|
|
1824
1872
|
* Delete a transaction by ID.
|
|
1825
1873
|
*
|
|
1826
1874
|
* @param id - Transaction UUID.
|
|
1875
|
+
* @param options - Optional `signal` to cancel the call.
|
|
1827
1876
|
* @returns Confirmation with the deleted transaction ID.
|
|
1828
1877
|
*/
|
|
1829
|
-
delete(id: string): Promise<{
|
|
1878
|
+
delete(id: string, options?: RequestOptions): Promise<{
|
|
1830
1879
|
deleted: true;
|
|
1831
1880
|
transactionId: string;
|
|
1832
1881
|
}>;
|
|
@@ -1849,7 +1898,7 @@ declare class Transactions {
|
|
|
1849
1898
|
* });
|
|
1850
1899
|
* ```
|
|
1851
1900
|
*/
|
|
1852
|
-
batchDelete(request: BatchDeleteTransactionsParams): Promise<BatchDeleteResponse["data"]>;
|
|
1901
|
+
batchDelete(request: BatchDeleteTransactionsParams, options?: RequestOptions): Promise<BatchDeleteResponse["data"]>;
|
|
1853
1902
|
}
|
|
1854
1903
|
|
|
1855
1904
|
/**
|
|
@@ -1903,7 +1952,7 @@ declare class Triqai {
|
|
|
1903
1952
|
* console.log(health.data.version); // "1.1.9"
|
|
1904
1953
|
* ```
|
|
1905
1954
|
*/
|
|
1906
|
-
health(): Promise<HealthResponse>;
|
|
1955
|
+
health(options?: RequestOptions): Promise<HealthResponse>;
|
|
1907
1956
|
/**
|
|
1908
1957
|
* Get API version and endpoint directory.
|
|
1909
1958
|
*
|
|
@@ -1916,33 +1965,36 @@ declare class Triqai {
|
|
|
1916
1965
|
* console.log(info.data.endpoints);
|
|
1917
1966
|
* ```
|
|
1918
1967
|
*/
|
|
1919
|
-
apiInfo(): Promise<ApiInfoResponse>;
|
|
1968
|
+
apiInfo(options?: RequestOptions): Promise<ApiInfoResponse>;
|
|
1920
1969
|
/**
|
|
1921
1970
|
* Make a raw GET request to any API path.
|
|
1922
1971
|
* Useful for accessing endpoints not yet covered by a resource class.
|
|
1923
1972
|
*
|
|
1924
1973
|
* @param path - API path (e.g. "/v1/some-endpoint").
|
|
1925
1974
|
* @param query - Optional query parameters.
|
|
1975
|
+
* @param options - Optional `signal` to cancel the call.
|
|
1926
1976
|
* @returns The full HTTP response including headers and rate limit info.
|
|
1927
1977
|
*/
|
|
1928
|
-
rawGet<T = unknown>(path: string, query?: Record<string, unknown
|
|
1978
|
+
rawGet<T = unknown>(path: string, query?: Record<string, unknown>, options?: RequestOptions): Promise<HttpResponse<T>>;
|
|
1929
1979
|
/**
|
|
1930
1980
|
* Make a raw POST request to any API path.
|
|
1931
1981
|
* Useful for accessing endpoints not yet covered by a resource class.
|
|
1932
1982
|
*
|
|
1933
1983
|
* @param path - API path (e.g. "/v1/some-endpoint").
|
|
1934
1984
|
* @param body - Request body.
|
|
1985
|
+
* @param options - Optional `signal` to cancel the call.
|
|
1935
1986
|
* @returns The full HTTP response including headers and rate limit info.
|
|
1936
1987
|
*/
|
|
1937
|
-
rawPost<T = unknown>(path: string, body?: unknown): Promise<HttpResponse<T>>;
|
|
1988
|
+
rawPost<T = unknown>(path: string, body?: unknown, options?: RequestOptions): Promise<HttpResponse<T>>;
|
|
1938
1989
|
/**
|
|
1939
1990
|
* Make a raw DELETE request to any API path.
|
|
1940
1991
|
* Useful for accessing endpoints not yet covered by a resource class.
|
|
1941
1992
|
*
|
|
1942
1993
|
* @param path - API path (e.g. "/v1/some-resource/uuid").
|
|
1994
|
+
* @param options - Optional `signal` to cancel the call.
|
|
1943
1995
|
* @returns The full HTTP response including headers and rate limit info.
|
|
1944
1996
|
*/
|
|
1945
|
-
rawDelete<T = unknown>(path: string): Promise<HttpResponse<T>>;
|
|
1997
|
+
rawDelete<T = unknown>(path: string, options?: RequestOptions): Promise<HttpResponse<T>>;
|
|
1946
1998
|
}
|
|
1947
1999
|
|
|
1948
2000
|
interface RawErrorObject {
|
|
@@ -2032,7 +2084,16 @@ declare class ConnectionError extends TriqaiError {
|
|
|
2032
2084
|
constructor(message: string);
|
|
2033
2085
|
}
|
|
2034
2086
|
declare class TimeoutError extends TriqaiError {
|
|
2087
|
+
constructor(message: string, opts?: {
|
|
2088
|
+
code?: string;
|
|
2089
|
+
});
|
|
2090
|
+
}
|
|
2091
|
+
/**
|
|
2092
|
+
* The call waited longer than `pacing.maxWait` for its turn and was never
|
|
2093
|
+
* sent, so nothing was charged. Safe to call again.
|
|
2094
|
+
*/
|
|
2095
|
+
declare class PacingTimeoutError extends TimeoutError {
|
|
2035
2096
|
constructor(message: string);
|
|
2036
2097
|
}
|
|
2037
2098
|
|
|
2038
|
-
export { type ApiInfoResponse, AuthenticationError, AuthorizationError, type BankData, type BankResponse, type BankSearchParams, type BankSearchResponse, type BatchDeleteRequest, type BatchDeleteResponse, type BatchDeleteTransactionsParams, type Category, type CategoryCode, type CategoryInfo, type CategoryListResponse, type CategoryStructure, ClientDisconnectedError, type ClientDisconnectedErrorResponse, type ConfidenceWithReasons, ConnectionError, type Coordinates, type CountTransactionsParams, type CreateIssueReportParams, type DeleteTransactionResponse, DuplicateRequestError, type DuplicateRequestErrorResponse, type EnrichMeta, type EnrichOptions, type EnrichRequest, type EnrichRequestOptions, type EnrichSuccessResponse, type EnrichedTransaction, type EnrichmentData, type EnrichmentErrorCode, type EnrichmentFieldPath, type EnrichmentFilterOptions, type EntityResult, type ErrorObject, type ErrorResponse, GatewayTimeoutError, GoneError, type HealthResponse, type HttpResponse, InsufficientCreditsError, type IntermediaryData, type IntermediaryRecord, type IntermediaryResponse, InternalServerError, type IssueReport, type IssueReportListResponse, type IssueReportResponse, type IssueReportStatus, type ListIssueReportsParams, type ListTransactionsParams, type LocationData, type LocationRating, type LocationResponse, type MerchantData, type MerchantResponse, NotFoundError, Page, type PageInfo, type PaginationMeta, type PersonData, type PrefilledIntermediary, type PrefilledLocation, type PrefilledMerchant, RateLimitError, type RateLimitInfo, type RawErrorObject, type RawResponseMeta, type ReportIssueRequest, type RequestInfo, type ResponseInfo, type ResponseMeta, ServiceUnavailableError, type StructuredAddress, TimeoutError, type TransactionCountResponse, type TransactionData, type TransactionDetailResponse, type TransactionListResponse, type TransactionPagination, type TransactionRecord, type TransactionType, Triqai, type TriqaiConfig, TriqaiError, ValidationError, Triqai as default };
|
|
2099
|
+
export { type ApiInfoResponse, AuthenticationError, AuthorizationError, type BankData, type BankResponse, type BankSearchParams, type BankSearchResponse, type BatchDeleteRequest, type BatchDeleteResponse, type BatchDeleteTransactionsParams, type Category, type CategoryCode, type CategoryInfo, type CategoryListResponse, type CategoryStructure, ClientDisconnectedError, type ClientDisconnectedErrorResponse, type ConfidenceWithReasons, ConnectionError, type Coordinates, type CountTransactionsParams, type CreateIssueReportParams, type DeleteTransactionResponse, DuplicateRequestError, type DuplicateRequestErrorResponse, type EnrichMeta, type EnrichOptions, type EnrichRequest, type EnrichRequestOptions, type EnrichSuccessResponse, type EnrichedTransaction, type EnrichmentData, type EnrichmentErrorCode, type EnrichmentFieldPath, type EnrichmentFilterOptions, type EntityResult, type ErrorObject, type ErrorResponse, GatewayTimeoutError, GoneError, type HealthResponse, type HttpResponse, InsufficientCreditsError, type IntermediaryData, type IntermediaryRecord, type IntermediaryResponse, InternalServerError, type IssueReport, type IssueReportListResponse, type IssueReportResponse, type IssueReportStatus, type ListIssueReportsParams, type ListTransactionsParams, type LocationData, type LocationRating, type LocationResponse, type MerchantData, type MerchantResponse, NotFoundError, type PacingOptions, PacingTimeoutError, Page, type PageInfo, type PaginationMeta, type PersonData, type PrefilledIntermediary, type PrefilledLocation, type PrefilledMerchant, RateLimitError, type RateLimitInfo, type RawErrorObject, type RawResponseMeta, type ReportIssueRequest, type RequestInfo, type RequestOptions, type ResponseInfo, type ResponseMeta, ServiceUnavailableError, type StructuredAddress, TimeoutError, type TransactionCountResponse, type TransactionData, type TransactionDetailResponse, type TransactionListResponse, type TransactionPagination, type TransactionRecord, type TransactionType, Triqai, type TriqaiConfig, TriqaiError, ValidationError, Triqai as default };
|