@pelican.ts/sdk 0.4.0 → 0.4.1
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/.husky/pre-commit +3 -3
- package/README.md +1 -5
- package/biome.json +32 -35
- package/dist/api/index.d.mts +2 -2
- package/dist/api/index.d.ts +2 -2
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +43 -6
- package/dist/index.mjs +34 -6
- package/dist/types.d.ts +7 -7
- package/package.json +59 -59
- package/src/api/client/types/server.ts +64 -51
- package/src/api/client/types/user.ts +18 -19
- package/src/api/client/types/websocket.ts +76 -76
- package/src/api/index.ts +4 -4
- package/src/humane/Account.ts +32 -43
- package/src/humane/Client.ts +17 -16
- package/src/humane/Server.ts +86 -97
- package/src/humane/ServerAllocation.ts +11 -9
- package/src/humane/ServerBackup.ts +7 -7
- package/src/humane/ServerDatabase.ts +6 -5
- package/src/humane/ServerFile.ts +33 -18
- package/src/humane/ServerSchedule.ts +81 -47
- package/src/humane/ServerUser.ts +20 -18
- package/src/index.ts +18 -5
- package/src/utils/sized.ts +2 -3
package/src/humane/ServerUser.ts
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
import type {ServerClient} from "@/api/client/server"
|
|
2
|
-
import type {
|
|
1
|
+
import type { ServerClient } from "@/api/client/server"
|
|
2
|
+
import type {
|
|
3
|
+
ServerSubuser,
|
|
4
|
+
SubuserPermission,
|
|
5
|
+
} from "@/api/client/types/server_subuser"
|
|
3
6
|
|
|
4
7
|
export class ServerUser {
|
|
5
8
|
private readonly client: ServerClient
|
|
6
9
|
|
|
7
|
-
readonly uuid: string
|
|
8
|
-
readonly username: string
|
|
9
|
-
readonly email: string
|
|
10
|
-
readonly language: string
|
|
11
|
-
readonly image: string
|
|
12
|
-
readonly admin: boolean
|
|
13
|
-
readonly root_admin: boolean
|
|
14
|
-
readonly has2faEnabled: boolean
|
|
15
|
-
readonly createdAt: Date
|
|
16
|
-
private $permissions: SubuserPermission[] | string[]
|
|
17
|
-
get permissions() {
|
|
10
|
+
readonly uuid: string
|
|
11
|
+
readonly username: string
|
|
12
|
+
readonly email: string
|
|
13
|
+
readonly language: string
|
|
14
|
+
readonly image: string
|
|
15
|
+
readonly admin: boolean
|
|
16
|
+
readonly root_admin: boolean
|
|
17
|
+
readonly has2faEnabled: boolean
|
|
18
|
+
readonly createdAt: Date
|
|
19
|
+
private $permissions: SubuserPermission[] | string[]
|
|
20
|
+
get permissions() {
|
|
21
|
+
return this.$permissions
|
|
22
|
+
}
|
|
18
23
|
|
|
19
24
|
constructor(client: ServerClient, user: ServerSubuser) {
|
|
20
25
|
this.client = client
|
|
@@ -30,13 +35,10 @@ export class ServerUser {
|
|
|
30
35
|
this.$permissions = user.permissions
|
|
31
36
|
}
|
|
32
37
|
|
|
33
|
-
update = async (
|
|
34
|
-
permissions: SubuserPermission[] | string[]
|
|
35
|
-
) => {
|
|
38
|
+
update = async (permissions: SubuserPermission[] | string[]) => {
|
|
36
39
|
const data = await this.client.users.update(this.uuid, permissions)
|
|
37
40
|
this.$permissions = data.permissions
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
delete = async () => this.client.users.delete(this.uuid)
|
|
41
|
-
|
|
42
|
-
}
|
|
44
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
import {PelicanAPIClient} from "@/api"
|
|
2
|
-
import {Client as UserClient} from "@/humane/Client"
|
|
1
|
+
import { PelicanAPIClient } from "@/api"
|
|
2
|
+
import { Client as UserClient } from "@/humane/Client"
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export const createPelicanClient = (
|
|
5
|
+
url: string,
|
|
6
|
+
token: string,
|
|
7
|
+
suffix: string = "/api",
|
|
8
|
+
) => {
|
|
6
9
|
const client = new PelicanAPIClient(url, token, suffix)
|
|
7
10
|
return new UserClient(client)
|
|
8
|
-
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {Client} from "@/humane/Client"
|
|
14
|
+
export {Account} from "@/humane/Account"
|
|
15
|
+
export {Server} from "@/humane/Server"
|
|
16
|
+
export {ServerAllocation} from "@/humane/ServerAllocation"
|
|
17
|
+
export {ServerBackup} from "@/humane/ServerBackup"
|
|
18
|
+
export {ServerDatabase} from "@/humane/ServerDatabase"
|
|
19
|
+
export {ServerFile} from "@/humane/ServerFile"
|
|
20
|
+
export {ServerSchedule} from "@/humane/ServerSchedule"
|
|
21
|
+
export {ServerUser} from "@/humane/ServerUser"
|
package/src/utils/sized.ts
CHANGED
|
@@ -3,12 +3,11 @@ export const SIZES = {
|
|
|
3
3
|
KB: 1024,
|
|
4
4
|
MB: 1024 * 1024,
|
|
5
5
|
GB: 1024 * 1024 * 1024,
|
|
6
|
-
TB: 1024 * 1024 * 1024 * 1024
|
|
6
|
+
TB: 1024 * 1024 * 1024 * 1024,
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const sized = (bytes: number, unit: keyof typeof SIZES): number => {
|
|
10
10
|
return parseInt((bytes / SIZES[unit]).toFixed(3), 10)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
export default sized
|
|
13
|
+
export default sized
|