hvp-shared 13.27.0 → 14.0.0

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.
@@ -24,6 +24,7 @@ export * from './force-majeure.enums';
24
24
  export * from './hris.constants';
25
25
  export * from './payroll-features.constants';
26
26
  export * from './inventory-session.enums';
27
+ export * from './shift-checklist.enums';
27
28
  export * from './documentation.enums';
28
29
  export * from './document.enums';
29
30
  export * from './settlement.enums';
@@ -40,6 +40,7 @@ __exportStar(require("./force-majeure.enums"), exports);
40
40
  __exportStar(require("./hris.constants"), exports);
41
41
  __exportStar(require("./payroll-features.constants"), exports);
42
42
  __exportStar(require("./inventory-session.enums"), exports);
43
+ __exportStar(require("./shift-checklist.enums"), exports);
43
44
  __exportStar(require("./documentation.enums"), exports);
44
45
  __exportStar(require("./document.enums"), exports);
45
46
  __exportStar(require("./settlement.enums"), exports);
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Shift Checklist Enums
3
+ *
4
+ * Enums for the shift checklist module. A master `ChecklistActivity` defines a
5
+ * recurring task; a `ChecklistDailyStatus` records, per `(branch, day, activity)`,
6
+ * whether it was done/skipped/not-done and who did it. There is no per-person
7
+ * "run" — status is tracked at the branch+day grain (the matrix model, GH#454).
8
+ */
9
+ /**
10
+ * When an activity applies (shown as a tag in the day checklist).
11
+ *
12
+ * - `check_in` (Entrada): start-of-shift tasks
13
+ * - `check_out` (Salida): end-of-shift tasks
14
+ * - `both` (Ambos): relevant at both entrada and salida
15
+ * - `any` (Indistinto): do it once, doesn't matter entrada or salida
16
+ *
17
+ * `both` / `any` are valid ONLY on an activity definition. A view is always
18
+ * requested for a single `check_in` OR `check_out` occasion.
19
+ */
20
+ export declare enum ChecklistMoment {
21
+ check_in = "check_in",
22
+ check_out = "check_out",
23
+ both = "both",
24
+ any = "any"
25
+ }
26
+ export declare const CHECKLIST_MOMENT_LABELS: Record<ChecklistMoment, string>;
27
+ /** Moments a view can be requested for (never `both` / `any`). */
28
+ export declare const VIEW_MOMENTS: Set<ChecklistMoment>;
29
+ /**
30
+ * Status of a task within a run (three conscious actions; "unmarked" = no action).
31
+ *
32
+ * - `done` (Hecho): the task was performed.
33
+ * - `skipped` (No hacía falta): evaluated and deemed unnecessary (e.g. the
34
+ * sanitary dispensers were already full). Carries a reason.
35
+ * - `not_done` (No se pudo): consciously not done because it couldn't be (e.g.
36
+ * missing material, no time). Carries a reason.
37
+ */
38
+ export declare enum ChecklistCompletionStatus {
39
+ done = "done",
40
+ not_done = "not_done",
41
+ skipped = "skipped"
42
+ }
43
+ export declare const CHECKLIST_COMPLETION_STATUS_LABELS: Record<ChecklistCompletionStatus, string>;
44
+ /** Tooltip help text per status (for the UI controls). */
45
+ export declare const CHECKLIST_COMPLETION_STATUS_HELP: Record<ChecklistCompletionStatus, string>;
46
+ /** Statuses that reset the overdue clock (i.e. count as "the task was done"). */
47
+ export declare const SATISFYING_COMPLETION_STATUSES: Set<ChecklistCompletionStatus>;
48
+ /**
49
+ * How an activity's doneness is scoped across branches.
50
+ *
51
+ * - `specific` (Sucursales específicas): applies to the listed `branchIds`;
52
+ * done/overdue tracked PER branch.
53
+ * - `each` (Todas — cada una): applies to every branch; each branch does
54
+ * its own; done/overdue tracked PER branch (e.g. "Barrer recepción").
55
+ * - `any` (Cualquier sucursal): done ONCE for the whole org regardless of
56
+ * branch; done/overdue tracked GLOBALLY (e.g. "Enviar recordatorios de vacuna").
57
+ */
58
+ export declare enum ChecklistBranchMode {
59
+ specific = "specific",
60
+ each = "each",
61
+ any = "any"
62
+ }
63
+ export declare const CHECKLIST_BRANCH_MODE_LABELS: Record<ChecklistBranchMode, string>;
64
+ /** Branch modes whose doneness is tracked per-branch (not global). */
65
+ export declare const PER_BRANCH_MODES: Set<ChecklistBranchMode>;
66
+ export declare enum ChecklistPriority {
67
+ high = "high",
68
+ medium = "medium",
69
+ low = "low"
70
+ }
71
+ export declare const CHECKLIST_PRIORITY_LABELS: Record<ChecklistPriority, string>;
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ /**
3
+ * Shift Checklist Enums
4
+ *
5
+ * Enums for the shift checklist module. A master `ChecklistActivity` defines a
6
+ * recurring task; a `ChecklistDailyStatus` records, per `(branch, day, activity)`,
7
+ * whether it was done/skipped/not-done and who did it. There is no per-person
8
+ * "run" — status is tracked at the branch+day grain (the matrix model, GH#454).
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.CHECKLIST_PRIORITY_LABELS = exports.ChecklistPriority = exports.PER_BRANCH_MODES = exports.CHECKLIST_BRANCH_MODE_LABELS = exports.ChecklistBranchMode = exports.SATISFYING_COMPLETION_STATUSES = exports.CHECKLIST_COMPLETION_STATUS_HELP = exports.CHECKLIST_COMPLETION_STATUS_LABELS = exports.ChecklistCompletionStatus = exports.VIEW_MOMENTS = exports.CHECKLIST_MOMENT_LABELS = exports.ChecklistMoment = void 0;
12
+ // --- Moment of shift ---
13
+ /**
14
+ * When an activity applies (shown as a tag in the day checklist).
15
+ *
16
+ * - `check_in` (Entrada): start-of-shift tasks
17
+ * - `check_out` (Salida): end-of-shift tasks
18
+ * - `both` (Ambos): relevant at both entrada and salida
19
+ * - `any` (Indistinto): do it once, doesn't matter entrada or salida
20
+ *
21
+ * `both` / `any` are valid ONLY on an activity definition. A view is always
22
+ * requested for a single `check_in` OR `check_out` occasion.
23
+ */
24
+ var ChecklistMoment;
25
+ (function (ChecklistMoment) {
26
+ ChecklistMoment["check_in"] = "check_in";
27
+ ChecklistMoment["check_out"] = "check_out";
28
+ ChecklistMoment["both"] = "both";
29
+ ChecklistMoment["any"] = "any";
30
+ })(ChecklistMoment || (exports.ChecklistMoment = ChecklistMoment = {}));
31
+ exports.CHECKLIST_MOMENT_LABELS = {
32
+ [ChecklistMoment.check_in]: "Entrada",
33
+ [ChecklistMoment.check_out]: "Salida",
34
+ [ChecklistMoment.both]: "Ambos",
35
+ [ChecklistMoment.any]: "Indistinto",
36
+ };
37
+ /** Moments a view can be requested for (never `both` / `any`). */
38
+ exports.VIEW_MOMENTS = new Set([
39
+ ChecklistMoment.check_in,
40
+ ChecklistMoment.check_out,
41
+ ]);
42
+ // --- Completion status ---
43
+ /**
44
+ * Status of a task within a run (three conscious actions; "unmarked" = no action).
45
+ *
46
+ * - `done` (Hecho): the task was performed.
47
+ * - `skipped` (No hacía falta): evaluated and deemed unnecessary (e.g. the
48
+ * sanitary dispensers were already full). Carries a reason.
49
+ * - `not_done` (No se pudo): consciously not done because it couldn't be (e.g.
50
+ * missing material, no time). Carries a reason.
51
+ */
52
+ var ChecklistCompletionStatus;
53
+ (function (ChecklistCompletionStatus) {
54
+ ChecklistCompletionStatus["done"] = "done";
55
+ ChecklistCompletionStatus["not_done"] = "not_done";
56
+ ChecklistCompletionStatus["skipped"] = "skipped";
57
+ })(ChecklistCompletionStatus || (exports.ChecklistCompletionStatus = ChecklistCompletionStatus = {}));
58
+ exports.CHECKLIST_COMPLETION_STATUS_LABELS = {
59
+ [ChecklistCompletionStatus.done]: "Hecho",
60
+ [ChecklistCompletionStatus.skipped]: "No hacía falta",
61
+ [ChecklistCompletionStatus.not_done]: "No se pudo",
62
+ };
63
+ /** Tooltip help text per status (for the UI controls). */
64
+ exports.CHECKLIST_COMPLETION_STATUS_HELP = {
65
+ [ChecklistCompletionStatus.done]: "Se realizó.",
66
+ [ChecklistCompletionStatus.skipped]: "Se evaluó y no era necesario hacerla (ej. las sanitas ya estaban llenas).",
67
+ [ChecklistCompletionStatus.not_done]: "Conscientemente no se hizo porque no se pudo (ej. faltó material, no dio tiempo).",
68
+ };
69
+ /** Statuses that reset the overdue clock (i.e. count as "the task was done"). */
70
+ exports.SATISFYING_COMPLETION_STATUSES = new Set([
71
+ ChecklistCompletionStatus.done,
72
+ ]);
73
+ // --- Branch mode (how an activity relates to branches) ---
74
+ /**
75
+ * How an activity's doneness is scoped across branches.
76
+ *
77
+ * - `specific` (Sucursales específicas): applies to the listed `branchIds`;
78
+ * done/overdue tracked PER branch.
79
+ * - `each` (Todas — cada una): applies to every branch; each branch does
80
+ * its own; done/overdue tracked PER branch (e.g. "Barrer recepción").
81
+ * - `any` (Cualquier sucursal): done ONCE for the whole org regardless of
82
+ * branch; done/overdue tracked GLOBALLY (e.g. "Enviar recordatorios de vacuna").
83
+ */
84
+ var ChecklistBranchMode;
85
+ (function (ChecklistBranchMode) {
86
+ ChecklistBranchMode["specific"] = "specific";
87
+ ChecklistBranchMode["each"] = "each";
88
+ ChecklistBranchMode["any"] = "any";
89
+ })(ChecklistBranchMode || (exports.ChecklistBranchMode = ChecklistBranchMode = {}));
90
+ exports.CHECKLIST_BRANCH_MODE_LABELS = {
91
+ [ChecklistBranchMode.specific]: "Sucursales específicas",
92
+ [ChecklistBranchMode.each]: "Todas (cada una)",
93
+ [ChecklistBranchMode.any]: "Cualquier sucursal",
94
+ };
95
+ /** Branch modes whose doneness is tracked per-branch (not global). */
96
+ exports.PER_BRANCH_MODES = new Set([
97
+ ChecklistBranchMode.specific,
98
+ ChecklistBranchMode.each,
99
+ ]);
100
+ // --- Priority ---
101
+ var ChecklistPriority;
102
+ (function (ChecklistPriority) {
103
+ ChecklistPriority["high"] = "high";
104
+ ChecklistPriority["medium"] = "medium";
105
+ ChecklistPriority["low"] = "low";
106
+ })(ChecklistPriority || (exports.ChecklistPriority = ChecklistPriority = {}));
107
+ exports.CHECKLIST_PRIORITY_LABELS = {
108
+ [ChecklistPriority.high]: "Alta",
109
+ [ChecklistPriority.medium]: "Media",
110
+ [ChecklistPriority.low]: "Baja",
111
+ };
@@ -13,6 +13,7 @@ export * from './time-off-request';
13
13
  export * from './force-majeure';
14
14
  export * from './job';
15
15
  export * from './inventory-session';
16
+ export * from './shift-checklist';
16
17
  export * from './client-billing';
17
18
  export * from './global-invoice';
18
19
  export * from './inventory-report';
@@ -29,6 +29,7 @@ __exportStar(require("./time-off-request"), exports);
29
29
  __exportStar(require("./force-majeure"), exports);
30
30
  __exportStar(require("./job"), exports);
31
31
  __exportStar(require("./inventory-session"), exports);
32
+ __exportStar(require("./shift-checklist"), exports);
32
33
  __exportStar(require("./client-billing"), exports);
33
34
  __exportStar(require("./global-invoice"), exports);
34
35
  __exportStar(require("./inventory-report"), exports);
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export * from './requests';
3
+ export * from './responses';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./requests"), exports);
19
+ __exportStar(require("./responses"), exports);
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Shift Checklist Request Types
3
+ *
4
+ * Request DTOs for the shift checklist endpoints (matrix model, GH#454).
5
+ *
6
+ * @example POST /api/shift-checklist/activities
7
+ * @example GET /api/shift-checklist/view
8
+ * @example POST /api/shift-checklist/record
9
+ */
10
+ import { ChecklistBranchMode, ChecklistCompletionStatus, ChecklistMoment, ChecklistPriority } from '../../constants/shift-checklist.enums';
11
+ /**
12
+ * Create a master checklist activity.
13
+ *
14
+ * @example POST /api/shift-checklist/activities
15
+ */
16
+ export interface CreateChecklistActivityRequest {
17
+ /** Concrete, verb-first action (location lives in the name when it matters) */
18
+ name: string;
19
+ /** Branch scope: specific (these branchIds) / each (all, per-branch) / any (global) */
20
+ branchMode: ChecklistBranchMode;
21
+ /** Branch ids the activity applies to (required when branchMode is `specific`) */
22
+ branchIds?: string[];
23
+ momentOfShift: ChecklistMoment;
24
+ /** When false, the activity is a visible reminder only (default true). */
25
+ isTracked?: boolean;
26
+ /** Days between occurrences; null = no fixed cadence (never overdue) */
27
+ frequencyDays?: number | null;
28
+ priority?: ChecklistPriority | null;
29
+ estimatedMinutes?: number | null;
30
+ /** How/when to do it: merged procedure + conditional notes (free text, may be multiline). */
31
+ instructions?: string;
32
+ requiresEvidence?: boolean;
33
+ }
34
+ /**
35
+ * Update a master checklist activity (partial).
36
+ *
37
+ * @example PATCH /api/shift-checklist/activities/:id
38
+ */
39
+ export interface UpdateChecklistActivityRequest {
40
+ name?: string;
41
+ branchMode?: ChecklistBranchMode;
42
+ branchIds?: string[];
43
+ momentOfShift?: ChecklistMoment;
44
+ isTracked?: boolean;
45
+ frequencyDays?: number | null;
46
+ priority?: ChecklistPriority | null;
47
+ estimatedMinutes?: number | null;
48
+ /** How/when to do it: merged procedure + conditional notes (free text, may be multiline). */
49
+ instructions?: string;
50
+ requiresEvidence?: boolean;
51
+ isActive?: boolean;
52
+ }
53
+ /**
54
+ * Filters for listing master activities.
55
+ *
56
+ * @example GET /api/shift-checklist/activities?branchId=...&momentOfShift=check_out&isActive=true
57
+ */
58
+ export interface ListChecklistActivitiesFilters {
59
+ branchId?: string;
60
+ momentOfShift?: ChecklistMoment;
61
+ isActive?: boolean;
62
+ }
63
+ /**
64
+ * Query for the day view: the activities for a branch + moment, each with its
65
+ * last-done history and today's status from the matrix. Run-less.
66
+ *
67
+ * @example GET /api/shift-checklist/view?momentOfShift=check_out&branchId=...
68
+ */
69
+ export interface GetChecklistViewQuery {
70
+ /** check_in or check_out (never both) — filters which activities show. */
71
+ momentOfShift: ChecklistMoment;
72
+ branchId: string;
73
+ /** YYYY-MM-DD (Mexico calendar day); defaults to today (America/Mexico_City) server-side */
74
+ shiftDate?: string;
75
+ }
76
+ /**
77
+ * A single activity's status to record for the day. Upserted into the matrix
78
+ * cell `(branchId, shiftDate, activityId)`; performers are unioned, not replaced.
79
+ */
80
+ export interface RecordChecklistStatusItem {
81
+ activityId: string;
82
+ status: ChecklistCompletionStatus;
83
+ /** who did it; defaults to [current user]. Multiple for shared tasks. */
84
+ performedByIds?: string[];
85
+ /** optional reason when status is "skipped" / "not_done" */
86
+ skipReason?: string;
87
+ notes?: string;
88
+ }
89
+ /**
90
+ * Batch upsert the day's status for one branch (idempotent per activity).
91
+ *
92
+ * @example POST /api/shift-checklist/record
93
+ */
94
+ export interface RecordChecklistStatusRequest {
95
+ branchId: string;
96
+ /** YYYY-MM-DD (Mexico calendar day); defaults to today server-side */
97
+ shiftDate?: string;
98
+ /** context only (which moment the user was in); not stored on the cell */
99
+ momentOfShift?: ChecklistMoment;
100
+ items: RecordChecklistStatusItem[];
101
+ }
102
+ /**
103
+ * Query filters for checklist statistics.
104
+ *
105
+ * @example GET /api/shift-checklist/stats?branchId=...&from=2026-06-01&to=2026-06-20
106
+ */
107
+ export interface ChecklistStatsQuery {
108
+ branchId?: string;
109
+ from?: string;
110
+ to?: string;
111
+ }
112
+ /**
113
+ * Create a one-off pendiente (just a title; stays open until resolved).
114
+ *
115
+ * @example POST /api/shift-checklist/pending-tasks
116
+ */
117
+ export interface CreateChecklistPendingTaskRequest {
118
+ title: string;
119
+ branchId: string;
120
+ }
121
+ /**
122
+ * Mark a pendiente done, recording who did it.
123
+ *
124
+ * @example PATCH /api/shift-checklist/pending-tasks/:id/resolve
125
+ */
126
+ export interface ResolveChecklistPendingTaskRequest {
127
+ performedByIds: string[];
128
+ }
129
+ /**
130
+ * Filters for listing pendientes.
131
+ *
132
+ * @example GET /api/shift-checklist/pending-tasks?branchId=...&includeResolved=false
133
+ */
134
+ export interface ListChecklistPendingTasksFilters {
135
+ branchId: string;
136
+ includeResolved?: boolean;
137
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ /**
3
+ * Shift Checklist Request Types
4
+ *
5
+ * Request DTOs for the shift checklist endpoints (matrix model, GH#454).
6
+ *
7
+ * @example POST /api/shift-checklist/activities
8
+ * @example GET /api/shift-checklist/view
9
+ * @example POST /api/shift-checklist/record
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Shift Checklist Response Types
3
+ *
4
+ * Response DTOs for the shift checklist endpoints. Dates are ISO 8601 strings.
5
+ * Model (GH#454): the day view is run-less — activities + their matrix status.
6
+ */
7
+ import { ChecklistBranchMode, ChecklistMoment, ChecklistPriority } from '../../constants/shift-checklist.enums';
8
+ import { ChecklistViewItem } from './types';
9
+ /**
10
+ * A master checklist activity.
11
+ *
12
+ * @example GET /api/shift-checklist/activities
13
+ */
14
+ export interface ChecklistActivityResponse {
15
+ id: string;
16
+ name: string;
17
+ branchMode: ChecklistBranchMode;
18
+ branchIds: string[];
19
+ momentOfShift: ChecklistMoment;
20
+ isTracked: boolean;
21
+ frequencyDays: number | null;
22
+ priority: ChecklistPriority | null;
23
+ estimatedMinutes: number | null;
24
+ /** How/when to do it: merged procedure + conditional notes (free text, may be multiline). */
25
+ instructions: string;
26
+ requiresEvidence: boolean;
27
+ isActive: boolean;
28
+ createdAt: string;
29
+ updatedAt: string;
30
+ createdBy: string;
31
+ updatedBy: string;
32
+ }
33
+ /**
34
+ * The assembled day view: the branch/day/moment context plus the activity rows
35
+ * (each with last-done, overdue, and today's status). Powers the checklist UI
36
+ * and the check-in/check-out modal. Run-less.
37
+ *
38
+ * @example GET /api/shift-checklist/view
39
+ * @example POST /api/shift-checklist/record (refreshed view)
40
+ */
41
+ export interface ChecklistViewResponse {
42
+ branchId: string;
43
+ branchName: string;
44
+ /** YYYY-MM-DD, Mexico calendar day */
45
+ shiftDate: string;
46
+ /** the moment requested (check_in | check_out) */
47
+ momentOfShift: ChecklistMoment;
48
+ items: ChecklistViewItem[];
49
+ }
50
+ /**
51
+ * Per-activity rollup over the period at a branch (the matrix, aggregated).
52
+ */
53
+ export interface ChecklistActivityStat {
54
+ activityId: string;
55
+ name: string;
56
+ /** distinct days the activity was DONE in range */
57
+ doneDays: number;
58
+ /** distinct days marked "No hacía falta" */
59
+ skippedDays: number;
60
+ /** distinct days marked "No se pudo" */
61
+ notDoneDays: number;
62
+ }
63
+ /**
64
+ * Per-branch checklist statistics over a period.
65
+ */
66
+ export interface ChecklistBranchStats {
67
+ branchId: string;
68
+ branchName: string;
69
+ /** matrix cells with status done in range */
70
+ doneCount: number;
71
+ /** matrix cells with status skipped in range */
72
+ skippedCount: number;
73
+ /** matrix cells with status not_done in range */
74
+ notDoneCount: number;
75
+ /** master activities currently overdue at this branch */
76
+ overdueActivityCount: number;
77
+ byActivity: ChecklistActivityStat[];
78
+ }
79
+ /**
80
+ * Checklist statistics over a period.
81
+ *
82
+ * @example GET /api/shift-checklist/stats
83
+ */
84
+ export interface ChecklistStatsResponse {
85
+ from: string | null;
86
+ to: string | null;
87
+ byBranch: ChecklistBranchStats[];
88
+ /** done cells in range */
89
+ totalDone: number;
90
+ /** all acted cells in range (done + skipped + not_done) */
91
+ totalActions: number;
92
+ }
93
+ /**
94
+ * A one-off "pendiente" — created on the fly, stays open per branch across shifts
95
+ * until someone marks it done (and only then records who did it).
96
+ *
97
+ * @example GET /api/shift-checklist/pending-tasks?branchId=...
98
+ */
99
+ export interface ChecklistPendingTaskResponse {
100
+ id: string;
101
+ title: string;
102
+ branchId: string;
103
+ isResolved: boolean;
104
+ doneByIds: string[];
105
+ doneByNames: string[];
106
+ doneAt: string | null;
107
+ createdBy: string;
108
+ createdAt: string;
109
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /**
3
+ * Shift Checklist Response Types
4
+ *
5
+ * Response DTOs for the shift checklist endpoints. Dates are ISO 8601 strings.
6
+ * Model (GH#454): the day view is run-less — activities + their matrix status.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Shift Checklist — shared building-block types
3
+ *
4
+ * Reusable shapes referenced by the endpoint responses. Dates are ISO 8601
5
+ * strings on the wire.
6
+ *
7
+ * Model (GH#454): status is tracked per `(branch, day, activity)` — the matrix.
8
+ * There is no per-person "run"/"completion"; multiple people who did the same
9
+ * task on the same day are merged into a single row's `doneBy` list.
10
+ */
11
+ import { ChecklistBranchMode, ChecklistCompletionStatus, ChecklistMoment, ChecklistPriority } from '../../constants/shift-checklist.enums';
12
+ /**
13
+ * Today's recorded status for an activity at a branch (one matrix cell).
14
+ * `null` on a view item means no action has been taken today.
15
+ */
16
+ export interface ChecklistTodayStatus {
17
+ status: ChecklistCompletionStatus;
18
+ /** Everyone who contributed today (union; nobody overwrites anyone). */
19
+ doneByIds: string[];
20
+ doneByNames: string[];
21
+ /** present when status is "skipped" / "not_done" */
22
+ skipReason: string | null;
23
+ notes: string;
24
+ /** when the latest action was recorded today */
25
+ lastActionAt: string | null;
26
+ }
27
+ /**
28
+ * One row in the day view: a master activity plus its last-done history and
29
+ * today's status (if any) at the viewed branch.
30
+ */
31
+ export interface ChecklistViewItem {
32
+ activityId: string;
33
+ name: string;
34
+ /** When the activity is meant to be done (shown as a tag in the day list). */
35
+ momentOfShift: ChecklistMoment;
36
+ /** Branch scope — `any` items count globally and are grouped apart. */
37
+ branchMode: ChecklistBranchMode;
38
+ /** When false, the activity is a visible reminder only — not marked/tracked. */
39
+ isTracked: boolean;
40
+ priority: ChecklistPriority | null;
41
+ estimatedMinutes: number | null;
42
+ instructions: string;
43
+ requiresEvidence: boolean;
44
+ frequencyDays: number | null;
45
+ /** last time this activity was DONE at this branch (drives overdue / "Última vez") */
46
+ lastDoneAt: string | null;
47
+ /** who did it last (may be several for a shared task) */
48
+ lastDoneByIds: string[];
49
+ lastDoneByNames: string[];
50
+ /**
51
+ * Most recent action on this activity at this branch, ANY status — for
52
+ * context when the last thing that happened was an omission (e.g. last done
53
+ * Jan 1 but last action was "omitida" yesterday). Null if never acted on.
54
+ */
55
+ lastAction: {
56
+ status: ChecklistCompletionStatus;
57
+ at: string;
58
+ byIds: string[];
59
+ byNames: string[];
60
+ skipReason: string | null;
61
+ notes: string;
62
+ } | null;
63
+ /** A full cadence was missed (Philosophy B). False when no cadence or never done. */
64
+ isOverdue: boolean;
65
+ /** today's matrix cell for this activity at this branch, if acted on */
66
+ today: ChecklistTodayStatus | null;
67
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ /**
3
+ * Shift Checklist — shared building-block types
4
+ *
5
+ * Reusable shapes referenced by the endpoint responses. Dates are ISO 8601
6
+ * strings on the wire.
7
+ *
8
+ * Model (GH#454): status is tracked per `(branch, day, activity)` — the matrix.
9
+ * There is no per-person "run"/"completion"; multiple people who did the same
10
+ * task on the same day are merged into a single row's `doneBy` list.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -9,3 +9,4 @@ export * from './email.validation';
9
9
  export * from './phone.validation';
10
10
  export * from './address.validation';
11
11
  export * from './document.validation';
12
+ export * from './shift-checklist.validation';
@@ -25,3 +25,4 @@ __exportStar(require("./email.validation"), exports);
25
25
  __exportStar(require("./phone.validation"), exports);
26
26
  __exportStar(require("./address.validation"), exports);
27
27
  __exportStar(require("./document.validation"), exports);
28
+ __exportStar(require("./shift-checklist.validation"), exports);
@@ -0,0 +1,12 @@
1
+ import { ValidationResult } from './rfc.validation';
2
+ /**
3
+ * Validates a checklist activity frequency (in days).
4
+ *
5
+ * The frequency is the number of days between occurrences of a recurring task.
6
+ * - `null`/`undefined` → no fixed cadence (valid; the task is never "overdue").
7
+ * - otherwise → must be an integer ≥ 1.
8
+ *
9
+ * @param value - frequency in days, or null/undefined for "no cadence"
10
+ * @returns ValidationResult with isValid flag and optional error message
11
+ */
12
+ export declare function validateChecklistFrequency(value: number | null | undefined): ValidationResult;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateChecklistFrequency = validateChecklistFrequency;
4
+ /**
5
+ * Validates a checklist activity frequency (in days).
6
+ *
7
+ * The frequency is the number of days between occurrences of a recurring task.
8
+ * - `null`/`undefined` → no fixed cadence (valid; the task is never "overdue").
9
+ * - otherwise → must be an integer ≥ 1.
10
+ *
11
+ * @param value - frequency in days, or null/undefined for "no cadence"
12
+ * @returns ValidationResult with isValid flag and optional error message
13
+ */
14
+ function validateChecklistFrequency(value) {
15
+ if (value === null || value === undefined) {
16
+ return { isValid: true };
17
+ }
18
+ if (typeof value !== 'number' || Number.isNaN(value) || !Number.isInteger(value)) {
19
+ return {
20
+ isValid: false,
21
+ error: 'La frecuencia debe ser un número entero de días',
22
+ };
23
+ }
24
+ if (value < 1) {
25
+ return { isValid: false, error: 'La frecuencia debe ser al menos 1 día' };
26
+ }
27
+ return { isValid: true };
28
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const shift_checklist_validation_1 = require("./shift-checklist.validation");
4
+ describe('validateChecklistFrequency', () => {
5
+ describe('valid frequencies', () => {
6
+ it('accepts null (no fixed cadence)', () => {
7
+ expect((0, shift_checklist_validation_1.validateChecklistFrequency)(null).isValid).toBe(true);
8
+ });
9
+ it('accepts undefined (no fixed cadence)', () => {
10
+ expect((0, shift_checklist_validation_1.validateChecklistFrequency)(undefined).isValid).toBe(true);
11
+ });
12
+ it('accepts 1 (daily)', () => {
13
+ expect((0, shift_checklist_validation_1.validateChecklistFrequency)(1).isValid).toBe(true);
14
+ });
15
+ it('accepts arbitrary positive integers', () => {
16
+ expect((0, shift_checklist_validation_1.validateChecklistFrequency)(7).isValid).toBe(true);
17
+ expect((0, shift_checklist_validation_1.validateChecklistFrequency)(30).isValid).toBe(true);
18
+ expect((0, shift_checklist_validation_1.validateChecklistFrequency)(45).isValid).toBe(true);
19
+ });
20
+ });
21
+ describe('invalid frequencies', () => {
22
+ it('rejects 0', () => {
23
+ const result = (0, shift_checklist_validation_1.validateChecklistFrequency)(0);
24
+ expect(result.isValid).toBe(false);
25
+ expect(result.error).toBeDefined();
26
+ });
27
+ it('rejects negative numbers', () => {
28
+ expect((0, shift_checklist_validation_1.validateChecklistFrequency)(-1).isValid).toBe(false);
29
+ });
30
+ it('rejects non-integers', () => {
31
+ expect((0, shift_checklist_validation_1.validateChecklistFrequency)(1.5).isValid).toBe(false);
32
+ });
33
+ it('rejects NaN', () => {
34
+ expect((0, shift_checklist_validation_1.validateChecklistFrequency)(Number.NaN).isValid).toBe(false);
35
+ });
36
+ });
37
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hvp-shared",
3
- "version": "13.27.0",
3
+ "version": "14.0.0",
4
4
  "description": "Shared types and utilities for HVP backend and frontend",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",