@cbm-common/cbm-types 0.0.274 → 0.0.276
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/lib/domain/models/user-calendar.domain.model.d.ts +38 -0
- package/lib/domain/repositories/user-calendar.domain.repository.d.ts +11 -0
- package/lib/domain/services/refresch-schedules.domain.service.d.ts +132 -0
- package/lib/infrastructure/repositories/user-calendar.infrastructure.repository.d.ts +8 -0
- package/lib/infrastructure/services/user-calendar.infrastructure.service.d.ts +13 -0
- package/package.json +1 -1
- package/lib/components/detail-by-section/detail-by-section.d.ts +0 -75
- package/lib/components/detail-by-section/detail-by-section.model.d.ts +0 -30
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare namespace UserCalendarModel {
|
|
2
|
+
interface ListResponse {
|
|
3
|
+
success: boolean;
|
|
4
|
+
data: ListResponse.Data[];
|
|
5
|
+
}
|
|
6
|
+
namespace ListResponse {
|
|
7
|
+
interface Data {
|
|
8
|
+
_id: string;
|
|
9
|
+
user_id: string;
|
|
10
|
+
day_code: number;
|
|
11
|
+
day_name: string;
|
|
12
|
+
begin_time: string;
|
|
13
|
+
end_time: string;
|
|
14
|
+
all_day: boolean;
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
created_at: number;
|
|
17
|
+
created_user: string;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
interface Save {
|
|
21
|
+
user_id: string;
|
|
22
|
+
day_code: string;
|
|
23
|
+
day_name: string;
|
|
24
|
+
begin_time: string;
|
|
25
|
+
end_time: string;
|
|
26
|
+
all_day: boolean;
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
}
|
|
29
|
+
interface Update {
|
|
30
|
+
user_id: string;
|
|
31
|
+
day_code: number;
|
|
32
|
+
day_name: string;
|
|
33
|
+
begin_time: string;
|
|
34
|
+
end_time: string;
|
|
35
|
+
all_day: boolean;
|
|
36
|
+
enabled: boolean;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import { UserCalendarModel } from "../models/user-calendar.domain.model";
|
|
3
|
+
import { IUserCalendarInfrastructureRepository } from "../../infrastructure/repositories/user-calendar.infrastructure.repository";
|
|
4
|
+
import { IGeneral } from "../models/general.domain.model";
|
|
5
|
+
export declare class UserCalendarDomainRepository implements IUserCalendarInfrastructureRepository {
|
|
6
|
+
private readonly userCalendarService;
|
|
7
|
+
constructor(userCalendarService: IUserCalendarInfrastructureRepository);
|
|
8
|
+
list(userId: string): Observable<UserCalendarModel.ListResponse>;
|
|
9
|
+
save(request: UserCalendarModel.Save): Observable<IGeneral.Confirm>;
|
|
10
|
+
update(id: string, request: UserCalendarModel.Update): Observable<IGeneral.Confirm>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { OnDestroy } from "@angular/core";
|
|
2
|
+
import { Subject } from "rxjs";
|
|
3
|
+
import { Router } from "@angular/router";
|
|
4
|
+
import { UserCalendarModel } from "../models/user-calendar.domain.model";
|
|
5
|
+
import { UserCalendarDomainRepository } from "../repositories/user-calendar.domain.repository";
|
|
6
|
+
import { CbmAuthReactiveService } from "./auth-reactive.domain.service";
|
|
7
|
+
import { CbmNotificationService } from "./notification/notification.service";
|
|
8
|
+
export interface AccessControlResult {
|
|
9
|
+
hasAccess: boolean;
|
|
10
|
+
message: string;
|
|
11
|
+
scheduleInfo?: UserCalendarModel.ListResponse.Data;
|
|
12
|
+
}
|
|
13
|
+
export declare class RefreshSchedulesDomainService implements OnDestroy {
|
|
14
|
+
private userModel;
|
|
15
|
+
private router;
|
|
16
|
+
private authService;
|
|
17
|
+
private notificationService;
|
|
18
|
+
private readonly STORAGE_KEY;
|
|
19
|
+
private readonly LAST_CHECK_KEY;
|
|
20
|
+
private readonly CHECK_INTERVAL_MS;
|
|
21
|
+
private accessCheckSubscription;
|
|
22
|
+
private isMonitoring;
|
|
23
|
+
closeInterval$: Subject<void>;
|
|
24
|
+
private notifiedEndTime;
|
|
25
|
+
onAccessDenied: () => void;
|
|
26
|
+
onAccessGranted: (() => void) | null;
|
|
27
|
+
onAccessStatusChange: ((result: AccessControlResult) => void) | null;
|
|
28
|
+
constructor(userModel: UserCalendarDomainRepository, router: Router, authService: CbmAuthReactiveService, notificationService: CbmNotificationService);
|
|
29
|
+
ngOnDestroy(): void;
|
|
30
|
+
initUsershecudles(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Inicia la verificación periódica del acceso del usuario
|
|
33
|
+
* @param intervalMs Intervalo en milisegundos (por defecto 60000 = 1 minuto)
|
|
34
|
+
*/
|
|
35
|
+
startPeriodicAccessCheck(intervalMs?: number): void;
|
|
36
|
+
/**
|
|
37
|
+
* Detiene la verificación periódica del acceso
|
|
38
|
+
*/
|
|
39
|
+
stopPeriodicAccessCheck(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Realiza la verificación de acceso y ejecuta las acciones correspondientes
|
|
42
|
+
*/
|
|
43
|
+
private performAccessCheck;
|
|
44
|
+
/**
|
|
45
|
+
* Obtiene el estado actual del monitoreo
|
|
46
|
+
*/
|
|
47
|
+
isAccessMonitoring(): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Cambia el intervalo de verificación
|
|
50
|
+
* Nota: Se aplica en la próxima ronda de verificación
|
|
51
|
+
*/
|
|
52
|
+
setCheckInterval(intervalMs: number): void;
|
|
53
|
+
/**
|
|
54
|
+
* Verifica si el usuario tiene acceso en la hora actual
|
|
55
|
+
* Compara la hora actual con los horarios permitidos del día
|
|
56
|
+
* @param schedules Lista de horarios configurados
|
|
57
|
+
* @returns Resultado indicando si tiene acceso o debe ser sacado del sistema
|
|
58
|
+
*/
|
|
59
|
+
checkAccessByCurrentTime(schedules: UserCalendarModel.ListResponse.Data[]): AccessControlResult;
|
|
60
|
+
/**
|
|
61
|
+
* Verifica y aplica control de acceso iterando sobre múltiples horarios
|
|
62
|
+
* Útil para verificar si un usuario debe ser expulsado del sistema
|
|
63
|
+
* @param schedules Lista de horarios a verificar
|
|
64
|
+
* @param userCurrentTime Hora actual del usuario (opcional, usa hora del servidor si no se proporciona)
|
|
65
|
+
* @returns Array de resultados de acceso por cada horario verificado
|
|
66
|
+
*/
|
|
67
|
+
validateSchedulesAndApplyControl(schedules: UserCalendarModel.ListResponse.Data[], userCurrentTime?: Date): AccessControlResult[];
|
|
68
|
+
/**
|
|
69
|
+
* Verifica si existe acceso activo en la hora actual
|
|
70
|
+
* Retorna true si el usuario tiene acceso ahora mismo
|
|
71
|
+
*/
|
|
72
|
+
hasActiveAccess(schedules: UserCalendarModel.ListResponse.Data[]): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Obtiene el próximo horario de expulsión del sistema
|
|
75
|
+
* Útil para programar la expulsión automática
|
|
76
|
+
*/
|
|
77
|
+
getNextLogoutTime(schedules: UserCalendarModel.ListResponse.Data[]): Date | null;
|
|
78
|
+
private checkAndNotifyExpiry;
|
|
79
|
+
/**
|
|
80
|
+
* Guarda los horarios en localStorage
|
|
81
|
+
* @param schedules Lista de horarios a guardar
|
|
82
|
+
*/
|
|
83
|
+
saveSchedulesToStorage(schedules: UserCalendarModel.ListResponse.Data[]): void;
|
|
84
|
+
/**
|
|
85
|
+
* Obtiene los horarios desde localStorage
|
|
86
|
+
* @returns Array de horarios o array vacío si no existen
|
|
87
|
+
*/
|
|
88
|
+
getSchedulesFromStorage(): UserCalendarModel.ListResponse.Data[];
|
|
89
|
+
/**
|
|
90
|
+
* Verifica si existen horarios guardados en localStorage
|
|
91
|
+
*/
|
|
92
|
+
hasSchedulesInStorage(): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Elimina los horarios de localStorage
|
|
95
|
+
*/
|
|
96
|
+
clearSchedulesFromStorage(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Actualiza un horario específico en localStorage
|
|
99
|
+
* @param dayName Nombre del día a actualizar
|
|
100
|
+
* @param updatedSchedule Nuevo horario
|
|
101
|
+
*/
|
|
102
|
+
updateScheduleInStorage(dayName: string, updatedSchedule: UserCalendarModel.ListResponse.Data): void;
|
|
103
|
+
/**
|
|
104
|
+
* Verifica acceso usando los horarios guardados en localStorage
|
|
105
|
+
* @returns Resultado del control de acceso
|
|
106
|
+
*/
|
|
107
|
+
checkAccessFromStorage(): AccessControlResult;
|
|
108
|
+
/**
|
|
109
|
+
* Registra la última vez que se verificó el acceso en localStorage
|
|
110
|
+
*/
|
|
111
|
+
recordLastAccessCheck(): void;
|
|
112
|
+
/**
|
|
113
|
+
* Obtiene la última vez que se verificó el acceso
|
|
114
|
+
*/
|
|
115
|
+
getLastAccessCheck(): Date | null;
|
|
116
|
+
/**
|
|
117
|
+
* Convierte un número de día (0-6) a nombre del día en español
|
|
118
|
+
*/
|
|
119
|
+
private getDayName;
|
|
120
|
+
/**
|
|
121
|
+
* Formatea la hora actual en formato HH:mm
|
|
122
|
+
*/
|
|
123
|
+
private formatTime;
|
|
124
|
+
/**
|
|
125
|
+
* Verifica si una hora está dentro de un rango de tiempo
|
|
126
|
+
*/
|
|
127
|
+
private isTimeWithinRange;
|
|
128
|
+
/**
|
|
129
|
+
* Genera un mensaje descriptivo sobre el acceso
|
|
130
|
+
*/
|
|
131
|
+
private generateAccessMessage;
|
|
132
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import { UserCalendarModel } from "../../domain/models/user-calendar.domain.model";
|
|
3
|
+
import { IGeneral } from "../../domain/models/general.domain.model";
|
|
4
|
+
export interface IUserCalendarInfrastructureRepository {
|
|
5
|
+
list(userId: string): Observable<UserCalendarModel.ListResponse>;
|
|
6
|
+
save(request: UserCalendarModel.Save): Observable<IGeneral.Confirm>;
|
|
7
|
+
update(id: string, request: UserCalendarModel.Update): Observable<IGeneral.Confirm>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IUserCalendarInfrastructureRepository } from "../repositories/user-calendar.infrastructure.repository";
|
|
2
|
+
import { Observable } from "rxjs";
|
|
3
|
+
import { HttpClient } from "@angular/common/http";
|
|
4
|
+
import { UserCalendarModel } from "../../domain/models/user-calendar.domain.model";
|
|
5
|
+
import { IGeneral } from "../../domain/models/general.domain.model";
|
|
6
|
+
export declare class UserCalendarInfrastrcutureService implements IUserCalendarInfrastructureRepository {
|
|
7
|
+
private readonly http;
|
|
8
|
+
constructor(http: HttpClient);
|
|
9
|
+
private readonly userCalendarUrl;
|
|
10
|
+
list(userId: string): Observable<UserCalendarModel.ListResponse>;
|
|
11
|
+
save(request: UserCalendarModel.Save): Observable<IGeneral.Confirm>;
|
|
12
|
+
update(id: string, request: UserCalendarModel.Update): Observable<IGeneral.Confirm>;
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { CdkDragDrop } from '@angular/cdk/drag-drop';
|
|
2
|
-
import { DestroyRef } from '@angular/core';
|
|
3
|
-
import { FormControl } from '@angular/forms';
|
|
4
|
-
import { CbmDetailBySectionModel } from './detail-by-section.model';
|
|
5
|
-
type TDetailCategory = 'all' | 'item' | 'service' | 'subcontracted';
|
|
6
|
-
declare class DetailSectionControl {
|
|
7
|
-
readonly id: `${string}-${string}-${string}-${string}-${string}`;
|
|
8
|
-
readonly defaultTitle: string;
|
|
9
|
-
constructor(title: string);
|
|
10
|
-
title: import("@angular/core").WritableSignal<string>;
|
|
11
|
-
items: import("@angular/core").WritableSignal<CbmDetailBySectionModel.SectionDetail[]>;
|
|
12
|
-
isDetailHidden: import("@angular/core").WritableSignal<boolean>;
|
|
13
|
-
itemsCount: import("@angular/core").Signal<number>;
|
|
14
|
-
subtotal: import("@angular/core").Signal<number>;
|
|
15
|
-
hasItems: import("@angular/core").Signal<boolean>;
|
|
16
|
-
summaryMessage: import("@angular/core").Signal<string>;
|
|
17
|
-
addItems(details: Array<CbmDetailBySectionModel.SectionDetail>): void;
|
|
18
|
-
replaceItems(details: Array<CbmDetailBySectionModel.SectionDetail>): void;
|
|
19
|
-
removeItem(detailKey: string): boolean;
|
|
20
|
-
resetTitleIfEmpty(value: string): void;
|
|
21
|
-
toggleDetailVisibility(): void;
|
|
22
|
-
}
|
|
23
|
-
export declare class CbmDetailBySectionComponent {
|
|
24
|
-
private readonly destroyRef;
|
|
25
|
-
EType: typeof CbmDetailBySectionModel.Type;
|
|
26
|
-
constructor(destroyRef: DestroyRef);
|
|
27
|
-
labels: import("@angular/core").WritableSignal<{
|
|
28
|
-
labelDetail: string;
|
|
29
|
-
labelSection: string;
|
|
30
|
-
}>;
|
|
31
|
-
sectionsChange: import("@angular/core").OutputEmitterRef<CbmDetailBySectionModel.SectionSnapshot[]>;
|
|
32
|
-
searchItemsControl: FormControl<string>;
|
|
33
|
-
detailCategory: import("@angular/core").WritableSignal<{
|
|
34
|
-
all: boolean;
|
|
35
|
-
item: boolean;
|
|
36
|
-
service: boolean;
|
|
37
|
-
subcontracted: boolean;
|
|
38
|
-
}>;
|
|
39
|
-
selectedCategory: import("@angular/core").WritableSignal<TDetailCategory>;
|
|
40
|
-
detail: import("@angular/core").WritableSignal<CbmDetailBySectionModel.SectionDetail[]>;
|
|
41
|
-
sectionsDetail: import("@angular/core").WritableSignal<DetailSectionControl[]>;
|
|
42
|
-
editingSectionIndex: import("@angular/core").WritableSignal<number | null>;
|
|
43
|
-
nextSectionNumber: import("@angular/core").WritableSignal<number>;
|
|
44
|
-
visibleDetail: import("@angular/core").Signal<CbmDetailBySectionModel.SectionDetail[]>;
|
|
45
|
-
detailSectionAssignments: import("@angular/core").Signal<Map<string, string[]>>;
|
|
46
|
-
dropListIds: import("@angular/core").Signal<string[]>;
|
|
47
|
-
allSectionsConsolidated: import("@angular/core").Signal<boolean>;
|
|
48
|
-
setLabels(labels: Partial<ReturnType<typeof this.labels>>): void;
|
|
49
|
-
setDetail(input: Array<CbmDetailBySectionModel.InputDetail>): void;
|
|
50
|
-
reset(): void;
|
|
51
|
-
searchTerm(term: string): void;
|
|
52
|
-
createSection(): void;
|
|
53
|
-
distributeSections(): void;
|
|
54
|
-
startEditSectionTitle(index: number): void;
|
|
55
|
-
saveSectionTitle(index: number, value: string): void;
|
|
56
|
-
removeSection(index: number): void;
|
|
57
|
-
removeItemFromSection(sectionId: string, detailKey: string, event?: Event): void;
|
|
58
|
-
addItemsByTypeToSection(sectionIndex: number, type: CbmDetailBySectionModel.Type): void;
|
|
59
|
-
toggleSectionDetailVisibility(sectionIndex: number): void;
|
|
60
|
-
toggleAllSectionsDetailVisibility(): void;
|
|
61
|
-
isDetailAssigned(detailKey: string): boolean;
|
|
62
|
-
getDetailAssignedSections(detailKey: string): string[];
|
|
63
|
-
onDropToSection(event: CdkDragDrop<Array<CbmDetailBySectionModel.SectionDetail>>, targetSectionIndex: number): void;
|
|
64
|
-
getSectionDropListId(id: string): string;
|
|
65
|
-
getSectionsSnapshot(): Array<CbmDetailBySectionModel.SectionSnapshot>;
|
|
66
|
-
getDetailAmount(detail: Pick<CbmDetailBySectionModel.SectionDetail, 'amount'>): number;
|
|
67
|
-
getDetailTotal(detail: Pick<CbmDetailBySectionModel.SectionDetail, 'total' | 'total_price'>): number;
|
|
68
|
-
private getDistributionSectionDefinitions;
|
|
69
|
-
private getSourceDetails;
|
|
70
|
-
private getAvailableDetailsByType;
|
|
71
|
-
private getSourceDetailsByType;
|
|
72
|
-
private loadCategory;
|
|
73
|
-
private getDetailKey;
|
|
74
|
-
}
|
|
75
|
-
export {};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export declare namespace CbmDetailBySectionModel {
|
|
2
|
-
enum Type {
|
|
3
|
-
ITEM = "item",
|
|
4
|
-
SERVICE = "service",
|
|
5
|
-
SUBCONTRACTED = "subcontracted"
|
|
6
|
-
}
|
|
7
|
-
interface InputDetail {
|
|
8
|
-
_id?: string;
|
|
9
|
-
item_id: string;
|
|
10
|
-
item_code: string;
|
|
11
|
-
item_name: string;
|
|
12
|
-
amount: number;
|
|
13
|
-
total: number;
|
|
14
|
-
type: Type;
|
|
15
|
-
visible: boolean;
|
|
16
|
-
item_barcode?: string;
|
|
17
|
-
total_price?: number;
|
|
18
|
-
unit_measure_name?: string;
|
|
19
|
-
}
|
|
20
|
-
interface SectionDetail extends InputDetail {
|
|
21
|
-
key: string;
|
|
22
|
-
}
|
|
23
|
-
interface SectionSnapshot {
|
|
24
|
-
id: string;
|
|
25
|
-
title: string;
|
|
26
|
-
isDetailHidden: boolean;
|
|
27
|
-
subtotal: number;
|
|
28
|
-
items: Array<SectionDetail>;
|
|
29
|
-
}
|
|
30
|
-
}
|