@takeal/cusfront-sdk 0.6.5 → 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 (79) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +53 -0
  3. package/dist/{cards-CEFKrVkl.d.cts → cards-BiXmrz7h.d.cts} +1 -1
  4. package/dist/{cards-ColpW52n.d.ts → cards-DwmzjKDC.d.ts} +1 -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 +81 -6
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +13 -9
  12. package/dist/index.d.ts +13 -9
  13. package/dist/index.js +81 -6
  14. package/dist/index.js.map +1 -1
  15. package/dist/react/index.d.cts +4 -3
  16. package/dist/react/index.d.ts +4 -3
  17. package/dist/resources/attribution.d.cts +1 -1
  18. package/dist/resources/attribution.d.ts +1 -1
  19. package/dist/resources/auth.d.cts +2 -2
  20. package/dist/resources/auth.d.ts +2 -2
  21. package/dist/resources/balance.d.cts +1 -1
  22. package/dist/resources/balance.d.ts +1 -1
  23. package/dist/resources/blog.d.cts +1 -1
  24. package/dist/resources/blog.d.ts +1 -1
  25. package/dist/resources/bonus.d.cts +1 -1
  26. package/dist/resources/bonus.d.ts +1 -1
  27. package/dist/resources/branding.d.cts +1 -1
  28. package/dist/resources/branding.d.ts +1 -1
  29. package/dist/resources/cards.d.cts +2 -2
  30. package/dist/resources/cards.d.ts +2 -2
  31. package/dist/resources/close-requests.d.cts +1 -1
  32. package/dist/resources/close-requests.d.ts +1 -1
  33. package/dist/resources/codes.d.cts +1 -1
  34. package/dist/resources/codes.d.ts +1 -1
  35. package/dist/resources/consents.d.cts +1 -1
  36. package/dist/resources/consents.d.ts +1 -1
  37. package/dist/resources/debt.d.cts +1 -1
  38. package/dist/resources/debt.d.ts +1 -1
  39. package/dist/resources/deposits.d.cts +2 -2
  40. package/dist/resources/deposits.d.ts +2 -2
  41. package/dist/resources/devices.d.cts +2 -2
  42. package/dist/resources/devices.d.ts +2 -2
  43. package/dist/resources/documents.d.cts +1 -1
  44. package/dist/resources/documents.d.ts +1 -1
  45. package/dist/resources/funding-options.d.cts +2 -2
  46. package/dist/resources/funding-options.d.ts +2 -2
  47. package/dist/resources/history.d.cts +1 -1
  48. package/dist/resources/history.d.ts +1 -1
  49. package/dist/resources/me.d.cts +2 -2
  50. package/dist/resources/me.d.ts +2 -2
  51. package/dist/resources/notifications.d.cts +1 -1
  52. package/dist/resources/notifications.d.ts +1 -1
  53. package/dist/resources/push.d.cts +1 -1
  54. package/dist/resources/push.d.ts +1 -1
  55. package/dist/resources/receipts.d.cts +1 -1
  56. package/dist/resources/receipts.d.ts +1 -1
  57. package/dist/resources/referral.d.cts +1 -1
  58. package/dist/resources/referral.d.ts +1 -1
  59. package/dist/resources/sessions.d.cts +1 -1
  60. package/dist/resources/sessions.d.ts +1 -1
  61. package/dist/resources/subscription.d.cts +1 -1
  62. package/dist/resources/subscription.d.ts +1 -1
  63. package/dist/resources/subscriptions.d.cts +1 -1
  64. package/dist/resources/subscriptions.d.ts +1 -1
  65. package/dist/resources/support.cjs +69 -0
  66. package/dist/resources/support.cjs.map +1 -0
  67. package/dist/resources/support.d.cts +110 -0
  68. package/dist/resources/support.d.ts +110 -0
  69. package/dist/resources/support.js +67 -0
  70. package/dist/resources/support.js.map +1 -0
  71. package/dist/resources/wallet.d.cts +1 -1
  72. package/dist/resources/wallet.d.ts +1 -1
  73. package/dist/telegram.cjs +81 -6
  74. package/dist/telegram.cjs.map +1 -1
  75. package/dist/telegram.d.cts +4 -3
  76. package/dist/telegram.d.ts +4 -3
  77. package/dist/telegram.js +81 -6
  78. package/dist/telegram.js.map +1 -1
  79. package/package.json +6 -1
@@ -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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/resources/support.ts"],"names":[],"mappings":";AAmFA,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,IAAA,CAAK,UAAU,MAAA,EAAW,CAAA,CAAE,IAAI,OAAA,EAAS,MAAA,CAAO,IAAA,CAAK,KAAK,CAAC,CAAA;AAC/D,IAAA,MAAM,EAAA,GAAK,EAAE,QAAA,EAAS;AACtB,IAAA,OAAO,IAAA,CAAK,KAAK,GAAA,CAAyB,CAAA,oBAAA,EAAuB,KAAK,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA,EAAI;AAAA,MACrF,QAAQ,IAAA,CAAK;AAAA,KACd,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,IAAA,CACJ,OAAA,EACA,IAAA,GAAiC,EAAC,EACT;AACzB,IAAA,MAAM,WAAA,GAAc,MAAM,OAAA,CAAQ,GAAA;AAAA,MAAA,CAC/B,QAAQ,KAAA,IAAS,EAAC,EAAG,GAAA,CAAI,OAAO,CAAA,MAAO;AAAA,QACtC,WAAW,CAAA,CAAE,QAAA;AAAA,QACb,cAAc,CAAA,CAAE,WAAA;AAAA,QAChB,WAAA,EAAa,MAAM,QAAA,CAAS,CAAA,CAAE,IAAI;AAAA,OACpC,CAAE;AAAA,KACJ;AACA,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAqB,sBAAA,EAAwB;AAAA,MAC5D,MAAM,EAAE,IAAA,EAAM,OAAA,CAAQ,IAAA,IAAQ,IAAI,WAAA,EAAY;AAAA,MAC9C,QAAQ,IAAA,CAAK;AAAA,KACd,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,UAAA,CAAW,EAAA,EAAY,IAAA,GAAiC,EAAC,EAAkB;AAC/E,IAAA,OAAO,KAAK,IAAA,CAAK,OAAA,CAAQ,2BAA2B,kBAAA,CAAmB,EAAE,CAAC,CAAA,CAAA,EAAI;AAAA,MAC5E,QAAQ,IAAA,CAAK;AAAA,KACd,CAAA;AAAA,EACH;AAAA;AAAA;AAAA,EAIA,MAAM,IAAA,CACJ,EAAA,EACA,MAAA,EACA,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.\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"]}
@@ -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.*`.
package/dist/telegram.cjs CHANGED
@@ -70,10 +70,20 @@ var HttpClient = class {
70
70
  async delete(path, opts = {}) {
71
71
  return this.request("DELETE", path, opts);
72
72
  }
73
+ /** GET a file. Same auth and refresh as the JSON calls; an error status
74
+ * throws `ApiError` the same way. */
75
+ async getBlob(path, opts = {}) {
76
+ const resp = await this.send("GET", path, { ...opts, accept: "*/*" });
77
+ if (!resp.ok) return parseResponse(resp);
78
+ return resp.blob();
79
+ }
73
80
  async request(method, path, opts) {
81
+ return parseResponse(await this.send(method, path, opts));
82
+ }
83
+ async send(method, path, opts) {
74
84
  const url = this.absolute(path);
75
85
  const headers = {
76
- Accept: "application/json",
86
+ Accept: opts.accept ?? "application/json",
77
87
  ...this.defaultHeaders
78
88
  };
79
89
  if (opts.body !== void 0) headers["Content-Type"] = "application/json";
@@ -99,10 +109,10 @@ var HttpClient = class {
99
109
  }
100
110
  if (resp.status === 401 && !opts.skipAuth && !opts.retried && this.refresher) {
101
111
  if (await this.refreshOnce()) {
102
- return this.request(method, path, { ...opts, retried: true });
112
+ return this.send(method, path, { ...opts, retried: true });
103
113
  }
104
114
  }
105
- return parseResponse(resp);
115
+ return resp;
106
116
  }
107
117
  absolute(path) {
108
118
  if (path.startsWith("http://") || path.startsWith("https://")) return path;
@@ -1409,6 +1419,70 @@ var ReceiptsResource = class {
1409
1419
  }
1410
1420
  };
1411
1421
 
1422
+ // src/resources/support.ts
1423
+ function bytesToBase64(bytes) {
1424
+ let binary = "";
1425
+ const chunk = 32768;
1426
+ for (let i = 0; i < bytes.length; i += chunk) {
1427
+ binary += String.fromCharCode(...bytes.subarray(i, i + chunk));
1428
+ }
1429
+ return btoa(binary);
1430
+ }
1431
+ async function toBase64(data) {
1432
+ if (typeof data === "string") return data;
1433
+ if (data instanceof Uint8Array) return bytesToBase64(data);
1434
+ if (data instanceof ArrayBuffer) return bytesToBase64(new Uint8Array(data));
1435
+ return bytesToBase64(new Uint8Array(await data.arrayBuffer()));
1436
+ }
1437
+ var SupportResource = class {
1438
+ constructor(http) {
1439
+ this.http = http;
1440
+ }
1441
+ /** The latest messages, oldest first, and the conversation's status.
1442
+ * `before` reads further back; `limit` is 1 to 100 (50). */
1443
+ async list(opts = {}) {
1444
+ const q = new URLSearchParams();
1445
+ if (opts.before) q.set("before", opts.before);
1446
+ if (opts.limit !== void 0) q.set("limit", String(opts.limit));
1447
+ const qs = q.toString();
1448
+ return this.http.get(`/me/support/messages${qs ? `?${qs}` : ""}`, {
1449
+ signal: opts.signal
1450
+ });
1451
+ }
1452
+ /** Write to support. Text, files or both; up to 10 files. */
1453
+ async send(message, opts = {}) {
1454
+ const attachments = await Promise.all(
1455
+ (message.files ?? []).map(async (f) => ({
1456
+ file_name: f.fileName,
1457
+ content_type: f.contentType,
1458
+ data_base64: await toBase64(f.data)
1459
+ }))
1460
+ );
1461
+ return this.http.post("/me/support/messages", {
1462
+ body: { text: message.text ?? "", attachments },
1463
+ signal: opts.signal
1464
+ });
1465
+ }
1466
+ /** A file from the conversation: the person's own or one support sent. */
1467
+ async attachment(id, opts = {}) {
1468
+ return this.http.getBlob(`/me/support/attachments/${encodeURIComponent(id)}`, {
1469
+ signal: opts.signal
1470
+ });
1471
+ }
1472
+ /** Answer `rating_request`: 1 (bad) to 5 (great), a comment if the person
1473
+ * wrote one. Each question takes one answer; a second one is a 404. */
1474
+ async rate(id, answer, opts = {}) {
1475
+ await this.http.post(`/me/support/ratings/${encodeURIComponent(id)}`, {
1476
+ body: { rating: answer.rating, ...answer.comment ? { comment: answer.comment } : {} },
1477
+ signal: opts.signal
1478
+ });
1479
+ }
1480
+ /** Just the conversation's status. */
1481
+ async status(opts = {}) {
1482
+ return (await this.list({ limit: 1, signal: opts.signal })).status;
1483
+ }
1484
+ };
1485
+
1412
1486
  // src/resources/funding-options.ts
1413
1487
  var FundingOptionsResource = class {
1414
1488
  constructor(http) {
@@ -1421,7 +1495,7 @@ var FundingOptionsResource = class {
1421
1495
  };
1422
1496
 
1423
1497
  // src/version.ts
1424
- var SDK_VERSION = "0.6.5";
1498
+ var SDK_VERSION = "0.6.6";
1425
1499
 
1426
1500
  // src/client-platform.ts
1427
1501
  var CLIENT_HEADER = "X-Takeal-Client";
@@ -1496,7 +1570,7 @@ function isAbsolute(url) {
1496
1570
  }
1497
1571
 
1498
1572
  // src/compat.ts
1499
- var SUPPORTED_MEISTER = ">=0.6.11, <0.7.0";
1573
+ var SUPPORTED_MEISTER = ">=0.6.12, <0.7.0";
1500
1574
  var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
1501
1575
  function parse(v) {
1502
1576
  const m = SEMVER.exec(v.trim());
@@ -1609,7 +1683,8 @@ function createClient(opts) {
1609
1683
  attribution: new AttributionResource(http),
1610
1684
  history: new HistoryResource(http),
1611
1685
  consents: new ConsentsResource(http),
1612
- receipts: new ReceiptsResource(http)
1686
+ receipts: new ReceiptsResource(http),
1687
+ support: new SupportResource(http)
1613
1688
  };
1614
1689
  }
1615
1690
  function pickDefaultStore(key) {