@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.
Files changed (69) hide show
  1. package/esm/mod.d.ts +1 -0
  2. package/esm/mod.d.ts.map +1 -1
  3. package/esm/mod.js +1 -0
  4. package/esm/src/features/admin/contract.d.ts +648 -0
  5. package/esm/src/features/admin/contract.d.ts.map +1 -0
  6. package/esm/src/features/admin/contract.js +184 -0
  7. package/esm/src/features/admin/index.d.ts +4 -0
  8. package/esm/src/features/admin/index.d.ts.map +1 -0
  9. package/esm/src/features/admin/index.js +3 -0
  10. package/esm/src/features/admin/repository.d.ts +104 -0
  11. package/esm/src/features/admin/repository.d.ts.map +1 -0
  12. package/esm/src/features/admin/repository.js +224 -0
  13. package/esm/src/features/admin/schemas.d.ts +119 -0
  14. package/esm/src/features/admin/schemas.d.ts.map +1 -0
  15. package/esm/src/features/admin/schemas.js +172 -0
  16. package/esm/src/models/index.d.ts +1 -0
  17. package/esm/src/models/index.d.ts.map +1 -1
  18. package/esm/src/models/index.js +1 -0
  19. package/esm/src/models/permission.d.ts +11 -1
  20. package/esm/src/models/permission.d.ts.map +1 -1
  21. package/esm/src/models/permission.js +10 -0
  22. package/esm/src/models/role.d.ts +21 -0
  23. package/esm/src/models/role.d.ts.map +1 -0
  24. package/esm/src/models/role.js +73 -0
  25. package/esm/src/models/user/{user.d.ts → authenticated-user.d.ts} +1 -1
  26. package/esm/src/models/user/authenticated-user.d.ts.map +1 -0
  27. package/esm/src/models/user/index.d.ts +2 -1
  28. package/esm/src/models/user/index.d.ts.map +1 -1
  29. package/esm/src/models/user/index.js +2 -1
  30. package/esm/src/models/user/managed-user.d.ts +102 -0
  31. package/esm/src/models/user/managed-user.d.ts.map +1 -0
  32. package/esm/src/models/user/managed-user.js +226 -0
  33. package/package.json +1 -1
  34. package/script/mod.d.ts +1 -0
  35. package/script/mod.d.ts.map +1 -1
  36. package/script/mod.js +1 -0
  37. package/script/src/features/admin/contract.d.ts +648 -0
  38. package/script/src/features/admin/contract.d.ts.map +1 -0
  39. package/script/src/features/admin/contract.js +187 -0
  40. package/script/src/features/admin/index.d.ts +4 -0
  41. package/script/src/features/admin/index.d.ts.map +1 -0
  42. package/script/src/features/admin/index.js +19 -0
  43. package/script/src/features/admin/repository.d.ts +104 -0
  44. package/script/src/features/admin/repository.d.ts.map +1 -0
  45. package/script/src/features/admin/repository.js +228 -0
  46. package/script/src/features/admin/schemas.d.ts +119 -0
  47. package/script/src/features/admin/schemas.d.ts.map +1 -0
  48. package/script/src/features/admin/schemas.js +175 -0
  49. package/script/src/models/index.d.ts +1 -0
  50. package/script/src/models/index.d.ts.map +1 -1
  51. package/script/src/models/index.js +1 -0
  52. package/script/src/models/permission.d.ts +11 -1
  53. package/script/src/models/permission.d.ts.map +1 -1
  54. package/script/src/models/permission.js +10 -0
  55. package/script/src/models/role.d.ts +21 -0
  56. package/script/src/models/role.d.ts.map +1 -0
  57. package/script/src/models/role.js +77 -0
  58. package/script/src/models/user/{user.d.ts → authenticated-user.d.ts} +1 -1
  59. package/script/src/models/user/authenticated-user.d.ts.map +1 -0
  60. package/script/src/models/user/index.d.ts +2 -1
  61. package/script/src/models/user/index.d.ts.map +1 -1
  62. package/script/src/models/user/index.js +2 -1
  63. package/script/src/models/user/managed-user.d.ts +102 -0
  64. package/script/src/models/user/managed-user.d.ts.map +1 -0
  65. package/script/src/models/user/managed-user.js +231 -0
  66. package/esm/src/models/user/user.d.ts.map +0 -1
  67. package/script/src/models/user/user.d.ts.map +0 -1
  68. /package/esm/src/models/user/{user.js → authenticated-user.js} +0 -0
  69. /package/script/src/models/user/{user.js → authenticated-user.js} +0 -0
@@ -0,0 +1,172 @@
1
+ import { z } from "zod";
2
+ // ====================== Custom Schema Definitions ====================== //
3
+ /**
4
+ * Custom password schema that enforces strong password requirements.
5
+ * Password must contain:
6
+ * - At least 8 characters
7
+ * - At least one uppercase letter
8
+ * - At least one lowercase letter
9
+ * - At least one number
10
+ * - At least one special character (!@#$%^&*()_+-=[]{}|;:,.<>?)
11
+ * - No common passwords or sequential patterns
12
+ */
13
+ const passwordSchema = z
14
+ .string()
15
+ .min(8, "Password must be at least 8 characters long")
16
+ .max(128, "Password must not exceed 128 characters")
17
+ .regex(/[A-Z]/, "Password must contain at least one uppercase letter")
18
+ .regex(/[a-z]/, "Password must contain at least one lowercase letter")
19
+ .regex(/[0-9]/, "Password must contain at least one number")
20
+ .regex(/[!@#$%^&*()_+\-=\[\]{}|;:,.<>?]/, "Password must contain at least one special character (!@#$%^&*()_+-=[]{}|;:,.<>?)")
21
+ .refine((password) => {
22
+ // Check for common weak patterns
23
+ const weakPatterns = [
24
+ /(.)\1{2,}/, // Three or more consecutive identical characters
25
+ /123456|654321|abcdef|qwerty|password|admin|user/i, // Common passwords
26
+ /^[0-9]+$/, // Only numbers
27
+ /^[a-zA-Z]+$/, // Only letters
28
+ ];
29
+ return !weakPatterns.some((pattern) => pattern.test(password));
30
+ }, "Password contains weak patterns. Avoid repeated characters, common words, or simple sequences")
31
+ .refine((password) => {
32
+ // Check for sequential characters (e.g., "abcd", "1234")
33
+ 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
34
+ .test(password);
35
+ return !hasSequential;
36
+ }, "Password should not contain sequential characters")
37
+ .refine((password) => {
38
+ // Check for keyboard patterns (e.g., "qwer", "asdf")
39
+ const keyboardPatterns = /(?:qwer|wert|erty|rtyu|tyui|yuio|uiop|asdf|sdfg|dfgh|fghj|ghjk|hjkl|zxcv|xcvb|cvbn|vbnm)/i;
40
+ return !keyboardPatterns.test(password);
41
+ }, "Password should not contain keyboard patterns");
42
+ // ====================== Schema Definitions ====================== //
43
+ /**
44
+ * Schema definition for a role.
45
+ * Represents a user role with permissions in the system.
46
+ *
47
+ * @property {string} id - Unique identifier for the role
48
+ * @property {string} name - Display name of the role
49
+ * @property {string} description - Optional description of the role
50
+ * @property {string[]} access - Array of permission strings
51
+ * @property {string} createdAt - ISO datetime string of role creation
52
+ * @property {string} updatedAt - ISO datetime string of last role update
53
+ */
54
+ const roleSchema = z.object({
55
+ id: z.string().min(1),
56
+ name: z.string().min(1, "Role name is required"),
57
+ description: z.string().optional(),
58
+ access: z.array(z.string()),
59
+ createdAt: z.string().datetime("Invalid creation timestamp"),
60
+ updatedAt: z.string().datetime("Invalid update timestamp"),
61
+ });
62
+ /**
63
+ * Schema definition for a managed user account.
64
+ * Represents a user account from the admin management perspective.
65
+ *
66
+ * @property {string} id - Unique identifier for the user account
67
+ * @property {string} name - Full name of the user
68
+ * @property {string} identity - User's email address or phone number
69
+ * @property {string} type - Type of user account
70
+ * @property {string} profileId - ID of the associated profile
71
+ * @property {string} roleId - ID of the assigned role
72
+ * @property {boolean} resetPassword - Whether user must reset password on next login
73
+ * @property {boolean} isActive - Whether the account is currently active
74
+ * @property {Role} role - Full role object with permissions
75
+ * @property {string} createdAt - ISO datetime string of account creation
76
+ * @property {string} updatedAt - ISO datetime string of last account update
77
+ */
78
+ const managedUserSchema = z.object({
79
+ id: z.string().min(1),
80
+ name: z.string().min(1, "User name is required"),
81
+ identity: z.string().email("Invalid email address"),
82
+ type: z.string().min(1, "User type is required"),
83
+ profileId: z.string().min(1, "Profile ID is required"),
84
+ roleId: z.string().min(1, "Role ID is required"),
85
+ resetPassword: z.boolean(),
86
+ isActive: z.boolean(),
87
+ role: roleSchema,
88
+ createdAt: z.string().datetime("Invalid creation timestamp"),
89
+ updatedAt: z.string().datetime("Invalid update timestamp"),
90
+ });
91
+ /**
92
+ * Schema definition for creating a new user account.
93
+ * Defines the required and optional fields for user creation.
94
+ *
95
+ * @property {string} name - Full name of the user
96
+ * @property {string} identity - User's email address
97
+ * @property {string} password - Initial password for the account
98
+ * @property {string} roleId - Optional role ID (defaults to system default)
99
+ * @property {boolean} resetPassword - Optional flag to force password reset (defaults to true)
100
+ */
101
+ const createUserRequestSchema = z.object({
102
+ name: z.string().min(1, "User name is required"),
103
+ identity: z.string().email("Valid email address is required"),
104
+ password: passwordSchema,
105
+ roleId: z.string().optional(),
106
+ resetPassword: z.boolean().optional(),
107
+ });
108
+ /**
109
+ * Schema definition for updating a user account.
110
+ * All fields are optional for partial updates.
111
+ *
112
+ * @property {string} name - Optional updated name
113
+ * @property {string} roleId - Optional updated role ID
114
+ * @property {string} password - Optional new password
115
+ * @property {boolean} resetPassword - Optional flag to force password reset
116
+ * @property {boolean} isActive - Optional account activation status
117
+ */
118
+ const updateUserRequestSchema = z.object({
119
+ name: z.string().min(1, "User name cannot be empty").optional(),
120
+ roleId: z.string().min(1, "Role ID cannot be empty").optional(),
121
+ password: passwordSchema.optional(),
122
+ resetPassword: z.boolean().optional(),
123
+ isActive: z.boolean().optional(),
124
+ });
125
+ /**
126
+ * Schema definition for resetting a user's password.
127
+ * Both fields are optional with system defaults.
128
+ *
129
+ * @property {string} newPassword - Optional new password (random generated if not provided)
130
+ * @property {boolean} sendNotification - Optional flag to send notification to user
131
+ */
132
+ const resetPasswordRequestSchema = z.object({
133
+ newPassword: passwordSchema.optional(),
134
+ sendNotification: z.boolean().optional(),
135
+ });
136
+ /**
137
+ * Schema definition for the response when creating a user.
138
+ * Returns basic user information without sensitive data.
139
+ *
140
+ * @property {string} id - Unique identifier for the created user
141
+ * @property {string} name - Full name of the user
142
+ * @property {string} identity - User's email address
143
+ * @property {string} type - Type of user account
144
+ * @property {string} profileId - ID of the associated profile
145
+ * @property {string} roleId - ID of the assigned role
146
+ * @property {boolean} isActive - Whether the account is active
147
+ * @property {string} createdAt - ISO datetime string of account creation
148
+ */
149
+ const createUserResponseSchema = z.object({
150
+ id: z.string(),
151
+ name: z.string(),
152
+ identity: z.string(),
153
+ type: z.string(),
154
+ profileId: z.string(),
155
+ roleId: z.string(),
156
+ isActive: z.boolean(),
157
+ createdAt: z.string().datetime(),
158
+ });
159
+ // ====================== Schema Collections ====================== //
160
+ /**
161
+ * Collection of user management schemas for export.
162
+ * Provides access to all user and role validation schemas.
163
+ */
164
+ export const UserManagementSchemas = {
165
+ role: roleSchema,
166
+ managedUser: managedUserSchema,
167
+ createUserRequest: createUserRequestSchema,
168
+ updateUserRequest: updateUserRequestSchema,
169
+ resetPasswordRequest: resetPasswordRequestSchema,
170
+ createUserResponse: createUserResponseSchema,
171
+ password: passwordSchema, // Export password schema for reuse
172
+ };
@@ -3,4 +3,5 @@ export * from "./user/index.js";
3
3
  export * from "./contact/index.js";
4
4
  export * from "./payout/index.js";
5
5
  export * from "./wallet/index.js";
6
+ export * from "./role.js";
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -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"}
@@ -3,3 +3,4 @@ export * from "./user/index.js";
3
3
  export * from "./contact/index.js";
4
4
  export * from "./payout/index.js";
5
5
  export * from "./wallet/index.js";
6
+ export * from "./role.js";
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCd,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,MAAM,CAAC,MAAM,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC"}
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"}
@@ -34,4 +34,14 @@ export const Permissions = {
34
34
  ViewBalance: "wallet.getBalance",
35
35
  ViewStatement: "wallet.getStatement",
36
36
  },
37
+ UserManagement: {
38
+ ViewRoles: "userManagement.getRoles",
39
+ ViewUsers: "userManagement.getUsers",
40
+ ViewUser: "userManagement.getUser",
41
+ CreateUser: "userManagement.createUser",
42
+ UpdateUser: "userManagement.updateUser",
43
+ ArchiveUser: "userManagement.archiveUser",
44
+ ResetPassword: "userManagement.resetPassword",
45
+ ViewRole: "userManagement.getRole",
46
+ },
37
47
  }; // 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,73 @@
1
+ // deno-lint-ignore-file no-explicit-any
2
+ // ====================== Role Entity ====================== //
3
+ export class Role {
4
+ constructor(data) {
5
+ Object.defineProperty(this, "id", {
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true,
9
+ value: void 0
10
+ });
11
+ Object.defineProperty(this, "name", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: void 0
16
+ });
17
+ Object.defineProperty(this, "description", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: void 0
22
+ });
23
+ Object.defineProperty(this, "permissions", {
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true,
27
+ value: void 0
28
+ });
29
+ Object.defineProperty(this, "createdAt", {
30
+ enumerable: true,
31
+ configurable: true,
32
+ writable: true,
33
+ value: void 0
34
+ });
35
+ Object.defineProperty(this, "updatedAt", {
36
+ enumerable: true,
37
+ configurable: true,
38
+ writable: true,
39
+ value: void 0
40
+ });
41
+ this.id = data.id;
42
+ this.name = data.name;
43
+ this.description = data.description;
44
+ this.permissions = new Set(data.access);
45
+ this.createdAt = new Date(data.createdAt);
46
+ this.updatedAt = new Date(data.updatedAt);
47
+ }
48
+ hasPermission(permission) {
49
+ return this.permissions.has(permission);
50
+ }
51
+ static from(data) {
52
+ try {
53
+ if (!data?.id || !data?.name || !Array.isArray(data?.access)) {
54
+ return undefined;
55
+ }
56
+ return new Role(data);
57
+ }
58
+ catch (error) {
59
+ console.error("Error creating Role:", error);
60
+ return undefined;
61
+ }
62
+ }
63
+ toJSON() {
64
+ return {
65
+ id: this.id,
66
+ name: this.name,
67
+ description: this.description,
68
+ access: Array.from(this.permissions),
69
+ createdAt: this.createdAt.toISOString(),
70
+ updatedAt: this.updatedAt.toISOString(),
71
+ };
72
+ }
73
+ }
@@ -74,4 +74,4 @@ export declare class User {
74
74
  */
75
75
  static from(data: any): User | undefined;
76
76
  }
77
- //# sourceMappingURL=user.d.ts.map
77
+ //# sourceMappingURL=authenticated-user.d.ts.map
@@ -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,3 +1,4 @@
1
1
  export * from "./profile.js";
2
- export * from "./user.js";
2
+ export * from "./authenticated-user.js";
3
+ export * from "./managed-user.js";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -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,WAAW,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"}
@@ -1,2 +1,3 @@
1
1
  export * from "./profile.js";
2
- export * from "./user.js";
2
+ export * from "./authenticated-user.js";
3
+ export * from "./managed-user.js";
@@ -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"}