dabke 0.81.1 → 0.83.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.
Files changed (231) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +45 -27
  3. package/dist/client.d.ts +20 -2
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +4 -1
  6. package/dist/client.js.map +1 -1
  7. package/dist/client.types.d.ts +9 -0
  8. package/dist/client.types.d.ts.map +1 -1
  9. package/dist/client.types.js +1 -0
  10. package/dist/client.types.js.map +1 -1
  11. package/dist/cpsat/model-builder.d.ts +9 -0
  12. package/dist/cpsat/model-builder.d.ts.map +1 -1
  13. package/dist/cpsat/model-builder.js +36 -34
  14. package/dist/cpsat/model-builder.js.map +1 -1
  15. package/dist/cpsat/response.d.ts +13 -1
  16. package/dist/cpsat/response.d.ts.map +1 -1
  17. package/dist/cpsat/response.js +4 -0
  18. package/dist/cpsat/response.js.map +1 -1
  19. package/dist/cpsat/rules/cost-utils.d.ts +11 -0
  20. package/dist/cpsat/rules/cost-utils.d.ts.map +1 -0
  21. package/dist/cpsat/rules/cost-utils.js +24 -0
  22. package/dist/cpsat/rules/cost-utils.js.map +1 -0
  23. package/dist/cpsat/rules/day-cost-multiplier.d.ts.map +1 -1
  24. package/dist/cpsat/rules/day-cost-multiplier.js +3 -14
  25. package/dist/cpsat/rules/day-cost-multiplier.js.map +1 -1
  26. package/dist/cpsat/rules/day-cost-surcharge.d.ts.map +1 -1
  27. package/dist/cpsat/rules/day-cost-surcharge.js +3 -7
  28. package/dist/cpsat/rules/day-cost-surcharge.js.map +1 -1
  29. package/dist/cpsat/rules/index.d.ts +3 -0
  30. package/dist/cpsat/rules/index.d.ts.map +1 -1
  31. package/dist/cpsat/rules/index.js +3 -0
  32. package/dist/cpsat/rules/index.js.map +1 -1
  33. package/dist/cpsat/rules/max-consecutive-days.d.ts.map +1 -1
  34. package/dist/cpsat/rules/max-consecutive-days.js +16 -2
  35. package/dist/cpsat/rules/max-consecutive-days.js.map +1 -1
  36. package/dist/cpsat/rules/max-days-week.d.ts +44 -0
  37. package/dist/cpsat/rules/max-days-week.d.ts.map +1 -0
  38. package/dist/cpsat/rules/max-days-week.js +95 -0
  39. package/dist/cpsat/rules/max-days-week.js.map +1 -0
  40. package/dist/cpsat/rules/max-hours-day.d.ts.map +1 -1
  41. package/dist/cpsat/rules/max-hours-day.js +15 -2
  42. package/dist/cpsat/rules/max-hours-day.js.map +1 -1
  43. package/dist/cpsat/rules/max-hours-week.d.ts.map +1 -1
  44. package/dist/cpsat/rules/max-hours-week.js +16 -2
  45. package/dist/cpsat/rules/max-hours-week.js.map +1 -1
  46. package/dist/cpsat/rules/max-shifts-day.d.ts.map +1 -1
  47. package/dist/cpsat/rules/max-shifts-day.js +15 -2
  48. package/dist/cpsat/rules/max-shifts-day.js.map +1 -1
  49. package/dist/cpsat/rules/min-consecutive-days.d.ts.map +1 -1
  50. package/dist/cpsat/rules/min-consecutive-days.js +15 -2
  51. package/dist/cpsat/rules/min-consecutive-days.js.map +1 -1
  52. package/dist/cpsat/rules/min-days-week.d.ts +34 -0
  53. package/dist/cpsat/rules/min-days-week.d.ts.map +1 -0
  54. package/dist/cpsat/rules/min-days-week.js +84 -0
  55. package/dist/cpsat/rules/min-days-week.js.map +1 -0
  56. package/dist/cpsat/rules/min-hours-day.d.ts.map +1 -1
  57. package/dist/cpsat/rules/min-hours-day.js +15 -2
  58. package/dist/cpsat/rules/min-hours-day.js.map +1 -1
  59. package/dist/cpsat/rules/min-hours-week.d.ts.map +1 -1
  60. package/dist/cpsat/rules/min-hours-week.js +16 -2
  61. package/dist/cpsat/rules/min-hours-week.js.map +1 -1
  62. package/dist/cpsat/rules/min-rest-between-shifts.d.ts.map +1 -1
  63. package/dist/cpsat/rules/min-rest-between-shifts.js +72 -2
  64. package/dist/cpsat/rules/min-rest-between-shifts.js.map +1 -1
  65. package/dist/cpsat/rules/minimize-cost.d.ts.map +1 -1
  66. package/dist/cpsat/rules/minimize-cost.js +2 -23
  67. package/dist/cpsat/rules/minimize-cost.js.map +1 -1
  68. package/dist/cpsat/rules/must-assign.d.ts +49 -0
  69. package/dist/cpsat/rules/must-assign.d.ts.map +1 -0
  70. package/dist/cpsat/rules/must-assign.js +86 -0
  71. package/dist/cpsat/rules/must-assign.js.map +1 -0
  72. package/dist/cpsat/rules/overtime-daily-multiplier.d.ts.map +1 -1
  73. package/dist/cpsat/rules/overtime-daily-multiplier.js +1 -12
  74. package/dist/cpsat/rules/overtime-daily-multiplier.js.map +1 -1
  75. package/dist/cpsat/rules/overtime-daily-surcharge.d.ts.map +1 -1
  76. package/dist/cpsat/rules/overtime-daily-surcharge.js +1 -5
  77. package/dist/cpsat/rules/overtime-daily-surcharge.js.map +1 -1
  78. package/dist/cpsat/rules/overtime-tiered-multiplier.d.ts +5 -1
  79. package/dist/cpsat/rules/overtime-tiered-multiplier.d.ts.map +1 -1
  80. package/dist/cpsat/rules/overtime-tiered-multiplier.js +1 -12
  81. package/dist/cpsat/rules/overtime-tiered-multiplier.js.map +1 -1
  82. package/dist/cpsat/rules/overtime-weekly-multiplier.d.ts.map +1 -1
  83. package/dist/cpsat/rules/overtime-weekly-multiplier.js +1 -12
  84. package/dist/cpsat/rules/overtime-weekly-multiplier.js.map +1 -1
  85. package/dist/cpsat/rules/overtime-weekly-surcharge.d.ts.map +1 -1
  86. package/dist/cpsat/rules/overtime-weekly-surcharge.js +1 -5
  87. package/dist/cpsat/rules/overtime-weekly-surcharge.js.map +1 -1
  88. package/dist/cpsat/rules/registry.d.ts +28 -2
  89. package/dist/cpsat/rules/registry.d.ts.map +1 -1
  90. package/dist/cpsat/rules/registry.js +4 -1
  91. package/dist/cpsat/rules/registry.js.map +1 -1
  92. package/dist/cpsat/rules/resolver.js +2 -2
  93. package/dist/cpsat/rules/resolver.js.map +1 -1
  94. package/dist/cpsat/rules/rules.types.d.ts +3 -0
  95. package/dist/cpsat/rules/rules.types.d.ts.map +1 -1
  96. package/dist/cpsat/rules/scope.types.d.ts +18 -1
  97. package/dist/cpsat/rules/scope.types.d.ts.map +1 -1
  98. package/dist/cpsat/rules/scope.types.js +59 -16
  99. package/dist/cpsat/rules/scope.types.js.map +1 -1
  100. package/dist/cpsat/rules/time-cost-surcharge.d.ts.map +1 -1
  101. package/dist/cpsat/rules/time-cost-surcharge.js +2 -1
  102. package/dist/cpsat/rules/time-cost-surcharge.js.map +1 -1
  103. package/dist/cpsat/rules/time-off.d.ts.map +1 -1
  104. package/dist/cpsat/rules/time-off.js +6 -3
  105. package/dist/cpsat/rules/time-off.js.map +1 -1
  106. package/dist/cpsat/semantic-time.d.ts +44 -42
  107. package/dist/cpsat/semantic-time.d.ts.map +1 -1
  108. package/dist/cpsat/semantic-time.js +64 -46
  109. package/dist/cpsat/semantic-time.js.map +1 -1
  110. package/dist/cpsat/types.d.ts +37 -27
  111. package/dist/cpsat/types.d.ts.map +1 -1
  112. package/dist/cpsat/utils.d.ts.map +1 -1
  113. package/dist/cpsat/utils.js +7 -12
  114. package/dist/cpsat/utils.js.map +1 -1
  115. package/dist/cpsat/validation-reporter.d.ts +10 -7
  116. package/dist/cpsat/validation-reporter.d.ts.map +1 -1
  117. package/dist/cpsat/validation-reporter.js +44 -72
  118. package/dist/cpsat/validation-reporter.js.map +1 -1
  119. package/dist/cpsat/validation.types.d.ts +54 -44
  120. package/dist/cpsat/validation.types.d.ts.map +1 -1
  121. package/dist/cpsat/validation.types.js +15 -10
  122. package/dist/cpsat/validation.types.js.map +1 -1
  123. package/dist/datetime.utils.d.ts +3 -203
  124. package/dist/datetime.utils.d.ts.map +1 -1
  125. package/dist/datetime.utils.js +1 -288
  126. package/dist/datetime.utils.js.map +1 -1
  127. package/dist/index.d.ts +14 -83
  128. package/dist/index.d.ts.map +1 -1
  129. package/dist/index.js +11 -83
  130. package/dist/index.js.map +1 -1
  131. package/dist/schedule/cost.d.ts +204 -0
  132. package/dist/schedule/cost.d.ts.map +1 -0
  133. package/dist/schedule/cost.js +187 -0
  134. package/dist/schedule/cost.js.map +1 -0
  135. package/dist/schedule/coverage.d.ts +85 -0
  136. package/dist/schedule/coverage.d.ts.map +1 -0
  137. package/dist/schedule/coverage.js +33 -0
  138. package/dist/schedule/coverage.js.map +1 -0
  139. package/dist/schedule/definition.d.ts +227 -0
  140. package/dist/schedule/definition.d.ts.map +1 -0
  141. package/dist/schedule/definition.js +659 -0
  142. package/dist/schedule/definition.js.map +1 -0
  143. package/dist/schedule/index.d.ts +67 -0
  144. package/dist/schedule/index.d.ts.map +1 -0
  145. package/dist/schedule/index.js +69 -0
  146. package/dist/schedule/index.js.map +1 -0
  147. package/dist/schedule/rules.d.ts +353 -0
  148. package/dist/schedule/rules.d.ts.map +1 -0
  149. package/dist/schedule/rules.js +352 -0
  150. package/dist/schedule/rules.js.map +1 -0
  151. package/dist/schedule/shift-patterns.d.ts +34 -0
  152. package/dist/schedule/shift-patterns.d.ts.map +1 -0
  153. package/dist/schedule/shift-patterns.js +41 -0
  154. package/dist/schedule/shift-patterns.js.map +1 -0
  155. package/dist/schedule/time-periods.d.ts +69 -0
  156. package/dist/schedule/time-periods.d.ts.map +1 -0
  157. package/dist/schedule/time-periods.js +91 -0
  158. package/dist/schedule/time-periods.js.map +1 -0
  159. package/dist/types.d.ts +14 -78
  160. package/dist/types.d.ts.map +1 -1
  161. package/dist/types.js.map +1 -1
  162. package/package.json +4 -9
  163. package/solver/src/solver/app.py +1 -1
  164. package/solver/src/solver/solver.py +7 -4
  165. package/src/client.ts +6 -8
  166. package/src/client.types.ts +9 -0
  167. package/src/cpsat/model-builder.ts +44 -35
  168. package/src/cpsat/response.ts +13 -1
  169. package/src/cpsat/rules/cost-utils.ts +25 -0
  170. package/src/cpsat/rules/day-cost-multiplier.ts +3 -14
  171. package/src/cpsat/rules/day-cost-surcharge.ts +3 -8
  172. package/src/cpsat/rules/index.ts +3 -0
  173. package/src/cpsat/rules/max-consecutive-days.ts +17 -0
  174. package/src/cpsat/rules/max-days-week.ts +143 -0
  175. package/src/cpsat/rules/max-hours-day.ts +21 -1
  176. package/src/cpsat/rules/max-hours-week.ts +22 -1
  177. package/src/cpsat/rules/max-shifts-day.ts +21 -1
  178. package/src/cpsat/rules/min-consecutive-days.ts +16 -1
  179. package/src/cpsat/rules/min-days-week.ts +120 -0
  180. package/src/cpsat/rules/min-hours-day.ts +16 -1
  181. package/src/cpsat/rules/min-hours-week.ts +17 -1
  182. package/src/cpsat/rules/min-rest-between-shifts.ts +92 -2
  183. package/src/cpsat/rules/minimize-cost.ts +2 -29
  184. package/src/cpsat/rules/must-assign.ts +108 -0
  185. package/src/cpsat/rules/overtime-daily-multiplier.ts +1 -12
  186. package/src/cpsat/rules/overtime-daily-surcharge.ts +1 -6
  187. package/src/cpsat/rules/overtime-tiered-multiplier.ts +6 -13
  188. package/src/cpsat/rules/overtime-weekly-multiplier.ts +1 -12
  189. package/src/cpsat/rules/overtime-weekly-surcharge.ts +1 -6
  190. package/src/cpsat/rules/registry.ts +8 -2
  191. package/src/cpsat/rules/resolver.ts +2 -2
  192. package/src/cpsat/rules/rules.types.ts +3 -0
  193. package/src/cpsat/rules/scope.types.ts +73 -20
  194. package/src/cpsat/rules/time-cost-surcharge.ts +2 -1
  195. package/src/cpsat/rules/time-off.ts +6 -2
  196. package/src/cpsat/semantic-time.ts +115 -91
  197. package/src/cpsat/types.ts +37 -27
  198. package/src/cpsat/utils.ts +8 -12
  199. package/src/cpsat/validation-reporter.ts +51 -82
  200. package/src/cpsat/validation.types.ts +72 -47
  201. package/src/datetime.utils.ts +3 -334
  202. package/src/index.ts +35 -107
  203. package/src/schedule/cost.ts +242 -0
  204. package/src/schedule/coverage.ts +135 -0
  205. package/src/schedule/definition.ts +958 -0
  206. package/src/schedule/index.ts +112 -0
  207. package/src/schedule/rules.ts +529 -0
  208. package/src/schedule/shift-patterns.ts +46 -0
  209. package/src/schedule/time-periods.ts +110 -0
  210. package/src/types.ts +14 -88
  211. package/dist/errors.d.ts +0 -12
  212. package/dist/errors.d.ts.map +0 -1
  213. package/dist/errors.js +0 -17
  214. package/dist/errors.js.map +0 -1
  215. package/dist/llms.d.ts +0 -2
  216. package/dist/llms.d.ts.map +0 -1
  217. package/dist/llms.js +0 -3
  218. package/dist/llms.js.map +0 -1
  219. package/dist/schedule.d.ts +0 -724
  220. package/dist/schedule.d.ts.map +0 -1
  221. package/dist/schedule.js +0 -899
  222. package/dist/schedule.js.map +0 -1
  223. package/dist/validation.d.ts +0 -105
  224. package/dist/validation.d.ts.map +0 -1
  225. package/dist/validation.js +0 -130
  226. package/dist/validation.js.map +0 -1
  227. package/llms.txt +0 -925
  228. package/src/errors.ts +0 -17
  229. package/src/llms.ts +0 -3
  230. package/src/schedule.ts +0 -1419
  231. package/src/validation.ts +0 -188
@@ -1,23 +1,4 @@
1
1
  import type { TimeOfDay } from "../types.js";
2
- declare const GroupKeyBrand: unique symbol;
3
- /**
4
- * Branded type for validation group keys.
5
- * Groups related validation items that originated from the same instruction.
6
- */
7
- export type GroupKey = string & {
8
- readonly [GroupKeyBrand]: never;
9
- };
10
- /**
11
- * Creates a GroupKey from a description string.
12
- * Use this to create keys that group related validation items together.
13
- *
14
- * @example
15
- * ```typescript
16
- * const key = groupKey("2x waiter during lunch");
17
- * coverage.groupKey = key;
18
- * ```
19
- */
20
- export declare function groupKey(description: string): GroupKey;
21
2
  /**
22
3
  * Context shared across validation results for grouping/display.
23
4
  */
@@ -26,30 +7,53 @@ export interface ValidationContext {
26
7
  timeSlots?: string[];
27
8
  memberIds?: string[];
28
9
  }
10
+ /**
11
+ * Groups related validation items under a deterministic, structural key.
12
+ *
13
+ * The `key` is derived from the rule/coverage structure (e.g.,
14
+ * `"rule:max-hours-week:40:roles:nurse"`), ensuring that identical
15
+ * configurations always produce the same key. The `title` is the
16
+ * human-readable label shown in summaries.
17
+ *
18
+ * Rule authors create groups via {@link ruleGroup} in `scope.types.ts`;
19
+ * coverage groups are produced by the semantic-time resolver.
20
+ */
21
+ export interface ValidationGroup {
22
+ /** Deterministic key derived from rule/coverage structure. */
23
+ readonly key: string;
24
+ /** Human-readable label for summaries (e.g., "Max 40h per week"). */
25
+ readonly title: string;
26
+ }
27
+ /**
28
+ * Throws if a value contains characters used as key delimiters.
29
+ * Call before interpolating user-provided IDs into group keys.
30
+ */
31
+ export declare function assertSafeKeySegment(value: string, label: string): void;
32
+ export declare function assertSafeKeySegments(values: readonly string[], label: string): void;
29
33
  export interface CoverageError {
30
34
  readonly id: string;
31
35
  readonly type: "coverage";
32
36
  readonly day: string;
33
37
  readonly timeSlots: readonly string[];
34
- readonly roles?: string[];
35
- readonly skills?: readonly string[];
36
- readonly reason: string;
38
+ readonly roleIds?: string[];
39
+ readonly skillIds?: readonly string[];
40
+ readonly message: string;
37
41
  readonly suggestions?: readonly string[];
38
- readonly groupKey?: GroupKey;
42
+ readonly group?: ValidationGroup;
39
43
  }
40
44
  export interface RuleError {
41
45
  readonly id: string;
42
46
  readonly type: "rule";
43
47
  readonly rule: string;
44
- readonly reason: string;
48
+ readonly message: string;
45
49
  readonly context: ValidationContext;
46
50
  readonly suggestions?: readonly string[];
47
- readonly groupKey?: GroupKey;
51
+ readonly group?: ValidationGroup;
48
52
  }
49
53
  export interface SolverError {
50
54
  readonly id: string;
51
55
  readonly type: "solver";
52
- readonly reason: string;
56
+ readonly message: string;
53
57
  }
54
58
  export type ScheduleError = CoverageError | RuleError | SolverError;
55
59
  export interface CoverageViolation {
@@ -57,22 +61,23 @@ export interface CoverageViolation {
57
61
  readonly type: "coverage";
58
62
  readonly day: string;
59
63
  readonly timeSlots: readonly string[];
60
- readonly roles?: string[];
61
- readonly skills?: readonly string[];
64
+ readonly roleIds?: string[];
65
+ readonly skillIds?: readonly string[];
62
66
  readonly targetCount: number;
63
67
  readonly actualCount: number;
64
68
  readonly shortfall: number;
65
- readonly groupKey?: GroupKey;
69
+ readonly message: string;
70
+ readonly group?: ValidationGroup;
66
71
  }
67
72
  export interface RuleViolation {
68
73
  readonly id: string;
69
74
  readonly type: "rule";
70
75
  readonly rule: string;
71
- readonly reason: string;
76
+ readonly message: string;
72
77
  readonly context: ValidationContext;
73
78
  readonly shortfall?: number;
74
79
  readonly overflow?: number;
75
- readonly groupKey?: GroupKey;
80
+ readonly group?: ValidationGroup;
76
81
  }
77
82
  export type ScheduleViolation = CoverageViolation | RuleViolation;
78
83
  export interface CoveragePassed {
@@ -80,20 +85,21 @@ export interface CoveragePassed {
80
85
  readonly type: "coverage";
81
86
  readonly day: string;
82
87
  readonly timeSlots: readonly string[];
83
- readonly roles?: string[];
84
- readonly skills?: readonly string[];
85
- readonly description: string;
86
- readonly groupKey?: GroupKey;
88
+ readonly roleIds?: string[];
89
+ readonly skillIds?: readonly string[];
90
+ readonly message: string;
91
+ readonly group?: ValidationGroup;
87
92
  }
88
93
  export interface RulePassed {
89
94
  readonly id: string;
90
95
  readonly type: "rule";
91
96
  readonly rule: string;
92
- readonly description: string;
97
+ readonly message: string;
93
98
  readonly context: ValidationContext;
94
- readonly groupKey?: GroupKey;
99
+ readonly group?: ValidationGroup;
95
100
  }
96
101
  export type SchedulePassed = CoveragePassed | RulePassed;
102
+ /** @category Validation */
97
103
  export interface ScheduleValidation {
98
104
  readonly errors: readonly ScheduleError[];
99
105
  readonly violations: readonly ScheduleViolation[];
@@ -101,12 +107,16 @@ export interface ScheduleValidation {
101
107
  }
102
108
  /**
103
109
  * Summary of validation items grouped by their source instruction.
104
- * Use `summarizeValidation()` to create these from a ScheduleValidation.
110
+ * Use `summarizeValidation()` to create these from a `ScheduleValidation`.
111
+ *
112
+ * @category Validation
105
113
  */
106
114
  export interface ValidationSummary {
107
- readonly groupKey: GroupKey;
115
+ /** Deterministic group key derived from rule/coverage structure. */
116
+ readonly groupKey: string;
108
117
  readonly type: "coverage" | "rule";
109
- readonly description: string;
118
+ /** Human-readable title for this group (e.g., "3x nurse during day_ward"). */
119
+ readonly title: string;
110
120
  readonly days: readonly string[];
111
121
  readonly status: "passed" | "partial" | "failed";
112
122
  readonly passedCount: number;
@@ -117,15 +127,16 @@ export interface TrackedConstraint {
117
127
  readonly id: string;
118
128
  readonly type: "coverage" | "rule";
119
129
  readonly rule?: string;
130
+ /** Per-constraint description used to generate violation messages. */
120
131
  readonly description: string;
121
132
  readonly targetValue: number;
122
133
  readonly comparator: "<=" | ">=";
123
134
  readonly day?: string;
124
135
  readonly timeSlot?: string;
125
- readonly roles?: string[];
126
- readonly skills?: readonly string[];
136
+ readonly roleIds?: string[];
137
+ readonly skillIds?: readonly string[];
127
138
  readonly context: ValidationContext;
128
- readonly groupKey?: GroupKey;
139
+ readonly group?: ValidationGroup;
129
140
  }
130
141
  /**
131
142
  * Coverage exclusion - indicates a team member is unavailable for coverage during a time period.
@@ -137,5 +148,4 @@ export interface CoverageExclusion {
137
148
  startTime?: TimeOfDay;
138
149
  endTime?: TimeOfDay;
139
150
  }
140
- export {};
141
151
  //# sourceMappingURL=validation.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation.types.d.ts","sourceRoot":"","sources":["../../src/cpsat/validation.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAM7C,OAAO,CAAC,MAAM,aAAa,EAAE,OAAO,MAAM,CAAC;AAE3C;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,aAAa,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAEpE;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,QAAQ,CAEtD;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAMD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC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,MAAM,CAAC;IACnC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,sEAAsE;IACtE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB"}
@@ -1,14 +1,19 @@
1
+ // =============================================================================
2
+ // Key safety helpers
3
+ // =============================================================================
4
+ const KEY_DELIMITERS = /[,:/+]/;
1
5
  /**
2
- * Creates a GroupKey from a description string.
3
- * Use this to create keys that group related validation items together.
4
- *
5
- * @example
6
- * ```typescript
7
- * const key = groupKey("2x waiter during lunch");
8
- * coverage.groupKey = key;
9
- * ```
6
+ * Throws if a value contains characters used as key delimiters.
7
+ * Call before interpolating user-provided IDs into group keys.
10
8
  */
11
- export function groupKey(description) {
12
- return description;
9
+ export function assertSafeKeySegment(value, label) {
10
+ if (KEY_DELIMITERS.test(value)) {
11
+ throw new Error(`${label} "${value}" contains reserved delimiter characters (: , / +)`);
12
+ }
13
+ }
14
+ export function assertSafeKeySegments(values, label) {
15
+ for (const v of values) {
16
+ assertSafeKeySegment(v, label);
17
+ }
13
18
  }
14
19
  //# sourceMappingURL=validation.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation.types.js","sourceRoot":"","sources":["../../src/cpsat/validation.types.ts"],"names":[],"mappings":"AAcA;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CAAC,WAAmB;IAC1C,OAAO,WAAuB,CAAC;AACjC,CAAC"}
1
+ {"version":3,"file":"validation.types.js","sourceRoot":"","sources":["../../src/cpsat/validation.types.ts"],"names":[],"mappings":"AAiCA,gFAAgF;AAChF,qBAAqB;AACrB,gFAAgF;AAEhF,MAAM,cAAc,GAAG,QAAQ,CAAC;AAEhC;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAa,EAAE,KAAa;IAC/D,IAAI,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,KAAK,KAAK,oDAAoD,CAAC,CAAC;IAC1F,CAAC;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAAyB,EAAE,KAAa;IAC5E,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,oBAAoB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC;AACH,CAAC"}
@@ -1,210 +1,10 @@
1
- import { CalendarDate, DateTime, DateTimeRange, DayOfWeek, SchedulingPeriod } from "./types.js";
1
+ import type { DayOfWeek, SchedulingPeriod } from "./types.js";
2
+ export declare const DAY_OF_WEEK_MAP: Record<DayOfWeek, number>;
2
3
  /**
3
- * Converts a JavaScript Date to a CalendarDate
4
- */
5
- export declare function dateToCalendarDate(date: Date): CalendarDate;
6
- /**
7
- * Converts a DateTime to a JavaScript Date
8
- * Internal helper function
9
- */
10
- export declare function dateTimeToDate(dateTime: DateTime): Date;
11
- /**
12
- * Compares two DateTimes
13
- * Returns:
14
- * -1 if dateTime1 < dateTime2
15
- * 0 if dateTime1 = dateTime2
16
- * 1 if dateTime1 > dateTime2
17
- */
18
- export declare function compareDateTimes(dateTime1: DateTime, dateTime2: DateTime): number;
19
- export declare const DAY_OF_WEEK_MAP: {
20
- sunday: number;
21
- monday: number;
22
- tuesday: number;
23
- wednesday: number;
24
- thursday: number;
25
- friday: number;
26
- saturday: number;
27
- };
28
- /**
29
- * Helper to get the day of week name from a Date (local time)
30
- */
31
- export declare function toDayOfWeek(date: Date): DayOfWeek;
32
- /**
33
- * Helper to get the day of week name from a Date (UTC)
4
+ * Helper to get the day of week name from a Date (UTC).
34
5
  * Use this when working with date strings like "2026-01-10" that are timezone-agnostic.
35
6
  */
36
7
  export declare function toDayOfWeekUTC(date: Date): DayOfWeek;
37
- /**
38
- * Formats a date as YYYY-MM-DD string
39
- */
40
- export declare function formatDateString(date: Date): string;
41
- /**
42
- * Generates an array of day strings (YYYY-MM-DD) from a time horizon.
43
- *
44
- * @param horizon - The time horizon with start (inclusive) and end (inclusive) dates
45
- * @returns Array of day strings in YYYY-MM-DD format
46
- *
47
- * @example
48
- * ```typescript
49
- * const days = generateDays({
50
- * start: new Date('2025-01-01'),
51
- * end: new Date('2025-01-04')
52
- * });
53
- * // Returns: ["2025-01-01", "2025-01-02", "2025-01-03", "2025-01-04"]
54
- * ```
55
- */
56
- export declare function generateDays(horizon: {
57
- start: Date;
58
- end: Date;
59
- }): string[];
60
- /**
61
- * Splits a time period into consecutive day ranges.
62
- *
63
- * Each range represents a single calendar day within the period from start to end.
64
- * This is useful for rules that need to apply constraints on a per-day basis,
65
- * such as maximum or minimum hours per day.
66
- *
67
- * @param start - The start date of the period (inclusive)
68
- * @param end - The end date of the period (exclusive)
69
- * @returns An array of [startDate, endDate] tuples, where each tuple represents
70
- * a single day. The last range's end date will be the provided end date.
71
- *
72
- * @example
73
- * ```typescript
74
- * const ranges = splitPeriodIntoDays({
75
- * start: new Date('2025-01-01'),
76
- * end: new Date('2025-01-03')
77
- * });
78
- * // Returns:
79
- * // [
80
- * // [Date('2025-01-01'), Date('2025-01-02')],
81
- * // [Date('2025-01-02'), Date('2025-01-03')]
82
- * // ]
83
- * ```
84
- */
85
- export declare function splitPeriodIntoDays({ start, end }: {
86
- start: Date;
87
- end: Date;
88
- }): [Date, Date][];
89
- /**
90
- * Splits a time period into consecutive week ranges.
91
- *
92
- * Each range represents a week period starting on the specified day of the week.
93
- * This is useful for rules that need to apply constraints on a per-week basis,
94
- * such as maximum or minimum hours per week.
95
- *
96
- * The first range starts at the provided start date (not necessarily on weekStartsOn).
97
- * Subsequent ranges align to the weekStartsOn day. The last range's end date will be
98
- * the provided end date.
99
- *
100
- * @param start - The start date of the period (inclusive)
101
- * @param end - The end date of the period (exclusive)
102
- * @param weekStartsOn - The day of the week that weeks start on (e.g., "monday", "sunday")
103
- * @returns An array of [startDate, endDate] tuples, where each tuple represents
104
- * a week period aligned to the specified week start day.
105
- *
106
- * @example
107
- * ```typescript
108
- * const ranges = splitPeriodIntoWeeks({
109
- * start: new Date('2025-01-01'), // Wednesday
110
- * end: new Date('2025-01-15'),
111
- * weekStartsOn: 'monday'
112
- * });
113
- * // Returns ranges starting from Jan 1 (Wed), then aligning to Mondays:
114
- * // [
115
- * // [Date('2025-01-01 Wed'), Date('2025-01-06 Mon')],
116
- * // [Date('2025-01-06 Mon'), Date('2025-01-13 Mon')],
117
- * // [Date('2025-01-13 Mon'), Date('2025-01-15 Wed')]
118
- * // ]
119
- * ```
120
- */
121
- export declare function splitPeriodIntoWeeks({ start, end, weekStartsOn, }: {
122
- start: Date;
123
- end: Date;
124
- weekStartsOn: DayOfWeek;
125
- }): [Date, Date][];
126
- /**
127
- * Checks if two DateTime ranges overlap in both date and time.
128
- * Ranges overlap if they share any moment in time.
129
- *
130
- * Two ranges overlap if: range1.start < range2.end AND range2.start < range1.end
131
- *
132
- * @param range1 First time range with start (inclusive) and end (exclusive)
133
- * @param range2 Second time range with start (inclusive) and end (exclusive)
134
- * @returns true if ranges overlap, false otherwise
135
- *
136
- * @example
137
- * ```typescript
138
- * // Same day, overlapping times (9-17 overlaps with 12-20)
139
- * dateTimeRangesOverlap(
140
- * {
141
- * start: { year: 2025, month: 6, day: 1, hours: 9, minutes: 0 },
142
- * end: { year: 2025, month: 6, day: 1, hours: 17, minutes: 0 }
143
- * },
144
- * {
145
- * start: { year: 2025, month: 6, day: 1, hours: 12, minutes: 0 },
146
- * end: { year: 2025, month: 6, day: 1, hours: 20, minutes: 0 }
147
- * }
148
- * ); // true
149
- *
150
- * // Different days - no overlap
151
- * dateTimeRangesOverlap(
152
- * {
153
- * start: { year: 2025, month: 6, day: 1, hours: 9, minutes: 0 },
154
- * end: { year: 2025, month: 6, day: 1, hours: 17, minutes: 0 }
155
- * },
156
- * {
157
- * start: { year: 2025, month: 6, day: 2, hours: 9, minutes: 0 },
158
- * end: { year: 2025, month: 6, day: 2, hours: 17, minutes: 0 }
159
- * }
160
- * ); // false
161
- *
162
- * // Works naturally with Shift objects
163
- * dateTimeRangesOverlap(
164
- * { start: shift1.startDateTime, end: shift1.endDateTime },
165
- * { start: shift2.startDateTime, end: shift2.endDateTime }
166
- * );
167
- * ```
168
- */
169
- export declare function dateTimeRangesOverlap(range1: DateTimeRange, range2: DateTimeRange): boolean;
170
- /**
171
- * Calculates the number of complete days between two dates
172
- * @param start The start date
173
- * @param end The end date
174
- * @returns Number of complete days from start to end (can be negative if end < start)
175
- *
176
- * @example
177
- * ```typescript
178
- * daysBetween(new Date('2025-01-01'), new Date('2025-01-05')); // 4
179
- * ```
180
- */
181
- export declare function daysBetween(start: Date, end: Date): number;
182
- /**
183
- * Adds a number of minutes to a base date and returns a DateTime.
184
- * Treats the base date as a reference point (typically midnight of horizon start),
185
- * and the minutes parameter as absolute minutes from that point.
186
- *
187
- * @param baseDate The starting date (used as reference point)
188
- * @param minutes Absolute minutes from the base date
189
- * @returns DateTime representing the result
190
- *
191
- * @example
192
- * ```typescript
193
- * // Add 90 minutes from midnight
194
- * addMinutesToDate(new Date('2025-01-01'), 90);
195
- * // Returns: { year: 2025, month: 1, day: 1, hours: 1, minutes: 30 }
196
- *
197
- * // Add 1500 minutes (spans to next day)
198
- * addMinutesToDate(new Date('2025-01-01'), 1500);
199
- * // Returns: { year: 2025, month: 1, day: 2, hours: 1, minutes: 0 }
200
- * ```
201
- */
202
- export declare function addMinutesToDate(baseDate: Date, minutes: number): DateTime;
203
- /**
204
- * Returns the points where a range should be split, filtered to within [start, end).
205
- * Always includes range start. Sorted ascending.
206
- */
207
- export declare function splitPoints([start, end]: [number, number], splitAt: number[]): number[];
208
8
  /**
209
9
  * Computes the list of day strings (YYYY-MM-DD) from a SchedulingPeriod.
210
10
  *
@@ -1 +1 @@
1
- {"version":3,"file":"datetime.utils.d.ts","sourceRoot":"","sources":["../src/datetime.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEhG;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,YAAY,CAM3D;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CASvD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,GAAG,MAAM,CAOjF;AAED,eAAO,MAAM,eAAe;;;;;;;;CAQ3B,CAAC;AAYF;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,CAGjD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,CAGpD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAKnD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,IAAI,CAAA;CAAE,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