@temboplus/afloat 0.1.34 → 0.1.36

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.
@@ -2,6 +2,13 @@ import { z } from "zod";
2
2
  export declare const userManagementContract: {
3
3
  getUsers: {
4
4
  description: "Retrieve a list of all user accounts in the system";
5
+ query: z.ZodObject<{
6
+ eager: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ eager: string;
9
+ }, {
10
+ eager: string;
11
+ }>;
5
12
  summary: "List all user accounts";
6
13
  method: "GET";
7
14
  path: "/login";
@@ -89,6 +96,13 @@ export declare const userManagementContract: {
89
96
  }, {
90
97
  id: string;
91
98
  }>;
99
+ query: z.ZodObject<{
100
+ eager: z.ZodString;
101
+ }, "strip", z.ZodTypeAny, {
102
+ eager: string;
103
+ }, {
104
+ eager: string;
105
+ }>;
92
106
  summary: "Get user account details";
93
107
  method: "GET";
94
108
  path: "/login/:id";
@@ -1 +1 @@
1
- {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../../src/src/features/admin/contract.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiMjC,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,OAAO,sBAAsB,CAAC"}
@@ -8,6 +8,9 @@ export const userManagementContract = c.router({
8
8
  getUsers: {
9
9
  method: "GET",
10
10
  path: "/login",
11
+ query: z.object({
12
+ eager: z.string(),
13
+ }),
11
14
  responses: {
12
15
  200: z.array(UserManagementSchemas.managedUser),
13
16
  401: z.object({
@@ -27,6 +30,9 @@ export const userManagementContract = c.router({
27
30
  pathParams: z.object({
28
31
  id: z.string(),
29
32
  }),
33
+ query: z.object({
34
+ eager: z.string(),
35
+ }),
30
36
  responses: {
31
37
  200: UserManagementSchemas.managedUser,
32
38
  401: z.object({
@@ -1 +1 @@
1
- {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/admin/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAqC,MAAM,uBAAuB,CAAC;AAEvF,OAAO,EAAE,IAAI,EAAiB,MAAM,sBAAsB,CAAC;AAE3D;;;GAGG;AACH,qBAAa,wBACX,SAAQ,cAAc,CAAC,OAAO,sBAAsB,CAAC;IACrD;;;;;OAKG;gBACS,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,UAAU,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;IAIxD;;;;;;OAMG;IACG,UAAU,CAAC,KAAK,EAAE,iBAAiB,GAAG,OA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AAI,CAAC,EAAE,UAAU,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;IAIxD;;;;;;OAMG;IACG,UAAU,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAgBvE;;;;;;;OAOG;IACG,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;IAuB5E;;;;;;OAMG;IACG,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAoBnD;;;;;;;OAOG;IACG,iBAAiB,CACrB,EAAE,EAAE,MAAM,EACV,KAAK,GAAE,oBAAyB,GAC/B,OAAO,CAAC,IAAI,CAAC;IAkBhB;;;;;;;;;;OAUG;IACG,WAAW,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAgB3C;;;;;;;;;;OAUG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAuB/C;;;;;;;;;OASG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAsBpC;;;;;;;;;;OAUG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAmBzC"}
@@ -1,6 +1,6 @@
1
1
  import { BaseRepository } from "../../shared/base_repository.js";
2
2
  import { userManagementContract } from "./contract.js";
3
- import { ManagedUser, Permissions } from "../../models/index.js";
3
+ import { ManagedUser, Permissions, } from "../../models/index.js";
4
4
  import { PermissionError } from "../../errors/index.js";
5
5
  import { Role } from "../../models/role.js";
6
6
  /**
@@ -132,7 +132,7 @@ export class UserManagementRepository extends BaseRepository {
132
132
  requiredPermissions: [requiredPerm],
133
133
  });
134
134
  }
135
- const result = await this.client.getUsers();
135
+ const result = await this.client.getUsers({ query: { eager: "role" } });
136
136
  const data = this.handleResponse(result, 200);
137
137
  return ManagedUser.createMany(data);
138
138
  }
@@ -156,7 +156,10 @@ export class UserManagementRepository extends BaseRepository {
156
156
  requiredPermissions: [requiredPerm],
157
157
  });
158
158
  }
159
- const result = await this.client.getUser({ params: { id } });
159
+ const result = await this.client.getUser({
160
+ params: { id },
161
+ query: { eager: "role" },
162
+ });
160
163
  const data = this.handleResponse(result, 200);
161
164
  const managedUser = ManagedUser.from(data);
162
165
  if (!managedUser) {
@@ -1 +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
+ {"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;IAwBP;;;;;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"}
@@ -80,16 +80,10 @@ export class User {
80
80
  this.resetPassword = resetPassword;
81
81
  this.name = name;
82
82
  this.identity = identity;
83
- // Initialize the permissions map
84
83
  this.permissionsMap = {};
85
- for (const permission of Object.values(Permissions)) {
86
- if (typeof permission === "object") {
87
- Object.values(permission).forEach((perm) => {
88
- this.permissionsMap[perm] = access.includes(perm);
89
- });
90
- }
91
- else {
92
- this.permissionsMap[permission] = access.includes(permission);
84
+ for (const group of Object.values(Permissions)) {
85
+ for (const perm of Object.values(group)) {
86
+ this.permissionsMap[perm] = access.includes(perm);
93
87
  }
94
88
  }
95
89
  }
@@ -49,7 +49,7 @@ export interface ManagedUserData {
49
49
  roleId: string;
50
50
  resetPassword: boolean;
51
51
  isActive: boolean;
52
- role: RoleData;
52
+ role?: RoleData;
53
53
  createdAt: string;
54
54
  updatedAt: string;
55
55
  }
@@ -62,7 +62,7 @@ export declare class ManagedUser extends UserEntity {
62
62
  readonly roleId: string;
63
63
  readonly resetPassword: boolean;
64
64
  readonly isActive: boolean;
65
- readonly role: Role;
65
+ readonly role?: Role;
66
66
  readonly createdAt: Date;
67
67
  readonly updatedAt: Date;
68
68
  constructor(data: ManagedUserData);
@@ -78,9 +78,9 @@ export declare class ManagedUser extends UserEntity {
78
78
  * Get comprehensive account status
79
79
  */
80
80
  getAccountStatus(): {
81
- status: 'active' | 'inactive' | 'password_reset_required';
81
+ status: "active" | "inactive" | "password_reset_required";
82
82
  label: string;
83
- color: 'success' | 'warning' | 'error';
83
+ color: "success" | "warning" | "error";
84
84
  description: string;
85
85
  };
86
86
  /**
@@ -1 +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,a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AG,GAAG,WAAW,GAAG,SAAS;IAa/C,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,WAAW,EAAE;IAMlD,MAAM,IAAI,GAAG;CAed"}
@@ -52,13 +52,13 @@ export class UserEntity {
52
52
  * Check if user has any of the specified permissions
53
53
  */
54
54
  canAny(permissions) {
55
- return permissions.some(p => this.permissions.has(p));
55
+ return permissions.some((p) => this.permissions.has(p));
56
56
  }
57
57
  /**
58
58
  * Check if user has all of the specified permissions
59
59
  */
60
60
  canAll(permissions) {
61
- return permissions.every(p => this.permissions.has(p));
61
+ return permissions.every((p) => this.permissions.has(p));
62
62
  }
63
63
  }
64
64
  /**
@@ -72,7 +72,7 @@ export class ManagedUser extends UserEntity {
72
72
  name: data.name,
73
73
  identity: data.identity,
74
74
  profileId: data.profileId,
75
- permissions: data.role.access,
75
+ permissions: data.role?.access ?? [],
76
76
  });
77
77
  Object.defineProperty(this, "type", {
78
78
  enumerable: true,
@@ -120,9 +120,16 @@ export class ManagedUser extends UserEntity {
120
120
  this.roleId = data.roleId;
121
121
  this.resetPassword = data.resetPassword;
122
122
  this.isActive = data.isActive;
123
- this.role = new Role(data.role);
124
123
  this.createdAt = new Date(data.createdAt);
125
124
  this.updatedAt = new Date(data.updatedAt);
125
+ if (data.role) {
126
+ try {
127
+ this.role = new Role(data.role);
128
+ }
129
+ catch (_) {
130
+ //
131
+ }
132
+ }
126
133
  }
127
134
  /**
128
135
  * Check if user account is active
@@ -142,32 +149,32 @@ export class ManagedUser extends UserEntity {
142
149
  getAccountStatus() {
143
150
  if (!this.isActive) {
144
151
  return {
145
- status: 'inactive',
146
- label: 'Inactive',
147
- color: 'error',
148
- description: 'Account has been deactivated by an administrator'
152
+ status: "inactive",
153
+ label: "Inactive",
154
+ color: "error",
155
+ description: "Account has been deactivated by an administrator",
149
156
  };
150
157
  }
151
158
  if (this.resetPassword) {
152
159
  return {
153
- status: 'password_reset_required',
154
- label: 'Password Reset Required',
155
- color: 'warning',
156
- description: 'User must reset their password on next login'
160
+ status: "password_reset_required",
161
+ label: "Password Reset Required",
162
+ color: "warning",
163
+ description: "User must reset their password on next login",
157
164
  };
158
165
  }
159
166
  return {
160
- status: 'active',
161
- label: 'Active',
162
- color: 'success',
163
- description: 'Account is active and ready to use'
167
+ status: "active",
168
+ label: "Active",
169
+ color: "success",
170
+ description: "Account is active and ready to use",
164
171
  };
165
172
  }
166
173
  /**
167
174
  * Get role display name
168
175
  */
169
176
  getRoleName() {
170
- return this.role.name;
177
+ return this.role?.name ?? "";
171
178
  }
172
179
  /**
173
180
  * Get formatted creation date
@@ -183,9 +190,9 @@ export class ManagedUser extends UserEntity {
183
190
  const diffMs = now.getTime() - this.updatedAt.getTime();
184
191
  const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
185
192
  if (diffDays === 0)
186
- return 'Today';
193
+ return "Today";
187
194
  if (diffDays === 1)
188
- return 'Yesterday';
195
+ return "Yesterday";
189
196
  if (diffDays < 7)
190
197
  return `${diffDays} days ago`;
191
198
  if (diffDays < 30)
@@ -194,7 +201,7 @@ export class ManagedUser extends UserEntity {
194
201
  }
195
202
  static from(data) {
196
203
  try {
197
- if (!data?.id || !data?.name || !data?.identity || !data?.role) {
204
+ if (!data?.id || !data?.name || !data?.identity || !data?.roleId) {
198
205
  console.error("Missing required ManagedUser fields:", data);
199
206
  return undefined;
200
207
  }
@@ -206,7 +213,7 @@ export class ManagedUser extends UserEntity {
206
213
  }
207
214
  }
208
215
  static createMany(dataArray) {
209
- return dataArray.map(data => ManagedUser.from(data)).filter(Boolean);
216
+ return dataArray.map((data) => ManagedUser.from(data)).filter(Boolean);
210
217
  }
211
218
  toJSON() {
212
219
  return {
@@ -218,7 +225,7 @@ export class ManagedUser extends UserEntity {
218
225
  roleId: this.roleId,
219
226
  resetPassword: this.resetPassword,
220
227
  isActive: this.isActive,
221
- role: this.role.toJSON(),
228
+ role: this.role?.toJSON(),
222
229
  createdAt: this.createdAt.toISOString(),
223
230
  updatedAt: this.updatedAt.toISOString(),
224
231
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temboplus/afloat",
3
- "version": "0.1.34",
3
+ "version": "0.1.36",
4
4
  "description": "A JavaScript/TypeScript package providing common utilities and logic shared across all Temboplus-Afloat Projects",
5
5
  "repository": {
6
6
  "type": "git",
@@ -2,6 +2,13 @@ import { z } from "zod";
2
2
  export declare const userManagementContract: {
3
3
  getUsers: {
4
4
  description: "Retrieve a list of all user accounts in the system";
5
+ query: z.ZodObject<{
6
+ eager: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ eager: string;
9
+ }, {
10
+ eager: string;
11
+ }>;
5
12
  summary: "List all user accounts";
6
13
  method: "GET";
7
14
  path: "/login";
@@ -89,6 +96,13 @@ export declare const userManagementContract: {
89
96
  }, {
90
97
  id: string;
91
98
  }>;
99
+ query: z.ZodObject<{
100
+ eager: z.ZodString;
101
+ }, "strip", z.ZodTypeAny, {
102
+ eager: string;
103
+ }, {
104
+ eager: string;
105
+ }>;
92
106
  summary: "Get user account details";
93
107
  method: "GET";
94
108
  path: "/login/:id";
@@ -1 +1 @@
1
- {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../../src/src/features/admin/contract.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiMjC,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,OAAO,sBAAsB,CAAC"}
@@ -11,6 +11,9 @@ exports.userManagementContract = c.router({
11
11
  getUsers: {
12
12
  method: "GET",
13
13
  path: "/login",
14
+ query: zod_1.z.object({
15
+ eager: zod_1.z.string(),
16
+ }),
14
17
  responses: {
15
18
  200: zod_1.z.array(schemas_js_1.UserManagementSchemas.managedUser),
16
19
  401: zod_1.z.object({
@@ -30,6 +33,9 @@ exports.userManagementContract = c.router({
30
33
  pathParams: zod_1.z.object({
31
34
  id: zod_1.z.string(),
32
35
  }),
36
+ query: zod_1.z.object({
37
+ eager: zod_1.z.string(),
38
+ }),
33
39
  responses: {
34
40
  200: schemas_js_1.UserManagementSchemas.managedUser,
35
41
  401: zod_1.z.object({
@@ -1 +1 @@
1
- {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/admin/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAqC,MAAM,uBAAuB,CAAC;AAEvF,OAAO,EAAE,IAAI,EAAiB,MAAM,sBAAsB,CAAC;AAE3D;;;GAGG;AACH,qBAAa,wBACX,SAAQ,cAAc,CAAC,OAAO,sBAAsB,CAA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AAuB,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAiB,MAAM,sBAAsB,CAAC;AAE3D;;;GAGG;AACH,qBAAa,wBACX,SAAQ,cAAc,CAAC,OAAO,sBAAsB,CAAC;IACrD;;;;;OAKG;gBACS,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,UAAU,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;IAIxD;;;;;;OAMG;IACG,UAAU,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAgBvE;;;;;;;OAOG;IACG,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;IAuB5E;;;;;;OAMG;IACG,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAoBnD;;;;;;;OAOG;IACG,iBAAiB,CACrB,EAAE,EAAE,MAAM,EACV,KAAK,GAAE,oBAAyB,GAC/B,OAAO,CAAC,IAAI,CAAC;IAkBhB;;;;;;;;;;OAUG;IACG,WAAW,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAgB3C;;;;;;;;;;OAUG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAuB/C;;;;;;;;;OASG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAsBpC;;;;;;;;;;OAUG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAmBzC"}
@@ -135,7 +135,7 @@ class UserManagementRepository extends base_repository_js_1.BaseRepository {
135
135
  requiredPermissions: [requiredPerm],
136
136
  });
137
137
  }
138
- const result = await this.client.getUsers();
138
+ const result = await this.client.getUsers({ query: { eager: "role" } });
139
139
  const data = this.handleResponse(result, 200);
140
140
  return index_js_1.ManagedUser.createMany(data);
141
141
  }
@@ -159,7 +159,10 @@ class UserManagementRepository extends base_repository_js_1.BaseRepository {
159
159
  requiredPermissions: [requiredPerm],
160
160
  });
161
161
  }
162
- const result = await this.client.getUser({ params: { id } });
162
+ const result = await this.client.getUser({
163
+ params: { id },
164
+ query: { eager: "role" },
165
+ });
163
166
  const data = this.handleResponse(result, 200);
164
167
  const managedUser = index_js_1.ManagedUser.from(data);
165
168
  if (!managedUser) {
@@ -1 +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
+ {"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;IAwBP;;;;;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"}
@@ -83,16 +83,10 @@ class User {
83
83
  this.resetPassword = resetPassword;
84
84
  this.name = name;
85
85
  this.identity = identity;
86
- // Initialize the permissions map
87
86
  this.permissionsMap = {};
88
- for (const permission of Object.values(permission_js_1.Permissions)) {
89
- if (typeof permission === "object") {
90
- Object.values(permission).forEach((perm) => {
91
- this.permissionsMap[perm] = access.includes(perm);
92
- });
93
- }
94
- else {
95
- this.permissionsMap[permission] = access.includes(permission);
87
+ for (const group of Object.values(permission_js_1.Permissions)) {
88
+ for (const perm of Object.values(group)) {
89
+ this.permissionsMap[perm] = access.includes(perm);
96
90
  }
97
91
  }
98
92
  }
@@ -49,7 +49,7 @@ export interface ManagedUserData {
49
49
  roleId: string;
50
50
  resetPassword: boolean;
51
51
  isActive: boolean;
52
- role: RoleData;
52
+ role?: RoleData;
53
53
  createdAt: string;
54
54
  updatedAt: string;
55
55
  }
@@ -62,7 +62,7 @@ export declare class ManagedUser extends UserEntity {
62
62
  readonly roleId: string;
63
63
  readonly resetPassword: boolean;
64
64
  readonly isActive: boolean;
65
- readonly role: Role;
65
+ readonly role?: Role;
66
66
  readonly createdAt: Date;
67
67
  readonly updatedAt: Date;
68
68
  constructor(data: ManagedUserData);
@@ -78,9 +78,9 @@ export declare class ManagedUser extends UserEntity {
78
78
  * Get comprehensive account status
79
79
  */
80
80
  getAccountStatus(): {
81
- status: 'active' | 'inactive' | 'password_reset_required';
81
+ status: "active" | "inactive" | "password_reset_required";
82
82
  label: string;
83
- color: 'success' | 'warning' | 'error';
83
+ color: "success" | "warning" | "error";
84
84
  description: string;
85
85
  };
86
86
  /**
@@ -1 +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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AAC,IAAI,EAAE,GAAG,GAAG,WAAW,GAAG,SAAS;IAa/C,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,WAAW,EAAE;IAMlD,MAAM,IAAI,GAAG;CAed"}
@@ -55,13 +55,13 @@ class UserEntity {
55
55
  * Check if user has any of the specified permissions
56
56
  */
57
57
  canAny(permissions) {
58
- return permissions.some(p => this.permissions.has(p));
58
+ return permissions.some((p) => this.permissions.has(p));
59
59
  }
60
60
  /**
61
61
  * Check if user has all of the specified permissions
62
62
  */
63
63
  canAll(permissions) {
64
- return permissions.every(p => this.permissions.has(p));
64
+ return permissions.every((p) => this.permissions.has(p));
65
65
  }
66
66
  }
67
67
  exports.UserEntity = UserEntity;
@@ -76,7 +76,7 @@ class ManagedUser extends UserEntity {
76
76
  name: data.name,
77
77
  identity: data.identity,
78
78
  profileId: data.profileId,
79
- permissions: data.role.access,
79
+ permissions: data.role?.access ?? [],
80
80
  });
81
81
  Object.defineProperty(this, "type", {
82
82
  enumerable: true,
@@ -124,9 +124,16 @@ class ManagedUser extends UserEntity {
124
124
  this.roleId = data.roleId;
125
125
  this.resetPassword = data.resetPassword;
126
126
  this.isActive = data.isActive;
127
- this.role = new role_js_1.Role(data.role);
128
127
  this.createdAt = new Date(data.createdAt);
129
128
  this.updatedAt = new Date(data.updatedAt);
129
+ if (data.role) {
130
+ try {
131
+ this.role = new role_js_1.Role(data.role);
132
+ }
133
+ catch (_) {
134
+ //
135
+ }
136
+ }
130
137
  }
131
138
  /**
132
139
  * Check if user account is active
@@ -146,32 +153,32 @@ class ManagedUser extends UserEntity {
146
153
  getAccountStatus() {
147
154
  if (!this.isActive) {
148
155
  return {
149
- status: 'inactive',
150
- label: 'Inactive',
151
- color: 'error',
152
- description: 'Account has been deactivated by an administrator'
156
+ status: "inactive",
157
+ label: "Inactive",
158
+ color: "error",
159
+ description: "Account has been deactivated by an administrator",
153
160
  };
154
161
  }
155
162
  if (this.resetPassword) {
156
163
  return {
157
- status: 'password_reset_required',
158
- label: 'Password Reset Required',
159
- color: 'warning',
160
- description: 'User must reset their password on next login'
164
+ status: "password_reset_required",
165
+ label: "Password Reset Required",
166
+ color: "warning",
167
+ description: "User must reset their password on next login",
161
168
  };
162
169
  }
163
170
  return {
164
- status: 'active',
165
- label: 'Active',
166
- color: 'success',
167
- description: 'Account is active and ready to use'
171
+ status: "active",
172
+ label: "Active",
173
+ color: "success",
174
+ description: "Account is active and ready to use",
168
175
  };
169
176
  }
170
177
  /**
171
178
  * Get role display name
172
179
  */
173
180
  getRoleName() {
174
- return this.role.name;
181
+ return this.role?.name ?? "";
175
182
  }
176
183
  /**
177
184
  * Get formatted creation date
@@ -187,9 +194,9 @@ class ManagedUser extends UserEntity {
187
194
  const diffMs = now.getTime() - this.updatedAt.getTime();
188
195
  const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
189
196
  if (diffDays === 0)
190
- return 'Today';
197
+ return "Today";
191
198
  if (diffDays === 1)
192
- return 'Yesterday';
199
+ return "Yesterday";
193
200
  if (diffDays < 7)
194
201
  return `${diffDays} days ago`;
195
202
  if (diffDays < 30)
@@ -198,7 +205,7 @@ class ManagedUser extends UserEntity {
198
205
  }
199
206
  static from(data) {
200
207
  try {
201
- if (!data?.id || !data?.name || !data?.identity || !data?.role) {
208
+ if (!data?.id || !data?.name || !data?.identity || !data?.roleId) {
202
209
  console.error("Missing required ManagedUser fields:", data);
203
210
  return undefined;
204
211
  }
@@ -210,7 +217,7 @@ class ManagedUser extends UserEntity {
210
217
  }
211
218
  }
212
219
  static createMany(dataArray) {
213
- return dataArray.map(data => ManagedUser.from(data)).filter(Boolean);
220
+ return dataArray.map((data) => ManagedUser.from(data)).filter(Boolean);
214
221
  }
215
222
  toJSON() {
216
223
  return {
@@ -222,7 +229,7 @@ class ManagedUser extends UserEntity {
222
229
  roleId: this.roleId,
223
230
  resetPassword: this.resetPassword,
224
231
  isActive: this.isActive,
225
- role: this.role.toJSON(),
232
+ role: this.role?.toJSON(),
226
233
  createdAt: this.createdAt.toISOString(),
227
234
  updatedAt: this.updatedAt.toISOString(),
228
235
  };