@takeal/cusfront-sdk 0.3.20 → 0.6.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 (133) hide show
  1. package/CHANGELOG.md +137 -2
  2. package/README.md +407 -8
  3. package/dist/analytics.cjs +438 -0
  4. package/dist/analytics.cjs.map +1 -0
  5. package/dist/analytics.d.cts +129 -0
  6. package/dist/analytics.d.ts +129 -0
  7. package/dist/analytics.js +424 -0
  8. package/dist/analytics.js.map +1 -0
  9. package/dist/cards-B_aNY35J.d.cts +514 -0
  10. package/dist/cards-Ba1wZttb.d.ts +514 -0
  11. package/dist/deposits-BEc8U80M.d.cts +310 -0
  12. package/dist/deposits-DScyT_D9.d.ts +310 -0
  13. package/dist/{devices-DP_hxwmW.d.ts → devices-B_YveTl9.d.ts} +1 -1
  14. package/dist/{devices-C3JHi2Hi.d.cts → devices-a5Z45Mx_.d.cts} +1 -1
  15. package/dist/{http-B-OQwMYn.d.cts → http-DeANAoTs.d.cts} +11 -3
  16. package/dist/{http-B-OQwMYn.d.ts → http-DeANAoTs.d.ts} +11 -3
  17. package/dist/index.cjs +978 -101
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +101 -13
  20. package/dist/index.d.ts +101 -13
  21. package/dist/index.js +963 -102
  22. package/dist/index.js.map +1 -1
  23. package/dist/react/index.cjs +2 -8
  24. package/dist/react/index.cjs.map +1 -1
  25. package/dist/react/index.d.cts +12 -5
  26. package/dist/react/index.d.ts +12 -5
  27. package/dist/react/index.js +2 -8
  28. package/dist/react/index.js.map +1 -1
  29. package/dist/resources/attribution.cjs +82 -0
  30. package/dist/resources/attribution.cjs.map +1 -0
  31. package/dist/resources/attribution.d.cts +100 -0
  32. package/dist/resources/attribution.d.ts +100 -0
  33. package/dist/resources/attribution.js +78 -0
  34. package/dist/resources/attribution.js.map +1 -0
  35. package/dist/resources/auth.cjs +81 -15
  36. package/dist/resources/auth.cjs.map +1 -1
  37. package/dist/resources/auth.d.cts +53 -6
  38. package/dist/resources/auth.d.ts +53 -6
  39. package/dist/resources/auth.js +81 -15
  40. package/dist/resources/auth.js.map +1 -1
  41. package/dist/resources/balance.d.cts +1 -1
  42. package/dist/resources/balance.d.ts +1 -1
  43. package/dist/resources/blog.cjs.map +1 -1
  44. package/dist/resources/blog.d.cts +8 -1
  45. package/dist/resources/blog.d.ts +8 -1
  46. package/dist/resources/blog.js.map +1 -1
  47. package/dist/resources/bonus.cjs +28 -0
  48. package/dist/resources/bonus.cjs.map +1 -0
  49. package/dist/resources/bonus.d.cts +121 -0
  50. package/dist/resources/bonus.d.ts +121 -0
  51. package/dist/resources/bonus.js +26 -0
  52. package/dist/resources/bonus.js.map +1 -0
  53. package/dist/resources/branding.d.cts +1 -1
  54. package/dist/resources/branding.d.ts +1 -1
  55. package/dist/resources/cards.cjs +55 -28
  56. package/dist/resources/cards.cjs.map +1 -1
  57. package/dist/resources/cards.d.cts +2 -347
  58. package/dist/resources/cards.d.ts +2 -347
  59. package/dist/resources/cards.js +55 -29
  60. package/dist/resources/cards.js.map +1 -1
  61. package/dist/resources/codes.cjs +20 -0
  62. package/dist/resources/codes.cjs.map +1 -0
  63. package/dist/resources/codes.d.cts +100 -0
  64. package/dist/resources/codes.d.ts +100 -0
  65. package/dist/resources/codes.js +18 -0
  66. package/dist/resources/codes.js.map +1 -0
  67. package/dist/resources/deposits.cjs +32 -7
  68. package/dist/resources/deposits.cjs.map +1 -1
  69. package/dist/resources/deposits.d.cts +3 -176
  70. package/dist/resources/deposits.d.ts +3 -176
  71. package/dist/resources/deposits.js +32 -7
  72. package/dist/resources/deposits.js.map +1 -1
  73. package/dist/resources/devices.cjs +3 -1
  74. package/dist/resources/devices.cjs.map +1 -1
  75. package/dist/resources/devices.d.cts +2 -2
  76. package/dist/resources/devices.d.ts +2 -2
  77. package/dist/resources/devices.js +3 -1
  78. package/dist/resources/devices.js.map +1 -1
  79. package/dist/resources/documents.cjs +66 -0
  80. package/dist/resources/documents.cjs.map +1 -0
  81. package/dist/resources/documents.d.cts +212 -0
  82. package/dist/resources/documents.d.ts +212 -0
  83. package/dist/resources/documents.js +64 -0
  84. package/dist/resources/documents.js.map +1 -0
  85. package/dist/resources/funding-options.cjs +16 -0
  86. package/dist/resources/funding-options.cjs.map +1 -0
  87. package/dist/resources/funding-options.d.cts +3 -0
  88. package/dist/resources/funding-options.d.ts +3 -0
  89. package/dist/resources/funding-options.js +14 -0
  90. package/dist/resources/funding-options.js.map +1 -0
  91. package/dist/resources/history.cjs +33 -0
  92. package/dist/resources/history.cjs.map +1 -0
  93. package/dist/resources/history.d.cts +95 -0
  94. package/dist/resources/history.d.ts +95 -0
  95. package/dist/resources/history.js +31 -0
  96. package/dist/resources/history.js.map +1 -0
  97. package/dist/resources/me.d.cts +3 -1
  98. package/dist/resources/me.d.ts +3 -1
  99. package/dist/resources/notifications.d.cts +1 -1
  100. package/dist/resources/notifications.d.ts +1 -1
  101. package/dist/resources/push.cjs +3 -1
  102. package/dist/resources/push.cjs.map +1 -1
  103. package/dist/resources/push.d.cts +1 -1
  104. package/dist/resources/push.d.ts +1 -1
  105. package/dist/resources/push.js +3 -1
  106. package/dist/resources/push.js.map +1 -1
  107. package/dist/resources/referral.cjs +16 -0
  108. package/dist/resources/referral.cjs.map +1 -0
  109. package/dist/resources/referral.d.cts +58 -0
  110. package/dist/resources/referral.d.ts +58 -0
  111. package/dist/resources/referral.js +14 -0
  112. package/dist/resources/referral.js.map +1 -0
  113. package/dist/resources/sessions.d.cts +1 -1
  114. package/dist/resources/sessions.d.ts +1 -1
  115. package/dist/resources/subscription.cjs +24 -0
  116. package/dist/resources/subscription.cjs.map +1 -0
  117. package/dist/resources/subscription.d.cts +48 -0
  118. package/dist/resources/subscription.d.ts +48 -0
  119. package/dist/resources/subscription.js +22 -0
  120. package/dist/resources/subscription.js.map +1 -0
  121. package/dist/resources/subscriptions.d.cts +1 -1
  122. package/dist/resources/subscriptions.d.ts +1 -1
  123. package/dist/resources/wallet.d.cts +1 -1
  124. package/dist/resources/wallet.d.ts +1 -1
  125. package/dist/telegram.cjs +495 -111
  126. package/dist/telegram.cjs.map +1 -1
  127. package/dist/telegram.d.cts +12 -5
  128. package/dist/telegram.d.ts +12 -5
  129. package/dist/telegram.js +495 -111
  130. package/dist/telegram.js.map +1 -1
  131. package/package.json +57 -5
  132. package/dist/customer-CoxPwe5o.d.cts +0 -32
  133. package/dist/customer-CoxPwe5o.d.ts +0 -32
@@ -0,0 +1,100 @@
1
+ import { H as HttpClient } from '../http-DeANAoTs.cjs';
2
+
3
+ /**
4
+ * Codes resource — `client.codes.*`.
5
+ *
6
+ * Promo and referral codes. A code is used on the operation itself:
7
+ * `code` on `auth.register` / `auth.exchangeTelegram`, `promo_code` on
8
+ * `deposits.initiate`, `promoCode` on `cards.create`, and
9
+ * `client.subscription.setPromoCode` for the monthly fee.
10
+ * {@link CodesResource.validate} checks one first and says what it would do,
11
+ * without using it up.
12
+ *
13
+ * What a code gives besides a discount (bonuses, a gift subscription) comes
14
+ * once the operation goes through. Bonuses are a discount on our services,
15
+ * never money: show them as a number of bonuses.
16
+ *
17
+ * Mirrors `POST /me/codes/validate`.
18
+ */
19
+ /** The operations a code can be used on. */
20
+ type CodeOperation = "signup" | "deposit" | "card_issuance" | "subscription";
21
+ /** Why a code can't be used. Show `message` from the response as is. */
22
+ type CodeRejection = "unknown" | "disabled" | "not_started" | "expired" | "not_applicable" | "exhausted" | "already_used" | "not_first_operation" | "below_minimum" | "currency_mismatch" | "own_code" | "already_registered" | (string & {});
23
+ /** What one effect of a code did, as a sign-up reports it. */
24
+ interface CodeEffectOutcome {
25
+ /** `bonus_credit`, `gift_subscription`, `grant_referral_code` or `referral_link`. */
26
+ kind: string;
27
+ /** `applied`, `skipped` (a gift when a subscription was already running) or `failed`. */
28
+ status: "applied" | "skipped" | "failed" | (string & {});
29
+ reason?: string;
30
+ /** Details by kind: `units` for bonuses, `tier` and `until` for a gift, `code` for a referral code of one's own. */
31
+ [detail: string]: unknown;
32
+ }
33
+ /** What the code sent with a sign-up did. The account is created either way. */
34
+ interface CodeResult {
35
+ code: string;
36
+ status: "applied" | "rejected";
37
+ reason: CodeRejection | null;
38
+ /** A sentence to show when the code was not applied. */
39
+ message: string | null;
40
+ effects: CodeEffectOutcome[];
41
+ }
42
+ /** One effect a code carries, as `validate` lists it. */
43
+ type CodeEffect = {
44
+ kind: "gift_subscription";
45
+ tier_id: string;
46
+ days: number | null;
47
+ } | {
48
+ kind: "bonus_credit";
49
+ amount: string;
50
+ } | {
51
+ kind: "grant_referral_code";
52
+ program_id: string;
53
+ } | {
54
+ kind: string;
55
+ [k: string]: unknown;
56
+ };
57
+ interface CodeDiscount {
58
+ kind: "percent" | "fixed";
59
+ /** For `percent`: basis points off (1000 = 10%). */
60
+ bps: number | null;
61
+ /** For `fixed`: the amount off, decimal string. */
62
+ amount: string | null;
63
+ currency: string | null;
64
+ /** What comes off: `card_issuance`, `funding_commission` (the top-up commission) or `subscription`. */
65
+ applies_to: "card_issuance" | "funding_commission" | "subscription" | null;
66
+ }
67
+ interface ValidateCodeInput {
68
+ code: string;
69
+ operation: CodeOperation;
70
+ /** The operation's amount, decimal string: needed for a code with a minimum or a fixed discount. */
71
+ amount?: string;
72
+ /** ISO 4217 code of `amount`; for a top-up, the currency it is credited in. */
73
+ currency?: string;
74
+ }
75
+ /** `POST /me/codes/validate`. */
76
+ interface CodeCheck {
77
+ valid: boolean;
78
+ code: string | null;
79
+ /** `promo` or `referral`. */
80
+ kind: string | null;
81
+ reason: CodeRejection | null;
82
+ message: string | null;
83
+ discount: CodeDiscount | null;
84
+ /** For a card or the monthly fee with `amount` sent: what comes off it. */
85
+ discount_value: string | null;
86
+ /** Everything else the code gives, once the operation goes through. */
87
+ effects: CodeEffect[];
88
+ }
89
+ declare class CodesResource {
90
+ private readonly http;
91
+ constructor(http: HttpClient);
92
+ /**
93
+ * Whether a code can be used on an operation now and what it would do.
94
+ * Nothing is used up. For sign-up there is nothing to check here: send
95
+ * the code with `auth.register` and read `code_result`.
96
+ */
97
+ validate(input: ValidateCodeInput): Promise<CodeCheck>;
98
+ }
99
+
100
+ export { type CodeCheck, type CodeDiscount, type CodeEffect, type CodeEffectOutcome, type CodeOperation, type CodeRejection, type CodeResult, CodesResource, type ValidateCodeInput };
@@ -0,0 +1,100 @@
1
+ import { H as HttpClient } from '../http-DeANAoTs.js';
2
+
3
+ /**
4
+ * Codes resource — `client.codes.*`.
5
+ *
6
+ * Promo and referral codes. A code is used on the operation itself:
7
+ * `code` on `auth.register` / `auth.exchangeTelegram`, `promo_code` on
8
+ * `deposits.initiate`, `promoCode` on `cards.create`, and
9
+ * `client.subscription.setPromoCode` for the monthly fee.
10
+ * {@link CodesResource.validate} checks one first and says what it would do,
11
+ * without using it up.
12
+ *
13
+ * What a code gives besides a discount (bonuses, a gift subscription) comes
14
+ * once the operation goes through. Bonuses are a discount on our services,
15
+ * never money: show them as a number of bonuses.
16
+ *
17
+ * Mirrors `POST /me/codes/validate`.
18
+ */
19
+ /** The operations a code can be used on. */
20
+ type CodeOperation = "signup" | "deposit" | "card_issuance" | "subscription";
21
+ /** Why a code can't be used. Show `message` from the response as is. */
22
+ type CodeRejection = "unknown" | "disabled" | "not_started" | "expired" | "not_applicable" | "exhausted" | "already_used" | "not_first_operation" | "below_minimum" | "currency_mismatch" | "own_code" | "already_registered" | (string & {});
23
+ /** What one effect of a code did, as a sign-up reports it. */
24
+ interface CodeEffectOutcome {
25
+ /** `bonus_credit`, `gift_subscription`, `grant_referral_code` or `referral_link`. */
26
+ kind: string;
27
+ /** `applied`, `skipped` (a gift when a subscription was already running) or `failed`. */
28
+ status: "applied" | "skipped" | "failed" | (string & {});
29
+ reason?: string;
30
+ /** Details by kind: `units` for bonuses, `tier` and `until` for a gift, `code` for a referral code of one's own. */
31
+ [detail: string]: unknown;
32
+ }
33
+ /** What the code sent with a sign-up did. The account is created either way. */
34
+ interface CodeResult {
35
+ code: string;
36
+ status: "applied" | "rejected";
37
+ reason: CodeRejection | null;
38
+ /** A sentence to show when the code was not applied. */
39
+ message: string | null;
40
+ effects: CodeEffectOutcome[];
41
+ }
42
+ /** One effect a code carries, as `validate` lists it. */
43
+ type CodeEffect = {
44
+ kind: "gift_subscription";
45
+ tier_id: string;
46
+ days: number | null;
47
+ } | {
48
+ kind: "bonus_credit";
49
+ amount: string;
50
+ } | {
51
+ kind: "grant_referral_code";
52
+ program_id: string;
53
+ } | {
54
+ kind: string;
55
+ [k: string]: unknown;
56
+ };
57
+ interface CodeDiscount {
58
+ kind: "percent" | "fixed";
59
+ /** For `percent`: basis points off (1000 = 10%). */
60
+ bps: number | null;
61
+ /** For `fixed`: the amount off, decimal string. */
62
+ amount: string | null;
63
+ currency: string | null;
64
+ /** What comes off: `card_issuance`, `funding_commission` (the top-up commission) or `subscription`. */
65
+ applies_to: "card_issuance" | "funding_commission" | "subscription" | null;
66
+ }
67
+ interface ValidateCodeInput {
68
+ code: string;
69
+ operation: CodeOperation;
70
+ /** The operation's amount, decimal string: needed for a code with a minimum or a fixed discount. */
71
+ amount?: string;
72
+ /** ISO 4217 code of `amount`; for a top-up, the currency it is credited in. */
73
+ currency?: string;
74
+ }
75
+ /** `POST /me/codes/validate`. */
76
+ interface CodeCheck {
77
+ valid: boolean;
78
+ code: string | null;
79
+ /** `promo` or `referral`. */
80
+ kind: string | null;
81
+ reason: CodeRejection | null;
82
+ message: string | null;
83
+ discount: CodeDiscount | null;
84
+ /** For a card or the monthly fee with `amount` sent: what comes off it. */
85
+ discount_value: string | null;
86
+ /** Everything else the code gives, once the operation goes through. */
87
+ effects: CodeEffect[];
88
+ }
89
+ declare class CodesResource {
90
+ private readonly http;
91
+ constructor(http: HttpClient);
92
+ /**
93
+ * Whether a code can be used on an operation now and what it would do.
94
+ * Nothing is used up. For sign-up there is nothing to check here: send
95
+ * the code with `auth.register` and read `code_result`.
96
+ */
97
+ validate(input: ValidateCodeInput): Promise<CodeCheck>;
98
+ }
99
+
100
+ export { type CodeCheck, type CodeDiscount, type CodeEffect, type CodeEffectOutcome, type CodeOperation, type CodeRejection, type CodeResult, CodesResource, type ValidateCodeInput };
@@ -0,0 +1,18 @@
1
+ // src/resources/codes.ts
2
+ var CodesResource = class {
3
+ constructor(http) {
4
+ this.http = http;
5
+ }
6
+ /**
7
+ * Whether a code can be used on an operation now and what it would do.
8
+ * Nothing is used up. For sign-up there is nothing to check here: send
9
+ * the code with `auth.register` and read `code_result`.
10
+ */
11
+ async validate(input) {
12
+ return this.http.post("/me/codes/validate", { body: input });
13
+ }
14
+ };
15
+
16
+ export { CodesResource };
17
+ //# sourceMappingURL=codes.js.map
18
+ //# sourceMappingURL=codes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/resources/codes.ts"],"names":[],"mappings":";AAqGO,IAAM,gBAAN,MAAoB;AAAA,EACzB,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhD,MAAM,SAAS,KAAA,EAA8C;AAC3D,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA,CAAgB,sBAAsB,EAAE,IAAA,EAAM,OAAO,CAAA;AAAA,EACxE;AACF","file":"codes.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Codes resource — `client.codes.*`.\n *\n * Promo and referral codes. A code is used on the operation itself:\n * `code` on `auth.register` / `auth.exchangeTelegram`, `promo_code` on\n * `deposits.initiate`, `promoCode` on `cards.create`, and\n * `client.subscription.setPromoCode` for the monthly fee.\n * {@link CodesResource.validate} checks one first and says what it would do,\n * without using it up.\n *\n * What a code gives besides a discount (bonuses, a gift subscription) comes\n * once the operation goes through. Bonuses are a discount on our services,\n * never money: show them as a number of bonuses.\n *\n * Mirrors `POST /me/codes/validate`.\n */\n\n/** The operations a code can be used on. */\nexport type CodeOperation = \"signup\" | \"deposit\" | \"card_issuance\" | \"subscription\";\n\n/** Why a code can't be used. Show `message` from the response as is. */\nexport type CodeRejection =\n | \"unknown\"\n | \"disabled\"\n | \"not_started\"\n | \"expired\"\n | \"not_applicable\"\n | \"exhausted\"\n | \"already_used\"\n | \"not_first_operation\"\n | \"below_minimum\"\n | \"currency_mismatch\"\n | \"own_code\"\n | \"already_registered\"\n | (string & {});\n\n/** What one effect of a code did, as a sign-up reports it. */\nexport interface CodeEffectOutcome {\n /** `bonus_credit`, `gift_subscription`, `grant_referral_code` or `referral_link`. */\n kind: string;\n /** `applied`, `skipped` (a gift when a subscription was already running) or `failed`. */\n status: \"applied\" | \"skipped\" | \"failed\" | (string & {});\n reason?: string;\n /** Details by kind: `units` for bonuses, `tier` and `until` for a gift, `code` for a referral code of one's own. */\n [detail: string]: unknown;\n}\n\n/** What the code sent with a sign-up did. The account is created either way. */\nexport interface CodeResult {\n code: string;\n status: \"applied\" | \"rejected\";\n reason: CodeRejection | null;\n /** A sentence to show when the code was not applied. */\n message: string | null;\n effects: CodeEffectOutcome[];\n}\n\n/** One effect a code carries, as `validate` lists it. */\nexport type CodeEffect =\n | { kind: \"gift_subscription\"; tier_id: string; days: number | null }\n | { kind: \"bonus_credit\"; amount: string }\n | { kind: \"grant_referral_code\"; program_id: string }\n | { kind: string; [k: string]: unknown };\n\nexport interface CodeDiscount {\n kind: \"percent\" | \"fixed\";\n /** For `percent`: basis points off (1000 = 10%). */\n bps: number | null;\n /** For `fixed`: the amount off, decimal string. */\n amount: string | null;\n currency: string | null;\n /** What comes off: `card_issuance`, `funding_commission` (the top-up commission) or `subscription`. */\n applies_to: \"card_issuance\" | \"funding_commission\" | \"subscription\" | null;\n}\n\nexport interface ValidateCodeInput {\n code: string;\n operation: CodeOperation;\n /** The operation's amount, decimal string: needed for a code with a minimum or a fixed discount. */\n amount?: string;\n /** ISO 4217 code of `amount`; for a top-up, the currency it is credited in. */\n currency?: string;\n}\n\n/** `POST /me/codes/validate`. */\nexport interface CodeCheck {\n valid: boolean;\n code: string | null;\n /** `promo` or `referral`. */\n kind: string | null;\n reason: CodeRejection | null;\n message: string | null;\n discount: CodeDiscount | null;\n /** For a card or the monthly fee with `amount` sent: what comes off it. */\n discount_value: string | null;\n /** Everything else the code gives, once the operation goes through. */\n effects: CodeEffect[];\n}\n\nexport class CodesResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Whether a code can be used on an operation now and what it would do.\n * Nothing is used up. For sign-up there is nothing to check here: send\n * the code with `auth.register` and read `code_result`.\n */\n async validate(input: ValidateCodeInput): Promise<CodeCheck> {\n return this.http.post<CodeCheck>(\"/me/codes/validate\", { body: input });\n }\n}\n"]}
@@ -1,5 +1,27 @@
1
1
  'use strict';
2
2
 
3
+ // src/resources/cards.ts
4
+ function cardRequestBody(input) {
5
+ const {
6
+ productId,
7
+ name,
8
+ designId,
9
+ useBonus,
10
+ bonusAmount,
11
+ promoCode,
12
+ initial_amount: _ignored,
13
+ ...rest
14
+ } = input;
15
+ const body = { ...rest };
16
+ if (productId !== void 0) body["product_id"] = productId;
17
+ if (name !== void 0) body["name"] = name;
18
+ if (designId !== void 0) body["design_id"] = designId;
19
+ if (useBonus !== void 0) body["use_bonus"] = useBonus;
20
+ if (bonusAmount !== void 0) body["bonus_amount"] = bonusAmount;
21
+ if (promoCode !== void 0) body["promo_code"] = promoCode;
22
+ return body;
23
+ }
24
+
3
25
  // src/resources/deposits.ts
4
26
  var DepositsResource = class {
5
27
  constructor(http) {
@@ -12,14 +34,17 @@ var DepositsResource = class {
12
34
  */
13
35
  /**
14
36
  * Price a cross-currency deposit BEFORE paying. The rate is locked
15
- * server-side until `expires_at`; deposits in the local currency need no
16
- * quote (the API answers 400 `no_quote_needed`).
37
+ * server-side until `expires_at`; deposits already in the currency they
38
+ * credit (the wallet's, or the card's with `card_id`) need no quote (the
39
+ * API answers 400 `no_quote_needed`).
17
40
  */
18
41
  async quote(input) {
19
42
  return this.http.post("/me/deposits/quotes", { body: input });
20
43
  }
21
44
  async initiate(input) {
22
- const { idempotencyKey, ...body } = input;
45
+ const { idempotencyKey, issue_card, ...rest } = input;
46
+ const body = { ...rest };
47
+ if (issue_card !== void 0) body["issue_card"] = cardRequestBody(issue_card);
23
48
  return this.http.post("/me/deposits", {
24
49
  body,
25
50
  idempotencyKey
@@ -40,10 +65,10 @@ var DepositsResource = class {
40
65
  */
41
66
  async refund(depositId, input) {
42
67
  const { idempotencyKey, ...body } = input;
43
- return this.http.post(
44
- `/me/deposits/${encodeURIComponent(depositId)}/refunds`,
45
- { body, idempotencyKey }
46
- );
68
+ return this.http.post(`/me/deposits/${encodeURIComponent(depositId)}/refunds`, {
69
+ body,
70
+ idempotencyKey
71
+ });
47
72
  }
48
73
  };
49
74
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/resources/deposits.ts"],"names":[],"mappings":";;;AAiKO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYhD,MAAM,MAAM,KAAA,EAAgD;AAC1D,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA,CAAmB,uBAAuB,EAAE,IAAA,EAAM,OAAO,CAAA;AAAA,EAC5E;AAAA,EAEA,MAAM,SAAS,KAAA,EAA+C;AAC5D,IAAA,MAAM,EAAE,cAAA,EAAgB,GAAG,IAAA,EAAK,GAAI,KAAA;AACpC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAc,cAAA,EAAgB;AAAA,MAC7C,IAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,IAAI,EAAA,EAA8B;AACtC,IAAA,OAAO,KAAK,IAAA,CAAK,GAAA,CAAa,gBAAgB,kBAAA,CAAmB,EAAE,CAAC,CAAA,CAAE,CAAA;AAAA,EACxE;AAAA;AAAA,EAGA,MAAM,IAAA,GAA2B;AAC/B,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAe,cAAc,CAAA;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,MAAA,CACJ,SAAA,EACA,KAAA,EACiB;AACjB,IAAA,MAAM,EAAE,cAAA,EAAgB,GAAG,IAAA,EAAK,GAAI,KAAA;AACpC,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA;AAAA,MACf,CAAA,aAAA,EAAgB,kBAAA,CAAmB,SAAS,CAAC,CAAA,QAAA,CAAA;AAAA,MAC7C,EAAE,MAAM,cAAA;AAAe,KACzB;AAAA,EACF;AACF","file":"deposits.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\nimport type { CustomerInfo } from \"../types/customer.js\";\n\n/**\n * Deposits resource — `client.deposits.*`.\n *\n * The \"money IN\" surface: an end user tops up their wallet balance via a\n * funder connector. Mirrors the Takeal API's `/me/deposits` routes:\n *\n * POST /me/deposits → initiate\n * GET /me/deposits → list (most recent first)\n * GET /me/deposits/{id} → get\n * POST /me/deposits/{id}/refunds → refund\n *\n * A deposit is rarely terminal on the initiate call: real PSPs return\n * `redirect_required` (3DS / APM redirect) and flip to `confirmed` later via\n * a connector → Takeal API inbound event. Poll `get(id)` or watch the user's\n * webhook stream for the `deposit.confirmed` / `deposit.failed` outcome.\n */\n\n/** Lifecycle of a deposit. `redirect_required` carries `redirect_url`. */\nexport type DepositStatus =\n | \"pending\"\n | \"redirect_required\"\n | \"confirmed\"\n | \"failed\";\n\n/** Top-up rail. The chosen funder decides which it supports. */\nexport type DepositMethod = \"card\" | \"crypto\" | \"bank_transfer\";\n\n/**\n * A deposit record as the Takeal API returns it. Mirrors the `deposits` table; the\n * server-side `id` is the stable handle the SDK polls against. `idempotency_key`\n * and `request_fingerprint` are server-internal and never serialised.\n */\n/** Input for `quote()` — price a cross-currency deposit before paying. */\nexport interface CreateQuoteInput {\n /** Decimal string, e.g. `\"5000.00\"`. */\n amount: string;\n /** ISO 4217 source currency — must differ from the wallet's local currency. */\n currency: string;\n}\n\n/**\n * A rate-locked funding quote: pay `source_amount source_currency`, the\n * wallet is credited `credited_amount credited_currency` (net of the\n * platform's conversion spread). Execute by passing `id` as `quote_id` to\n * `initiate()` before `expires_at`; after that the API returns 409 and a new\n * quote is needed.\n */\nexport interface FundingQuote {\n id: string;\n source_amount: string;\n source_currency: string;\n credited_amount: string;\n credited_currency: string;\n /** Provider rate before spread (credited units per 1 source unit). */\n rate: string;\n spread_bps: number;\n provider: string;\n expires_at: string;\n}\n\nexport interface Deposit {\n id: string;\n user_id: string;\n /** Slug of the funder that handled this deposit, as configured by the deployment. */\n connector_slug: string;\n /** The connector's own reference, populated once it responds. */\n provider_reference: string | null;\n status: DepositStatus;\n /** Decimal serialised as a string to avoid float drift. */\n amount: string;\n currency: string;\n method: DepositMethod;\n /** Present when `status === \"redirect_required\"` — send the user here. */\n redirect_url: string | null;\n failure_reason: string | null;\n /** Final settled amount once confirmed (may differ from `amount` on FX). */\n confirmed_amount: string | null;\n confirmed_at: string | null;\n /** Set on cross-currency deposits: the quote this deposit executed against. */\n quote_id?: string | null;\n /** Locked provider rate (credited units per 1 source unit). */\n fx_rate?: string | null;\n fx_spread_bps?: number | null;\n /** The wallet's local currency the deposit converted into. */\n credited_currency?: string | null;\n /** What the wallet was actually credited, net of spread. */\n credited_amount?: string | null;\n created_at: string;\n updated_at: string;\n}\n\nexport interface InitiateDepositInput {\n /** Decimal as a string (`\"100.00\"`) — avoids float-precision loss on the wire. */\n amount: string;\n /** ISO 4217 code, e.g. `\"USD\"`. */\n currency: string;\n method: DepositMethod;\n /**\n * Optional. Slug of a specific funder to route through. Omit to\n * let the Takeal API pick the first active funder. Unknown slug → 400; empty\n * funder list → 503.\n */\n funder_slug?: string;\n /**\n * Passed to the funding connector and stored with the deposit. Two keys\n * work across connectors: `return_url`, where the provider sends the user\n * back after a 3-D Secure step (pair it with `redirect_required`), and on\n * test deployments with the mock funder `mock_scenario`, which picks the\n * outcome: `happy` (confirmed at once, the default), `pending` (confirmed\n * about 15 s later), `redirect` (a hosted page where the user approves or\n * declines) or `fail`.\n */\n metadata?: Record<string, string>;\n /** Structured billing details — real PSPs require these for 3DS / compliance. */\n customer?: CustomerInfo;\n /**\n * Required by the Takeal API on this write endpoint. Same key + body replays the\n * original deposit; same key + different body returns 409. Supply a stable\n * UUID per logical attempt so a retried network call is safe.\n */\n idempotencyKey: string;\n /**\n * Required when `currency` differs from the wallet's local currency: a\n * fresh quote id from `quote()`. Cross-currency deposits without one are\n * rejected with 400; expired quotes with 409.\n */\n quote_id?: string;\n}\n\nexport interface CreateDepositRefundInput {\n /** Omit for a full refund of the original confirmed amount; same currency. */\n amount?: string;\n /** Human-readable reason, e.g. `\"customer_request\"`. */\n reason?: string;\n metadata?: Record<string, string>;\n /** Required. Replays are keyed on this. */\n idempotencyKey: string;\n}\n\n/** A refund row as the Takeal API returns it (`refunds` table, deposit-targeted). */\nexport interface Refund {\n id: string;\n target_type: string;\n deposit_id?: string;\n payment_id?: string;\n connector_slug: string;\n amount: string;\n currency: string;\n reason: string;\n status: string;\n provider_refund_reference?: string;\n failure_reason?: string;\n requestor_type: string;\n requestor_id: string;\n created_at: string;\n updated_at: string;\n}\n\nexport class DepositsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Initiate a top-up. Resolves to the freshly-created `Deposit`, whose\n * `status` may already be `confirmed` (synchronous rails / mock) or\n * `redirect_required` (3DS / APM — forward the user to `redirect_url`).\n */\n /**\n * Price a cross-currency deposit BEFORE paying. The rate is locked\n * server-side until `expires_at`; deposits in the local currency need no\n * quote (the API answers 400 `no_quote_needed`).\n */\n async quote(input: CreateQuoteInput): Promise<FundingQuote> {\n return this.http.post<FundingQuote>(\"/me/deposits/quotes\", { body: input });\n }\n\n async initiate(input: InitiateDepositInput): Promise<Deposit> {\n const { idempotencyKey, ...body } = input;\n return this.http.post<Deposit>(\"/me/deposits\", {\n body,\n idempotencyKey,\n });\n }\n\n /** Fetch one deposit by id — the poll target while a redirect resolves. */\n async get(id: string): Promise<Deposit> {\n return this.http.get<Deposit>(`/me/deposits/${encodeURIComponent(id)}`);\n }\n\n /** List the caller's deposits, most recent first. */\n async list(): Promise<Deposit[]> {\n return this.http.get<Deposit[]>(\"/me/deposits\");\n }\n\n /**\n * Refund a previously-confirmed deposit. Synchronous when the\n * connector settles inline; otherwise the row stays `pending` and flips\n * later via the inbound `deposit.refunded` event.\n */\n async refund(\n depositId: string,\n input: CreateDepositRefundInput,\n ): Promise<Refund> {\n const { idempotencyKey, ...body } = input;\n return this.http.post<Refund>(\n `/me/deposits/${encodeURIComponent(depositId)}/refunds`,\n { body, idempotencyKey },\n );\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/resources/cards.ts","../../src/resources/deposits.ts"],"names":[],"mappings":";;;AAqPO,SAAS,gBACd,KAAA,EACyB;AACzB,EAAA,MAAM;AAAA,IACJ,SAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,SAAA;AAAA,IACA,cAAA,EAAgB,QAAA;AAAA,IAChB,GAAG;AAAA,GACL,GAAI,KAAA;AACJ,EAAA,MAAM,IAAA,GAAgC,EAAE,GAAG,IAAA,EAAK;AAChD,EAAA,IAAI,SAAA,KAAc,MAAA,EAAW,IAAA,CAAK,YAAY,CAAA,GAAI,SAAA;AAClD,EAAA,IAAI,IAAA,KAAS,MAAA,EAAW,IAAA,CAAK,MAAM,CAAA,GAAI,IAAA;AACvC,EAAA,IAAI,QAAA,KAAa,MAAA,EAAW,IAAA,CAAK,WAAW,CAAA,GAAI,QAAA;AAChD,EAAA,IAAI,QAAA,KAAa,MAAA,EAAW,IAAA,CAAK,WAAW,CAAA,GAAI,QAAA;AAChD,EAAA,IAAI,WAAA,KAAgB,MAAA,EAAW,IAAA,CAAK,cAAc,CAAA,GAAI,WAAA;AACtD,EAAA,IAAI,SAAA,KAAc,MAAA,EAAW,IAAA,CAAK,YAAY,CAAA,GAAI,SAAA;AAClD,EAAA,OAAO,IAAA;AACT;;;ACZO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAahD,MAAM,MAAM,KAAA,EAAgD;AAC1D,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA,CAAmB,uBAAuB,EAAE,IAAA,EAAM,OAAO,CAAA;AAAA,EAC5E;AAAA,EAEA,MAAM,SAAS,KAAA,EAA+C;AAC5D,IAAA,MAAM,EAAE,cAAA,EAAgB,UAAA,EAAY,GAAG,MAAK,GAAI,KAAA;AAChD,IAAA,MAAM,IAAA,GAAgC,EAAE,GAAG,IAAA,EAAK;AAChD,IAAA,IAAI,eAAe,MAAA,EAAW,IAAA,CAAK,YAAY,CAAA,GAAI,gBAAgB,UAAU,CAAA;AAC7E,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAc,cAAA,EAAgB;AAAA,MAC7C,IAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,IAAI,EAAA,EAA8B;AACtC,IAAA,OAAO,KAAK,IAAA,CAAK,GAAA,CAAa,gBAAgB,kBAAA,CAAmB,EAAE,CAAC,CAAA,CAAE,CAAA;AAAA,EACxE;AAAA;AAAA,EAGA,MAAM,IAAA,GAA2B;AAC/B,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAe,cAAc,CAAA;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,MAAA,CAAO,SAAA,EAAmB,KAAA,EAAkD;AAChF,IAAA,MAAM,EAAE,cAAA,EAAgB,GAAG,IAAA,EAAK,GAAI,KAAA;AACpC,IAAA,OAAO,KAAK,IAAA,CAAK,IAAA,CAAa,gBAAgB,kBAAA,CAAmB,SAAS,CAAC,CAAA,QAAA,CAAA,EAAY;AAAA,MACrF,IAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"deposits.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\nimport type { CustomerInfo } from \"../types/customer.js\";\n\n/**\n * Cards resource — `client.cards.*`.\n *\n * The end-user \"money OUT\" surface: a user issues themselves a card backed by\n * their wallet balance via an issuer connector. Mirrors the Takeal API's\n * `/me/cards` routes:\n *\n * GET /card-products → catalog (public, before sign-in)\n * GET /me/card-products → listProducts (the catalog, personal price)\n * GET /me/card-products/{id} → getProduct\n * GET /me/cards/{id}/topup → topUpTerms\n * POST /me/cards/{id}/topup → topUp\n * POST /me/cards → create\n * GET /me/cards → list (most recent first)\n * GET /me/cards/{id} → get\n * PATCH /me/cards/{id} → update (name, design)\n * GET /me/cards/{id}/balance → balance (prepaid remaining)\n * POST /me/cards/{id}/freeze → freeze\n * POST /me/cards/{id}/unfreeze → unfreeze\n * POST /me/cards/{id}/transfer → transfer (to another of their cards)\n * POST /me/cards/{id}/terminate → terminate (one-way)\n *\n * The lifecycle actions are ownership-gated server-side: a caller can only\n * freeze / unfreeze / terminate a card that belongs to them (else 404).\n *\n * ## What is intentionally NOT here\n *\n * Card-data reveal (PAN / CVV) is a separate, security-sensitive flow with its\n * own re-auth + rate-limit + audit contract and is intentionally\n * NOT part of this resource (tracked separately).\n *\n * Today only PREPAID is wired end-to-end; CREDIT and GIFT return 400 from\n * the Takeal API until their issuer flows land.\n */\n\n/** Card product. Only `prepaid` is fully implemented today. */\nexport type CardType = \"credit\" | \"prepaid\" | \"gift\";\n\n/**\n * Card lifecycle state.\n *\n * `pending_payment` is a transient state: the row exists but the\n * per-card issuance-fee debit has not yet succeeded; such cards have no\n * provider reference and no user-visible side effects.\n */\nexport type CardStatus =\n \"pending_payment\" | \"active\" | \"frozen\" | \"terminated\" | \"redeemed\" | \"failed\";\n\n/**\n * A card design: the artwork a card is shown with. `image_url` is the front,\n * `image_url_back` the back; both are either absolute URLs or paths relative\n * to the API origin (the deployment's default design is\n * `/card-designs/default.svg`, its back `/card-designs/default.svg?side=back`)\n * — pass them through `client.assetUrl()` before rendering. `image_url_back`\n * is `null` or absent for a one-sided design: show the front on both sides.\n * The picture is in the proportions of a plastic card (1586×1000) and draws\n * no chip or card data; the client renders the number, name and expiry on\n * top. `id` is `null` for the deployment default, which is rendered from the\n * branding settings.\n */\nexport interface CardDesignRef {\n id: string | null;\n name?: string;\n image_url: string;\n image_url_back?: string | null;\n}\n\n/**\n * What issuing a card costs the caller. `amount` is the price after the\n * user's subscription discount; `base_amount` is the list price and\n * `discount_bps` the discount in basis points (1000 = 10 %). `label` is the\n * operator's wording for the fee line (\"Card issuance\").\n */\nexport interface CardProductPrice {\n /** What the user pays, decimal string, after their subscription discount. */\n amount: string;\n /**\n * ISO 4217 code: the currency the buyer pays in. A signed-in user sees\n * their wallet currency, converted the way issuance will charge it; the\n * public catalog shows the currency the operator priced the card in. It\n * is not necessarily the currency the card is held in (`CardProduct.currency`).\n */\n currency: string;\n /** Wording for the fee line, e.g. \"Card issuance\". */\n label: string;\n /** The list price before the discount, decimal string, in the same currency. */\n base_amount: string;\n /** Discount applied, in basis points (1000 = 10%). */\n discount_bps: number;\n}\n\n/**\n * A card the user can order, as listed by `GET /me/card-products`. The id is\n * opaque — it names a product, never a provider. The list comes in the\n * order the operator arranged the storefront; `is_default` marks the\n * product issued when none is chosen, wherever it sits. `designs` is the\n * set the user may pick from (may be empty when only the default applies);\n * `design` is what the card gets when no choice is made. `price` is `null`\n * for a free card. `features` is an operator-defined object (scheme, wallet\n * support, load limits, …) with no fixed keys.\n */\nexport interface CardProduct {\n id: string;\n name: string;\n /** One line under the name on the tile, or `null`. */\n tagline: string | null;\n description: string | null;\n /** Selling points to list on the product card, in order. May be empty. */\n benefits: string[];\n /**\n * Picture for the product tile, absolute URL, or `null`: show the card\n * design (`design.image_url`) then.\n */\n tile_image_url: string | null;\n card_type: CardType;\n currency: string | null;\n features: Record<string, unknown>;\n design: CardDesignRef;\n designs: CardDesignRef[];\n price: CardProductPrice | null;\n /**\n * The balance a new card comes with, already included in `price`; `null`\n * when the card starts empty and is funded with `topUp()` afterwards.\n */\n starting_balance: CardBalance | null;\n /** True for the product the deployment issues when none is chosen. */\n is_default: boolean;\n}\n\n/**\n * A card record as the Takeal API returns it. Mirrors the `cards` table. Note the\n * SDK never receives the full PAN or CVV here — only `last4` + expiry. The\n * gift-card `redemption_code` is returned exactly once (on create) and\n * scrubbed from subsequent list/get responses.\n */\nexport interface Card {\n id: string;\n user_id: string;\n card_type: CardType;\n status: CardStatus;\n /** Last four digits of the PAN — safe to display. */\n last4: string | null;\n expiry_month: number | null;\n expiry_year: number | null;\n /** Gift cards only, present once on create then scrubbed. */\n redemption_code?: string;\n /** The balance the card was issued with, decimal string; `null` or `\"0\"` for a card issued empty. */\n initial_amount: string | null;\n currency: string;\n failure_reason: string | null;\n /** The name the user gave the card, or `null`. */\n name: string | null;\n /** The artwork the card is shown with. Always present. */\n design: CardDesignRef;\n /** The product the card was issued from; `null` for cards issued without one. */\n product: { id: string; name: string } | null;\n created_at: string;\n updated_at: string;\n /** Only on the result of `create`, when bonuses paid part of the price. */\n bonus?: IssuanceBonus;\n}\n\n/** How bonuses changed a new card's price (\"was / now\"). Decimal strings in `currency`. */\nexport interface IssuanceBonus {\n /** Bonuses used. */\n units: string;\n /** The price before bonuses (\"was\"). */\n price: string;\n /** What the bonuses covered. */\n covered: string;\n /** What the wallet paid (\"now\"). */\n paid: string;\n currency: string;\n}\n\nexport interface CreateCardInput {\n /**\n * A product id from {@link CardsResource.listProducts}. Sent as\n * `product_id`. When given, `type` and `issuer_slug` may be omitted; when\n * both are given they must agree with the product (400 `product_mismatch`).\n * Unknown, disabled or hidden product → 400 `unknown_product`.\n */\n productId?: string;\n /** A name for the card, 1–40 characters. Sent as `name`. */\n name?: string;\n /**\n * One of the product's `designs`. Sent as `design_id`. `null` or omitted\n * picks the product's default design; a design outside the product's set →\n * 400 `design_not_allowed`.\n */\n designId?: string | null;\n /**\n * `prepaid` (the only fully-wired type today), `credit`, or `gift`.\n * Optional when `productId` is given, required otherwise.\n */\n type?: CardType;\n /**\n * @deprecated Ignored since 0.3.21. A card is issued for its product price;\n * the balance it starts with, if the product includes one, is part of that\n * price (see `CardProduct.starting_balance`). Money is added afterwards\n * with {@link CardsResource.topUp}. The field is no longer sent.\n */\n initial_amount?: string;\n /** ISO 4217 code, e.g. `\"USD\"`. */\n currency: string;\n /**\n * Optional. Slug of a specific issuer to mint with. Omit to let\n * the Takeal API pick the first active issuer. Unknown slug → 400; empty issuer\n * list → 503.\n */\n issuer_slug?: string;\n metadata?: Record<string, string>;\n /** Structured billing details — real issuers require these for 3DS / KYC. */\n customer?: CustomerInfo;\n /**\n * Pay part of the price with bonuses. Sent as `use_bonus`. On by default\n * whenever the user has bonuses; `false` pays it all from the wallet.\n */\n useBonus?: boolean;\n /** The most bonuses to use, decimal string. Sent as `bonus_amount`. */\n bonusAmount?: string;\n /**\n * A promo code for the card's price. Sent as `promo_code`. Its discount\n * comes off before bonuses; `client.codes.validate` shows it first. A code\n * that can't be used fails the request with 400 `promo_code_*` and the\n * reason. Without one, the code the user signed up with applies when it\n * covers cards. Ignored inside `deposits.initiate({ issue_card })`: send\n * `promo_code` on the top-up there.\n */\n promoCode?: string;\n /**\n * Required by the Takeal API on this write endpoint. Same key + body replays the\n * original card; same key + different body returns 409.\n */\n idempotencyKey: string;\n}\n\n/**\n * The wire body of a card request: the camelCase fields renamed to what\n * the API reads. Shared by {@link CardsResource.create} and the\n * `issue_card` block of `deposits.initiate`.\n */\nexport function cardRequestBody(\n input: Omit<CreateCardInput, \"idempotencyKey\" | \"currency\"> & { currency?: string },\n): Record<string, unknown> {\n const {\n productId,\n name,\n designId,\n useBonus,\n bonusAmount,\n promoCode,\n initial_amount: _ignored,\n ...rest\n } = input;\n const body: Record<string, unknown> = { ...rest };\n if (productId !== undefined) body[\"product_id\"] = productId;\n if (name !== undefined) body[\"name\"] = name;\n if (designId !== undefined) body[\"design_id\"] = designId;\n if (useBonus !== undefined) body[\"use_bonus\"] = useBonus;\n if (bonusAmount !== undefined) body[\"bonus_amount\"] = bonusAmount;\n if (promoCode !== undefined) body[\"promo_code\"] = promoCode;\n return body;\n}\n\n/** Remaining balance of a prepaid card. */\nexport interface CardBalance {\n amount: string;\n currency: string;\n}\n\n/** What a top-up of a card can be right now, from `GET /me/cards/{id}/topup`. */\nexport interface TopUpTerms {\n /** Whether the card can be topped up at this moment. */\n available: boolean;\n /** Why not, in plain words, when `available` is false. */\n reason: string | null;\n /** Currency top-ups are made in: the card's. */\n currency: string;\n /** What the wallet holds right now, in the wallet's currency. */\n wallet_available: CardBalance;\n /** Smallest single top-up the product allows, or `null` for no floor. */\n min: CardBalance | null;\n /** Largest single top-up the product allows, or `null` for no cap. */\n max: CardBalance | null;\n}\n\nexport interface TopUpInput {\n /** Amount to add, decimal string, in the card's currency. */\n amount: string;\n /**\n * Required. Same key + same amount replays the first outcome; same key +\n * different amount is 409. Use a stable UUID per attempt so a retried\n * network call cannot move the money twice.\n */\n idempotencyKey: string;\n}\n\n/** One top-up attempt as the API records it. */\nexport interface CardTopUp {\n id: string;\n card_id: string;\n status: \"pending\" | \"confirmed\" | \"failed\";\n /** What landed on the card, decimal string, in `currency`. */\n amount: string;\n currency: string;\n /** What the wallet paid, decimal string, in `wallet_currency`. */\n wallet_amount: string;\n wallet_currency: string;\n failure_reason: string | null;\n created_at: string;\n updated_at: string;\n}\n\n/** A completed top-up with the state to redraw: card, its balance, the wallet. */\nexport interface TopUpResult {\n topup: CardTopUp;\n card: Card;\n card_balance: CardBalance;\n wallet: CardBalance;\n}\n\n/** Fields a user can change on their own card. Omitted fields are left as they are. */\nexport interface UpdateCardInput {\n /** New name, 1–40 characters. Sent as `name`. */\n name?: string;\n /**\n * New design (one of the product's `designs`), or `null` for the product's\n * default. Sent as `design_id`.\n */\n designId?: string | null;\n}\n\n/**\n * Kept for callers written against 0.3.x: the API no longer asks for a\n * password or a code on reveal, the session is enough. Both fields are\n * ignored and will be dropped in the next major.\n * @deprecated\n */\nexport interface RevealCardInput {\n password?: string;\n totpCode?: string;\n}\n\n/**\n * Full card data from a successful reveal. **Security**: never persist this —\n * keep it in volatile memory only, clear it within `expires_in_seconds`, and\n * never write it to localStorage / logs (the API marks the response no-store).\n */\nexport interface RevealedCard {\n pan: string;\n cvv: string;\n expiry_month: number;\n expiry_year: number;\n holder_name: string;\n /**\n * The address the card is registered at — what a merchant's checkout asks\n * for, and the postal code some of them decline a payment over. Absent\n * when the deployment has not set one.\n */\n billing_address?: BillingAddress;\n /** Display window before the client should auto-clear the data. */\n expires_in_seconds: number;\n}\n\n/** Postal address a card is registered at. Which parts exist depends on the country. */\nexport interface BillingAddress {\n line1?: string;\n line2?: string;\n city?: string;\n state?: string;\n postal_code?: string;\n country?: string;\n}\n\n/** What to move, and the key that makes a retry safe. */\nexport interface TransferInput {\n /** The card the money lands on. Must be the caller's, and of the same kind and currency. */\n toCardId: string;\n /** Amount to move, decimal string, in the cards' currency. */\n amount: string;\n /**\n * Required. The same key with the same body replays the first outcome; a\n * different body on the same key is 409.\n */\n idempotencyKey: string;\n}\n\n/** One transfer attempt as the API records it. */\nexport interface CardTransfer {\n id: string;\n from_card_id: string;\n to_card_id: string;\n /**\n * `confirmed` — the money is on the other card. `on_wallet` — it came off\n * the first card but the second did not take it, so it is on the wallet\n * and `failure_reason` says so in words. `pending` / `failed` otherwise.\n */\n status: \"pending\" | \"confirmed\" | \"on_wallet\" | \"failed\";\n amount: string;\n currency: string;\n failure_reason: string | null;\n created_at: string;\n updated_at: string;\n}\n\n/** A finished transfer with the balances to redraw both cards and the wallet. */\nexport interface TransferResult {\n transfer: CardTransfer;\n from_balance: CardBalance;\n to_balance: CardBalance;\n /** Holds the money when `transfer.status` is `on_wallet`. */\n wallet: CardBalance;\n}\n\nexport class CardsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Issue a card backed by the user's wallet balance. Resolves to the new\n * `Card`. On a ledger failure after provider creation, the Takeal API rolls the row\n * to `failed` (never an orphaned active card); inspect `status` /\n * `failure_reason` on the result.\n */\n async create(input: CreateCardInput): Promise<Card> {\n const { idempotencyKey, ...card } = input;\n return this.http.post<Card>(\"/me/cards\", {\n body: cardRequestBody(card),\n idempotencyKey,\n });\n }\n\n /**\n * The cards the caller can order, in the order the storefront shows them\n * (`is_default` marks the one issued when none is chosen). Each item\n * carries its product card (name, tagline, benefits, tile picture),\n * artwork, and the issuance price after the caller's subscription\n * discount, in the caller's wallet currency. Pass an item's `id` as\n * `productId` to {@link create}.\n */\n async listProducts(): Promise<CardProduct[]> {\n return this.http.get<CardProduct[]>(\"/me/card-products\");\n }\n\n /** One product from the catalog. 404 when unknown, disabled or hidden. */\n async getProduct(id: string): Promise<CardProduct> {\n return this.http.get<CardProduct>(`/me/card-products/${encodeURIComponent(id)}`);\n }\n\n /**\n * The public catalog: the same products, order and default as\n * {@link listProducts}, but readable before sign-in, for a landing page or\n * the cabinet's first screen. Prices are list prices (`discount_bps` is\n * always 0); once the user is signed in, {@link listProducts} shows what\n * they pay. The API lets caches keep this response for a minute.\n */\n async catalog(): Promise<CardProduct[]> {\n return this.http.get<CardProduct[]>(\"/card-products\");\n }\n\n /**\n * Rename the caller's own card or change its design. Resolves to the\n * updated card. 404 if the card isn't the caller's; 400 `invalid_name` /\n * `design_not_allowed` on a bad value.\n */\n async update(id: string, input: UpdateCardInput): Promise<Card> {\n const body: Record<string, unknown> = {};\n if (input.name !== undefined) body[\"name\"] = input.name;\n if (input.designId !== undefined) body[\"design_id\"] = input.designId;\n return this.http.patch<Card>(`/me/cards/${encodeURIComponent(id)}`, {\n body,\n });\n }\n\n /** Fetch one card by id. */\n async get(id: string): Promise<Card> {\n return this.http.get<Card>(`/me/cards/${encodeURIComponent(id)}`);\n }\n\n /** List the caller's cards, most recent first. */\n async list(): Promise<Card[]> {\n return this.http.get<Card[]>(\"/me/cards\");\n }\n\n /**\n * Remaining balance of a prepaid card. `currency` is required by the Takeal API and\n * forwarded as a query param.\n */\n async balance(id: string, currency: string): Promise<CardBalance> {\n const q = new URLSearchParams({ currency }).toString();\n return this.http.get<CardBalance>(`/me/cards/${encodeURIComponent(id)}/balance?${q}`);\n }\n\n /**\n * What a top-up of this card can be right now: whether it is possible, the\n * currency, the wallet balance, and the product's floor and cap for one\n * top-up. Read it before drawing the form. 404 if the card isn't the caller's.\n */\n async topUpTerms(id: string): Promise<TopUpTerms> {\n return this.http.get<TopUpTerms>(`/me/cards/${encodeURIComponent(id)}/topup`);\n }\n\n /**\n * Move money from the wallet onto the caller's own card. The wallet is\n * debited first, then the card's provider loads the card; if the provider\n * refuses, the money is back on the wallet and the error says so. Resolves\n * to the card, its new balance and the wallet balance, so no second call\n * is needed. Errors carry a sentence the user can read: 400 outside the\n * floor or cap · 402 not enough in the wallet · 404 not the caller's card ·\n * 409 card frozen, closed or still being issued · 501 provider can't top\n * up · 502/503 provider declined or unreachable (wallet untouched).\n */\n async topUp(id: string, input: TopUpInput): Promise<TopUpResult> {\n const { idempotencyKey, amount } = input;\n return this.http.post<TopUpResult>(`/me/cards/${encodeURIComponent(id)}/topup`, {\n body: { amount },\n idempotencyKey,\n });\n }\n\n /**\n * Move money from one of the caller's cards to another. Both must be\n * theirs, active, in the same currency and of the same kind. The money\n * travels through the wallet one leg at a time: when the second leg does\n * not go through, the call still resolves, `transfer.status` is\n * `on_wallet` and the money is on the wallet — never between two cards.\n * Errors carry a sentence the user can read: 400 the same card twice,\n * different currencies or different kinds · 402 the card holds less than\n * that · 404 one of the cards isn't theirs · 409 a card is frozen, closed\n * or still being issued, or the key was reused with a different body ·\n * 501/502/503 the provider cannot or will not move it.\n */\n async transfer(fromCardId: string, input: TransferInput): Promise<TransferResult> {\n const { toCardId, amount, idempotencyKey } = input;\n return this.http.post<TransferResult>(`/me/cards/${encodeURIComponent(fromCardId)}/transfer`, {\n body: { to_card_id: toCardId, amount },\n idempotencyKey,\n });\n }\n\n /**\n * Freeze the caller's own card. Reversible via {@link unfreeze}. The optional\n * `reason` is recorded on the audit trail. Resolves to the updated card.\n * 404 if the card isn't the caller's; 501 if the issuer can't freeze.\n */\n async freeze(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/freeze`, { body: { reason } });\n }\n\n /**\n * Reveal the FULL PAN + CVV for the caller's own card. The signed-in\n * session is all the API asks for; the call is rate-limited and audited\n * server-side. The Takeal API never persists this data and marks the\n * response no-store; the SDK returns it verbatim and holds nothing.\n *\n * **Consumer security duties** (the SDK can't enforce these for you):\n * keep the result in volatile memory only, never write it to\n * localStorage / logs, and clear it within `expires_in_seconds`.\n *\n * 401 bad re-auth · 403 not your card · 429 rate-limited · 501 connector\n * has no sensitive-data endpoint · 503 provider error.\n */\n async reveal(id: string, _input?: RevealCardInput): Promise<RevealedCard> {\n return this.http.post<RevealedCard>(`/me/cards/${encodeURIComponent(id)}/reveal`);\n }\n\n /** Unfreeze a previously-frozen card. Idempotent on an already-active card. */\n async unfreeze(id: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });\n }\n\n /**\n * Terminate the caller's own card. **One-way** — a terminated card cannot be\n * reactivated. The optional `reason` is audited. Idempotent on an\n * already-terminated card.\n */\n async terminate(id: string, reason?: string): Promise<Card> {\n return this.http.post<Card>(`/me/cards/${encodeURIComponent(id)}/terminate`, {\n body: { reason },\n });\n }\n}\n","import type { HttpClient } from \"../http.js\";\nimport type { CustomerInfo } from \"../types/customer.js\";\nimport { cardRequestBody, type CreateCardInput } from \"./cards.js\";\nimport type { DepositTarget, FunderMode } from \"./funding-options.js\";\n\n/**\n * Deposits resource — `client.deposits.*`.\n *\n * The \"money IN\" surface: an end user tops up their wallet balance via a\n * funder connector, or one of their cards straight away, past the wallet\n * (`card_id`, or `issue_card` for a new card). Which of the two a\n * deployment allows is in `client.fundingOptions.list()`. Mirrors the\n * Takeal API's `/me/deposits` routes:\n *\n * POST /me/deposits → initiate\n * GET /me/deposits → list (most recent first)\n * GET /me/deposits/{id} → get\n * POST /me/deposits/{id}/refunds → refund\n *\n * A deposit is rarely terminal on the initiate call: real PSPs return\n * `redirect_required` (3DS / APM redirect) and flip to `confirmed` later via\n * a connector → Takeal API inbound event. Poll `get(id)` or watch the user's\n * webhook stream for the `deposit.confirmed` / `deposit.failed` outcome.\n */\n\n/** Lifecycle of a deposit. `redirect_required` carries `redirect_url`. */\nexport type DepositStatus = \"pending\" | \"redirect_required\" | \"confirmed\" | \"failed\";\n\n/** Top-up rail. The chosen funder decides which it supports. */\nexport type DepositMethod = \"card\" | \"crypto\" | \"bank_transfer\";\n\n/**\n * A deposit record as the Takeal API returns it. Mirrors the `deposits` table; the\n * server-side `id` is the stable handle the SDK polls against. `idempotency_key`\n * and `request_fingerprint` are server-internal and never serialised.\n */\n/** Input for `quote()` — price a cross-currency deposit before paying. */\nexport interface CreateQuoteInput {\n /** Decimal string, e.g. `\"5000.00\"`. */\n amount: string;\n /** ISO 4217 source currency — must differ from the currency credited. */\n currency: string;\n /**\n * Quote a top-up of this card: credited in the card's currency. Pass the\n * same `card_id` to `initiate()`.\n */\n card_id?: string;\n /**\n * Quote into this currency instead of the wallet's: the currency of a\n * card issued with the top-up (`issue_card`). Ignored with `card_id`.\n */\n target_currency?: string;\n}\n\n/** How far a top-up meant for a card has got. */\nexport type CardLoadStatus = \"pending\" | \"succeeded\" | \"failed\";\n\n/**\n * A card to issue with the top-up: the fields of `cards.create` without\n * its idempotency key (the deposit's covers both). The card's price is\n * paid from the top-up and the rest becomes its starting balance.\n */\nexport type IssueCardInput = Omit<CreateCardInput, \"idempotencyKey\" | \"currency\"> & {\n /** Optional with `productId`: the product names the currency. */\n currency?: string;\n};\n\n/**\n * A rate-locked funding quote: pay `source_amount source_currency`, the\n * wallet is credited `credited_amount credited_currency` (net of the\n * platform's conversion spread). Execute by passing `id` as `quote_id` to\n * `initiate()` before `expires_at`; after that the API returns 409 and a new\n * quote is needed.\n */\nexport interface FundingQuote {\n id: string;\n source_amount: string;\n source_currency: string;\n credited_amount: string;\n credited_currency: string;\n /** Provider rate before spread (credited units per 1 source unit). */\n rate: string;\n spread_bps: number;\n provider: string;\n expires_at: string;\n}\n\nexport interface Deposit {\n id: string;\n user_id: string;\n /** Slug of the funder that handled this deposit, as configured by the deployment. */\n connector_slug: string;\n /** The connector's own reference, populated once it responds. */\n provider_reference: string | null;\n status: DepositStatus;\n /** Decimal serialised as a string to avoid float drift. */\n amount: string;\n currency: string;\n method: DepositMethod;\n /** Present when `status === \"redirect_required\"` — send the user here. */\n redirect_url: string | null;\n failure_reason: string | null;\n /** Final settled amount once confirmed (may differ from `amount` on FX). */\n confirmed_amount: string | null;\n confirmed_at: string | null;\n /** Set on cross-currency deposits: the quote this deposit executed against. */\n quote_id?: string | null;\n /** Locked provider rate (credited units per 1 source unit). */\n fx_rate?: string | null;\n fx_spread_bps?: number | null;\n /** The wallet's local currency the deposit converted into. */\n credited_currency?: string | null;\n /** What the wallet was actually credited, net of spread. */\n credited_amount?: string | null;\n /** Bonuses added on top of the top-up, when any were. */\n bonus_units?: string | null;\n /** What those bonuses added to the wallet, in the credited currency. */\n bonus_value?: string | null;\n /** The promo code the top-up was made with; its discount came off the commission. */\n promo_code?: string | null;\n /** Where the money goes. Older deployments leave it out: the wallet. */\n target?: DepositTarget;\n /** For a top-up onto a card: the card. */\n card_id?: string | null;\n /** The funding connector's mode when the top-up was made. */\n funder_mode?: FunderMode | null;\n /** True when the card was issued with this top-up. */\n issues_card?: boolean;\n /**\n * For a top-up onto a card: `pending` until the card provider has loaded\n * the card, then `succeeded` or `failed`. Show the top-up as done only\n * once it is `succeeded`, or once `returned_to_wallet_at` is set.\n */\n card_load_status?: CardLoadStatus | null;\n /** Why the card could not take it, when `card_load_status` is `failed`. */\n card_load_error?: string | null;\n /** What went towards the card, in its currency, bonuses included. */\n card_amount?: string | null;\n /** The commission taken from a top-up onto a card, in the card's currency. */\n card_commission?: string | null;\n /** The money part of the price of a card issued with the top-up. */\n issue_fee?: string | null;\n /** The bonus part of that price. */\n issue_bonus_units?: string | null;\n issue_bonus_value?: string | null;\n card_loaded_at?: string | null;\n /**\n * Set when the card could not take the top-up and the money went to the\n * wallet instead (funding connectors in `mixed` mode). The user is told.\n */\n returned_to_wallet_at?: string | null;\n created_at: string;\n updated_at: string;\n}\n\nexport interface InitiateDepositInput {\n /** Decimal as a string (`\"100.00\"`) — avoids float-precision loss on the wire. */\n amount: string;\n /** ISO 4217 code, e.g. `\"USD\"`. */\n currency: string;\n method: DepositMethod;\n /**\n * Optional. Slug of a specific funder to route through. Omit to\n * let the Takeal API pick the first active funder. Unknown slug → 400; empty\n * funder list → 503.\n */\n funder_slug?: string;\n /**\n * Passed to the funding connector and stored with the deposit. Two keys\n * work across connectors: `return_url`, where the provider sends the user\n * back after a 3-D Secure step (pair it with `redirect_required`), and on\n * test deployments with the mock funder `mock_scenario`, which picks the\n * outcome: `happy` (confirmed at once, the default), `pending` (confirmed\n * about 15 s later), `redirect` (a hosted page where the user approves or\n * declines) or `fail`.\n */\n metadata?: Record<string, string>;\n /** Structured billing details — real PSPs require these for 3DS / compliance. */\n customer?: CustomerInfo;\n /**\n * Required by the Takeal API on this write endpoint. Same key + body replays the\n * original deposit; same key + different body returns 409. Supply a stable\n * UUID per logical attempt so a retried network call is safe.\n */\n idempotencyKey: string;\n /**\n * Required when `currency` differs from the wallet's local currency: a\n * fresh quote id from `quote()`. Cross-currency deposits without one are\n * rejected with 400; expired quotes with 409.\n */\n quote_id?: string;\n /**\n * Add bonuses on top of the top-up: the user pays `amount`, the wallet\n * gets `amount` plus what the bonuses add. On by default whenever the\n * user has bonuses that can go to a top-up (only ones that came with a\n * payment can); `false` tops up without them.\n */\n use_bonus?: boolean;\n /** The most bonuses to add, decimal string. Omit to add as many as allowed. */\n bonus_amount?: string;\n /**\n * Top up this card instead of the wallet. It must be the user's, active\n * and prepaid. A funding connector that tops up the wallet only answers\n * 400 `target_not_allowed`; one that tops up cards only needs `card_id`\n * or `issue_card`. Paying in another currency than the card's needs a\n * quote made with the same `card_id`.\n */\n card_id?: string;\n /**\n * Issue a new card and put this top-up on it. The card shows up as\n * `pending_payment` and is issued once the top-up is confirmed; if the\n * top-up fails, so does the card. Too small to cover the price → 400\n * `amount_too_small`. Not together with `card_id`.\n */\n issue_card?: IssueCardInput;\n /**\n * A promo code for this top-up, to the wallet or to a card. Its discount\n * comes off the commission; bonuses or a gift that come with the code\n * arrive once the top-up is confirmed. A code that can't be used fails the\n * request with 400 `promo_code_*` and the reason. `client.codes.validate`\n * checks it first.\n */\n promo_code?: string;\n}\n\nexport interface CreateDepositRefundInput {\n /** Omit for a full refund of the original confirmed amount; same currency. */\n amount?: string;\n /** Human-readable reason, e.g. `\"customer_request\"`. */\n reason?: string;\n metadata?: Record<string, string>;\n /** Required. Replays are keyed on this. */\n idempotencyKey: string;\n}\n\n/** A refund row as the Takeal API returns it (`refunds` table, deposit-targeted). */\nexport interface Refund {\n id: string;\n target_type: string;\n deposit_id?: string;\n payment_id?: string;\n connector_slug: string;\n amount: string;\n currency: string;\n reason: string;\n status: string;\n provider_refund_reference?: string;\n failure_reason?: string;\n requestor_type: string;\n requestor_id: string;\n created_at: string;\n updated_at: string;\n}\n\nexport class DepositsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Initiate a top-up. Resolves to the freshly-created `Deposit`, whose\n * `status` may already be `confirmed` (synchronous rails / mock) or\n * `redirect_required` (3DS / APM — forward the user to `redirect_url`).\n */\n /**\n * Price a cross-currency deposit BEFORE paying. The rate is locked\n * server-side until `expires_at`; deposits already in the currency they\n * credit (the wallet's, or the card's with `card_id`) need no quote (the\n * API answers 400 `no_quote_needed`).\n */\n async quote(input: CreateQuoteInput): Promise<FundingQuote> {\n return this.http.post<FundingQuote>(\"/me/deposits/quotes\", { body: input });\n }\n\n async initiate(input: InitiateDepositInput): Promise<Deposit> {\n const { idempotencyKey, issue_card, ...rest } = input;\n const body: Record<string, unknown> = { ...rest };\n if (issue_card !== undefined) body[\"issue_card\"] = cardRequestBody(issue_card);\n return this.http.post<Deposit>(\"/me/deposits\", {\n body,\n idempotencyKey,\n });\n }\n\n /** Fetch one deposit by id — the poll target while a redirect resolves. */\n async get(id: string): Promise<Deposit> {\n return this.http.get<Deposit>(`/me/deposits/${encodeURIComponent(id)}`);\n }\n\n /** List the caller's deposits, most recent first. */\n async list(): Promise<Deposit[]> {\n return this.http.get<Deposit[]>(\"/me/deposits\");\n }\n\n /**\n * Refund a previously-confirmed deposit. Synchronous when the\n * connector settles inline; otherwise the row stays `pending` and flips\n * later via the inbound `deposit.refunded` event.\n */\n async refund(depositId: string, input: CreateDepositRefundInput): Promise<Refund> {\n const { idempotencyKey, ...body } = input;\n return this.http.post<Refund>(`/me/deposits/${encodeURIComponent(depositId)}/refunds`, {\n body,\n idempotencyKey,\n });\n }\n}\n"]}
@@ -1,176 +1,3 @@
1
- import { H as HttpClient } from '../http-B-OQwMYn.cjs';
2
- import { C as CustomerInfo } from '../customer-CoxPwe5o.cjs';
3
-
4
- /**
5
- * Deposits resource — `client.deposits.*`.
6
- *
7
- * The "money IN" surface: an end user tops up their wallet balance via a
8
- * funder connector. Mirrors the Takeal API's `/me/deposits` routes:
9
- *
10
- * POST /me/deposits → initiate
11
- * GET /me/deposits → list (most recent first)
12
- * GET /me/deposits/{id} → get
13
- * POST /me/deposits/{id}/refunds → refund
14
- *
15
- * A deposit is rarely terminal on the initiate call: real PSPs return
16
- * `redirect_required` (3DS / APM redirect) and flip to `confirmed` later via
17
- * a connector → Takeal API inbound event. Poll `get(id)` or watch the user's
18
- * webhook stream for the `deposit.confirmed` / `deposit.failed` outcome.
19
- */
20
- /** Lifecycle of a deposit. `redirect_required` carries `redirect_url`. */
21
- type DepositStatus = "pending" | "redirect_required" | "confirmed" | "failed";
22
- /** Top-up rail. The chosen funder decides which it supports. */
23
- type DepositMethod = "card" | "crypto" | "bank_transfer";
24
- /**
25
- * A deposit record as the Takeal API returns it. Mirrors the `deposits` table; the
26
- * server-side `id` is the stable handle the SDK polls against. `idempotency_key`
27
- * and `request_fingerprint` are server-internal and never serialised.
28
- */
29
- /** Input for `quote()` — price a cross-currency deposit before paying. */
30
- interface CreateQuoteInput {
31
- /** Decimal string, e.g. `"5000.00"`. */
32
- amount: string;
33
- /** ISO 4217 source currency — must differ from the wallet's local currency. */
34
- currency: string;
35
- }
36
- /**
37
- * A rate-locked funding quote: pay `source_amount source_currency`, the
38
- * wallet is credited `credited_amount credited_currency` (net of the
39
- * platform's conversion spread). Execute by passing `id` as `quote_id` to
40
- * `initiate()` before `expires_at`; after that the API returns 409 and a new
41
- * quote is needed.
42
- */
43
- interface FundingQuote {
44
- id: string;
45
- source_amount: string;
46
- source_currency: string;
47
- credited_amount: string;
48
- credited_currency: string;
49
- /** Provider rate before spread (credited units per 1 source unit). */
50
- rate: string;
51
- spread_bps: number;
52
- provider: string;
53
- expires_at: string;
54
- }
55
- interface Deposit {
56
- id: string;
57
- user_id: string;
58
- /** Slug of the funder that handled this deposit, as configured by the deployment. */
59
- connector_slug: string;
60
- /** The connector's own reference, populated once it responds. */
61
- provider_reference: string | null;
62
- status: DepositStatus;
63
- /** Decimal serialised as a string to avoid float drift. */
64
- amount: string;
65
- currency: string;
66
- method: DepositMethod;
67
- /** Present when `status === "redirect_required"` — send the user here. */
68
- redirect_url: string | null;
69
- failure_reason: string | null;
70
- /** Final settled amount once confirmed (may differ from `amount` on FX). */
71
- confirmed_amount: string | null;
72
- confirmed_at: string | null;
73
- /** Set on cross-currency deposits: the quote this deposit executed against. */
74
- quote_id?: string | null;
75
- /** Locked provider rate (credited units per 1 source unit). */
76
- fx_rate?: string | null;
77
- fx_spread_bps?: number | null;
78
- /** The wallet's local currency the deposit converted into. */
79
- credited_currency?: string | null;
80
- /** What the wallet was actually credited, net of spread. */
81
- credited_amount?: string | null;
82
- created_at: string;
83
- updated_at: string;
84
- }
85
- interface InitiateDepositInput {
86
- /** Decimal as a string (`"100.00"`) — avoids float-precision loss on the wire. */
87
- amount: string;
88
- /** ISO 4217 code, e.g. `"USD"`. */
89
- currency: string;
90
- method: DepositMethod;
91
- /**
92
- * Optional. Slug of a specific funder to route through. Omit to
93
- * let the Takeal API pick the first active funder. Unknown slug → 400; empty
94
- * funder list → 503.
95
- */
96
- funder_slug?: string;
97
- /**
98
- * Passed to the funding connector and stored with the deposit. Two keys
99
- * work across connectors: `return_url`, where the provider sends the user
100
- * back after a 3-D Secure step (pair it with `redirect_required`), and on
101
- * test deployments with the mock funder `mock_scenario`, which picks the
102
- * outcome: `happy` (confirmed at once, the default), `pending` (confirmed
103
- * about 15 s later), `redirect` (a hosted page where the user approves or
104
- * declines) or `fail`.
105
- */
106
- metadata?: Record<string, string>;
107
- /** Structured billing details — real PSPs require these for 3DS / compliance. */
108
- customer?: CustomerInfo;
109
- /**
110
- * Required by the Takeal API on this write endpoint. Same key + body replays the
111
- * original deposit; same key + different body returns 409. Supply a stable
112
- * UUID per logical attempt so a retried network call is safe.
113
- */
114
- idempotencyKey: string;
115
- /**
116
- * Required when `currency` differs from the wallet's local currency: a
117
- * fresh quote id from `quote()`. Cross-currency deposits without one are
118
- * rejected with 400; expired quotes with 409.
119
- */
120
- quote_id?: string;
121
- }
122
- interface CreateDepositRefundInput {
123
- /** Omit for a full refund of the original confirmed amount; same currency. */
124
- amount?: string;
125
- /** Human-readable reason, e.g. `"customer_request"`. */
126
- reason?: string;
127
- metadata?: Record<string, string>;
128
- /** Required. Replays are keyed on this. */
129
- idempotencyKey: string;
130
- }
131
- /** A refund row as the Takeal API returns it (`refunds` table, deposit-targeted). */
132
- interface Refund {
133
- id: string;
134
- target_type: string;
135
- deposit_id?: string;
136
- payment_id?: string;
137
- connector_slug: string;
138
- amount: string;
139
- currency: string;
140
- reason: string;
141
- status: string;
142
- provider_refund_reference?: string;
143
- failure_reason?: string;
144
- requestor_type: string;
145
- requestor_id: string;
146
- created_at: string;
147
- updated_at: string;
148
- }
149
- declare class DepositsResource {
150
- private readonly http;
151
- constructor(http: HttpClient);
152
- /**
153
- * Initiate a top-up. Resolves to the freshly-created `Deposit`, whose
154
- * `status` may already be `confirmed` (synchronous rails / mock) or
155
- * `redirect_required` (3DS / APM — forward the user to `redirect_url`).
156
- */
157
- /**
158
- * Price a cross-currency deposit BEFORE paying. The rate is locked
159
- * server-side until `expires_at`; deposits in the local currency need no
160
- * quote (the API answers 400 `no_quote_needed`).
161
- */
162
- quote(input: CreateQuoteInput): Promise<FundingQuote>;
163
- initiate(input: InitiateDepositInput): Promise<Deposit>;
164
- /** Fetch one deposit by id — the poll target while a redirect resolves. */
165
- get(id: string): Promise<Deposit>;
166
- /** List the caller's deposits, most recent first. */
167
- list(): Promise<Deposit[]>;
168
- /**
169
- * Refund a previously-confirmed deposit. Synchronous when the
170
- * connector settles inline; otherwise the row stays `pending` and flips
171
- * later via the inbound `deposit.refunded` event.
172
- */
173
- refund(depositId: string, input: CreateDepositRefundInput): Promise<Refund>;
174
- }
175
-
176
- export { type CreateDepositRefundInput, type CreateQuoteInput, type Deposit, type DepositMethod, type DepositStatus, DepositsResource, type FundingQuote, type InitiateDepositInput, type Refund };
1
+ import '../http-DeANAoTs.cjs';
2
+ import '../cards-B_aNY35J.cjs';
3
+ export { C as CardLoadStatus, b as CreateDepositRefundInput, c as CreateQuoteInput, D as Deposit, d as DepositMethod, e as DepositStatus, a as DepositsResource, i as FundingQuote, I as InitiateDepositInput, j as IssueCardInput, R as Refund } from '../deposits-BEc8U80M.cjs';