@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,231 @@
1
+ "use strict";
2
+ // deno-lint-ignore-file no-explicit-any
3
+ // ====================== Base User Entity ====================== //
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.ManagedUser = exports.UserEntity = void 0;
6
+ const role_js_1 = require("../role.js");
7
+ /**
8
+ * Base user entity - represents a user in the system
9
+ */
10
+ class UserEntity {
11
+ constructor(data) {
12
+ Object.defineProperty(this, "id", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: void 0
17
+ });
18
+ Object.defineProperty(this, "name", {
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true,
22
+ value: void 0
23
+ });
24
+ Object.defineProperty(this, "identity", {
25
+ enumerable: true,
26
+ configurable: true,
27
+ writable: true,
28
+ value: void 0
29
+ }); // email or phone
30
+ Object.defineProperty(this, "profileId", {
31
+ enumerable: true,
32
+ configurable: true,
33
+ writable: true,
34
+ value: void 0
35
+ });
36
+ Object.defineProperty(this, "permissions", {
37
+ enumerable: true,
38
+ configurable: true,
39
+ writable: true,
40
+ value: void 0
41
+ });
42
+ this.id = data.id;
43
+ this.name = data.name;
44
+ this.identity = data.identity;
45
+ this.profileId = data.profileId;
46
+ this.permissions = new Set(data.permissions);
47
+ }
48
+ /**
49
+ * Check if user has a specific permission
50
+ */
51
+ can(permission) {
52
+ return this.permissions.has(permission);
53
+ }
54
+ /**
55
+ * Check if user has any of the specified permissions
56
+ */
57
+ canAny(permissions) {
58
+ return permissions.some(p => this.permissions.has(p));
59
+ }
60
+ /**
61
+ * Check if user has all of the specified permissions
62
+ */
63
+ canAll(permissions) {
64
+ return permissions.every(p => this.permissions.has(p));
65
+ }
66
+ }
67
+ exports.UserEntity = UserEntity;
68
+ /**
69
+ * Represents a user from the admin management perspective.
70
+ * Same person as AuthenticatedUser but with management metadata and capabilities.
71
+ */
72
+ class ManagedUser extends UserEntity {
73
+ constructor(data) {
74
+ super({
75
+ id: data.id,
76
+ name: data.name,
77
+ identity: data.identity,
78
+ profileId: data.profileId,
79
+ permissions: data.role.access,
80
+ });
81
+ Object.defineProperty(this, "type", {
82
+ enumerable: true,
83
+ configurable: true,
84
+ writable: true,
85
+ value: void 0
86
+ });
87
+ Object.defineProperty(this, "roleId", {
88
+ enumerable: true,
89
+ configurable: true,
90
+ writable: true,
91
+ value: void 0
92
+ });
93
+ Object.defineProperty(this, "resetPassword", {
94
+ enumerable: true,
95
+ configurable: true,
96
+ writable: true,
97
+ value: void 0
98
+ });
99
+ Object.defineProperty(this, "isActive", {
100
+ enumerable: true,
101
+ configurable: true,
102
+ writable: true,
103
+ value: void 0
104
+ });
105
+ Object.defineProperty(this, "role", {
106
+ enumerable: true,
107
+ configurable: true,
108
+ writable: true,
109
+ value: void 0
110
+ });
111
+ Object.defineProperty(this, "createdAt", {
112
+ enumerable: true,
113
+ configurable: true,
114
+ writable: true,
115
+ value: void 0
116
+ });
117
+ Object.defineProperty(this, "updatedAt", {
118
+ enumerable: true,
119
+ configurable: true,
120
+ writable: true,
121
+ value: void 0
122
+ });
123
+ this.type = data.type;
124
+ this.roleId = data.roleId;
125
+ this.resetPassword = data.resetPassword;
126
+ this.isActive = data.isActive;
127
+ this.role = new role_js_1.Role(data.role);
128
+ this.createdAt = new Date(data.createdAt);
129
+ this.updatedAt = new Date(data.updatedAt);
130
+ }
131
+ /**
132
+ * Check if user account is active
133
+ */
134
+ isAccountActive() {
135
+ return this.isActive;
136
+ }
137
+ /**
138
+ * Check if user needs to reset password
139
+ */
140
+ needsPasswordReset() {
141
+ return this.resetPassword;
142
+ }
143
+ /**
144
+ * Get comprehensive account status
145
+ */
146
+ getAccountStatus() {
147
+ if (!this.isActive) {
148
+ return {
149
+ status: 'inactive',
150
+ label: 'Inactive',
151
+ color: 'error',
152
+ description: 'Account has been deactivated by an administrator'
153
+ };
154
+ }
155
+ if (this.resetPassword) {
156
+ return {
157
+ status: 'password_reset_required',
158
+ label: 'Password Reset Required',
159
+ color: 'warning',
160
+ description: 'User must reset their password on next login'
161
+ };
162
+ }
163
+ return {
164
+ status: 'active',
165
+ label: 'Active',
166
+ color: 'success',
167
+ description: 'Account is active and ready to use'
168
+ };
169
+ }
170
+ /**
171
+ * Get role display name
172
+ */
173
+ getRoleName() {
174
+ return this.role.name;
175
+ }
176
+ /**
177
+ * Get formatted creation date
178
+ */
179
+ getCreatedDate() {
180
+ return this.createdAt.toLocaleDateString();
181
+ }
182
+ /**
183
+ * Get time since last update
184
+ */
185
+ getLastUpdateInfo() {
186
+ const now = new Date();
187
+ const diffMs = now.getTime() - this.updatedAt.getTime();
188
+ const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
189
+ if (diffDays === 0)
190
+ return 'Today';
191
+ if (diffDays === 1)
192
+ return 'Yesterday';
193
+ if (diffDays < 7)
194
+ return `${diffDays} days ago`;
195
+ if (diffDays < 30)
196
+ return `${Math.floor(diffDays / 7)} weeks ago`;
197
+ return this.updatedAt.toLocaleDateString();
198
+ }
199
+ static from(data) {
200
+ try {
201
+ if (!data?.id || !data?.name || !data?.identity || !data?.role) {
202
+ console.error("Missing required ManagedUser fields:", data);
203
+ return undefined;
204
+ }
205
+ return new ManagedUser(data);
206
+ }
207
+ catch (error) {
208
+ console.error("Error creating ManagedUser:", error);
209
+ return undefined;
210
+ }
211
+ }
212
+ static createMany(dataArray) {
213
+ return dataArray.map(data => ManagedUser.from(data)).filter(Boolean);
214
+ }
215
+ toJSON() {
216
+ return {
217
+ id: this.id,
218
+ name: this.name,
219
+ identity: this.identity,
220
+ type: this.type,
221
+ profileId: this.profileId,
222
+ roleId: this.roleId,
223
+ resetPassword: this.resetPassword,
224
+ isActive: this.isActive,
225
+ role: this.role.toJSON(),
226
+ createdAt: this.createdAt.toISOString(),
227
+ updatedAt: this.updatedAt.toISOString(),
228
+ };
229
+ }
230
+ }
231
+ exports.ManagedUser = ManagedUser;
@@ -1 +0,0 @@
1
- {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../../src/src/models/user/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;IAEx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