@takeal/cusfront-sdk 0.6.4 → 0.6.5

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 (59) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +129 -3
  3. package/dist/{cards-ofoGRU9v.d.cts → cards-CEFKrVkl.d.cts} +125 -10
  4. package/dist/{cards-BrqeBqLV.d.ts → cards-ColpW52n.d.ts} +125 -10
  5. package/dist/index.cjs +121 -11
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +13 -5
  8. package/dist/index.d.ts +13 -5
  9. package/dist/index.js +120 -12
  10. package/dist/index.js.map +1 -1
  11. package/dist/react/index.d.cts +3 -1
  12. package/dist/react/index.d.ts +3 -1
  13. package/dist/resources/auth.cjs.map +1 -1
  14. package/dist/resources/auth.d.cts +1 -1
  15. package/dist/resources/auth.d.ts +1 -1
  16. package/dist/resources/auth.js.map +1 -1
  17. package/dist/resources/cards.cjs +9 -2
  18. package/dist/resources/cards.cjs.map +1 -1
  19. package/dist/resources/cards.d.cts +1 -1
  20. package/dist/resources/cards.d.ts +1 -1
  21. package/dist/resources/cards.js +9 -2
  22. package/dist/resources/cards.js.map +1 -1
  23. package/dist/resources/close-requests.cjs +54 -0
  24. package/dist/resources/close-requests.cjs.map +1 -0
  25. package/dist/resources/close-requests.d.cts +155 -0
  26. package/dist/resources/close-requests.d.ts +155 -0
  27. package/dist/resources/close-requests.js +52 -0
  28. package/dist/resources/close-requests.js.map +1 -0
  29. package/dist/resources/consents.cjs +42 -7
  30. package/dist/resources/consents.cjs.map +1 -1
  31. package/dist/resources/consents.d.cts +58 -8
  32. package/dist/resources/consents.d.ts +58 -8
  33. package/dist/resources/consents.js +41 -8
  34. package/dist/resources/consents.js.map +1 -1
  35. package/dist/resources/debt.cjs +22 -0
  36. package/dist/resources/debt.cjs.map +1 -0
  37. package/dist/resources/debt.d.cts +76 -0
  38. package/dist/resources/debt.d.ts +76 -0
  39. package/dist/resources/debt.js +20 -0
  40. package/dist/resources/debt.js.map +1 -0
  41. package/dist/resources/deposits.cjs.map +1 -1
  42. package/dist/resources/deposits.d.cts +1 -1
  43. package/dist/resources/deposits.d.ts +1 -1
  44. package/dist/resources/deposits.js.map +1 -1
  45. package/dist/resources/funding-options.d.cts +1 -1
  46. package/dist/resources/funding-options.d.ts +1 -1
  47. package/dist/resources/history.cjs.map +1 -1
  48. package/dist/resources/history.d.cts +12 -1
  49. package/dist/resources/history.d.ts +12 -1
  50. package/dist/resources/history.js.map +1 -1
  51. package/dist/resources/me.d.cts +1 -1
  52. package/dist/resources/me.d.ts +1 -1
  53. package/dist/telegram.cjs +119 -11
  54. package/dist/telegram.cjs.map +1 -1
  55. package/dist/telegram.d.cts +3 -1
  56. package/dist/telegram.d.ts +3 -1
  57. package/dist/telegram.js +119 -11
  58. package/dist/telegram.js.map +1 -1
  59. package/package.json +11 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/resources/history.ts"],"names":[],"mappings":";;;AA8GO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,IAAA,CAAK,MAAA,GAA4B,EAAC,EAAyB;AAC/D,IAAA,MAAM,CAAA,GAAI,IAAI,eAAA,EAAgB;AAC9B,IAAA,IAAI,OAAO,MAAA,EAAQ,CAAA,CAAE,GAAA,CAAI,SAAA,EAAW,OAAO,MAAM,CAAA;AACjD,IAAA,IAAI,OAAO,MAAA,EAAQ,CAAA,CAAE,GAAA,CAAI,QAAA,EAAU,OAAO,MAAM,CAAA;AAChD,IAAA,IAAI,MAAA,CAAO,UAAU,MAAA,EAAW,CAAA,CAAE,IAAI,OAAA,EAAS,MAAA,CAAO,MAAA,CAAO,KAAK,CAAC,CAAA;AACnE,IAAA,IAAI,OAAO,IAAA,EAAM,CAAA,CAAE,GAAA,CAAI,MAAA,EAAQ,OAAO,IAAI,CAAA;AAC1C,IAAA,MAAM,EAAA,GAAK,EAAE,QAAA,EAAS;AACtB,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAAiB,CAAA,WAAA,EAAc,KAAK,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA,EAAI;AAAA,MACpE,QAAQ,MAAA,CAAO;AAAA,KAChB,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,OAAO,GAAA,CAAI,MAAA,GAA4C,EAAC,EAAgC;AACtF,IAAA,IAAI,MAAA;AACJ,IAAA,GAAG;AACD,MAAA,MAAM,IAAA,GAAO,MAAM,IAAA,CAAK,IAAA,CAAK,EAAE,GAAG,MAAA,EAAQ,QAAQ,CAAA;AAClD,MAAA,OAAO,IAAA,CAAK,KAAA;AACZ,MAAA,MAAA,GAAS,KAAK,WAAA,IAAe,MAAA;AAAA,IAC/B,CAAA,QAAS,MAAA;AAAA,EACX;AACF","file":"history.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * History resource — `client.history.*`: everything that happened to the\n * user's money in one list, newest first.\n *\n * ```ts\n * const page = await client.history.list({ limit: 30 });\n * const more = await client.history.list({ cursor: page.next_cursor! });\n * const oneCard = await client.history.list({ cardId: card.id });\n * for await (const item of client.history.all()) { … }\n * ```\n *\n * New kinds are added over time. Render an unknown `kind` from its `title`,\n * `amount`, `direction` and `status`; don't drop it.\n */\n\nexport type HistoryKind =\n | \"card_purchase\"\n | \"card_refund\"\n | \"card_issued\"\n | \"card_topup\"\n | \"card_transfer\"\n | \"wallet_deposit\"\n | \"deposit_refund\"\n | \"fee\"\n | \"balance_adjustment\"\n | \"bonus\"\n // Any kind added later still type-checks.\n | (string & {});\n\nexport type HistoryStatus =\n \"completed\" | \"pending\" | \"declined\" | \"reversed\" | \"failed\" | (string & {});\n\nexport interface HistoryAmount {\n /** Decimal string, never negative; see `direction`. */\n amount: string;\n /** ISO 4217 code. */\n currency: string;\n}\n\nexport interface HistoryCard {\n id: string;\n name: string | null;\n last4: string | null;\n}\n\nexport interface HistoryItem {\n /** Unique across kinds. */\n id: string;\n kind: HistoryKind;\n occurred_at: string;\n /** `pending` is not finished yet; `reversed` is an authorisation that was released. */\n status: HistoryStatus;\n /** `out` money left the user, `in` it came in, `internal` it moved between the wallet and the user's cards. */\n direction: \"out\" | \"in\" | \"internal\" | (string & {});\n /** The merchant, or what the operation was, in the language asked for. */\n title: string;\n /**\n * In the currency the operation happened in. For `bonus` the currency is\n * `BNS` and the amount is a number of bonuses, not money.\n */\n amount: HistoryAmount;\n /**\n * The other side of a conversion (what the card was billed, what the\n * wallet or card received). For a `bonus` spend: the part of the price\n * the bonuses covered, or what they added to a top-up.\n */\n counter_amount: HistoryAmount | null;\n /** Rate between `amount` and `counter_amount`, decimal string. */\n fx_rate: string | null;\n /** A fee charged with the operation, in the wallet's currency. */\n fee: HistoryAmount | null;\n /** The card; the source card of a transfer. */\n card: HistoryCard | null;\n /** The destination card of a transfer. */\n to_card: HistoryCard | null;\n merchant: { name: string | null; city: string | null; country: string | null } | null;\n /** On a declined payment: a stable code and the reason in plain words. */\n decline_reason: {\n code:\n | \"insufficient_funds\"\n | \"limit_exceeded\"\n | \"card_blocked\"\n | \"card_expired\"\n | \"wrong_details\"\n | \"merchant_not_allowed\"\n | \"other\"\n | (string & {});\n text: string;\n } | null;\n}\n\nexport interface HistoryPage {\n items: HistoryItem[];\n /** Pass as `cursor` for the next, older page; `null` on the last one. */\n next_cursor: string | null;\n}\n\nexport interface ListHistoryParams {\n /** Only this card's operations, transfers to and from it included. */\n cardId?: string;\n cursor?: string;\n /** 1 to 100, default 30. */\n limit?: number;\n /** `en` or `ru` for titles and decline reasons. Defaults to the browser's language header. */\n lang?: \"en\" | \"ru\";\n signal?: AbortSignal;\n}\n\nexport class HistoryResource {\n constructor(private readonly http: HttpClient) {}\n\n /** One page of the history. Errors: 400 bad cursor or limit, 404 `cardId` is not the user's card. */\n async list(params: ListHistoryParams = {}): Promise<HistoryPage> {\n const q = new URLSearchParams();\n if (params.cardId) q.set(\"card_id\", params.cardId);\n if (params.cursor) q.set(\"cursor\", params.cursor);\n if (params.limit !== undefined) q.set(\"limit\", String(params.limit));\n if (params.lang) q.set(\"lang\", params.lang);\n const qs = q.toString();\n return this.http.get<HistoryPage>(`/me/history${qs ? `?${qs}` : \"\"}`, {\n signal: params.signal,\n });\n }\n\n /** Every entry, page after page, newest first. */\n async *all(params: Omit<ListHistoryParams, \"cursor\"> = {}): AsyncGenerator<HistoryItem> {\n let cursor: string | undefined;\n do {\n const page = await this.list({ ...params, cursor });\n yield* page.items;\n cursor = page.next_cursor ?? undefined;\n } while (cursor);\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/resources/history.ts"],"names":[],"mappings":";;;AAyHO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,IAAA,CAAK,MAAA,GAA4B,EAAC,EAAyB;AAC/D,IAAA,MAAM,CAAA,GAAI,IAAI,eAAA,EAAgB;AAC9B,IAAA,IAAI,OAAO,MAAA,EAAQ,CAAA,CAAE,GAAA,CAAI,SAAA,EAAW,OAAO,MAAM,CAAA;AACjD,IAAA,IAAI,OAAO,MAAA,EAAQ,CAAA,CAAE,GAAA,CAAI,QAAA,EAAU,OAAO,MAAM,CAAA;AAChD,IAAA,IAAI,MAAA,CAAO,UAAU,MAAA,EAAW,CAAA,CAAE,IAAI,OAAA,EAAS,MAAA,CAAO,MAAA,CAAO,KAAK,CAAC,CAAA;AACnE,IAAA,IAAI,OAAO,IAAA,EAAM,CAAA,CAAE,GAAA,CAAI,MAAA,EAAQ,OAAO,IAAI,CAAA;AAC1C,IAAA,MAAM,EAAA,GAAK,EAAE,QAAA,EAAS;AACtB,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAAiB,CAAA,WAAA,EAAc,KAAK,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA,EAAI;AAAA,MACpE,QAAQ,MAAA,CAAO;AAAA,KAChB,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,OAAO,GAAA,CAAI,MAAA,GAA4C,EAAC,EAAgC;AACtF,IAAA,IAAI,MAAA;AACJ,IAAA,GAAG;AACD,MAAA,MAAM,IAAA,GAAO,MAAM,IAAA,CAAK,IAAA,CAAK,EAAE,GAAG,MAAA,EAAQ,QAAQ,CAAA;AAClD,MAAA,OAAO,IAAA,CAAK,KAAA;AACZ,MAAA,MAAA,GAAS,KAAK,WAAA,IAAe,MAAA;AAAA,IAC/B,CAAA,QAAS,MAAA;AAAA,EACX;AACF","file":"history.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * History resource — `client.history.*`: everything that happened to the\n * user's money in one list, newest first.\n *\n * ```ts\n * const page = await client.history.list({ limit: 30 });\n * const more = await client.history.list({ cursor: page.next_cursor! });\n * const oneCard = await client.history.list({ cardId: card.id });\n * for await (const item of client.history.all()) { … }\n * ```\n *\n * New kinds are added over time. Render an unknown `kind` from its `title`,\n * `amount`, `direction` and `status`; don't drop it.\n */\n\nexport type HistoryKind =\n | \"card_purchase\"\n | \"card_refund\"\n | \"card_issued\"\n | \"card_topup\"\n | \"card_transfer\"\n | \"wallet_deposit\"\n | \"deposit_refund\"\n | \"fee\"\n | \"balance_adjustment\"\n | \"bonus\"\n /**\n * What was left on a closed card moving to the card that replaced it:\n * `card` is the old card, `to_card` the new one. `pending` until the\n * issuer returns the money and it is on the new card. If the new card\n * could not take it, the money went to the wallet and `title` says so.\n */\n | \"closed_card_balance\"\n /** A fee for using the card: a payment, a declined payment, a cash withdrawal. */\n | \"card_fee\"\n /** Money that paid card fees owed. */\n | \"debt_payment\"\n // Any kind added later still type-checks.\n | (string & {});\n\nexport type HistoryStatus =\n \"completed\" | \"pending\" | \"declined\" | \"reversed\" | \"failed\" | (string & {});\n\nexport interface HistoryAmount {\n /** Decimal string, never negative; see `direction`. */\n amount: string;\n /** ISO 4217 code. */\n currency: string;\n}\n\nexport interface HistoryCard {\n id: string;\n name: string | null;\n last4: string | null;\n}\n\nexport interface HistoryItem {\n /** Unique across kinds. */\n id: string;\n kind: HistoryKind;\n occurred_at: string;\n /** `pending` is not finished yet; `reversed` is an authorisation that was released. */\n status: HistoryStatus;\n /** `out` money left the user, `in` it came in, `internal` it moved between the wallet and the user's cards. */\n direction: \"out\" | \"in\" | \"internal\" | (string & {});\n /** The merchant, or what the operation was, in the language asked for. */\n title: string;\n /**\n * In the currency the operation happened in. For `bonus` the currency is\n * `BNS` and the amount is a number of bonuses, not money.\n */\n amount: HistoryAmount;\n /**\n * The other side of a conversion (what the card was billed, what the\n * wallet or card received). For a `bonus` spend: the part of the price\n * the bonuses covered, or what they added to a top-up.\n */\n counter_amount: HistoryAmount | null;\n /** Rate between `amount` and `counter_amount`, decimal string. */\n fx_rate: string | null;\n /** A fee charged with the operation, in the wallet's currency. */\n fee: HistoryAmount | null;\n /** The card; the source card of a transfer. */\n card: HistoryCard | null;\n /** The destination card of a transfer. */\n to_card: HistoryCard | null;\n merchant: { name: string | null; city: string | null; country: string | null } | null;\n /** On a declined payment: a stable code and the reason in plain words. */\n decline_reason: {\n code:\n | \"insufficient_funds\"\n | \"limit_exceeded\"\n | \"card_blocked\"\n | \"card_expired\"\n | \"wrong_details\"\n | \"merchant_not_allowed\"\n | \"other\"\n | (string & {});\n text: string;\n } | null;\n}\n\nexport interface HistoryPage {\n items: HistoryItem[];\n /** Pass as `cursor` for the next, older page; `null` on the last one. */\n next_cursor: string | null;\n}\n\nexport interface ListHistoryParams {\n /** Only this card's operations, transfers to and from it included. */\n cardId?: string;\n cursor?: string;\n /** 1 to 100, default 30. */\n limit?: number;\n /** `en` or `ru` for titles and decline reasons. Defaults to the browser's language header. */\n lang?: \"en\" | \"ru\";\n signal?: AbortSignal;\n}\n\nexport class HistoryResource {\n constructor(private readonly http: HttpClient) {}\n\n /** One page of the history. Errors: 400 bad cursor or limit, 404 `cardId` is not the user's card. */\n async list(params: ListHistoryParams = {}): Promise<HistoryPage> {\n const q = new URLSearchParams();\n if (params.cardId) q.set(\"card_id\", params.cardId);\n if (params.cursor) q.set(\"cursor\", params.cursor);\n if (params.limit !== undefined) q.set(\"limit\", String(params.limit));\n if (params.lang) q.set(\"lang\", params.lang);\n const qs = q.toString();\n return this.http.get<HistoryPage>(`/me/history${qs ? `?${qs}` : \"\"}`, {\n signal: params.signal,\n });\n }\n\n /** Every entry, page after page, newest first. */\n async *all(params: Omit<ListHistoryParams, \"cursor\"> = {}): AsyncGenerator<HistoryItem> {\n let cursor: string | undefined;\n do {\n const page = await this.list({ ...params, cursor });\n yield* page.items;\n cursor = page.next_cursor ?? undefined;\n } while (cursor);\n }\n}\n"]}
@@ -14,7 +14,18 @@ import { H as HttpClient } from '../http-DeANAoTs.cjs';
14
14
  * New kinds are added over time. Render an unknown `kind` from its `title`,
15
15
  * `amount`, `direction` and `status`; don't drop it.
16
16
  */
17
- type HistoryKind = "card_purchase" | "card_refund" | "card_issued" | "card_topup" | "card_transfer" | "wallet_deposit" | "deposit_refund" | "fee" | "balance_adjustment" | "bonus" | (string & {});
17
+ type HistoryKind = "card_purchase" | "card_refund" | "card_issued" | "card_topup" | "card_transfer" | "wallet_deposit" | "deposit_refund" | "fee" | "balance_adjustment" | "bonus"
18
+ /**
19
+ * What was left on a closed card moving to the card that replaced it:
20
+ * `card` is the old card, `to_card` the new one. `pending` until the
21
+ * issuer returns the money and it is on the new card. If the new card
22
+ * could not take it, the money went to the wallet and `title` says so.
23
+ */
24
+ | "closed_card_balance"
25
+ /** A fee for using the card: a payment, a declined payment, a cash withdrawal. */
26
+ | "card_fee"
27
+ /** Money that paid card fees owed. */
28
+ | "debt_payment" | (string & {});
18
29
  type HistoryStatus = "completed" | "pending" | "declined" | "reversed" | "failed" | (string & {});
19
30
  interface HistoryAmount {
20
31
  /** Decimal string, never negative; see `direction`. */
@@ -14,7 +14,18 @@ import { H as HttpClient } from '../http-DeANAoTs.js';
14
14
  * New kinds are added over time. Render an unknown `kind` from its `title`,
15
15
  * `amount`, `direction` and `status`; don't drop it.
16
16
  */
17
- type HistoryKind = "card_purchase" | "card_refund" | "card_issued" | "card_topup" | "card_transfer" | "wallet_deposit" | "deposit_refund" | "fee" | "balance_adjustment" | "bonus" | (string & {});
17
+ type HistoryKind = "card_purchase" | "card_refund" | "card_issued" | "card_topup" | "card_transfer" | "wallet_deposit" | "deposit_refund" | "fee" | "balance_adjustment" | "bonus"
18
+ /**
19
+ * What was left on a closed card moving to the card that replaced it:
20
+ * `card` is the old card, `to_card` the new one. `pending` until the
21
+ * issuer returns the money and it is on the new card. If the new card
22
+ * could not take it, the money went to the wallet and `title` says so.
23
+ */
24
+ | "closed_card_balance"
25
+ /** A fee for using the card: a payment, a declined payment, a cash withdrawal. */
26
+ | "card_fee"
27
+ /** Money that paid card fees owed. */
28
+ | "debt_payment" | (string & {});
18
29
  type HistoryStatus = "completed" | "pending" | "declined" | "reversed" | "failed" | (string & {});
19
30
  interface HistoryAmount {
20
31
  /** Decimal string, never negative; see `direction`. */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/resources/history.ts"],"names":[],"mappings":";AA8GO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,IAAA,CAAK,MAAA,GAA4B,EAAC,EAAyB;AAC/D,IAAA,MAAM,CAAA,GAAI,IAAI,eAAA,EAAgB;AAC9B,IAAA,IAAI,OAAO,MAAA,EAAQ,CAAA,CAAE,GAAA,CAAI,SAAA,EAAW,OAAO,MAAM,CAAA;AACjD,IAAA,IAAI,OAAO,MAAA,EAAQ,CAAA,CAAE,GAAA,CAAI,QAAA,EAAU,OAAO,MAAM,CAAA;AAChD,IAAA,IAAI,MAAA,CAAO,UAAU,MAAA,EAAW,CAAA,CAAE,IAAI,OAAA,EAAS,MAAA,CAAO,MAAA,CAAO,KAAK,CAAC,CAAA;AACnE,IAAA,IAAI,OAAO,IAAA,EAAM,CAAA,CAAE,GAAA,CAAI,MAAA,EAAQ,OAAO,IAAI,CAAA;AAC1C,IAAA,MAAM,EAAA,GAAK,EAAE,QAAA,EAAS;AACtB,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAAiB,CAAA,WAAA,EAAc,KAAK,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA,EAAI;AAAA,MACpE,QAAQ,MAAA,CAAO;AAAA,KAChB,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,OAAO,GAAA,CAAI,MAAA,GAA4C,EAAC,EAAgC;AACtF,IAAA,IAAI,MAAA;AACJ,IAAA,GAAG;AACD,MAAA,MAAM,IAAA,GAAO,MAAM,IAAA,CAAK,IAAA,CAAK,EAAE,GAAG,MAAA,EAAQ,QAAQ,CAAA;AAClD,MAAA,OAAO,IAAA,CAAK,KAAA;AACZ,MAAA,MAAA,GAAS,KAAK,WAAA,IAAe,MAAA;AAAA,IAC/B,CAAA,QAAS,MAAA;AAAA,EACX;AACF","file":"history.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * History resource — `client.history.*`: everything that happened to the\n * user's money in one list, newest first.\n *\n * ```ts\n * const page = await client.history.list({ limit: 30 });\n * const more = await client.history.list({ cursor: page.next_cursor! });\n * const oneCard = await client.history.list({ cardId: card.id });\n * for await (const item of client.history.all()) { … }\n * ```\n *\n * New kinds are added over time. Render an unknown `kind` from its `title`,\n * `amount`, `direction` and `status`; don't drop it.\n */\n\nexport type HistoryKind =\n | \"card_purchase\"\n | \"card_refund\"\n | \"card_issued\"\n | \"card_topup\"\n | \"card_transfer\"\n | \"wallet_deposit\"\n | \"deposit_refund\"\n | \"fee\"\n | \"balance_adjustment\"\n | \"bonus\"\n // Any kind added later still type-checks.\n | (string & {});\n\nexport type HistoryStatus =\n \"completed\" | \"pending\" | \"declined\" | \"reversed\" | \"failed\" | (string & {});\n\nexport interface HistoryAmount {\n /** Decimal string, never negative; see `direction`. */\n amount: string;\n /** ISO 4217 code. */\n currency: string;\n}\n\nexport interface HistoryCard {\n id: string;\n name: string | null;\n last4: string | null;\n}\n\nexport interface HistoryItem {\n /** Unique across kinds. */\n id: string;\n kind: HistoryKind;\n occurred_at: string;\n /** `pending` is not finished yet; `reversed` is an authorisation that was released. */\n status: HistoryStatus;\n /** `out` money left the user, `in` it came in, `internal` it moved between the wallet and the user's cards. */\n direction: \"out\" | \"in\" | \"internal\" | (string & {});\n /** The merchant, or what the operation was, in the language asked for. */\n title: string;\n /**\n * In the currency the operation happened in. For `bonus` the currency is\n * `BNS` and the amount is a number of bonuses, not money.\n */\n amount: HistoryAmount;\n /**\n * The other side of a conversion (what the card was billed, what the\n * wallet or card received). For a `bonus` spend: the part of the price\n * the bonuses covered, or what they added to a top-up.\n */\n counter_amount: HistoryAmount | null;\n /** Rate between `amount` and `counter_amount`, decimal string. */\n fx_rate: string | null;\n /** A fee charged with the operation, in the wallet's currency. */\n fee: HistoryAmount | null;\n /** The card; the source card of a transfer. */\n card: HistoryCard | null;\n /** The destination card of a transfer. */\n to_card: HistoryCard | null;\n merchant: { name: string | null; city: string | null; country: string | null } | null;\n /** On a declined payment: a stable code and the reason in plain words. */\n decline_reason: {\n code:\n | \"insufficient_funds\"\n | \"limit_exceeded\"\n | \"card_blocked\"\n | \"card_expired\"\n | \"wrong_details\"\n | \"merchant_not_allowed\"\n | \"other\"\n | (string & {});\n text: string;\n } | null;\n}\n\nexport interface HistoryPage {\n items: HistoryItem[];\n /** Pass as `cursor` for the next, older page; `null` on the last one. */\n next_cursor: string | null;\n}\n\nexport interface ListHistoryParams {\n /** Only this card's operations, transfers to and from it included. */\n cardId?: string;\n cursor?: string;\n /** 1 to 100, default 30. */\n limit?: number;\n /** `en` or `ru` for titles and decline reasons. Defaults to the browser's language header. */\n lang?: \"en\" | \"ru\";\n signal?: AbortSignal;\n}\n\nexport class HistoryResource {\n constructor(private readonly http: HttpClient) {}\n\n /** One page of the history. Errors: 400 bad cursor or limit, 404 `cardId` is not the user's card. */\n async list(params: ListHistoryParams = {}): Promise<HistoryPage> {\n const q = new URLSearchParams();\n if (params.cardId) q.set(\"card_id\", params.cardId);\n if (params.cursor) q.set(\"cursor\", params.cursor);\n if (params.limit !== undefined) q.set(\"limit\", String(params.limit));\n if (params.lang) q.set(\"lang\", params.lang);\n const qs = q.toString();\n return this.http.get<HistoryPage>(`/me/history${qs ? `?${qs}` : \"\"}`, {\n signal: params.signal,\n });\n }\n\n /** Every entry, page after page, newest first. */\n async *all(params: Omit<ListHistoryParams, \"cursor\"> = {}): AsyncGenerator<HistoryItem> {\n let cursor: string | undefined;\n do {\n const page = await this.list({ ...params, cursor });\n yield* page.items;\n cursor = page.next_cursor ?? undefined;\n } while (cursor);\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/resources/history.ts"],"names":[],"mappings":";AAyHO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,IAAA,CAAK,MAAA,GAA4B,EAAC,EAAyB;AAC/D,IAAA,MAAM,CAAA,GAAI,IAAI,eAAA,EAAgB;AAC9B,IAAA,IAAI,OAAO,MAAA,EAAQ,CAAA,CAAE,GAAA,CAAI,SAAA,EAAW,OAAO,MAAM,CAAA;AACjD,IAAA,IAAI,OAAO,MAAA,EAAQ,CAAA,CAAE,GAAA,CAAI,QAAA,EAAU,OAAO,MAAM,CAAA;AAChD,IAAA,IAAI,MAAA,CAAO,UAAU,MAAA,EAAW,CAAA,CAAE,IAAI,OAAA,EAAS,MAAA,CAAO,MAAA,CAAO,KAAK,CAAC,CAAA;AACnE,IAAA,IAAI,OAAO,IAAA,EAAM,CAAA,CAAE,GAAA,CAAI,MAAA,EAAQ,OAAO,IAAI,CAAA;AAC1C,IAAA,MAAM,EAAA,GAAK,EAAE,QAAA,EAAS;AACtB,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAAiB,CAAA,WAAA,EAAc,KAAK,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA,EAAI;AAAA,MACpE,QAAQ,MAAA,CAAO;AAAA,KAChB,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,OAAO,GAAA,CAAI,MAAA,GAA4C,EAAC,EAAgC;AACtF,IAAA,IAAI,MAAA;AACJ,IAAA,GAAG;AACD,MAAA,MAAM,IAAA,GAAO,MAAM,IAAA,CAAK,IAAA,CAAK,EAAE,GAAG,MAAA,EAAQ,QAAQ,CAAA;AAClD,MAAA,OAAO,IAAA,CAAK,KAAA;AACZ,MAAA,MAAA,GAAS,KAAK,WAAA,IAAe,MAAA;AAAA,IAC/B,CAAA,QAAS,MAAA;AAAA,EACX;AACF","file":"history.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * History resource — `client.history.*`: everything that happened to the\n * user's money in one list, newest first.\n *\n * ```ts\n * const page = await client.history.list({ limit: 30 });\n * const more = await client.history.list({ cursor: page.next_cursor! });\n * const oneCard = await client.history.list({ cardId: card.id });\n * for await (const item of client.history.all()) { … }\n * ```\n *\n * New kinds are added over time. Render an unknown `kind` from its `title`,\n * `amount`, `direction` and `status`; don't drop it.\n */\n\nexport type HistoryKind =\n | \"card_purchase\"\n | \"card_refund\"\n | \"card_issued\"\n | \"card_topup\"\n | \"card_transfer\"\n | \"wallet_deposit\"\n | \"deposit_refund\"\n | \"fee\"\n | \"balance_adjustment\"\n | \"bonus\"\n /**\n * What was left on a closed card moving to the card that replaced it:\n * `card` is the old card, `to_card` the new one. `pending` until the\n * issuer returns the money and it is on the new card. If the new card\n * could not take it, the money went to the wallet and `title` says so.\n */\n | \"closed_card_balance\"\n /** A fee for using the card: a payment, a declined payment, a cash withdrawal. */\n | \"card_fee\"\n /** Money that paid card fees owed. */\n | \"debt_payment\"\n // Any kind added later still type-checks.\n | (string & {});\n\nexport type HistoryStatus =\n \"completed\" | \"pending\" | \"declined\" | \"reversed\" | \"failed\" | (string & {});\n\nexport interface HistoryAmount {\n /** Decimal string, never negative; see `direction`. */\n amount: string;\n /** ISO 4217 code. */\n currency: string;\n}\n\nexport interface HistoryCard {\n id: string;\n name: string | null;\n last4: string | null;\n}\n\nexport interface HistoryItem {\n /** Unique across kinds. */\n id: string;\n kind: HistoryKind;\n occurred_at: string;\n /** `pending` is not finished yet; `reversed` is an authorisation that was released. */\n status: HistoryStatus;\n /** `out` money left the user, `in` it came in, `internal` it moved between the wallet and the user's cards. */\n direction: \"out\" | \"in\" | \"internal\" | (string & {});\n /** The merchant, or what the operation was, in the language asked for. */\n title: string;\n /**\n * In the currency the operation happened in. For `bonus` the currency is\n * `BNS` and the amount is a number of bonuses, not money.\n */\n amount: HistoryAmount;\n /**\n * The other side of a conversion (what the card was billed, what the\n * wallet or card received). For a `bonus` spend: the part of the price\n * the bonuses covered, or what they added to a top-up.\n */\n counter_amount: HistoryAmount | null;\n /** Rate between `amount` and `counter_amount`, decimal string. */\n fx_rate: string | null;\n /** A fee charged with the operation, in the wallet's currency. */\n fee: HistoryAmount | null;\n /** The card; the source card of a transfer. */\n card: HistoryCard | null;\n /** The destination card of a transfer. */\n to_card: HistoryCard | null;\n merchant: { name: string | null; city: string | null; country: string | null } | null;\n /** On a declined payment: a stable code and the reason in plain words. */\n decline_reason: {\n code:\n | \"insufficient_funds\"\n | \"limit_exceeded\"\n | \"card_blocked\"\n | \"card_expired\"\n | \"wrong_details\"\n | \"merchant_not_allowed\"\n | \"other\"\n | (string & {});\n text: string;\n } | null;\n}\n\nexport interface HistoryPage {\n items: HistoryItem[];\n /** Pass as `cursor` for the next, older page; `null` on the last one. */\n next_cursor: string | null;\n}\n\nexport interface ListHistoryParams {\n /** Only this card's operations, transfers to and from it included. */\n cardId?: string;\n cursor?: string;\n /** 1 to 100, default 30. */\n limit?: number;\n /** `en` or `ru` for titles and decline reasons. Defaults to the browser's language header. */\n lang?: \"en\" | \"ru\";\n signal?: AbortSignal;\n}\n\nexport class HistoryResource {\n constructor(private readonly http: HttpClient) {}\n\n /** One page of the history. Errors: 400 bad cursor or limit, 404 `cardId` is not the user's card. */\n async list(params: ListHistoryParams = {}): Promise<HistoryPage> {\n const q = new URLSearchParams();\n if (params.cardId) q.set(\"card_id\", params.cardId);\n if (params.cursor) q.set(\"cursor\", params.cursor);\n if (params.limit !== undefined) q.set(\"limit\", String(params.limit));\n if (params.lang) q.set(\"lang\", params.lang);\n const qs = q.toString();\n return this.http.get<HistoryPage>(`/me/history${qs ? `?${qs}` : \"\"}`, {\n signal: params.signal,\n });\n }\n\n /** Every entry, page after page, newest first. */\n async *all(params: Omit<ListHistoryParams, \"cursor\"> = {}): AsyncGenerator<HistoryItem> {\n let cursor: string | undefined;\n do {\n const page = await this.list({ ...params, cursor });\n yield* page.items;\n cursor = page.next_cursor ?? undefined;\n } while (cursor);\n }\n}\n"]}
@@ -3,7 +3,7 @@ import { User } from './auth.cjs';
3
3
  import './consents.cjs';
4
4
  import './attribution.cjs';
5
5
  import './codes.cjs';
6
- import '../cards-ofoGRU9v.cjs';
6
+ import '../cards-CEFKrVkl.cjs';
7
7
 
8
8
  /**
9
9
  * Me resource — `client.me.*`.
@@ -3,7 +3,7 @@ import { User } from './auth.js';
3
3
  import './consents.js';
4
4
  import './attribution.js';
5
5
  import './codes.js';
6
- import '../cards-BrqeBqLV.js';
6
+ import '../cards-ColpW52n.js';
7
7
 
8
8
  /**
9
9
  * Me resource — `client.me.*`.
package/dist/telegram.cjs CHANGED
@@ -183,6 +183,8 @@ var CardsResource = class {
183
183
  * `Card`. On a ledger failure after provider creation, the Takeal API rolls the row
184
184
  * to `failed` (never an orphaned active card); inspect `status` /
185
185
  * `failure_reason` on the result.
186
+ * Errors: 409 `holder_data_consent_required` when the product has
187
+ * `holder_data_required` and the user has not agreed to it.
186
188
  */
187
189
  async create(input) {
188
190
  const { idempotencyKey, ...card } = input;
@@ -198,7 +200,9 @@ var CardsResource = class {
198
200
  * `pending_payment` until the payment is confirmed. The same
199
201
  * `idempotencyKey` returns the same order.
200
202
  * Errors: 400 `unknown_product` / `method_not_available` / a limit of the
201
- * way of paying, 503 no funding connector or no exchange rate.
203
+ * way of paying, 409 `holder_data_consent_required` (the product has
204
+ * `holder_data_required` and the user has not agreed to it), 503 no
205
+ * funding connector or no exchange rate.
202
206
  */
203
207
  async order(input) {
204
208
  const { idempotencyKey, ...order } = input;
@@ -360,7 +364,10 @@ var CardsResource = class {
360
364
  /**
361
365
  * Terminate the caller's own card. **One-way** — a terminated card cannot be
362
366
  * reactivated. The optional `reason` is audited. Idempotent on an
363
- * already-terminated card.
367
+ * already-terminated card. A card that still holds money is refused (409
368
+ * `move_balance_first` or `contact_support_to_close`): close it with
369
+ * `client.closeRequests.request(id)` instead, and the money goes back the
370
+ * way it was paid.
364
371
  */
365
372
  async terminate(id, reason) {
366
373
  return this.http.post(`/me/cards/${encodeURIComponent(id)}/terminate`, {
@@ -727,6 +734,72 @@ var BonusResource = class {
727
734
  }
728
735
  };
729
736
 
737
+ // src/resources/debt.ts
738
+ var DebtResource = class {
739
+ constructor(http) {
740
+ this.http = http;
741
+ }
742
+ /** What the user owes in card fees, per currency, and what for. */
743
+ async get(opts = {}) {
744
+ return this.http.get("/me/debt", { signal: opts.signal });
745
+ }
746
+ /** What the user owes in `currency`, decimal string; `"0"` when nothing. */
747
+ async owedIn(currency, opts = {}) {
748
+ const debt = await this.get(opts);
749
+ const want = currency.trim().toUpperCase();
750
+ return debt.total.find((d) => d.currency.toUpperCase() === want)?.amount ?? "0";
751
+ }
752
+ };
753
+
754
+ // src/resources/close-requests.ts
755
+ var CloseRequestsResource = class {
756
+ constructor(http) {
757
+ this.http = http;
758
+ }
759
+ /**
760
+ * Close a card that holds money, the rest going back the way it was paid.
761
+ * Asking again for the same card returns the same request. 404 no such
762
+ * card · 409 {@link CloseRequestError}: `no_balance` means the card holds
763
+ * nothing, close it with `cards.terminate()` · 503 the issuer can't be
764
+ * reached; the card stays as it was.
765
+ */
766
+ async request(cardId, input = {}) {
767
+ return this.http.post(`/me/cards/${encodeURIComponent(cardId)}/close-request`, {
768
+ body: { reason: input.reason }
769
+ });
770
+ }
771
+ /** Every card close request of the user, newest first. */
772
+ async list(opts = {}) {
773
+ const res = await this.http.get("/me/close-requests", {
774
+ signal: opts.signal
775
+ });
776
+ return res.items;
777
+ }
778
+ /** One close request. 404 when it isn't the user's. */
779
+ async get(id, opts = {}) {
780
+ return this.http.get(`/me/close-requests/${encodeURIComponent(id)}`, {
781
+ signal: opts.signal
782
+ });
783
+ }
784
+ /** The request for this card, if the user made one. */
785
+ async forCard(cardId, opts = {}) {
786
+ const all = await this.list(opts);
787
+ return all.find((r) => r.card_id === cardId) ?? null;
788
+ }
789
+ /**
790
+ * Give a bank account or a card in the user's own name, when the request
791
+ * is `payout_details_required` (or `identity_check`, to correct them). 400
792
+ * `validation`: a name, number or bank code that doesn't look right · 409
793
+ * `details_not_needed`.
794
+ */
795
+ async submitPayoutDetails(id, details) {
796
+ return this.http.post(
797
+ `/me/close-requests/${encodeURIComponent(id)}/payout-details`,
798
+ { body: details }
799
+ );
800
+ }
801
+ };
802
+
730
803
  // src/resources/codes.ts
731
804
  var CodesResource = class {
732
805
  constructor(http) {
@@ -1241,6 +1314,8 @@ var HistoryResource = class {
1241
1314
  };
1242
1315
 
1243
1316
  // src/resources/consents.ts
1317
+ var HOLDER_DATA_CONSENT = "holder_data_transfer";
1318
+ var DISPUTE_DOCUMENTS_CONSENT = "dispute_documents_transfer";
1244
1319
  var ConsentsResource = class {
1245
1320
  constructor(http) {
1246
1321
  this.http = http;
@@ -1249,20 +1324,51 @@ var ConsentsResource = class {
1249
1324
  async get() {
1250
1325
  return this.http.get("/me/consents");
1251
1326
  }
1327
+ /** Whether `kind` stands now: given and not withdrawn since. */
1328
+ async stands(kind) {
1329
+ const { consents } = await this.get();
1330
+ return consents.some((c) => c.kind === kind && c.given);
1331
+ }
1252
1332
  /**
1253
- * Give (`true`) or withdraw (`false`) an optional consent: `marketing` or
1254
- * `cookies_analytics`. Withdrawing `marketing` turns advertising off in
1255
- * every channel at once; giving it turns on advertising by e-mail. A call
1256
- * that changes nothing records nothing.
1333
+ * Give (`true`) or withdraw (`false`) an optional consent: `marketing`,
1334
+ * `cookies_analytics`, `holder_data_transfer` or
1335
+ * `dispute_documents_transfer`. Withdrawing `marketing` turns advertising
1336
+ * off in every channel at once; giving it turns on advertising by e-mail.
1337
+ * Withdrawing `holder_data_transfer` leaves the user's cards alone and
1338
+ * stops new cards whose product has `holder_data_required`. A call that
1339
+ * changes nothing records nothing, unless it names a card.
1340
+ *
1341
+ * The third argument is the channel, or {@link ConsentOptions} with the
1342
+ * channel and the card.
1257
1343
  *
1258
1344
  * Errors: 400 `consent_required` for `terms` or `personal_data`,
1259
- * 400 `unknown_consent`.
1345
+ * 400 `unknown_consent`, 400 `card_not_allowed` (a card named with a kind
1346
+ * that takes none), 404 `not_found` (not one of the user's cards).
1260
1347
  */
1261
- async set(kind, given, channel) {
1348
+ async set(kind, given, options) {
1349
+ const opts = typeof options === "string" ? { channel: options } : options ?? {};
1262
1350
  const body = { kind, given };
1263
- if (channel !== void 0) body.channel = channel;
1351
+ if (opts.channel !== void 0) body.channel = opts.channel;
1352
+ if (opts.cardId !== void 0) body.card_id = opts.cardId;
1264
1353
  return this.http.post("/me/consents", { body });
1265
1354
  }
1355
+ /**
1356
+ * The user agreed on the consent screen that their real personal details
1357
+ * go to the card issuer (`holder_data_transfer`). Needed before ordering a
1358
+ * product with `holder_data_required`, unless the order itself carries the
1359
+ * kind in its `consents`.
1360
+ */
1361
+ async allowHolderData(options) {
1362
+ return this.set(HOLDER_DATA_CONSENT, true, options);
1363
+ }
1364
+ /**
1365
+ * The user agreed that their documents go to the card issuer for a
1366
+ * dispute (`dispute_documents_transfer`). Name the disputed card with
1367
+ * `cardId`; each call is then recorded on its own.
1368
+ */
1369
+ async allowDisputeDocuments(options) {
1370
+ return this.set(DISPUTE_DOCUMENTS_CONSENT, true, options);
1371
+ }
1266
1372
  /**
1267
1373
  * Record what the cookie banner or the cookie settings say about
1268
1374
  * analytics. Works signed in or not: before sign-in the choice is kept
@@ -1315,7 +1421,7 @@ var FundingOptionsResource = class {
1315
1421
  };
1316
1422
 
1317
1423
  // src/version.ts
1318
- var SDK_VERSION = "0.6.4";
1424
+ var SDK_VERSION = "0.6.5";
1319
1425
 
1320
1426
  // src/client-platform.ts
1321
1427
  var CLIENT_HEADER = "X-Takeal-Client";
@@ -1390,7 +1496,7 @@ function isAbsolute(url) {
1390
1496
  }
1391
1497
 
1392
1498
  // src/compat.ts
1393
- var SUPPORTED_MEISTER = ">=0.6.9, <0.7.0";
1499
+ var SUPPORTED_MEISTER = ">=0.6.11, <0.7.0";
1394
1500
  var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
1395
1501
  function parse(v) {
1396
1502
  const m = SEMVER.exec(v.trim());
@@ -1485,6 +1591,8 @@ function createClient(opts) {
1485
1591
  cards: new CardsResource(http),
1486
1592
  balance: new BalanceResource(http),
1487
1593
  bonus: new BonusResource(http),
1594
+ debt: new DebtResource(http),
1595
+ closeRequests: new CloseRequestsResource(http),
1488
1596
  codes: new CodesResource(http),
1489
1597
  referral: new ReferralResource(http),
1490
1598
  subscription: new SubscriptionResource(http),