@temboplus/afloat 0.1.76-beta.0 → 0.1.77-beta.2

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 (33) hide show
  1. package/dist/index.cjs.js +1 -1
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.esm.js +1 -1
  5. package/dist/index.esm.js.map +1 -1
  6. package/dist/lib/error/error.permission.d.ts +1 -1
  7. package/dist/modules/auth/auth.contract.d.ts +4 -4
  8. package/dist/modules/auth/auth.manager.d.ts +1 -1
  9. package/dist/modules/auth/company-membership.model.d.ts +58 -0
  10. package/dist/modules/auth/index.d.ts +1 -1
  11. package/dist/modules/auth/user.model.d.ts +107 -33
  12. package/dist/modules/contact/contact.api-contract.d.ts +16 -16
  13. package/dist/modules/contact/contact.dtos.d.ts +4 -4
  14. package/dist/modules/login/index.d.ts +2 -0
  15. package/dist/modules/login/login.api-contract.d.ts +34 -5
  16. package/dist/modules/login/login.dtos.d.ts +85 -0
  17. package/dist/modules/login/login.model.d.ts +138 -1
  18. package/dist/modules/{auth → login}/permission.type.d.ts +8 -8
  19. package/dist/modules/payout/payout.api-contract.d.ts +46 -46
  20. package/dist/modules/payout/payout.dtos.d.ts +24 -24
  21. package/dist/modules/team-member/index.d.ts +4 -0
  22. package/dist/modules/{user → team-member}/role.model.d.ts +2 -2
  23. package/dist/modules/{user/user.contract.d.ts → team-member/team-member.contract.d.ts} +238 -127
  24. package/dist/modules/team-member/team-member.dtos.d.ts +261 -0
  25. package/dist/modules/team-member/team-member.model.d.ts +137 -0
  26. package/dist/modules/team-member/team-member.repository.d.ts +179 -0
  27. package/dist/modules/wallet/wallet.contract.d.ts +4 -4
  28. package/dist/modules/wallet/wallet.dtos.d.ts +8 -8
  29. package/package.json +1 -1
  30. package/dist/modules/user/index.d.ts +0 -4
  31. package/dist/modules/user/user.dtos.d.ts +0 -145
  32. package/dist/modules/user/user.model.d.ts +0 -108
  33. package/dist/modules/user/user.repository.d.ts +0 -179
@@ -1,145 +0,0 @@
1
- import { z } from "zod";
2
- /**
3
- * Type definition for password schema using Zod.
4
- * This is used as a TypeScript type helper for the actual schema implementation.
5
- */
6
- type _PasswordType = z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
7
- /**
8
- * Type definition for role schema using Zod.
9
- * This is used as a TypeScript type helper for the actual schema implementation.
10
- */
11
- type _RoleType = z.ZodObject<{
12
- id: z.ZodString;
13
- name: z.ZodString;
14
- description: z.ZodOptional<z.ZodString>;
15
- access: z.ZodArray<z.ZodString>;
16
- createdAt: z.ZodString;
17
- updatedAt: z.ZodString;
18
- }>;
19
- /**
20
- * Type definition for managed user schema using Zod.
21
- * This is used as a TypeScript type helper for the actual schema implementation.
22
- */
23
- type _ManagedUserType = z.ZodObject<{
24
- id: z.ZodString;
25
- name: z.ZodString;
26
- identity: z.ZodString;
27
- type: z.ZodString;
28
- profileId: z.ZodString;
29
- roleId: z.ZodString;
30
- resetPassword: z.ZodBoolean;
31
- isActive: z.ZodBoolean;
32
- isArchived: z.ZodBoolean;
33
- role: z.ZodOptional<z.ZodType<RoleDTO>>;
34
- createdAt: z.ZodString;
35
- updatedAt: z.ZodString;
36
- }>;
37
- /**
38
- * Type definition for create user request schema using Zod.
39
- * This is used as a TypeScript type helper for the actual schema implementation.
40
- */
41
- type _CreateUserRequestType = z.ZodObject<{
42
- name: z.ZodString;
43
- identity: z.ZodString;
44
- password: z.ZodOptional<_PasswordType>;
45
- roleId: z.ZodOptional<z.ZodString>;
46
- resetPassword: z.ZodOptional<z.ZodBoolean>;
47
- }>;
48
- /**
49
- * Type definition for update user request schema using Zod.
50
- * This is used as a TypeScript type helper for the actual schema implementation.
51
- */
52
- type _UpdateUserRequestType = z.ZodObject<{
53
- name: z.ZodOptional<z.ZodString>;
54
- roleId: z.ZodOptional<z.ZodString>;
55
- password: z.ZodOptional<_PasswordType>;
56
- resetPassword: z.ZodOptional<z.ZodBoolean>;
57
- isActive: z.ZodOptional<z.ZodBoolean>;
58
- }>;
59
- /**
60
- * Type definition for reset password request schema using Zod.
61
- * This is used as a TypeScript type helper for the actual schema implementation.
62
- */
63
- type _ResetPasswordRequestType = z.ZodObject<{
64
- newPassword: z.ZodOptional<_PasswordType>;
65
- sendNotification: z.ZodOptional<z.ZodBoolean>;
66
- }>;
67
- /**
68
- * Type definition for create user response schema using Zod.
69
- * This is used as a TypeScript type helper for the actual schema implementation.
70
- */
71
- type _CreateUserResponseType = z.ZodObject<{
72
- id: z.ZodString;
73
- name: z.ZodString;
74
- identity: z.ZodString;
75
- type: z.ZodString;
76
- profileId: z.ZodString;
77
- roleId: z.ZodString;
78
- isActive: z.ZodBoolean;
79
- isArchived: z.ZodBoolean;
80
- createdAt: z.ZodString;
81
- }>;
82
- /**
83
- * Type definition for managed user query parameters schema using Zod.
84
- * This is used as a TypeScript type helper for the actual schema implementation.
85
- */
86
- type _ManagedUserQueryParamsType = z.ZodObject<{
87
- id: z.ZodOptional<z.ZodString>;
88
- name: z.ZodOptional<z.ZodString>;
89
- identity: z.ZodOptional<z.ZodString>;
90
- type: z.ZodOptional<z.ZodString>;
91
- profileId: z.ZodOptional<z.ZodString>;
92
- roleId: z.ZodOptional<z.ZodString>;
93
- resetPassword: z.ZodOptional<z.ZodNumber>;
94
- isActive: z.ZodOptional<z.ZodNumber>;
95
- isArchived: z.ZodOptional<z.ZodNumber>;
96
- createdAt: z.ZodOptional<z.ZodString>;
97
- updatedAt: z.ZodOptional<z.ZodString>;
98
- eager: z.ZodOptional<z.ZodString>;
99
- }>;
100
- /**
101
- * Collection of user management schemas for export.
102
- * Provides access to all user and role validation schemas.
103
- */
104
- export declare const UserManagementDTOSchemas: {
105
- role: _RoleType;
106
- managedUser: _ManagedUserType;
107
- managedUserQueryParams: _ManagedUserQueryParamsType;
108
- createUserRequest: _CreateUserRequestType;
109
- updateUserRequest: _UpdateUserRequestType;
110
- resetPasswordRequest: _ResetPasswordRequestType;
111
- createUserResponse: _CreateUserResponseType;
112
- password: _PasswordType;
113
- };
114
- /**
115
- * TypeScript type for a validated role object.
116
- * Use this type for role instances that have been validated against the schema.
117
- */
118
- export type RoleDTO = z.infer<typeof UserManagementDTOSchemas.role>;
119
- /**
120
- * TypeScript type for a create user request object.
121
- * Use this type for user creation requests that have been validated against the schema.
122
- */
123
- export type CreateUserRequestDTO = z.infer<typeof UserManagementDTOSchemas.createUserRequest>;
124
- /**
125
- * TypeScript type for an update user request object.
126
- * Use this type for user update requests that have been validated against the schema.
127
- */
128
- export type UpdateUserRequestDTO = z.infer<typeof UserManagementDTOSchemas.updateUserRequest>;
129
- /**
130
- * TypeScript type for a reset password request object.
131
- * Use this type for password reset requests that have been validated against the schema.
132
- */
133
- export type ResetPasswordRequestDTO = z.infer<typeof UserManagementDTOSchemas.resetPasswordRequest>;
134
- /**
135
- * TypeScript type for a create user response object.
136
- * Use this type for user creation responses that have been validated against the schema.
137
- */
138
- export type CreateUserResponseDTO = z.infer<typeof UserManagementDTOSchemas.createUserResponse>;
139
- /**
140
- * TypeScript type for managed user query parameters.
141
- * Use this type for query parameter objects that have been validated against the schema.
142
- * All fields are optional to allow flexible filtering and searching.
143
- */
144
- export type ManagedUserQueryParamsDTO = z.infer<typeof UserManagementDTOSchemas.managedUserQueryParams>;
145
- export {};
@@ -1,108 +0,0 @@
1
- import { RoleDTO } from "@/modules/user/user.dtos.js";
2
- import { Role } from "./role.model.js";
3
- export interface UserEntityData {
4
- id: string;
5
- name: string;
6
- identity: string;
7
- profileId: string;
8
- permissions: string[];
9
- }
10
- /**
11
- * Base user entity - represents a user in the system
12
- */
13
- export declare class UserEntity {
14
- readonly id: string;
15
- readonly name: string;
16
- readonly identity: string;
17
- readonly profileId: string;
18
- readonly permissions: ReadonlySet<string>;
19
- constructor(data: UserEntityData);
20
- /**
21
- * Check if user has a specific permission
22
- */
23
- can(permission: string): boolean;
24
- /**
25
- * Check if user has any of the specified permissions
26
- */
27
- canAny(permissions: string[]): boolean;
28
- /**
29
- * Check if user has all of the specified permissions
30
- */
31
- canAll(permissions: string[]): boolean;
32
- }
33
- export interface AuthenticatedUserData {
34
- name: string;
35
- identity: string;
36
- profileId: string;
37
- profile: any;
38
- token: string;
39
- resetPassword: boolean;
40
- permissions: string[];
41
- sessionId?: string;
42
- expiresAt?: string;
43
- }
44
- export interface ManagedUserData {
45
- id: string;
46
- name: string;
47
- identity: string;
48
- type: string;
49
- profileId: string;
50
- roleId: string;
51
- resetPassword: boolean;
52
- isActive: boolean;
53
- isArchived: boolean;
54
- role?: RoleDTO;
55
- createdAt: string;
56
- updatedAt: string;
57
- }
58
- /**
59
- * Represents a user from the admin management perspective.
60
- * Same person as AuthenticatedUser but with management metadata and capabilities.
61
- */
62
- export declare class ManagedUser extends UserEntity {
63
- readonly type: string;
64
- readonly roleId: string;
65
- readonly resetPassword: boolean;
66
- readonly isActive: boolean;
67
- readonly isArchived: boolean;
68
- readonly role?: Role;
69
- readonly createdAt: Date;
70
- readonly updatedAt: Date;
71
- constructor(data: ManagedUserData);
72
- /**
73
- * Check if user account is active
74
- */
75
- isAccountActive(): boolean;
76
- /**
77
- * Check if user account is archived
78
- */
79
- isAccountArchived(): boolean;
80
- /**
81
- * Check if user needs to reset password
82
- */
83
- needsPasswordReset(): boolean;
84
- /**
85
- * Get comprehensive account status
86
- */
87
- getAccountStatus(): {
88
- status: "active" | "inactive" | "archived" | "password_reset_required";
89
- label: string;
90
- color: "success" | "warning" | "error" | "default";
91
- description: string;
92
- };
93
- /**
94
- * Get role display name
95
- */
96
- getRoleName(): string;
97
- /**
98
- * Get formatted creation date
99
- */
100
- getCreatedDate(): string;
101
- /**
102
- * Get time since last update
103
- */
104
- getLastUpdateInfo(): string;
105
- static from(data: any): ManagedUser | undefined;
106
- static createMany(dataArray: any[]): ManagedUser[];
107
- toJSON(): any;
108
- }
@@ -1,179 +0,0 @@
1
- import { BaseRepository } from "@/lib/api/base-repository.js";
2
- import { ManagedUser } from "@/modules/user/user.model.js";
3
- import { Role } from "@/modules/user/role.model.js";
4
- import { userManagementContract } from "./user.contract.js";
5
- import { CreateUserRequestDTO, CreateUserResponseDTO, UpdateUserRequestDTO, ResetPasswordRequestDTO, ManagedUserQueryParamsDTO } from "./user.dtos.js";
6
- /**
7
- * Repository class for managing user accounts through API interactions.
8
- * Handles user creation, updates, archiving, and role management.
9
- *
10
- * This repository handles pure API communication without permission checking.
11
- * Permission validation should be handled at the service layer or route handlers.
12
- *
13
- * @extends {BaseRepository<typeof userManagementContract>}
14
- *
15
- * @example
16
- * ```typescript
17
- * const repo = new UserManagementRepository({ token: adminToken });
18
- * const users = await repo.getAllUsers();
19
- * ```
20
- */
21
- export declare class UserManagementRepository extends BaseRepository<typeof userManagementContract> {
22
- /**
23
- * Creates an instance of UserManagementRepository using the user management contract.
24
- *
25
- * @param options - Optional configuration
26
- * @param options.token - Authentication token for API calls
27
- * @param options.root - Custom API root URL
28
- *
29
- * @example
30
- * ```typescript
31
- * const repo = new UserManagementRepository({
32
- * token: "admin-auth-token",
33
- * root: "https://api-staging.afloat.money/v1"
34
- * });
35
- * ```
36
- */
37
- constructor(options?: {
38
- token?: string;
39
- root?: string;
40
- });
41
- /**
42
- * Creates a new user account.
43
- *
44
- * @param input - The data required to create a new user account
45
- * @returns Promise that resolves to the newly created user response
46
- * @throws {APIError} If the creation operation fails
47
- *
48
- * @example
49
- * ```typescript
50
- * const newUser = await repo.createUser({
51
- * email: "newuser@example.com",
52
- * name: "New User",
53
- * roleId: "role-id"
54
- * });
55
- * ```
56
- */
57
- createUser(input: CreateUserRequestDTO): Promise<CreateUserResponseDTO>;
58
- /**
59
- * Updates an existing user account by ID.
60
- *
61
- * @param id - The unique identifier of the user account to update
62
- * @param input - The data to update the user account with
63
- * @returns Promise that resolves to the updated user account
64
- * @throws {APIError} If the update operation fails
65
- *
66
- * @example
67
- * ```typescript
68
- * const updatedUser = await repo.updateUser("user-id", {
69
- * name: "Updated Name",
70
- * email: "updated@example.com"
71
- * });
72
- * ```
73
- */
74
- updateUser(id: string, input: UpdateUserRequestDTO): Promise<ManagedUser>;
75
- /**
76
- * Archives (soft deletes) a user account by ID.
77
- *
78
- * @param id - The unique identifier of the user account to archive
79
- * @returns Promise that resolves to the updated user object
80
- * @throws {APIError} If the archive operation fails
81
- *
82
- * @example
83
- * ```typescript
84
- * const archivedUser = await repo.archiveUser("user-id");
85
- * ```
86
- */
87
- archiveUser(id: string): Promise<ManagedUser>;
88
- /**
89
- * Unarchives a previously archived user account by ID.
90
- *
91
- * @param id - The unique identifier of the user account to unarchive
92
- * @returns Promise that resolves to the updated user object
93
- * @throws {APIError} If the unarchive operation fails
94
- *
95
- * @example
96
- * ```typescript
97
- * const restoredUser = await repo.unArchiveUser("user-id");
98
- * ```
99
- */
100
- unArchiveUser(id: string): Promise<ManagedUser>;
101
- /**
102
- * Resets a user's password.
103
- *
104
- * @param id - The unique identifier of the user account
105
- * @param input - Optional password reset configuration
106
- * @returns Promise that resolves to success status
107
- * @throws {APIError} If the password reset operation fails
108
- *
109
- * @example
110
- * ```typescript
111
- * const result = await repo.resetUserPassword("user-id", {
112
- * sendEmail: true
113
- * });
114
- * ```
115
- */
116
- resetUserPassword(id: string, input?: ResetPasswordRequestDTO): Promise<{
117
- success: boolean;
118
- }>;
119
- /**
120
- * Retrieves all user accounts.
121
- * Results are ordered in descending order by creation date by default.
122
- *
123
- * @param query - Optional query parameters for filtering and eager loading
124
- * @returns Promise that resolves to an array of managed users
125
- * @throws {APIError} If the fetch operation fails
126
- *
127
- * @example
128
- * ```typescript
129
- * // Get all users with role information
130
- * const users = await repo.getAllUsers({ eager: "role" });
131
- *
132
- * // Get users with custom query
133
- * const activeUsers = await repo.getAllUsers({ status: "active" });
134
- * ```
135
- */
136
- getAllUsers(query?: ManagedUserQueryParamsDTO): Promise<ManagedUser[]>;
137
- /**
138
- * Retrieves a specific user account by ID.
139
- *
140
- * @param id - The unique identifier of the user account to retrieve
141
- * @param query - Optional query parameters for eager loading
142
- * @returns Promise that resolves to the managed user
143
- * @throws {APIError} If the user is not found or fetch operation fails
144
- *
145
- * @example
146
- * ```typescript
147
- * const user = await repo.getUser("user-id", { eager: "role" });
148
- * console.log(`User: ${user.name}, Role: ${user.role?.name}`);
149
- * ```
150
- */
151
- getUser(id: string, query?: ManagedUserQueryParamsDTO): Promise<ManagedUser>;
152
- /**
153
- * Retrieves all available roles in the system.
154
- *
155
- * @returns Promise that resolves to an array of roles
156
- * @throws {APIError} If the fetch operation fails
157
- *
158
- * @example
159
- * ```typescript
160
- * const roles = await repo.getAllRoles();
161
- * roles.forEach(role => console.log(`Role: ${role.name}`));
162
- * ```
163
- */
164
- getAllRoles(): Promise<Role[]>;
165
- /**
166
- * Retrieves a specific role by ID.
167
- *
168
- * @param id - The unique identifier of the role to retrieve
169
- * @returns Promise that resolves to the role
170
- * @throws {APIError} If the role is not found or fetch operation fails
171
- *
172
- * @example
173
- * ```typescript
174
- * const role = await repo.getRole("role-id");
175
- * console.log(`Role: ${role.name}, Permissions: ${role.permissions.length}`);
176
- * ```
177
- */
178
- getRole(id: string): Promise<Role>;
179
- }