@flusys/ng-auth 0.1.0-alpha.1

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.
@@ -0,0 +1,1594 @@
1
+ import { IMessageResponse, ApiResourceService, ISingleResponse, IUserProvider, IListResponse, IUserBasicInfo, ICompanyApiProvider, ICompanyBasicInfo, IUserPermissionProvider } from '@flusys/ng-shared';
2
+ import * as rxjs from 'rxjs';
3
+ import { Observable } from 'rxjs';
4
+ import * as _angular_core from '@angular/core';
5
+ import { Signal, Provider, OnInit } from '@angular/core';
6
+ import { HttpClient, HttpRequest, HttpHandlerFn, HttpEvent } from '@angular/common/http';
7
+ import { CanActivateFn, Routes } from '@angular/router';
8
+ import { ILayoutAuthState, ICompanyInfo as ICompanyInfo$1, IBranchInfo as IBranchInfo$1, IUserInfo as IUserInfo$1, ILayoutAuthApi } from '@flusys/ng-layout';
9
+ import * as _angular_forms_signals from '@angular/forms/signals';
10
+ import * as _flusys_ng_auth from '@flusys/ng-auth';
11
+
12
+ /**
13
+ * Login Request Interface
14
+ */
15
+ interface ILoginRequest {
16
+ email: string;
17
+ password: string;
18
+ }
19
+ /**
20
+ * Registration Request Interface
21
+ * Supports both simple registration and company-based registration
22
+ */
23
+ interface IRegistrationRequest {
24
+ name: string;
25
+ email: string;
26
+ password: string;
27
+ phone?: string;
28
+ companySlug?: string;
29
+ branchSlug?: string;
30
+ newCompanyName?: string;
31
+ newCompanyPhone?: string;
32
+ newCompanyAddress?: string;
33
+ }
34
+ /**
35
+ * Select Company & Branch Request Interface
36
+ * Used after login when user needs to select company and branch
37
+ */
38
+ interface ISelectRequest {
39
+ sessionId: string;
40
+ companyId: string;
41
+ branchId: string;
42
+ }
43
+ /**
44
+ * Switch Company Request Interface
45
+ * Used to switch company/branch after login
46
+ */
47
+ interface ISwitchCompanyRequest {
48
+ companyId: string;
49
+ branchId: string;
50
+ }
51
+ /**
52
+ * Change Password Request Interface
53
+ */
54
+ interface IChangePasswordRequest {
55
+ currentPassword: string;
56
+ newPassword: string;
57
+ }
58
+ /**
59
+ * User Info Interface (used in responses)
60
+ */
61
+ interface IUserInfo {
62
+ id: string;
63
+ email: string;
64
+ name?: string;
65
+ profilePictureId?: string | null;
66
+ companyId?: string;
67
+ branchId?: string;
68
+ companyLogoId?: string;
69
+ branchLogoId?: string;
70
+ }
71
+ /**
72
+ * Company Info Interface (used in responses)
73
+ */
74
+ interface ICompanyInfo {
75
+ id: string;
76
+ name: string;
77
+ slug?: string;
78
+ logoId?: string | null;
79
+ }
80
+ /**
81
+ * Branch Info Interface (used in responses)
82
+ */
83
+ interface IBranchInfo {
84
+ id: string;
85
+ name: string;
86
+ slug?: string;
87
+ logoId?: string | null;
88
+ }
89
+ /**
90
+ * Branch Selection Info Interface (with additional fields)
91
+ */
92
+ interface IBranchSelectionInfo {
93
+ id: string;
94
+ name: string;
95
+ slug: string;
96
+ isActive: boolean;
97
+ logoId?: string | null;
98
+ }
99
+ /**
100
+ * Company with Branches Interface (for selection response)
101
+ */
102
+ interface ICompanyWithBranches {
103
+ id: string;
104
+ name: string;
105
+ slug: string;
106
+ isActive: boolean;
107
+ logoId?: string | null;
108
+ branches: IBranchSelectionInfo[];
109
+ }
110
+ /**
111
+ * Login Response Interface
112
+ * Returned on successful login with tokens
113
+ */
114
+ interface ILoginResponse {
115
+ accessToken: string;
116
+ refreshToken: string;
117
+ user: IUserInfo;
118
+ company?: ICompanyInfo;
119
+ branch?: IBranchInfo;
120
+ companyFeatureEnabled?: boolean;
121
+ }
122
+ /**
123
+ * Me Response Interface
124
+ * Returned by GET /auth/me endpoint
125
+ * Contains only user data, no tokens
126
+ */
127
+ interface IMeResponse {
128
+ user: IUserInfo;
129
+ company?: ICompanyInfo;
130
+ branch?: IBranchInfo;
131
+ }
132
+ /**
133
+ * Registration Response Interface
134
+ * Returned on successful registration
135
+ */
136
+ interface IRegistrationResponse {
137
+ accessToken: string;
138
+ refreshToken: string;
139
+ user: IUserInfo;
140
+ company?: ICompanyInfo;
141
+ branch?: IBranchInfo;
142
+ companyFeatureEnabled?: boolean;
143
+ }
144
+ /**
145
+ * Company Selection Response Interface
146
+ * Returned when user has multiple companies/branches to choose from
147
+ */
148
+ interface ICompanySelectionResponse {
149
+ requiresSelection: true;
150
+ sessionId: string;
151
+ expiresAt: Date | string;
152
+ user: IUserInfo;
153
+ companies: ICompanyWithBranches[];
154
+ }
155
+ /**
156
+ * Refresh Token Response Interface
157
+ */
158
+ interface IRefreshTokenResponse {
159
+ accessToken: string;
160
+ refreshToken?: string;
161
+ }
162
+ /**
163
+ * Auth Response Type - Can be login success or company selection required
164
+ */
165
+ type AuthResponse = ILoginResponse | ICompanySelectionResponse;
166
+ /**
167
+ * Type guard to check if response requires company selection
168
+ */
169
+ declare function isCompanySelectionResponse(response: AuthResponse): response is ICompanySelectionResponse;
170
+ /**
171
+ * Type guard to check if response is a successful login
172
+ */
173
+ declare function isLoginResponse(response: AuthResponse): response is ILoginResponse;
174
+
175
+ /**
176
+ * Create Company Branch Request Interface
177
+ */
178
+ interface ICreateBranchRequest {
179
+ name: string;
180
+ slug: string;
181
+ companyId: string;
182
+ parentId?: string;
183
+ logoId?: string;
184
+ address?: string;
185
+ phone?: string;
186
+ email?: string;
187
+ serial?: number;
188
+ isActive?: boolean;
189
+ additionalFields?: Record<string, unknown>;
190
+ }
191
+ /**
192
+ * Update Company Branch Request Interface
193
+ */
194
+ interface IUpdateBranchRequest extends Partial<Omit<ICreateBranchRequest, 'companyId'>> {
195
+ id: string;
196
+ }
197
+ /**
198
+ * Company Branch Response Interface
199
+ */
200
+ interface IBranch {
201
+ id: string;
202
+ name: string;
203
+ slug: string;
204
+ companyId: string;
205
+ parentId?: string | null;
206
+ logoId?: string | null;
207
+ address?: string | null;
208
+ phone?: string | null;
209
+ email?: string | null;
210
+ serial?: number;
211
+ isActive: boolean;
212
+ readOnly: boolean;
213
+ additionalFields?: Record<string, unknown> | null;
214
+ createdAt: Date | string;
215
+ updatedAt: Date | string;
216
+ }
217
+
218
+ /**
219
+ * Create Company Request Interface
220
+ */
221
+ interface ICreateCompanyRequest {
222
+ name: string;
223
+ slug: string;
224
+ logoId?: string;
225
+ address?: string;
226
+ phone?: string;
227
+ email?: string;
228
+ website?: string;
229
+ serial?: number;
230
+ isActive?: boolean;
231
+ settings?: Record<string, unknown>;
232
+ additionalFields?: Record<string, unknown>;
233
+ }
234
+ /**
235
+ * Update Company Request Interface
236
+ */
237
+ interface IUpdateCompanyRequest extends Partial<ICreateCompanyRequest> {
238
+ id: string;
239
+ }
240
+ /**
241
+ * Company Response Interface
242
+ */
243
+ interface ICompany {
244
+ id: string;
245
+ name: string;
246
+ slug: string;
247
+ logoId?: string | null;
248
+ address?: string | null;
249
+ phone?: string | null;
250
+ email?: string | null;
251
+ website?: string | null;
252
+ serial?: number;
253
+ isActive: boolean;
254
+ readOnly: boolean;
255
+ settings?: Record<string, unknown> | null;
256
+ additionalFields?: Record<string, unknown> | null;
257
+ createdAt: Date | string;
258
+ updatedAt: Date | string;
259
+ }
260
+
261
+ /**
262
+ * Permission item for batch assignment/revocation
263
+ */
264
+ interface IPermissionItem {
265
+ /** Target ID (Company ID or Branch ID) */
266
+ targetId: string;
267
+ /** Action: true to add permission, false to remove permission */
268
+ isAdd: boolean;
269
+ }
270
+ /**
271
+ * Batch assign/revoke user-company permissions request
272
+ */
273
+ interface IAssignUserCompanyRequest {
274
+ /** User ID to assign/revoke permissions for */
275
+ userId: string;
276
+ /** List of company permissions to add or remove */
277
+ items: IPermissionItem[];
278
+ }
279
+ /**
280
+ * Batch assign/revoke user-branch permissions request
281
+ */
282
+ interface IAssignUserBranchRequest {
283
+ /** User ID to assign/revoke permissions for */
284
+ userId: string;
285
+ /** List of branch permissions to add or remove */
286
+ items: IPermissionItem[];
287
+ }
288
+ /**
289
+ * User company permission with populated company details
290
+ */
291
+ interface IUserCompanyPermission {
292
+ /** Permission ID */
293
+ id: string;
294
+ /** User ID */
295
+ userId: string;
296
+ /** Company ID */
297
+ companyId: string;
298
+ /** Company name */
299
+ companyName: string;
300
+ /** Company slug */
301
+ companySlug: string;
302
+ }
303
+ /**
304
+ * User branch permission with populated branch details
305
+ */
306
+ interface IUserBranchPermission {
307
+ /** Permission ID */
308
+ id: string;
309
+ /** User ID */
310
+ userId: string;
311
+ /** Branch ID */
312
+ branchId: string;
313
+ /** Branch name */
314
+ branchName: string;
315
+ /** Branch slug */
316
+ branchSlug: string;
317
+ /** Company ID this branch belongs to */
318
+ companyId: string;
319
+ }
320
+ /**
321
+ * Response for user companies
322
+ */
323
+ interface IUserCompaniesResponse {
324
+ data: IUserCompanyPermission[];
325
+ }
326
+ /**
327
+ * Response for user branches
328
+ */
329
+ interface IUserBranchesResponse {
330
+ data: IUserBranchPermission[];
331
+ }
332
+ /**
333
+ * Batch operation result response
334
+ */
335
+ interface IBatchOperationResponse {
336
+ success: boolean;
337
+ message: string;
338
+ }
339
+
340
+ /**
341
+ * Create User Request Interface
342
+ */
343
+ interface ICreateUserRequest {
344
+ name: string;
345
+ email: string;
346
+ password: string;
347
+ phone?: string;
348
+ profilePictureId?: string;
349
+ isActive?: boolean;
350
+ emailVerified?: boolean;
351
+ phoneVerified?: boolean;
352
+ additionalFields?: Record<string, unknown>;
353
+ }
354
+ /**
355
+ * Update User Request Interface
356
+ */
357
+ interface IUpdateUserRequest {
358
+ id: string;
359
+ name?: string;
360
+ email?: string;
361
+ password?: string;
362
+ phone?: string;
363
+ profilePictureId?: string;
364
+ isActive?: boolean;
365
+ emailVerified?: boolean;
366
+ phoneVerified?: boolean;
367
+ additionalFields?: Record<string, unknown>;
368
+ }
369
+ /**
370
+ * User Response Interface
371
+ */
372
+ interface IUser {
373
+ id: string;
374
+ name: string;
375
+ email: string;
376
+ phone?: string | null;
377
+ profilePictureId?: string | null;
378
+ isActive: boolean;
379
+ emailVerified: boolean;
380
+ phoneVerified: boolean;
381
+ lastLoginAt?: Date | string | null;
382
+ additionalFields?: Record<string, unknown> | null;
383
+ createdAt: Date | string;
384
+ updatedAt: Date | string;
385
+ deletedAt?: Date | string | null;
386
+ }
387
+
388
+ /**
389
+ * Auth API Service
390
+ * Handles all authentication-related API calls matching NestJS auth endpoints
391
+ */
392
+ declare class AuthApiService {
393
+ private readonly appConfig;
394
+ private readonly http;
395
+ private readonly baseUrl;
396
+ constructor();
397
+ /**
398
+ * Login with email and password
399
+ * Returns either:
400
+ * - ILoginResponse (direct login success)
401
+ * - ICompanySelectionResponse (requires company/branch selection)
402
+ */
403
+ login(data: ILoginRequest): Observable<AuthResponse>;
404
+ /**
405
+ * Register new user
406
+ * Supports simple registration and company-based registration
407
+ * Returns RegistrationResponse directly (not wrapped in SingleResponse)
408
+ */
409
+ register(data: IRegistrationRequest): Observable<IRegistrationResponse>;
410
+ /**
411
+ * Select company and branch after login
412
+ * Used when login returns requiresSelection: true
413
+ * Returns LoginResponse directly (not wrapped)
414
+ */
415
+ select(data: ISelectRequest): Observable<ILoginResponse>;
416
+ /**
417
+ * Switch company/branch for logged-in user
418
+ * Returns LoginResponse directly (not wrapped)
419
+ */
420
+ switchCompany(data: ISwitchCompanyRequest): Observable<ILoginResponse>;
421
+ /**
422
+ * Refresh access token
423
+ * Refresh token is sent via HTTP-only cookie
424
+ * Returns RefreshTokenResponse directly (not wrapped)
425
+ */
426
+ refresh(): Observable<IRefreshTokenResponse>;
427
+ /**
428
+ * Get current user info
429
+ * Returns only user data (no tokens) - IMeResponse
430
+ */
431
+ me(): Observable<IMeResponse>;
432
+ /**
433
+ * Logout current user
434
+ */
435
+ logout(): Observable<IMessageResponse>;
436
+ /**
437
+ * Change password for logged-in user
438
+ */
439
+ changePassword(data: IChangePasswordRequest): Observable<IMessageResponse>;
440
+ /**
441
+ * Send forgot password email
442
+ */
443
+ forgotPassword(email: string): Observable<IMessageResponse>;
444
+ /**
445
+ * Reset password with token
446
+ */
447
+ resetPassword(token: string, newPassword: string): Observable<IMessageResponse>;
448
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<AuthApiService, never>;
449
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<AuthApiService>;
450
+ }
451
+
452
+ /**
453
+ * Auth Initialization Service
454
+ * Handles app startup authentication flow:
455
+ * 1. Check if user has valid session (via refresh token cookie)
456
+ * 2. Restore user state from /auth/me
457
+ * 3. Handle company selection if needed
458
+ *
459
+ * IMPORTANT: Skips initialization during SSR to avoid cookie/localStorage issues
460
+ */
461
+ declare class AuthInitService {
462
+ private readonly authState;
463
+ private readonly authApi;
464
+ private readonly router;
465
+ private readonly appConfig;
466
+ /** Whether initial auth check has completed */
467
+ readonly initialized: _angular_core.WritableSignal<boolean>;
468
+ /** Whether auth check is in progress */
469
+ readonly loading: _angular_core.WritableSignal<boolean>;
470
+ /** Error from auth check */
471
+ readonly error: _angular_core.WritableSignal<string | null>;
472
+ /** Cached initialization observable to prevent duplicate calls */
473
+ private initializationCache$;
474
+ /**
475
+ * Initialize authentication state on app startup.
476
+ *
477
+ * Flow:
478
+ * 1. If already authenticated with user data -> done
479
+ * 2. Try refresh token (via cookie) -> get new access token
480
+ * 3. Call /auth/me to get user info
481
+ * 4. Update state accordingly
482
+ *
483
+ * Uses shareReplay to prevent duplicate initialization calls.
484
+ */
485
+ initialize(): Observable<boolean>;
486
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<AuthInitService, never>;
487
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<AuthInitService>;
488
+ }
489
+
490
+ /**
491
+ * Auth State Service
492
+ * Minimal signal-based state management for authentication
493
+ */
494
+ declare class AuthStateService {
495
+ private readonly appConfig;
496
+ private readonly router;
497
+ readonly user: _angular_core.WritableSignal<IUserInfo | null>;
498
+ readonly accessToken: _angular_core.WritableSignal<string>;
499
+ readonly company: _angular_core.WritableSignal<ICompanyInfo | null>;
500
+ readonly branch: _angular_core.WritableSignal<IBranchInfo | null>;
501
+ readonly selectionSessionId: _angular_core.WritableSignal<string | null>;
502
+ readonly availableCompanies: _angular_core.WritableSignal<ICompanyWithBranches[]>;
503
+ readonly selectionExpiresAt: _angular_core.WritableSignal<Date | null>;
504
+ readonly isAuthenticated: _angular_core.Signal<boolean>;
505
+ readonly requiresCompanySelection: _angular_core.Signal<boolean>;
506
+ readonly userName: _angular_core.Signal<string>;
507
+ readonly companyName: _angular_core.Signal<string>;
508
+ readonly branchName: _angular_core.Signal<string>;
509
+ readonly tenantId: _angular_core.Signal<string | null>;
510
+ constructor();
511
+ setLoginState(response: ILoginResponse): void;
512
+ setSelectionState(response: ICompanySelectionResponse): void;
513
+ clearSelectionState(): void;
514
+ resetState(): void;
515
+ navigateToLogin(returnUrl?: string): void;
516
+ navigateAfterLogin(returnUrl?: string): void;
517
+ getStoredCompanyId(): string | null;
518
+ getStoredBranchId(): string | null;
519
+ private loadFromStorage;
520
+ private store;
521
+ private get;
522
+ private remove;
523
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<AuthStateService, never>;
524
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<AuthStateService>;
525
+ }
526
+
527
+ /**
528
+ * Branch API Service
529
+ * Signal-based service for branch CRUD operations
530
+ * Branches default to current company context
531
+ *
532
+ * @example
533
+ * ```typescript
534
+ * branchService = inject(BranchApiService);
535
+ *
536
+ * // Set current company context
537
+ * branchService.setCurrentCompanyId('company-uuid');
538
+ *
539
+ * // Access data via signals
540
+ * branches = this.branchService.data;
541
+ * isLoading = this.branchService.isLoading;
542
+ *
543
+ * // Fetch branches (will filter by current company)
544
+ * this.branchService.fetchList('search');
545
+ *
546
+ * // Create branch (companyId will be auto-set if not provided)
547
+ * await this.branchService.insertBranch({ name: 'New Branch', slug: 'new-branch' });
548
+ * ```
549
+ */
550
+ declare class BranchApiService extends ApiResourceService<ICreateBranchRequest | IUpdateBranchRequest, IBranch> {
551
+ /** Current company context for branch operations */
552
+ readonly currentCompanyId: _angular_core.WritableSignal<string | null>;
553
+ /** Branches filtered by current company */
554
+ readonly companyBranches: _angular_core.Signal<IBranch[]>;
555
+ constructor(http: HttpClient);
556
+ /**
557
+ * Set the current company context for branch operations
558
+ */
559
+ setCurrentCompanyId(companyId: string | null): void;
560
+ /**
561
+ * Insert a new branch, auto-setting companyId if not provided
562
+ */
563
+ insertBranch(data: Omit<ICreateBranchRequest, 'companyId'> & {
564
+ companyId?: string;
565
+ }): Promise<ReturnType<typeof this.insertAsync>>;
566
+ /**
567
+ * Fetch branches for a specific company
568
+ */
569
+ fetchByCompany(companyId: string, search?: string): void;
570
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<BranchApiService, never>;
571
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<BranchApiService>;
572
+ }
573
+
574
+ /**
575
+ * Company API Service
576
+ * Signal-based service for company CRUD operations
577
+ *
578
+ * @example
579
+ * ```typescript
580
+ * companyService = inject(CompanyApiService);
581
+ *
582
+ * // Access data via signals
583
+ * companies = this.companyService.data;
584
+ * isLoading = this.companyService.isLoading;
585
+ *
586
+ * // Fetch companies
587
+ * this.companyService.fetchList('search', { pagination: { currentPage: 0, pageSize: 10 } });
588
+ *
589
+ * // Create company
590
+ * await this.companyService.insertAsync({ name: 'New Company', slug: 'new-company' });
591
+ * ```
592
+ */
593
+ declare class CompanyApiService extends ApiResourceService<ICreateCompanyRequest | IUpdateCompanyRequest, ICompany> {
594
+ constructor(http: HttpClient);
595
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CompanyApiService, never>;
596
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<CompanyApiService>;
597
+ }
598
+
599
+ /**
600
+ * Token Refresh State Service
601
+ *
602
+ * Manages token refresh state in a request-safe manner for SSR environments.
603
+ * Replaces module-level state that would be shared across requests in SSR.
604
+ *
605
+ * @example
606
+ * ```typescript
607
+ * const refreshState = inject(TokenRefreshStateService);
608
+ *
609
+ * if (refreshState.isRefreshing()) {
610
+ * // Queue request
611
+ * } else {
612
+ * refreshState.startRefresh();
613
+ * // Perform refresh
614
+ * }
615
+ * ```
616
+ */
617
+ declare class TokenRefreshStateService {
618
+ /** Flag to track if token refresh is in progress */
619
+ private readonly _isRefreshing;
620
+ readonly isRefreshing: _angular_core.Signal<boolean>;
621
+ /** Subject to queue requests while refreshing */
622
+ private readonly _refreshTokenSubject;
623
+ readonly refreshTokenSubject$: rxjs.Observable<string | null>;
624
+ /**
625
+ * Mark refresh as started
626
+ */
627
+ startRefresh(): void;
628
+ /**
629
+ * Mark refresh as completed and broadcast new token
630
+ */
631
+ completeRefresh(newToken: string): void;
632
+ /**
633
+ * Mark refresh as failed
634
+ */
635
+ failRefresh(): void;
636
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<TokenRefreshStateService, never>;
637
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<TokenRefreshStateService>;
638
+ }
639
+
640
+ /**
641
+ * User API Service
642
+ * Signal-based service for user CRUD operations
643
+ *
644
+ * @example
645
+ * ```typescript
646
+ * userService = inject(UserApiService);
647
+ *
648
+ * // Access data via signals
649
+ * users = this.userService.data;
650
+ * isLoading = this.userService.isLoading;
651
+ *
652
+ * // Fetch users
653
+ * this.userService.fetchList('search', { pagination: { currentPage: 0, pageSize: 10 } });
654
+ *
655
+ * // Create user
656
+ * await this.userService.insertAsync({
657
+ * name: 'John Doe',
658
+ * email: 'john@example.com',
659
+ * password: 'password123'
660
+ * });
661
+ * ```
662
+ */
663
+ declare class UserApiService extends ApiResourceService<ICreateUserRequest | IUpdateUserRequest, IUser> {
664
+ constructor(http: HttpClient);
665
+ /**
666
+ * Verify user's email
667
+ */
668
+ verifyEmail(userId: string): Observable<IMessageResponse>;
669
+ /**
670
+ * Verify user's phone
671
+ */
672
+ verifyPhone(userId: string): Observable<IMessageResponse>;
673
+ /**
674
+ * Update user status (active/inactive)
675
+ */
676
+ updateStatus(userId: string, isActive: boolean): Observable<IMessageResponse>;
677
+ /**
678
+ * Update current user's profile
679
+ */
680
+ updateProfile(data: IUpdateUserRequest): Observable<ISingleResponse<IUser>>;
681
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<UserApiService, never>;
682
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<UserApiService>;
683
+ }
684
+
685
+ /**
686
+ * User Permission API Service
687
+ *
688
+ * Handles user-company and user-branch permission assignments.
689
+ * Uses batch operations for efficient permission management.
690
+ *
691
+ * Backend Endpoints:
692
+ * - POST /administration/permissions/user-company/assign - Batch assign/revoke company permissions
693
+ * - GET /administration/permissions/user-company?userId=xxx - Get user's companies
694
+ * - POST /administration/permissions/user-branch/assign - Batch assign/revoke branch permissions
695
+ * - GET /administration/permissions/user-branch?userId=xxx - Get user's branches
696
+ */
697
+ declare class UserPermissionApiService {
698
+ private readonly appConfig;
699
+ private readonly http;
700
+ private readonly baseUrl;
701
+ constructor();
702
+ /**
703
+ * Batch assign/revoke user-company permissions
704
+ *
705
+ * @example
706
+ * // Add company permissions
707
+ * service.assignUserCompanies({
708
+ * userId: 'user-id',
709
+ * items: [
710
+ * { targetId: 'company-1', isAdd: true },
711
+ * { targetId: 'company-2', isAdd: true }
712
+ * ]
713
+ * });
714
+ *
715
+ * @example
716
+ * // Remove company permissions
717
+ * service.assignUserCompanies({
718
+ * userId: 'user-id',
719
+ * items: [
720
+ * { targetId: 'company-1', isAdd: false }
721
+ * ]
722
+ * });
723
+ */
724
+ assignUserCompanies(data: IAssignUserCompanyRequest): Observable<IBatchOperationResponse>;
725
+ /**
726
+ * Assign single company to user (convenience method)
727
+ */
728
+ assignUserToCompany(userId: string, companyId: string): Observable<IBatchOperationResponse>;
729
+ /**
730
+ * Revoke single company from user (convenience method)
731
+ */
732
+ revokeUserFromCompany(userId: string, companyId: string): Observable<IBatchOperationResponse>;
733
+ /**
734
+ * Get user's company permissions
735
+ *
736
+ * @param userId - User ID to get companies for
737
+ * @returns Observable with user's company permissions
738
+ */
739
+ getUserCompanies(userId: string): Observable<IUserCompaniesResponse>;
740
+ /**
741
+ * Batch assign/revoke user-branch permissions
742
+ *
743
+ * @example
744
+ * // Add branch permissions
745
+ * service.assignUserBranches({
746
+ * userId: 'user-id',
747
+ * items: [
748
+ * { targetId: 'branch-1', isAdd: true },
749
+ * { targetId: 'branch-2', isAdd: true }
750
+ * ]
751
+ * });
752
+ *
753
+ * @example
754
+ * // Remove branch permissions
755
+ * service.assignUserBranches({
756
+ * userId: 'user-id',
757
+ * items: [
758
+ * { targetId: 'branch-1', isAdd: false }
759
+ * ]
760
+ * });
761
+ */
762
+ assignUserBranches(data: IAssignUserBranchRequest): Observable<IBatchOperationResponse>;
763
+ /**
764
+ * Assign single branch to user (convenience method)
765
+ */
766
+ assignUserToBranch(userId: string, branchId: string): Observable<IBatchOperationResponse>;
767
+ /**
768
+ * Revoke single branch from user (convenience method)
769
+ */
770
+ revokeUserFromBranch(userId: string, branchId: string): Observable<IBatchOperationResponse>;
771
+ /**
772
+ * Get user's branch permissions
773
+ *
774
+ * @param userId - User ID to get branches for
775
+ * @returns Observable with user's branch permissions
776
+ */
777
+ getUserBranches(userId: string): Observable<IUserBranchesResponse>;
778
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<UserPermissionApiService, never>;
779
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<UserPermissionApiService>;
780
+ }
781
+
782
+ /**
783
+ * Auth Guard
784
+ * Protects routes that require authentication.
785
+ *
786
+ * Session restoration is handled by guestGuard. This guard assumes
787
+ * the session has already been restored if user accessed login page first.
788
+ *
789
+ * Handles company feature:
790
+ * - If company feature enabled and no company selected, redirects to login
791
+ * (login page handles company selection as step 2)
792
+ * - If not authenticated, redirects to login
793
+ *
794
+ * @example
795
+ * ```typescript
796
+ * // In routes configuration
797
+ * {
798
+ * path: 'dashboard',
799
+ * loadComponent: () => import('./dashboard.component'),
800
+ * canActivate: [authGuard]
801
+ * }
802
+ * ```
803
+ */
804
+ declare const authGuard: CanActivateFn;
805
+ /**
806
+ * Guest Guard
807
+ * Protects auth routes (login, register) from authenticated users.
808
+ * Redirects authenticated users to home page.
809
+ *
810
+ * CRITICAL: Unlike old implementation, this guard RESTORES the session first
811
+ * before checking authentication. This handles the case when users directly
812
+ * navigate to /auth/login via browser URL while having valid refresh token.
813
+ *
814
+ * Flow:
815
+ * 1. Restore session (if needed) via AuthInitService.initialize()
816
+ * 2. Check if user is authenticated
817
+ * 3. If authenticated -> redirect to dashboard
818
+ * 4. If not authenticated -> allow access to login page
819
+ *
820
+ * @example
821
+ * ```typescript
822
+ * // In routes configuration
823
+ * {
824
+ * path: 'auth/login',
825
+ * loadComponent: () => import('./login.component'),
826
+ * canActivate: [guestGuard]
827
+ * }
828
+ * ```
829
+ */
830
+ declare const guestGuard: CanActivateFn;
831
+ /**
832
+ * Company Feature Guard
833
+ * Protects routes that require company feature to be enabled.
834
+ * Redirects to home if company feature is disabled.
835
+ *
836
+ * Use this guard on company/branch management routes.
837
+ *
838
+ * @example
839
+ * ```typescript
840
+ * // In routes configuration
841
+ * {
842
+ * path: 'administration/company',
843
+ * loadComponent: () => import('./company-list.component'),
844
+ * canActivate: [authGuard, companyFeatureGuard]
845
+ * }
846
+ * ```
847
+ */
848
+ declare const companyFeatureGuard: CanActivateFn;
849
+
850
+ /**
851
+ * Auth Interceptor
852
+ * Adds Authorization header and tenant header to HTTP requests.
853
+ *
854
+ * - Adds Bearer token for authenticated requests (including /auth/me)
855
+ * - Adds tenant header for multi-tenant mode
856
+ * - Adds withCredentials for auth endpoints (cookies)
857
+ *
858
+ * @example
859
+ * ```typescript
860
+ * // In app.config.ts
861
+ * provideHttpClient(
862
+ * withFetch(),
863
+ * withInterceptors([authInterceptor, tokenRefreshInterceptor])
864
+ * )
865
+ * ```
866
+ */
867
+ declare function authInterceptor(req: HttpRequest<unknown>, next: HttpHandlerFn): Observable<HttpEvent<unknown>>;
868
+
869
+ /**
870
+ * Token Refresh Interceptor
871
+ * Handles 401 errors by refreshing the access token.
872
+ *
873
+ * - Intercepts 401 Unauthorized responses
874
+ * - Calls refresh token endpoint
875
+ * - Retries failed request with new token
876
+ * - Queues concurrent requests during refresh
877
+ * - Redirects to login on refresh failure
878
+ * - SSR-safe: Uses injectable service instead of module-level state
879
+ *
880
+ * @example
881
+ * ```typescript
882
+ * // In app.config.ts
883
+ * provideHttpClient(
884
+ * withFetch(),
885
+ * withInterceptors([authInterceptor, tokenRefreshInterceptor])
886
+ * )
887
+ * ```
888
+ */
889
+ declare function tokenRefreshInterceptor(req: HttpRequest<unknown>, next: HttpHandlerFn): Observable<HttpEvent<unknown>>;
890
+
891
+ /**
892
+ * Auth Routes Configuration
893
+ * Public routes for authentication (login, register, etc.)
894
+ *
895
+ * Note: Company selection is now handled within the login page as a multi-step flow.
896
+ */
897
+ declare const AUTH_ROUTES: Routes;
898
+ /**
899
+ * Administration Routes Configuration
900
+ * Protected routes for company, branch, user management and permissions
901
+ * Uses tabbed interface - all under /administration with child routes
902
+ */
903
+ declare const ADMINISTRATION_ROUTES: Routes;
904
+
905
+ /**
906
+ * Auth Layout State Adapter
907
+ * Bridges AuthStateService signals to ILayoutAuthState interface.
908
+ * Provides ready-to-use integration between ng-auth, ng-layout, and ng-shared provider tokens.
909
+ */
910
+ declare class AuthLayoutStateAdapter implements ILayoutAuthState {
911
+ private readonly authState;
912
+ /**
913
+ * Maps company info to company info for layout.
914
+ * Falls back to app name from config when no company is selected.
915
+ */
916
+ readonly currentCompanyInfo: Signal<ICompanyInfo$1 | null>;
917
+ /**
918
+ * Maps branch info to branch info for layout.
919
+ * Returns null when no branch is selected.
920
+ */
921
+ readonly currentBranchInfo: Signal<IBranchInfo$1 | null>;
922
+ /**
923
+ * Maps user info from auth state to layout user info.
924
+ * Profile picture URL is managed separately by AuthLayoutSyncService via FileUrlService.
925
+ */
926
+ readonly loginUserData: Signal<IUserInfo$1 | null>;
927
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<AuthLayoutStateAdapter, never>;
928
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<AuthLayoutStateAdapter>;
929
+ }
930
+ /**
931
+ * Auth Layout API Adapter
932
+ * Bridges AuthApiService to ILayoutAuthApi interface.
933
+ * Handles logout and navigation for layout components.
934
+ */
935
+ declare class AuthLayoutApiAdapter implements ILayoutAuthApi {
936
+ private readonly authApi;
937
+ private readonly authState;
938
+ private readonly permissionApi;
939
+ private readonly router;
940
+ /**
941
+ * Logout the current user.
942
+ * Calls backend logout endpoint and resets local auth state.
943
+ * Auth state reset handles clearing all localStorage including company/branch.
944
+ */
945
+ logOut(): Observable<any>;
946
+ /**
947
+ * Navigate to login page.
948
+ * Optionally preserves current URL as return URL.
949
+ */
950
+ navigateLogin(withUrl?: boolean): void;
951
+ /**
952
+ * Switch to a different company and branch.
953
+ * Calls backend switch endpoint, then triggers full page reload to
954
+ * refresh permissions, reset component state, and re-filter all data.
955
+ */
956
+ switchCompany(companyId: string, branchId: string): Observable<any>;
957
+ /**
958
+ * Get list of companies the logged-in user has permissions for.
959
+ * Uses permission API to filter by user's actual company-level permissions.
960
+ */
961
+ getUserCompanies(): Observable<ICompanyInfo$1[]>;
962
+ /**
963
+ * Get branches for a specific company that the logged-in user has access to.
964
+ * Fetches all user branches and filters by companyId.
965
+ */
966
+ getCompanyBranches(companyId: string): Observable<IBranchInfo$1[]>;
967
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<AuthLayoutApiAdapter, never>;
968
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<AuthLayoutApiAdapter>;
969
+ }
970
+
971
+ /**
972
+ * Auth User Provider Adapter
973
+ *
974
+ * Implements IUserProvider interface from ng-shared using UserApiService from ng-auth.
975
+ * This allows IAM and other packages to access user data without depending on ng-auth directly.
976
+ *
977
+ * @example
978
+ * // In app.config.ts
979
+ * providers: [
980
+ * { provide: USER_PROVIDER, useClass: AuthUserProviderAdapter }
981
+ * ]
982
+ *
983
+ * // In IAM component
984
+ * private readonly userProvider = inject(USER_PROVIDER);
985
+ * this.userProvider.getUsers({ page: 0, pageSize: 50 }).subscribe(...);
986
+ */
987
+ declare class AuthUserProviderAdapter implements IUserProvider {
988
+ private readonly userApi;
989
+ getUsers(filter?: {
990
+ page?: number;
991
+ pageSize?: number;
992
+ search?: string;
993
+ companyId?: string;
994
+ branchId?: string;
995
+ [key: string]: any;
996
+ }): Observable<IListResponse<IUserBasicInfo>>;
997
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<AuthUserProviderAdapter, never>;
998
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<AuthUserProviderAdapter>;
999
+ }
1000
+
1001
+ /**
1002
+ * Auth Company API Provider Adapter
1003
+ *
1004
+ * Implements ICompanyApiProvider interface from ng-shared using CompanyApiService.
1005
+ * Allows IAM package to access company data without depending on ng-auth directly.
1006
+ *
1007
+ * @example
1008
+ * // In app.config.ts
1009
+ * providers: [
1010
+ * { provide: COMPANY_API_PROVIDER, useClass: AuthCompanyApiProviderAdapter }
1011
+ * ]
1012
+ */
1013
+ declare class AuthCompanyApiProviderAdapter implements ICompanyApiProvider {
1014
+ private readonly companyApi;
1015
+ getCompanies(filter?: {
1016
+ page?: number;
1017
+ pageSize?: number;
1018
+ search?: string;
1019
+ }): Observable<IListResponse<ICompanyBasicInfo>>;
1020
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<AuthCompanyApiProviderAdapter, never>;
1021
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<AuthCompanyApiProviderAdapter>;
1022
+ }
1023
+
1024
+ /**
1025
+ * Auth User Permission Provider Adapter
1026
+ *
1027
+ * Implements IUserPermissionProvider interface from ng-shared using UserPermissionApiService.
1028
+ * Allows IAM package to query user permissions without depending on ng-auth directly.
1029
+ *
1030
+ * @example
1031
+ * // In app.config.ts
1032
+ * providers: [
1033
+ * { provide: USER_PERMISSION_PROVIDER, useClass: AuthUserPermissionProviderAdapter }
1034
+ * ]
1035
+ */
1036
+ declare class AuthUserPermissionProviderAdapter implements IUserPermissionProvider {
1037
+ private readonly userPermissionApi;
1038
+ getUserBranchPermissions(userId: string): Observable<ISingleResponse<any>>;
1039
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<AuthUserPermissionProviderAdapter, never>;
1040
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<AuthUserPermissionProviderAdapter>;
1041
+ }
1042
+
1043
+ /**
1044
+ * Provides auth layout integration for ng-layout.
1045
+ * Call this in your app.config.ts to integrate ng-auth with ng-layout.
1046
+ *
1047
+ * Also registers LAYOUT_AUTH_STATE since AuthLayoutStateAdapter
1048
+ * implements both ILayoutAuthState and ICompanyContextProvider.
1049
+ *
1050
+ * @example
1051
+ * ```typescript
1052
+ * // In app.config.ts
1053
+ * export const appConfig: ApplicationConfig = {
1054
+ * providers: [
1055
+ * ...provideAuthLayoutIntegration(),
1056
+ * ],
1057
+ * };
1058
+ * ```
1059
+ */
1060
+ declare function provideAuthLayoutIntegration(): Provider[];
1061
+
1062
+ /**
1063
+ * Provide Auth Provider Adapters
1064
+ *
1065
+ * Registers auth implementations for provider interfaces from ng-shared.
1066
+ * This allows IAM and Storage packages to use auth services without direct dependencies.
1067
+ *
1068
+ * @example
1069
+ * // In app.config.ts
1070
+ * import { provideAuthProviders } from '@flusys/ng-auth';
1071
+ *
1072
+ * export const appConfig: ApplicationConfig = {
1073
+ * providers: [
1074
+ * provideAuthProviders(),
1075
+ * // ... other providers
1076
+ * ]
1077
+ * };
1078
+ *
1079
+ * @returns Array of Angular providers
1080
+ */
1081
+ declare function provideAuthProviders(): Provider[];
1082
+
1083
+ /**
1084
+ * Authentication API Endpoints
1085
+ *
1086
+ * Centralized endpoint definitions to prevent inconsistencies across interceptors
1087
+ * and services. All auth-related endpoints should be referenced from here.
1088
+ *
1089
+ * @example
1090
+ * ```typescript
1091
+ * if (isAuthEndpoint(req.url)) {
1092
+ * // Skip interceptor logic
1093
+ * }
1094
+ * ```
1095
+ */
1096
+ declare const AUTH_ENDPOINTS: {
1097
+ readonly LOGIN: "/auth/login";
1098
+ readonly LOGOUT: "/auth/logout";
1099
+ readonly REFRESH: "/auth/refresh";
1100
+ readonly REGISTER: "/auth/register";
1101
+ readonly SELECT: "/auth/select";
1102
+ readonly SWITCH_COMPANY: "/auth/switch-company";
1103
+ };
1104
+ /**
1105
+ * Check if a URL is an auth-related endpoint
1106
+ */
1107
+ declare function isAuthEndpoint(url: string): boolean;
1108
+ /**
1109
+ * Check if a URL is a specific auth endpoint
1110
+ */
1111
+ declare function isEndpoint(url: string, endpoint: string): boolean;
1112
+
1113
+ interface ITab {
1114
+ id: string;
1115
+ label: string;
1116
+ icon: string;
1117
+ route: string;
1118
+ requiresCompanyFeature?: boolean;
1119
+ }
1120
+ /**
1121
+ * Administration Page Component
1122
+ * Unified administration page with tabs for:
1123
+ * - Users (always visible) - includes permission management via dialogs
1124
+ * - Companies (only if company feature enabled)
1125
+ * - Branches (only if company feature enabled)
1126
+ */
1127
+ declare class AdministrationPageComponent {
1128
+ private readonly appConfig;
1129
+ /** All available tabs */
1130
+ private readonly allTabs;
1131
+ /** Visible tabs based on config */
1132
+ readonly visibleTabs: _angular_core.Signal<ITab[]>;
1133
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<AdministrationPageComponent, never>;
1134
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<AdministrationPageComponent, "lib-administration-page", never, {}, {}, never, never, true, never>;
1135
+ }
1136
+
1137
+ /** Branch form model interface */
1138
+ interface IBranchFormModel {
1139
+ companyId: string;
1140
+ name: string;
1141
+ slug: string;
1142
+ email: string;
1143
+ phone: string;
1144
+ address: string;
1145
+ isActive: boolean;
1146
+ }
1147
+ /**
1148
+ * Branch Form Component
1149
+ * Handles creating and editing branches.
1150
+ * Defaults to current company context.
1151
+ */
1152
+ declare class BranchFormComponent implements OnInit {
1153
+ private readonly router;
1154
+ private readonly route;
1155
+ private readonly messageService;
1156
+ private readonly branchService;
1157
+ private readonly companyService;
1158
+ private readonly authState;
1159
+ /** Loading state */
1160
+ readonly isLoading: _angular_core.WritableSignal<boolean>;
1161
+ /** Existing branch data when editing */
1162
+ readonly existingBranch: _angular_core.WritableSignal<IBranch | null>;
1163
+ /** Whether in edit mode */
1164
+ readonly isEditMode: _angular_core.Signal<boolean>;
1165
+ /** Companies list for dropdown */
1166
+ readonly companies: _angular_core.Signal<_flusys_ng_auth.ICompany[]>;
1167
+ /** Form model */
1168
+ readonly formModel: _angular_core.WritableSignal<IBranchFormModel>;
1169
+ /** Form with validation schema */
1170
+ readonly branchForm: _angular_forms_signals.FieldTree<IBranchFormModel, string | number>;
1171
+ /** Check if form is valid */
1172
+ readonly isFormValid: _angular_core.Signal<boolean>;
1173
+ ngOnInit(): void;
1174
+ loadBranch(id: string): Promise<void>;
1175
+ generateSlug(): void;
1176
+ onSubmit(): Promise<void>;
1177
+ onCancel(): void;
1178
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<BranchFormComponent, never>;
1179
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<BranchFormComponent, "lib-branch-form", never, {}, {}, never, never, true, never>;
1180
+ }
1181
+
1182
+ /**
1183
+ * Branch List Component
1184
+ * Displays a list of branches for a company with CRUD operations.
1185
+ * Defaults to current company context.
1186
+ */
1187
+ declare class BranchListComponent implements OnInit {
1188
+ private readonly router;
1189
+ private readonly route;
1190
+ private readonly messageService;
1191
+ private readonly confirmationService;
1192
+ private readonly branchService;
1193
+ private readonly companyService;
1194
+ private readonly authState;
1195
+ /** Selected company ID */
1196
+ selectedCompanyId: string | null;
1197
+ /** Companies list for dropdown */
1198
+ readonly companies: _angular_core.Signal<_flusys_ng_auth.ICompany[]>;
1199
+ /** Branches from service */
1200
+ readonly branches: _angular_core.Signal<IBranch[]>;
1201
+ /** Loading state from service */
1202
+ readonly isLoading: _angular_core.Signal<boolean>;
1203
+ /** Total count from service */
1204
+ readonly total: _angular_core.Signal<number>;
1205
+ ngOnInit(): void;
1206
+ loadBranches(): void;
1207
+ onCompanyChange(): void;
1208
+ onLazyLoad(event: {
1209
+ first?: number | null;
1210
+ rows?: number | null;
1211
+ }): void;
1212
+ onCreate(): void;
1213
+ onEdit(branch: IBranch): void;
1214
+ onDelete(branch: IBranch): void;
1215
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<BranchListComponent, never>;
1216
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<BranchListComponent, "lib-branch-list", never, {}, {}, never, never, true, never>;
1217
+ }
1218
+
1219
+ /** Company form model interface */
1220
+ interface ICompanyFormModel$1 {
1221
+ name: string;
1222
+ slug: string;
1223
+ email: string;
1224
+ phone: string;
1225
+ website: string;
1226
+ address: string;
1227
+ isActive: boolean;
1228
+ }
1229
+ /**
1230
+ * Company Form Component
1231
+ * Handles creating and editing companies.
1232
+ */
1233
+ declare class CompanyFormComponent implements OnInit {
1234
+ private readonly router;
1235
+ private readonly route;
1236
+ private readonly messageService;
1237
+ private readonly companyService;
1238
+ /** Loading state */
1239
+ readonly isLoading: _angular_core.WritableSignal<boolean>;
1240
+ /** Existing company data when editing */
1241
+ readonly existingCompany: _angular_core.WritableSignal<ICompany | null>;
1242
+ /** Whether in edit mode */
1243
+ readonly isEditMode: _angular_core.Signal<boolean>;
1244
+ /** Form model */
1245
+ readonly formModel: _angular_core.WritableSignal<ICompanyFormModel$1>;
1246
+ /** Form with validation schema */
1247
+ readonly companyForm: _angular_forms_signals.FieldTree<ICompanyFormModel$1, string | number>;
1248
+ /** Check if form is valid */
1249
+ readonly isFormValid: _angular_core.Signal<boolean>;
1250
+ ngOnInit(): void;
1251
+ loadCompany(id: string): Promise<void>;
1252
+ generateSlug(): void;
1253
+ onSubmit(): Promise<void>;
1254
+ onCancel(): void;
1255
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CompanyFormComponent, never>;
1256
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<CompanyFormComponent, "lib-company-form", never, {}, {}, never, never, true, never>;
1257
+ }
1258
+
1259
+ /**
1260
+ * Company List Component
1261
+ * Displays a list of companies with CRUD operations.
1262
+ * Only visible when company feature is enabled.
1263
+ */
1264
+ declare class CompanyListComponent implements OnInit {
1265
+ private readonly router;
1266
+ private readonly messageService;
1267
+ private readonly confirmationService;
1268
+ private readonly companyService;
1269
+ /** Companies from service */
1270
+ readonly companies: _angular_core.Signal<ICompany[]>;
1271
+ /** Loading state from service */
1272
+ readonly isLoading: _angular_core.Signal<boolean>;
1273
+ /** Total count from service */
1274
+ readonly total: _angular_core.Signal<number>;
1275
+ ngOnInit(): void;
1276
+ loadCompanies(): void;
1277
+ onLazyLoad(event: {
1278
+ first?: number | null;
1279
+ rows?: number | null;
1280
+ }): void;
1281
+ onCreate(): void;
1282
+ onEdit(company: ICompany): void;
1283
+ onViewBranches(company: ICompany): void;
1284
+ onDelete(company: ICompany): void;
1285
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CompanyListComponent, never>;
1286
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<CompanyListComponent, "lib-company-list", never, {}, {}, never, never, true, never>;
1287
+ }
1288
+
1289
+ /** Login form model interface */
1290
+ interface ILoginFormModel {
1291
+ email: string;
1292
+ password: string;
1293
+ rememberMe: boolean;
1294
+ }
1295
+ /** Company selection form model interface */
1296
+ interface ISelectionFormModel {
1297
+ companyId: string;
1298
+ branchId: string;
1299
+ rememberSelection: boolean;
1300
+ }
1301
+ type LoginStep = 'credentials' | 'company-selection';
1302
+ /**
1303
+ * Login Page Component
1304
+ * Multi-step authentication flow:
1305
+ * - Step 1: Email/Password credentials
1306
+ * - Step 2: Company/Branch selection (when company feature enabled and user has multiple)
1307
+ */
1308
+ declare class LoginPageComponent implements OnInit {
1309
+ private readonly destroyRef;
1310
+ private readonly appConfig;
1311
+ private readonly messageService;
1312
+ private readonly authApi;
1313
+ private readonly authState;
1314
+ /** Return URL after successful login */
1315
+ readonly returnUrl: _angular_core.InputSignal<string>;
1316
+ /** Current step in login flow */
1317
+ readonly currentStep: _angular_core.WritableSignal<LoginStep>;
1318
+ /** Loading state */
1319
+ readonly isLoading: _angular_core.WritableSignal<boolean>;
1320
+ /** Login form model */
1321
+ readonly loginFormModel: _angular_core.WritableSignal<ILoginFormModel>;
1322
+ /** Login form with validation schema */
1323
+ readonly loginForm: _angular_forms_signals.FieldTree<ILoginFormModel, string | number>;
1324
+ /** Check if login form is valid */
1325
+ readonly isLoginFormValid: _angular_core.Signal<boolean>;
1326
+ /** Selection form model */
1327
+ readonly selectionFormModel: _angular_core.WritableSignal<ISelectionFormModel>;
1328
+ /** Selection form with validation schema */
1329
+ readonly selectionForm: _angular_forms_signals.FieldTree<ISelectionFormModel, string | number>;
1330
+ /** Check if selection form is valid */
1331
+ readonly isSelectionFormValid: _angular_core.Signal<boolean>;
1332
+ /** Whether company feature is enabled */
1333
+ readonly companyFeatureEnabled: _angular_core.Signal<boolean>;
1334
+ /** Session ID for company selection */
1335
+ private sessionId;
1336
+ /** Available companies */
1337
+ readonly companies: _angular_core.WritableSignal<ICompanyWithBranches[]>;
1338
+ /** User's name */
1339
+ readonly userName: _angular_core.WritableSignal<string>;
1340
+ /** Branches for selected company */
1341
+ readonly branches: _angular_core.Signal<IBranchSelectionInfo[]>;
1342
+ ngOnInit(): void;
1343
+ onSubmit(): void;
1344
+ /** Handle company selection change */
1345
+ onCompanyChange(): void;
1346
+ onSelectCompany(): void;
1347
+ goBackToCredentials(): void;
1348
+ private autoSelectIfSingle;
1349
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<LoginPageComponent, never>;
1350
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<LoginPageComponent, "lib-login-page", never, { "returnUrl": { "alias": "returnUrl"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
1351
+ }
1352
+
1353
+ /** User registration form model */
1354
+ interface IUserFormModel$1 {
1355
+ name: string;
1356
+ email: string;
1357
+ password: string;
1358
+ confirmPassword: string;
1359
+ phone: string;
1360
+ }
1361
+ /** Company form model */
1362
+ interface ICompanyFormModel {
1363
+ createNewCompany: boolean;
1364
+ companySlug: string;
1365
+ branchSlug: string;
1366
+ newCompanyName: string;
1367
+ newCompanyPhone: string;
1368
+ newCompanyAddress: string;
1369
+ }
1370
+ /**
1371
+ * Registration Page Component
1372
+ * Handles user registration with optional company creation
1373
+ * Adapts UI based on company feature configuration
1374
+ */
1375
+ declare class RegisterPageComponent implements OnInit {
1376
+ private readonly destroyRef;
1377
+ private readonly appConfig;
1378
+ private readonly messageService;
1379
+ private readonly authApi;
1380
+ private readonly authState;
1381
+ private readonly route;
1382
+ /** Return URL after successful registration */
1383
+ readonly returnUrl: _angular_core.InputSignal<string>;
1384
+ /** Loading state */
1385
+ readonly isLoading: _angular_core.WritableSignal<boolean>;
1386
+ /** Whether company feature is enabled */
1387
+ readonly companyFeatureEnabled: _angular_core.Signal<boolean>;
1388
+ /** User form model */
1389
+ readonly userFormModel: _angular_core.WritableSignal<IUserFormModel$1>;
1390
+ /** User form with validation schema */
1391
+ readonly userForm: _angular_forms_signals.FieldTree<IUserFormModel$1, string | number>;
1392
+ /** Company form model */
1393
+ readonly companyFormModel: _angular_core.WritableSignal<ICompanyFormModel>;
1394
+ /** Company form with conditional validation schema */
1395
+ readonly companyForm: _angular_forms_signals.FieldTree<ICompanyFormModel, string | number>;
1396
+ ngOnInit(): void;
1397
+ /** Check if passwords match */
1398
+ readonly passwordsMatch: _angular_core.Signal<boolean>;
1399
+ /** Check if form is valid */
1400
+ readonly isFormValid: _angular_core.Signal<boolean>;
1401
+ onCreateCompanyToggle(): void;
1402
+ onSubmit(): void;
1403
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<RegisterPageComponent, never>;
1404
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<RegisterPageComponent, "lib-register-page", never, { "returnUrl": { "alias": "returnUrl"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
1405
+ }
1406
+
1407
+ /** User form model interface */
1408
+ interface IUserFormModel {
1409
+ name: string;
1410
+ email: string;
1411
+ password: string;
1412
+ phone: string;
1413
+ isActive: boolean;
1414
+ emailVerified: boolean;
1415
+ }
1416
+ /**
1417
+ * User Form Component
1418
+ * Handles creating and editing users.
1419
+ * When company feature is enabled, automatically assigns new users to current company/branch.
1420
+ */
1421
+ declare class UserFormComponent implements OnInit {
1422
+ private readonly destroyRef;
1423
+ private readonly router;
1424
+ private readonly route;
1425
+ private readonly appConfig;
1426
+ private readonly messageService;
1427
+ private readonly userService;
1428
+ private readonly permissionService;
1429
+ private readonly authState;
1430
+ /** Loading state */
1431
+ readonly isLoading: _angular_core.WritableSignal<boolean>;
1432
+ /** Existing user data when editing */
1433
+ readonly existingUser: _angular_core.WritableSignal<IUser | null>;
1434
+ /** Whether in edit mode */
1435
+ readonly isEditMode: _angular_core.Signal<boolean>;
1436
+ /** Whether company feature is enabled */
1437
+ readonly companyFeatureEnabled: _angular_core.Signal<boolean>;
1438
+ /** Current company name */
1439
+ readonly currentCompanyName: _angular_core.Signal<string>;
1440
+ /** Current branch name */
1441
+ readonly currentBranchName: _angular_core.Signal<string>;
1442
+ /** Form model */
1443
+ readonly formModel: _angular_core.WritableSignal<IUserFormModel>;
1444
+ /** Form with validation schema */
1445
+ readonly formTree: _angular_forms_signals.FieldTree<IUserFormModel, string | number>;
1446
+ /** Check if form is valid */
1447
+ readonly isFormValid: _angular_core.Signal<boolean>;
1448
+ ngOnInit(): void;
1449
+ loadUser(id: string): void;
1450
+ onSubmit(): void;
1451
+ /**
1452
+ * Assign user to current company and branch
1453
+ */
1454
+ private assignUserToCompanyAndBranch;
1455
+ onCancel(): void;
1456
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<UserFormComponent, never>;
1457
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<UserFormComponent, "lib-user-form", never, {}, {}, never, never, true, never>;
1458
+ }
1459
+
1460
+ /**
1461
+ * User List Component
1462
+ * Displays a list of users with CRUD operations.
1463
+ */
1464
+ declare class UserListComponent implements OnInit {
1465
+ private readonly router;
1466
+ private readonly appConfig;
1467
+ private readonly messageService;
1468
+ private readonly confirmationService;
1469
+ private readonly userService;
1470
+ /** Users from service */
1471
+ readonly users: _angular_core.Signal<IUser[]>;
1472
+ /** Loading state from service */
1473
+ readonly isLoading: _angular_core.Signal<boolean>;
1474
+ /** Total count from service */
1475
+ readonly total: _angular_core.Signal<number>;
1476
+ /** Whether company feature is enabled */
1477
+ readonly companyFeatureEnabled: _angular_core.Signal<boolean>;
1478
+ /** Dialog visibility */
1479
+ readonly showCompanyDialog: _angular_core.WritableSignal<boolean>;
1480
+ readonly showBranchDialog: _angular_core.WritableSignal<boolean>;
1481
+ /** Selected user for permission management */
1482
+ readonly selectedUser: _angular_core.WritableSignal<IUser | null>;
1483
+ ngOnInit(): void;
1484
+ loadUsers(): void;
1485
+ onLazyLoad(event: {
1486
+ first?: number | null;
1487
+ rows?: number | null;
1488
+ }): void;
1489
+ onCreate(): void;
1490
+ onEdit(user: IUser): void;
1491
+ onManageCompanyPermissions(user: IUser): void;
1492
+ onManageBranchPermissions(user: IUser): void;
1493
+ onDelete(user: IUser): void;
1494
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<UserListComponent, never>;
1495
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<UserListComponent, "lib-user-list", never, {}, {}, never, never, true, never>;
1496
+ }
1497
+
1498
+ /**
1499
+ * User Branch Permission Dialog
1500
+ *
1501
+ * Workflow:
1502
+ * 1. Dialog opens → Shows company dropdown with user's permitted companies
1503
+ * 2. User selects a company → Branches load for that company
1504
+ * 3. Branches show with checkboxes (checked = already assigned)
1505
+ * 4. Check to assign, uncheck to revoke
1506
+ *
1507
+ * Company dropdown only shows companies the user has company-level permissions for.
1508
+ * Branch permissions can only be assigned within user's permitted companies.
1509
+ */
1510
+ declare class UserBranchPermissionDialogComponent {
1511
+ private readonly branchApi;
1512
+ private readonly permissionApi;
1513
+ private readonly authState;
1514
+ private readonly messageService;
1515
+ /** Dialog visibility */
1516
+ readonly visible: _angular_core.InputSignal<boolean>;
1517
+ /** User to manage permissions for */
1518
+ readonly user: _angular_core.InputSignal<IUser | null>;
1519
+ /** Close event */
1520
+ readonly closed: _angular_core.OutputEmitterRef<void>;
1521
+ /** Refresh event after changes */
1522
+ readonly permissionsChanged: _angular_core.OutputEmitterRef<void>;
1523
+ /** Loading state */
1524
+ readonly isLoading: _angular_core.WritableSignal<boolean>;
1525
+ /** Saving state */
1526
+ readonly isSaving: _angular_core.WritableSignal<boolean>;
1527
+ /** Branches with assignment status */
1528
+ readonly branches: _angular_core.WritableSignal<BranchWithAssignment[]>;
1529
+ /** Available companies (filtered by user's company permissions) */
1530
+ readonly companies: _angular_core.WritableSignal<{
1531
+ id: string;
1532
+ name: string;
1533
+ }[]>;
1534
+ /** Selected company ID */
1535
+ selectedCompanyId: string | null;
1536
+ /** Current company from auth state */
1537
+ readonly currentCompany: _angular_core.Signal<_flusys_ng_auth.ICompanyInfo | null>;
1538
+ /** Currently assigned branch IDs */
1539
+ private assignedBranchIds;
1540
+ constructor();
1541
+ /**
1542
+ * Load user's assigned companies (does not auto-select or load branches)
1543
+ */
1544
+ private loadUserCompaniesAndData;
1545
+ private loadData;
1546
+ onCompanyChange(): void;
1547
+ onBranchToggle(branch: BranchWithAssignment): Promise<void>;
1548
+ onClose(): void;
1549
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<UserBranchPermissionDialogComponent, never>;
1550
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<UserBranchPermissionDialogComponent, "lib-user-branch-permission-dialog", never, { "visible": { "alias": "visible"; "required": true; "isSignal": true; }; "user": { "alias": "user"; "required": true; "isSignal": true; }; }, { "closed": "closed"; "permissionsChanged": "permissionsChanged"; }, never, never, true, never>;
1551
+ }
1552
+ interface BranchWithAssignment extends IBranch {
1553
+ isAssigned: boolean;
1554
+ }
1555
+
1556
+ /**
1557
+ * User Company Permission Dialog
1558
+ * Shows all companies with checkboxes
1559
+ * Initially assigned companies are checked
1560
+ * Check to assign, uncheck to revoke
1561
+ */
1562
+ declare class UserCompanyPermissionDialogComponent {
1563
+ private readonly companyApi;
1564
+ private readonly permissionApi;
1565
+ private readonly messageService;
1566
+ /** Dialog visibility */
1567
+ readonly visible: _angular_core.InputSignal<boolean>;
1568
+ /** User to manage permissions for */
1569
+ readonly user: _angular_core.InputSignal<IUser | null>;
1570
+ /** Close event */
1571
+ readonly closed: _angular_core.OutputEmitterRef<void>;
1572
+ /** Refresh event after changes */
1573
+ readonly permissionsChanged: _angular_core.OutputEmitterRef<void>;
1574
+ /** Loading state */
1575
+ readonly isLoading: _angular_core.WritableSignal<boolean>;
1576
+ /** Saving state */
1577
+ readonly isSaving: _angular_core.WritableSignal<boolean>;
1578
+ /** Companies with assignment status */
1579
+ readonly companies: _angular_core.WritableSignal<CompanyWithAssignment[]>;
1580
+ /** Currently assigned company IDs */
1581
+ private assignedCompanyIds;
1582
+ constructor();
1583
+ private loadData;
1584
+ onCompanyToggle(company: CompanyWithAssignment): Promise<void>;
1585
+ onClose(): void;
1586
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<UserCompanyPermissionDialogComponent, never>;
1587
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<UserCompanyPermissionDialogComponent, "lib-user-company-permission-dialog", never, { "visible": { "alias": "visible"; "required": true; "isSignal": true; }; "user": { "alias": "user"; "required": true; "isSignal": true; }; }, { "closed": "closed"; "permissionsChanged": "permissionsChanged"; }, never, never, true, never>;
1588
+ }
1589
+ interface CompanyWithAssignment extends ICompany {
1590
+ isAssigned: boolean;
1591
+ }
1592
+
1593
+ export { ADMINISTRATION_ROUTES, AUTH_ENDPOINTS, AUTH_ROUTES, AdministrationPageComponent, AuthApiService, AuthCompanyApiProviderAdapter, AuthInitService, AuthLayoutApiAdapter, AuthLayoutStateAdapter, AuthStateService, AuthUserPermissionProviderAdapter, AuthUserProviderAdapter, BranchApiService, BranchFormComponent, BranchListComponent, CompanyApiService, CompanyFormComponent, CompanyListComponent, LoginPageComponent, RegisterPageComponent, TokenRefreshStateService, UserApiService, UserBranchPermissionDialogComponent, UserCompanyPermissionDialogComponent, UserFormComponent, UserListComponent, UserPermissionApiService, authGuard, authInterceptor, companyFeatureGuard, guestGuard, isAuthEndpoint, isCompanySelectionResponse, isEndpoint, isLoginResponse, provideAuthLayoutIntegration, provideAuthProviders, tokenRefreshInterceptor };
1594
+ export type { AuthResponse, IAssignUserBranchRequest, IAssignUserCompanyRequest, IBatchOperationResponse, IBranch, IBranchInfo, IBranchSelectionInfo, IChangePasswordRequest, ICompany, ICompanyInfo, ICompanySelectionResponse, ICompanyWithBranches, ICreateBranchRequest, ICreateCompanyRequest, ICreateUserRequest, ILoginRequest, ILoginResponse, IMeResponse, IPermissionItem, IRefreshTokenResponse, IRegistrationRequest, IRegistrationResponse, ISelectRequest, ISwitchCompanyRequest, IUpdateBranchRequest, IUpdateCompanyRequest, IUpdateUserRequest, IUser, IUserBranchPermission, IUserBranchesResponse, IUserCompaniesResponse, IUserCompanyPermission, IUserInfo };