@temboplus/afloat 0.1.32 → 0.1.33
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/esm/mod.d.ts +1 -0
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +1 -0
- package/esm/src/features/admin/contract.d.ts +648 -0
- package/esm/src/features/admin/contract.d.ts.map +1 -0
- package/esm/src/features/admin/contract.js +184 -0
- package/esm/src/features/admin/index.d.ts +4 -0
- package/esm/src/features/admin/index.d.ts.map +1 -0
- package/esm/src/features/admin/index.js +3 -0
- package/esm/src/features/admin/repository.d.ts +104 -0
- package/esm/src/features/admin/repository.d.ts.map +1 -0
- package/esm/src/features/admin/repository.js +224 -0
- package/esm/src/features/admin/schemas.d.ts +119 -0
- package/esm/src/features/admin/schemas.d.ts.map +1 -0
- package/esm/src/features/admin/schemas.js +172 -0
- package/esm/src/models/index.d.ts +1 -0
- package/esm/src/models/index.d.ts.map +1 -1
- package/esm/src/models/index.js +1 -0
- package/esm/src/models/permission.d.ts +11 -1
- package/esm/src/models/permission.d.ts.map +1 -1
- package/esm/src/models/permission.js +10 -0
- package/esm/src/models/role.d.ts +21 -0
- package/esm/src/models/role.d.ts.map +1 -0
- package/esm/src/models/role.js +73 -0
- package/esm/src/models/user/{user.d.ts → authenticated-user.d.ts} +1 -1
- package/esm/src/models/user/authenticated-user.d.ts.map +1 -0
- package/esm/src/models/user/index.d.ts +2 -1
- package/esm/src/models/user/index.d.ts.map +1 -1
- package/esm/src/models/user/index.js +2 -1
- package/esm/src/models/user/managed-user.d.ts +102 -0
- package/esm/src/models/user/managed-user.d.ts.map +1 -0
- package/esm/src/models/user/managed-user.js +226 -0
- package/package.json +1 -1
- package/script/mod.d.ts +1 -0
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +1 -0
- package/script/src/features/admin/contract.d.ts +648 -0
- package/script/src/features/admin/contract.d.ts.map +1 -0
- package/script/src/features/admin/contract.js +187 -0
- package/script/src/features/admin/index.d.ts +4 -0
- package/script/src/features/admin/index.d.ts.map +1 -0
- package/script/src/features/admin/index.js +19 -0
- package/script/src/features/admin/repository.d.ts +104 -0
- package/script/src/features/admin/repository.d.ts.map +1 -0
- package/script/src/features/admin/repository.js +228 -0
- package/script/src/features/admin/schemas.d.ts +119 -0
- package/script/src/features/admin/schemas.d.ts.map +1 -0
- package/script/src/features/admin/schemas.js +175 -0
- package/script/src/models/index.d.ts +1 -0
- package/script/src/models/index.d.ts.map +1 -1
- package/script/src/models/index.js +1 -0
- package/script/src/models/permission.d.ts +11 -1
- package/script/src/models/permission.d.ts.map +1 -1
- package/script/src/models/permission.js +10 -0
- package/script/src/models/role.d.ts +21 -0
- package/script/src/models/role.d.ts.map +1 -0
- package/script/src/models/role.js +77 -0
- package/script/src/models/user/{user.d.ts → authenticated-user.d.ts} +1 -1
- package/script/src/models/user/authenticated-user.d.ts.map +1 -0
- package/script/src/models/user/index.d.ts +2 -1
- package/script/src/models/user/index.d.ts.map +1 -1
- package/script/src/models/user/index.js +2 -1
- package/script/src/models/user/managed-user.d.ts +102 -0
- package/script/src/models/user/managed-user.d.ts.map +1 -0
- package/script/src/models/user/managed-user.js +231 -0
- package/esm/src/models/user/user.d.ts.map +0 -1
- package/script/src/models/user/user.d.ts.map +0 -1
- /package/esm/src/models/user/{user.js → authenticated-user.js} +0 -0
- /package/script/src/models/user/{user.js → authenticated-user.js} +0 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserManagementSchemas = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
// ====================== Custom Schema Definitions ====================== //
|
|
6
|
+
/**
|
|
7
|
+
* Custom password schema that enforces strong password requirements.
|
|
8
|
+
* Password must contain:
|
|
9
|
+
* - At least 8 characters
|
|
10
|
+
* - At least one uppercase letter
|
|
11
|
+
* - At least one lowercase letter
|
|
12
|
+
* - At least one number
|
|
13
|
+
* - At least one special character (!@#$%^&*()_+-=[]{}|;:,.<>?)
|
|
14
|
+
* - No common passwords or sequential patterns
|
|
15
|
+
*/
|
|
16
|
+
const passwordSchema = zod_1.z
|
|
17
|
+
.string()
|
|
18
|
+
.min(8, "Password must be at least 8 characters long")
|
|
19
|
+
.max(128, "Password must not exceed 128 characters")
|
|
20
|
+
.regex(/[A-Z]/, "Password must contain at least one uppercase letter")
|
|
21
|
+
.regex(/[a-z]/, "Password must contain at least one lowercase letter")
|
|
22
|
+
.regex(/[0-9]/, "Password must contain at least one number")
|
|
23
|
+
.regex(/[!@#$%^&*()_+\-=\[\]{}|;:,.<>?]/, "Password must contain at least one special character (!@#$%^&*()_+-=[]{}|;:,.<>?)")
|
|
24
|
+
.refine((password) => {
|
|
25
|
+
// Check for common weak patterns
|
|
26
|
+
const weakPatterns = [
|
|
27
|
+
/(.)\1{2,}/, // Three or more consecutive identical characters
|
|
28
|
+
/123456|654321|abcdef|qwerty|password|admin|user/i, // Common passwords
|
|
29
|
+
/^[0-9]+$/, // Only numbers
|
|
30
|
+
/^[a-zA-Z]+$/, // Only letters
|
|
31
|
+
];
|
|
32
|
+
return !weakPatterns.some((pattern) => pattern.test(password));
|
|
33
|
+
}, "Password contains weak patterns. Avoid repeated characters, common words, or simple sequences")
|
|
34
|
+
.refine((password) => {
|
|
35
|
+
// Check for sequential characters (e.g., "abcd", "1234")
|
|
36
|
+
const hasSequential = /(?:abc|bcd|cde|def|efg|fgh|ghi|hij|ijk|jkl|klm|lmn|mno|nop|opq|pqr|qrs|rst|stu|tuv|uvw|vwx|wxy|xyz|012|123|234|345|456|567|678|789)/i
|
|
37
|
+
.test(password);
|
|
38
|
+
return !hasSequential;
|
|
39
|
+
}, "Password should not contain sequential characters")
|
|
40
|
+
.refine((password) => {
|
|
41
|
+
// Check for keyboard patterns (e.g., "qwer", "asdf")
|
|
42
|
+
const keyboardPatterns = /(?:qwer|wert|erty|rtyu|tyui|yuio|uiop|asdf|sdfg|dfgh|fghj|ghjk|hjkl|zxcv|xcvb|cvbn|vbnm)/i;
|
|
43
|
+
return !keyboardPatterns.test(password);
|
|
44
|
+
}, "Password should not contain keyboard patterns");
|
|
45
|
+
// ====================== Schema Definitions ====================== //
|
|
46
|
+
/**
|
|
47
|
+
* Schema definition for a role.
|
|
48
|
+
* Represents a user role with permissions in the system.
|
|
49
|
+
*
|
|
50
|
+
* @property {string} id - Unique identifier for the role
|
|
51
|
+
* @property {string} name - Display name of the role
|
|
52
|
+
* @property {string} description - Optional description of the role
|
|
53
|
+
* @property {string[]} access - Array of permission strings
|
|
54
|
+
* @property {string} createdAt - ISO datetime string of role creation
|
|
55
|
+
* @property {string} updatedAt - ISO datetime string of last role update
|
|
56
|
+
*/
|
|
57
|
+
const roleSchema = zod_1.z.object({
|
|
58
|
+
id: zod_1.z.string().min(1),
|
|
59
|
+
name: zod_1.z.string().min(1, "Role name is required"),
|
|
60
|
+
description: zod_1.z.string().optional(),
|
|
61
|
+
access: zod_1.z.array(zod_1.z.string()),
|
|
62
|
+
createdAt: zod_1.z.string().datetime("Invalid creation timestamp"),
|
|
63
|
+
updatedAt: zod_1.z.string().datetime("Invalid update timestamp"),
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* Schema definition for a managed user account.
|
|
67
|
+
* Represents a user account from the admin management perspective.
|
|
68
|
+
*
|
|
69
|
+
* @property {string} id - Unique identifier for the user account
|
|
70
|
+
* @property {string} name - Full name of the user
|
|
71
|
+
* @property {string} identity - User's email address or phone number
|
|
72
|
+
* @property {string} type - Type of user account
|
|
73
|
+
* @property {string} profileId - ID of the associated profile
|
|
74
|
+
* @property {string} roleId - ID of the assigned role
|
|
75
|
+
* @property {boolean} resetPassword - Whether user must reset password on next login
|
|
76
|
+
* @property {boolean} isActive - Whether the account is currently active
|
|
77
|
+
* @property {Role} role - Full role object with permissions
|
|
78
|
+
* @property {string} createdAt - ISO datetime string of account creation
|
|
79
|
+
* @property {string} updatedAt - ISO datetime string of last account update
|
|
80
|
+
*/
|
|
81
|
+
const managedUserSchema = zod_1.z.object({
|
|
82
|
+
id: zod_1.z.string().min(1),
|
|
83
|
+
name: zod_1.z.string().min(1, "User name is required"),
|
|
84
|
+
identity: zod_1.z.string().email("Invalid email address"),
|
|
85
|
+
type: zod_1.z.string().min(1, "User type is required"),
|
|
86
|
+
profileId: zod_1.z.string().min(1, "Profile ID is required"),
|
|
87
|
+
roleId: zod_1.z.string().min(1, "Role ID is required"),
|
|
88
|
+
resetPassword: zod_1.z.boolean(),
|
|
89
|
+
isActive: zod_1.z.boolean(),
|
|
90
|
+
role: roleSchema,
|
|
91
|
+
createdAt: zod_1.z.string().datetime("Invalid creation timestamp"),
|
|
92
|
+
updatedAt: zod_1.z.string().datetime("Invalid update timestamp"),
|
|
93
|
+
});
|
|
94
|
+
/**
|
|
95
|
+
* Schema definition for creating a new user account.
|
|
96
|
+
* Defines the required and optional fields for user creation.
|
|
97
|
+
*
|
|
98
|
+
* @property {string} name - Full name of the user
|
|
99
|
+
* @property {string} identity - User's email address
|
|
100
|
+
* @property {string} password - Initial password for the account
|
|
101
|
+
* @property {string} roleId - Optional role ID (defaults to system default)
|
|
102
|
+
* @property {boolean} resetPassword - Optional flag to force password reset (defaults to true)
|
|
103
|
+
*/
|
|
104
|
+
const createUserRequestSchema = zod_1.z.object({
|
|
105
|
+
name: zod_1.z.string().min(1, "User name is required"),
|
|
106
|
+
identity: zod_1.z.string().email("Valid email address is required"),
|
|
107
|
+
password: passwordSchema,
|
|
108
|
+
roleId: zod_1.z.string().optional(),
|
|
109
|
+
resetPassword: zod_1.z.boolean().optional(),
|
|
110
|
+
});
|
|
111
|
+
/**
|
|
112
|
+
* Schema definition for updating a user account.
|
|
113
|
+
* All fields are optional for partial updates.
|
|
114
|
+
*
|
|
115
|
+
* @property {string} name - Optional updated name
|
|
116
|
+
* @property {string} roleId - Optional updated role ID
|
|
117
|
+
* @property {string} password - Optional new password
|
|
118
|
+
* @property {boolean} resetPassword - Optional flag to force password reset
|
|
119
|
+
* @property {boolean} isActive - Optional account activation status
|
|
120
|
+
*/
|
|
121
|
+
const updateUserRequestSchema = zod_1.z.object({
|
|
122
|
+
name: zod_1.z.string().min(1, "User name cannot be empty").optional(),
|
|
123
|
+
roleId: zod_1.z.string().min(1, "Role ID cannot be empty").optional(),
|
|
124
|
+
password: passwordSchema.optional(),
|
|
125
|
+
resetPassword: zod_1.z.boolean().optional(),
|
|
126
|
+
isActive: zod_1.z.boolean().optional(),
|
|
127
|
+
});
|
|
128
|
+
/**
|
|
129
|
+
* Schema definition for resetting a user's password.
|
|
130
|
+
* Both fields are optional with system defaults.
|
|
131
|
+
*
|
|
132
|
+
* @property {string} newPassword - Optional new password (random generated if not provided)
|
|
133
|
+
* @property {boolean} sendNotification - Optional flag to send notification to user
|
|
134
|
+
*/
|
|
135
|
+
const resetPasswordRequestSchema = zod_1.z.object({
|
|
136
|
+
newPassword: passwordSchema.optional(),
|
|
137
|
+
sendNotification: zod_1.z.boolean().optional(),
|
|
138
|
+
});
|
|
139
|
+
/**
|
|
140
|
+
* Schema definition for the response when creating a user.
|
|
141
|
+
* Returns basic user information without sensitive data.
|
|
142
|
+
*
|
|
143
|
+
* @property {string} id - Unique identifier for the created user
|
|
144
|
+
* @property {string} name - Full name of the user
|
|
145
|
+
* @property {string} identity - User's email address
|
|
146
|
+
* @property {string} type - Type of user account
|
|
147
|
+
* @property {string} profileId - ID of the associated profile
|
|
148
|
+
* @property {string} roleId - ID of the assigned role
|
|
149
|
+
* @property {boolean} isActive - Whether the account is active
|
|
150
|
+
* @property {string} createdAt - ISO datetime string of account creation
|
|
151
|
+
*/
|
|
152
|
+
const createUserResponseSchema = zod_1.z.object({
|
|
153
|
+
id: zod_1.z.string(),
|
|
154
|
+
name: zod_1.z.string(),
|
|
155
|
+
identity: zod_1.z.string(),
|
|
156
|
+
type: zod_1.z.string(),
|
|
157
|
+
profileId: zod_1.z.string(),
|
|
158
|
+
roleId: zod_1.z.string(),
|
|
159
|
+
isActive: zod_1.z.boolean(),
|
|
160
|
+
createdAt: zod_1.z.string().datetime(),
|
|
161
|
+
});
|
|
162
|
+
// ====================== Schema Collections ====================== //
|
|
163
|
+
/**
|
|
164
|
+
* Collection of user management schemas for export.
|
|
165
|
+
* Provides access to all user and role validation schemas.
|
|
166
|
+
*/
|
|
167
|
+
exports.UserManagementSchemas = {
|
|
168
|
+
role: roleSchema,
|
|
169
|
+
managedUser: managedUserSchema,
|
|
170
|
+
createUserRequest: createUserRequestSchema,
|
|
171
|
+
updateUserRequest: updateUserRequestSchema,
|
|
172
|
+
resetPasswordRequest: resetPasswordRequestSchema,
|
|
173
|
+
createUserResponse: createUserResponseSchema,
|
|
174
|
+
password: passwordSchema, // Export password schema for reuse
|
|
175
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC"}
|
|
@@ -34,9 +34,19 @@ export declare const Permissions: {
|
|
|
34
34
|
readonly ViewBalance: "wallet.getBalance";
|
|
35
35
|
readonly ViewStatement: "wallet.getStatement";
|
|
36
36
|
};
|
|
37
|
+
readonly UserManagement: {
|
|
38
|
+
readonly ViewRoles: "userManagement.getRoles";
|
|
39
|
+
readonly ViewUsers: "userManagement.getUsers";
|
|
40
|
+
readonly ViewUser: "userManagement.getUser";
|
|
41
|
+
readonly CreateUser: "userManagement.createUser";
|
|
42
|
+
readonly UpdateUser: "userManagement.updateUser";
|
|
43
|
+
readonly ArchiveUser: "userManagement.archiveUser";
|
|
44
|
+
readonly ResetPassword: "userManagement.resetPassword";
|
|
45
|
+
readonly ViewRole: "userManagement.getRole";
|
|
46
|
+
};
|
|
37
47
|
};
|
|
38
48
|
/**
|
|
39
49
|
* Permission Type
|
|
40
50
|
*/
|
|
41
|
-
export type Permission = typeof Permissions.Profile[keyof typeof Permissions.Profile] | typeof Permissions.Contact[keyof typeof Permissions.Contact] | typeof Permissions.Payment[keyof typeof Permissions.Payment] | typeof Permissions.Payout[keyof typeof Permissions.Payout] | typeof Permissions.Transfer[keyof typeof Permissions.Transfer] | typeof Permissions.Wallet[keyof typeof Permissions.Wallet];
|
|
51
|
+
export type Permission = typeof Permissions.Profile[keyof typeof Permissions.Profile] | typeof Permissions.Contact[keyof typeof Permissions.Contact] | typeof Permissions.Payment[keyof typeof Permissions.Payment] | typeof Permissions.Payout[keyof typeof Permissions.Payout] | typeof Permissions.Transfer[keyof typeof Permissions.Transfer] | typeof Permissions.UserManagement[keyof typeof Permissions.UserManagement] | typeof Permissions.Wallet[keyof typeof Permissions.Wallet];
|
|
42
52
|
//# sourceMappingURL=permission.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission.d.ts","sourceRoot":"","sources":["../../../src/src/models/permission.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"permission.d.ts","sourceRoot":"","sources":["../../../src/src/models/permission.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Cd,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,OAAO,WAAW,CAAC,OAAO,CAAC,MAAM,OAAO,WAAW,CAAC,OAAO,CAAC,GAC5D,OAAO,WAAW,CAAC,OAAO,CAAC,MAAM,OAAO,WAAW,CAAC,OAAO,CAAC,GAC5D,OAAO,WAAW,CAAC,OAAO,CAAC,MAAM,OAAO,WAAW,CAAC,OAAO,CAAC,GAC5D,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,OAAO,WAAW,CAAC,MAAM,CAAC,GAC1D,OAAO,WAAW,CAAC,QAAQ,CAAC,MAAM,OAAO,WAAW,CAAC,QAAQ,CAAC,GAC9D,OAAO,WAAW,CAAC,cAAc,CAAC,MAAM,OAAO,WAAW,CAAC,cAAc,CAAC,GAC1E,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -37,4 +37,14 @@ exports.Permissions = {
|
|
|
37
37
|
ViewBalance: "wallet.getBalance",
|
|
38
38
|
ViewStatement: "wallet.getStatement",
|
|
39
39
|
},
|
|
40
|
+
UserManagement: {
|
|
41
|
+
ViewRoles: "userManagement.getRoles",
|
|
42
|
+
ViewUsers: "userManagement.getUsers",
|
|
43
|
+
ViewUser: "userManagement.getUser",
|
|
44
|
+
CreateUser: "userManagement.createUser",
|
|
45
|
+
UpdateUser: "userManagement.updateUser",
|
|
46
|
+
ArchiveUser: "userManagement.archiveUser",
|
|
47
|
+
ResetPassword: "userManagement.resetPassword",
|
|
48
|
+
ViewRole: "userManagement.getRole",
|
|
49
|
+
},
|
|
40
50
|
}; // Make it deeply readonly
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface RoleData {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
access: string[];
|
|
6
|
+
createdAt: string;
|
|
7
|
+
updatedAt: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class Role {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly description?: string;
|
|
13
|
+
readonly permissions: ReadonlySet<string>;
|
|
14
|
+
readonly createdAt: Date;
|
|
15
|
+
readonly updatedAt: Date;
|
|
16
|
+
constructor(data: RoleData);
|
|
17
|
+
hasPermission(permission: string): boolean;
|
|
18
|
+
static from(data: any): Role | undefined;
|
|
19
|
+
toJSON(): any;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=role.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"role.d.ts","sourceRoot":"","sources":["../../../src/src/models/role.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,IAAI;IACf,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrC,SAAgB,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACjD,SAAgB,SAAS,EAAE,IAAI,CAAC;IAChC,SAAgB,SAAS,EAAE,IAAI,CAAC;gBAEpB,IAAI,EAAE,QAAQ;IAS1B,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAI1C,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,GAAG,SAAS;IAYxC,MAAM,IAAI,GAAG;CAUd"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// deno-lint-ignore-file no-explicit-any
|
|
3
|
+
// ====================== Role Entity ====================== //
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.Role = void 0;
|
|
6
|
+
class Role {
|
|
7
|
+
constructor(data) {
|
|
8
|
+
Object.defineProperty(this, "id", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true,
|
|
12
|
+
value: void 0
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(this, "name", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true,
|
|
18
|
+
value: void 0
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(this, "description", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
value: void 0
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(this, "permissions", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true,
|
|
30
|
+
value: void 0
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(this, "createdAt", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true,
|
|
36
|
+
value: void 0
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(this, "updatedAt", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
writable: true,
|
|
42
|
+
value: void 0
|
|
43
|
+
});
|
|
44
|
+
this.id = data.id;
|
|
45
|
+
this.name = data.name;
|
|
46
|
+
this.description = data.description;
|
|
47
|
+
this.permissions = new Set(data.access);
|
|
48
|
+
this.createdAt = new Date(data.createdAt);
|
|
49
|
+
this.updatedAt = new Date(data.updatedAt);
|
|
50
|
+
}
|
|
51
|
+
hasPermission(permission) {
|
|
52
|
+
return this.permissions.has(permission);
|
|
53
|
+
}
|
|
54
|
+
static from(data) {
|
|
55
|
+
try {
|
|
56
|
+
if (!data?.id || !data?.name || !Array.isArray(data?.access)) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
return new Role(data);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
console.error("Error creating Role:", error);
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
toJSON() {
|
|
67
|
+
return {
|
|
68
|
+
id: this.id,
|
|
69
|
+
name: this.name,
|
|
70
|
+
description: this.description,
|
|
71
|
+
access: Array.from(this.permissions),
|
|
72
|
+
createdAt: this.createdAt.toISOString(),
|
|
73
|
+
updatedAt: this.updatedAt.toISOString(),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.Role = Role;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticated-user.d.ts","sourceRoot":"","sources":["../../../../src/src/models/user/authenticated-user.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;;;GAKG;AACH,qBAAa,IAAI;IACf;;OAEG;IACI,IAAI,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACI,QAAQ,EAAE,MAAM,CAAC;IAExB;;OAEG;IACI,OAAO,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACI,KAAK,EAAE,MAAM,CAAC;IAErB;;;;;OAKG;IACI,aAAa,EAAE,OAAO,CAAC;IAE9B;;;OAGG;IACH,OAAO,CAAC,cAAc,CAA0B;IAEhD;;;;;OAKG;IACH,OAAO;IA6BP;;;;;OAKG;IACI,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAIvC;;;;;;;;OAQG;IACI,MAAM,IAAI,MAAM;IAavB;;;;;OAKG;WACW,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAS5D;;;;;OAKG;WACW,IAAI,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,GAAG,SAAS;CA4FhD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/models/user/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/models/user/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC"}
|
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./profile.js"), exports);
|
|
18
|
-
__exportStar(require("./user.js"), exports);
|
|
18
|
+
__exportStar(require("./authenticated-user.js"), exports);
|
|
19
|
+
__exportStar(require("./managed-user.js"), exports);
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Role, type RoleData } from "../role.js";
|
|
2
|
+
export interface UserEntityData {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
identity: string;
|
|
6
|
+
profileId: string;
|
|
7
|
+
permissions: string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Base user entity - represents a user in the system
|
|
11
|
+
*/
|
|
12
|
+
export declare class UserEntity {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly identity: string;
|
|
16
|
+
readonly profileId: string;
|
|
17
|
+
readonly permissions: ReadonlySet<string>;
|
|
18
|
+
constructor(data: UserEntityData);
|
|
19
|
+
/**
|
|
20
|
+
* Check if user has a specific permission
|
|
21
|
+
*/
|
|
22
|
+
can(permission: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Check if user has any of the specified permissions
|
|
25
|
+
*/
|
|
26
|
+
canAny(permissions: string[]): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Check if user has all of the specified permissions
|
|
29
|
+
*/
|
|
30
|
+
canAll(permissions: string[]): boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface AuthenticatedUserData {
|
|
33
|
+
name: string;
|
|
34
|
+
identity: string;
|
|
35
|
+
profileId: string;
|
|
36
|
+
profile: any;
|
|
37
|
+
token: string;
|
|
38
|
+
resetPassword: boolean;
|
|
39
|
+
permissions: string[];
|
|
40
|
+
sessionId?: string;
|
|
41
|
+
expiresAt?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface ManagedUserData {
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
identity: string;
|
|
47
|
+
type: string;
|
|
48
|
+
profileId: string;
|
|
49
|
+
roleId: string;
|
|
50
|
+
resetPassword: boolean;
|
|
51
|
+
isActive: boolean;
|
|
52
|
+
role: RoleData;
|
|
53
|
+
createdAt: string;
|
|
54
|
+
updatedAt: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Represents a user from the admin management perspective.
|
|
58
|
+
* Same person as AuthenticatedUser but with management metadata and capabilities.
|
|
59
|
+
*/
|
|
60
|
+
export declare class ManagedUser extends UserEntity {
|
|
61
|
+
readonly type: string;
|
|
62
|
+
readonly roleId: string;
|
|
63
|
+
readonly resetPassword: boolean;
|
|
64
|
+
readonly isActive: boolean;
|
|
65
|
+
readonly role: Role;
|
|
66
|
+
readonly createdAt: Date;
|
|
67
|
+
readonly updatedAt: Date;
|
|
68
|
+
constructor(data: ManagedUserData);
|
|
69
|
+
/**
|
|
70
|
+
* Check if user account is active
|
|
71
|
+
*/
|
|
72
|
+
isAccountActive(): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Check if user needs to reset password
|
|
75
|
+
*/
|
|
76
|
+
needsPasswordReset(): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Get comprehensive account status
|
|
79
|
+
*/
|
|
80
|
+
getAccountStatus(): {
|
|
81
|
+
status: 'active' | 'inactive' | 'password_reset_required';
|
|
82
|
+
label: string;
|
|
83
|
+
color: 'success' | 'warning' | 'error';
|
|
84
|
+
description: string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Get role display name
|
|
88
|
+
*/
|
|
89
|
+
getRoleName(): string;
|
|
90
|
+
/**
|
|
91
|
+
* Get formatted creation date
|
|
92
|
+
*/
|
|
93
|
+
getCreatedDate(): string;
|
|
94
|
+
/**
|
|
95
|
+
* Get time since last update
|
|
96
|
+
*/
|
|
97
|
+
getLastUpdateInfo(): string;
|
|
98
|
+
static from(data: any): ManagedUser | undefined;
|
|
99
|
+
static createMany(dataArray: any[]): ManagedUser[];
|
|
100
|
+
toJSON(): any;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=managed-user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managed-user.d.ts","sourceRoot":"","sources":["../../../../src/src/models/user/managed-user.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,qBAAa,UAAU;IACrB,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;gBAErC,IAAI,EAAE,cAAc;IAQhC;;OAEG;IACH,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAIhC;;OAEG;IACH,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO;IAItC;;OAEG;IACH,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO;CAGvC;AAID,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,GAAG,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,qBAAa,WAAY,SAAQ,UAAU;IACzC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,aAAa,EAAE,OAAO,CAAC;IACvC,SAAgB,QAAQ,EAAE,OAAO,CAAC;IAClC,SAAgB,IAAI,EAAE,IAAI,CAAC;IAC3B,SAAgB,SAAS,EAAE,IAAI,CAAC;IAChC,SAAgB,SAAS,EAAE,IAAI,CAAC;gBAEpB,IAAI,EAAE,eAAe;IAkBjC;;OAEG;IACH,eAAe,IAAI,OAAO;IAI1B;;OAEG;IACH,kBAAkB,IAAI,OAAO;IAI7B;;OAEG;IACH,gBAAgB,IAAI;QAClB,MAAM,EAAE,QAAQ,GAAG,UAAU,GAAG,yBAAyB,CAAC;QAC1D,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;QACvC,WAAW,EAAE,MAAM,CAAC;KACrB;IA2BD;;OAEG;IACH,WAAW,IAAI,MAAM;IAIrB;;OAEG;IACH,cAAc,IAAI,MAAM;IAIxB;;OAEG;IACH,iBAAiB,IAAI,MAAM;IAY3B,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,GAAG,WAAW,GAAG,SAAS;IAa/C,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,WAAW,EAAE;IAIlD,MAAM,IAAI,GAAG;CAed"}
|