@amityco/ts-sdk 7.1.1-1d526d8.0 → 7.1.1-5d7c3fd0.0
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/dist/@types/domains/client.d.ts +1 -0
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/client/api/createClient.d.ts +1 -0
- package/dist/client/api/createClient.d.ts.map +1 -1
- package/dist/client/utils/endpoints.d.ts +1 -0
- package/dist/client/utils/endpoints.d.ts.map +1 -1
- package/dist/client/utils/setClientToken.d.ts.map +1 -1
- package/dist/index.cjs.js +16 -6
- package/dist/index.esm.js +16 -6
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
- package/src/@types/domains/client.ts +1 -0
- package/src/client/api/createClient.ts +4 -1
- package/src/client/utils/endpoints.ts +1 -0
- package/src/client/utils/setClientToken.ts +8 -0
- package/src/fileRepository/api/uploadFile.ts +1 -1
- package/src/fileRepository/api/uploadImage.ts +1 -1
- package/src/fileRepository/api/uploadVideo.ts +1 -1
package/package.json
CHANGED
|
@@ -50,7 +50,7 @@ export const createClient = (
|
|
|
50
50
|
rteEnabled = true,
|
|
51
51
|
}: {
|
|
52
52
|
debugSession?: string;
|
|
53
|
-
apiEndpoint?: { http?: string; mqtt?: string };
|
|
53
|
+
apiEndpoint?: { http?: string; mqtt?: string; upload?: string };
|
|
54
54
|
prefixDeviceIdKey?: string;
|
|
55
55
|
rteEnabled?: boolean;
|
|
56
56
|
} = {},
|
|
@@ -63,9 +63,11 @@ export const createClient = (
|
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
const httpEndpoint = apiEndpoint?.http ?? computeUrl('http', apiRegion);
|
|
66
|
+
const uploadEndpoint = apiEndpoint?.upload ?? computeUrl('upload', apiRegion);
|
|
66
67
|
const mqttEndpoint = apiEndpoint?.mqtt ?? computeUrl('mqtt', apiRegion);
|
|
67
68
|
|
|
68
69
|
const http = createHttpTransport(httpEndpoint);
|
|
70
|
+
const upload = createHttpTransport(uploadEndpoint);
|
|
69
71
|
|
|
70
72
|
let ws;
|
|
71
73
|
let mqtt;
|
|
@@ -103,6 +105,7 @@ export const createClient = (
|
|
|
103
105
|
http,
|
|
104
106
|
ws,
|
|
105
107
|
mqtt,
|
|
108
|
+
upload,
|
|
106
109
|
emitter,
|
|
107
110
|
|
|
108
111
|
/*
|
|
@@ -30,6 +30,14 @@ export const setClientToken = async (params: Parameters<typeof getToken>[0]) =>
|
|
|
30
30
|
isUserDeleted: false,
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
client.upload.defaults.headers.common.Authorization = `Bearer ${accessToken}`;
|
|
34
|
+
|
|
35
|
+
client.upload.defaults.metadata = {
|
|
36
|
+
tokenExpiry: expiresAt,
|
|
37
|
+
isGlobalBanned: false,
|
|
38
|
+
isUserDeleted: false,
|
|
39
|
+
};
|
|
40
|
+
|
|
33
41
|
// manually setup the token for ws transport
|
|
34
42
|
if (client.ws) client.ws.io.opts.query = { token: accessToken };
|
|
35
43
|
|
|
@@ -42,7 +42,7 @@ export const uploadFile = async <T extends Amity.FileType = any>(
|
|
|
42
42
|
? (formData as any).getHeaders()
|
|
43
43
|
: { 'content-type': 'multipart/form-data' };
|
|
44
44
|
|
|
45
|
-
const { data } = await client.
|
|
45
|
+
const { data } = await client.upload.post<Amity.CreateFilePayload<T>>('/api/v4/files', formData, {
|
|
46
46
|
headers,
|
|
47
47
|
onUploadProgress({ loaded, total = 100 }) {
|
|
48
48
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
@@ -42,7 +42,7 @@ export const uploadImage = async (
|
|
|
42
42
|
? (formData as any).getHeaders()
|
|
43
43
|
: { 'content-type': 'multipart/form-data' };
|
|
44
44
|
|
|
45
|
-
const { data } = await client.
|
|
45
|
+
const { data } = await client.upload.post<Amity.CreateFilePayload<'image'>>(
|
|
46
46
|
'/api/v4/images',
|
|
47
47
|
formData,
|
|
48
48
|
{
|
|
@@ -48,7 +48,7 @@ export const uploadVideo = async (
|
|
|
48
48
|
? (formData as any).getHeaders()
|
|
49
49
|
: { 'content-type': 'multipart/form-data' };
|
|
50
50
|
|
|
51
|
-
const { data } = await client.
|
|
51
|
+
const { data } = await client.upload.post<Amity.CreateFilePayload<'video'>>(
|
|
52
52
|
'/api/v4/videos',
|
|
53
53
|
formData,
|
|
54
54
|
{
|