@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.
- package/CHANGELOG.md +13 -0
- package/README.md +53 -0
- package/dist/{cards-CEFKrVkl.d.cts → cards-BiXmrz7h.d.cts} +1 -1
- package/dist/{cards-ColpW52n.d.ts → cards-DwmzjKDC.d.ts} +1 -1
- package/dist/{devices-B_YveTl9.d.ts → devices-C88c38hm.d.ts} +1 -1
- package/dist/{devices-a5Z45Mx_.d.cts → devices-CiJrlXum.d.cts} +1 -1
- package/dist/{http-DeANAoTs.d.cts → http-CL97TjMO.d.cts} +4 -0
- package/dist/{http-DeANAoTs.d.ts → http-CL97TjMO.d.ts} +4 -0
- package/dist/index.cjs +81 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -9
- package/dist/index.d.ts +13 -9
- package/dist/index.js +81 -6
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +4 -3
- package/dist/react/index.d.ts +4 -3
- package/dist/resources/attribution.d.cts +1 -1
- package/dist/resources/attribution.d.ts +1 -1
- package/dist/resources/auth.d.cts +2 -2
- package/dist/resources/auth.d.ts +2 -2
- package/dist/resources/balance.d.cts +1 -1
- package/dist/resources/balance.d.ts +1 -1
- package/dist/resources/blog.d.cts +1 -1
- package/dist/resources/blog.d.ts +1 -1
- package/dist/resources/bonus.d.cts +1 -1
- package/dist/resources/bonus.d.ts +1 -1
- package/dist/resources/branding.d.cts +1 -1
- package/dist/resources/branding.d.ts +1 -1
- package/dist/resources/cards.d.cts +2 -2
- package/dist/resources/cards.d.ts +2 -2
- package/dist/resources/close-requests.d.cts +1 -1
- package/dist/resources/close-requests.d.ts +1 -1
- package/dist/resources/codes.d.cts +1 -1
- package/dist/resources/codes.d.ts +1 -1
- package/dist/resources/consents.d.cts +1 -1
- package/dist/resources/consents.d.ts +1 -1
- package/dist/resources/debt.d.cts +1 -1
- package/dist/resources/debt.d.ts +1 -1
- package/dist/resources/deposits.d.cts +2 -2
- package/dist/resources/deposits.d.ts +2 -2
- package/dist/resources/devices.d.cts +2 -2
- package/dist/resources/devices.d.ts +2 -2
- package/dist/resources/documents.d.cts +1 -1
- package/dist/resources/documents.d.ts +1 -1
- package/dist/resources/funding-options.d.cts +2 -2
- package/dist/resources/funding-options.d.ts +2 -2
- package/dist/resources/history.d.cts +1 -1
- package/dist/resources/history.d.ts +1 -1
- package/dist/resources/me.d.cts +2 -2
- package/dist/resources/me.d.ts +2 -2
- package/dist/resources/notifications.d.cts +1 -1
- package/dist/resources/notifications.d.ts +1 -1
- package/dist/resources/push.d.cts +1 -1
- package/dist/resources/push.d.ts +1 -1
- package/dist/resources/receipts.d.cts +1 -1
- package/dist/resources/receipts.d.ts +1 -1
- package/dist/resources/referral.d.cts +1 -1
- package/dist/resources/referral.d.ts +1 -1
- package/dist/resources/sessions.d.cts +1 -1
- package/dist/resources/sessions.d.ts +1 -1
- package/dist/resources/subscription.d.cts +1 -1
- package/dist/resources/subscription.d.ts +1 -1
- package/dist/resources/subscriptions.d.cts +1 -1
- package/dist/resources/subscriptions.d.ts +1 -1
- package/dist/resources/support.cjs +69 -0
- package/dist/resources/support.cjs.map +1 -0
- package/dist/resources/support.d.cts +110 -0
- package/dist/resources/support.d.ts +110 -0
- package/dist/resources/support.js +67 -0
- package/dist/resources/support.js.map +1 -0
- package/dist/resources/wallet.d.cts +1 -1
- package/dist/resources/wallet.d.ts +1 -1
- package/dist/telegram.cjs +81 -6
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +4 -3
- package/dist/telegram.d.ts +4 -3
- package/dist/telegram.js +81 -6
- package/dist/telegram.js.map +1 -1
- package/package.json +6 -1
package/dist/react/index.d.cts
CHANGED
|
@@ -2,10 +2,10 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { CusfrontClient } from '../index.cjs';
|
|
4
4
|
import { User } from '../resources/auth.cjs';
|
|
5
|
-
import { C as CardProduct, a as Card, D as Deposit } from '../cards-
|
|
5
|
+
import { C as CardProduct, a as Card, D as Deposit } from '../cards-BiXmrz7h.cjs';
|
|
6
6
|
import { Balance } from '../resources/balance.cjs';
|
|
7
7
|
import { NotificationPage, InboxItem, NotificationCategory } from '../resources/notifications.cjs';
|
|
8
|
-
import '../http-
|
|
8
|
+
import '../http-CL97TjMO.cjs';
|
|
9
9
|
import '../resources/bonus.cjs';
|
|
10
10
|
import '../resources/debt.cjs';
|
|
11
11
|
import '../resources/close-requests.cjs';
|
|
@@ -20,11 +20,12 @@ import '../resources/subscriptions.cjs';
|
|
|
20
20
|
import '../resources/sessions.cjs';
|
|
21
21
|
import '../resources/push.cjs';
|
|
22
22
|
import '../resources/me.cjs';
|
|
23
|
-
import '../devices-
|
|
23
|
+
import '../devices-CiJrlXum.cjs';
|
|
24
24
|
import '../resources/attribution.cjs';
|
|
25
25
|
import '../resources/history.cjs';
|
|
26
26
|
import '../resources/consents.cjs';
|
|
27
27
|
import '../resources/receipts.cjs';
|
|
28
|
+
import '../resources/support.cjs';
|
|
28
29
|
import '../analytics.cjs';
|
|
29
30
|
|
|
30
31
|
interface ClientProviderProps {
|
package/dist/react/index.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { CusfrontClient } from '../index.js';
|
|
4
4
|
import { User } from '../resources/auth.js';
|
|
5
|
-
import { C as CardProduct, a as Card, D as Deposit } from '../cards-
|
|
5
|
+
import { C as CardProduct, a as Card, D as Deposit } from '../cards-DwmzjKDC.js';
|
|
6
6
|
import { Balance } from '../resources/balance.js';
|
|
7
7
|
import { NotificationPage, InboxItem, NotificationCategory } from '../resources/notifications.js';
|
|
8
|
-
import '../http-
|
|
8
|
+
import '../http-CL97TjMO.js';
|
|
9
9
|
import '../resources/bonus.js';
|
|
10
10
|
import '../resources/debt.js';
|
|
11
11
|
import '../resources/close-requests.js';
|
|
@@ -20,11 +20,12 @@ import '../resources/subscriptions.js';
|
|
|
20
20
|
import '../resources/sessions.js';
|
|
21
21
|
import '../resources/push.js';
|
|
22
22
|
import '../resources/me.js';
|
|
23
|
-
import '../devices-
|
|
23
|
+
import '../devices-C88c38hm.js';
|
|
24
24
|
import '../resources/attribution.js';
|
|
25
25
|
import '../resources/history.js';
|
|
26
26
|
import '../resources/consents.js';
|
|
27
27
|
import '../resources/receipts.js';
|
|
28
|
+
import '../resources/support.js';
|
|
28
29
|
import '../analytics.js';
|
|
29
30
|
|
|
30
31
|
interface ClientProviderProps {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ConsentKind, ConsentChannel } from './consents.cjs';
|
|
2
|
-
import { H as HttpClient, T as TokenStore } from '../http-
|
|
2
|
+
import { H as HttpClient, T as TokenStore } from '../http-CL97TjMO.cjs';
|
|
3
3
|
import { SignupAttribution } from './attribution.cjs';
|
|
4
4
|
import { CodeResult } from './codes.cjs';
|
|
5
|
-
import { k as CardOrderInput, i as CardOrder, j as CardOrderError } from '../cards-
|
|
5
|
+
import { k as CardOrderInput, i as CardOrder, j as CardOrderError } from '../cards-BiXmrz7h.cjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Auth resource — `client.auth.*`.
|
package/dist/resources/auth.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ConsentKind, ConsentChannel } from './consents.js';
|
|
2
|
-
import { H as HttpClient, T as TokenStore } from '../http-
|
|
2
|
+
import { H as HttpClient, T as TokenStore } from '../http-CL97TjMO.js';
|
|
3
3
|
import { SignupAttribution } from './attribution.js';
|
|
4
4
|
import { CodeResult } from './codes.js';
|
|
5
|
-
import { k as CardOrderInput, i as CardOrder, j as CardOrderError } from '../cards-
|
|
5
|
+
import { k as CardOrderInput, i as CardOrder, j as CardOrderError } from '../cards-DwmzjKDC.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Auth resource — `client.auth.*`.
|
package/dist/resources/blog.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import './consents.cjs';
|
|
2
|
-
import '../http-
|
|
3
|
-
export { B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardInTransit, i as CardOrder, j as CardOrderError, k as CardOrderInput, C as CardProduct, l as CardProductPrice, m as CardStatus, n as CardStatusSource, o as CardTariff, p as CardTopUp, q as CardTopUpStatus, r as CardTransfer, s as CardType, t as Cardholder, c as CardsResource, u as CloseBlockedReason, v as CreateCardInput, M as IssuanceBonus, P as RevealCardInput, Q as RevealedCard, S as SetPinInput, T as TopUpInput, U as TopUpResult, V as TopUpTerms, W as TransferInput, X as TransferResult, Y as UpdateCardInput, Z as cardOrderBody, _ as cardRequestBody } from '../cards-
|
|
2
|
+
import '../http-CL97TjMO.cjs';
|
|
3
|
+
export { B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardInTransit, i as CardOrder, j as CardOrderError, k as CardOrderInput, C as CardProduct, l as CardProductPrice, m as CardStatus, n as CardStatusSource, o as CardTariff, p as CardTopUp, q as CardTopUpStatus, r as CardTransfer, s as CardType, t as Cardholder, c as CardsResource, u as CloseBlockedReason, v as CreateCardInput, M as IssuanceBonus, P as RevealCardInput, Q as RevealedCard, S as SetPinInput, T as TopUpInput, U as TopUpResult, V as TopUpTerms, W as TransferInput, X as TransferResult, Y as UpdateCardInput, Z as cardOrderBody, _ as cardRequestBody } from '../cards-BiXmrz7h.cjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import './consents.js';
|
|
2
|
-
import '../http-
|
|
3
|
-
export { B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardInTransit, i as CardOrder, j as CardOrderError, k as CardOrderInput, C as CardProduct, l as CardProductPrice, m as CardStatus, n as CardStatusSource, o as CardTariff, p as CardTopUp, q as CardTopUpStatus, r as CardTransfer, s as CardType, t as Cardholder, c as CardsResource, u as CloseBlockedReason, v as CreateCardInput, M as IssuanceBonus, P as RevealCardInput, Q as RevealedCard, S as SetPinInput, T as TopUpInput, U as TopUpResult, V as TopUpTerms, W as TransferInput, X as TransferResult, Y as UpdateCardInput, Z as cardOrderBody, _ as cardRequestBody } from '../cards-
|
|
2
|
+
import '../http-CL97TjMO.js';
|
|
3
|
+
export { B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardInTransit, i as CardOrder, j as CardOrderError, k as CardOrderInput, C as CardProduct, l as CardProductPrice, m as CardStatus, n as CardStatusSource, o as CardTariff, p as CardTopUp, q as CardTopUpStatus, r as CardTransfer, s as CardType, t as Cardholder, c as CardsResource, u as CloseBlockedReason, v as CreateCardInput, M as IssuanceBonus, P as RevealCardInput, Q as RevealedCard, S as SetPinInput, T as TopUpInput, U as TopUpResult, V as TopUpTerms, W as TransferInput, X as TransferResult, Y as UpdateCardInput, Z as cardOrderBody, _ as cardRequestBody } from '../cards-DwmzjKDC.js';
|
package/dist/resources/debt.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import '../http-
|
|
2
|
-
export { h as CardLoadStatus, w as CreateDepositRefundInput, x as CreateQuoteInput, D as Deposit, z as DepositMethod, E as DepositStatus, b as DepositsResource, H as FeeKind, K as FundingQuote, L as InitiateDepositInput, N as IssueCardInput, R as Refund } from '../cards-
|
|
1
|
+
import '../http-CL97TjMO.cjs';
|
|
2
|
+
export { h as CardLoadStatus, w as CreateDepositRefundInput, x as CreateQuoteInput, D as Deposit, z as DepositMethod, E as DepositStatus, b as DepositsResource, H as FeeKind, K as FundingQuote, L as InitiateDepositInput, N as IssueCardInput, R as Refund } from '../cards-BiXmrz7h.cjs';
|
|
3
3
|
import './consents.cjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import '../http-
|
|
2
|
-
export { h as CardLoadStatus, w as CreateDepositRefundInput, x as CreateQuoteInput, D as Deposit, z as DepositMethod, E as DepositStatus, b as DepositsResource, H as FeeKind, K as FundingQuote, L as InitiateDepositInput, N as IssueCardInput, R as Refund } from '../cards-
|
|
1
|
+
import '../http-CL97TjMO.js';
|
|
2
|
+
export { h as CardLoadStatus, w as CreateDepositRefundInput, x as CreateQuoteInput, D as Deposit, z as DepositMethod, E as DepositStatus, b as DepositsResource, H as FeeKind, K as FundingQuote, L as InitiateDepositInput, N as IssueCardInput, R as Refund } from '../cards-DwmzjKDC.js';
|
|
3
3
|
import './consents.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import '../http-
|
|
2
|
-
export { c as Device, d as DeviceKind, e as DevicePlatform, D as DevicesResource, M as MobilePushCredential, f as RegisterDeviceInput, g as RegisterWebPushOptions, h as RegisteredDevice, U as UnregisterWebPushOptions, W as WebPushCredential, j as devicePlatformOf } from '../devices-
|
|
1
|
+
import '../http-CL97TjMO.cjs';
|
|
2
|
+
export { c as Device, d as DeviceKind, e as DevicePlatform, D as DevicesResource, M as MobilePushCredential, f as RegisterDeviceInput, g as RegisterWebPushOptions, h as RegisteredDevice, U as UnregisterWebPushOptions, W as WebPushCredential, j as devicePlatformOf } from '../devices-CiJrlXum.cjs';
|
|
3
3
|
import './push.cjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import '../http-
|
|
2
|
-
export { c as Device, d as DeviceKind, e as DevicePlatform, D as DevicesResource, M as MobilePushCredential, f as RegisterDeviceInput, g as RegisterWebPushOptions, h as RegisteredDevice, U as UnregisterWebPushOptions, W as WebPushCredential, j as devicePlatformOf } from '../devices-
|
|
1
|
+
import '../http-CL97TjMO.js';
|
|
2
|
+
export { c as Device, d as DeviceKind, e as DevicePlatform, D as DevicesResource, M as MobilePushCredential, f as RegisterDeviceInput, g as RegisterWebPushOptions, h as RegisteredDevice, U as UnregisterWebPushOptions, W as WebPushCredential, j as devicePlatformOf } from '../devices-C88c38hm.js';
|
|
3
3
|
import './push.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import '../http-
|
|
2
|
-
export { G as DepositTarget, I as FunderMode, J as FundingOption, F as FundingOptionsResource, O as MethodTerms } from '../cards-
|
|
1
|
+
import '../http-CL97TjMO.cjs';
|
|
2
|
+
export { G as DepositTarget, I as FunderMode, J as FundingOption, F as FundingOptionsResource, O as MethodTerms } from '../cards-BiXmrz7h.cjs';
|
|
3
3
|
import './consents.cjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import '../http-
|
|
2
|
-
export { G as DepositTarget, I as FunderMode, J as FundingOption, F as FundingOptionsResource, O as MethodTerms } from '../cards-
|
|
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';
|
package/dist/resources/me.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { H as HttpClient } from '../http-
|
|
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-
|
|
6
|
+
import '../cards-BiXmrz7h.cjs';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Me resource — `client.me.*`.
|
package/dist/resources/me.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { H as HttpClient } from '../http-
|
|
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-
|
|
6
|
+
import '../cards-DwmzjKDC.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Me resource — `client.me.*`.
|
package/dist/resources/push.d.ts
CHANGED
|
@@ -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":";;;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,KAA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**\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"]}
|