hvp-shared 13.35.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.
@@ -1,11 +1,10 @@
1
1
  /**
2
2
  * Shift Checklist Enums
3
3
  *
4
- * Enums for the shift checklist module: a per-occasion ("run") list of recurring
5
- * tasks a collaborator reviews at check-in and before checkout. A master
6
- * `ChecklistActivity` defines the recurring task; a `ChecklistRun` is one
7
- * occasion (collaborator + moment + day); a `ChecklistCompletion` records a task
8
- * done/not-done within a run.
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).
9
8
  */
10
9
  /**
11
10
  * When an activity applies (shown as a tag in the day checklist).
@@ -15,8 +14,8 @@
15
14
  * - `both` (Ambos): relevant at both entrada and salida
16
15
  * - `any` (Indistinto): do it once, doesn't matter entrada or salida
17
16
  *
18
- * `both` / `any` are valid ONLY on an activity definition. A run/completion
19
- * occasion is always `check_in` OR `check_out`.
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.
20
19
  */
21
20
  export declare enum ChecklistMoment {
22
21
  check_in = "check_in",
@@ -25,8 +24,8 @@ export declare enum ChecklistMoment {
25
24
  any = "any"
26
25
  }
27
26
  export declare const CHECKLIST_MOMENT_LABELS: Record<ChecklistMoment, string>;
28
- /** Moments valid for a run/completion occasion (never `both` / `any`). */
29
- export declare const RUN_MOMENTS: Set<ChecklistMoment>;
27
+ /** Moments a view can be requested for (never `both` / `any`). */
28
+ export declare const VIEW_MOMENTS: Set<ChecklistMoment>;
30
29
  /**
31
30
  * Status of a task within a run (three conscious actions; "unmarked" = no action).
32
31
  *
@@ -70,14 +69,3 @@ export declare enum ChecklistPriority {
70
69
  low = "low"
71
70
  }
72
71
  export declare const CHECKLIST_PRIORITY_LABELS: Record<ChecklistPriority, string>;
73
- /**
74
- * Lifecycle of a per-occasion checklist run.
75
- *
76
- * - `open`: created, collaborator filling it
77
- * - `submitted`: collaborator confirmed/submitted the run
78
- */
79
- export declare enum ChecklistRunStatus {
80
- open = "open",
81
- submitted = "submitted"
82
- }
83
- export declare const CHECKLIST_RUN_STATUS_LABELS: Record<ChecklistRunStatus, string>;
@@ -2,14 +2,13 @@
2
2
  /**
3
3
  * Shift Checklist Enums
4
4
  *
5
- * Enums for the shift checklist module: a per-occasion ("run") list of recurring
6
- * tasks a collaborator reviews at check-in and before checkout. A master
7
- * `ChecklistActivity` defines the recurring task; a `ChecklistRun` is one
8
- * occasion (collaborator + moment + day); a `ChecklistCompletion` records a task
9
- * done/not-done within a run.
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).
10
9
  */
11
10
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.CHECKLIST_RUN_STATUS_LABELS = exports.ChecklistRunStatus = 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.RUN_MOMENTS = exports.CHECKLIST_MOMENT_LABELS = exports.ChecklistMoment = void 0;
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;
13
12
  // --- Moment of shift ---
14
13
  /**
15
14
  * When an activity applies (shown as a tag in the day checklist).
@@ -19,8 +18,8 @@ exports.CHECKLIST_RUN_STATUS_LABELS = exports.ChecklistRunStatus = exports.CHECK
19
18
  * - `both` (Ambos): relevant at both entrada and salida
20
19
  * - `any` (Indistinto): do it once, doesn't matter entrada or salida
21
20
  *
22
- * `both` / `any` are valid ONLY on an activity definition. A run/completion
23
- * occasion is always `check_in` OR `check_out`.
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.
24
23
  */
25
24
  var ChecklistMoment;
26
25
  (function (ChecklistMoment) {
@@ -35,8 +34,8 @@ exports.CHECKLIST_MOMENT_LABELS = {
35
34
  [ChecklistMoment.both]: "Ambos",
36
35
  [ChecklistMoment.any]: "Indistinto",
37
36
  };
38
- /** Moments valid for a run/completion occasion (never `both` / `any`). */
39
- exports.RUN_MOMENTS = new Set([
37
+ /** Moments a view can be requested for (never `both` / `any`). */
38
+ exports.VIEW_MOMENTS = new Set([
40
39
  ChecklistMoment.check_in,
41
40
  ChecklistMoment.check_out,
42
41
  ]);
@@ -110,19 +109,3 @@ exports.CHECKLIST_PRIORITY_LABELS = {
110
109
  [ChecklistPriority.medium]: "Media",
111
110
  [ChecklistPriority.low]: "Baja",
112
111
  };
113
- // --- Run status ---
114
- /**
115
- * Lifecycle of a per-occasion checklist run.
116
- *
117
- * - `open`: created, collaborator filling it
118
- * - `submitted`: collaborator confirmed/submitted the run
119
- */
120
- var ChecklistRunStatus;
121
- (function (ChecklistRunStatus) {
122
- ChecklistRunStatus["open"] = "open";
123
- ChecklistRunStatus["submitted"] = "submitted";
124
- })(ChecklistRunStatus || (exports.ChecklistRunStatus = ChecklistRunStatus = {}));
125
- exports.CHECKLIST_RUN_STATUS_LABELS = {
126
- [ChecklistRunStatus.open]: "Abierto",
127
- [ChecklistRunStatus.submitted]: "Enviado",
128
- };
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * Shift Checklist Request Types
3
3
  *
4
- * Request DTOs for the shift checklist endpoints.
4
+ * Request DTOs for the shift checklist endpoints (matrix model, GH#454).
5
5
  *
6
- * @example POST /api/shift-checklist/activities
7
- * @example GET /api/shift-checklist/runs/view
8
- * @example POST /api/shift-checklist/runs/:id/completions/batch
6
+ * @example POST /api/shift-checklist/activities
7
+ * @example GET /api/shift-checklist/view
8
+ * @example POST /api/shift-checklist/record
9
9
  */
10
10
  import { ChecklistBranchMode, ChecklistCompletionStatus, ChecklistMoment, ChecklistPriority } from '../../constants/shift-checklist.enums';
11
11
  /**
@@ -61,51 +61,43 @@ export interface ListChecklistActivitiesFilters {
61
61
  isActive?: boolean;
62
62
  }
63
63
  /**
64
- * Query for the checkout view (find-or-create a run + its assembled view).
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.
65
66
  *
66
- * @example GET /api/shift-checklist/runs/view?momentOfShift=check_out&branchId=...
67
+ * @example GET /api/shift-checklist/view?momentOfShift=check_out&branchId=...
67
68
  */
68
69
  export interface GetChecklistViewQuery {
69
- /** check_in or check_out (never both) */
70
+ /** check_in or check_out (never both) — filters which activities show. */
70
71
  momentOfShift: ChecklistMoment;
71
72
  branchId: string;
72
- /** YYYY-MM-DD; defaults to today (America/Mexico_City) server-side */
73
+ /** YYYY-MM-DD (Mexico calendar day); defaults to today (America/Mexico_City) server-side */
73
74
  shiftDate?: string;
74
- /** link to the realized attendance occasion (TimeShift) when opened from checkout */
75
- attendanceRecordId?: string;
76
75
  }
77
76
  /**
78
- * Update a run (e.g. correct the branch for the whole run, or add notes).
79
- *
80
- * @example PATCH /api/shift-checklist/runs/:id
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.
81
79
  */
82
- export interface UpdateChecklistRunRequest {
83
- branchId?: string;
84
- notes?: string;
85
- }
86
- /**
87
- * A single completion to record/update within a run.
88
- * Either `activityId` (master task) or `adHocTitle` (ad-hoc task) must be set.
89
- */
90
- export interface RecordCompletionItemRequest {
91
- /** null/omitted = ad-hoc task (requires adHocTitle) */
92
- activityId?: string | null;
93
- adHocTitle?: string;
80
+ export interface RecordChecklistStatusItem {
81
+ activityId: string;
94
82
  status: ChecklistCompletionStatus;
95
83
  /** who did it; defaults to [current user]. Multiple for shared tasks. */
96
84
  performedByIds?: string[];
97
- /** required when status is "skipped" */
85
+ /** optional reason when status is "skipped" / "not_done" */
98
86
  skipReason?: string;
99
87
  notes?: string;
100
- evidenceUrl?: string | null;
101
88
  }
102
89
  /**
103
- * Batch upsert completions in a run (idempotent per activity).
90
+ * Batch upsert the day's status for one branch (idempotent per activity).
104
91
  *
105
- * @example POST /api/shift-checklist/runs/:id/completions/batch
92
+ * @example POST /api/shift-checklist/record
106
93
  */
107
- export interface RecordCompletionsBatchRequest {
108
- items: RecordCompletionItemRequest[];
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[];
109
101
  }
110
102
  /**
111
103
  * Query filters for checklist statistics.
@@ -2,10 +2,10 @@
2
2
  /**
3
3
  * Shift Checklist Request Types
4
4
  *
5
- * Request DTOs for the shift checklist endpoints.
5
+ * Request DTOs for the shift checklist endpoints (matrix model, GH#454).
6
6
  *
7
- * @example POST /api/shift-checklist/activities
8
- * @example GET /api/shift-checklist/runs/view
9
- * @example POST /api/shift-checklist/runs/:id/completions/batch
7
+ * @example POST /api/shift-checklist/activities
8
+ * @example GET /api/shift-checklist/view
9
+ * @example POST /api/shift-checklist/record
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -2,9 +2,10 @@
2
2
  * Shift Checklist Response Types
3
3
  *
4
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.
5
6
  */
6
- import { ChecklistBranchMode, ChecklistMoment, ChecklistPriority, ChecklistRunStatus } from '../../constants/shift-checklist.enums';
7
- import { ChecklistAdHocItem, ChecklistCheckoutItem } from './types';
7
+ import { ChecklistBranchMode, ChecklistMoment, ChecklistPriority } from '../../constants/shift-checklist.enums';
8
+ import { ChecklistViewItem } from './types';
8
9
  /**
9
10
  * A master checklist activity.
10
11
  *
@@ -30,43 +31,50 @@ export interface ChecklistActivityResponse {
30
31
  updatedBy: string;
31
32
  }
32
33
  /**
33
- * A per-occasion checklist run.
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.
34
37
  *
35
- * @example GET /api/shift-checklist/runs/view
38
+ * @example GET /api/shift-checklist/view
39
+ * @example POST /api/shift-checklist/record (refreshed view)
36
40
  */
37
- export interface ChecklistRunResponse {
38
- id: string;
39
- collaboratorId: string;
41
+ export interface ChecklistViewResponse {
40
42
  branchId: string;
41
43
  branchName: string;
42
- momentOfShift: ChecklistMoment;
44
+ /** YYYY-MM-DD, Mexico calendar day */
43
45
  shiftDate: string;
44
- attendanceRecordId: string | null;
45
- status: ChecklistRunStatus;
46
- submittedAt: string | null;
47
- notes: string;
46
+ /** the moment requested (check_in | check_out) */
47
+ momentOfShift: ChecklistMoment;
48
+ items: ChecklistViewItem[];
48
49
  }
49
50
  /**
50
- * The assembled checkout view: the run, its activity rows (with last-done +
51
- * overdue), and any ad-hoc items. Powers the checkout modal.
52
- *
53
- * @example GET /api/shift-checklist/runs/view
54
- * @example POST /api/shift-checklist/runs/:id/completions/batch (refreshed view)
51
+ * Per-activity rollup over the period at a branch (the matrix, aggregated).
55
52
  */
56
- export interface ChecklistCheckoutViewResponse {
57
- run: ChecklistRunResponse;
58
- items: ChecklistCheckoutItem[];
59
- adHocItems: ChecklistAdHocItem[];
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;
60
62
  }
63
+ /**
64
+ * Per-branch checklist statistics over a period.
65
+ */
61
66
  export interface ChecklistBranchStats {
62
67
  branchId: string;
63
68
  branchName: string;
64
- totalCompletions: number;
69
+ /** matrix cells with status done in range */
65
70
  doneCount: number;
66
- notDoneCount: number;
71
+ /** matrix cells with status skipped in range */
67
72
  skippedCount: number;
73
+ /** matrix cells with status not_done in range */
74
+ notDoneCount: number;
68
75
  /** master activities currently overdue at this branch */
69
76
  overdueActivityCount: number;
77
+ byActivity: ChecklistActivityStat[];
70
78
  }
71
79
  /**
72
80
  * Checklist statistics over a period.
@@ -77,9 +85,10 @@ export interface ChecklistStatsResponse {
77
85
  from: string | null;
78
86
  to: string | null;
79
87
  byBranch: ChecklistBranchStats[];
80
- totalRuns: number;
81
- /** done completions / total completions, 0..1 */
82
- completionRate: number;
88
+ /** done cells in range */
89
+ totalDone: number;
90
+ /** all acted cells in range (done + skipped + not_done) */
91
+ totalActions: number;
83
92
  }
84
93
  /**
85
94
  * A one-off "pendiente" — created on the fly, stays open per branch across shifts
@@ -3,5 +3,6 @@
3
3
  * Shift Checklist Response Types
4
4
  *
5
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.
6
7
  */
7
8
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,43 +1,34 @@
1
1
  /**
2
2
  * Shift Checklist — shared building-block types
3
3
  *
4
- * Reusable shapes referenced by the endpoint responses (checkout view items,
5
- * completion shape). Dates are ISO 8601 strings on the wire.
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.
6
10
  */
7
11
  import { ChecklistBranchMode, ChecklistCompletionStatus, ChecklistMoment, ChecklistPriority } from '../../constants/shift-checklist.enums';
8
12
  /**
9
- * A recorded completion of a task within a run (or an ad-hoc task).
10
- *
11
- * @example POST /api/shift-checklist/runs/:id/completions/batch
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.
12
15
  */
13
- export interface ChecklistCompletionResponse {
14
- id: string;
15
- runId: string;
16
- /** null = ad-hoc task (not on the master list) */
17
- activityId: string | null;
18
- /** present when activityId is null */
19
- adHocTitle: string | null;
16
+ export interface ChecklistTodayStatus {
20
17
  status: ChecklistCompletionStatus;
21
- /** present when status is "skipped" */
18
+ /** Everyone who contributed today (union; nobody overwrites anyone). */
19
+ doneByIds: string[];
20
+ doneByNames: string[];
21
+ /** present when status is "skipped" / "not_done" */
22
22
  skipReason: string | null;
23
- /** who performed the task (one or more, for shared tasks) */
24
- performedByIds: string[];
25
- performedByNames: string[];
26
- /** who logged the completion */
27
- reportedById: string;
28
- evidenceUrl: string | null;
29
23
  notes: string;
30
- completedAt: string | null;
31
- /** denormalized from the run */
32
- branchId: string;
33
- shiftDate: string;
34
- momentOfShift: ChecklistMoment;
24
+ /** when the latest action was recorded today */
25
+ lastActionAt: string | null;
35
26
  }
36
27
  /**
37
- * One row in the checkout view: a master activity plus its last-done history and
38
- * this run's completion (if any).
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.
39
30
  */
40
- export interface ChecklistCheckoutItem {
31
+ export interface ChecklistViewItem {
41
32
  activityId: string;
42
33
  name: string;
43
34
  /** When the activity is meant to be done (shown as a tag in the day list). */
@@ -51,7 +42,7 @@ export interface ChecklistCheckoutItem {
51
42
  instructions: string;
52
43
  requiresEvidence: boolean;
53
44
  frequencyDays: number | null;
54
- /** last time this activity was DONE at this branch (drives overdue) */
45
+ /** last time this activity was DONE at this branch (drives overdue / "Última vez") */
55
46
  lastDoneAt: string | null;
56
47
  /** who did it last (may be several for a shared task) */
57
48
  lastDoneByIds: string[];
@@ -69,18 +60,8 @@ export interface ChecklistCheckoutItem {
69
60
  skipReason: string | null;
70
61
  notes: string;
71
62
  } | null;
72
- /** lastDoneAt + frequencyDays < now (false when no cadence or never done) */
63
+ /** A full cadence was missed (Philosophy B). False when no cadence or never done. */
73
64
  isOverdue: boolean;
74
- /** this run's completion for the activity, if recorded */
75
- completion: ChecklistCompletionResponse | null;
76
- }
77
- /** An ad-hoc task added during a run (not tied to a master activity). */
78
- export interface ChecklistAdHocItem {
79
- id: string;
80
- adHocTitle: string;
81
- status: ChecklistCompletionStatus;
82
- performedByIds: string[];
83
- performedByNames: string[];
84
- completedAt: string | null;
85
- notes: string;
65
+ /** today's matrix cell for this activity at this branch, if acted on */
66
+ today: ChecklistTodayStatus | null;
86
67
  }
@@ -2,7 +2,11 @@
2
2
  /**
3
3
  * Shift Checklist — shared building-block types
4
4
  *
5
- * Reusable shapes referenced by the endpoint responses (checkout view items,
6
- * completion shape). Dates are ISO 8601 strings on the wire.
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.
7
11
  */
8
12
  Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hvp-shared",
3
- "version": "13.35.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",