@famgia/omnify-react-sso 2.2.1 → 2.2.3
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/README.md +404 -113
- package/dist/@omnify-base/schemas/Branch.ts +12 -12
- package/dist/@omnify-base/schemas/BranchCache.ts +131 -0
- package/dist/@omnify-base/schemas/OrganizationCache.ts +117 -0
- package/dist/@omnify-base/schemas/Permission.ts +10 -10
- package/dist/@omnify-base/schemas/Role.ts +19 -12
- package/dist/@omnify-base/schemas/RolePermission.ts +6 -6
- package/dist/@omnify-base/schemas/Team.ts +6 -6
- package/dist/@omnify-base/schemas/TeamCache.ts +110 -0
- package/dist/@omnify-base/schemas/TeamPermission.ts +6 -6
- package/dist/@omnify-base/schemas/User.ts +13 -13
- package/dist/@omnify-base/schemas/UserCache.ts +142 -0
- package/dist/index.cjs +1846 -427
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +623 -14
- package/dist/index.d.ts +623 -14
- package/dist/index.js +1790 -400
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.cjs +245 -167
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +67 -28
- package/dist/schemas/index.d.ts +67 -28
- package/dist/schemas/index.js +217 -146
- package/dist/schemas/index.js.map +1 -1
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/{types-BCBSfJJr.d.cts → types-bD5deLxs.d.cts} +102 -1
- package/dist/{types-BCBSfJJr.d.ts → types-bD5deLxs.d.ts} +102 -1
- package/package.json +121 -106
- package/scripts/build-schemas.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
export { DateString, DateTimeString,
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export { DateString, DateTimeString, LocaleMap, ValidationRule } from '@omnify-base/schemas/common';
|
|
2
|
+
export { fallbackLocale, getMessage, getMessages, supportedLocales, validationMessages } from '@omnify-base/schemas/i18n';
|
|
3
|
+
export { BranchCache, BranchCacheCreate, BranchCacheUpdate, OrganizationCache, OrganizationCacheCreate, OrganizationCacheUpdate, PermissionCreate, PermissionUpdate, RoleCreate, RolePermission, RolePermissionCreate, RolePermissionUpdate, RoleUpdate, TeamCache, TeamCacheCreate, TeamCacheUpdate, TeamPermission, TeamPermissionCreate, TeamPermissionUpdate, UserCache, UserCacheCreate, UserCacheUpdate, branchCacheCreateSchema, branchCacheSchemas, branchCacheUpdateSchema, organizationCacheCreateSchema, organizationCacheSchemas, organizationCacheUpdateSchema, permissionCreateSchema, permissionSchemas, permissionUpdateSchema, roleCreateSchema, rolePermissionCreateSchema, rolePermissionSchemas, rolePermissionUpdateSchema, roleSchemas, roleUpdateSchema, teamCacheCreateSchema, teamCacheSchemas, teamCacheUpdateSchema, teamPermissionCreateSchema, teamPermissionSchemas, teamPermissionUpdateSchema, userCacheCreateSchema, userCacheSchemas, userCacheUpdateSchema } from './schemas/index.js';
|
|
4
4
|
import * as react from 'react';
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import { ReactNode } from 'react';
|
|
6
|
+
import { b as SsoContextValue, c as SsoProviderProps, B as BranchContextValue, d as BranchProviderProps, S as SsoUser$2, a as SsoOrganization, e as SsoConfig, f as SsoCallbackProps, O as OrganizationSwitcherProps, P as ProtectedRouteProps, g as OrgBranchSelectorModalProps, h as BranchGateProps, i as BranchGateSelection } from './types-bD5deLxs.js';
|
|
7
|
+
export { j as OrgBranchSelection, k as SsoBranch, l as SsoCallbackResponse } from './types-bD5deLxs.js';
|
|
7
8
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
|
-
export {
|
|
9
|
+
export { branchCacheI18n, getBranchCacheFieldLabel, getBranchCacheFieldPlaceholder, getBranchCacheLabel } from '@omnify-base/schemas/BranchCache';
|
|
10
|
+
export { getOrganizationCacheFieldLabel, getOrganizationCacheFieldPlaceholder, getOrganizationCacheLabel, organizationCacheI18n } from '@omnify-base/schemas/OrganizationCache';
|
|
9
11
|
export { getPermissionFieldLabel, getPermissionFieldPlaceholder, getPermissionLabel, permissionI18n } from '@omnify-base/schemas/Permission';
|
|
10
12
|
export { getRoleFieldLabel, getRoleFieldPlaceholder, getRoleLabel, roleI18n } from '@omnify-base/schemas/Role';
|
|
11
13
|
export { getRolePermissionFieldLabel, getRolePermissionFieldPlaceholder, getRolePermissionLabel, rolePermissionI18n } from '@omnify-base/schemas/RolePermission';
|
|
12
|
-
export {
|
|
14
|
+
export { getTeamCacheFieldLabel, getTeamCacheFieldPlaceholder, getTeamCacheLabel, teamCacheI18n } from '@omnify-base/schemas/TeamCache';
|
|
13
15
|
export { getTeamPermissionFieldLabel, getTeamPermissionFieldPlaceholder, getTeamPermissionLabel, teamPermissionI18n } from '@omnify-base/schemas/TeamPermission';
|
|
14
|
-
export {
|
|
16
|
+
export { getUserCacheFieldLabel, getUserCacheFieldPlaceholder, getUserCacheLabel, userCacheI18n } from '@omnify-base/schemas/UserCache';
|
|
15
17
|
import 'zod';
|
|
16
18
|
|
|
17
19
|
/**
|
|
@@ -24,6 +26,38 @@ declare const SsoContext: react.Context<SsoContextValue | null>;
|
|
|
24
26
|
*/
|
|
25
27
|
declare function SsoProvider({ children, config, onAuthChange }: SsoProviderProps): react_jsx_runtime.JSX.Element;
|
|
26
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Branch Context
|
|
31
|
+
*
|
|
32
|
+
* Provides branch state management across the application.
|
|
33
|
+
* Must be used within a BranchProvider.
|
|
34
|
+
*/
|
|
35
|
+
declare const BranchContext: react.Context<BranchContextValue | null>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* BranchProvider component
|
|
39
|
+
*
|
|
40
|
+
* Provides branch state management for the application.
|
|
41
|
+
* Automatically fetches branches when organization changes.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* // In your app
|
|
46
|
+
* <SsoProvider config={ssoConfig}>
|
|
47
|
+
* <BranchProvider>
|
|
48
|
+
* <App />
|
|
49
|
+
* </BranchProvider>
|
|
50
|
+
* </SsoProvider>
|
|
51
|
+
*
|
|
52
|
+
* // In a component
|
|
53
|
+
* function MyComponent() {
|
|
54
|
+
* const { branches, currentBranch, switchBranch } = useBranch();
|
|
55
|
+
* // ...
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
declare function BranchProvider({ children, storage, storageKey, onBranchChange, }: BranchProviderProps): react_jsx_runtime.JSX.Element;
|
|
60
|
+
|
|
27
61
|
/**
|
|
28
62
|
* Hook for authentication actions and state
|
|
29
63
|
*/
|
|
@@ -163,6 +197,49 @@ interface UseSsoReturn {
|
|
|
163
197
|
*/
|
|
164
198
|
declare function useSso(): UseSsoReturn;
|
|
165
199
|
|
|
200
|
+
/**
|
|
201
|
+
* Hook return type for branch management
|
|
202
|
+
*/
|
|
203
|
+
type UseBranchReturn = BranchContextValue;
|
|
204
|
+
/**
|
|
205
|
+
* Hook for branch management
|
|
206
|
+
*
|
|
207
|
+
* Provides access to branch state and operations.
|
|
208
|
+
* Must be used within a BranchProvider.
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```tsx
|
|
212
|
+
* function BranchInfo() {
|
|
213
|
+
* const {
|
|
214
|
+
* branches,
|
|
215
|
+
* currentBranch,
|
|
216
|
+
* hasMultipleBranches,
|
|
217
|
+
* switchBranch
|
|
218
|
+
* } = useBranch();
|
|
219
|
+
*
|
|
220
|
+
* // Auto-selection logic is handled by the provider
|
|
221
|
+
* // - If only 1 branch: auto-selected
|
|
222
|
+
* // - If multiple: use saved preference or primary branch
|
|
223
|
+
*
|
|
224
|
+
* return (
|
|
225
|
+
* <div>
|
|
226
|
+
* <p>Current: {currentBranch?.name}</p>
|
|
227
|
+
* {hasMultipleBranches && (
|
|
228
|
+
* <select onChange={(e) => switchBranch(Number(e.target.value))}>
|
|
229
|
+
* {branches.map((branch) => (
|
|
230
|
+
* <option key={branch.id} value={branch.id}>
|
|
231
|
+
* {branch.name}
|
|
232
|
+
* </option>
|
|
233
|
+
* ))}
|
|
234
|
+
* </select>
|
|
235
|
+
* )}
|
|
236
|
+
* </div>
|
|
237
|
+
* );
|
|
238
|
+
* }
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
declare function useBranch(): UseBranchReturn;
|
|
242
|
+
|
|
166
243
|
/**
|
|
167
244
|
* SSO Callback component
|
|
168
245
|
*
|
|
@@ -241,6 +318,96 @@ declare function OrganizationSwitcher({ className, renderTrigger, renderOption,
|
|
|
241
318
|
*/
|
|
242
319
|
declare function ProtectedRoute({ children, fallback, loginFallback, requiredRole, requiredPermission, onAccessDenied, }: ProtectedRouteProps): react_jsx_runtime.JSX.Element;
|
|
243
320
|
|
|
321
|
+
/**
|
|
322
|
+
* Organization and Branch Selector Modal
|
|
323
|
+
*
|
|
324
|
+
* A modal component for selecting organization and branch.
|
|
325
|
+
* - If user has only one organization, it's auto-selected
|
|
326
|
+
* - If user has only one branch, it's auto-selected
|
|
327
|
+
* - Shows selection UI only when there are multiple options
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```tsx
|
|
331
|
+
* function CreateProjectButton() {
|
|
332
|
+
* const [modalOpen, setModalOpen] = useState(false);
|
|
333
|
+
*
|
|
334
|
+
* const handleConfirm = (orgId: number, branchId: number) => {
|
|
335
|
+
* // Create project with selected org and branch
|
|
336
|
+
* createProject({ organization_id: orgId, branch_id: branchId });
|
|
337
|
+
* setModalOpen(false);
|
|
338
|
+
* };
|
|
339
|
+
*
|
|
340
|
+
* return (
|
|
341
|
+
* <>
|
|
342
|
+
* <Button onClick={() => setModalOpen(true)}>
|
|
343
|
+
* Create Project
|
|
344
|
+
* </Button>
|
|
345
|
+
* <OrgBranchSelectorModal
|
|
346
|
+
* open={modalOpen}
|
|
347
|
+
* onClose={() => setModalOpen(false)}
|
|
348
|
+
* onConfirm={handleConfirm}
|
|
349
|
+
* />
|
|
350
|
+
* </>
|
|
351
|
+
* );
|
|
352
|
+
* }
|
|
353
|
+
* ```
|
|
354
|
+
*/
|
|
355
|
+
declare function OrgBranchSelectorModal({ open, onClose, onConfirm, title, requireBranch, loadingComponent, }: OrgBranchSelectorModalProps): react_jsx_runtime.JSX.Element;
|
|
356
|
+
|
|
357
|
+
type StoredSelection = {
|
|
358
|
+
orgId: string;
|
|
359
|
+
orgSlug: string;
|
|
360
|
+
orgName: string;
|
|
361
|
+
branchId: string;
|
|
362
|
+
branchName: string;
|
|
363
|
+
branchCode: string;
|
|
364
|
+
};
|
|
365
|
+
/**
|
|
366
|
+
* BranchGate - Ensures user has selected an org/branch before accessing the app.
|
|
367
|
+
*
|
|
368
|
+
* Different from OrgBranchSelectorModal:
|
|
369
|
+
* - OrgBranchSelectorModal: Modal for one-time selection (e.g., creating a project)
|
|
370
|
+
* - BranchGate: Gate that blocks app access until selection is made, persists globally
|
|
371
|
+
*
|
|
372
|
+
* Auto-selection behavior:
|
|
373
|
+
* - If user has only 1 org and 1 branch: auto-selects and allows access
|
|
374
|
+
* - If user has multiple options: shows selection modal first
|
|
375
|
+
* - Stores selection in localStorage for persistence
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* ```tsx
|
|
379
|
+
* // In your app layout
|
|
380
|
+
* function DashboardLayout({ children }) {
|
|
381
|
+
* return (
|
|
382
|
+
* <BranchGate
|
|
383
|
+
* onSelectionChange={(selection) => {
|
|
384
|
+
* // Set API headers globally
|
|
385
|
+
* api.defaults.headers['X-Branch-Id'] = selection.branchId;
|
|
386
|
+
* api.defaults.headers['X-Org-Id'] = selection.orgId;
|
|
387
|
+
* }}
|
|
388
|
+
* >
|
|
389
|
+
* {children}
|
|
390
|
+
* </BranchGate>
|
|
391
|
+
* );
|
|
392
|
+
* }
|
|
393
|
+
* ```
|
|
394
|
+
*/
|
|
395
|
+
declare function BranchGate({ children, onSelectionChange, storageKey, loadingComponent, title, description, }: BranchGateProps): react_jsx_runtime.JSX.Element;
|
|
396
|
+
declare function useBranchGate(storageKey?: string): {
|
|
397
|
+
selection: StoredSelection | null;
|
|
398
|
+
selectedOrg: {
|
|
399
|
+
id: string;
|
|
400
|
+
slug: string;
|
|
401
|
+
name: string;
|
|
402
|
+
} | null;
|
|
403
|
+
selectedBranch: {
|
|
404
|
+
id: string;
|
|
405
|
+
name: string;
|
|
406
|
+
code: string;
|
|
407
|
+
} | null;
|
|
408
|
+
clearSelection: () => void;
|
|
409
|
+
};
|
|
410
|
+
|
|
244
411
|
/**
|
|
245
412
|
* Base service configuration
|
|
246
413
|
*/
|
|
@@ -248,6 +415,400 @@ interface ServiceConfig {
|
|
|
248
415
|
apiUrl: string;
|
|
249
416
|
}
|
|
250
417
|
|
|
418
|
+
/**
|
|
419
|
+
* User Service - Admin User CRUD operations
|
|
420
|
+
*
|
|
421
|
+
* Provides user management functionality for admin users.
|
|
422
|
+
* Uses the /api/admin/sso/users endpoints.
|
|
423
|
+
*/
|
|
424
|
+
|
|
425
|
+
interface User {
|
|
426
|
+
id: string;
|
|
427
|
+
name: string;
|
|
428
|
+
email: string;
|
|
429
|
+
console_user_id?: string;
|
|
430
|
+
created_at?: string;
|
|
431
|
+
updated_at?: string;
|
|
432
|
+
}
|
|
433
|
+
interface UserListParams {
|
|
434
|
+
page?: number;
|
|
435
|
+
per_page?: number;
|
|
436
|
+
"filter[search]"?: string;
|
|
437
|
+
"filter[org_id]"?: string;
|
|
438
|
+
sort?: string;
|
|
439
|
+
}
|
|
440
|
+
interface UserListResponse {
|
|
441
|
+
data: User[];
|
|
442
|
+
links?: {
|
|
443
|
+
first?: string;
|
|
444
|
+
last?: string;
|
|
445
|
+
prev?: string | null;
|
|
446
|
+
next?: string | null;
|
|
447
|
+
};
|
|
448
|
+
meta: {
|
|
449
|
+
current_page: number;
|
|
450
|
+
from: number | null;
|
|
451
|
+
last_page: number;
|
|
452
|
+
per_page: number;
|
|
453
|
+
to: number | null;
|
|
454
|
+
total: number;
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
interface UpdateUserInput {
|
|
458
|
+
name?: string;
|
|
459
|
+
email?: string;
|
|
460
|
+
}
|
|
461
|
+
interface RoleAssignmentWithPermissions {
|
|
462
|
+
role: {
|
|
463
|
+
id: string;
|
|
464
|
+
name: string;
|
|
465
|
+
slug: string;
|
|
466
|
+
level: number;
|
|
467
|
+
};
|
|
468
|
+
scope: "global" | "org-wide" | "branch";
|
|
469
|
+
console_org_id: string | null;
|
|
470
|
+
console_branch_id: string | null;
|
|
471
|
+
org_name?: string | null;
|
|
472
|
+
branch_name?: string | null;
|
|
473
|
+
permissions: string[];
|
|
474
|
+
}
|
|
475
|
+
interface TeamMembershipWithPermissions {
|
|
476
|
+
team: {
|
|
477
|
+
id: string | number;
|
|
478
|
+
name: string;
|
|
479
|
+
path: string | null;
|
|
480
|
+
};
|
|
481
|
+
is_leader: boolean;
|
|
482
|
+
permissions: string[];
|
|
483
|
+
}
|
|
484
|
+
interface UserPermissionsBreakdown {
|
|
485
|
+
user: {
|
|
486
|
+
id: string;
|
|
487
|
+
name: string;
|
|
488
|
+
email: string;
|
|
489
|
+
console_org_id?: string | null;
|
|
490
|
+
organization?: {
|
|
491
|
+
id: string;
|
|
492
|
+
console_org_id: string;
|
|
493
|
+
name: string;
|
|
494
|
+
code: string;
|
|
495
|
+
} | null;
|
|
496
|
+
};
|
|
497
|
+
context: {
|
|
498
|
+
org_id: string | null;
|
|
499
|
+
branch_id: string | null;
|
|
500
|
+
};
|
|
501
|
+
role_assignments: RoleAssignmentWithPermissions[];
|
|
502
|
+
team_memberships: TeamMembershipWithPermissions[];
|
|
503
|
+
aggregated_permissions: string[];
|
|
504
|
+
}
|
|
505
|
+
interface UserService {
|
|
506
|
+
list(params?: UserListParams, orgSlug?: string): Promise<UserListResponse>;
|
|
507
|
+
get(id: string, orgSlug?: string): Promise<User>;
|
|
508
|
+
update(id: string, input: UpdateUserInput, orgSlug?: string): Promise<User>;
|
|
509
|
+
delete(id: string, orgSlug?: string): Promise<void>;
|
|
510
|
+
search(email: string, orgSlug?: string): Promise<User[]>;
|
|
511
|
+
getPermissions(userId: string, orgId?: string, branchId?: string, orgSlug?: string): Promise<UserPermissionsBreakdown>;
|
|
512
|
+
}
|
|
513
|
+
declare function createUserService(config: ServiceConfig): UserService;
|
|
514
|
+
|
|
515
|
+
interface UserTableProps {
|
|
516
|
+
users: User[];
|
|
517
|
+
loading?: boolean;
|
|
518
|
+
pagination?: UserListResponse["meta"];
|
|
519
|
+
sortField?: string;
|
|
520
|
+
sortOrder?: "asc" | "desc";
|
|
521
|
+
onPageChange?: (page: number, pageSize: number) => void;
|
|
522
|
+
onSortChange?: (field: string | undefined, order: "asc" | "desc" | undefined) => void;
|
|
523
|
+
onSearch?: (value: string) => void;
|
|
524
|
+
onEdit?: (user: User) => void;
|
|
525
|
+
onDelete?: (user: User) => void;
|
|
526
|
+
deleteLoading?: boolean;
|
|
527
|
+
showSearch?: boolean;
|
|
528
|
+
showActions?: boolean;
|
|
529
|
+
}
|
|
530
|
+
declare function UserTable({ users, loading, pagination, sortField, sortOrder, onPageChange, onSortChange, onSearch, onEdit, onDelete, deleteLoading, showSearch, showActions, }: UserTableProps): react_jsx_runtime.JSX.Element;
|
|
531
|
+
|
|
532
|
+
interface UserFormProps {
|
|
533
|
+
initialValues?: Partial<User>;
|
|
534
|
+
onSubmit: (values: UpdateUserInput) => void;
|
|
535
|
+
onCancel?: () => void;
|
|
536
|
+
loading?: boolean;
|
|
537
|
+
submitText?: string;
|
|
538
|
+
}
|
|
539
|
+
declare function UserForm({ initialValues, onSubmit, onCancel, loading, submitText, }: UserFormProps): react_jsx_runtime.JSX.Element;
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Default translations for SSO components
|
|
543
|
+
*
|
|
544
|
+
* Apps can override these by adding to their i18n resources under the "sso" namespace.
|
|
545
|
+
*/
|
|
546
|
+
declare const ssoNamespace = "sso";
|
|
547
|
+
declare const defaultTranslations: {
|
|
548
|
+
en: {
|
|
549
|
+
actions: string;
|
|
550
|
+
save: string;
|
|
551
|
+
cancel: string;
|
|
552
|
+
delete: string;
|
|
553
|
+
edit: string;
|
|
554
|
+
search: string;
|
|
555
|
+
loading: string;
|
|
556
|
+
yes: string;
|
|
557
|
+
no: string;
|
|
558
|
+
confirmDelete: string;
|
|
559
|
+
users: string;
|
|
560
|
+
user: string;
|
|
561
|
+
name: string;
|
|
562
|
+
email: string;
|
|
563
|
+
ssoUser: string;
|
|
564
|
+
localUser: string;
|
|
565
|
+
userList: string;
|
|
566
|
+
userDetails: string;
|
|
567
|
+
editUser: string;
|
|
568
|
+
deleteUser: string;
|
|
569
|
+
searchUsers: string;
|
|
570
|
+
noUsersFound: string;
|
|
571
|
+
userDeleted: string;
|
|
572
|
+
userUpdated: string;
|
|
573
|
+
roles: string;
|
|
574
|
+
role: string;
|
|
575
|
+
roleName: string;
|
|
576
|
+
roleDescription: string;
|
|
577
|
+
permissions: string;
|
|
578
|
+
assignRole: string;
|
|
579
|
+
removeRole: string;
|
|
580
|
+
permission: string;
|
|
581
|
+
permissionName: string;
|
|
582
|
+
permissionDescription: string;
|
|
583
|
+
required: string;
|
|
584
|
+
maxLength: string;
|
|
585
|
+
invalidEmail: string;
|
|
586
|
+
total: string;
|
|
587
|
+
page: string;
|
|
588
|
+
};
|
|
589
|
+
ja: {
|
|
590
|
+
actions: string;
|
|
591
|
+
save: string;
|
|
592
|
+
cancel: string;
|
|
593
|
+
delete: string;
|
|
594
|
+
edit: string;
|
|
595
|
+
search: string;
|
|
596
|
+
loading: string;
|
|
597
|
+
yes: string;
|
|
598
|
+
no: string;
|
|
599
|
+
confirmDelete: string;
|
|
600
|
+
users: string;
|
|
601
|
+
user: string;
|
|
602
|
+
name: string;
|
|
603
|
+
email: string;
|
|
604
|
+
ssoUser: string;
|
|
605
|
+
localUser: string;
|
|
606
|
+
userList: string;
|
|
607
|
+
userDetails: string;
|
|
608
|
+
editUser: string;
|
|
609
|
+
deleteUser: string;
|
|
610
|
+
searchUsers: string;
|
|
611
|
+
noUsersFound: string;
|
|
612
|
+
userDeleted: string;
|
|
613
|
+
userUpdated: string;
|
|
614
|
+
roles: string;
|
|
615
|
+
role: string;
|
|
616
|
+
roleName: string;
|
|
617
|
+
roleDescription: string;
|
|
618
|
+
permissions: string;
|
|
619
|
+
assignRole: string;
|
|
620
|
+
removeRole: string;
|
|
621
|
+
permission: string;
|
|
622
|
+
permissionName: string;
|
|
623
|
+
permissionDescription: string;
|
|
624
|
+
required: string;
|
|
625
|
+
maxLength: string;
|
|
626
|
+
invalidEmail: string;
|
|
627
|
+
total: string;
|
|
628
|
+
page: string;
|
|
629
|
+
};
|
|
630
|
+
vi: {
|
|
631
|
+
actions: string;
|
|
632
|
+
save: string;
|
|
633
|
+
cancel: string;
|
|
634
|
+
delete: string;
|
|
635
|
+
edit: string;
|
|
636
|
+
search: string;
|
|
637
|
+
loading: string;
|
|
638
|
+
yes: string;
|
|
639
|
+
no: string;
|
|
640
|
+
confirmDelete: string;
|
|
641
|
+
users: string;
|
|
642
|
+
user: string;
|
|
643
|
+
name: string;
|
|
644
|
+
email: string;
|
|
645
|
+
ssoUser: string;
|
|
646
|
+
localUser: string;
|
|
647
|
+
userList: string;
|
|
648
|
+
userDetails: string;
|
|
649
|
+
editUser: string;
|
|
650
|
+
deleteUser: string;
|
|
651
|
+
searchUsers: string;
|
|
652
|
+
noUsersFound: string;
|
|
653
|
+
userDeleted: string;
|
|
654
|
+
userUpdated: string;
|
|
655
|
+
roles: string;
|
|
656
|
+
role: string;
|
|
657
|
+
roleName: string;
|
|
658
|
+
roleDescription: string;
|
|
659
|
+
permissions: string;
|
|
660
|
+
assignRole: string;
|
|
661
|
+
removeRole: string;
|
|
662
|
+
permission: string;
|
|
663
|
+
permissionName: string;
|
|
664
|
+
permissionDescription: string;
|
|
665
|
+
required: string;
|
|
666
|
+
maxLength: string;
|
|
667
|
+
invalidEmail: string;
|
|
668
|
+
total: string;
|
|
669
|
+
page: string;
|
|
670
|
+
};
|
|
671
|
+
};
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Hook for SSO translations using react-i18next
|
|
675
|
+
*
|
|
676
|
+
* Falls back to English if translation not found.
|
|
677
|
+
* Apps should initialize i18next and add SSO translations to their resources.
|
|
678
|
+
*/
|
|
679
|
+
|
|
680
|
+
type TranslationKey = keyof typeof defaultTranslations.en;
|
|
681
|
+
/**
|
|
682
|
+
* Hook for SSO component translations
|
|
683
|
+
*
|
|
684
|
+
* Falls back to English if react-i18next is not available or translation not found.
|
|
685
|
+
*
|
|
686
|
+
* @example
|
|
687
|
+
* const { t } = useSsoTranslation();
|
|
688
|
+
* <span>{t("users")}</span>
|
|
689
|
+
* <span>{t("required", { field: t("email") })}</span>
|
|
690
|
+
*/
|
|
691
|
+
declare function useSsoTranslation(): {
|
|
692
|
+
t: (key: TranslationKey, options?: Record<string, unknown>) => string;
|
|
693
|
+
};
|
|
694
|
+
|
|
695
|
+
type TranslationMessages = Record<string, any>;
|
|
696
|
+
interface I18nProviderProps {
|
|
697
|
+
children: ReactNode;
|
|
698
|
+
/** App-specific translations for each locale */
|
|
699
|
+
translations?: {
|
|
700
|
+
en?: TranslationMessages;
|
|
701
|
+
ja?: TranslationMessages;
|
|
702
|
+
vi?: TranslationMessages;
|
|
703
|
+
};
|
|
704
|
+
/** Default locale (defaults to "ja") */
|
|
705
|
+
fallbackLocale?: string;
|
|
706
|
+
}
|
|
707
|
+
declare function I18nProvider({ children, translations, fallbackLocale }: I18nProviderProps): react_jsx_runtime.JSX.Element;
|
|
708
|
+
|
|
709
|
+
type TranslationValues = Record<string, string | number>;
|
|
710
|
+
/**
|
|
711
|
+
* Hook that mimics next-intl's useTranslations API
|
|
712
|
+
*
|
|
713
|
+
* @example
|
|
714
|
+
* // Without namespace (uses default "translation" namespace)
|
|
715
|
+
* const t = useTranslations();
|
|
716
|
+
* t("common.save") // "Save"
|
|
717
|
+
*
|
|
718
|
+
* // With namespace prefix
|
|
719
|
+
* const t = useTranslations("auth");
|
|
720
|
+
* t("login") // accesses "auth.login"
|
|
721
|
+
*/
|
|
722
|
+
declare function useTranslations(namespace?: string): (key: string, values?: TranslationValues) => string;
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* i18n configuration constants
|
|
726
|
+
*/
|
|
727
|
+
declare const locales: readonly ["ja", "en", "vi"];
|
|
728
|
+
type Locale = (typeof locales)[number];
|
|
729
|
+
declare const defaultLocale: Locale;
|
|
730
|
+
declare const localeNames: Record<Locale, string>;
|
|
731
|
+
declare const changeLanguage: (locale: Locale) => void;
|
|
732
|
+
declare const getCurrentLocale: () => Locale;
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Hook to get the current locale
|
|
736
|
+
* This provides the same API as next-intl's useLocale()
|
|
737
|
+
*/
|
|
738
|
+
declare function useLocale(): Locale;
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Branch header utilities for API clients
|
|
742
|
+
*
|
|
743
|
+
* These utilities help set branch context headers on axios instances.
|
|
744
|
+
* Works with BranchGate's onSelectionChange callback.
|
|
745
|
+
*
|
|
746
|
+
* @example
|
|
747
|
+
* ```typescript
|
|
748
|
+
* import { createBranchHeaderSetter } from '@famgia/omnify-react-sso';
|
|
749
|
+
* import api from './api'; // your axios instance
|
|
750
|
+
*
|
|
751
|
+
* // Create setter for your axios instance
|
|
752
|
+
* const setBranchHeaders = createBranchHeaderSetter(api);
|
|
753
|
+
*
|
|
754
|
+
* // Use in BranchGate
|
|
755
|
+
* <BranchGate onSelectionChange={setBranchHeaders}>
|
|
756
|
+
* <App />
|
|
757
|
+
* </BranchGate>
|
|
758
|
+
* ```
|
|
759
|
+
*/
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* Headers set by branch selection
|
|
763
|
+
*/
|
|
764
|
+
declare const BRANCH_HEADERS: {
|
|
765
|
+
readonly BRANCH_ID: "X-Branch-Id";
|
|
766
|
+
readonly ORG_ID: "X-Org-Id";
|
|
767
|
+
readonly BRANCH_NAME: "X-Branch-Name";
|
|
768
|
+
readonly BRANCH_CODE: "X-Branch-Code";
|
|
769
|
+
};
|
|
770
|
+
/**
|
|
771
|
+
* Minimal axios-like interface for header management
|
|
772
|
+
*/
|
|
773
|
+
interface AxiosLike {
|
|
774
|
+
defaults: {
|
|
775
|
+
headers: {
|
|
776
|
+
common: Record<string, string | undefined>;
|
|
777
|
+
};
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Create a branch header setter function for an axios instance
|
|
782
|
+
*
|
|
783
|
+
* @param axiosInstance - Your axios instance
|
|
784
|
+
* @returns A function to pass to BranchGate's onSelectionChange
|
|
785
|
+
*
|
|
786
|
+
* @example
|
|
787
|
+
* ```typescript
|
|
788
|
+
* const setBranchHeaders = createBranchHeaderSetter(api);
|
|
789
|
+
*
|
|
790
|
+
* <BranchGate onSelectionChange={setBranchHeaders}>
|
|
791
|
+
* <App />
|
|
792
|
+
* </BranchGate>
|
|
793
|
+
* ```
|
|
794
|
+
*/
|
|
795
|
+
declare function createBranchHeaderSetter(axiosInstance: AxiosLike): (selection: BranchGateSelection | null) => void;
|
|
796
|
+
/**
|
|
797
|
+
* Set branch headers directly on an axios instance
|
|
798
|
+
*
|
|
799
|
+
* @example
|
|
800
|
+
* ```typescript
|
|
801
|
+
* import api from './api';
|
|
802
|
+
* import { setBranchHeaders } from '@famgia/omnify-react-sso';
|
|
803
|
+
*
|
|
804
|
+
* // In BranchGate onSelectionChange
|
|
805
|
+
* <BranchGate onSelectionChange={(s) => setBranchHeaders(api, s)}>
|
|
806
|
+
* <App />
|
|
807
|
+
* </BranchGate>
|
|
808
|
+
* ```
|
|
809
|
+
*/
|
|
810
|
+
declare function setBranchHeaders(axiosInstance: AxiosLike, selection: BranchGateSelection | null): void;
|
|
811
|
+
|
|
251
812
|
/**
|
|
252
813
|
* Auth Service - SSO Authentication
|
|
253
814
|
*
|
|
@@ -353,17 +914,24 @@ type TokenService = ReturnType<typeof createTokenService>;
|
|
|
353
914
|
*/
|
|
354
915
|
|
|
355
916
|
interface Role$1 {
|
|
356
|
-
id:
|
|
917
|
+
id: string;
|
|
357
918
|
name: string;
|
|
358
919
|
slug: string;
|
|
359
920
|
description: string | null;
|
|
360
921
|
level: number;
|
|
922
|
+
console_org_id?: string | null;
|
|
361
923
|
permissions_count?: number;
|
|
924
|
+
organization?: {
|
|
925
|
+
id: string;
|
|
926
|
+
console_org_id: string;
|
|
927
|
+
name: string;
|
|
928
|
+
code: string;
|
|
929
|
+
} | null;
|
|
362
930
|
created_at: string;
|
|
363
931
|
updated_at: string;
|
|
364
932
|
}
|
|
365
933
|
interface Permission$1 {
|
|
366
|
-
id:
|
|
934
|
+
id: string;
|
|
367
935
|
name: string;
|
|
368
936
|
slug: string;
|
|
369
937
|
group: string | null;
|
|
@@ -380,6 +948,12 @@ interface CreateRoleInput$1 {
|
|
|
380
948
|
name: string;
|
|
381
949
|
level: number;
|
|
382
950
|
description?: string;
|
|
951
|
+
scope?: 'global' | 'org';
|
|
952
|
+
console_org_id?: string | null;
|
|
953
|
+
}
|
|
954
|
+
interface RoleListParams {
|
|
955
|
+
'filter[scope]'?: 'global' | 'org' | 'all';
|
|
956
|
+
'filter[org_id]'?: string;
|
|
383
957
|
}
|
|
384
958
|
interface UpdateRoleInput$1 {
|
|
385
959
|
name?: string;
|
|
@@ -413,7 +987,7 @@ declare function createRoleService(config: ServiceConfig): {
|
|
|
413
987
|
* List all roles (admin)
|
|
414
988
|
* GET /api/admin/sso/roles
|
|
415
989
|
*/
|
|
416
|
-
adminList: (orgSlug: string) => Promise<{
|
|
990
|
+
adminList: (orgSlug: string, params?: RoleListParams) => Promise<{
|
|
417
991
|
data: Role$1[];
|
|
418
992
|
}>;
|
|
419
993
|
/**
|
|
@@ -798,17 +1372,18 @@ interface Organization {
|
|
|
798
1372
|
role: string;
|
|
799
1373
|
}
|
|
800
1374
|
interface Role {
|
|
801
|
-
id:
|
|
1375
|
+
id: string;
|
|
802
1376
|
name: string;
|
|
803
1377
|
slug: string;
|
|
804
1378
|
description: string | null;
|
|
805
1379
|
level: number;
|
|
1380
|
+
console_org_id?: string | null;
|
|
806
1381
|
permissions_count?: number;
|
|
807
1382
|
created_at: string;
|
|
808
1383
|
updated_at: string;
|
|
809
1384
|
}
|
|
810
1385
|
interface Permission {
|
|
811
|
-
id:
|
|
1386
|
+
id: string;
|
|
812
1387
|
name: string;
|
|
813
1388
|
slug: string;
|
|
814
1389
|
group: string | null;
|
|
@@ -1169,6 +1744,23 @@ declare const ssoQueryKeys: {
|
|
|
1169
1744
|
readonly list: (userId: string) => readonly ["sso", "user-roles", string];
|
|
1170
1745
|
readonly byBranch: (userId: string, orgId: string, branchId: string | null) => readonly ["sso", "user-roles", string, string, string | null];
|
|
1171
1746
|
};
|
|
1747
|
+
readonly users: {
|
|
1748
|
+
readonly all: () => readonly ["sso", "users"];
|
|
1749
|
+
readonly list: (params?: {
|
|
1750
|
+
page?: number;
|
|
1751
|
+
per_page?: number;
|
|
1752
|
+
search?: string;
|
|
1753
|
+
sort?: string;
|
|
1754
|
+
order?: string;
|
|
1755
|
+
}) => readonly ["sso", "users", "list", {
|
|
1756
|
+
page?: number;
|
|
1757
|
+
per_page?: number;
|
|
1758
|
+
search?: string;
|
|
1759
|
+
sort?: string;
|
|
1760
|
+
order?: string;
|
|
1761
|
+
} | undefined];
|
|
1762
|
+
readonly detail: (id: number | string) => readonly ["sso", "users", "detail", string | number];
|
|
1763
|
+
};
|
|
1172
1764
|
readonly branches: {
|
|
1173
1765
|
readonly all: () => readonly ["sso", "branches"];
|
|
1174
1766
|
readonly list: (orgSlug?: string) => readonly ["sso", "branches", "list", string | undefined];
|
|
@@ -1177,6 +1769,23 @@ declare const ssoQueryKeys: {
|
|
|
1177
1769
|
readonly primary: (orgSlug?: string) => readonly ["sso", "branches", "primary", string | undefined];
|
|
1178
1770
|
};
|
|
1179
1771
|
readonly admin: {
|
|
1772
|
+
readonly users: {
|
|
1773
|
+
readonly all: (orgSlug: string) => readonly ["sso", "admin", string, "users"];
|
|
1774
|
+
readonly list: (orgSlug: string, params?: {
|
|
1775
|
+
page?: number;
|
|
1776
|
+
per_page?: number;
|
|
1777
|
+
search?: string;
|
|
1778
|
+
sort?: string;
|
|
1779
|
+
order?: string;
|
|
1780
|
+
}) => readonly ["sso", "admin", string, "users", "list", {
|
|
1781
|
+
page?: number;
|
|
1782
|
+
per_page?: number;
|
|
1783
|
+
search?: string;
|
|
1784
|
+
sort?: string;
|
|
1785
|
+
order?: string;
|
|
1786
|
+
} | undefined];
|
|
1787
|
+
readonly detail: (orgSlug: string, id: number | string) => readonly ["sso", "admin", string, "users", "detail", string | number];
|
|
1788
|
+
};
|
|
1180
1789
|
readonly roles: {
|
|
1181
1790
|
readonly all: (orgSlug: string) => readonly ["sso", "admin", string, "roles"];
|
|
1182
1791
|
readonly list: (orgSlug: string) => readonly ["sso", "admin", string, "roles", "list"];
|
|
@@ -1211,4 +1820,4 @@ declare const ssoQueryKeys: {
|
|
|
1211
1820
|
};
|
|
1212
1821
|
};
|
|
1213
1822
|
|
|
1214
|
-
export { type ApiToken$1 as ApiToken, type AssignRoleInput, type AssignRoleResponse, type AuthCallbackInput, type AuthCallbackResponse, type AuthService, type SsoUser$1 as AuthUser, type AuthUserResponse, type Branch, type BranchService, type BranchesResponse, type CleanupOrphanedInput$1 as CleanupOrphanedInput, type CreatePermissionInput$1 as CreatePermissionInput, type CreateRoleInput$1 as CreateRoleInput, type Organization$1 as Organization, OrganizationSwitcher, OrganizationSwitcherProps, type OrphanedTeam$1 as OrphanedTeam, type Permission$1 as Permission, type PermissionListParams, type PermissionMatrix$1 as PermissionMatrix, type PermissionService, ProtectedRoute, ProtectedRouteProps, type RemoveRoleResponse, type Role$1 as Role, type RoleAssignment, type RoleScope, type RoleService, type RoleWithPermissions$1 as RoleWithPermissions, type ServiceConfig, type Permission$1 as ServicePermission, type Role$1 as ServiceRole, SsoCallback, SsoCallbackProps, SsoConfig, SsoContext, SsoContextValue, SsoOrganization, SsoProvider, SsoProviderProps, type SsoService, type SsoServiceConfig, type SsoUser$1 as SsoServiceUser, SsoUser$2 as SsoUser, type SyncPermissionsInput$1 as SyncPermissionsInput, type SyncPermissionsResponse, type SyncRolesInput, type SyncRolesResponse, type SyncTeamPermissionsInput, type TeamPermissionDetail$1 as TeamPermissionDetail, type TeamService, type TeamWithPermissions$1 as TeamWithPermissions, type TokenService, type UpdatePermissionInput$1 as UpdatePermissionInput, type UpdateRoleInput$1 as UpdateRoleInput, type UseAuthReturn, type UseOrganizationReturn, type UseSsoReturn, type UserRoleService, createAuthService, createBranchService, createPermissionService, createRoleService, createSsoService, createTeamService, createTokenService, createUserRoleService, getEffectivePermissions, getScopeLabel, ssoQueryKeys, useAuth, useOrganization, useSso };
|
|
1823
|
+
export { type ApiToken$1 as ApiToken, type AssignRoleInput, type AssignRoleResponse, type AuthCallbackInput, type AuthCallbackResponse, type AuthService, type SsoUser$1 as AuthUser, type AuthUserResponse, BRANCH_HEADERS, type Branch, BranchContext, BranchContextValue, BranchGate, BranchGateProps, BranchGateSelection, BranchProvider, BranchProviderProps, type BranchService, type BranchesResponse, type CleanupOrphanedInput$1 as CleanupOrphanedInput, type CreatePermissionInput$1 as CreatePermissionInput, type CreateRoleInput$1 as CreateRoleInput, I18nProvider, type I18nProviderProps, type Locale, OrgBranchSelectorModal, OrgBranchSelectorModalProps, type Organization$1 as Organization, OrganizationSwitcher, OrganizationSwitcherProps, type OrphanedTeam$1 as OrphanedTeam, type Permission$1 as Permission, type PermissionListParams, type PermissionMatrix$1 as PermissionMatrix, type PermissionService, ProtectedRoute, ProtectedRouteProps, type RemoveRoleResponse, type Role$1 as Role, type RoleAssignment, type RoleAssignmentWithPermissions, type RoleScope, type RoleService, type RoleWithPermissions$1 as RoleWithPermissions, type ServiceConfig, type Permission$1 as ServicePermission, type Role$1 as ServiceRole, SsoCallback, SsoCallbackProps, SsoConfig, SsoContext, SsoContextValue, SsoOrganization, SsoProvider, SsoProviderProps, type SsoService, type SsoServiceConfig, type SsoUser$1 as SsoServiceUser, SsoUser$2 as SsoUser, type SyncPermissionsInput$1 as SyncPermissionsInput, type SyncPermissionsResponse, type SyncRolesInput, type SyncRolesResponse, type SyncTeamPermissionsInput, type TeamMembershipWithPermissions, type TeamPermissionDetail$1 as TeamPermissionDetail, type TeamService, type TeamWithPermissions$1 as TeamWithPermissions, type TokenService, type UpdatePermissionInput$1 as UpdatePermissionInput, type UpdateRoleInput$1 as UpdateRoleInput, type UpdateUserInput, type UseAuthReturn, type UseBranchReturn, type UseOrganizationReturn, type UseSsoReturn, type User, UserForm, type UserFormProps, type UserListParams, type UserListResponse, type UserPermissionsBreakdown, type UserRoleService, type UserService, UserTable, type UserTableProps, changeLanguage, createAuthService, createBranchHeaderSetter, createBranchService, createPermissionService, createRoleService, createSsoService, createTeamService, createTokenService, createUserRoleService, createUserService, defaultLocale, defaultTranslations, getCurrentLocale, getEffectivePermissions, getScopeLabel, localeNames, locales, setBranchHeaders, ssoNamespace, ssoQueryKeys, useAuth, useBranch, useBranchGate, useLocale, useOrganization, useSso, useSsoTranslation, useTranslations };
|