@takeal/cusfront-sdk 0.6.5 → 0.6.8

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 (97) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +90 -0
  3. package/dist/{cards-ColpW52n.d.ts → cards-BgY00UpU.d.ts} +18 -1
  4. package/dist/{cards-CEFKrVkl.d.cts → cards-DGz4Rqu1.d.cts} +18 -1
  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 +142 -6
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +19 -11
  12. package/dist/index.d.ts +19 -11
  13. package/dist/index.js +142 -6
  14. package/dist/index.js.map +1 -1
  15. package/dist/react/index.d.cts +5 -3
  16. package/dist/react/index.d.ts +5 -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 +3 -2
  21. package/dist/resources/auth.d.ts +3 -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 +16 -0
  32. package/dist/resources/cards.cjs.map +1 -1
  33. package/dist/resources/cards.d.cts +3 -2
  34. package/dist/resources/cards.d.ts +3 -2
  35. package/dist/resources/cards.js +16 -0
  36. package/dist/resources/cards.js.map +1 -1
  37. package/dist/resources/claims.cjs +40 -0
  38. package/dist/resources/claims.cjs.map +1 -0
  39. package/dist/resources/claims.d.cts +114 -0
  40. package/dist/resources/claims.d.ts +114 -0
  41. package/dist/resources/claims.js +38 -0
  42. package/dist/resources/claims.js.map +1 -0
  43. package/dist/resources/close-requests.d.cts +1 -1
  44. package/dist/resources/close-requests.d.ts +1 -1
  45. package/dist/resources/codes.d.cts +1 -1
  46. package/dist/resources/codes.d.ts +1 -1
  47. package/dist/resources/consents.d.cts +1 -1
  48. package/dist/resources/consents.d.ts +1 -1
  49. package/dist/resources/debt.d.cts +1 -1
  50. package/dist/resources/debt.d.ts +1 -1
  51. package/dist/resources/deposits.cjs.map +1 -1
  52. package/dist/resources/deposits.d.cts +3 -2
  53. package/dist/resources/deposits.d.ts +3 -2
  54. package/dist/resources/deposits.js.map +1 -1
  55. package/dist/resources/devices.d.cts +2 -2
  56. package/dist/resources/devices.d.ts +2 -2
  57. package/dist/resources/documents.d.cts +1 -1
  58. package/dist/resources/documents.d.ts +1 -1
  59. package/dist/resources/funding-options.d.cts +3 -2
  60. package/dist/resources/funding-options.d.ts +3 -2
  61. package/dist/resources/history.d.cts +1 -1
  62. package/dist/resources/history.d.ts +1 -1
  63. package/dist/resources/me.d.cts +3 -2
  64. package/dist/resources/me.d.ts +3 -2
  65. package/dist/resources/notifications.d.cts +1 -1
  66. package/dist/resources/notifications.d.ts +1 -1
  67. package/dist/resources/push.d.cts +1 -1
  68. package/dist/resources/push.d.ts +1 -1
  69. package/dist/resources/receipts.d.cts +1 -1
  70. package/dist/resources/receipts.d.ts +1 -1
  71. package/dist/resources/referral.d.cts +1 -1
  72. package/dist/resources/referral.d.ts +1 -1
  73. package/dist/resources/sessions.d.cts +1 -1
  74. package/dist/resources/sessions.d.ts +1 -1
  75. package/dist/resources/subscription.cjs +9 -0
  76. package/dist/resources/subscription.cjs.map +1 -1
  77. package/dist/resources/subscription.d.cts +20 -3
  78. package/dist/resources/subscription.d.ts +20 -3
  79. package/dist/resources/subscription.js +9 -0
  80. package/dist/resources/subscription.js.map +1 -1
  81. package/dist/resources/subscriptions.d.cts +1 -1
  82. package/dist/resources/subscriptions.d.ts +1 -1
  83. package/dist/resources/support.cjs +69 -0
  84. package/dist/resources/support.cjs.map +1 -0
  85. package/dist/resources/support.d.cts +115 -0
  86. package/dist/resources/support.d.ts +115 -0
  87. package/dist/resources/support.js +67 -0
  88. package/dist/resources/support.js.map +1 -0
  89. package/dist/resources/wallet.d.cts +1 -1
  90. package/dist/resources/wallet.d.ts +1 -1
  91. package/dist/telegram.cjs +142 -6
  92. package/dist/telegram.cjs.map +1 -1
  93. package/dist/telegram.d.cts +5 -3
  94. package/dist/telegram.d.ts +5 -3
  95. package/dist/telegram.js +142 -6
  96. package/dist/telegram.js.map +1 -1
  97. package/package.json +11 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/resources/subscription.ts"],"names":[],"mappings":";AAkCO,IAAM,uBAAN,MAA2B;AAAA,EAChC,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,GAAA,CAAI,IAAA,GAAiC,EAAC,EAAqC;AAC/E,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAA6B,kBAAA,EAAoB,EAAE,MAAA,EAAQ,IAAA,CAAK,QAAQ,CAAA;AAAA,EAC3F;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aAAa,IAAA,EAAgD;AACjE,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAAsB,6BAAA,EAA+B,EAAE,IAAA,EAAM,EAAE,IAAA,EAAK,EAAG,CAAA;AAAA,EAC1F;AACF","file":"subscription.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Subscription resource — `client.subscription.*`.\n *\n * The user's own paid tier or gift: the discounts it gives and, for a\n * gift, when it ends. Not to be confused with `client.subscriptions`, which\n * is about announcement channels.\n *\n * Mirrors `GET /me/subscription` and `PUT /me/subscription/promo-code`.\n */\n\nexport interface UserSubscription {\n id: string;\n tier_id: string;\n tier_name: string;\n /** `active`, `tryout`, `grace`, `cancelled` or `expired`. */\n status: string;\n /** `billing` (charged monthly) or `gift` (never charged). */\n kind: \"billing\" | \"gift\" | (string & {});\n /** For a gift: when it ends; `null` = no end date. */\n gift_until: string | null;\n monthly_fee: string;\n currency: string;\n /** Discount on card prices, basis points. */\n issuance_discount_bps: number;\n /** Discount on the top-up commission, basis points. */\n funding_discount_bps: number;\n started_at: string;\n current_period_end: string | null;\n /** The promo code the monthly fee is charged with, if any. */\n promo_code_id: string | null;\n}\n\nexport class SubscriptionResource {\n constructor(private readonly http: HttpClient) {}\n\n /** The user's subscription, or `null` when there is none. */\n async get(opts: { signal?: AbortSignal } = {}): Promise<UserSubscription | null> {\n return this.http.get<UserSubscription | null>(\"/me/subscription\", { signal: opts.signal });\n }\n\n /**\n * Charge the monthly fee with a promo code, as long as the code allows.\n * `null` removes it. A code that can't be used on the fee fails with 400\n * `promo_code_*`; no paid subscription running → 404.\n */\n async setPromoCode(code: string | null): Promise<UserSubscription> {\n return this.http.put<UserSubscription>(\"/me/subscription/promo-code\", { body: { code } });\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/resources/subscription.ts"],"names":[],"mappings":";AA6CO,IAAM,uBAAN,MAA2B;AAAA,EAChC,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAM,GAAA,CAAI,IAAA,GAAiC,EAAC,EAAqC;AAC/E,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAA6B,kBAAA,EAAoB,EAAE,MAAA,EAAQ,IAAA,CAAK,QAAQ,CAAA;AAAA,EAC3F;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aAAa,IAAA,EAAgD;AACjE,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAAsB,6BAAA,EAA+B,EAAE,IAAA,EAAM,EAAE,IAAA,EAAK,EAAG,CAAA;AAAA,EAC1F;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,MAAA,GAAyC;AAC7C,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAA4B,yBAAA,EAA2B,EAAE,CAAA;AAAA,EAC5E;AACF","file":"subscription.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Subscription resource — `client.subscription.*`.\n *\n * The user's own paid tier or gift: the discounts it gives and, for a\n * gift, when it ends. Not to be confused with `client.subscriptions`, which\n * is about announcement channels.\n *\n * Mirrors `GET /me/subscription`, `PUT /me/subscription/promo-code` and\n * `POST /me/subscription/cancel`.\n */\n\nexport interface UserSubscription {\n id: string;\n tier_id: string;\n tier_name: string;\n /** `active`, `tryout`, `grace`, `cancelled` or `expired`. */\n status: string;\n /** `billing` (charged monthly) or `gift` (never charged). */\n kind: \"billing\" | \"gift\" | (string & {});\n /** For a gift: when it ends; `null` = no end date. */\n gift_until: string | null;\n monthly_fee: string;\n currency: string;\n /** Discount on card prices, basis points. */\n issuance_discount_bps: number;\n /** Discount on the top-up commission, basis points. */\n funding_discount_bps: number;\n started_at: string;\n current_period_end: string | null;\n /** The promo code the monthly fee is charged with, if any. */\n promo_code_id: string | null;\n}\n\n/** What cancelling did. */\nexport interface CancelledSubscription {\n /** The subscription, now `cancelled`. */\n subscription: UserSubscription | null;\n /** What went back to the balance for the unused days of the paid period,\n * decimal string; `\"0\"` for a gift, a trial or an unpaid renewal. */\n refund: string;\n currency: string;\n}\n\nexport class SubscriptionResource {\n constructor(private readonly http: HttpClient) {}\n\n /** The user's subscription, or `null` when there is none. */\n async get(opts: { signal?: AbortSignal } = {}): Promise<UserSubscription | null> {\n return this.http.get<UserSubscription | null>(\"/me/subscription\", { signal: opts.signal });\n }\n\n /**\n * Charge the monthly fee with a promo code, as long as the code allows.\n * `null` removes it. A code that can't be used on the fee fails with 400\n * `promo_code_*`; no paid subscription running → 404.\n */\n async setPromoCode(code: string | null): Promise<UserSubscription> {\n return this.http.put<UserSubscription>(\"/me/subscription/promo-code\", { body: { code } });\n }\n\n /**\n * Cancel the subscription now, in one step. What was paid for the current\n * period comes back to the balance for the days not used. No subscription\n * running → 404; 503 `refund_unavailable` when the refund can't be made\n * right now (the subscription keeps running; try again).\n */\n async cancel(): Promise<CancelledSubscription> {\n return this.http.post<CancelledSubscription>(\"/me/subscription/cancel\", {});\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
  * 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":";;;AAwFA,SAAS,cAAc,KAAA,EAA2B;AAChD,EAAA,IAAI,MAAA,GAAS,EAAA;AACb,EAAA,MAAM,KAAA,GAAQ,KAAA;AACd,EAAA,KAAA,IAAS,IAAI,CAAA,EAAG,CAAA,GAAI,KAAA,CAAM,MAAA,EAAQ,KAAK,KAAA,EAAO;AAC5C,IAAA,MAAA,IAAU,MAAA,C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IAAA,OAAA,CAAQ,MAAM,IAAA,CAAK,IAAA,CAAK,EAAE,KAAA,EAAO,GAAG,MAAA,EAAQ,IAAA,CAAK,MAAA,EAAQ,CAAA,EAAG,MAAA;AAAA,EAC9D;AACF","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. A message written in\n * Telegram keeps its formatting: `html` has it, `text` the plain words.\n * An answer sent to the person's Telegram is `queued` until all of it got\n * there, and `failed` if it could not get there.\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 (for an answer\n * sent to Telegram, until the person 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. On the person's own messages it is set\n * only for those written in Telegram, which keep their formatting. */\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,115 @@
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. A message written in
20
+ * Telegram keeps its formatting: `html` has it, `text` the plain words.
21
+ * An answer sent to the person's Telegram is `queued` until all of it got
22
+ * there, and `failed` if it could not get there.
23
+ */
24
+ /** Where a message came from, or where an answer was sent. */
25
+ type SupportChannel = "cabinet" | "telegram" | (string & {});
26
+ /** How far a message got: `queued` until support has it (for an answer
27
+ * sent to Telegram, until the person has it). */
28
+ type SupportMessageStatus = "queued" | "delivered" | "failed" | (string & {});
29
+ /** The conversation's state: `none` until the person writes for the first
30
+ * time, `resolved` once support closed it. Writing again reopens it. */
31
+ type SupportConversationStatus = "none" | "open" | "resolved" | (string & {});
32
+ /** A file in the conversation. Download it with `attachment(id)`. */
33
+ interface SupportAttachment {
34
+ id: string;
35
+ file_name: string;
36
+ content_type: string;
37
+ /** Bytes. */
38
+ size: number;
39
+ }
40
+ /** One message. */
41
+ interface SupportMessage {
42
+ id: string;
43
+ /** `user` for what the person wrote, `support` for an answer. */
44
+ author: "user" | "support" | (string & {});
45
+ /** The name the support agent goes by; answers only. */
46
+ operator_name: string | null;
47
+ channel: SupportChannel | null;
48
+ /** What the person wrote, plain text. Empty on answers. */
49
+ text: string;
50
+ /** The answer as cleaned HTML. On the person's own messages it is set
51
+ * only for those written in Telegram, which keep their formatting. */
52
+ html: string;
53
+ attachments: SupportAttachment[];
54
+ status: SupportMessageStatus;
55
+ created_at: string;
56
+ }
57
+ /** Support closed the conversation and asks how it went. */
58
+ interface SupportRatingRequest {
59
+ id: string;
60
+ asked_at: string;
61
+ }
62
+ /** A page of the conversation, oldest first. */
63
+ interface SupportConversation {
64
+ status: SupportConversationStatus;
65
+ items: SupportMessage[];
66
+ /** Older messages exist: `list({ before: items[0].created_at })`. */
67
+ has_more: boolean;
68
+ /** Show a 1–5 rating when set; answer with `rate()`. `null` otherwise. */
69
+ rating_request: SupportRatingRequest | null;
70
+ }
71
+ /** A file to send. `data` may be a `Blob` (a `File` from an input), bytes,
72
+ * or base64 already. */
73
+ interface SupportFile {
74
+ fileName: string;
75
+ /** E.g. `image/png`. Pictures and PDF up to 20 MB by default; the platform
76
+ * sets the list and the size. */
77
+ contentType: string;
78
+ data: Blob | ArrayBuffer | Uint8Array | string;
79
+ }
80
+ declare class SupportResource {
81
+ private readonly http;
82
+ constructor(http: HttpClient);
83
+ /** The latest messages, oldest first, and the conversation's status.
84
+ * `before` reads further back; `limit` is 1 to 100 (50). */
85
+ list(opts?: {
86
+ before?: string;
87
+ limit?: number;
88
+ signal?: AbortSignal;
89
+ }): Promise<SupportConversation>;
90
+ /** Write to support. Text, files or both; up to 10 files. */
91
+ send(message: {
92
+ text?: string;
93
+ files?: SupportFile[];
94
+ }, opts?: {
95
+ signal?: AbortSignal;
96
+ }): Promise<SupportMessage>;
97
+ /** A file from the conversation: the person's own or one support sent. */
98
+ attachment(id: string, opts?: {
99
+ signal?: AbortSignal;
100
+ }): Promise<Blob>;
101
+ /** Answer `rating_request`: 1 (bad) to 5 (great), a comment if the person
102
+ * wrote one. Each question takes one answer; a second one is a 404. */
103
+ rate(id: string, answer: {
104
+ rating: 1 | 2 | 3 | 4 | 5;
105
+ comment?: string;
106
+ }, opts?: {
107
+ signal?: AbortSignal;
108
+ }): Promise<void>;
109
+ /** Just the conversation's status. */
110
+ status(opts?: {
111
+ signal?: AbortSignal;
112
+ }): Promise<SupportConversationStatus>;
113
+ }
114
+
115
+ export { type SupportAttachment, type SupportChannel, type SupportConversation, type SupportConversationStatus, type SupportFile, type SupportMessage, type SupportMessageStatus, type SupportRatingRequest, SupportResource };
@@ -0,0 +1,115 @@
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. A message written in
20
+ * Telegram keeps its formatting: `html` has it, `text` the plain words.
21
+ * An answer sent to the person's Telegram is `queued` until all of it got
22
+ * there, and `failed` if it could not get there.
23
+ */
24
+ /** Where a message came from, or where an answer was sent. */
25
+ type SupportChannel = "cabinet" | "telegram" | (string & {});
26
+ /** How far a message got: `queued` until support has it (for an answer
27
+ * sent to Telegram, until the person has it). */
28
+ type SupportMessageStatus = "queued" | "delivered" | "failed" | (string & {});
29
+ /** The conversation's state: `none` until the person writes for the first
30
+ * time, `resolved` once support closed it. Writing again reopens it. */
31
+ type SupportConversationStatus = "none" | "open" | "resolved" | (string & {});
32
+ /** A file in the conversation. Download it with `attachment(id)`. */
33
+ interface SupportAttachment {
34
+ id: string;
35
+ file_name: string;
36
+ content_type: string;
37
+ /** Bytes. */
38
+ size: number;
39
+ }
40
+ /** One message. */
41
+ interface SupportMessage {
42
+ id: string;
43
+ /** `user` for what the person wrote, `support` for an answer. */
44
+ author: "user" | "support" | (string & {});
45
+ /** The name the support agent goes by; answers only. */
46
+ operator_name: string | null;
47
+ channel: SupportChannel | null;
48
+ /** What the person wrote, plain text. Empty on answers. */
49
+ text: string;
50
+ /** The answer as cleaned HTML. On the person's own messages it is set
51
+ * only for those written in Telegram, which keep their formatting. */
52
+ html: string;
53
+ attachments: SupportAttachment[];
54
+ status: SupportMessageStatus;
55
+ created_at: string;
56
+ }
57
+ /** Support closed the conversation and asks how it went. */
58
+ interface SupportRatingRequest {
59
+ id: string;
60
+ asked_at: string;
61
+ }
62
+ /** A page of the conversation, oldest first. */
63
+ interface SupportConversation {
64
+ status: SupportConversationStatus;
65
+ items: SupportMessage[];
66
+ /** Older messages exist: `list({ before: items[0].created_at })`. */
67
+ has_more: boolean;
68
+ /** Show a 1–5 rating when set; answer with `rate()`. `null` otherwise. */
69
+ rating_request: SupportRatingRequest | null;
70
+ }
71
+ /** A file to send. `data` may be a `Blob` (a `File` from an input), bytes,
72
+ * or base64 already. */
73
+ interface SupportFile {
74
+ fileName: string;
75
+ /** E.g. `image/png`. Pictures and PDF up to 20 MB by default; the platform
76
+ * sets the list and the size. */
77
+ contentType: string;
78
+ data: Blob | ArrayBuffer | Uint8Array | string;
79
+ }
80
+ declare class SupportResource {
81
+ private readonly http;
82
+ constructor(http: HttpClient);
83
+ /** The latest messages, oldest first, and the conversation's status.
84
+ * `before` reads further back; `limit` is 1 to 100 (50). */
85
+ list(opts?: {
86
+ before?: string;
87
+ limit?: number;
88
+ signal?: AbortSignal;
89
+ }): Promise<SupportConversation>;
90
+ /** Write to support. Text, files or both; up to 10 files. */
91
+ send(message: {
92
+ text?: string;
93
+ files?: SupportFile[];
94
+ }, opts?: {
95
+ signal?: AbortSignal;
96
+ }): Promise<SupportMessage>;
97
+ /** A file from the conversation: the person's own or one support sent. */
98
+ attachment(id: string, opts?: {
99
+ signal?: AbortSignal;
100
+ }): Promise<Blob>;
101
+ /** Answer `rating_request`: 1 (bad) to 5 (great), a comment if the person
102
+ * wrote one. Each question takes one answer; a second one is a 404. */
103
+ rate(id: string, answer: {
104
+ rating: 1 | 2 | 3 | 4 | 5;
105
+ comment?: string;
106
+ }, opts?: {
107
+ signal?: AbortSignal;
108
+ }): Promise<void>;
109
+ /** Just the conversation's status. */
110
+ status(opts?: {
111
+ signal?: AbortSignal;
112
+ }): Promise<SupportConversationStatus>;
113
+ }
114
+
115
+ 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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/resources/support.ts"],"names":[],"mappings":";AAwFA,SAAS,cAAc,KAAA,EAA2B;AAChD,EAAA,IAAI,MAAA,GAAS,EAAA;AACb,EAAA,MAAM,KAAA,GAAQ,KAAA;AACd,EAAA,KAAA,IAAS,IAAI,CAAA,EAAG,CAAA,GAAI,KAAA,CAAM,MAAA,EAAQ,KAAK,KAAA,EAAO;AAC5C,IAAA,MAAA,IAAU,MAAA,CAAO,aAAa,GAAG,KAAA,CAAM,SAAS,CAAA,EAAG,CAAA,GAAI,KAAK,CAAC,CAAA;AAAA,EAC/D;AACA,EAAA,OAAO,KAAK,MAAM,CAAA;AACpB;AAEA,eAAe,SAAS,IAAA,EAA4C;AAClE,EAAA,IAAI,OAAO,IAAA,KAAS,QAAA,EAAU,OAAO,IAAA;AACrC,EAAA,IAAI,IAAA,YAAgB,UAAA,EAAY,OAAO,aAAA,CAAc,IAAI,CAAA;AACzD,EAAA,IAAI,gBAAgB,WAAA,EAAa,OAAO,cAAc,IAAI,UAAA,CAAW,IAAI,CAAC,CAAA;AAC1E,EAAA,OAAO,cAAc,IAAI,UAAA,CAAW,MAAM,IAAA,CAAK,WAAA,EAAa,CAAC,CAAA;AAC/D;AAEO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA;AAAA,EAIhD,MAAM,IAAA,CACJ,IAAA,GAAkE,EAAC,EACrC;AAC9B,IAAA,MAAM,CAAA,GAAI,IAAI,eAAA,EAAgB;AAC9B,IAAA,IAAI,KAAK,MAAA,EAAQ,CAAA,CAAE,GAAA,CAAI,QAAA,EAAU,KAAK,MAAM,CAAA;AAC5C,IAAA,IAAI,I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IAAA,GAAiC,EAAC,EACnB;AACf,IAAA,MAAM,KAAK,IAAA,CAAK,IAAA,CAAW,uBAAuB,kBAAA,CAAmB,EAAE,CAAC,CAAA,CAAA,EAAI;AAAA,MAC1E,IAAA,EAAM,EAAE,MAAA,EAAQ,MAAA,CAAO,QAAQ,GAAI,MAAA,CAAO,OAAA,GAAU,EAAE,OAAA,EAAS,MAAA,CAAO,OAAA,EAAQ,GAAI,EAAC,EAAG;AAAA,MACtF,QAAQ,IAAA,CAAK;AAAA,KACd,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,MAAA,CAAO,IAAA,GAAiC,EAAC,EAAuC;AACpF,IAAA,OAAA,CAAQ,MAAM,IAAA,CAAK,IAAA,CAAK,EAAE,KAAA,EAAO,GAAG,MAAA,EAAQ,IAAA,CAAK,MAAA,EAAQ,CAAA,EAAG,MAAA;AAAA,EAC9D;AACF","file":"support.js","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. A message written in\n * Telegram keeps its formatting: `html` has it, `text` the plain words.\n * An answer sent to the person's Telegram is `queued` until all of it got\n * there, and `failed` if it could not get there.\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 (for an answer\n * sent to Telegram, until the person 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. On the person's own messages it is set\n * only for those written in Telegram, which keep their formatting. */\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"]}
@@ -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
  * Wallet resource — `client.wallet.*`.
@@ -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
  * Wallet resource — `client.wallet.*`.