@takeal/cusfront-sdk 0.8.4 → 0.9.0

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.md +46 -5
  3. package/dist/analytics.cjs +74 -22
  4. package/dist/analytics.cjs.map +1 -1
  5. package/dist/analytics.d.cts +43 -4
  6. package/dist/analytics.d.ts +43 -4
  7. package/dist/analytics.js +71 -23
  8. package/dist/analytics.js.map +1 -1
  9. package/dist/{cards-DwxkVJUB.d.cts → cards-C5rk0XkI.d.cts} +47 -5
  10. package/dist/{cards-VkS_2lPe.d.ts → cards-CS-oxqLS.d.ts} +47 -5
  11. package/dist/index.cjs +94 -26
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +13 -5
  14. package/dist/index.d.ts +13 -5
  15. package/dist/index.js +91 -27
  16. package/dist/index.js.map +1 -1
  17. package/dist/react/index.d.cts +1 -1
  18. package/dist/react/index.d.ts +1 -1
  19. package/dist/resources/auth.cjs.map +1 -1
  20. package/dist/resources/auth.d.cts +1 -1
  21. package/dist/resources/auth.d.ts +1 -1
  22. package/dist/resources/auth.js.map +1 -1
  23. package/dist/resources/branding.cjs.map +1 -1
  24. package/dist/resources/branding.d.cts +6 -0
  25. package/dist/resources/branding.d.ts +6 -0
  26. package/dist/resources/branding.js.map +1 -1
  27. package/dist/resources/cards.cjs.map +1 -1
  28. package/dist/resources/cards.d.cts +1 -1
  29. package/dist/resources/cards.d.ts +1 -1
  30. package/dist/resources/cards.js.map +1 -1
  31. package/dist/resources/deposits.cjs.map +1 -1
  32. package/dist/resources/deposits.d.cts +1 -1
  33. package/dist/resources/deposits.d.ts +1 -1
  34. package/dist/resources/deposits.js.map +1 -1
  35. package/dist/resources/funding-options.d.cts +1 -1
  36. package/dist/resources/funding-options.d.ts +1 -1
  37. package/dist/resources/me.d.cts +1 -1
  38. package/dist/resources/me.d.ts +1 -1
  39. package/dist/telegram.cjs +20 -4
  40. package/dist/telegram.cjs.map +1 -1
  41. package/dist/telegram.d.cts +1 -1
  42. package/dist/telegram.d.ts +1 -1
  43. package/dist/telegram.js +20 -4
  44. package/dist/telegram.js.map +1 -1
  45. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { CusfrontClient, CreateClientOptions } from './index.cjs';
2
2
  import { JwtIssued, TelegramUnknown } from './resources/auth.cjs';
3
3
  import './http-CL97TjMO.cjs';
4
- import './cards-DwxkVJUB.cjs';
4
+ import './cards-C5rk0XkI.cjs';
5
5
  import './resources/claims.cjs';
6
6
  import './resources/codes.cjs';
7
7
  import './resources/consents.cjs';
@@ -1,7 +1,7 @@
1
1
  import { CusfrontClient, CreateClientOptions } from './index.js';
2
2
  import { JwtIssued, TelegramUnknown } from './resources/auth.js';
3
3
  import './http-CL97TjMO.js';
4
- import './cards-VkS_2lPe.js';
4
+ import './cards-CS-oxqLS.js';
5
5
  import './resources/claims.js';
6
6
  import './resources/codes.js';
7
7
  import './resources/consents.js';
package/dist/telegram.js CHANGED
@@ -1,10 +1,11 @@
1
1
  // src/error.ts
2
2
  var ApiError = class extends Error {
3
- constructor(status, code, message, body) {
3
+ constructor(status, code, message, body, retryAfterSeconds) {
4
4
  super(message);
5
5
  this.status = status;
6
6
  this.code = code;
7
7
  this.body = body;
8
+ this.retryAfterSeconds = retryAfterSeconds;
8
9
  this.isApiError = true;
9
10
  this.name = "ApiError";
10
11
  }
@@ -136,11 +137,20 @@ async function parseResponse(resp) {
136
137
  resp.status,
137
138
  errBody.code ?? `http_${resp.status}`,
138
139
  errBody.message ?? resp.statusText ?? "request failed",
139
- body
140
+ body,
141
+ retryAfter(resp.headers?.get("Retry-After"))
140
142
  );
141
143
  }
142
144
  return body;
143
145
  }
146
+ function retryAfter(v, now = Date.now()) {
147
+ if (!v) return void 0;
148
+ const t = v.trim();
149
+ if (/^\d+$/.test(t)) return Number(t);
150
+ const at = Date.parse(t);
151
+ if (Number.isNaN(at)) return void 0;
152
+ return Math.max(0, Math.ceil((at - now) / 1e3));
153
+ }
144
154
 
145
155
  // src/resources/attribution.ts
146
156
  var AttributionResource = class {
@@ -1771,7 +1781,7 @@ var FundingOptionsResource = class {
1771
1781
  };
1772
1782
 
1773
1783
  // src/version.ts
1774
- var SDK_VERSION = "0.8.4";
1784
+ var SDK_VERSION = "0.9.0";
1775
1785
 
1776
1786
  // src/client-platform.ts
1777
1787
  var CLIENT_HEADER = "X-Takeal-Client";
@@ -1908,12 +1918,18 @@ function readyInfo(raw, healthy) {
1908
1918
  }
1909
1919
  return { ...base, compatible: true };
1910
1920
  }
1921
+ function isReadyBody(body) {
1922
+ if (typeof body !== "object" || body === null || Array.isArray(body)) return false;
1923
+ const b = body;
1924
+ const block = (v) => typeof v === "object" && v !== null;
1925
+ return b.code !== "service_unavailable" && typeof b.status === "string" && (block(b.checks) || block(b.ops));
1926
+ }
1911
1927
  async function fetchReady(http, opts = {}) {
1912
1928
  try {
1913
1929
  const body = await http.get("/ready", { skipAuth: true, signal: opts.signal });
1914
1930
  return readyInfo(body ?? {}, true);
1915
1931
  } catch (e) {
1916
- if (isApiError(e) && e.status === 503 && typeof e.body === "object" && e.body !== null) {
1932
+ if (isApiError(e) && e.status === 503 && isReadyBody(e.body)) {
1917
1933
  return readyInfo(e.body, false);
1918
1934
  }
1919
1935
  throw e;