@famgia/omnify-react-sso 2.2.3 → 2.2.4
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/ant/index.cjs +3235 -0
- package/dist/ant/index.cjs.map +1 -0
- package/dist/ant/index.d.cts +685 -0
- package/dist/ant/index.d.ts +685 -0
- package/dist/ant/index.js +3268 -0
- package/dist/ant/index.js.map +1 -0
- package/dist/core/index.cjs +2432 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +112 -0
- package/dist/core/index.d.ts +112 -0
- package/dist/core/index.js +2360 -0
- package/dist/core/index.js.map +1 -0
- package/dist/{testing → core/testing}/index.cjs +1 -1
- package/dist/core/testing/index.cjs.map +1 -0
- package/dist/{testing → core/testing}/index.d.cts +1 -1
- package/dist/{testing → core/testing}/index.d.ts +1 -1
- package/dist/{testing → core/testing}/index.js +1 -1
- package/dist/core/testing/index.js.map +1 -0
- package/dist/index-CHuDTvHg.d.ts +2250 -0
- package/dist/index-DVssHZFD.d.cts +2250 -0
- package/dist/index.cjs +2464 -784
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1822
- package/dist/index.d.ts +10 -1822
- package/dist/index.js +2528 -771
- package/dist/index.js.map +1 -1
- package/dist/{types-bD5deLxs.d.cts → types-BxClyvTX.d.cts} +2 -3
- package/dist/{types-bD5deLxs.d.ts → types-BxClyvTX.d.ts} +2 -3
- package/dist/userService-DH9-vPSg.d.cts +269 -0
- package/dist/userService-DH9-vPSg.d.ts +269 -0
- package/package.json +27 -48
- package/dist/@omnify-base/package.json +0 -16
- package/dist/@omnify-base/schemas/Branch.ts +0 -131
- package/dist/@omnify-base/schemas/BranchCache.ts +0 -131
- package/dist/@omnify-base/schemas/OrganizationCache.ts +0 -117
- package/dist/@omnify-base/schemas/Permission.ts +0 -114
- package/dist/@omnify-base/schemas/Role.ts +0 -128
- package/dist/@omnify-base/schemas/RolePermission.ts +0 -97
- package/dist/@omnify-base/schemas/Team.ts +0 -110
- package/dist/@omnify-base/schemas/TeamCache.ts +0 -110
- package/dist/@omnify-base/schemas/TeamPermission.ts +0 -109
- package/dist/@omnify-base/schemas/User.ts +0 -135
- package/dist/@omnify-base/schemas/UserCache.ts +0 -142
- package/dist/@omnify-base/schemas/common.ts +0 -47
- package/dist/@omnify-base/schemas/i18n.ts +0 -118
- package/dist/schemas/index.cjs +0 -645
- package/dist/schemas/index.cjs.map +0 -1
- package/dist/schemas/index.d.cts +0 -260
- package/dist/schemas/index.d.ts +0 -260
- package/dist/schemas/index.js +0 -557
- package/dist/schemas/index.js.map +0 -1
- package/dist/testing/index.cjs.map +0 -1
- package/dist/testing/index.js.map +0 -1
- package/scripts/build-schemas.ts +0 -191
- package/scripts/postinstall.cjs +0 -43
|
@@ -55,7 +55,7 @@ interface SsoContextValue {
|
|
|
55
55
|
/** Global logout (logout from Console too) */
|
|
56
56
|
globalLogout: (redirectTo?: string) => void;
|
|
57
57
|
/** Switch to different organization */
|
|
58
|
-
switchOrg: (
|
|
58
|
+
switchOrg: (orgId: string) => void;
|
|
59
59
|
/** Refresh user data */
|
|
60
60
|
refreshUser: () => Promise<void>;
|
|
61
61
|
/** Get headers for API requests */
|
|
@@ -211,7 +211,6 @@ interface OrgBranchSelection {
|
|
|
211
211
|
*/
|
|
212
212
|
interface BranchGateSelection {
|
|
213
213
|
orgId: string;
|
|
214
|
-
orgSlug: string;
|
|
215
214
|
orgName: string;
|
|
216
215
|
branchId: string;
|
|
217
216
|
branchName: string;
|
|
@@ -234,4 +233,4 @@ interface BranchGateProps {
|
|
|
234
233
|
description?: string;
|
|
235
234
|
}
|
|
236
235
|
|
|
237
|
-
export type { BranchContextValue as B,
|
|
236
|
+
export type { BranchContextValue as B, OrgBranchSelection as O, ProtectedRouteProps as P, SsoBranch as S, BranchGateProps as a, BranchGateSelection as b, BranchProviderProps as c, OrgBranchSelectorModalProps as d, OrganizationSwitcherProps as e, SsoCallbackProps as f, SsoCallbackResponse as g, SsoConfig as h, SsoContextValue as i, SsoOrganization as j, SsoProviderProps as k, SsoUser as l };
|
|
@@ -55,7 +55,7 @@ interface SsoContextValue {
|
|
|
55
55
|
/** Global logout (logout from Console too) */
|
|
56
56
|
globalLogout: (redirectTo?: string) => void;
|
|
57
57
|
/** Switch to different organization */
|
|
58
|
-
switchOrg: (
|
|
58
|
+
switchOrg: (orgId: string) => void;
|
|
59
59
|
/** Refresh user data */
|
|
60
60
|
refreshUser: () => Promise<void>;
|
|
61
61
|
/** Get headers for API requests */
|
|
@@ -211,7 +211,6 @@ interface OrgBranchSelection {
|
|
|
211
211
|
*/
|
|
212
212
|
interface BranchGateSelection {
|
|
213
213
|
orgId: string;
|
|
214
|
-
orgSlug: string;
|
|
215
214
|
orgName: string;
|
|
216
215
|
branchId: string;
|
|
217
216
|
branchName: string;
|
|
@@ -234,4 +233,4 @@ interface BranchGateProps {
|
|
|
234
233
|
description?: string;
|
|
235
234
|
}
|
|
236
235
|
|
|
237
|
-
export type { BranchContextValue as B,
|
|
236
|
+
export type { BranchContextValue as B, OrgBranchSelection as O, ProtectedRouteProps as P, SsoBranch as S, BranchGateProps as a, BranchGateSelection as b, BranchProviderProps as c, OrgBranchSelectorModalProps as d, OrganizationSwitcherProps as e, SsoCallbackProps as f, SsoCallbackResponse as g, SsoConfig as h, SsoContextValue as i, SsoOrganization as j, SsoProviderProps as k, SsoUser as l };
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base service configuration
|
|
3
|
+
*/
|
|
4
|
+
interface ServiceConfig {
|
|
5
|
+
apiUrl: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Role Service - Role Management
|
|
10
|
+
*
|
|
11
|
+
* CRUD operations for roles and role-permission assignments
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
interface Role {
|
|
15
|
+
id: number;
|
|
16
|
+
name: string;
|
|
17
|
+
slug: string;
|
|
18
|
+
description: string | null;
|
|
19
|
+
level: number;
|
|
20
|
+
permissions_count?: number;
|
|
21
|
+
console_org_id?: string | null;
|
|
22
|
+
organization?: {
|
|
23
|
+
id: string;
|
|
24
|
+
console_org_id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
code: string;
|
|
27
|
+
} | null;
|
|
28
|
+
created_at: string;
|
|
29
|
+
updated_at: string;
|
|
30
|
+
}
|
|
31
|
+
interface Permission {
|
|
32
|
+
id: number;
|
|
33
|
+
name: string;
|
|
34
|
+
slug: string;
|
|
35
|
+
group: string | null;
|
|
36
|
+
description?: string | null;
|
|
37
|
+
roles_count?: number;
|
|
38
|
+
created_at: string;
|
|
39
|
+
updated_at: string;
|
|
40
|
+
}
|
|
41
|
+
interface RoleWithPermissions extends Role {
|
|
42
|
+
permissions: Permission[];
|
|
43
|
+
}
|
|
44
|
+
interface CreateRoleInput {
|
|
45
|
+
slug: string;
|
|
46
|
+
name: string;
|
|
47
|
+
level: number;
|
|
48
|
+
description?: string;
|
|
49
|
+
scope?: "global" | "org" | "org-wide" | "branch";
|
|
50
|
+
console_org_id?: string | null;
|
|
51
|
+
}
|
|
52
|
+
interface RoleListParams {
|
|
53
|
+
"filter[scope]"?: "all" | "global" | "org";
|
|
54
|
+
"filter[search]"?: string;
|
|
55
|
+
page?: number;
|
|
56
|
+
per_page?: number;
|
|
57
|
+
}
|
|
58
|
+
interface UpdateRoleInput {
|
|
59
|
+
name?: string;
|
|
60
|
+
level?: number;
|
|
61
|
+
description?: string | null;
|
|
62
|
+
}
|
|
63
|
+
interface SyncPermissionsInput {
|
|
64
|
+
permissions: (number | string)[];
|
|
65
|
+
}
|
|
66
|
+
interface SyncPermissionsResponse {
|
|
67
|
+
message: string;
|
|
68
|
+
attached: number;
|
|
69
|
+
detached: number;
|
|
70
|
+
}
|
|
71
|
+
declare function createRoleService(config: ServiceConfig): {
|
|
72
|
+
/**
|
|
73
|
+
* Get all roles
|
|
74
|
+
* GET /api/sso/roles
|
|
75
|
+
*/
|
|
76
|
+
list: () => Promise<{
|
|
77
|
+
data: Role[];
|
|
78
|
+
}>;
|
|
79
|
+
/**
|
|
80
|
+
* Get single role with permissions
|
|
81
|
+
* GET /api/sso/roles/{id}
|
|
82
|
+
*/
|
|
83
|
+
get: (id: number | string) => Promise<{
|
|
84
|
+
data: RoleWithPermissions;
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* List all roles (admin)
|
|
88
|
+
* GET /api/admin/sso/roles
|
|
89
|
+
*/
|
|
90
|
+
adminList: (orgId: string, params?: RoleListParams) => Promise<{
|
|
91
|
+
data: Role[];
|
|
92
|
+
}>;
|
|
93
|
+
/**
|
|
94
|
+
* Get single role (admin)
|
|
95
|
+
* GET /api/admin/sso/roles/{id}
|
|
96
|
+
*/
|
|
97
|
+
adminGet: (id: number | string, orgId: string) => Promise<{
|
|
98
|
+
data: RoleWithPermissions;
|
|
99
|
+
}>;
|
|
100
|
+
/**
|
|
101
|
+
* Create role (admin only)
|
|
102
|
+
* POST /api/admin/sso/roles
|
|
103
|
+
*/
|
|
104
|
+
create: (input: CreateRoleInput, orgId: string) => Promise<{
|
|
105
|
+
data: Role;
|
|
106
|
+
message: string;
|
|
107
|
+
}>;
|
|
108
|
+
/**
|
|
109
|
+
* Update role (admin only)
|
|
110
|
+
* PUT /api/admin/sso/roles/{id}
|
|
111
|
+
*/
|
|
112
|
+
update: (id: number | string, input: UpdateRoleInput, orgId: string) => Promise<{
|
|
113
|
+
data: Role;
|
|
114
|
+
message: string;
|
|
115
|
+
}>;
|
|
116
|
+
/**
|
|
117
|
+
* Delete role (admin only)
|
|
118
|
+
* DELETE /api/admin/sso/roles/{id}
|
|
119
|
+
*/
|
|
120
|
+
delete: (id: number | string, orgId: string) => Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Get role's permissions (admin)
|
|
123
|
+
* GET /api/admin/sso/roles/{id}/permissions
|
|
124
|
+
*/
|
|
125
|
+
getPermissions: (id: number | string, orgId: string) => Promise<{
|
|
126
|
+
role: Pick<Role, "id" | "slug" | "name">;
|
|
127
|
+
permissions: Permission[];
|
|
128
|
+
}>;
|
|
129
|
+
/**
|
|
130
|
+
* Sync role's permissions (admin)
|
|
131
|
+
* PUT /api/admin/sso/roles/{id}/permissions
|
|
132
|
+
*/
|
|
133
|
+
syncPermissions: (id: number | string, input: SyncPermissionsInput, orgId: string) => Promise<SyncPermissionsResponse>;
|
|
134
|
+
};
|
|
135
|
+
type RoleService = ReturnType<typeof createRoleService>;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* User Service - User Management for Admin Panel
|
|
139
|
+
*
|
|
140
|
+
* Provides user listing and permission retrieval for admin interface
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
interface User {
|
|
144
|
+
id: string;
|
|
145
|
+
email: string;
|
|
146
|
+
name: string;
|
|
147
|
+
email_verified_at?: string | null;
|
|
148
|
+
created_at: string;
|
|
149
|
+
updated_at: string;
|
|
150
|
+
}
|
|
151
|
+
interface UserWithOrg extends User {
|
|
152
|
+
console_org_id?: string;
|
|
153
|
+
organization?: {
|
|
154
|
+
id: string;
|
|
155
|
+
console_org_id: string;
|
|
156
|
+
name: string;
|
|
157
|
+
code: string;
|
|
158
|
+
} | null;
|
|
159
|
+
}
|
|
160
|
+
interface UserListParams {
|
|
161
|
+
"filter[search]"?: string;
|
|
162
|
+
"filter[org_id]"?: string;
|
|
163
|
+
page?: number;
|
|
164
|
+
per_page?: number;
|
|
165
|
+
}
|
|
166
|
+
interface UserListResponse {
|
|
167
|
+
data: User[];
|
|
168
|
+
meta?: {
|
|
169
|
+
current_page: number;
|
|
170
|
+
last_page: number;
|
|
171
|
+
per_page: number;
|
|
172
|
+
total: number;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
interface RoleAssignmentWithPermissions {
|
|
176
|
+
id: string | null;
|
|
177
|
+
role: {
|
|
178
|
+
id: string;
|
|
179
|
+
name: string;
|
|
180
|
+
slug: string;
|
|
181
|
+
level: number;
|
|
182
|
+
};
|
|
183
|
+
console_org_id: string | null;
|
|
184
|
+
console_branch_id: string | null;
|
|
185
|
+
org_name?: string | null;
|
|
186
|
+
branch_name?: string | null;
|
|
187
|
+
scope: "global" | "org-wide" | "branch";
|
|
188
|
+
permissions: Array<{
|
|
189
|
+
id: string;
|
|
190
|
+
name: string;
|
|
191
|
+
slug: string;
|
|
192
|
+
group: string;
|
|
193
|
+
}>;
|
|
194
|
+
}
|
|
195
|
+
interface TeamMembershipWithPermissions {
|
|
196
|
+
id: string;
|
|
197
|
+
team: {
|
|
198
|
+
id: string;
|
|
199
|
+
name: string;
|
|
200
|
+
path?: string;
|
|
201
|
+
};
|
|
202
|
+
is_leader?: boolean;
|
|
203
|
+
permissions: Array<{
|
|
204
|
+
id: string;
|
|
205
|
+
name: string;
|
|
206
|
+
slug: string;
|
|
207
|
+
group: string;
|
|
208
|
+
}>;
|
|
209
|
+
}
|
|
210
|
+
interface PermissionDetail {
|
|
211
|
+
id: string;
|
|
212
|
+
name: string;
|
|
213
|
+
slug: string;
|
|
214
|
+
group: string;
|
|
215
|
+
sources: Array<{
|
|
216
|
+
type: "role" | "team" | "direct";
|
|
217
|
+
name: string;
|
|
218
|
+
scope?: string;
|
|
219
|
+
}>;
|
|
220
|
+
}
|
|
221
|
+
interface UserPermissionsBreakdown {
|
|
222
|
+
user: {
|
|
223
|
+
id: string;
|
|
224
|
+
email: string;
|
|
225
|
+
name: string;
|
|
226
|
+
created_at?: string;
|
|
227
|
+
organization?: {
|
|
228
|
+
id: string;
|
|
229
|
+
console_org_id: string;
|
|
230
|
+
name: string;
|
|
231
|
+
code: string;
|
|
232
|
+
} | null;
|
|
233
|
+
};
|
|
234
|
+
context: {
|
|
235
|
+
org_id: string | null;
|
|
236
|
+
branch_id: string | null;
|
|
237
|
+
};
|
|
238
|
+
role_assignments: RoleAssignmentWithPermissions[];
|
|
239
|
+
team_memberships: TeamMembershipWithPermissions[];
|
|
240
|
+
direct_permissions: Array<{
|
|
241
|
+
id: string;
|
|
242
|
+
name: string;
|
|
243
|
+
slug: string;
|
|
244
|
+
group: string;
|
|
245
|
+
}>;
|
|
246
|
+
effective_permissions: PermissionDetail[];
|
|
247
|
+
aggregated_permissions: string[];
|
|
248
|
+
total_permissions: number;
|
|
249
|
+
}
|
|
250
|
+
declare function createUserService(config: ServiceConfig): {
|
|
251
|
+
/**
|
|
252
|
+
* List users with optional filters
|
|
253
|
+
* GET /api/admin/sso/users
|
|
254
|
+
*/
|
|
255
|
+
list: (params?: UserListParams, orgId?: string) => Promise<UserListResponse>;
|
|
256
|
+
/**
|
|
257
|
+
* Get single user by ID
|
|
258
|
+
* GET /api/admin/sso/users/{userId}
|
|
259
|
+
*/
|
|
260
|
+
get: (userId: string, orgId?: string) => Promise<User>;
|
|
261
|
+
/**
|
|
262
|
+
* Get user permissions breakdown for specific org/branch context
|
|
263
|
+
* GET /api/admin/sso/users/{userId}/permissions
|
|
264
|
+
*/
|
|
265
|
+
getPermissions: (userId: string, consoleOrgId?: string, branchId?: string, orgId?: string) => Promise<UserPermissionsBreakdown>;
|
|
266
|
+
};
|
|
267
|
+
type UserService = ReturnType<typeof createUserService>;
|
|
268
|
+
|
|
269
|
+
export { type CreateRoleInput as C, type Permission as P, type Role as R, type ServiceConfig as S, type TeamMembershipWithPermissions as T, type UpdateRoleInput as U, type PermissionDetail as a, type RoleAssignmentWithPermissions as b, type RoleService as c, type RoleWithPermissions as d, type SyncPermissionsInput as e, type SyncPermissionsResponse as f, type User as g, type UserListParams as h, type UserListResponse as i, type UserPermissionsBreakdown as j, type UserService as k, type UserWithOrg as l, createRoleService as m, createUserService as n, type RoleListParams as o };
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base service configuration
|
|
3
|
+
*/
|
|
4
|
+
interface ServiceConfig {
|
|
5
|
+
apiUrl: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Role Service - Role Management
|
|
10
|
+
*
|
|
11
|
+
* CRUD operations for roles and role-permission assignments
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
interface Role {
|
|
15
|
+
id: number;
|
|
16
|
+
name: string;
|
|
17
|
+
slug: string;
|
|
18
|
+
description: string | null;
|
|
19
|
+
level: number;
|
|
20
|
+
permissions_count?: number;
|
|
21
|
+
console_org_id?: string | null;
|
|
22
|
+
organization?: {
|
|
23
|
+
id: string;
|
|
24
|
+
console_org_id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
code: string;
|
|
27
|
+
} | null;
|
|
28
|
+
created_at: string;
|
|
29
|
+
updated_at: string;
|
|
30
|
+
}
|
|
31
|
+
interface Permission {
|
|
32
|
+
id: number;
|
|
33
|
+
name: string;
|
|
34
|
+
slug: string;
|
|
35
|
+
group: string | null;
|
|
36
|
+
description?: string | null;
|
|
37
|
+
roles_count?: number;
|
|
38
|
+
created_at: string;
|
|
39
|
+
updated_at: string;
|
|
40
|
+
}
|
|
41
|
+
interface RoleWithPermissions extends Role {
|
|
42
|
+
permissions: Permission[];
|
|
43
|
+
}
|
|
44
|
+
interface CreateRoleInput {
|
|
45
|
+
slug: string;
|
|
46
|
+
name: string;
|
|
47
|
+
level: number;
|
|
48
|
+
description?: string;
|
|
49
|
+
scope?: "global" | "org" | "org-wide" | "branch";
|
|
50
|
+
console_org_id?: string | null;
|
|
51
|
+
}
|
|
52
|
+
interface RoleListParams {
|
|
53
|
+
"filter[scope]"?: "all" | "global" | "org";
|
|
54
|
+
"filter[search]"?: string;
|
|
55
|
+
page?: number;
|
|
56
|
+
per_page?: number;
|
|
57
|
+
}
|
|
58
|
+
interface UpdateRoleInput {
|
|
59
|
+
name?: string;
|
|
60
|
+
level?: number;
|
|
61
|
+
description?: string | null;
|
|
62
|
+
}
|
|
63
|
+
interface SyncPermissionsInput {
|
|
64
|
+
permissions: (number | string)[];
|
|
65
|
+
}
|
|
66
|
+
interface SyncPermissionsResponse {
|
|
67
|
+
message: string;
|
|
68
|
+
attached: number;
|
|
69
|
+
detached: number;
|
|
70
|
+
}
|
|
71
|
+
declare function createRoleService(config: ServiceConfig): {
|
|
72
|
+
/**
|
|
73
|
+
* Get all roles
|
|
74
|
+
* GET /api/sso/roles
|
|
75
|
+
*/
|
|
76
|
+
list: () => Promise<{
|
|
77
|
+
data: Role[];
|
|
78
|
+
}>;
|
|
79
|
+
/**
|
|
80
|
+
* Get single role with permissions
|
|
81
|
+
* GET /api/sso/roles/{id}
|
|
82
|
+
*/
|
|
83
|
+
get: (id: number | string) => Promise<{
|
|
84
|
+
data: RoleWithPermissions;
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* List all roles (admin)
|
|
88
|
+
* GET /api/admin/sso/roles
|
|
89
|
+
*/
|
|
90
|
+
adminList: (orgId: string, params?: RoleListParams) => Promise<{
|
|
91
|
+
data: Role[];
|
|
92
|
+
}>;
|
|
93
|
+
/**
|
|
94
|
+
* Get single role (admin)
|
|
95
|
+
* GET /api/admin/sso/roles/{id}
|
|
96
|
+
*/
|
|
97
|
+
adminGet: (id: number | string, orgId: string) => Promise<{
|
|
98
|
+
data: RoleWithPermissions;
|
|
99
|
+
}>;
|
|
100
|
+
/**
|
|
101
|
+
* Create role (admin only)
|
|
102
|
+
* POST /api/admin/sso/roles
|
|
103
|
+
*/
|
|
104
|
+
create: (input: CreateRoleInput, orgId: string) => Promise<{
|
|
105
|
+
data: Role;
|
|
106
|
+
message: string;
|
|
107
|
+
}>;
|
|
108
|
+
/**
|
|
109
|
+
* Update role (admin only)
|
|
110
|
+
* PUT /api/admin/sso/roles/{id}
|
|
111
|
+
*/
|
|
112
|
+
update: (id: number | string, input: UpdateRoleInput, orgId: string) => Promise<{
|
|
113
|
+
data: Role;
|
|
114
|
+
message: string;
|
|
115
|
+
}>;
|
|
116
|
+
/**
|
|
117
|
+
* Delete role (admin only)
|
|
118
|
+
* DELETE /api/admin/sso/roles/{id}
|
|
119
|
+
*/
|
|
120
|
+
delete: (id: number | string, orgId: string) => Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Get role's permissions (admin)
|
|
123
|
+
* GET /api/admin/sso/roles/{id}/permissions
|
|
124
|
+
*/
|
|
125
|
+
getPermissions: (id: number | string, orgId: string) => Promise<{
|
|
126
|
+
role: Pick<Role, "id" | "slug" | "name">;
|
|
127
|
+
permissions: Permission[];
|
|
128
|
+
}>;
|
|
129
|
+
/**
|
|
130
|
+
* Sync role's permissions (admin)
|
|
131
|
+
* PUT /api/admin/sso/roles/{id}/permissions
|
|
132
|
+
*/
|
|
133
|
+
syncPermissions: (id: number | string, input: SyncPermissionsInput, orgId: string) => Promise<SyncPermissionsResponse>;
|
|
134
|
+
};
|
|
135
|
+
type RoleService = ReturnType<typeof createRoleService>;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* User Service - User Management for Admin Panel
|
|
139
|
+
*
|
|
140
|
+
* Provides user listing and permission retrieval for admin interface
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
interface User {
|
|
144
|
+
id: string;
|
|
145
|
+
email: string;
|
|
146
|
+
name: string;
|
|
147
|
+
email_verified_at?: string | null;
|
|
148
|
+
created_at: string;
|
|
149
|
+
updated_at: string;
|
|
150
|
+
}
|
|
151
|
+
interface UserWithOrg extends User {
|
|
152
|
+
console_org_id?: string;
|
|
153
|
+
organization?: {
|
|
154
|
+
id: string;
|
|
155
|
+
console_org_id: string;
|
|
156
|
+
name: string;
|
|
157
|
+
code: string;
|
|
158
|
+
} | null;
|
|
159
|
+
}
|
|
160
|
+
interface UserListParams {
|
|
161
|
+
"filter[search]"?: string;
|
|
162
|
+
"filter[org_id]"?: string;
|
|
163
|
+
page?: number;
|
|
164
|
+
per_page?: number;
|
|
165
|
+
}
|
|
166
|
+
interface UserListResponse {
|
|
167
|
+
data: User[];
|
|
168
|
+
meta?: {
|
|
169
|
+
current_page: number;
|
|
170
|
+
last_page: number;
|
|
171
|
+
per_page: number;
|
|
172
|
+
total: number;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
interface RoleAssignmentWithPermissions {
|
|
176
|
+
id: string | null;
|
|
177
|
+
role: {
|
|
178
|
+
id: string;
|
|
179
|
+
name: string;
|
|
180
|
+
slug: string;
|
|
181
|
+
level: number;
|
|
182
|
+
};
|
|
183
|
+
console_org_id: string | null;
|
|
184
|
+
console_branch_id: string | null;
|
|
185
|
+
org_name?: string | null;
|
|
186
|
+
branch_name?: string | null;
|
|
187
|
+
scope: "global" | "org-wide" | "branch";
|
|
188
|
+
permissions: Array<{
|
|
189
|
+
id: string;
|
|
190
|
+
name: string;
|
|
191
|
+
slug: string;
|
|
192
|
+
group: string;
|
|
193
|
+
}>;
|
|
194
|
+
}
|
|
195
|
+
interface TeamMembershipWithPermissions {
|
|
196
|
+
id: string;
|
|
197
|
+
team: {
|
|
198
|
+
id: string;
|
|
199
|
+
name: string;
|
|
200
|
+
path?: string;
|
|
201
|
+
};
|
|
202
|
+
is_leader?: boolean;
|
|
203
|
+
permissions: Array<{
|
|
204
|
+
id: string;
|
|
205
|
+
name: string;
|
|
206
|
+
slug: string;
|
|
207
|
+
group: string;
|
|
208
|
+
}>;
|
|
209
|
+
}
|
|
210
|
+
interface PermissionDetail {
|
|
211
|
+
id: string;
|
|
212
|
+
name: string;
|
|
213
|
+
slug: string;
|
|
214
|
+
group: string;
|
|
215
|
+
sources: Array<{
|
|
216
|
+
type: "role" | "team" | "direct";
|
|
217
|
+
name: string;
|
|
218
|
+
scope?: string;
|
|
219
|
+
}>;
|
|
220
|
+
}
|
|
221
|
+
interface UserPermissionsBreakdown {
|
|
222
|
+
user: {
|
|
223
|
+
id: string;
|
|
224
|
+
email: string;
|
|
225
|
+
name: string;
|
|
226
|
+
created_at?: string;
|
|
227
|
+
organization?: {
|
|
228
|
+
id: string;
|
|
229
|
+
console_org_id: string;
|
|
230
|
+
name: string;
|
|
231
|
+
code: string;
|
|
232
|
+
} | null;
|
|
233
|
+
};
|
|
234
|
+
context: {
|
|
235
|
+
org_id: string | null;
|
|
236
|
+
branch_id: string | null;
|
|
237
|
+
};
|
|
238
|
+
role_assignments: RoleAssignmentWithPermissions[];
|
|
239
|
+
team_memberships: TeamMembershipWithPermissions[];
|
|
240
|
+
direct_permissions: Array<{
|
|
241
|
+
id: string;
|
|
242
|
+
name: string;
|
|
243
|
+
slug: string;
|
|
244
|
+
group: string;
|
|
245
|
+
}>;
|
|
246
|
+
effective_permissions: PermissionDetail[];
|
|
247
|
+
aggregated_permissions: string[];
|
|
248
|
+
total_permissions: number;
|
|
249
|
+
}
|
|
250
|
+
declare function createUserService(config: ServiceConfig): {
|
|
251
|
+
/**
|
|
252
|
+
* List users with optional filters
|
|
253
|
+
* GET /api/admin/sso/users
|
|
254
|
+
*/
|
|
255
|
+
list: (params?: UserListParams, orgId?: string) => Promise<UserListResponse>;
|
|
256
|
+
/**
|
|
257
|
+
* Get single user by ID
|
|
258
|
+
* GET /api/admin/sso/users/{userId}
|
|
259
|
+
*/
|
|
260
|
+
get: (userId: string, orgId?: string) => Promise<User>;
|
|
261
|
+
/**
|
|
262
|
+
* Get user permissions breakdown for specific org/branch context
|
|
263
|
+
* GET /api/admin/sso/users/{userId}/permissions
|
|
264
|
+
*/
|
|
265
|
+
getPermissions: (userId: string, consoleOrgId?: string, branchId?: string, orgId?: string) => Promise<UserPermissionsBreakdown>;
|
|
266
|
+
};
|
|
267
|
+
type UserService = ReturnType<typeof createUserService>;
|
|
268
|
+
|
|
269
|
+
export { type CreateRoleInput as C, type Permission as P, type Role as R, type ServiceConfig as S, type TeamMembershipWithPermissions as T, type UpdateRoleInput as U, type PermissionDetail as a, type RoleAssignmentWithPermissions as b, type RoleService as c, type RoleWithPermissions as d, type SyncPermissionsInput as e, type SyncPermissionsResponse as f, type User as g, type UserListParams as h, type UserListResponse as i, type UserPermissionsBreakdown as j, type UserService as k, type UserWithOrg as l, createRoleService as m, createUserService as n, type RoleListParams as o };
|