tonightpass 0.0.97 → 0.0.99
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +12 -5
- package/dist/index.d.ts +12 -5
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/rest/endpoints.ts +4 -4
- package/src/rest/request/request.ts +8 -12
- package/src/rest/types/careers/index.ts +1 -1
- package/src/rest/types/notifications/index.ts +1 -1
- package/src/rest/types/users/index.ts +6 -0
- package/src/sdk/users/index.ts +19 -1
- package/src/utils/index.ts +20 -0
package/src/sdk/users/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { UpdateUserDto } from "../../rest";
|
|
1
|
+
import { UpdateUserDto, UserFileType } from "../../rest";
|
|
2
|
+
import { buildFileFormData } from "../../utils";
|
|
2
3
|
import { sdk } from "../builder";
|
|
3
4
|
|
|
4
5
|
export const users = sdk((client) => ({
|
|
@@ -9,4 +10,21 @@ export const users = sdk((client) => ({
|
|
|
9
10
|
client.get("/users/check/:identifier", { identifier, suggestions }),
|
|
10
11
|
update: async (userId: string, data: UpdateUserDto) =>
|
|
11
12
|
client.put("/users/:userId", data, { userId }),
|
|
13
|
+
uploadFile: async (
|
|
14
|
+
userId: string,
|
|
15
|
+
userFileType: UserFileType,
|
|
16
|
+
file: File,
|
|
17
|
+
) => {
|
|
18
|
+
return client.post(
|
|
19
|
+
"/users/:userId/files/:userFileType",
|
|
20
|
+
undefined,
|
|
21
|
+
{
|
|
22
|
+
userId,
|
|
23
|
+
userFileType,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
data: buildFileFormData("file", file),
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
},
|
|
12
30
|
}));
|
package/src/utils/index.ts
CHANGED
|
@@ -1 +1,21 @@
|
|
|
1
1
|
export const isBrowser = typeof window !== "undefined";
|
|
2
|
+
|
|
3
|
+
export function buildFileFormData(
|
|
4
|
+
key: string,
|
|
5
|
+
files: File | File[] | FileList,
|
|
6
|
+
): FormData {
|
|
7
|
+
const formData = new FormData();
|
|
8
|
+
|
|
9
|
+
if (files instanceof File) {
|
|
10
|
+
// Single file case
|
|
11
|
+
formData.append(key, files);
|
|
12
|
+
} else if (files instanceof FileList) {
|
|
13
|
+
// FileList case
|
|
14
|
+
Array.from(files).forEach((file) => formData.append(key, file));
|
|
15
|
+
} else {
|
|
16
|
+
// Array of files case
|
|
17
|
+
files.forEach((file) => formData.append(key, file));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return formData;
|
|
21
|
+
}
|