@temboplus/afloat 0.1.76-beta.0 → 0.1.77-beta.10
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/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/lib/error/error.permission.d.ts +1 -1
- package/dist/modules/auth/auth.contract.d.ts +6 -6
- package/dist/modules/auth/auth.manager.d.ts +1 -1
- package/dist/modules/auth/company-membership.model.d.ts +171 -0
- package/dist/modules/auth/index.d.ts +1 -1
- package/dist/modules/auth/user.model.d.ts +330 -33
- package/dist/modules/contact/contact-info.model.d.ts +183 -533
- package/dist/modules/contact/contact.api-contract.d.ts +16 -16
- package/dist/modules/contact/contact.dtos.d.ts +4 -4
- package/dist/modules/contact/contact.model.d.ts +309 -32
- package/dist/modules/login/index.d.ts +2 -0
- package/dist/modules/login/login.api-contract.d.ts +34 -5
- package/dist/modules/login/login.dtos.d.ts +85 -0
- package/dist/modules/login/login.model.d.ts +168 -1
- package/dist/modules/{auth → login}/permission.type.d.ts +8 -8
- package/dist/modules/payout/payout.api-contract.d.ts +46 -46
- package/dist/modules/payout/payout.dtos.d.ts +30 -24
- package/dist/modules/payout/payout.model.d.ts +242 -2
- package/dist/modules/payout/payout.query.d.ts +7 -0
- package/dist/modules/profile/profile.model.d.ts +65 -30
- package/dist/modules/team-member/index.d.ts +4 -0
- package/dist/modules/team-member/role.model.d.ts +61 -0
- package/dist/modules/{user/user.contract.d.ts → team-member/team-member.contract.d.ts} +238 -127
- package/dist/modules/team-member/team-member.dtos.d.ts +261 -0
- package/dist/modules/team-member/team-member.model.d.ts +237 -0
- package/dist/modules/team-member/team-member.repository.d.ts +179 -0
- package/dist/modules/wallet/narration.model.d.ts +34 -38
- package/dist/modules/wallet/statement-entry.model.d.ts +172 -73
- package/dist/modules/wallet/wallet.contract.d.ts +4 -4
- package/dist/modules/wallet/wallet.dtos.d.ts +8 -8
- package/dist/modules/wallet/wallet.model.d.ts +56 -19
- package/dist/modules/wallet/wallet.query.d.ts +95 -0
- package/dist/modules/wallet/wallet.repository.d.ts +45 -13
- package/package.json +2 -2
- package/dist/modules/user/index.d.ts +0 -4
- package/dist/modules/user/role.model.d.ts +0 -13
- package/dist/modules/user/user.dtos.d.ts +0 -145
- package/dist/modules/user/user.model.d.ts +0 -108
- package/dist/modules/user/user.repository.d.ts +0 -179
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { Amount } from "@temboplus/frontend-core";
|
|
2
2
|
import { WalletStatementEntry } from "./statement-entry.model.js";
|
|
3
3
|
import { Wallet } from "./wallet.model.js";
|
|
4
|
-
import { WalletDTOSchemas } from "./wallet.dtos.js";
|
|
5
|
-
import { z } from "zod";
|
|
6
4
|
import { contract } from "./wallet.contract.js";
|
|
7
5
|
import { BaseRepository } from "@/lib/api/base-repository.js";
|
|
6
|
+
import { WalletQuery } from "./wallet.query.js";
|
|
7
|
+
import { WalletQueryDTO } from "./wallet.dtos.js";
|
|
8
|
+
/**
|
|
9
|
+
* Flexible query input type - supports the class, filters interface, URL params, etc.
|
|
10
|
+
*/
|
|
11
|
+
export type WalletQueryInput = WalletQuery | WalletQueryDTO | Record<string, string> | URLSearchParams | null | undefined;
|
|
8
12
|
/**
|
|
9
13
|
* Repository class for managing wallet operations including balance checking,
|
|
10
14
|
* statement generation, and wallet information retrieval.
|
|
@@ -87,13 +91,9 @@ export declare class WalletRepository extends BaseRepository<typeof contract> {
|
|
|
87
91
|
/**
|
|
88
92
|
* Retrieves all wallets associated with the authenticated user.
|
|
89
93
|
*
|
|
90
|
-
* Supports
|
|
91
|
-
* status, or currency filtering.
|
|
94
|
+
* Supports flexible filtering through WalletQuery or plain filter objects.
|
|
92
95
|
*
|
|
93
96
|
* @param query - Optional query parameters for filtering wallets
|
|
94
|
-
* @param query.accountNo - Filter by specific account number
|
|
95
|
-
* @param query.status - Filter by wallet status (active, inactive, etc.)
|
|
96
|
-
* @param query.currencyCode - Filter by currency code
|
|
97
97
|
* @returns Promise that resolves to an array of validated Wallet instances
|
|
98
98
|
* @throws {Error} If the wallet fetch operation fails or data is invalid
|
|
99
99
|
*
|
|
@@ -105,14 +105,38 @@ export declare class WalletRepository extends BaseRepository<typeof contract> {
|
|
|
105
105
|
* // Get specific wallet by account number
|
|
106
106
|
* const specificWallet = await repo.getWallets({ accountNo: '123456789' });
|
|
107
107
|
*
|
|
108
|
-
* // Get wallets with multiple filters
|
|
109
|
-
* const
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
108
|
+
* // Get wallets with multiple filters using WalletQuery
|
|
109
|
+
* const query = WalletQuery.create()
|
|
110
|
+
* .whereCountryCode('TZ')
|
|
111
|
+
* .whereCurrencyCode('TZS');
|
|
112
|
+
* const tzWallets = await repo.getWallets(query);
|
|
113
|
+
*
|
|
114
|
+
* // Get wallets with filters object
|
|
115
|
+
* const usdWallets = await repo.getWallets({ currencyCode: 'USD' });
|
|
113
116
|
* ```
|
|
114
117
|
*/
|
|
115
|
-
getWallets(query?:
|
|
118
|
+
getWallets(query?: WalletQueryInput): Promise<Wallet[]>;
|
|
119
|
+
/**
|
|
120
|
+
* Retrieves a single wallet by its ID.
|
|
121
|
+
*
|
|
122
|
+
* Since the API doesn't have a dedicated /id endpoint, this method queries
|
|
123
|
+
* the list endpoint with the ID filter and returns the first result.
|
|
124
|
+
*
|
|
125
|
+
* @param id - The unique identifier of the wallet to retrieve
|
|
126
|
+
* @returns Promise that resolves to the wallet if found, undefined otherwise
|
|
127
|
+
* @throws {Error} If the fetch operation fails
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const wallet = await repo.getByID("wallet-id");
|
|
132
|
+
* if (wallet) {
|
|
133
|
+
* console.log(`Wallet: ${wallet.accountName}`);
|
|
134
|
+
* } else {
|
|
135
|
+
* console.log('Wallet not found');
|
|
136
|
+
* }
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
getByID(id: string): Promise<Wallet | undefined>;
|
|
116
140
|
/**
|
|
117
141
|
* Retrieves wallet statement entries for a specified date range.
|
|
118
142
|
*
|
|
@@ -170,4 +194,12 @@ export declare class WalletRepository extends BaseRepository<typeof contract> {
|
|
|
170
194
|
wallet?: Wallet;
|
|
171
195
|
accountNo?: string;
|
|
172
196
|
}): Promise<WalletStatementEntry[]>;
|
|
197
|
+
/**
|
|
198
|
+
* Check if a wallet exists with the given query
|
|
199
|
+
*/
|
|
200
|
+
exists(query?: WalletQueryInput): Promise<boolean>;
|
|
201
|
+
/**
|
|
202
|
+
* Get count of wallets matching a query
|
|
203
|
+
*/
|
|
204
|
+
count(query?: WalletQueryInput): Promise<number>;
|
|
173
205
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temboplus/afloat",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.77-beta.10",
|
|
4
4
|
"description": "A foundational library for Temboplus-Afloat projects.",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -58,6 +58,6 @@
|
|
|
58
58
|
"typescript": "^5.8.3"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@temboplus/frontend-core": "^0.2.
|
|
61
|
+
"@temboplus/frontend-core": "^0.2.20-beta.2"
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { RoleDTO } from "@/modules/user/user.dtos.js";
|
|
2
|
-
export declare class Role {
|
|
3
|
-
readonly id: string;
|
|
4
|
-
readonly name: string;
|
|
5
|
-
readonly description?: string;
|
|
6
|
-
readonly permissions: ReadonlySet<string>;
|
|
7
|
-
readonly createdAt: Date;
|
|
8
|
-
readonly updatedAt: Date;
|
|
9
|
-
constructor(data: RoleDTO);
|
|
10
|
-
hasPermission(permission: string): boolean;
|
|
11
|
-
static from(data: any): Role | undefined;
|
|
12
|
-
toJSON(): any;
|
|
13
|
-
}
|
|
@@ -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
|
-
}
|