@dakota-xyz/ts-sdk 2.1.0 → 2.1.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/README.md +51 -1
- package/dist/index.d.mts +89 -1
- package/dist/index.d.ts +89 -1
- package/dist/index.js +205 -79
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +205 -79
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -134,6 +134,8 @@ var AuthMode = /* @__PURE__ */ ((AuthMode2) => {
|
|
|
134
134
|
AuthMode2["ApplicationToken"] = "application_token";
|
|
135
135
|
return AuthMode2;
|
|
136
136
|
})(AuthMode || {});
|
|
137
|
+
var DEFAULT_TIMEOUT_MS = 15e3;
|
|
138
|
+
var AGENTIC_MODEL_TIMEOUT_MS = 18e4;
|
|
137
139
|
var DEFAULT_RETRY_POLICY = {
|
|
138
140
|
maxAttempts: 3,
|
|
139
141
|
initialBackoffMs: 200,
|
|
@@ -191,7 +193,8 @@ function resolveConfig(config) {
|
|
|
191
193
|
const env = config.environment ?? "sandbox" /* Sandbox */;
|
|
192
194
|
baseURL = getEnvironmentURL(env);
|
|
193
195
|
}
|
|
194
|
-
const
|
|
196
|
+
const timeoutWasExplicit = config.timeout !== void 0;
|
|
197
|
+
const timeout = config.timeout ?? DEFAULT_TIMEOUT_MS;
|
|
195
198
|
if (timeout <= 0) {
|
|
196
199
|
throw new ConfigurationError("Timeout must be greater than zero");
|
|
197
200
|
}
|
|
@@ -218,6 +221,7 @@ function resolveConfig(config) {
|
|
|
218
221
|
baseURL,
|
|
219
222
|
authMode,
|
|
220
223
|
timeout,
|
|
224
|
+
timeoutWasExplicit,
|
|
221
225
|
retryPolicy,
|
|
222
226
|
logger: config.logger ?? noopLogger,
|
|
223
227
|
automaticIdempotency: config.automaticIdempotency ?? true,
|
|
@@ -243,12 +247,16 @@ var Transport = class {
|
|
|
243
247
|
const url = this.buildURL(path, query);
|
|
244
248
|
const requestHeaders = this.buildHeaders(method, path, headers, idempotencyKey);
|
|
245
249
|
const requestBody = body !== void 0 ? JSON.stringify(body) : void 0;
|
|
246
|
-
return this.executeWithRetry(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
250
|
+
return this.executeWithRetry(
|
|
251
|
+
url,
|
|
252
|
+
{
|
|
253
|
+
method,
|
|
254
|
+
headers: requestHeaders,
|
|
255
|
+
body: requestBody,
|
|
256
|
+
signal
|
|
257
|
+
},
|
|
258
|
+
this.resolveTimeout(options)
|
|
259
|
+
);
|
|
252
260
|
}
|
|
253
261
|
/**
|
|
254
262
|
* Build the full URL with query parameters.
|
|
@@ -314,17 +322,47 @@ var Transport = class {
|
|
|
314
322
|
break;
|
|
315
323
|
}
|
|
316
324
|
}
|
|
325
|
+
/**
|
|
326
|
+
* Resolve the deadline for one request, most specific intent first:
|
|
327
|
+
*
|
|
328
|
+
* 1. the caller's per-request `timeout`
|
|
329
|
+
* 2. an explicit client-wide `timeout`
|
|
330
|
+
* 3. the endpoint's own default (slow endpoints raise their own)
|
|
331
|
+
* 4. the client-wide default
|
|
332
|
+
*
|
|
333
|
+
* (2) sits above (3) on purpose: a caller who configured a timeout chose
|
|
334
|
+
* it, and an endpoint must not quietly overrule that. (3) exists so the
|
|
335
|
+
* far more common caller — the one who configured nothing — gets a
|
|
336
|
+
* deadline that matches what the endpoint actually does.
|
|
337
|
+
*/
|
|
338
|
+
resolveTimeout(options) {
|
|
339
|
+
if (options.timeout !== void 0) {
|
|
340
|
+
return options.timeout;
|
|
341
|
+
}
|
|
342
|
+
if (this.config.timeoutWasExplicit) {
|
|
343
|
+
return this.config.timeout;
|
|
344
|
+
}
|
|
345
|
+
return options.endpointTimeout ?? this.config.timeout;
|
|
346
|
+
}
|
|
317
347
|
/**
|
|
318
348
|
* Execute request with exponential backoff retry.
|
|
349
|
+
*
|
|
350
|
+
* `timeout` is per ATTEMPT, not per call: each attempt gets its own
|
|
351
|
+
* deadline, so a request that keeps timing out can take up to
|
|
352
|
+
* `timeout × maxAttempts` before it throws.
|
|
319
353
|
*/
|
|
320
|
-
async executeWithRetry(url, init) {
|
|
354
|
+
async executeWithRetry(url, init, timeout) {
|
|
321
355
|
const { maxAttempts, initialBackoffMs, maxBackoffMs } = this.config.retryPolicy;
|
|
322
356
|
const method = init.method ?? "GET";
|
|
323
357
|
let lastError;
|
|
324
358
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
359
|
+
let timedOut = false;
|
|
325
360
|
try {
|
|
326
361
|
const controller = new AbortController();
|
|
327
|
-
const timeoutId = setTimeout(() =>
|
|
362
|
+
const timeoutId = setTimeout(() => {
|
|
363
|
+
timedOut = true;
|
|
364
|
+
controller.abort();
|
|
365
|
+
}, timeout);
|
|
328
366
|
const signal = init.signal ? this.mergeAbortSignals(init.signal, controller.signal) : controller.signal;
|
|
329
367
|
this.logRequest(method, url, attempt);
|
|
330
368
|
const response = await this.config.fetch(url, {
|
|
@@ -354,8 +392,13 @@ var Transport = class {
|
|
|
354
392
|
if (error instanceof APIError) {
|
|
355
393
|
throw error;
|
|
356
394
|
}
|
|
357
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
358
|
-
lastError = new TransportError(
|
|
395
|
+
if (error instanceof Error && error.name === "AbortError" && timedOut) {
|
|
396
|
+
lastError = new TransportError(
|
|
397
|
+
`Request timed out after ${timeout}ms. This is the SDK's client-side deadline, not a server error \u2014 raise it with \`new DakotaClient({ timeout })\`, or per call with \`{ timeout }\` in the request options. Agent conversations are the usual cause: pass \`{ timeout }\` to \`newAgentConversation\`.`,
|
|
398
|
+
error
|
|
399
|
+
);
|
|
400
|
+
} else if (error instanceof Error && error.name === "AbortError") {
|
|
401
|
+
throw new TransportError("Request aborted by caller", error);
|
|
359
402
|
} else if (error instanceof Error) {
|
|
360
403
|
lastError = new TransportError("Network error", error);
|
|
361
404
|
} else {
|
|
@@ -579,6 +622,9 @@ var BaseResource = class {
|
|
|
579
622
|
path,
|
|
580
623
|
query
|
|
581
624
|
});
|
|
625
|
+
if (Array.isArray(response)) {
|
|
626
|
+
return { data: response, meta: void 0 };
|
|
627
|
+
}
|
|
582
628
|
return {
|
|
583
629
|
data: response.data ?? [],
|
|
584
630
|
meta: response.meta
|
|
@@ -630,7 +676,8 @@ var CustomersResource = class extends BaseResource {
|
|
|
630
676
|
method: "POST",
|
|
631
677
|
path: "/customers",
|
|
632
678
|
body: data,
|
|
633
|
-
idempotencyKey: options?.idempotencyKey
|
|
679
|
+
idempotencyKey: options?.idempotencyKey,
|
|
680
|
+
timeout: options?.timeout
|
|
634
681
|
});
|
|
635
682
|
}
|
|
636
683
|
/**
|
|
@@ -744,7 +791,8 @@ var CustomersResource = class extends BaseResource {
|
|
|
744
791
|
return this.transport.request({
|
|
745
792
|
method: "POST",
|
|
746
793
|
path: `/customers/${customerId}/re-engagement`,
|
|
747
|
-
idempotencyKey: options?.idempotencyKey
|
|
794
|
+
idempotencyKey: options?.idempotencyKey,
|
|
795
|
+
timeout: options?.timeout
|
|
748
796
|
});
|
|
749
797
|
}
|
|
750
798
|
/**
|
|
@@ -780,7 +828,8 @@ var CustomersResource = class extends BaseResource {
|
|
|
780
828
|
method: "PATCH",
|
|
781
829
|
path: `/customers/${customerId}/sub-client`,
|
|
782
830
|
body: data,
|
|
783
|
-
idempotencyKey: options?.idempotencyKey
|
|
831
|
+
idempotencyKey: options?.idempotencyKey,
|
|
832
|
+
timeout: options?.timeout
|
|
784
833
|
});
|
|
785
834
|
}
|
|
786
835
|
/**
|
|
@@ -830,7 +879,8 @@ var CustomersResource = class extends BaseResource {
|
|
|
830
879
|
method: "POST",
|
|
831
880
|
path: "/customers/bulk-import-sumsub-tokens",
|
|
832
881
|
body: data,
|
|
833
|
-
idempotencyKey: options?.idempotencyKey
|
|
882
|
+
idempotencyKey: options?.idempotencyKey,
|
|
883
|
+
timeout: options?.timeout
|
|
834
884
|
});
|
|
835
885
|
}
|
|
836
886
|
/**
|
|
@@ -863,7 +913,8 @@ var CustomersResource = class extends BaseResource {
|
|
|
863
913
|
method: "POST",
|
|
864
914
|
path: "/customers/import-persona-tokens",
|
|
865
915
|
body: data,
|
|
866
|
-
idempotencyKey: options?.idempotencyKey
|
|
916
|
+
idempotencyKey: options?.idempotencyKey,
|
|
917
|
+
timeout: options?.timeout
|
|
867
918
|
});
|
|
868
919
|
}
|
|
869
920
|
/**
|
|
@@ -945,7 +996,8 @@ var RecipientsResource = class extends BaseResource {
|
|
|
945
996
|
method: "POST",
|
|
946
997
|
path: `/customers/${customerId}/recipients`,
|
|
947
998
|
body: data,
|
|
948
|
-
idempotencyKey: options?.idempotencyKey
|
|
999
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1000
|
+
timeout: options?.timeout
|
|
949
1001
|
});
|
|
950
1002
|
}
|
|
951
1003
|
/**
|
|
@@ -1001,7 +1053,8 @@ var RecipientsResource = class extends BaseResource {
|
|
|
1001
1053
|
method: "PUT",
|
|
1002
1054
|
path: `/recipients/${recipientId}`,
|
|
1003
1055
|
body: data,
|
|
1004
|
-
idempotencyKey: options?.idempotencyKey
|
|
1056
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1057
|
+
timeout: options?.timeout
|
|
1005
1058
|
});
|
|
1006
1059
|
}
|
|
1007
1060
|
/**
|
|
@@ -1067,7 +1120,8 @@ var DestinationsResource = class extends BaseResource {
|
|
|
1067
1120
|
method: "POST",
|
|
1068
1121
|
path: `/recipients/${recipientId}/destinations`,
|
|
1069
1122
|
body: data,
|
|
1070
|
-
idempotencyKey: options?.idempotencyKey
|
|
1123
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1124
|
+
timeout: options?.timeout
|
|
1071
1125
|
});
|
|
1072
1126
|
}
|
|
1073
1127
|
/**
|
|
@@ -1155,7 +1209,8 @@ var AccountsResource = class extends BaseResource {
|
|
|
1155
1209
|
method: "POST",
|
|
1156
1210
|
path: "/accounts",
|
|
1157
1211
|
body: data,
|
|
1158
|
-
idempotencyKey: options?.idempotencyKey
|
|
1212
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1213
|
+
timeout: options?.timeout
|
|
1159
1214
|
});
|
|
1160
1215
|
}
|
|
1161
1216
|
/**
|
|
@@ -1214,7 +1269,8 @@ var AccountsResource = class extends BaseResource {
|
|
|
1214
1269
|
method: "PATCH",
|
|
1215
1270
|
path: `/accounts/${accountId}`,
|
|
1216
1271
|
body: data,
|
|
1217
|
-
idempotencyKey: options?.idempotencyKey
|
|
1272
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1273
|
+
timeout: options?.timeout
|
|
1218
1274
|
});
|
|
1219
1275
|
}
|
|
1220
1276
|
/**
|
|
@@ -1274,7 +1330,8 @@ var TransactionsResource = class extends BaseResource {
|
|
|
1274
1330
|
method: "POST",
|
|
1275
1331
|
path: "/transactions",
|
|
1276
1332
|
body: data,
|
|
1277
|
-
idempotencyKey: options?.idempotencyKey
|
|
1333
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1334
|
+
timeout: options?.timeout
|
|
1278
1335
|
});
|
|
1279
1336
|
}
|
|
1280
1337
|
/**
|
|
@@ -1344,7 +1401,8 @@ var TransactionsResource = class extends BaseResource {
|
|
|
1344
1401
|
return this.transport.request({
|
|
1345
1402
|
method: "POST",
|
|
1346
1403
|
path: `/transactions/${transactionId}/cancellations`,
|
|
1347
|
-
idempotencyKey: options?.idempotencyKey
|
|
1404
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1405
|
+
timeout: options?.timeout
|
|
1348
1406
|
});
|
|
1349
1407
|
}
|
|
1350
1408
|
};
|
|
@@ -1397,7 +1455,8 @@ var WalletsResource = class extends BaseResource {
|
|
|
1397
1455
|
method: "POST",
|
|
1398
1456
|
path: "/wallets",
|
|
1399
1457
|
body: data,
|
|
1400
|
-
idempotencyKey: options?.idempotencyKey
|
|
1458
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1459
|
+
timeout: options?.timeout
|
|
1401
1460
|
});
|
|
1402
1461
|
}
|
|
1403
1462
|
/**
|
|
@@ -1519,7 +1578,8 @@ var WalletsResource = class extends BaseResource {
|
|
|
1519
1578
|
method: "POST",
|
|
1520
1579
|
path: `/wallets/${walletId}/transactions`,
|
|
1521
1580
|
body: data,
|
|
1522
|
-
idempotencyKey: options?.idempotencyKey
|
|
1581
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1582
|
+
timeout: options?.timeout
|
|
1523
1583
|
});
|
|
1524
1584
|
}
|
|
1525
1585
|
};
|
|
@@ -1586,7 +1646,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1586
1646
|
method: "POST",
|
|
1587
1647
|
path: `/applications/${applicationId}/submissions`,
|
|
1588
1648
|
body: data ?? {},
|
|
1589
|
-
idempotencyKey: options?.idempotencyKey
|
|
1649
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1650
|
+
timeout: options?.timeout
|
|
1590
1651
|
});
|
|
1591
1652
|
}
|
|
1592
1653
|
// ==========================================================================
|
|
@@ -1606,7 +1667,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1606
1667
|
method: "PUT",
|
|
1607
1668
|
path: `/applications/${applicationId}/business-details`,
|
|
1608
1669
|
body: data,
|
|
1609
|
-
idempotencyKey: options?.idempotencyKey
|
|
1670
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1671
|
+
timeout: options?.timeout
|
|
1610
1672
|
});
|
|
1611
1673
|
}
|
|
1612
1674
|
// ==========================================================================
|
|
@@ -1627,7 +1689,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1627
1689
|
method: "PUT",
|
|
1628
1690
|
path: `/applications/${applicationId}/individual-details`,
|
|
1629
1691
|
body: data,
|
|
1630
|
-
idempotencyKey: options?.idempotencyKey
|
|
1692
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1693
|
+
timeout: options?.timeout
|
|
1631
1694
|
});
|
|
1632
1695
|
}
|
|
1633
1696
|
// ==========================================================================
|
|
@@ -1645,7 +1708,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1645
1708
|
method: "POST",
|
|
1646
1709
|
path: `/applications/${applicationId}/associated-individuals`,
|
|
1647
1710
|
body: data,
|
|
1648
|
-
idempotencyKey: options?.idempotencyKey
|
|
1711
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1712
|
+
timeout: options?.timeout
|
|
1649
1713
|
});
|
|
1650
1714
|
}
|
|
1651
1715
|
/**
|
|
@@ -1663,7 +1727,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1663
1727
|
method: "PUT",
|
|
1664
1728
|
path: `/applications/${applicationId}/associated-individuals/${individualId}`,
|
|
1665
1729
|
body: data,
|
|
1666
|
-
idempotencyKey: options?.idempotencyKey
|
|
1730
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1731
|
+
timeout: options?.timeout
|
|
1667
1732
|
});
|
|
1668
1733
|
}
|
|
1669
1734
|
/**
|
|
@@ -1702,7 +1767,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1702
1767
|
method: "POST",
|
|
1703
1768
|
path: `/applications/${applicationId}/attestations`,
|
|
1704
1769
|
body: data,
|
|
1705
|
-
idempotencyKey: options?.idempotencyKey
|
|
1770
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1771
|
+
timeout: options?.timeout
|
|
1706
1772
|
});
|
|
1707
1773
|
}
|
|
1708
1774
|
// ==========================================================================
|
|
@@ -1734,7 +1800,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1734
1800
|
method: "PUT",
|
|
1735
1801
|
path: `/applications/${applicationId}/edd`,
|
|
1736
1802
|
body: data,
|
|
1737
|
-
idempotencyKey: options?.idempotencyKey
|
|
1803
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1804
|
+
timeout: options?.timeout
|
|
1738
1805
|
});
|
|
1739
1806
|
}
|
|
1740
1807
|
// ==========================================================================
|
|
@@ -1755,7 +1822,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1755
1822
|
method: "POST",
|
|
1756
1823
|
path: `/applications/${applicationId}/documents`,
|
|
1757
1824
|
body: data,
|
|
1758
|
-
idempotencyKey: options?.idempotencyKey
|
|
1825
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1826
|
+
timeout: options?.timeout
|
|
1759
1827
|
});
|
|
1760
1828
|
}
|
|
1761
1829
|
/**
|
|
@@ -1815,7 +1883,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1815
1883
|
method: "POST",
|
|
1816
1884
|
path: `/applications/${applicationId}/documents/${documentId}/verifications`,
|
|
1817
1885
|
body: _data ?? {},
|
|
1818
|
-
idempotencyKey: options?.idempotencyKey
|
|
1886
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1887
|
+
timeout: options?.timeout
|
|
1819
1888
|
});
|
|
1820
1889
|
}
|
|
1821
1890
|
/**
|
|
@@ -1833,7 +1902,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1833
1902
|
method: "POST",
|
|
1834
1903
|
path: `/applications/${applicationId}/document-uploads`,
|
|
1835
1904
|
body: data,
|
|
1836
|
-
idempotencyKey: options?.idempotencyKey
|
|
1905
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1906
|
+
timeout: options?.timeout
|
|
1837
1907
|
});
|
|
1838
1908
|
}
|
|
1839
1909
|
// ==========================================================================
|
|
@@ -1856,7 +1926,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1856
1926
|
method: "POST",
|
|
1857
1927
|
path: `/applications/${applicationId}/associated-individuals/${individualId}/documents`,
|
|
1858
1928
|
body: data,
|
|
1859
|
-
idempotencyKey: options?.idempotencyKey
|
|
1929
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1930
|
+
timeout: options?.timeout
|
|
1860
1931
|
});
|
|
1861
1932
|
}
|
|
1862
1933
|
/**
|
|
@@ -1875,7 +1946,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1875
1946
|
method: "POST",
|
|
1876
1947
|
path: `/applications/${applicationId}/associated-individuals/${individualId}/document-uploads`,
|
|
1877
1948
|
body: data,
|
|
1878
|
-
idempotencyKey: options?.idempotencyKey
|
|
1949
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1950
|
+
timeout: options?.timeout
|
|
1879
1951
|
});
|
|
1880
1952
|
}
|
|
1881
1953
|
};
|
|
@@ -1893,7 +1965,8 @@ var PoliciesResource = class extends BaseResource {
|
|
|
1893
1965
|
method: "POST",
|
|
1894
1966
|
path: "/policies",
|
|
1895
1967
|
body: data,
|
|
1896
|
-
idempotencyKey: options?.idempotencyKey
|
|
1968
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1969
|
+
timeout: options?.timeout
|
|
1897
1970
|
});
|
|
1898
1971
|
}
|
|
1899
1972
|
/**
|
|
@@ -1932,7 +2005,8 @@ var PoliciesResource = class extends BaseResource {
|
|
|
1932
2005
|
method: "DELETE",
|
|
1933
2006
|
path: `/policies/${policyId}`,
|
|
1934
2007
|
body: options?.endorsement,
|
|
1935
|
-
idempotencyKey: options?.idempotencyKey
|
|
2008
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2009
|
+
timeout: options?.timeout
|
|
1936
2010
|
});
|
|
1937
2011
|
}
|
|
1938
2012
|
/**
|
|
@@ -1947,7 +2021,8 @@ var PoliciesResource = class extends BaseResource {
|
|
|
1947
2021
|
method: "POST",
|
|
1948
2022
|
path: `/policies/${policyId}/rules`,
|
|
1949
2023
|
body: options?.endorsement ?? data,
|
|
1950
|
-
idempotencyKey: options?.idempotencyKey
|
|
2024
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2025
|
+
timeout: options?.timeout
|
|
1951
2026
|
});
|
|
1952
2027
|
}
|
|
1953
2028
|
/**
|
|
@@ -1963,7 +2038,8 @@ var PoliciesResource = class extends BaseResource {
|
|
|
1963
2038
|
method: "PATCH",
|
|
1964
2039
|
path: `/policies/${policyId}/rules/${ruleId}`,
|
|
1965
2040
|
body: options?.endorsement ?? data,
|
|
1966
|
-
idempotencyKey: options?.idempotencyKey
|
|
2041
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2042
|
+
timeout: options?.timeout
|
|
1967
2043
|
});
|
|
1968
2044
|
}
|
|
1969
2045
|
/**
|
|
@@ -1982,7 +2058,8 @@ var PoliciesResource = class extends BaseResource {
|
|
|
1982
2058
|
method: "DELETE",
|
|
1983
2059
|
path: `/policies/${policyId}/rules/${ruleId}`,
|
|
1984
2060
|
body: options?.endorsement,
|
|
1985
|
-
idempotencyKey: options?.idempotencyKey
|
|
2061
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2062
|
+
timeout: options?.timeout
|
|
1986
2063
|
});
|
|
1987
2064
|
}
|
|
1988
2065
|
/**
|
|
@@ -2015,7 +2092,8 @@ var PoliciesResource = class extends BaseResource {
|
|
|
2015
2092
|
method: "PUT",
|
|
2016
2093
|
path: `/policies/${policyId}/wallets/${walletId}`,
|
|
2017
2094
|
body: options?.endorsement,
|
|
2018
|
-
idempotencyKey: options?.idempotencyKey
|
|
2095
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2096
|
+
timeout: options?.timeout
|
|
2019
2097
|
});
|
|
2020
2098
|
}
|
|
2021
2099
|
/**
|
|
@@ -2034,7 +2112,8 @@ var PoliciesResource = class extends BaseResource {
|
|
|
2034
2112
|
method: "DELETE",
|
|
2035
2113
|
path: `/policies/${policyId}/wallets/${walletId}`,
|
|
2036
2114
|
body: options?.endorsement,
|
|
2037
|
-
idempotencyKey: options?.idempotencyKey
|
|
2115
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2116
|
+
timeout: options?.timeout
|
|
2038
2117
|
});
|
|
2039
2118
|
}
|
|
2040
2119
|
};
|
|
@@ -2052,7 +2131,8 @@ var SignerGroupsResource = class extends BaseResource {
|
|
|
2052
2131
|
method: "POST",
|
|
2053
2132
|
path: "/signer-groups",
|
|
2054
2133
|
body: data,
|
|
2055
|
-
idempotencyKey: options?.idempotencyKey
|
|
2134
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2135
|
+
timeout: options?.timeout
|
|
2056
2136
|
});
|
|
2057
2137
|
}
|
|
2058
2138
|
/**
|
|
@@ -2106,7 +2186,8 @@ var SignerGroupsResource = class extends BaseResource {
|
|
|
2106
2186
|
method: "POST",
|
|
2107
2187
|
path: `/signer-groups/${signerGroupId}/signers`,
|
|
2108
2188
|
body: data,
|
|
2109
|
-
idempotencyKey: options?.idempotencyKey
|
|
2189
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2190
|
+
timeout: options?.timeout
|
|
2110
2191
|
});
|
|
2111
2192
|
}
|
|
2112
2193
|
/**
|
|
@@ -2122,7 +2203,8 @@ var SignerGroupsResource = class extends BaseResource {
|
|
|
2122
2203
|
await this.transport.request({
|
|
2123
2204
|
method: "DELETE",
|
|
2124
2205
|
path: `/signer-groups/${signerGroupId}/signers/${signerId}`,
|
|
2125
|
-
idempotencyKey: options?.idempotencyKey
|
|
2206
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2207
|
+
timeout: options?.timeout
|
|
2126
2208
|
});
|
|
2127
2209
|
}
|
|
2128
2210
|
/**
|
|
@@ -2155,7 +2237,8 @@ var SignerGroupsResource = class extends BaseResource {
|
|
|
2155
2237
|
method: "PUT",
|
|
2156
2238
|
path: `/wallets/${walletId}/signer-groups/${signerGroupId}`,
|
|
2157
2239
|
body: options?.endorsement,
|
|
2158
|
-
idempotencyKey: options?.idempotencyKey
|
|
2240
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2241
|
+
timeout: options?.timeout
|
|
2159
2242
|
});
|
|
2160
2243
|
}
|
|
2161
2244
|
/**
|
|
@@ -2174,7 +2257,8 @@ var SignerGroupsResource = class extends BaseResource {
|
|
|
2174
2257
|
method: "DELETE",
|
|
2175
2258
|
path: `/wallets/${walletId}/signer-groups/${signerGroupId}`,
|
|
2176
2259
|
body: options?.endorsement,
|
|
2177
|
-
idempotencyKey: options?.idempotencyKey
|
|
2260
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2261
|
+
timeout: options?.timeout
|
|
2178
2262
|
});
|
|
2179
2263
|
}
|
|
2180
2264
|
/**
|
|
@@ -2201,7 +2285,8 @@ var SignersResource = class extends BaseResource {
|
|
|
2201
2285
|
method: "POST",
|
|
2202
2286
|
path: "/signers",
|
|
2203
2287
|
body: data,
|
|
2204
|
-
idempotencyKey: options?.idempotencyKey
|
|
2288
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2289
|
+
timeout: options?.timeout
|
|
2205
2290
|
});
|
|
2206
2291
|
}
|
|
2207
2292
|
/**
|
|
@@ -2232,7 +2317,8 @@ var ApiKeysResource = class extends BaseResource {
|
|
|
2232
2317
|
method: "POST",
|
|
2233
2318
|
path: "/api-keys",
|
|
2234
2319
|
body: data,
|
|
2235
|
-
idempotencyKey: options?.idempotencyKey
|
|
2320
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2321
|
+
timeout: options?.timeout
|
|
2236
2322
|
});
|
|
2237
2323
|
}
|
|
2238
2324
|
/**
|
|
@@ -2280,7 +2366,8 @@ var ApiKeysResource = class extends BaseResource {
|
|
|
2280
2366
|
method: "POST",
|
|
2281
2367
|
path: "/api-keys/admin",
|
|
2282
2368
|
body: data,
|
|
2283
|
-
idempotencyKey: options?.idempotencyKey
|
|
2369
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2370
|
+
timeout: options?.timeout
|
|
2284
2371
|
});
|
|
2285
2372
|
}
|
|
2286
2373
|
};
|
|
@@ -2298,7 +2385,8 @@ var UsersResource = class extends BaseResource {
|
|
|
2298
2385
|
method: "POST",
|
|
2299
2386
|
path: "/users",
|
|
2300
2387
|
body: data,
|
|
2301
|
-
idempotencyKey: options?.idempotencyKey
|
|
2388
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2389
|
+
timeout: options?.timeout
|
|
2302
2390
|
});
|
|
2303
2391
|
}
|
|
2304
2392
|
/**
|
|
@@ -2321,7 +2409,8 @@ var UsersResource = class extends BaseResource {
|
|
|
2321
2409
|
method: "PATCH",
|
|
2322
2410
|
path: `/users/${userId}`,
|
|
2323
2411
|
body: data,
|
|
2324
|
-
idempotencyKey: options?.idempotencyKey
|
|
2412
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2413
|
+
timeout: options?.timeout
|
|
2325
2414
|
});
|
|
2326
2415
|
}
|
|
2327
2416
|
/**
|
|
@@ -2350,7 +2439,8 @@ var WebhooksResource = class extends BaseResource {
|
|
|
2350
2439
|
method: "POST",
|
|
2351
2440
|
path: "/webhooks/targets",
|
|
2352
2441
|
body: data,
|
|
2353
|
-
idempotencyKey: options?.idempotencyKey
|
|
2442
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2443
|
+
timeout: options?.timeout
|
|
2354
2444
|
});
|
|
2355
2445
|
}
|
|
2356
2446
|
/**
|
|
@@ -2386,7 +2476,8 @@ var WebhooksResource = class extends BaseResource {
|
|
|
2386
2476
|
method: "PATCH",
|
|
2387
2477
|
path: `/webhooks/targets/${targetId}`,
|
|
2388
2478
|
body: data,
|
|
2389
|
-
idempotencyKey: options?.idempotencyKey
|
|
2479
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2480
|
+
timeout: options?.timeout
|
|
2390
2481
|
});
|
|
2391
2482
|
}
|
|
2392
2483
|
/**
|
|
@@ -2463,7 +2554,8 @@ var WebhooksResource = class extends BaseResource {
|
|
|
2463
2554
|
return this.transport.request({
|
|
2464
2555
|
method: "POST",
|
|
2465
2556
|
path: `/webhooks/events/${eventId}/replay`,
|
|
2466
|
-
idempotencyKey: options?.idempotencyKey
|
|
2557
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2558
|
+
timeout: options?.timeout
|
|
2467
2559
|
});
|
|
2468
2560
|
}
|
|
2469
2561
|
};
|
|
@@ -2574,7 +2666,8 @@ var SandboxResource = class extends BaseResource {
|
|
|
2574
2666
|
method: "POST",
|
|
2575
2667
|
path: "/sandbox/simulate/inbound",
|
|
2576
2668
|
body: data,
|
|
2577
|
-
idempotencyKey: options?.idempotencyKey
|
|
2669
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2670
|
+
timeout: options?.timeout
|
|
2578
2671
|
});
|
|
2579
2672
|
}
|
|
2580
2673
|
/**
|
|
@@ -2623,7 +2716,8 @@ var SandboxResource = class extends BaseResource {
|
|
|
2623
2716
|
method: "POST",
|
|
2624
2717
|
path: "/sandbox/simulate/onboarding",
|
|
2625
2718
|
body: data,
|
|
2626
|
-
idempotencyKey: options?.idempotencyKey
|
|
2719
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2720
|
+
timeout: options?.timeout
|
|
2627
2721
|
});
|
|
2628
2722
|
}
|
|
2629
2723
|
/**
|
|
@@ -2671,7 +2765,8 @@ var SandboxResource = class extends BaseResource {
|
|
|
2671
2765
|
method: "POST",
|
|
2672
2766
|
path: `/sandbox/simulations/${simulationId}/advance`,
|
|
2673
2767
|
body: data,
|
|
2674
|
-
idempotencyKey: options?.idempotencyKey
|
|
2768
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2769
|
+
timeout: options?.timeout
|
|
2675
2770
|
});
|
|
2676
2771
|
}
|
|
2677
2772
|
/**
|
|
@@ -2720,7 +2815,8 @@ var SelfServeResource = class extends BaseResource {
|
|
|
2720
2815
|
method: "POST",
|
|
2721
2816
|
path: "/self-serve/credits/purchase",
|
|
2722
2817
|
body: data,
|
|
2723
|
-
idempotencyKey: options?.idempotencyKey
|
|
2818
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2819
|
+
timeout: options?.timeout
|
|
2724
2820
|
});
|
|
2725
2821
|
}
|
|
2726
2822
|
/**
|
|
@@ -2866,7 +2962,8 @@ var FeePayoutDestinationResource = class extends BaseResource {
|
|
|
2866
2962
|
method: "PUT",
|
|
2867
2963
|
path: "/fee-payout-destination",
|
|
2868
2964
|
body: data,
|
|
2869
|
-
idempotencyKey: options?.idempotencyKey
|
|
2965
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2966
|
+
timeout: options?.timeout
|
|
2870
2967
|
});
|
|
2871
2968
|
}
|
|
2872
2969
|
/**
|
|
@@ -2900,7 +2997,8 @@ var PaymentAgentsResource = class extends BaseResource {
|
|
|
2900
2997
|
method: "POST",
|
|
2901
2998
|
path: "/payment-agents",
|
|
2902
2999
|
body: data,
|
|
2903
|
-
idempotencyKey: options?.idempotencyKey
|
|
3000
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3001
|
+
timeout: options?.timeout
|
|
2904
3002
|
});
|
|
2905
3003
|
}
|
|
2906
3004
|
/**
|
|
@@ -2939,7 +3037,8 @@ var PaymentAgentsResource = class extends BaseResource {
|
|
|
2939
3037
|
return this.transport.request({
|
|
2940
3038
|
method: "POST",
|
|
2941
3039
|
path: `/payment-agents/${paymentAgentId}/revoke`,
|
|
2942
|
-
idempotencyKey: options?.idempotencyKey
|
|
3040
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3041
|
+
timeout: options?.timeout
|
|
2943
3042
|
});
|
|
2944
3043
|
}
|
|
2945
3044
|
/**
|
|
@@ -2951,6 +3050,12 @@ var PaymentAgentsResource = class extends BaseResource {
|
|
|
2951
3050
|
* `AgentConversation` for multi-turn chat; use this directly only for
|
|
2952
3051
|
* one-shot proposals.
|
|
2953
3052
|
*
|
|
3053
|
+
* SLOW BY NATURE. A turn is a sequence of model calls — read the payees,
|
|
3054
|
+
* check balances, draft, revise — so a multi-payee request legitimately
|
|
3055
|
+
* runs minutes. It therefore defaults to {@link AGENTIC_MODEL_TIMEOUT_MS}
|
|
3056
|
+
* rather than the client's ordinary deadline. Pass `{ timeout }` to
|
|
3057
|
+
* change it for one call; an explicit client-wide `timeout` still wins.
|
|
3058
|
+
*
|
|
2954
3059
|
* @param paymentAgentId - Payment agent ID
|
|
2955
3060
|
* @param data - Prompt and/or messages
|
|
2956
3061
|
* @returns Proposals (at high confidence) and/or a conversational reply
|
|
@@ -2960,7 +3065,9 @@ var PaymentAgentsResource = class extends BaseResource {
|
|
|
2960
3065
|
method: "POST",
|
|
2961
3066
|
path: `/payment-agents/${paymentAgentId}/proposals`,
|
|
2962
3067
|
body: data,
|
|
2963
|
-
idempotencyKey: options?.idempotencyKey
|
|
3068
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3069
|
+
timeout: options?.timeout,
|
|
3070
|
+
endpointTimeout: AGENTIC_MODEL_TIMEOUT_MS
|
|
2964
3071
|
});
|
|
2965
3072
|
}
|
|
2966
3073
|
/**
|
|
@@ -3014,7 +3121,8 @@ var InstructionsResource = class extends BaseResource {
|
|
|
3014
3121
|
method: "POST",
|
|
3015
3122
|
path: "/instructions",
|
|
3016
3123
|
body: data,
|
|
3017
|
-
idempotencyKey: options?.idempotencyKey
|
|
3124
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3125
|
+
timeout: options?.timeout
|
|
3018
3126
|
});
|
|
3019
3127
|
}
|
|
3020
3128
|
/**
|
|
@@ -3075,7 +3183,8 @@ var MandatesResource = class extends BaseResource {
|
|
|
3075
3183
|
method: "POST",
|
|
3076
3184
|
path: "/mandates",
|
|
3077
3185
|
body: data,
|
|
3078
|
-
idempotencyKey: options?.idempotencyKey
|
|
3186
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3187
|
+
timeout: options?.timeout
|
|
3079
3188
|
});
|
|
3080
3189
|
}
|
|
3081
3190
|
/**
|
|
@@ -3093,7 +3202,8 @@ var MandatesResource = class extends BaseResource {
|
|
|
3093
3202
|
method: "POST",
|
|
3094
3203
|
path: `/mandates/${mandateId}/approve`,
|
|
3095
3204
|
body: data,
|
|
3096
|
-
idempotencyKey: options?.idempotencyKey
|
|
3205
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3206
|
+
timeout: options?.timeout
|
|
3097
3207
|
});
|
|
3098
3208
|
}
|
|
3099
3209
|
/**
|
|
@@ -3111,7 +3221,8 @@ var MandatesResource = class extends BaseResource {
|
|
|
3111
3221
|
method: "POST",
|
|
3112
3222
|
path: `/mandates/${mandateId}/cancel`,
|
|
3113
3223
|
body: data,
|
|
3114
|
-
idempotencyKey: options?.idempotencyKey
|
|
3224
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3225
|
+
timeout: options?.timeout
|
|
3115
3226
|
});
|
|
3116
3227
|
}
|
|
3117
3228
|
/**
|
|
@@ -3157,7 +3268,8 @@ var MandatesResource = class extends BaseResource {
|
|
|
3157
3268
|
method: "POST",
|
|
3158
3269
|
path: `/mandates/${mandateId}/amend`,
|
|
3159
3270
|
body: data,
|
|
3160
|
-
idempotencyKey: options?.idempotencyKey
|
|
3271
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3272
|
+
timeout: options?.timeout
|
|
3161
3273
|
});
|
|
3162
3274
|
}
|
|
3163
3275
|
/**
|
|
@@ -3243,7 +3355,8 @@ var ScheduledPaymentsResource = class extends BaseResource {
|
|
|
3243
3355
|
method: "POST",
|
|
3244
3356
|
path: "/scheduled-payments",
|
|
3245
3357
|
body: data,
|
|
3246
|
-
idempotencyKey: options?.idempotencyKey
|
|
3358
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3359
|
+
timeout: options?.timeout
|
|
3247
3360
|
});
|
|
3248
3361
|
}
|
|
3249
3362
|
/**
|
|
@@ -3259,7 +3372,8 @@ var ScheduledPaymentsResource = class extends BaseResource {
|
|
|
3259
3372
|
await this.transport.request({
|
|
3260
3373
|
method: "POST",
|
|
3261
3374
|
path: `/scheduled-payments/${scheduledPaymentId}/cancel`,
|
|
3262
|
-
idempotencyKey: options?.idempotencyKey
|
|
3375
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3376
|
+
timeout: options?.timeout
|
|
3263
3377
|
});
|
|
3264
3378
|
}
|
|
3265
3379
|
};
|
|
@@ -3295,6 +3409,10 @@ var InsightsResource = class extends BaseResource {
|
|
|
3295
3409
|
* never moves money. Rate-limited per customer (hourly burst + daily
|
|
3296
3410
|
* window) — a 429 means back off and retry later.
|
|
3297
3411
|
*
|
|
3412
|
+
* Model-backed, so it defaults to {@link AGENTIC_MODEL_TIMEOUT_MS} rather
|
|
3413
|
+
* than the client's ordinary deadline. Pass `{ timeout }` to change it for
|
|
3414
|
+
* one call; an explicit client-wide `timeout` still wins.
|
|
3415
|
+
*
|
|
3298
3416
|
* @param customerId - Customer ID
|
|
3299
3417
|
* @param data - The conversation so far (1–40 messages)
|
|
3300
3418
|
* @returns The assistant's reply (+ how the boundary screen treated the turn)
|
|
@@ -3304,7 +3422,9 @@ var InsightsResource = class extends BaseResource {
|
|
|
3304
3422
|
method: "POST",
|
|
3305
3423
|
path: `/customers/${customerId}/insights/chat`,
|
|
3306
3424
|
body: data,
|
|
3307
|
-
idempotencyKey: options?.idempotencyKey
|
|
3425
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3426
|
+
timeout: options?.timeout,
|
|
3427
|
+
endpointTimeout: AGENTIC_MODEL_TIMEOUT_MS
|
|
3308
3428
|
});
|
|
3309
3429
|
}
|
|
3310
3430
|
};
|
|
@@ -3314,11 +3434,13 @@ var AgentConversation = class {
|
|
|
3314
3434
|
client;
|
|
3315
3435
|
paymentAgentId;
|
|
3316
3436
|
timezone;
|
|
3437
|
+
timeout;
|
|
3317
3438
|
history = [];
|
|
3318
3439
|
constructor(client, paymentAgentId, history, options) {
|
|
3319
3440
|
this.client = client;
|
|
3320
3441
|
this.paymentAgentId = paymentAgentId;
|
|
3321
3442
|
this.timezone = options?.timezone;
|
|
3443
|
+
this.timeout = options?.timeout;
|
|
3322
3444
|
if (history && history.length > 0) {
|
|
3323
3445
|
this.history = history.map(cloneMessage);
|
|
3324
3446
|
}
|
|
@@ -3359,12 +3481,16 @@ var AgentConversation = class {
|
|
|
3359
3481
|
}
|
|
3360
3482
|
let result;
|
|
3361
3483
|
try {
|
|
3362
|
-
result = await this.client.paymentAgents.createProposals(
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3484
|
+
result = await this.client.paymentAgents.createProposals(
|
|
3485
|
+
this.paymentAgentId,
|
|
3486
|
+
{
|
|
3487
|
+
messages,
|
|
3488
|
+
// Resent on EVERY turn — the endpoint is stateless, so a zone given
|
|
3489
|
+
// once would be forgotten on the next one.
|
|
3490
|
+
...this.timezone ? { timezone: this.timezone } : {}
|
|
3491
|
+
},
|
|
3492
|
+
this.timeout !== void 0 ? { timeout: this.timeout } : void 0
|
|
3493
|
+
);
|
|
3368
3494
|
} catch (err) {
|
|
3369
3495
|
this.history.pop();
|
|
3370
3496
|
throw err;
|