@takeal/cusfront-sdk 0.6.4 → 0.6.6

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 (101) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +182 -3
  3. package/dist/{cards-ofoGRU9v.d.cts → cards-BiXmrz7h.d.cts} +126 -11
  4. package/dist/{cards-BrqeBqLV.d.ts → cards-DwmzjKDC.d.ts} +126 -11
  5. package/dist/{devices-B_YveTl9.d.ts → devices-C88c38hm.d.ts} +1 -1
  6. package/dist/{devices-a5Z45Mx_.d.cts → devices-CiJrlXum.d.cts} +1 -1
  7. package/dist/{http-DeANAoTs.d.cts → http-CL97TjMO.d.cts} +4 -0
  8. package/dist/{http-DeANAoTs.d.ts → http-CL97TjMO.d.ts} +4 -0
  9. package/dist/index.cjs +200 -15
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +22 -10
  12. package/dist/index.d.ts +22 -10
  13. package/dist/index.js +199 -16
  14. package/dist/index.js.map +1 -1
  15. package/dist/react/index.d.cts +6 -3
  16. package/dist/react/index.d.ts +6 -3
  17. package/dist/resources/attribution.d.cts +1 -1
  18. package/dist/resources/attribution.d.ts +1 -1
  19. package/dist/resources/auth.cjs.map +1 -1
  20. package/dist/resources/auth.d.cts +2 -2
  21. package/dist/resources/auth.d.ts +2 -2
  22. package/dist/resources/auth.js.map +1 -1
  23. package/dist/resources/balance.d.cts +1 -1
  24. package/dist/resources/balance.d.ts +1 -1
  25. package/dist/resources/blog.d.cts +1 -1
  26. package/dist/resources/blog.d.ts +1 -1
  27. package/dist/resources/bonus.d.cts +1 -1
  28. package/dist/resources/bonus.d.ts +1 -1
  29. package/dist/resources/branding.d.cts +1 -1
  30. package/dist/resources/branding.d.ts +1 -1
  31. package/dist/resources/cards.cjs +9 -2
  32. package/dist/resources/cards.cjs.map +1 -1
  33. package/dist/resources/cards.d.cts +2 -2
  34. package/dist/resources/cards.d.ts +2 -2
  35. package/dist/resources/cards.js +9 -2
  36. package/dist/resources/cards.js.map +1 -1
  37. package/dist/resources/close-requests.cjs +54 -0
  38. package/dist/resources/close-requests.cjs.map +1 -0
  39. package/dist/resources/close-requests.d.cts +155 -0
  40. package/dist/resources/close-requests.d.ts +155 -0
  41. package/dist/resources/close-requests.js +52 -0
  42. package/dist/resources/close-requests.js.map +1 -0
  43. package/dist/resources/codes.d.cts +1 -1
  44. package/dist/resources/codes.d.ts +1 -1
  45. package/dist/resources/consents.cjs +42 -7
  46. package/dist/resources/consents.cjs.map +1 -1
  47. package/dist/resources/consents.d.cts +59 -9
  48. package/dist/resources/consents.d.ts +59 -9
  49. package/dist/resources/consents.js +41 -8
  50. package/dist/resources/consents.js.map +1 -1
  51. package/dist/resources/debt.cjs +22 -0
  52. package/dist/resources/debt.cjs.map +1 -0
  53. package/dist/resources/debt.d.cts +76 -0
  54. package/dist/resources/debt.d.ts +76 -0
  55. package/dist/resources/debt.js +20 -0
  56. package/dist/resources/debt.js.map +1 -0
  57. package/dist/resources/deposits.cjs.map +1 -1
  58. package/dist/resources/deposits.d.cts +2 -2
  59. package/dist/resources/deposits.d.ts +2 -2
  60. package/dist/resources/deposits.js.map +1 -1
  61. package/dist/resources/devices.d.cts +2 -2
  62. package/dist/resources/devices.d.ts +2 -2
  63. package/dist/resources/documents.d.cts +1 -1
  64. package/dist/resources/documents.d.ts +1 -1
  65. package/dist/resources/funding-options.d.cts +2 -2
  66. package/dist/resources/funding-options.d.ts +2 -2
  67. package/dist/resources/history.cjs.map +1 -1
  68. package/dist/resources/history.d.cts +13 -2
  69. package/dist/resources/history.d.ts +13 -2
  70. package/dist/resources/history.js.map +1 -1
  71. package/dist/resources/me.d.cts +2 -2
  72. package/dist/resources/me.d.ts +2 -2
  73. package/dist/resources/notifications.d.cts +1 -1
  74. package/dist/resources/notifications.d.ts +1 -1
  75. package/dist/resources/push.d.cts +1 -1
  76. package/dist/resources/push.d.ts +1 -1
  77. package/dist/resources/receipts.d.cts +1 -1
  78. package/dist/resources/receipts.d.ts +1 -1
  79. package/dist/resources/referral.d.cts +1 -1
  80. package/dist/resources/referral.d.ts +1 -1
  81. package/dist/resources/sessions.d.cts +1 -1
  82. package/dist/resources/sessions.d.ts +1 -1
  83. package/dist/resources/subscription.d.cts +1 -1
  84. package/dist/resources/subscription.d.ts +1 -1
  85. package/dist/resources/subscriptions.d.cts +1 -1
  86. package/dist/resources/subscriptions.d.ts +1 -1
  87. package/dist/resources/support.cjs +69 -0
  88. package/dist/resources/support.cjs.map +1 -0
  89. package/dist/resources/support.d.cts +110 -0
  90. package/dist/resources/support.d.ts +110 -0
  91. package/dist/resources/support.js +67 -0
  92. package/dist/resources/support.js.map +1 -0
  93. package/dist/resources/wallet.d.cts +1 -1
  94. package/dist/resources/wallet.d.ts +1 -1
  95. package/dist/telegram.cjs +198 -15
  96. package/dist/telegram.cjs.map +1 -1
  97. package/dist/telegram.d.cts +6 -3
  98. package/dist/telegram.d.ts +6 -3
  99. package/dist/telegram.js +198 -15
  100. package/dist/telegram.js.map +1 -1
  101. package/package.json +16 -1
@@ -1,3 +1,3 @@
1
- import '../http-DeANAoTs.js';
2
- export { z as DepositTarget, G as FunderMode, H as FundingOption, F as FundingOptionsResource, M as MethodTerms } from '../cards-BrqeBqLV.js';
1
+ import '../http-CL97TjMO.js';
2
+ export { G as DepositTarget, I as FunderMode, J as FundingOption, F as FundingOptionsResource, O as MethodTerms } from '../cards-DwmzjKDC.js';
3
3
  import './consents.js';
@@ -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"]}
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-DeANAoTs.cjs';
1
+ import { H as HttpClient } from '../http-CL97TjMO.cjs';
2
2
 
3
3
  /**
4
4
  * History resource — `client.history.*`: everything that happened to the
@@ -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`. */
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-DeANAoTs.js';
1
+ import { H as HttpClient } from '../http-CL97TjMO.js';
2
2
 
3
3
  /**
4
4
  * History resource — `client.history.*`: everything that happened to the
@@ -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"]}
@@ -1,9 +1,9 @@
1
- import { H as HttpClient } from '../http-DeANAoTs.cjs';
1
+ import { H as HttpClient } from '../http-CL97TjMO.cjs';
2
2
  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-BiXmrz7h.cjs';
7
7
 
8
8
  /**
9
9
  * Me resource — `client.me.*`.
@@ -1,9 +1,9 @@
1
- import { H as HttpClient } from '../http-DeANAoTs.js';
1
+ import { H as HttpClient } from '../http-CL97TjMO.js';
2
2
  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-DwmzjKDC.js';
7
7
 
8
8
  /**
9
9
  * Me resource — `client.me.*`.
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-DeANAoTs.cjs';
1
+ import { H as HttpClient } from '../http-CL97TjMO.cjs';
2
2
 
3
3
  /**
4
4
  * Notifications resource — `client.notifications.*`.
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-DeANAoTs.js';
1
+ import { H as HttpClient } from '../http-CL97TjMO.js';
2
2
 
3
3
  /**
4
4
  * Notifications resource — `client.notifications.*`.
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-DeANAoTs.cjs';
1
+ import { H as HttpClient } from '../http-CL97TjMO.cjs';
2
2
 
3
3
  /**
4
4
  * Push resource — `client.push.*`.
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-DeANAoTs.js';
1
+ import { H as HttpClient } from '../http-CL97TjMO.js';
2
2
 
3
3
  /**
4
4
  * Push resource — `client.push.*`.
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-DeANAoTs.cjs';
1
+ import { H as HttpClient } from '../http-CL97TjMO.cjs';
2
2
 
3
3
  /**
4
4
  * Receipts resource — `client.receipts.*`: one numbered receipt for every
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-DeANAoTs.js';
1
+ import { H as HttpClient } from '../http-CL97TjMO.js';
2
2
 
3
3
  /**
4
4
  * Receipts resource — `client.receipts.*`: one numbered receipt for every
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-DeANAoTs.cjs';
1
+ import { H as HttpClient } from '../http-CL97TjMO.cjs';
2
2
 
3
3
  /**
4
4
  * Referral resource — `client.referral.*`.
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-DeANAoTs.js';
1
+ import { H as HttpClient } from '../http-CL97TjMO.js';
2
2
 
3
3
  /**
4
4
  * Referral resource — `client.referral.*`.
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-DeANAoTs.cjs';
1
+ import { H as HttpClient } from '../http-CL97TjMO.cjs';
2
2
 
3
3
  /**
4
4
  * Sessions resource — `client.sessions.*`.
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-DeANAoTs.js';
1
+ import { H as HttpClient } from '../http-CL97TjMO.js';
2
2
 
3
3
  /**
4
4
  * Sessions resource — `client.sessions.*`.
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-DeANAoTs.cjs';
1
+ import { H as HttpClient } from '../http-CL97TjMO.cjs';
2
2
 
3
3
  /**
4
4
  * Subscription resource — `client.subscription.*`.
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-DeANAoTs.js';
1
+ import { H as HttpClient } from '../http-CL97TjMO.js';
2
2
 
3
3
  /**
4
4
  * Subscription resource — `client.subscription.*`.
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-DeANAoTs.cjs';
1
+ import { H as HttpClient } from '../http-CL97TjMO.cjs';
2
2
 
3
3
  /**
4
4
  * Subscriptions resource — `client.subscriptions.*`.
@@ -1,4 +1,4 @@
1
- import { H as HttpClient } from '../http-DeANAoTs.js';
1
+ import { H as HttpClient } from '../http-CL97TjMO.js';
2
2
 
3
3
  /**
4
4
  * Subscriptions resource — `client.subscriptions.*`.
@@ -0,0 +1,69 @@
1
+ 'use strict';
2
+
3
+ // src/resources/support.ts
4
+ function bytesToBase64(bytes) {
5
+ let binary = "";
6
+ const chunk = 32768;
7
+ for (let i = 0; i < bytes.length; i += chunk) {
8
+ binary += String.fromCharCode(...bytes.subarray(i, i + chunk));
9
+ }
10
+ return btoa(binary);
11
+ }
12
+ async function toBase64(data) {
13
+ if (typeof data === "string") return data;
14
+ if (data instanceof Uint8Array) return bytesToBase64(data);
15
+ if (data instanceof ArrayBuffer) return bytesToBase64(new Uint8Array(data));
16
+ return bytesToBase64(new Uint8Array(await data.arrayBuffer()));
17
+ }
18
+ var SupportResource = class {
19
+ constructor(http) {
20
+ this.http = http;
21
+ }
22
+ /** The latest messages, oldest first, and the conversation's status.
23
+ * `before` reads further back; `limit` is 1 to 100 (50). */
24
+ async list(opts = {}) {
25
+ const q = new URLSearchParams();
26
+ if (opts.before) q.set("before", opts.before);
27
+ if (opts.limit !== void 0) q.set("limit", String(opts.limit));
28
+ const qs = q.toString();
29
+ return this.http.get(`/me/support/messages${qs ? `?${qs}` : ""}`, {
30
+ signal: opts.signal
31
+ });
32
+ }
33
+ /** Write to support. Text, files or both; up to 10 files. */
34
+ async send(message, opts = {}) {
35
+ const attachments = await Promise.all(
36
+ (message.files ?? []).map(async (f) => ({
37
+ file_name: f.fileName,
38
+ content_type: f.contentType,
39
+ data_base64: await toBase64(f.data)
40
+ }))
41
+ );
42
+ return this.http.post("/me/support/messages", {
43
+ body: { text: message.text ?? "", attachments },
44
+ signal: opts.signal
45
+ });
46
+ }
47
+ /** A file from the conversation: the person's own or one support sent. */
48
+ async attachment(id, opts = {}) {
49
+ return this.http.getBlob(`/me/support/attachments/${encodeURIComponent(id)}`, {
50
+ signal: opts.signal
51
+ });
52
+ }
53
+ /** Answer `rating_request`: 1 (bad) to 5 (great), a comment if the person
54
+ * wrote one. Each question takes one answer; a second one is a 404. */
55
+ async rate(id, answer, opts = {}) {
56
+ await this.http.post(`/me/support/ratings/${encodeURIComponent(id)}`, {
57
+ body: { rating: answer.rating, ...answer.comment ? { comment: answer.comment } : {} },
58
+ signal: opts.signal
59
+ });
60
+ }
61
+ /** Just the conversation's status. */
62
+ async status(opts = {}) {
63
+ return (await this.list({ limit: 1, signal: opts.signal })).status;
64
+ }
65
+ };
66
+
67
+ exports.SupportResource = SupportResource;
68
+ //# sourceMappingURL=support.cjs.map
69
+ //# sourceMappingURL=support.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/resources/support.ts"],"names":[],"mappings":"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","file":"support.cjs","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Support resource — `client.support.*`: the chat with support.\n *\n * GET /me/support/messages → list\n * POST /me/support/messages → send\n * GET /me/support/attachments/{id} → attachment\n * POST /me/support/ratings/{id} → rate\n *\n * What the person writes shows in the conversation at once, with the status\n * `queued`, and goes to support right after (`delivered`). Support answers\n * come back in the same conversation, with the text ready as cleaned HTML in\n * `html`: show it as it is, it carries only paragraphs, line breaks, bold,\n * italic, strikethrough, code, links, lists and quotes. A new answer also\n * comes as a `support_reply` notification.\n *\n * The person may write from the Telegram bot too; it is one conversation,\n * and `channel` says where each message came from.\n */\n\n/** Where a message came from, or where an answer was sent. */\nexport type SupportChannel = \"cabinet\" | \"telegram\" | (string & {});\n\n/** How far a message got: `queued` until support has it. */\nexport type SupportMessageStatus = \"queued\" | \"delivered\" | \"failed\" | (string & {});\n\n/** The conversation's state: `none` until the person writes for the first\n * time, `resolved` once support closed it. Writing again reopens it. */\nexport type SupportConversationStatus = \"none\" | \"open\" | \"resolved\" | (string & {});\n\n/** A file in the conversation. Download it with `attachment(id)`. */\nexport interface SupportAttachment {\n id: string;\n file_name: string;\n content_type: string;\n /** Bytes. */\n size: number;\n}\n\n/** One message. */\nexport interface SupportMessage {\n id: string;\n /** `user` for what the person wrote, `support` for an answer. */\n author: \"user\" | \"support\" | (string & {});\n /** The name the support agent goes by; answers only. */\n operator_name: string | null;\n channel: SupportChannel | null;\n /** What the person wrote, plain text. Empty on answers. */\n text: string;\n /** The answer as cleaned HTML. Empty on the person's own messages. */\n html: string;\n attachments: SupportAttachment[];\n status: SupportMessageStatus;\n created_at: string;\n}\n\n/** Support closed the conversation and asks how it went. */\nexport interface SupportRatingRequest {\n id: string;\n asked_at: string;\n}\n\n/** A page of the conversation, oldest first. */\nexport interface SupportConversation {\n status: SupportConversationStatus;\n items: SupportMessage[];\n /** Older messages exist: `list({ before: items[0].created_at })`. */\n has_more: boolean;\n /** Show a 1–5 rating when set; answer with `rate()`. `null` otherwise. */\n rating_request: SupportRatingRequest | null;\n}\n\n/** A file to send. `data` may be a `Blob` (a `File` from an input), bytes,\n * or base64 already. */\nexport interface SupportFile {\n fileName: string;\n /** E.g. `image/png`. Pictures and PDF up to 20 MB by default; the platform\n * sets the list and the size. */\n contentType: string;\n data: Blob | ArrayBuffer | Uint8Array | string;\n}\n\nfunction bytesToBase64(bytes: Uint8Array): string {\n let binary = \"\";\n const chunk = 0x8000;\n for (let i = 0; i < bytes.length; i += chunk) {\n binary += String.fromCharCode(...bytes.subarray(i, i + chunk));\n }\n return btoa(binary);\n}\n\nasync function toBase64(data: SupportFile[\"data\"]): Promise<string> {\n if (typeof data === \"string\") return data;\n if (data instanceof Uint8Array) return bytesToBase64(data);\n if (data instanceof ArrayBuffer) return bytesToBase64(new Uint8Array(data));\n return bytesToBase64(new Uint8Array(await data.arrayBuffer()));\n}\n\nexport class SupportResource {\n constructor(private readonly http: HttpClient) {}\n\n /** The latest messages, oldest first, and the conversation's status.\n * `before` reads further back; `limit` is 1 to 100 (50). */\n async list(\n opts: { before?: string; limit?: number; signal?: AbortSignal } = {},\n ): Promise<SupportConversation> {\n const q = new URLSearchParams();\n if (opts.before) q.set(\"before\", opts.before);\n if (opts.limit !== undefined) q.set(\"limit\", String(opts.limit));\n const qs = q.toString();\n return this.http.get<SupportConversation>(`/me/support/messages${qs ? `?${qs}` : \"\"}`, {\n signal: opts.signal,\n });\n }\n\n /** Write to support. Text, files or both; up to 10 files. */\n async send(\n message: { text?: string; files?: SupportFile[] },\n opts: { signal?: AbortSignal } = {},\n ): Promise<SupportMessage> {\n const attachments = await Promise.all(\n (message.files ?? []).map(async (f) => ({\n file_name: f.fileName,\n content_type: f.contentType,\n data_base64: await toBase64(f.data),\n })),\n );\n return this.http.post<SupportMessage>(\"/me/support/messages\", {\n body: { text: message.text ?? \"\", attachments },\n signal: opts.signal,\n });\n }\n\n /** A file from the conversation: the person's own or one support sent. */\n async attachment(id: string, opts: { signal?: AbortSignal } = {}): Promise<Blob> {\n return this.http.getBlob(`/me/support/attachments/${encodeURIComponent(id)}`, {\n signal: opts.signal,\n });\n }\n\n /** Answer `rating_request`: 1 (bad) to 5 (great), a comment if the person\n * wrote one. Each question takes one answer; a second one is a 404. */\n async rate(\n id: string,\n answer: { rating: 1 | 2 | 3 | 4 | 5; comment?: string },\n opts: { signal?: AbortSignal } = {},\n ): Promise<void> {\n await this.http.post<void>(`/me/support/ratings/${encodeURIComponent(id)}`, {\n body: { rating: answer.rating, ...(answer.comment ? { comment: answer.comment } : {}) },\n signal: opts.signal,\n });\n }\n\n /** Just the conversation's status. */\n async status(opts: { signal?: AbortSignal } = {}): Promise<SupportConversationStatus> {\n return (await this.list({ limit: 1, signal: opts.signal })).status;\n }\n}\n"]}
@@ -0,0 +1,110 @@
1
+ import { H as HttpClient } from '../http-CL97TjMO.cjs';
2
+
3
+ /**
4
+ * Support resource — `client.support.*`: the chat with support.
5
+ *
6
+ * GET /me/support/messages → list
7
+ * POST /me/support/messages → send
8
+ * GET /me/support/attachments/{id} → attachment
9
+ * POST /me/support/ratings/{id} → rate
10
+ *
11
+ * What the person writes shows in the conversation at once, with the status
12
+ * `queued`, and goes to support right after (`delivered`). Support answers
13
+ * come back in the same conversation, with the text ready as cleaned HTML in
14
+ * `html`: show it as it is, it carries only paragraphs, line breaks, bold,
15
+ * italic, strikethrough, code, links, lists and quotes. A new answer also
16
+ * comes as a `support_reply` notification.
17
+ *
18
+ * The person may write from the Telegram bot too; it is one conversation,
19
+ * and `channel` says where each message came from.
20
+ */
21
+ /** Where a message came from, or where an answer was sent. */
22
+ type SupportChannel = "cabinet" | "telegram" | (string & {});
23
+ /** How far a message got: `queued` until support has it. */
24
+ type SupportMessageStatus = "queued" | "delivered" | "failed" | (string & {});
25
+ /** The conversation's state: `none` until the person writes for the first
26
+ * time, `resolved` once support closed it. Writing again reopens it. */
27
+ type SupportConversationStatus = "none" | "open" | "resolved" | (string & {});
28
+ /** A file in the conversation. Download it with `attachment(id)`. */
29
+ interface SupportAttachment {
30
+ id: string;
31
+ file_name: string;
32
+ content_type: string;
33
+ /** Bytes. */
34
+ size: number;
35
+ }
36
+ /** One message. */
37
+ interface SupportMessage {
38
+ id: string;
39
+ /** `user` for what the person wrote, `support` for an answer. */
40
+ author: "user" | "support" | (string & {});
41
+ /** The name the support agent goes by; answers only. */
42
+ operator_name: string | null;
43
+ channel: SupportChannel | null;
44
+ /** What the person wrote, plain text. Empty on answers. */
45
+ text: string;
46
+ /** The answer as cleaned HTML. Empty on the person's own messages. */
47
+ html: string;
48
+ attachments: SupportAttachment[];
49
+ status: SupportMessageStatus;
50
+ created_at: string;
51
+ }
52
+ /** Support closed the conversation and asks how it went. */
53
+ interface SupportRatingRequest {
54
+ id: string;
55
+ asked_at: string;
56
+ }
57
+ /** A page of the conversation, oldest first. */
58
+ interface SupportConversation {
59
+ status: SupportConversationStatus;
60
+ items: SupportMessage[];
61
+ /** Older messages exist: `list({ before: items[0].created_at })`. */
62
+ has_more: boolean;
63
+ /** Show a 1–5 rating when set; answer with `rate()`. `null` otherwise. */
64
+ rating_request: SupportRatingRequest | null;
65
+ }
66
+ /** A file to send. `data` may be a `Blob` (a `File` from an input), bytes,
67
+ * or base64 already. */
68
+ interface SupportFile {
69
+ fileName: string;
70
+ /** E.g. `image/png`. Pictures and PDF up to 20 MB by default; the platform
71
+ * sets the list and the size. */
72
+ contentType: string;
73
+ data: Blob | ArrayBuffer | Uint8Array | string;
74
+ }
75
+ declare class SupportResource {
76
+ private readonly http;
77
+ constructor(http: HttpClient);
78
+ /** The latest messages, oldest first, and the conversation's status.
79
+ * `before` reads further back; `limit` is 1 to 100 (50). */
80
+ list(opts?: {
81
+ before?: string;
82
+ limit?: number;
83
+ signal?: AbortSignal;
84
+ }): Promise<SupportConversation>;
85
+ /** Write to support. Text, files or both; up to 10 files. */
86
+ send(message: {
87
+ text?: string;
88
+ files?: SupportFile[];
89
+ }, opts?: {
90
+ signal?: AbortSignal;
91
+ }): Promise<SupportMessage>;
92
+ /** A file from the conversation: the person's own or one support sent. */
93
+ attachment(id: string, opts?: {
94
+ signal?: AbortSignal;
95
+ }): Promise<Blob>;
96
+ /** Answer `rating_request`: 1 (bad) to 5 (great), a comment if the person
97
+ * wrote one. Each question takes one answer; a second one is a 404. */
98
+ rate(id: string, answer: {
99
+ rating: 1 | 2 | 3 | 4 | 5;
100
+ comment?: string;
101
+ }, opts?: {
102
+ signal?: AbortSignal;
103
+ }): Promise<void>;
104
+ /** Just the conversation's status. */
105
+ status(opts?: {
106
+ signal?: AbortSignal;
107
+ }): Promise<SupportConversationStatus>;
108
+ }
109
+
110
+ export { type SupportAttachment, type SupportChannel, type SupportConversation, type SupportConversationStatus, type SupportFile, type SupportMessage, type SupportMessageStatus, type SupportRatingRequest, SupportResource };
@@ -0,0 +1,110 @@
1
+ import { H as HttpClient } from '../http-CL97TjMO.js';
2
+
3
+ /**
4
+ * Support resource — `client.support.*`: the chat with support.
5
+ *
6
+ * GET /me/support/messages → list
7
+ * POST /me/support/messages → send
8
+ * GET /me/support/attachments/{id} → attachment
9
+ * POST /me/support/ratings/{id} → rate
10
+ *
11
+ * What the person writes shows in the conversation at once, with the status
12
+ * `queued`, and goes to support right after (`delivered`). Support answers
13
+ * come back in the same conversation, with the text ready as cleaned HTML in
14
+ * `html`: show it as it is, it carries only paragraphs, line breaks, bold,
15
+ * italic, strikethrough, code, links, lists and quotes. A new answer also
16
+ * comes as a `support_reply` notification.
17
+ *
18
+ * The person may write from the Telegram bot too; it is one conversation,
19
+ * and `channel` says where each message came from.
20
+ */
21
+ /** Where a message came from, or where an answer was sent. */
22
+ type SupportChannel = "cabinet" | "telegram" | (string & {});
23
+ /** How far a message got: `queued` until support has it. */
24
+ type SupportMessageStatus = "queued" | "delivered" | "failed" | (string & {});
25
+ /** The conversation's state: `none` until the person writes for the first
26
+ * time, `resolved` once support closed it. Writing again reopens it. */
27
+ type SupportConversationStatus = "none" | "open" | "resolved" | (string & {});
28
+ /** A file in the conversation. Download it with `attachment(id)`. */
29
+ interface SupportAttachment {
30
+ id: string;
31
+ file_name: string;
32
+ content_type: string;
33
+ /** Bytes. */
34
+ size: number;
35
+ }
36
+ /** One message. */
37
+ interface SupportMessage {
38
+ id: string;
39
+ /** `user` for what the person wrote, `support` for an answer. */
40
+ author: "user" | "support" | (string & {});
41
+ /** The name the support agent goes by; answers only. */
42
+ operator_name: string | null;
43
+ channel: SupportChannel | null;
44
+ /** What the person wrote, plain text. Empty on answers. */
45
+ text: string;
46
+ /** The answer as cleaned HTML. Empty on the person's own messages. */
47
+ html: string;
48
+ attachments: SupportAttachment[];
49
+ status: SupportMessageStatus;
50
+ created_at: string;
51
+ }
52
+ /** Support closed the conversation and asks how it went. */
53
+ interface SupportRatingRequest {
54
+ id: string;
55
+ asked_at: string;
56
+ }
57
+ /** A page of the conversation, oldest first. */
58
+ interface SupportConversation {
59
+ status: SupportConversationStatus;
60
+ items: SupportMessage[];
61
+ /** Older messages exist: `list({ before: items[0].created_at })`. */
62
+ has_more: boolean;
63
+ /** Show a 1–5 rating when set; answer with `rate()`. `null` otherwise. */
64
+ rating_request: SupportRatingRequest | null;
65
+ }
66
+ /** A file to send. `data` may be a `Blob` (a `File` from an input), bytes,
67
+ * or base64 already. */
68
+ interface SupportFile {
69
+ fileName: string;
70
+ /** E.g. `image/png`. Pictures and PDF up to 20 MB by default; the platform
71
+ * sets the list and the size. */
72
+ contentType: string;
73
+ data: Blob | ArrayBuffer | Uint8Array | string;
74
+ }
75
+ declare class SupportResource {
76
+ private readonly http;
77
+ constructor(http: HttpClient);
78
+ /** The latest messages, oldest first, and the conversation's status.
79
+ * `before` reads further back; `limit` is 1 to 100 (50). */
80
+ list(opts?: {
81
+ before?: string;
82
+ limit?: number;
83
+ signal?: AbortSignal;
84
+ }): Promise<SupportConversation>;
85
+ /** Write to support. Text, files or both; up to 10 files. */
86
+ send(message: {
87
+ text?: string;
88
+ files?: SupportFile[];
89
+ }, opts?: {
90
+ signal?: AbortSignal;
91
+ }): Promise<SupportMessage>;
92
+ /** A file from the conversation: the person's own or one support sent. */
93
+ attachment(id: string, opts?: {
94
+ signal?: AbortSignal;
95
+ }): Promise<Blob>;
96
+ /** Answer `rating_request`: 1 (bad) to 5 (great), a comment if the person
97
+ * wrote one. Each question takes one answer; a second one is a 404. */
98
+ rate(id: string, answer: {
99
+ rating: 1 | 2 | 3 | 4 | 5;
100
+ comment?: string;
101
+ }, opts?: {
102
+ signal?: AbortSignal;
103
+ }): Promise<void>;
104
+ /** Just the conversation's status. */
105
+ status(opts?: {
106
+ signal?: AbortSignal;
107
+ }): Promise<SupportConversationStatus>;
108
+ }
109
+
110
+ export { type SupportAttachment, type SupportChannel, type SupportConversation, type SupportConversationStatus, type SupportFile, type SupportMessage, type SupportMessageStatus, type SupportRatingRequest, SupportResource };
@@ -0,0 +1,67 @@
1
+ // src/resources/support.ts
2
+ function bytesToBase64(bytes) {
3
+ let binary = "";
4
+ const chunk = 32768;
5
+ for (let i = 0; i < bytes.length; i += chunk) {
6
+ binary += String.fromCharCode(...bytes.subarray(i, i + chunk));
7
+ }
8
+ return btoa(binary);
9
+ }
10
+ async function toBase64(data) {
11
+ if (typeof data === "string") return data;
12
+ if (data instanceof Uint8Array) return bytesToBase64(data);
13
+ if (data instanceof ArrayBuffer) return bytesToBase64(new Uint8Array(data));
14
+ return bytesToBase64(new Uint8Array(await data.arrayBuffer()));
15
+ }
16
+ var SupportResource = class {
17
+ constructor(http) {
18
+ this.http = http;
19
+ }
20
+ /** The latest messages, oldest first, and the conversation's status.
21
+ * `before` reads further back; `limit` is 1 to 100 (50). */
22
+ async list(opts = {}) {
23
+ const q = new URLSearchParams();
24
+ if (opts.before) q.set("before", opts.before);
25
+ if (opts.limit !== void 0) q.set("limit", String(opts.limit));
26
+ const qs = q.toString();
27
+ return this.http.get(`/me/support/messages${qs ? `?${qs}` : ""}`, {
28
+ signal: opts.signal
29
+ });
30
+ }
31
+ /** Write to support. Text, files or both; up to 10 files. */
32
+ async send(message, opts = {}) {
33
+ const attachments = await Promise.all(
34
+ (message.files ?? []).map(async (f) => ({
35
+ file_name: f.fileName,
36
+ content_type: f.contentType,
37
+ data_base64: await toBase64(f.data)
38
+ }))
39
+ );
40
+ return this.http.post("/me/support/messages", {
41
+ body: { text: message.text ?? "", attachments },
42
+ signal: opts.signal
43
+ });
44
+ }
45
+ /** A file from the conversation: the person's own or one support sent. */
46
+ async attachment(id, opts = {}) {
47
+ return this.http.getBlob(`/me/support/attachments/${encodeURIComponent(id)}`, {
48
+ signal: opts.signal
49
+ });
50
+ }
51
+ /** Answer `rating_request`: 1 (bad) to 5 (great), a comment if the person
52
+ * wrote one. Each question takes one answer; a second one is a 404. */
53
+ async rate(id, answer, opts = {}) {
54
+ await this.http.post(`/me/support/ratings/${encodeURIComponent(id)}`, {
55
+ body: { rating: answer.rating, ...answer.comment ? { comment: answer.comment } : {} },
56
+ signal: opts.signal
57
+ });
58
+ }
59
+ /** Just the conversation's status. */
60
+ async status(opts = {}) {
61
+ return (await this.list({ limit: 1, signal: opts.signal })).status;
62
+ }
63
+ };
64
+
65
+ export { SupportResource };
66
+ //# sourceMappingURL=support.js.map
67
+ //# sourceMappingURL=support.js.map