@temboplus/afloat 0.2.0-beta.8 → 0.2.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/README.md +150 -238
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/lib/api/base-repository.d.ts +8 -8
- package/dist/modules/auth/auth.contract.d.ts +30 -28
- package/dist/modules/auth/auth.dtos.d.ts +117 -0
- package/dist/modules/auth/auth.repository.d.ts +9 -4
- package/dist/modules/auth/company-membership.model.d.ts +13 -13
- package/dist/modules/auth/index.d.ts +1 -0
- package/dist/modules/auth/user.model.d.ts +27 -66
- package/dist/modules/beneficiary/beneficiary-info.model.d.ts +113 -56
- package/dist/modules/beneficiary/beneficiary.model.d.ts +53 -64
- package/dist/modules/beneficiary/index.d.ts +2 -2
- package/dist/modules/login/login.model.d.ts +26 -3
- package/dist/modules/payout/payout-channel-handler.d.ts +7 -6
- package/dist/modules/payout/payout.api-contract.d.ts +40 -0
- package/dist/modules/payout/payout.model.d.ts +4 -4
- package/dist/modules/profile/profile.model.d.ts +3 -3
- package/dist/modules/team-member/role.model.d.ts +3 -3
- package/dist/modules/team-member/team-member.model.d.ts +8 -8
- package/dist/modules/wallet/narration.model.d.ts +5 -5
- package/dist/modules/wallet/statement-entry.model.d.ts +23 -23
- package/dist/modules/wallet/wallet.model.d.ts +3 -3
- package/dist/modules/wallet/wallet.repository.d.ts +2 -2
- package/package.json +3 -4
|
@@ -6,24 +6,24 @@ export declare const setGlobalTokenGetter: (getter: TokenGetter) => void;
|
|
|
6
6
|
* BaseRepository - Generic base class for API repositories
|
|
7
7
|
*
|
|
8
8
|
* Provides a consistent way to interact with the Afloat API using ts-rest contracts.
|
|
9
|
-
* Handles authentication token management through
|
|
9
|
+
* Handles authentication token management through explicit repository options
|
|
10
|
+
* or a host-provided global token getter.
|
|
10
11
|
*
|
|
11
12
|
* **Token Resolution Order:**
|
|
12
13
|
* 1. Direct token provided in constructor
|
|
13
|
-
* 2. Global
|
|
14
|
+
* 2. Global token getter configured by the host app
|
|
14
15
|
*
|
|
15
16
|
* @template TContract - The API contract extending `AppRouter` from `@ts-rest/core`
|
|
16
17
|
*
|
|
17
18
|
* @example
|
|
18
19
|
* ```typescript
|
|
19
|
-
* //
|
|
20
|
+
* // Recommended authenticated usage
|
|
20
21
|
* const repo = new WalletRepository("wallet", walletContract, {
|
|
21
22
|
* token: "user-auth-token"
|
|
22
23
|
* });
|
|
23
24
|
*
|
|
24
|
-
* //
|
|
25
|
-
* //
|
|
26
|
-
* const repo = new WalletRepository("wallet", walletContract);
|
|
25
|
+
* // Advanced: the host app may also provide a global token getter,
|
|
26
|
+
* // but explicit tokens are the recommended integration path.
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
export declare class BaseRepository<TContract extends AppRouter> {
|
|
@@ -64,8 +64,8 @@ export declare class BaseRepository<TContract extends AppRouter> {
|
|
|
64
64
|
* root: "https://api-staging.afloat.money/v1"
|
|
65
65
|
* });
|
|
66
66
|
*
|
|
67
|
-
* //
|
|
68
|
-
*
|
|
67
|
+
* // Advanced global token getter fallback is supported,
|
|
68
|
+
* // but explicit tokens are the recommended integration path.
|
|
69
69
|
* ```
|
|
70
70
|
*/
|
|
71
71
|
constructor(endpoint: string, contract: TContract, options?: {
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
1
|
/**
|
|
3
2
|
* Auth API contract
|
|
4
3
|
*/
|
|
5
4
|
export declare const authContract: {
|
|
6
5
|
logIn: {
|
|
7
6
|
method: "POST";
|
|
8
|
-
body:
|
|
9
|
-
type:
|
|
10
|
-
identity:
|
|
11
|
-
password:
|
|
12
|
-
}, "strip",
|
|
7
|
+
body: import("zod").ZodObject<{
|
|
8
|
+
type: import("zod").ZodDefault<import("zod").ZodString>;
|
|
9
|
+
identity: import("zod").ZodString;
|
|
10
|
+
password: import("zod").ZodString;
|
|
11
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
13
12
|
type: string;
|
|
14
13
|
identity: string;
|
|
15
14
|
password: string;
|
|
@@ -20,17 +19,17 @@ export declare const authContract: {
|
|
|
20
19
|
}>;
|
|
21
20
|
path: "/login";
|
|
22
21
|
responses: {
|
|
23
|
-
201:
|
|
24
|
-
profile:
|
|
25
|
-
id:
|
|
26
|
-
firstName:
|
|
27
|
-
lastName:
|
|
28
|
-
displayName:
|
|
29
|
-
phone:
|
|
30
|
-
accountNo:
|
|
31
|
-
email:
|
|
32
|
-
autoApprove:
|
|
33
|
-
}, "strip",
|
|
22
|
+
201: import("zod").ZodObject<{
|
|
23
|
+
profile: import("zod").ZodObject<{
|
|
24
|
+
id: import("zod").ZodString;
|
|
25
|
+
firstName: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
26
|
+
lastName: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
27
|
+
displayName: import("zod").ZodString;
|
|
28
|
+
phone: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
29
|
+
accountNo: import("zod").ZodString;
|
|
30
|
+
email: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
31
|
+
autoApprove: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodBoolean>>;
|
|
32
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
34
33
|
id: string;
|
|
35
34
|
displayName: string;
|
|
36
35
|
accountNo: string;
|
|
@@ -49,10 +48,10 @@ export declare const authContract: {
|
|
|
49
48
|
email?: string | null | undefined;
|
|
50
49
|
autoApprove?: boolean | null | undefined;
|
|
51
50
|
}>;
|
|
52
|
-
token:
|
|
53
|
-
access:
|
|
54
|
-
resetPassword:
|
|
55
|
-
}, "strip",
|
|
51
|
+
token: import("zod").ZodString;
|
|
52
|
+
access: import("zod").ZodArray<import("zod").ZodString, "many">;
|
|
53
|
+
resetPassword: import("zod").ZodBoolean;
|
|
54
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
56
55
|
token: string;
|
|
57
56
|
resetPassword: boolean;
|
|
58
57
|
access: string[];
|
|
@@ -81,22 +80,22 @@ export declare const authContract: {
|
|
|
81
80
|
autoApprove?: boolean | null | undefined;
|
|
82
81
|
};
|
|
83
82
|
}>;
|
|
84
|
-
400:
|
|
83
|
+
400: import("zod").ZodObject<{}, "strip", import("zod").ZodTypeAny, {}, {}>;
|
|
85
84
|
};
|
|
86
85
|
};
|
|
87
86
|
access: {
|
|
88
87
|
method: "GET";
|
|
89
88
|
path: "/access";
|
|
90
89
|
responses: {
|
|
91
|
-
200:
|
|
90
|
+
200: import("zod").ZodArray<import("zod").ZodString, "many">;
|
|
92
91
|
};
|
|
93
92
|
};
|
|
94
93
|
resetPassword: {
|
|
95
94
|
method: "PUT";
|
|
96
|
-
body:
|
|
97
|
-
currentPassword:
|
|
98
|
-
newPassword:
|
|
99
|
-
}, "strip",
|
|
95
|
+
body: import("zod").ZodObject<{
|
|
96
|
+
currentPassword: import("zod").ZodString;
|
|
97
|
+
newPassword: import("zod").ZodString;
|
|
98
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
100
99
|
newPassword: string;
|
|
101
100
|
currentPassword: string;
|
|
102
101
|
}, {
|
|
@@ -104,6 +103,9 @@ export declare const authContract: {
|
|
|
104
103
|
currentPassword: string;
|
|
105
104
|
}>;
|
|
106
105
|
path: "/password";
|
|
107
|
-
responses: {
|
|
106
|
+
responses: {
|
|
107
|
+
200: import("zod").ZodObject<{}, "strip", import("zod").ZodTypeAny, {}, {}>;
|
|
108
|
+
400: import("zod").ZodObject<{}, "strip", import("zod").ZodTypeAny, {}, {}>;
|
|
109
|
+
};
|
|
108
110
|
};
|
|
109
111
|
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Collection of all auth-related schemas.
|
|
4
|
+
*/
|
|
5
|
+
export declare const AuthDTOSchemas: {
|
|
6
|
+
/** Schema for login request validation */
|
|
7
|
+
logInRequestDTO: z.ZodObject<{
|
|
8
|
+
type: z.ZodDefault<z.ZodString>;
|
|
9
|
+
identity: z.ZodString;
|
|
10
|
+
password: z.ZodString;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
type: string;
|
|
13
|
+
identity: string;
|
|
14
|
+
password: string;
|
|
15
|
+
}, {
|
|
16
|
+
identity: string;
|
|
17
|
+
password: string;
|
|
18
|
+
type?: string | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
/** Schema for successful login responses */
|
|
21
|
+
logInResponseDTO: z.ZodObject<{
|
|
22
|
+
profile: z.ZodObject<{
|
|
23
|
+
id: z.ZodString;
|
|
24
|
+
firstName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
25
|
+
lastName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
26
|
+
displayName: z.ZodString;
|
|
27
|
+
phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
28
|
+
accountNo: z.ZodString;
|
|
29
|
+
email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
30
|
+
autoApprove: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
id: string;
|
|
33
|
+
displayName: string;
|
|
34
|
+
accountNo: string;
|
|
35
|
+
firstName?: string | null | undefined;
|
|
36
|
+
lastName?: string | null | undefined;
|
|
37
|
+
phone?: string | null | undefined;
|
|
38
|
+
email?: string | null | undefined;
|
|
39
|
+
autoApprove?: boolean | null | undefined;
|
|
40
|
+
}, {
|
|
41
|
+
id: string;
|
|
42
|
+
displayName: string;
|
|
43
|
+
accountNo: string;
|
|
44
|
+
firstName?: string | null | undefined;
|
|
45
|
+
lastName?: string | null | undefined;
|
|
46
|
+
phone?: string | null | undefined;
|
|
47
|
+
email?: string | null | undefined;
|
|
48
|
+
autoApprove?: boolean | null | undefined;
|
|
49
|
+
}>;
|
|
50
|
+
token: z.ZodString;
|
|
51
|
+
access: z.ZodArray<z.ZodString, "many">;
|
|
52
|
+
resetPassword: z.ZodBoolean;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
token: string;
|
|
55
|
+
resetPassword: boolean;
|
|
56
|
+
access: string[];
|
|
57
|
+
profile: {
|
|
58
|
+
id: string;
|
|
59
|
+
displayName: string;
|
|
60
|
+
accountNo: string;
|
|
61
|
+
firstName?: string | null | undefined;
|
|
62
|
+
lastName?: string | null | undefined;
|
|
63
|
+
phone?: string | null | undefined;
|
|
64
|
+
email?: string | null | undefined;
|
|
65
|
+
autoApprove?: boolean | null | undefined;
|
|
66
|
+
};
|
|
67
|
+
}, {
|
|
68
|
+
token: string;
|
|
69
|
+
resetPassword: boolean;
|
|
70
|
+
access: string[];
|
|
71
|
+
profile: {
|
|
72
|
+
id: string;
|
|
73
|
+
displayName: string;
|
|
74
|
+
accountNo: string;
|
|
75
|
+
firstName?: string | null | undefined;
|
|
76
|
+
lastName?: string | null | undefined;
|
|
77
|
+
phone?: string | null | undefined;
|
|
78
|
+
email?: string | null | undefined;
|
|
79
|
+
autoApprove?: boolean | null | undefined;
|
|
80
|
+
};
|
|
81
|
+
}>;
|
|
82
|
+
/** Schema for access list responses */
|
|
83
|
+
accessResponseDTO: z.ZodArray<z.ZodString, "many">;
|
|
84
|
+
/** Schema for reset password request validation */
|
|
85
|
+
resetPasswordRequestDTO: z.ZodObject<{
|
|
86
|
+
currentPassword: z.ZodString;
|
|
87
|
+
newPassword: z.ZodString;
|
|
88
|
+
}, "strip", z.ZodTypeAny, {
|
|
89
|
+
newPassword: string;
|
|
90
|
+
currentPassword: string;
|
|
91
|
+
}, {
|
|
92
|
+
newPassword: string;
|
|
93
|
+
currentPassword: string;
|
|
94
|
+
}>;
|
|
95
|
+
/** Schema for empty responses */
|
|
96
|
+
emptyResponseDTO: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Type representing the login request payload.
|
|
100
|
+
*/
|
|
101
|
+
export type AuthLogInRequestDTO = z.infer<typeof AuthDTOSchemas.logInRequestDTO>;
|
|
102
|
+
/**
|
|
103
|
+
* Type representing a successful login response.
|
|
104
|
+
*/
|
|
105
|
+
export type AuthLogInResponseDTO = z.infer<typeof AuthDTOSchemas.logInResponseDTO>;
|
|
106
|
+
/**
|
|
107
|
+
* Type representing the access list response.
|
|
108
|
+
*/
|
|
109
|
+
export type AuthAccessResponseDTO = z.infer<typeof AuthDTOSchemas.accessResponseDTO>;
|
|
110
|
+
/**
|
|
111
|
+
* Type representing the reset password request payload.
|
|
112
|
+
*/
|
|
113
|
+
export type AuthResetPasswordRequestDTO = z.infer<typeof AuthDTOSchemas.resetPasswordRequestDTO>;
|
|
114
|
+
/**
|
|
115
|
+
* Type representing an empty auth response.
|
|
116
|
+
*/
|
|
117
|
+
export type AuthEmptyResponseDTO = z.infer<typeof AuthDTOSchemas.emptyResponseDTO>;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { BaseRepository } from "@/lib/api/base-repository.js";
|
|
2
2
|
import { User } from "@/modules/auth/user.model.js";
|
|
3
3
|
import { authContract } from "./auth.contract.js";
|
|
4
|
+
export type AuthLogInResult = {
|
|
5
|
+
token: string;
|
|
6
|
+
user: User;
|
|
7
|
+
};
|
|
4
8
|
/**
|
|
5
9
|
* Repository class for handling authentication-related operations.
|
|
6
10
|
* Provides methods for user login and password management.
|
|
@@ -10,7 +14,7 @@ import { authContract } from "./auth.contract.js";
|
|
|
10
14
|
* @example
|
|
11
15
|
* ```typescript
|
|
12
16
|
* const authRepo = new AuthRepository();
|
|
13
|
-
* const user = await authRepo.logIn("user@example.com", "password");
|
|
17
|
+
* const { token, user } = await authRepo.logIn("user@example.com", "password");
|
|
14
18
|
* ```
|
|
15
19
|
*/
|
|
16
20
|
export declare class AuthRepository extends BaseRepository<typeof authContract> {
|
|
@@ -30,20 +34,21 @@ export declare class AuthRepository extends BaseRepository<typeof authContract>
|
|
|
30
34
|
*
|
|
31
35
|
* @param email - The email of the user attempting to log in
|
|
32
36
|
* @param password - The password of the user
|
|
33
|
-
* @returns Promise that resolves to
|
|
37
|
+
* @returns Promise that resolves to the auth token and User object on successful login
|
|
34
38
|
* @throws {APIError} If the email or password is invalid, or if another error occurs during login
|
|
35
39
|
*
|
|
36
40
|
* @example
|
|
37
41
|
* ```typescript
|
|
38
42
|
* try {
|
|
39
|
-
* const user = await authRepo.logIn("user@example.com", "securePassword");
|
|
43
|
+
* const { token, user } = await authRepo.logIn("user@example.com", "securePassword");
|
|
44
|
+
* tokenStore.set(token);
|
|
40
45
|
* console.log(`Welcome ${user.name}!`);
|
|
41
46
|
* } catch (error) {
|
|
42
47
|
* console.error("Login failed:", error.message);
|
|
43
48
|
* }
|
|
44
49
|
* ```
|
|
45
50
|
*/
|
|
46
|
-
logIn(email: string, password: string): Promise<
|
|
51
|
+
logIn(email: string, password: string): Promise<AuthLogInResult>;
|
|
47
52
|
/**
|
|
48
53
|
* Updates the current user's password.
|
|
49
54
|
*
|
|
@@ -14,12 +14,12 @@ export declare const CompanyMembershipJSONSchema: z.ZodObject<{
|
|
|
14
14
|
accountNo: z.ZodString;
|
|
15
15
|
email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
16
16
|
autoApprove: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
17
|
-
|
|
17
|
+
_version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
18
18
|
}, "strip", z.ZodTypeAny, {
|
|
19
19
|
id: string;
|
|
20
20
|
displayName: string;
|
|
21
21
|
accountNo: string;
|
|
22
|
-
|
|
22
|
+
_version: string;
|
|
23
23
|
firstName?: string | null | undefined;
|
|
24
24
|
lastName?: string | null | undefined;
|
|
25
25
|
phone?: string | null | undefined;
|
|
@@ -34,7 +34,7 @@ export declare const CompanyMembershipJSONSchema: z.ZodObject<{
|
|
|
34
34
|
phone?: string | null | undefined;
|
|
35
35
|
email?: string | null | undefined;
|
|
36
36
|
autoApprove?: boolean | null | undefined;
|
|
37
|
-
|
|
37
|
+
_version?: string | undefined;
|
|
38
38
|
}>;
|
|
39
39
|
role: z.ZodOptional<z.ZodObject<{
|
|
40
40
|
id: z.ZodString;
|
|
@@ -43,12 +43,12 @@ export declare const CompanyMembershipJSONSchema: z.ZodObject<{
|
|
|
43
43
|
access: z.ZodArray<z.ZodString, "many">;
|
|
44
44
|
createdAt: z.ZodString;
|
|
45
45
|
updatedAt: z.ZodString;
|
|
46
|
-
|
|
46
|
+
_version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
47
47
|
}, "strip", z.ZodTypeAny, {
|
|
48
48
|
name: string;
|
|
49
49
|
createdAt: string;
|
|
50
50
|
id: string;
|
|
51
|
-
|
|
51
|
+
_version: string;
|
|
52
52
|
updatedAt: string;
|
|
53
53
|
access: string[];
|
|
54
54
|
description?: string | undefined;
|
|
@@ -58,17 +58,17 @@ export declare const CompanyMembershipJSONSchema: z.ZodObject<{
|
|
|
58
58
|
id: string;
|
|
59
59
|
updatedAt: string;
|
|
60
60
|
access: string[];
|
|
61
|
-
|
|
61
|
+
_version?: string | undefined;
|
|
62
62
|
description?: string | undefined;
|
|
63
63
|
}>>;
|
|
64
|
-
|
|
64
|
+
_version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
65
65
|
}, "strip", z.ZodTypeAny, {
|
|
66
|
-
|
|
66
|
+
_version: string;
|
|
67
67
|
companyProfile: {
|
|
68
68
|
id: string;
|
|
69
69
|
displayName: string;
|
|
70
70
|
accountNo: string;
|
|
71
|
-
|
|
71
|
+
_version: string;
|
|
72
72
|
firstName?: string | null | undefined;
|
|
73
73
|
lastName?: string | null | undefined;
|
|
74
74
|
phone?: string | null | undefined;
|
|
@@ -79,7 +79,7 @@ export declare const CompanyMembershipJSONSchema: z.ZodObject<{
|
|
|
79
79
|
name: string;
|
|
80
80
|
createdAt: string;
|
|
81
81
|
id: string;
|
|
82
|
-
|
|
82
|
+
_version: string;
|
|
83
83
|
updatedAt: string;
|
|
84
84
|
access: string[];
|
|
85
85
|
description?: string | undefined;
|
|
@@ -94,16 +94,16 @@ export declare const CompanyMembershipJSONSchema: z.ZodObject<{
|
|
|
94
94
|
phone?: string | null | undefined;
|
|
95
95
|
email?: string | null | undefined;
|
|
96
96
|
autoApprove?: boolean | null | undefined;
|
|
97
|
-
|
|
97
|
+
_version?: string | undefined;
|
|
98
98
|
};
|
|
99
|
-
|
|
99
|
+
_version?: string | undefined;
|
|
100
100
|
role?: {
|
|
101
101
|
name: string;
|
|
102
102
|
createdAt: string;
|
|
103
103
|
id: string;
|
|
104
104
|
updatedAt: string;
|
|
105
105
|
access: string[];
|
|
106
|
-
|
|
106
|
+
_version?: string | undefined;
|
|
107
107
|
description?: string | undefined;
|
|
108
108
|
} | undefined;
|
|
109
109
|
}>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Permission } from "../login/permission.type.js";
|
|
2
1
|
import { Profile } from "../profile/profile.model.js";
|
|
3
2
|
import { LogIn } from "../login/login.model.js";
|
|
4
3
|
import { CompanyMembership } from "./company-membership.model.js";
|
|
@@ -22,13 +21,13 @@ export declare const UserJSONSchema: z.ZodObject<{
|
|
|
22
21
|
createdAt: z.ZodString;
|
|
23
22
|
updatedAt: z.ZodString;
|
|
24
23
|
access: z.ZodArray<z.ZodString, "many">;
|
|
25
|
-
|
|
24
|
+
_version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
26
25
|
}, "strip", z.ZodTypeAny, {
|
|
27
26
|
type: string;
|
|
28
27
|
name: string;
|
|
29
28
|
createdAt: string;
|
|
30
29
|
id: string;
|
|
31
|
-
|
|
30
|
+
_version: string;
|
|
32
31
|
profileId: string;
|
|
33
32
|
identity: string;
|
|
34
33
|
roleId: string;
|
|
@@ -50,7 +49,7 @@ export declare const UserJSONSchema: z.ZodObject<{
|
|
|
50
49
|
resetPassword: boolean;
|
|
51
50
|
updatedAt: string;
|
|
52
51
|
access: string[];
|
|
53
|
-
|
|
52
|
+
_version?: string | undefined;
|
|
54
53
|
}>;
|
|
55
54
|
companyProfile: z.ZodObject<{
|
|
56
55
|
id: z.ZodString;
|
|
@@ -61,12 +60,12 @@ export declare const UserJSONSchema: z.ZodObject<{
|
|
|
61
60
|
accountNo: z.ZodString;
|
|
62
61
|
email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
63
62
|
autoApprove: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
64
|
-
|
|
63
|
+
_version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
65
64
|
}, "strip", z.ZodTypeAny, {
|
|
66
65
|
id: string;
|
|
67
66
|
displayName: string;
|
|
68
67
|
accountNo: string;
|
|
69
|
-
|
|
68
|
+
_version: string;
|
|
70
69
|
firstName?: string | null | undefined;
|
|
71
70
|
lastName?: string | null | undefined;
|
|
72
71
|
phone?: string | null | undefined;
|
|
@@ -81,7 +80,7 @@ export declare const UserJSONSchema: z.ZodObject<{
|
|
|
81
80
|
phone?: string | null | undefined;
|
|
82
81
|
email?: string | null | undefined;
|
|
83
82
|
autoApprove?: boolean | null | undefined;
|
|
84
|
-
|
|
83
|
+
_version?: string | undefined;
|
|
85
84
|
}>;
|
|
86
85
|
role: z.ZodOptional<z.ZodObject<{
|
|
87
86
|
id: z.ZodString;
|
|
@@ -90,12 +89,12 @@ export declare const UserJSONSchema: z.ZodObject<{
|
|
|
90
89
|
access: z.ZodArray<z.ZodString, "many">;
|
|
91
90
|
createdAt: z.ZodString;
|
|
92
91
|
updatedAt: z.ZodString;
|
|
93
|
-
|
|
92
|
+
_version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
94
93
|
}, "strip", z.ZodTypeAny, {
|
|
95
94
|
name: string;
|
|
96
95
|
createdAt: string;
|
|
97
96
|
id: string;
|
|
98
|
-
|
|
97
|
+
_version: string;
|
|
99
98
|
updatedAt: string;
|
|
100
99
|
access: string[];
|
|
101
100
|
description?: string | undefined;
|
|
@@ -105,19 +104,17 @@ export declare const UserJSONSchema: z.ZodObject<{
|
|
|
105
104
|
id: string;
|
|
106
105
|
updatedAt: string;
|
|
107
106
|
access: string[];
|
|
108
|
-
|
|
107
|
+
_version?: string | undefined;
|
|
109
108
|
description?: string | undefined;
|
|
110
109
|
}>>;
|
|
111
|
-
|
|
112
|
-
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
110
|
+
_version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
113
111
|
}, "strip", z.ZodTypeAny, {
|
|
114
|
-
|
|
115
|
-
version: string;
|
|
112
|
+
_version: string;
|
|
116
113
|
companyProfile: {
|
|
117
114
|
id: string;
|
|
118
115
|
displayName: string;
|
|
119
116
|
accountNo: string;
|
|
120
|
-
|
|
117
|
+
_version: string;
|
|
121
118
|
firstName?: string | null | undefined;
|
|
122
119
|
lastName?: string | null | undefined;
|
|
123
120
|
phone?: string | null | undefined;
|
|
@@ -129,7 +126,7 @@ export declare const UserJSONSchema: z.ZodObject<{
|
|
|
129
126
|
name: string;
|
|
130
127
|
createdAt: string;
|
|
131
128
|
id: string;
|
|
132
|
-
|
|
129
|
+
_version: string;
|
|
133
130
|
profileId: string;
|
|
134
131
|
identity: string;
|
|
135
132
|
roleId: string;
|
|
@@ -143,13 +140,12 @@ export declare const UserJSONSchema: z.ZodObject<{
|
|
|
143
140
|
name: string;
|
|
144
141
|
createdAt: string;
|
|
145
142
|
id: string;
|
|
146
|
-
|
|
143
|
+
_version: string;
|
|
147
144
|
updatedAt: string;
|
|
148
145
|
access: string[];
|
|
149
146
|
description?: string | undefined;
|
|
150
147
|
} | undefined;
|
|
151
148
|
}, {
|
|
152
|
-
token: string;
|
|
153
149
|
companyProfile: {
|
|
154
150
|
id: string;
|
|
155
151
|
displayName: string;
|
|
@@ -159,7 +155,7 @@ export declare const UserJSONSchema: z.ZodObject<{
|
|
|
159
155
|
phone?: string | null | undefined;
|
|
160
156
|
email?: string | null | undefined;
|
|
161
157
|
autoApprove?: boolean | null | undefined;
|
|
162
|
-
|
|
158
|
+
_version?: string | undefined;
|
|
163
159
|
};
|
|
164
160
|
logIn: {
|
|
165
161
|
type: string;
|
|
@@ -174,16 +170,16 @@ export declare const UserJSONSchema: z.ZodObject<{
|
|
|
174
170
|
resetPassword: boolean;
|
|
175
171
|
updatedAt: string;
|
|
176
172
|
access: string[];
|
|
177
|
-
|
|
173
|
+
_version?: string | undefined;
|
|
178
174
|
};
|
|
179
|
-
|
|
175
|
+
_version?: string | undefined;
|
|
180
176
|
role?: {
|
|
181
177
|
name: string;
|
|
182
178
|
createdAt: string;
|
|
183
179
|
id: string;
|
|
184
180
|
updatedAt: string;
|
|
185
181
|
access: string[];
|
|
186
|
-
|
|
182
|
+
_version?: string | undefined;
|
|
187
183
|
description?: string | undefined;
|
|
188
184
|
} | undefined;
|
|
189
185
|
}>;
|
|
@@ -195,17 +191,15 @@ export type UserData = {
|
|
|
195
191
|
logIn: LogIn;
|
|
196
192
|
companyProfile: Profile;
|
|
197
193
|
role?: Role;
|
|
198
|
-
token: string;
|
|
199
194
|
};
|
|
200
195
|
/**
|
|
201
|
-
* Represents the currently authenticated user
|
|
196
|
+
* Represents the currently authenticated user context.
|
|
202
197
|
*
|
|
203
198
|
* This class combines:
|
|
204
199
|
* - LogIn: User account data (identity, permissions, resetPassword, etc.)
|
|
205
200
|
* - CompanyMembership: User's relationship to their company (company profile + role)
|
|
206
|
-
* - Token: Session authentication token
|
|
207
201
|
*
|
|
208
|
-
* The User represents "who is logged in right now" with their full context.
|
|
202
|
+
* The User represents "who is logged in right now" with their full profile context.
|
|
209
203
|
*
|
|
210
204
|
* Note: The role in CompanyMembership may be undefined if the user doesn't have
|
|
211
205
|
* permission to view role details (Permissions.Role.ViewRole).
|
|
@@ -213,8 +207,6 @@ export type UserData = {
|
|
|
213
207
|
export declare class User {
|
|
214
208
|
private readonly _logIn;
|
|
215
209
|
private readonly _membership;
|
|
216
|
-
private readonly _token;
|
|
217
|
-
private readonly _permissionMap;
|
|
218
210
|
private constructor();
|
|
219
211
|
/**
|
|
220
212
|
* Creates a User instance from the provided data.
|
|
@@ -228,7 +220,6 @@ export declare class User {
|
|
|
228
220
|
* logIn: logIn,
|
|
229
221
|
* companyProfile: profile,
|
|
230
222
|
* role: role, // optional
|
|
231
|
-
* token: "auth-token"
|
|
232
223
|
* });
|
|
233
224
|
* ```
|
|
234
225
|
*/
|
|
@@ -238,13 +229,13 @@ export declare class User {
|
|
|
238
229
|
*/
|
|
239
230
|
get logIn(): LogIn;
|
|
240
231
|
/**
|
|
241
|
-
* Gets the user's
|
|
232
|
+
* Gets the user's login data.
|
|
242
233
|
*/
|
|
243
|
-
get
|
|
234
|
+
get login(): LogIn;
|
|
244
235
|
/**
|
|
245
|
-
* Gets the user's
|
|
236
|
+
* Gets the user's company membership (includes company profile and role).
|
|
246
237
|
*/
|
|
247
|
-
get
|
|
238
|
+
get membership(): CompanyMembership;
|
|
248
239
|
/**
|
|
249
240
|
* Convenience getter for the user's ID.
|
|
250
241
|
*/
|
|
@@ -277,41 +268,12 @@ export declare class User {
|
|
|
277
268
|
* Convenience getter for permissions array.
|
|
278
269
|
*/
|
|
279
270
|
get access(): ReadonlyArray<string>;
|
|
280
|
-
/**
|
|
281
|
-
* Checks if the user has a specific permission.
|
|
282
|
-
*
|
|
283
|
-
* @param permission - The permission to check
|
|
284
|
-
* @returns true if the user has the permission
|
|
285
|
-
*/
|
|
286
|
-
can(permission: Permission): boolean;
|
|
287
|
-
/**
|
|
288
|
-
* Checks if the user has any of the specified permissions.
|
|
289
|
-
*
|
|
290
|
-
* @param permissions - Array of permissions to check
|
|
291
|
-
* @returns true if the user has at least one permission
|
|
292
|
-
*/
|
|
293
|
-
canAny(permissions: Permission[]): boolean;
|
|
294
|
-
/**
|
|
295
|
-
* Checks if the user has all of the specified permissions.
|
|
296
|
-
*
|
|
297
|
-
* @param permissions - Array of permissions to check
|
|
298
|
-
* @returns true if the user has all permissions
|
|
299
|
-
*/
|
|
300
|
-
canAll(permissions: Permission[]): boolean;
|
|
301
|
-
/**
|
|
302
|
-
* Checks if the user can manage team members.
|
|
303
|
-
*/
|
|
304
|
-
canManageTeam(): boolean;
|
|
305
|
-
/**
|
|
306
|
-
* Checks if the user can view role details.
|
|
307
|
-
*/
|
|
308
|
-
canViewRoles(): boolean;
|
|
309
271
|
/**
|
|
310
272
|
* Serializes the User instance to a JSON-compatible object
|
|
311
273
|
*
|
|
312
274
|
* This method creates a complete snapshot of the user session including
|
|
313
|
-
* all nested objects (LogIn, Profile, Role).
|
|
314
|
-
*
|
|
275
|
+
* all nested objects (LogIn, Profile, Role). Authentication tokens are kept
|
|
276
|
+
* outside of the User model and are not serialized here.
|
|
315
277
|
*
|
|
316
278
|
* @returns {UserJSON} A plain object containing all necessary User data
|
|
317
279
|
*
|
|
@@ -349,8 +311,7 @@ export declare class User {
|
|
|
349
311
|
* // From object
|
|
350
312
|
* const userJson = {
|
|
351
313
|
* logIn: { id: "...", ... },
|
|
352
|
-
* companyProfile: { id: "...", ... }
|
|
353
|
-
* token: "..."
|
|
314
|
+
* companyProfile: { id: "...", ... }
|
|
354
315
|
* };
|
|
355
316
|
* const user = User.fromJSON(userJson);
|
|
356
317
|
* ```
|